aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2010-08-10 21:02:23 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-11 11:59:08 -0400
commit4a22b8a4ad5561436b16f5278d2f9e406ffb8705 (patch)
tree8569c6dd4cc215876156fa5b2721ad1a487b9c88 /drivers/gpio
parent22e3d63147c9608dc48ac6a6d9973eba8672efbe (diff)
gpio: max730x: make pullups configurable via platformdata
The gpios on the max730x chips have support for internal pullups while in input mode. This patch adds support for configuring these pullups via platform data. A new member ("input_pullup_active") to the platform data struct is introduced. A set bit in this variable activates the pullups while the respective port is in input mode. This is a compatible enhancement since unset bits lead to disables pullups which was the default in the original driver. _Note_: the 4 lowest bits in "input_pullup_active" are unused because the first 4 ports of the controller are not used, too. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Reviewed-by: Wolfram Sang <w.sang@pengutronix.de> Cc: David Brownell <david-b@pacbell.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/max730x.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/gpio/max730x.c b/drivers/gpio/max730x.c
index 7696a5625d58..94ce773f95f8 100644
--- a/drivers/gpio/max730x.c
+++ b/drivers/gpio/max730x.c
@@ -54,7 +54,7 @@ static int max7301_direction_input(struct gpio_chip *chip, unsigned offset)
54{ 54{
55 struct max7301 *ts = container_of(chip, struct max7301, chip); 55 struct max7301 *ts = container_of(chip, struct max7301, chip);
56 u8 *config; 56 u8 *config;
57 u8 offset_bits; 57 u8 offset_bits, pin_config;
58 int ret; 58 int ret;
59 59
60 /* First 4 pins are unused in the controller */ 60 /* First 4 pins are unused in the controller */
@@ -63,12 +63,15 @@ static int max7301_direction_input(struct gpio_chip *chip, unsigned offset)
63 63
64 config = &ts->port_config[offset >> 2]; 64 config = &ts->port_config[offset >> 2];
65 65
66 if (ts->input_pullup_active & BIT(offset))
67 pin_config = PIN_CONFIG_IN_PULLUP;
68 else
69 pin_config = PIN_CONFIG_IN_WO_PULLUP;
70
66 mutex_lock(&ts->lock); 71 mutex_lock(&ts->lock);
67 72
68 /* Standard GPIO API doesn't support pull-ups, has to be extended.
69 * Hard-coding no pollup for now. */
70 *config = (*config & ~(PIN_CONFIG_MASK << offset_bits)) 73 *config = (*config & ~(PIN_CONFIG_MASK << offset_bits))
71 | (PIN_CONFIG_IN_WO_PULLUP << offset_bits); 74 | (pin_config << offset_bits);
72 75
73 ret = ts->write(ts->dev, 0x08 + (offset >> 2), *config); 76 ret = ts->write(ts->dev, 0x08 + (offset >> 2), *config);
74 77
@@ -177,6 +180,7 @@ int __devinit __max730x_probe(struct max7301 *ts)
177 /* Power up the chip and disable IRQ output */ 180 /* Power up the chip and disable IRQ output */
178 ts->write(dev, 0x04, 0x01); 181 ts->write(dev, 0x04, 0x01);
179 182
183 ts->input_pullup_active = pdata->input_pullup_active;
180 ts->chip.label = dev->driver->name; 184 ts->chip.label = dev->driver->name;
181 185
182 ts->chip.direction_input = max7301_direction_input; 186 ts->chip.direction_input = max7301_direction_input;
@@ -191,13 +195,17 @@ int __devinit __max730x_probe(struct max7301 *ts)
191 ts->chip.owner = THIS_MODULE; 195 ts->chip.owner = THIS_MODULE;
192 196
193 /* 197 /*
194 * tristate all pins in hardware and cache the 198 * initialize pullups according to platform data and cache the
195 * register values for later use. 199 * register values for later use.
196 */ 200 */
197 for (i = 1; i < 8; i++) { 201 for (i = 1; i < 8; i++) {
198 int j; 202 int j;
199 /* 0xAA means input with internal pullup disabled */ 203 /*
200 ts->write(dev, 0x08 + i, 0xAA); 204 * initialize port_config with "0xAA", which means
205 * input with internal pullup disabled. This is needed
206 * to avoid writing zeros (in the inner for loop),
207 * which is not allowed according to the datasheet.
208 */
201 ts->port_config[i] = 0xAA; 209 ts->port_config[i] = 0xAA;
202 for (j = 0; j < 4; j++) { 210 for (j = 0; j < 4; j++) {
203 int offset = (i - 1) * 4 + j; 211 int offset = (i - 1) * 4 + j;