diff options
-rw-r--r-- | drivers/gpio/max730x.c | 22 | ||||
-rw-r--r-- | include/linux/spi/max7301.h | 8 |
2 files changed, 23 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; |
diff --git a/include/linux/spi/max7301.h b/include/linux/spi/max7301.h index 34af0a3477bf..bcaa2f762cc1 100644 --- a/include/linux/spi/max7301.h +++ b/include/linux/spi/max7301.h | |||
@@ -11,6 +11,7 @@ struct max7301 { | |||
11 | struct mutex lock; | 11 | struct mutex lock; |
12 | u8 port_config[8]; /* field 0 is unused */ | 12 | u8 port_config[8]; /* field 0 is unused */ |
13 | u32 out_level; /* cached output levels */ | 13 | u32 out_level; /* cached output levels */ |
14 | u32 input_pullup_active; | ||
14 | struct gpio_chip chip; | 15 | struct gpio_chip chip; |
15 | struct device *dev; | 16 | struct device *dev; |
16 | int (*write)(struct device *dev, unsigned int reg, unsigned int val); | 17 | int (*write)(struct device *dev, unsigned int reg, unsigned int val); |
@@ -20,6 +21,13 @@ struct max7301 { | |||
20 | struct max7301_platform_data { | 21 | struct max7301_platform_data { |
21 | /* number assigned to the first GPIO */ | 22 | /* number assigned to the first GPIO */ |
22 | unsigned base; | 23 | unsigned base; |
24 | /* | ||
25 | * bitmask controlling the pullup configuration, | ||
26 | * | ||
27 | * _note_ the 4 lowest bits are unused, because the first 4 | ||
28 | * ports of the controller are not used, too. | ||
29 | */ | ||
30 | u32 input_pullup_active; | ||
23 | }; | 31 | }; |
24 | 32 | ||
25 | extern int __max730x_remove(struct device *dev); | 33 | extern int __max730x_remove(struct device *dev); |