diff options
author | Bengt Jonsson <bengt.g.jonsson@stericsson.com> | 2011-03-30 14:11:27 +0200 |
---|---|---|
committer | Henrik CARLING <henrik.carling@stericsson.com> | 2011-03-30 20:58:53 +0200 |
commit | 984cc7fd240a26262e1608c066eeeb2a4ece8dde (patch) | |
tree | be60b5f472ddaeed8c640998bce1dbce6de5c056 /drivers/gpio | |
parent | 22d5089814fb52bbb9bdcf106685cf2d9374e86e (diff) |
regulator Added regulator for sysclkreq and connected BT and WLANu8500-android-2.3_v0.48
ST-Ericsson Linux next: -
ST-Ericsson ID: ER 324615
ST-Ericsson FOSS-OUT ID: Trivial
Change-Id: I616eda9d8e292c05dd8094d8085f5b488ee90396
Signed-off-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/19533
Reviewed-by: Par-Gunnar HJALMDAHL <par-gunnar.p.hjalmdahl@stericsson.com>
Reviewed-by: Yvan FILLION <yvan.fillion@stericsson.com>
Tested-by: Yvan FILLION <yvan.fillion@stericsson.com>
Reviewed-by: Henrik CARLING <henrik.carling@stericsson.com>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/ab8500-gpio.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/drivers/gpio/ab8500-gpio.c b/drivers/gpio/ab8500-gpio.c index e276bea49b9..262151a7400 100644 --- a/drivers/gpio/ab8500-gpio.c +++ b/drivers/gpio/ab8500-gpio.c @@ -506,6 +506,69 @@ int ab8500_config_pull_up_or_down(struct device *dev, } EXPORT_SYMBOL(ab8500_config_pull_up_or_down); +/* + * ab8500_gpio_config_select() + * + * Configure functionality of pin, either specific use or GPIO. + * @dev: device pointer + * @gpio: gpio number + * @gpio_select: true if the pin should be used as GPIO + */ +int ab8500_gpio_config_select(struct device *dev, + unsigned gpio, bool gpio_select) +{ + u8 offset = gpio - AB8500_PIN_GPIO1; + u8 reg = AB8500_GPIO_SEL1_REG + (offset / 8); + u8 pos = offset % 8; + u8 val = gpio_select ? 1 : 0; + int ret; + + ret = abx500_mask_and_set_register_interruptible(dev, + AB8500_MISC, reg, 1 << pos, val << pos); + if (ret < 0) + dev_err(dev, "%s write failed\n", __func__); + + dev_vdbg(dev, "%s (bank, addr, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n", + __func__, AB8500_MISC, reg, 1 << pos, val << pos); + + return ret; +} + +/* + * ab8500_gpio_config_get_select() + * + * Configure functionality of pin, either specific use or GPIO. + * @dev: device pointer + * @gpio: gpio number + * @gpio_select: pointer to pin selection status + */ +int ab8500_gpio_config_get_select(struct device *dev, + unsigned gpio, bool *gpio_select) +{ + u8 offset = gpio - AB8500_PIN_GPIO1; + u8 reg = AB8500_GPIO_SEL1_REG + (offset / 8); + u8 pos = offset % 8; + u8 val; + int ret; + + ret = abx500_get_register_interruptible(dev, + AB8500_MISC, reg, &val); + if (ret < 0) { + dev_err(dev, "%s read failed\n", __func__); + return ret; + } + + if (val & (1 << pos)) + *gpio_select = true; + else + *gpio_select = false; + + dev_vdbg(dev, "%s (bank, addr, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n", + __func__, AB8500_MISC, reg, 1 << pos, val); + + return 0; +} + static struct platform_driver ab8500_gpio_driver = { .driver = { .name = "ab8500-gpio", |