Topics

[PATCH 8/8] gpio: gpio_dw: Add suport for device_register_pm_ops()


dirk.brandewie@...
 

From: Dirk Brandewie <dirk.j.brandewie(a)intel.com>

Change-Id: Ib989e2a45b7c97728b79b4908d6d0aa8d0957999
Signed-off-by: Dirk Brandewie <dirk.j.brandewie(a)intel.com>
---
drivers/gpio/gpio_dw.c | 24 +++++++++++++++++++++++-
drivers/gpio/gpio_dw.h | 2 ++
2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio_dw.c b/drivers/gpio/gpio_dw.c
index 4b3da49..db84ee9 100644
--- a/drivers/gpio/gpio_dw.c
+++ b/drivers/gpio/gpio_dw.c
@@ -280,18 +280,39 @@ static inline int gpio_dw_disable_callback(struct device *port, int access_op,

static inline int gpio_dw_suspend_port(struct device *port)
{
+ struct gpio_dw_runtime *context = port->driver_data;
+
_gpio_dw_clock_off(port);
+ if (context->pm_ops->suspend) {
+ context->pm_ops->suspend(context->pm_context);
+ }

return 0;
}

static inline int gpio_dw_resume_port(struct device *port)
{
+ struct gpio_dw_runtime *context = port->driver_data;
+
_gpio_dw_clock_on(port);
+ if (context->pm_ops->resume) {
+ context->pm_ops->resume(context->pm_context);
+ }

return 0;
}

+static inline void gpio_dw_register_pm_ops(struct device *port,
+ struct pm_ops *pm_ops,
+ void *pm_context)
+{
+ struct gpio_dw_runtime *context = port->driver_data;
+
+ context->pm_ops = pm_ops;
+ context->pm_context = pm_context;
+}
+
+
#ifdef CONFIG_SOC_QUARK_SE
static inline void gpio_dw_unmask_int(uint32_t mask_addr)
{
@@ -417,7 +438,8 @@ int gpio_dw_initialize(struct device *port)

struct device_ops gpio_dw_dev_ops = {
.suspend = gpio_dw_suspend_port,
- .resume = gpio_dw_resume_port
+ .resume = gpio_dw_resume_port,
+ .register_pm_ops = gpio_dw_register_pm_ops
};

/* Bindings to the plaform */
diff --git a/drivers/gpio/gpio_dw.h b/drivers/gpio/gpio_dw.h
index a5f82f0..88dbbad 100644
--- a/drivers/gpio/gpio_dw.h
+++ b/drivers/gpio/gpio_dw.h
@@ -55,6 +55,8 @@ struct gpio_dw_runtime {
gpio_callback_t callback;
uint32_t enabled_callbacks;
uint8_t port_callback;
+ struct pm_ops *pm_ops;
+ void *pm_context;
};

#ifdef __cplusplus
--
2.4.3