aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@pengutronix.de>2008-02-06 04:39:03 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-06 13:41:15 -0500
commitf3dc3630f687aa4664b663143f69d99d83195c54 (patch)
tree928dd4c1b2ddc7970e6bfebe17911271e1417597 /drivers
parentd1c057e31734426ba385e02291d97bdf06ba0c1d (diff)
gpio: rename pca953x symbols
This second part of an extension to support more pca953x chips renames the C and Kconfig symbols. All affected files were updated by sed, except for a couple of obvious exceptions. It also updates the Kconfig helptext. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@pengutronix.de> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpio/Kconfig11
-rw-r--r--drivers/gpio/Makefile2
-rw-r--r--drivers/gpio/pca953x.c110
3 files changed, 62 insertions, 61 deletions
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 74fac0f5c348..bbd28342e771 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -27,15 +27,16 @@ config DEBUG_GPIO
27 27
28comment "I2C GPIO expanders:" 28comment "I2C GPIO expanders:"
29 29
30config GPIO_PCA9539 30config GPIO_PCA953X
31 tristate "PCA9539 16-bit I/O port" 31 tristate "PCA953x I/O ports"
32 depends on I2C 32 depends on I2C
33 help 33 help
34 Say yes here to support the PCA9539 16-bit I/O port. These 34 Say yes here to support the PCA9534 (8-bit), PCA9535 (16-bit),
35 parts are made by NXP and TI. 35 PCA9536 (4-bit), PCA9537 (4-bit), PCA9538 (8-bit), and PCA9539
36 (16-bit) I/O ports. These parts are made by NXP and TI.
36 37
37 This driver can also be built as a module. If so, the module 38 This driver can also be built as a module. If so, the module
38 will be called pca9539. 39 will be called pca953x.
39 40
40config GPIO_PCF857X 41config GPIO_PCF857X
41 tristate "PCF857x, PCA857x, and PCA967x I2C GPIO expanders" 42 tristate "PCF857x, PCA857x, and PCA967x I2C GPIO expanders"
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 16dda772b44b..fdde9923cf33 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -5,5 +5,5 @@ ccflags-$(CONFIG_DEBUG_GPIO) += -DDEBUG
5obj-$(CONFIG_HAVE_GPIO_LIB) += gpiolib.o 5obj-$(CONFIG_HAVE_GPIO_LIB) += gpiolib.o
6 6
7obj-$(CONFIG_GPIO_MCP23S08) += mcp23s08.o 7obj-$(CONFIG_GPIO_MCP23S08) += mcp23s08.o
8obj-$(CONFIG_GPIO_PCA9539) += pca953x.o 8obj-$(CONFIG_GPIO_PCA953X) += pca953x.o
9obj-$(CONFIG_GPIO_PCF857X) += pcf857x.o 9obj-$(CONFIG_GPIO_PCF857X) += pcf857x.o
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c
index 7fae4e500dfd..ef1fe24bcbaf 100644
--- a/drivers/gpio/pca953x.c
+++ b/drivers/gpio/pca953x.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * pca9539.c - 16-bit I/O port with interrupt and reset 2 * pca953x.c - 16-bit I/O port with interrupt and reset
3 * 3 *
4 * Copyright (C) 2005 Ben Gardner <bgardner@wabtec.com> 4 * Copyright (C) 2005 Ben Gardner <bgardner@wabtec.com>
5 * Copyright (C) 2007 Marvell International Ltd. 5 * Copyright (C) 2007 Marvell International Ltd.
@@ -19,14 +19,14 @@
19#include <asm/gpio.h> 19#include <asm/gpio.h>
20 20
21 21
22#define NR_PCA9539_GPIOS 16 22#define NR_PCA953X_GPIOS 16
23 23
24#define PCA9539_INPUT 0 24#define PCA953X_INPUT 0
25#define PCA9539_OUTPUT 2 25#define PCA953X_OUTPUT 2
26#define PCA9539_INVERT 4 26#define PCA953X_INVERT 4
27#define PCA9539_DIRECTION 6 27#define PCA953X_DIRECTION 6
28 28
29struct pca9539_chip { 29struct pca953x_chip {
30 unsigned gpio_start; 30 unsigned gpio_start;
31 uint16_t reg_output; 31 uint16_t reg_output;
32 uint16_t reg_direction; 32 uint16_t reg_direction;
@@ -38,7 +38,7 @@ struct pca9539_chip {
38/* NOTE: we can't currently rely on fault codes to come from SMBus 38/* NOTE: we can't currently rely on fault codes to come from SMBus
39 * calls, so we map all errors to EIO here and return zero otherwise. 39 * calls, so we map all errors to EIO here and return zero otherwise.
40 */ 40 */
41static int pca9539_write_reg(struct pca9539_chip *chip, int reg, uint16_t val) 41static int pca953x_write_reg(struct pca953x_chip *chip, int reg, uint16_t val)
42{ 42{
43 if (i2c_smbus_write_word_data(chip->client, reg, val) < 0) 43 if (i2c_smbus_write_word_data(chip->client, reg, val) < 0)
44 return -EIO; 44 return -EIO;
@@ -46,7 +46,7 @@ static int pca9539_write_reg(struct pca9539_chip *chip, int reg, uint16_t val)
46 return 0; 46 return 0;
47} 47}
48 48
49static int pca9539_read_reg(struct pca9539_chip *chip, int reg, uint16_t *val) 49static int pca953x_read_reg(struct pca953x_chip *chip, int reg, uint16_t *val)
50{ 50{
51 int ret; 51 int ret;
52 52
@@ -60,16 +60,16 @@ static int pca9539_read_reg(struct pca9539_chip *chip, int reg, uint16_t *val)
60 return 0; 60 return 0;
61} 61}
62 62
63static int pca9539_gpio_direction_input(struct gpio_chip *gc, unsigned off) 63static int pca953x_gpio_direction_input(struct gpio_chip *gc, unsigned off)
64{ 64{
65 struct pca9539_chip *chip; 65 struct pca953x_chip *chip;
66 uint16_t reg_val; 66 uint16_t reg_val;
67 int ret; 67 int ret;
68 68
69 chip = container_of(gc, struct pca9539_chip, gpio_chip); 69 chip = container_of(gc, struct pca953x_chip, gpio_chip);
70 70
71 reg_val = chip->reg_direction | (1u << off); 71 reg_val = chip->reg_direction | (1u << off);
72 ret = pca9539_write_reg(chip, PCA9539_DIRECTION, reg_val); 72 ret = pca953x_write_reg(chip, PCA953X_DIRECTION, reg_val);
73 if (ret) 73 if (ret)
74 return ret; 74 return ret;
75 75
@@ -77,14 +77,14 @@ static int pca9539_gpio_direction_input(struct gpio_chip *gc, unsigned off)
77 return 0; 77 return 0;
78} 78}
79 79
80static int pca9539_gpio_direction_output(struct gpio_chip *gc, 80static int pca953x_gpio_direction_output(struct gpio_chip *gc,
81 unsigned off, int val) 81 unsigned off, int val)
82{ 82{
83 struct pca9539_chip *chip; 83 struct pca953x_chip *chip;
84 uint16_t reg_val; 84 uint16_t reg_val;
85 int ret; 85 int ret;
86 86
87 chip = container_of(gc, struct pca9539_chip, gpio_chip); 87 chip = container_of(gc, struct pca953x_chip, gpio_chip);
88 88
89 /* set output level */ 89 /* set output level */
90 if (val) 90 if (val)
@@ -92,7 +92,7 @@ static int pca9539_gpio_direction_output(struct gpio_chip *gc,
92 else 92 else
93 reg_val = chip->reg_output & ~(1u << off); 93 reg_val = chip->reg_output & ~(1u << off);
94 94
95 ret = pca9539_write_reg(chip, PCA9539_OUTPUT, reg_val); 95 ret = pca953x_write_reg(chip, PCA953X_OUTPUT, reg_val);
96 if (ret) 96 if (ret)
97 return ret; 97 return ret;
98 98
@@ -100,7 +100,7 @@ static int pca9539_gpio_direction_output(struct gpio_chip *gc,
100 100
101 /* then direction */ 101 /* then direction */
102 reg_val = chip->reg_direction & ~(1u << off); 102 reg_val = chip->reg_direction & ~(1u << off);
103 ret = pca9539_write_reg(chip, PCA9539_DIRECTION, reg_val); 103 ret = pca953x_write_reg(chip, PCA953X_DIRECTION, reg_val);
104 if (ret) 104 if (ret)
105 return ret; 105 return ret;
106 106
@@ -108,15 +108,15 @@ static int pca9539_gpio_direction_output(struct gpio_chip *gc,
108 return 0; 108 return 0;
109} 109}
110 110
111static int pca9539_gpio_get_value(struct gpio_chip *gc, unsigned off) 111static int pca953x_gpio_get_value(struct gpio_chip *gc, unsigned off)
112{ 112{
113 struct pca9539_chip *chip; 113 struct pca953x_chip *chip;
114 uint16_t reg_val; 114 uint16_t reg_val;
115 int ret; 115 int ret;
116 116
117 chip = container_of(gc, struct pca9539_chip, gpio_chip); 117 chip = container_of(gc, struct pca953x_chip, gpio_chip);
118 118
119 ret = pca9539_read_reg(chip, PCA9539_INPUT, &reg_val); 119 ret = pca953x_read_reg(chip, PCA953X_INPUT, &reg_val);
120 if (ret < 0) { 120 if (ret < 0) {
121 /* NOTE: diagnostic already emitted; that's all we should 121 /* NOTE: diagnostic already emitted; that's all we should
122 * do unless gpio_*_value_cansleep() calls become different 122 * do unless gpio_*_value_cansleep() calls become different
@@ -128,55 +128,55 @@ static int pca9539_gpio_get_value(struct gpio_chip *gc, unsigned off)
128 return (reg_val & (1u << off)) ? 1 : 0; 128 return (reg_val & (1u << off)) ? 1 : 0;
129} 129}
130 130
131static void pca9539_gpio_set_value(struct gpio_chip *gc, unsigned off, int val) 131static void pca953x_gpio_set_value(struct gpio_chip *gc, unsigned off, int val)
132{ 132{
133 struct pca9539_chip *chip; 133 struct pca953x_chip *chip;
134 uint16_t reg_val; 134 uint16_t reg_val;
135 int ret; 135 int ret;
136 136
137 chip = container_of(gc, struct pca9539_chip, gpio_chip); 137 chip = container_of(gc, struct pca953x_chip, gpio_chip);
138 138
139 if (val) 139 if (val)
140 reg_val = chip->reg_output | (1u << off); 140 reg_val = chip->reg_output | (1u << off);
141 else 141 else
142 reg_val = chip->reg_output & ~(1u << off); 142 reg_val = chip->reg_output & ~(1u << off);
143 143
144 ret = pca9539_write_reg(chip, PCA9539_OUTPUT, reg_val); 144 ret = pca953x_write_reg(chip, PCA953X_OUTPUT, reg_val);
145 if (ret) 145 if (ret)
146 return; 146 return;
147 147
148 chip->reg_output = reg_val; 148 chip->reg_output = reg_val;
149} 149}
150 150
151static int pca9539_init_gpio(struct pca9539_chip *chip) 151static int pca953x_init_gpio(struct pca953x_chip *chip)
152{ 152{
153 struct gpio_chip *gc; 153 struct gpio_chip *gc;
154 154
155 gc = &chip->gpio_chip; 155 gc = &chip->gpio_chip;
156 156
157 gc->direction_input = pca9539_gpio_direction_input; 157 gc->direction_input = pca953x_gpio_direction_input;
158 gc->direction_output = pca9539_gpio_direction_output; 158 gc->direction_output = pca953x_gpio_direction_output;
159 gc->get = pca9539_gpio_get_value; 159 gc->get = pca953x_gpio_get_value;
160 gc->set = pca9539_gpio_set_value; 160 gc->set = pca953x_gpio_set_value;
161 161
162 gc->base = chip->gpio_start; 162 gc->base = chip->gpio_start;
163 gc->ngpio = NR_PCA9539_GPIOS; 163 gc->ngpio = NR_PCA953X_GPIOS;
164 gc->label = "pca9539"; 164 gc->label = "pca953x";
165 165
166 return gpiochip_add(gc); 166 return gpiochip_add(gc);
167} 167}
168 168
169static int __devinit pca9539_probe(struct i2c_client *client) 169static int __devinit pca953x_probe(struct i2c_client *client)
170{ 170{
171 struct pca9539_platform_data *pdata; 171 struct pca953x_platform_data *pdata;
172 struct pca9539_chip *chip; 172 struct pca953x_chip *chip;
173 int ret; 173 int ret;
174 174
175 pdata = client->dev.platform_data; 175 pdata = client->dev.platform_data;
176 if (pdata == NULL) 176 if (pdata == NULL)
177 return -ENODEV; 177 return -ENODEV;
178 178
179 chip = kzalloc(sizeof(struct pca9539_chip), GFP_KERNEL); 179 chip = kzalloc(sizeof(struct pca953x_chip), GFP_KERNEL);
180 if (chip == NULL) 180 if (chip == NULL)
181 return -ENOMEM; 181 return -ENOMEM;
182 182
@@ -187,20 +187,20 @@ static int __devinit pca9539_probe(struct i2c_client *client)
187 /* initialize cached registers from their original values. 187 /* initialize cached registers from their original values.
188 * we can't share this chip with another i2c master. 188 * we can't share this chip with another i2c master.
189 */ 189 */
190 ret = pca9539_read_reg(chip, PCA9539_OUTPUT, &chip->reg_output); 190 ret = pca953x_read_reg(chip, PCA953X_OUTPUT, &chip->reg_output);
191 if (ret) 191 if (ret)
192 goto out_failed; 192 goto out_failed;
193 193
194 ret = pca9539_read_reg(chip, PCA9539_DIRECTION, &chip->reg_direction); 194 ret = pca953x_read_reg(chip, PCA953X_DIRECTION, &chip->reg_direction);
195 if (ret) 195 if (ret)
196 goto out_failed; 196 goto out_failed;
197 197
198 /* set platform specific polarity inversion */ 198 /* set platform specific polarity inversion */
199 ret = pca9539_write_reg(chip, PCA9539_INVERT, pdata->invert); 199 ret = pca953x_write_reg(chip, PCA953X_INVERT, pdata->invert);
200 if (ret) 200 if (ret)
201 goto out_failed; 201 goto out_failed;
202 202
203 ret = pca9539_init_gpio(chip); 203 ret = pca953x_init_gpio(chip);
204 if (ret) 204 if (ret)
205 goto out_failed; 205 goto out_failed;
206 206
@@ -219,10 +219,10 @@ out_failed:
219 return ret; 219 return ret;
220} 220}
221 221
222static int pca9539_remove(struct i2c_client *client) 222static int pca953x_remove(struct i2c_client *client)
223{ 223{
224 struct pca9539_platform_data *pdata = client->dev.platform_data; 224 struct pca953x_platform_data *pdata = client->dev.platform_data;
225 struct pca9539_chip *chip = i2c_get_clientdata(client); 225 struct pca953x_chip *chip = i2c_get_clientdata(client);
226 int ret = 0; 226 int ret = 0;
227 227
228 if (pdata->teardown) { 228 if (pdata->teardown) {
@@ -246,26 +246,26 @@ static int pca9539_remove(struct i2c_client *client)
246 return 0; 246 return 0;
247} 247}
248 248
249static struct i2c_driver pca9539_driver = { 249static struct i2c_driver pca953x_driver = {
250 .driver = { 250 .driver = {
251 .name = "pca9539", 251 .name = "pca953x",
252 }, 252 },
253 .probe = pca9539_probe, 253 .probe = pca953x_probe,
254 .remove = pca9539_remove, 254 .remove = pca953x_remove,
255}; 255};
256 256
257static int __init pca9539_init(void) 257static int __init pca953x_init(void)
258{ 258{
259 return i2c_add_driver(&pca9539_driver); 259 return i2c_add_driver(&pca953x_driver);
260} 260}
261module_init(pca9539_init); 261module_init(pca953x_init);
262 262
263static void __exit pca9539_exit(void) 263static void __exit pca953x_exit(void)
264{ 264{
265 i2c_del_driver(&pca9539_driver); 265 i2c_del_driver(&pca953x_driver);
266} 266}
267module_exit(pca9539_exit); 267module_exit(pca953x_exit);
268 268
269MODULE_AUTHOR("eric miao <eric.miao@marvell.com>"); 269MODULE_AUTHOR("eric miao <eric.miao@marvell.com>");
270MODULE_DESCRIPTION("GPIO expander driver for PCA9539"); 270MODULE_DESCRIPTION("GPIO expander driver for PCA953x");
271MODULE_LICENSE("GPL"); 271MODULE_LICENSE("GPL");