diff options
-rw-r--r-- | drivers/gpio/gpio-sch311x.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-sch311x.c b/drivers/gpio/gpio-sch311x.c index faf44178f97b..1d2af9f97a91 100644 --- a/drivers/gpio/gpio-sch311x.c +++ b/drivers/gpio/gpio-sch311x.c | |||
@@ -235,6 +235,34 @@ static int sch311x_gpio_get_direction(struct gpio_chip *chip, unsigned offset) | |||
235 | return !!(data & SCH311X_GPIO_CONF_DIR); | 235 | return !!(data & SCH311X_GPIO_CONF_DIR); |
236 | } | 236 | } |
237 | 237 | ||
238 | static int sch311x_gpio_set_config(struct gpio_chip *chip, unsigned offset, | ||
239 | unsigned long config) | ||
240 | { | ||
241 | struct sch311x_gpio_block *block = gpiochip_get_data(chip); | ||
242 | enum pin_config_param param = pinconf_to_config_param(config); | ||
243 | unsigned char data; | ||
244 | |||
245 | switch (param) { | ||
246 | case PIN_CONFIG_DRIVE_OPEN_DRAIN: | ||
247 | spin_lock(&block->lock); | ||
248 | data = inb(block->runtime_reg + block->config_regs[offset]); | ||
249 | data |= SCH311X_GPIO_CONF_OPEN_DRAIN; | ||
250 | outb(data, block->runtime_reg + block->config_regs[offset]); | ||
251 | spin_unlock(&block->lock); | ||
252 | return 0; | ||
253 | case PIN_CONFIG_DRIVE_PUSH_PULL: | ||
254 | spin_lock(&block->lock); | ||
255 | data = inb(block->runtime_reg + block->config_regs[offset]); | ||
256 | data &= ~SCH311X_GPIO_CONF_OPEN_DRAIN; | ||
257 | outb(data, block->runtime_reg + block->config_regs[offset]); | ||
258 | spin_unlock(&block->lock); | ||
259 | return 0; | ||
260 | default: | ||
261 | break; | ||
262 | } | ||
263 | return -ENOTSUPP; | ||
264 | } | ||
265 | |||
238 | static int sch311x_gpio_probe(struct platform_device *pdev) | 266 | static int sch311x_gpio_probe(struct platform_device *pdev) |
239 | { | 267 | { |
240 | struct sch311x_pdev_data *pdata = dev_get_platdata(&pdev->dev); | 268 | struct sch311x_pdev_data *pdata = dev_get_platdata(&pdev->dev); |
@@ -268,6 +296,7 @@ static int sch311x_gpio_probe(struct platform_device *pdev) | |||
268 | block->chip.direction_input = sch311x_gpio_direction_in; | 296 | block->chip.direction_input = sch311x_gpio_direction_in; |
269 | block->chip.direction_output = sch311x_gpio_direction_out; | 297 | block->chip.direction_output = sch311x_gpio_direction_out; |
270 | block->chip.get_direction = sch311x_gpio_get_direction; | 298 | block->chip.get_direction = sch311x_gpio_get_direction; |
299 | block->chip.set_config = sch311x_gpio_set_config; | ||
271 | block->chip.get = sch311x_gpio_get; | 300 | block->chip.get = sch311x_gpio_get; |
272 | block->chip.set = sch311x_gpio_set; | 301 | block->chip.set = sch311x_gpio_set; |
273 | block->chip.ngpio = 8; | 302 | block->chip.ngpio = 8; |