summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-max77620.c
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2016-05-24 09:13:46 -0400
committerLinus Walleij <linus.walleij@linaro.org>2016-06-07 03:35:16 -0400
commit23087a05006057bbaa2c1f42163e45586dd77094 (patch)
tree0f7c9117289db0c5f1e632fa1fbe01c701bae11c /drivers/gpio/gpio-max77620.c
parentff93ec74966a84538a8129d7d8303a7f841a69c4 (diff)
gpio: max77620: use the new open drain callback
The MAX77620 have a GPIO pins which can act as open drain or push pull mode. Implement support for controlling this from GPIO descriptor tables or other hardware descriptions such as device tree by implementing the .set_single_ended() callback. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-max77620.c')
-rw-r--r--drivers/gpio/gpio-max77620.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-max77620.c b/drivers/gpio/gpio-max77620.c
index 35f365c36df9..8658c32c4690 100644
--- a/drivers/gpio/gpio-max77620.c
+++ b/drivers/gpio/gpio-max77620.c
@@ -202,6 +202,28 @@ static void max77620_gpio_set(struct gpio_chip *gc, unsigned int offset,
202 dev_err(mgpio->dev, "CNFG_GPIO_OUT update failed: %d\n", ret); 202 dev_err(mgpio->dev, "CNFG_GPIO_OUT update failed: %d\n", ret);
203} 203}
204 204
205static int max77620_gpio_set_single_ended(struct gpio_chip *gc,
206 unsigned int offset,
207 enum single_ended_mode mode)
208{
209 struct max77620_gpio *mgpio = gpiochip_get_data(gc);
210
211 switch (mode) {
212 case LINE_MODE_OPEN_DRAIN:
213 return regmap_update_bits(mgpio->rmap, GPIO_REG_ADDR(offset),
214 MAX77620_CNFG_GPIO_DRV_MASK,
215 MAX77620_CNFG_GPIO_DRV_OPENDRAIN);
216 case LINE_MODE_PUSH_PULL:
217 return regmap_update_bits(mgpio->rmap, GPIO_REG_ADDR(offset),
218 MAX77620_CNFG_GPIO_DRV_MASK,
219 MAX77620_CNFG_GPIO_DRV_PUSHPULL);
220 default:
221 break;
222 }
223
224 return -ENOTSUPP;
225}
226
205static int max77620_gpio_to_irq(struct gpio_chip *gc, unsigned int offset) 227static int max77620_gpio_to_irq(struct gpio_chip *gc, unsigned int offset)
206{ 228{
207 struct max77620_gpio *mgpio = gpiochip_get_data(gc); 229 struct max77620_gpio *mgpio = gpiochip_get_data(gc);
@@ -238,6 +260,7 @@ static int max77620_gpio_probe(struct platform_device *pdev)
238 mgpio->gpio_chip.direction_output = max77620_gpio_dir_output; 260 mgpio->gpio_chip.direction_output = max77620_gpio_dir_output;
239 mgpio->gpio_chip.set_debounce = max77620_gpio_set_debounce; 261 mgpio->gpio_chip.set_debounce = max77620_gpio_set_debounce;
240 mgpio->gpio_chip.set = max77620_gpio_set; 262 mgpio->gpio_chip.set = max77620_gpio_set;
263 mgpio->gpio_chip.set_single_ended = max77620_gpio_set_single_ended;
241 mgpio->gpio_chip.to_irq = max77620_gpio_to_irq; 264 mgpio->gpio_chip.to_irq = max77620_gpio_to_irq;
242 mgpio->gpio_chip.ngpio = MAX77620_GPIO_NR; 265 mgpio->gpio_chip.ngpio = MAX77620_GPIO_NR;
243 mgpio->gpio_chip.can_sleep = 1; 266 mgpio->gpio_chip.can_sleep = 1;