Add this function to allow other modules to configure the GPIO interface of SM501 Signed-off-by: yajin <yajin@xxxxxxxxxxxxx> --- drivers/mfd/sm501.c | 28 ++++++++++++++++++++++++++++ include/linux/sm501.h | 3 +++ 2 files changed, 31 insertions(+), 0 deletions(-) diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c index ab560fe..ce5dfce 100644 --- a/drivers/mfd/sm501.c +++ b/drivers/mfd/sm501.c @@ -1145,6 +1145,27 @@ static inline int sm501_gpio_isregistered(struct sm501_devdata *sm) { return sm->gpio.registered; } + +int sm501_configure_gpio(struct device *dev, unsigned int gpio, + unsigned char mode) +{ + int reg, offset, set; + + offset = 0; + set = 0; + + if (offset >= 32) { + reg = SM501_GPIO63_32_CONTROL; + offset = gpio - 32; + } else + reg = SM501_GPIO31_0_CONTROL; + + if (mode) + set = 1<<offset; + + sm501_modify_reg(dev, reg, set, 1<<offset); + return 0; +} #else static inline int sm501_register_gpio(struct sm501_devdata *sm) { @@ -1164,7 +1185,14 @@ static inline int sm501_gpio_isregistered(struct sm501_devdata *sm) { return 0; } + +int sm501_configure_gpio(struct device *dev, unsigned int gpio, + unsigned char mode) +{ + return -1; +} #endif +EXPORT_SYMBOL_GPL(sm501_configure_gpio); static int sm501_register_gpio_i2c_instance(struct sm501_devdata *sm, struct sm501_platdata_gpio_i2c *iic) diff --git a/include/linux/sm501.h b/include/linux/sm501.h index 0a4287e..c33b3b3 100644 --- a/include/linux/sm501.h +++ b/include/linux/sm501.h @@ -27,6 +27,9 @@ extern unsigned long sm501_set_clock(struct device *dev, extern unsigned long sm501_find_clock(struct device *dev, int clksrc, unsigned long req_freq); +extern int sm501_configure_gpio(struct device *dev, + unsigned int gpio, unsigned char mode); + /* sm501_misc_control * * Modify the SM501's MISC_CONTROL register -- 1.5.6.5