summaryrefslogtreecommitdiffstats
path: root/drivers/usb
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/usb
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/usb')
-rw-r--r--drivers/usb/serial/cp210x.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index fff718352e0c..5d61d0871f2e 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -1329,17 +1329,20 @@ static int cp210x_gpio_direction_output(struct gpio_chip *gc, unsigned int gpio,
1329 return 0; 1329 return 0;
1330} 1330}
1331 1331
1332static int cp210x_gpio_set_single_ended(struct gpio_chip *gc, unsigned int gpio, 1332static int cp210x_gpio_set_config(struct gpio_chip *gc, unsigned int gpio,
1333 enum single_ended_mode mode) 1333 unsigned long config)
1334{ 1334{
1335 struct usb_serial *serial = gpiochip_get_data(gc); 1335 struct usb_serial *serial = gpiochip_get_data(gc);
1336 struct cp210x_serial_private *priv = usb_get_serial_data(serial); 1336 struct cp210x_serial_private *priv = usb_get_serial_data(serial);
1337 enum pin_config_param param = pinconf_to_config_param(config);
1337 1338
1338 /* Succeed only if in correct mode (this can't be set at runtime) */ 1339 /* Succeed only if in correct mode (this can't be set at runtime) */
1339 if ((mode == LINE_MODE_PUSH_PULL) && (priv->gpio_mode & BIT(gpio))) 1340 if ((param == PIN_CONFIG_DRIVE_PUSH_PULL) &&
1341 (priv->gpio_mode & BIT(gpio)))
1340 return 0; 1342 return 0;
1341 1343
1342 if ((mode == LINE_MODE_OPEN_DRAIN) && !(priv->gpio_mode & BIT(gpio))) 1344 if ((param == PIN_CONFIG_DRIVE_OPEN_DRAIN) &&
1345 !(priv->gpio_mode & BIT(gpio)))
1343 return 0; 1346 return 0;
1344 1347
1345 return -ENOTSUPP; 1348 return -ENOTSUPP;
@@ -1402,7 +1405,7 @@ static int cp2105_shared_gpio_init(struct usb_serial *serial)
1402 priv->gc.direction_output = cp210x_gpio_direction_output; 1405 priv->gc.direction_output = cp210x_gpio_direction_output;
1403 priv->gc.get = cp210x_gpio_get; 1406 priv->gc.get = cp210x_gpio_get;
1404 priv->gc.set = cp210x_gpio_set; 1407 priv->gc.set = cp210x_gpio_set;
1405 priv->gc.set_single_ended = cp210x_gpio_set_single_ended; 1408 priv->gc.set_config = cp210x_gpio_set_config;
1406 priv->gc.owner = THIS_MODULE; 1409 priv->gc.owner = THIS_MODULE;
1407 priv->gc.parent = &serial->interface->dev; 1410 priv->gc.parent = &serial->interface->dev;
1408 priv->gc.base = -1; 1411 priv->gc.base = -1;