diff options
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/Kconfig | 7 | ||||
-rw-r--r-- | drivers/gpio/pca953x.c | 12 | ||||
-rw-r--r-- | drivers/gpio/twl4030-gpio.c | 54 |
3 files changed, 34 insertions, 39 deletions
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 48f49d93d249..3d2565441b36 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig | |||
@@ -95,7 +95,7 @@ config GPIO_MAX732X | |||
95 | number for these GPIOs. | 95 | number for these GPIOs. |
96 | 96 | ||
97 | config GPIO_PCA953X | 97 | config GPIO_PCA953X |
98 | tristate "PCA953x, PCA955x, and MAX7310 I/O ports" | 98 | tristate "PCA953x, PCA955x, TCA64xx, and MAX7310 I/O ports" |
99 | depends on I2C | 99 | depends on I2C |
100 | help | 100 | help |
101 | Say yes here to provide access to several register-oriented | 101 | Say yes here to provide access to several register-oriented |
@@ -104,9 +104,10 @@ config GPIO_PCA953X | |||
104 | 104 | ||
105 | 4 bits: pca9536, pca9537 | 105 | 4 bits: pca9536, pca9537 |
106 | 106 | ||
107 | 8 bits: max7310, pca9534, pca9538, pca9554, pca9557 | 107 | 8 bits: max7310, pca9534, pca9538, pca9554, pca9557, |
108 | tca6408 | ||
108 | 109 | ||
109 | 16 bits: pca9535, pca9539, pca9555 | 110 | 16 bits: pca9535, pca9539, pca9555, tca6416 |
110 | 111 | ||
111 | This driver can also be built as a module. If so, the module | 112 | This driver can also be built as a module. If so, the module |
112 | will be called pca953x. | 113 | will be called pca953x. |
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c index 9ceeb89f1325..37f35388a2ae 100644 --- a/drivers/gpio/pca953x.c +++ b/drivers/gpio/pca953x.c | |||
@@ -33,7 +33,12 @@ static const struct i2c_device_id pca953x_id[] = { | |||
33 | { "pca9554", 8, }, | 33 | { "pca9554", 8, }, |
34 | { "pca9555", 16, }, | 34 | { "pca9555", 16, }, |
35 | { "pca9557", 8, }, | 35 | { "pca9557", 8, }, |
36 | |||
36 | { "max7310", 8, }, | 37 | { "max7310", 8, }, |
38 | { "pca6107", 8, }, | ||
39 | { "tca6408", 8, }, | ||
40 | { "tca6416", 16, }, | ||
41 | /* NYET: { "tca6424", 24, }, */ | ||
37 | { } | 42 | { } |
38 | }; | 43 | }; |
39 | MODULE_DEVICE_TABLE(i2c, pca953x_id); | 44 | MODULE_DEVICE_TABLE(i2c, pca953x_id); |
@@ -47,9 +52,6 @@ struct pca953x_chip { | |||
47 | struct gpio_chip gpio_chip; | 52 | struct gpio_chip gpio_chip; |
48 | }; | 53 | }; |
49 | 54 | ||
50 | /* NOTE: we can't currently rely on fault codes to come from SMBus | ||
51 | * calls, so we map all errors to EIO here and return zero otherwise. | ||
52 | */ | ||
53 | static int pca953x_write_reg(struct pca953x_chip *chip, int reg, uint16_t val) | 55 | static int pca953x_write_reg(struct pca953x_chip *chip, int reg, uint16_t val) |
54 | { | 56 | { |
55 | int ret; | 57 | int ret; |
@@ -61,7 +63,7 @@ static int pca953x_write_reg(struct pca953x_chip *chip, int reg, uint16_t val) | |||
61 | 63 | ||
62 | if (ret < 0) { | 64 | if (ret < 0) { |
63 | dev_err(&chip->client->dev, "failed writing register\n"); | 65 | dev_err(&chip->client->dev, "failed writing register\n"); |
64 | return -EIO; | 66 | return ret; |
65 | } | 67 | } |
66 | 68 | ||
67 | return 0; | 69 | return 0; |
@@ -78,7 +80,7 @@ static int pca953x_read_reg(struct pca953x_chip *chip, int reg, uint16_t *val) | |||
78 | 80 | ||
79 | if (ret < 0) { | 81 | if (ret < 0) { |
80 | dev_err(&chip->client->dev, "failed reading register\n"); | 82 | dev_err(&chip->client->dev, "failed reading register\n"); |
81 | return -EIO; | 83 | return ret; |
82 | } | 84 | } |
83 | 85 | ||
84 | *val = (uint16_t)ret; | 86 | *val = (uint16_t)ret; |
diff --git a/drivers/gpio/twl4030-gpio.c b/drivers/gpio/twl4030-gpio.c index 37d3eec8730a..afad14792141 100644 --- a/drivers/gpio/twl4030-gpio.c +++ b/drivers/gpio/twl4030-gpio.c | |||
@@ -202,37 +202,6 @@ static int twl4030_get_gpio_datain(int gpio) | |||
202 | return ret; | 202 | return ret; |
203 | } | 203 | } |
204 | 204 | ||
205 | /* | ||
206 | * Configure debounce timing value for a GPIO pin on TWL4030 | ||
207 | */ | ||
208 | int twl4030_set_gpio_debounce(int gpio, int enable) | ||
209 | { | ||
210 | u8 d_bnk = gpio >> 3; | ||
211 | u8 d_msk = BIT(gpio & 0x7); | ||
212 | u8 reg = 0; | ||
213 | u8 base = 0; | ||
214 | int ret = 0; | ||
215 | |||
216 | if (unlikely((gpio >= TWL4030_GPIO_MAX) | ||
217 | || !(gpio_usage_count & BIT(gpio)))) | ||
218 | return -EPERM; | ||
219 | |||
220 | base = REG_GPIO_DEBEN1 + d_bnk; | ||
221 | mutex_lock(&gpio_lock); | ||
222 | ret = gpio_twl4030_read(base); | ||
223 | if (ret >= 0) { | ||
224 | if (enable) | ||
225 | reg = ret | d_msk; | ||
226 | else | ||
227 | reg = ret & ~d_msk; | ||
228 | |||
229 | ret = gpio_twl4030_write(base, reg); | ||
230 | } | ||
231 | mutex_unlock(&gpio_lock); | ||
232 | return ret; | ||
233 | } | ||
234 | EXPORT_SYMBOL(twl4030_set_gpio_debounce); | ||
235 | |||
236 | /*----------------------------------------------------------------------*/ | 205 | /*----------------------------------------------------------------------*/ |
237 | 206 | ||
238 | static int twl_request(struct gpio_chip *chip, unsigned offset) | 207 | static int twl_request(struct gpio_chip *chip, unsigned offset) |
@@ -405,6 +374,23 @@ static int __devinit gpio_twl4030_pulls(u32 ups, u32 downs) | |||
405 | REG_GPIOPUPDCTR1, 5); | 374 | REG_GPIOPUPDCTR1, 5); |
406 | } | 375 | } |
407 | 376 | ||
377 | static int __devinit gpio_twl4030_debounce(u32 debounce, u8 mmc_cd) | ||
378 | { | ||
379 | u8 message[4]; | ||
380 | |||
381 | /* 30 msec of debouncing is always used for MMC card detect, | ||
382 | * and is optional for everything else. | ||
383 | */ | ||
384 | message[1] = (debounce & 0xff) | (mmc_cd & 0x03); | ||
385 | debounce >>= 8; | ||
386 | message[2] = (debounce & 0xff); | ||
387 | debounce >>= 8; | ||
388 | message[3] = (debounce & 0x03); | ||
389 | |||
390 | return twl4030_i2c_write(TWL4030_MODULE_GPIO, message, | ||
391 | REG_GPIO_DEBEN1, 3); | ||
392 | } | ||
393 | |||
408 | static int gpio_twl4030_remove(struct platform_device *pdev); | 394 | static int gpio_twl4030_remove(struct platform_device *pdev); |
409 | 395 | ||
410 | static int __devinit gpio_twl4030_probe(struct platform_device *pdev) | 396 | static int __devinit gpio_twl4030_probe(struct platform_device *pdev) |
@@ -439,6 +425,12 @@ no_irqs: | |||
439 | pdata->pullups, pdata->pulldowns, | 425 | pdata->pullups, pdata->pulldowns, |
440 | ret); | 426 | ret); |
441 | 427 | ||
428 | ret = gpio_twl4030_debounce(pdata->debounce, pdata->mmc_cd); | ||
429 | if (ret) | ||
430 | dev_dbg(&pdev->dev, "debounce %.03x %.01x --> %d\n", | ||
431 | pdata->debounce, pdata->mmc_cd, | ||
432 | ret); | ||
433 | |||
442 | twl_gpiochip.base = pdata->gpio_base; | 434 | twl_gpiochip.base = pdata->gpio_base; |
443 | twl_gpiochip.ngpio = TWL4030_GPIO_MAX; | 435 | twl_gpiochip.ngpio = TWL4030_GPIO_MAX; |
444 | twl_gpiochip.dev = &pdev->dev; | 436 | twl_gpiochip.dev = &pdev->dev; |