summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-tc3589x.c
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2017-01-23 07:34:34 -0500
committerLinus Walleij <linus.walleij@linaro.org>2017-01-26 09:27:37 -0500
commit2956b5d94a76b596fa5057c2b3ca915cb27d7652 (patch)
tree3a1dbce1201ef4923a4124f63eb209026e8fba7e /drivers/gpio/gpio-tc3589x.c
parent15381bc7c7f52d56f87c56dd7c948ad78704b852 (diff)
pinctrl / gpio: Introduce .set_config() callback for GPIO chips
Currently we already have two pin configuration related callbacks available for GPIO chips .set_single_ended() and .set_debounce(). In future we expect to have even more, which does not scale well if we need to add yet another callback to the GPIO chip structure for each possible configuration parameter. Better solution is to reuse what we already have available in the generic pinconf. To support this, we introduce a new .set_config() callback for GPIO chips. The callback takes a single packed pin configuration value as parameter. This can then be extended easily beyond what is currently supported by just adding new types to the generic pinconf enum. If the GPIO driver is backed up by a pinctrl driver the GPIO driver can just assign gpiochip_generic_config() (introduced in this patch) to .set_config and that will take care configuration requests are directed to the pinctrl driver. We then convert the existing drivers over .set_config() and finally remove the .set_single_ended() and .set_debounce() callbacks. Suggested-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-tc3589x.c')
-rw-r--r--drivers/gpio/gpio-tc3589x.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c
index be97101c2c9a..433b45ef332e 100644
--- a/drivers/gpio/gpio-tc3589x.c
+++ b/drivers/gpio/gpio-tc3589x.c
@@ -100,9 +100,8 @@ static int tc3589x_gpio_get_direction(struct gpio_chip *chip,
100 return !(ret & BIT(pos)); 100 return !(ret & BIT(pos));
101} 101}
102 102
103static int tc3589x_gpio_set_single_ended(struct gpio_chip *chip, 103static int tc3589x_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
104 unsigned int offset, 104 unsigned long config)
105 enum single_ended_mode mode)
106{ 105{
107 struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); 106 struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip);
108 struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; 107 struct tc3589x *tc3589x = tc3589x_gpio->tc3589x;
@@ -116,22 +115,22 @@ static int tc3589x_gpio_set_single_ended(struct gpio_chip *chip,
116 unsigned int pos = offset % 8; 115 unsigned int pos = offset % 8;
117 int ret; 116 int ret;
118 117
119 switch(mode) { 118 switch (pinconf_to_config_param(config)) {
120 case LINE_MODE_OPEN_DRAIN: 119 case PIN_CONFIG_DRIVE_OPEN_DRAIN:
121 /* Set open drain mode */ 120 /* Set open drain mode */
122 ret = tc3589x_set_bits(tc3589x, odmreg, BIT(pos), 0); 121 ret = tc3589x_set_bits(tc3589x, odmreg, BIT(pos), 0);
123 if (ret) 122 if (ret)
124 return ret; 123 return ret;
125 /* Enable open drain/source mode */ 124 /* Enable open drain/source mode */
126 return tc3589x_set_bits(tc3589x, odereg, BIT(pos), BIT(pos)); 125 return tc3589x_set_bits(tc3589x, odereg, BIT(pos), BIT(pos));
127 case LINE_MODE_OPEN_SOURCE: 126 case PIN_CONFIG_DRIVE_OPEN_SOURCE:
128 /* Set open source mode */ 127 /* Set open source mode */
129 ret = tc3589x_set_bits(tc3589x, odmreg, BIT(pos), BIT(pos)); 128 ret = tc3589x_set_bits(tc3589x, odmreg, BIT(pos), BIT(pos));
130 if (ret) 129 if (ret)
131 return ret; 130 return ret;
132 /* Enable open drain/source mode */ 131 /* Enable open drain/source mode */
133 return tc3589x_set_bits(tc3589x, odereg, BIT(pos), BIT(pos)); 132 return tc3589x_set_bits(tc3589x, odereg, BIT(pos), BIT(pos));
134 case LINE_MODE_PUSH_PULL: 133 case PIN_CONFIG_DRIVE_PUSH_PULL:
135 /* Disable open drain/source mode */ 134 /* Disable open drain/source mode */
136 return tc3589x_set_bits(tc3589x, odereg, BIT(pos), 0); 135 return tc3589x_set_bits(tc3589x, odereg, BIT(pos), 0);
137 default: 136 default:
@@ -148,7 +147,7 @@ static const struct gpio_chip template_chip = {
148 .direction_output = tc3589x_gpio_direction_output, 147 .direction_output = tc3589x_gpio_direction_output,
149 .direction_input = tc3589x_gpio_direction_input, 148 .direction_input = tc3589x_gpio_direction_input,
150 .get_direction = tc3589x_gpio_get_direction, 149 .get_direction = tc3589x_gpio_get_direction,
151 .set_single_ended = tc3589x_gpio_set_single_ended, 150 .set_config = tc3589x_gpio_set_config,
152 .can_sleep = true, 151 .can_sleep = true,
153}; 152};
154 153