diff options
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/adp5520-gpio.c | 36 | ||||
-rw-r--r-- | drivers/gpio/twl4030-gpio.c | 20 | ||||
-rw-r--r-- | drivers/gpio/wm831x-gpio.c | 17 |
3 files changed, 44 insertions, 29 deletions
diff --git a/drivers/gpio/adp5520-gpio.c b/drivers/gpio/adp5520-gpio.c index ad05bbc7ffd5..0f93105873cd 100644 --- a/drivers/gpio/adp5520-gpio.c +++ b/drivers/gpio/adp5520-gpio.c | |||
@@ -34,9 +34,9 @@ static int adp5520_gpio_get_value(struct gpio_chip *chip, unsigned off) | |||
34 | */ | 34 | */ |
35 | 35 | ||
36 | if (test_bit(off, &dev->output)) | 36 | if (test_bit(off, &dev->output)) |
37 | adp5520_read(dev->master, GPIO_OUT, ®_val); | 37 | adp5520_read(dev->master, ADP5520_GPIO_OUT, ®_val); |
38 | else | 38 | else |
39 | adp5520_read(dev->master, GPIO_IN, ®_val); | 39 | adp5520_read(dev->master, ADP5520_GPIO_IN, ®_val); |
40 | 40 | ||
41 | return !!(reg_val & dev->lut[off]); | 41 | return !!(reg_val & dev->lut[off]); |
42 | } | 42 | } |
@@ -48,9 +48,9 @@ static void adp5520_gpio_set_value(struct gpio_chip *chip, | |||
48 | dev = container_of(chip, struct adp5520_gpio, gpio_chip); | 48 | dev = container_of(chip, struct adp5520_gpio, gpio_chip); |
49 | 49 | ||
50 | if (val) | 50 | if (val) |
51 | adp5520_set_bits(dev->master, GPIO_OUT, dev->lut[off]); | 51 | adp5520_set_bits(dev->master, ADP5520_GPIO_OUT, dev->lut[off]); |
52 | else | 52 | else |
53 | adp5520_clr_bits(dev->master, GPIO_OUT, dev->lut[off]); | 53 | adp5520_clr_bits(dev->master, ADP5520_GPIO_OUT, dev->lut[off]); |
54 | } | 54 | } |
55 | 55 | ||
56 | static int adp5520_gpio_direction_input(struct gpio_chip *chip, unsigned off) | 56 | static int adp5520_gpio_direction_input(struct gpio_chip *chip, unsigned off) |
@@ -60,7 +60,8 @@ static int adp5520_gpio_direction_input(struct gpio_chip *chip, unsigned off) | |||
60 | 60 | ||
61 | clear_bit(off, &dev->output); | 61 | clear_bit(off, &dev->output); |
62 | 62 | ||
63 | return adp5520_clr_bits(dev->master, GPIO_CFG_2, dev->lut[off]); | 63 | return adp5520_clr_bits(dev->master, ADP5520_GPIO_CFG_2, |
64 | dev->lut[off]); | ||
64 | } | 65 | } |
65 | 66 | ||
66 | static int adp5520_gpio_direction_output(struct gpio_chip *chip, | 67 | static int adp5520_gpio_direction_output(struct gpio_chip *chip, |
@@ -73,18 +74,21 @@ static int adp5520_gpio_direction_output(struct gpio_chip *chip, | |||
73 | set_bit(off, &dev->output); | 74 | set_bit(off, &dev->output); |
74 | 75 | ||
75 | if (val) | 76 | if (val) |
76 | ret |= adp5520_set_bits(dev->master, GPIO_OUT, dev->lut[off]); | 77 | ret |= adp5520_set_bits(dev->master, ADP5520_GPIO_OUT, |
78 | dev->lut[off]); | ||
77 | else | 79 | else |
78 | ret |= adp5520_clr_bits(dev->master, GPIO_OUT, dev->lut[off]); | 80 | ret |= adp5520_clr_bits(dev->master, ADP5520_GPIO_OUT, |
81 | dev->lut[off]); | ||
79 | 82 | ||
80 | ret |= adp5520_set_bits(dev->master, GPIO_CFG_2, dev->lut[off]); | 83 | ret |= adp5520_set_bits(dev->master, ADP5520_GPIO_CFG_2, |
84 | dev->lut[off]); | ||
81 | 85 | ||
82 | return ret; | 86 | return ret; |
83 | } | 87 | } |
84 | 88 | ||
85 | static int __devinit adp5520_gpio_probe(struct platform_device *pdev) | 89 | static int __devinit adp5520_gpio_probe(struct platform_device *pdev) |
86 | { | 90 | { |
87 | struct adp5520_gpio_platfrom_data *pdata = pdev->dev.platform_data; | 91 | struct adp5520_gpio_platform_data *pdata = pdev->dev.platform_data; |
88 | struct adp5520_gpio *dev; | 92 | struct adp5520_gpio *dev; |
89 | struct gpio_chip *gc; | 93 | struct gpio_chip *gc; |
90 | int ret, i, gpios; | 94 | int ret, i, gpios; |
@@ -129,20 +133,20 @@ static int __devinit adp5520_gpio_probe(struct platform_device *pdev) | |||
129 | gc->label = pdev->name; | 133 | gc->label = pdev->name; |
130 | gc->owner = THIS_MODULE; | 134 | gc->owner = THIS_MODULE; |
131 | 135 | ||
132 | ret = adp5520_clr_bits(dev->master, GPIO_CFG_1, | 136 | ret = adp5520_clr_bits(dev->master, ADP5520_GPIO_CFG_1, |
133 | pdata->gpio_en_mask); | 137 | pdata->gpio_en_mask); |
134 | 138 | ||
135 | if (pdata->gpio_en_mask & GPIO_C3) | 139 | if (pdata->gpio_en_mask & ADP5520_GPIO_C3) |
136 | ctl_mask |= C3_MODE; | 140 | ctl_mask |= ADP5520_C3_MODE; |
137 | 141 | ||
138 | if (pdata->gpio_en_mask & GPIO_R3) | 142 | if (pdata->gpio_en_mask & ADP5520_GPIO_R3) |
139 | ctl_mask |= R3_MODE; | 143 | ctl_mask |= ADP5520_R3_MODE; |
140 | 144 | ||
141 | if (ctl_mask) | 145 | if (ctl_mask) |
142 | ret = adp5520_set_bits(dev->master, LED_CONTROL, | 146 | ret = adp5520_set_bits(dev->master, ADP5520_LED_CONTROL, |
143 | ctl_mask); | 147 | ctl_mask); |
144 | 148 | ||
145 | ret |= adp5520_set_bits(dev->master, GPIO_PULLUP, | 149 | ret |= adp5520_set_bits(dev->master, ADP5520_GPIO_PULLUP, |
146 | pdata->gpio_pullup_mask); | 150 | pdata->gpio_pullup_mask); |
147 | 151 | ||
148 | if (ret) { | 152 | if (ret) { |
diff --git a/drivers/gpio/twl4030-gpio.c b/drivers/gpio/twl4030-gpio.c index 49384a7c5492..7fe881e2bdfb 100644 --- a/drivers/gpio/twl4030-gpio.c +++ b/drivers/gpio/twl4030-gpio.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #include <linux/platform_device.h> | 34 | #include <linux/platform_device.h> |
35 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
36 | 36 | ||
37 | #include <linux/i2c/twl4030.h> | 37 | #include <linux/i2c/twl.h> |
38 | 38 | ||
39 | 39 | ||
40 | /* | 40 | /* |
@@ -80,7 +80,7 @@ static unsigned int gpio_usage_count; | |||
80 | */ | 80 | */ |
81 | static inline int gpio_twl4030_write(u8 address, u8 data) | 81 | static inline int gpio_twl4030_write(u8 address, u8 data) |
82 | { | 82 | { |
83 | return twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, data, address); | 83 | return twl_i2c_write_u8(TWL4030_MODULE_GPIO, data, address); |
84 | } | 84 | } |
85 | 85 | ||
86 | /*----------------------------------------------------------------------*/ | 86 | /*----------------------------------------------------------------------*/ |
@@ -117,7 +117,7 @@ static inline int gpio_twl4030_read(u8 address) | |||
117 | u8 data; | 117 | u8 data; |
118 | int ret = 0; | 118 | int ret = 0; |
119 | 119 | ||
120 | ret = twl4030_i2c_read_u8(TWL4030_MODULE_GPIO, &data, address); | 120 | ret = twl_i2c_read_u8(TWL4030_MODULE_GPIO, &data, address); |
121 | return (ret < 0) ? ret : data; | 121 | return (ret < 0) ? ret : data; |
122 | } | 122 | } |
123 | 123 | ||
@@ -142,7 +142,7 @@ static void twl4030_led_set_value(int led, int value) | |||
142 | cached_leden &= ~mask; | 142 | cached_leden &= ~mask; |
143 | else | 143 | else |
144 | cached_leden |= mask; | 144 | cached_leden |= mask; |
145 | status = twl4030_i2c_write_u8(TWL4030_MODULE_LED, cached_leden, | 145 | status = twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden, |
146 | TWL4030_LED_LEDEN); | 146 | TWL4030_LED_LEDEN); |
147 | mutex_unlock(&gpio_lock); | 147 | mutex_unlock(&gpio_lock); |
148 | } | 148 | } |
@@ -223,23 +223,23 @@ static int twl_request(struct gpio_chip *chip, unsigned offset) | |||
223 | } | 223 | } |
224 | 224 | ||
225 | /* initialize PWM to always-drive */ | 225 | /* initialize PWM to always-drive */ |
226 | status = twl4030_i2c_write_u8(module, 0x7f, | 226 | status = twl_i2c_write_u8(module, 0x7f, |
227 | TWL4030_PWMx_PWMxOFF); | 227 | TWL4030_PWMx_PWMxOFF); |
228 | if (status < 0) | 228 | if (status < 0) |
229 | goto done; | 229 | goto done; |
230 | status = twl4030_i2c_write_u8(module, 0x7f, | 230 | status = twl_i2c_write_u8(module, 0x7f, |
231 | TWL4030_PWMx_PWMxON); | 231 | TWL4030_PWMx_PWMxON); |
232 | if (status < 0) | 232 | if (status < 0) |
233 | goto done; | 233 | goto done; |
234 | 234 | ||
235 | /* init LED to not-driven (high) */ | 235 | /* init LED to not-driven (high) */ |
236 | module = TWL4030_MODULE_LED; | 236 | module = TWL4030_MODULE_LED; |
237 | status = twl4030_i2c_read_u8(module, &cached_leden, | 237 | status = twl_i2c_read_u8(module, &cached_leden, |
238 | TWL4030_LED_LEDEN); | 238 | TWL4030_LED_LEDEN); |
239 | if (status < 0) | 239 | if (status < 0) |
240 | goto done; | 240 | goto done; |
241 | cached_leden &= ~ledclr_mask; | 241 | cached_leden &= ~ledclr_mask; |
242 | status = twl4030_i2c_write_u8(module, cached_leden, | 242 | status = twl_i2c_write_u8(module, cached_leden, |
243 | TWL4030_LED_LEDEN); | 243 | TWL4030_LED_LEDEN); |
244 | if (status < 0) | 244 | if (status < 0) |
245 | goto done; | 245 | goto done; |
@@ -370,7 +370,7 @@ static int __devinit gpio_twl4030_pulls(u32 ups, u32 downs) | |||
370 | message[i] = bit_mask; | 370 | message[i] = bit_mask; |
371 | } | 371 | } |
372 | 372 | ||
373 | return twl4030_i2c_write(TWL4030_MODULE_GPIO, message, | 373 | return twl_i2c_write(TWL4030_MODULE_GPIO, message, |
374 | REG_GPIOPUPDCTR1, 5); | 374 | REG_GPIOPUPDCTR1, 5); |
375 | } | 375 | } |
376 | 376 | ||
@@ -387,7 +387,7 @@ static int __devinit gpio_twl4030_debounce(u32 debounce, u8 mmc_cd) | |||
387 | debounce >>= 8; | 387 | debounce >>= 8; |
388 | message[3] = (debounce & 0x03); | 388 | message[3] = (debounce & 0x03); |
389 | 389 | ||
390 | return twl4030_i2c_write(TWL4030_MODULE_GPIO, message, | 390 | return twl_i2c_write(TWL4030_MODULE_GPIO, message, |
391 | REG_GPIO_DEBEN1, 3); | 391 | REG_GPIO_DEBEN1, 3); |
392 | } | 392 | } |
393 | 393 | ||
diff --git a/drivers/gpio/wm831x-gpio.c b/drivers/gpio/wm831x-gpio.c index f9c09a54ec7f..b4468b616890 100644 --- a/drivers/gpio/wm831x-gpio.c +++ b/drivers/gpio/wm831x-gpio.c | |||
@@ -22,8 +22,7 @@ | |||
22 | #include <linux/mfd/wm831x/core.h> | 22 | #include <linux/mfd/wm831x/core.h> |
23 | #include <linux/mfd/wm831x/pdata.h> | 23 | #include <linux/mfd/wm831x/pdata.h> |
24 | #include <linux/mfd/wm831x/gpio.h> | 24 | #include <linux/mfd/wm831x/gpio.h> |
25 | 25 | #include <linux/mfd/wm831x/irq.h> | |
26 | #define WM831X_GPIO_MAX 16 | ||
27 | 26 | ||
28 | struct wm831x_gpio { | 27 | struct wm831x_gpio { |
29 | struct wm831x *wm831x; | 28 | struct wm831x *wm831x; |
@@ -80,6 +79,17 @@ static void wm831x_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | |||
80 | value << offset); | 79 | value << offset); |
81 | } | 80 | } |
82 | 81 | ||
82 | static int wm831x_gpio_to_irq(struct gpio_chip *chip, unsigned offset) | ||
83 | { | ||
84 | struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip); | ||
85 | struct wm831x *wm831x = wm831x_gpio->wm831x; | ||
86 | |||
87 | if (!wm831x->irq_base) | ||
88 | return -EINVAL; | ||
89 | |||
90 | return wm831x->irq_base + WM831X_IRQ_GPIO_1 + offset; | ||
91 | } | ||
92 | |||
83 | #ifdef CONFIG_DEBUG_FS | 93 | #ifdef CONFIG_DEBUG_FS |
84 | static void wm831x_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) | 94 | static void wm831x_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) |
85 | { | 95 | { |
@@ -175,6 +185,7 @@ static struct gpio_chip template_chip = { | |||
175 | .get = wm831x_gpio_get, | 185 | .get = wm831x_gpio_get, |
176 | .direction_output = wm831x_gpio_direction_out, | 186 | .direction_output = wm831x_gpio_direction_out, |
177 | .set = wm831x_gpio_set, | 187 | .set = wm831x_gpio_set, |
188 | .to_irq = wm831x_gpio_to_irq, | ||
178 | .dbg_show = wm831x_gpio_dbg_show, | 189 | .dbg_show = wm831x_gpio_dbg_show, |
179 | .can_sleep = 1, | 190 | .can_sleep = 1, |
180 | }; | 191 | }; |
@@ -192,7 +203,7 @@ static int __devinit wm831x_gpio_probe(struct platform_device *pdev) | |||
192 | 203 | ||
193 | wm831x_gpio->wm831x = wm831x; | 204 | wm831x_gpio->wm831x = wm831x; |
194 | wm831x_gpio->gpio_chip = template_chip; | 205 | wm831x_gpio->gpio_chip = template_chip; |
195 | wm831x_gpio->gpio_chip.ngpio = WM831X_GPIO_MAX; | 206 | wm831x_gpio->gpio_chip.ngpio = wm831x->num_gpio; |
196 | wm831x_gpio->gpio_chip.dev = &pdev->dev; | 207 | wm831x_gpio->gpio_chip.dev = &pdev->dev; |
197 | if (pdata && pdata->gpio_base) | 208 | if (pdata && pdata->gpio_base) |
198 | wm831x_gpio->gpio_chip.base = pdata->gpio_base; | 209 | wm831x_gpio->gpio_chip.base = pdata->gpio_base; |