aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2010-05-22 02:36:56 -0400
committerGrant Likely <grant.likely@secretlab.ca>2010-05-22 02:36:56 -0400
commitcf9b59e9d3e008591d1f54830f570982bb307a0d (patch)
tree113478ce8fd8c832ba726ffdf59b82cb46356476 /drivers/gpio
parent44504b2bebf8b5823c59484e73096a7d6574471d (diff)
parentf4b87dee923342505e1ddba8d34ce9de33e75050 (diff)
Merge remote branch 'origin' into secretlab/next-devicetree
Merging in current state of Linus' tree to deal with merge conflicts and build failures in vio.c after merge. Conflicts: drivers/i2c/busses/i2c-cpm.c drivers/i2c/busses/i2c-mpc.c drivers/net/gianfar.c Also fixed up one line in arch/powerpc/kernel/vio.c to use the correct node pointer. Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpiolib.c5
-rw-r--r--drivers/gpio/it8761e_gpio.c18
-rw-r--r--drivers/gpio/pca953x.c14
-rw-r--r--drivers/gpio/pl061.c14
-rw-r--r--drivers/gpio/wm8994-gpio.c12
5 files changed, 47 insertions, 16 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 76be229c814d..cae1b8c5b08c 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -399,7 +399,7 @@ static int gpio_setup_irq(struct gpio_desc *desc, struct device *dev,
399 goto free_id; 399 goto free_id;
400 } 400 }
401 401
402 pdesc->value_sd = sysfs_get_dirent(dev->kobj.sd, "value"); 402 pdesc->value_sd = sysfs_get_dirent(dev->kobj.sd, NULL, "value");
403 if (!pdesc->value_sd) { 403 if (!pdesc->value_sd) {
404 ret = -ENODEV; 404 ret = -ENODEV;
405 goto free_id; 405 goto free_id;
@@ -416,7 +416,8 @@ static int gpio_setup_irq(struct gpio_desc *desc, struct device *dev,
416 return 0; 416 return 0;
417 417
418free_sd: 418free_sd:
419 sysfs_put(pdesc->value_sd); 419 if (pdesc)
420 sysfs_put(pdesc->value_sd);
420free_id: 421free_id:
421 idr_remove(&pdesc_idr, id); 422 idr_remove(&pdesc_idr, id);
422 desc->flags &= GPIO_FLAGS_MASK; 423 desc->flags &= GPIO_FLAGS_MASK;
diff --git a/drivers/gpio/it8761e_gpio.c b/drivers/gpio/it8761e_gpio.c
index 753219cf993a..41a9388f2fde 100644
--- a/drivers/gpio/it8761e_gpio.c
+++ b/drivers/gpio/it8761e_gpio.c
@@ -80,8 +80,8 @@ static int it8761e_gpio_get(struct gpio_chip *gc, unsigned gpio_num)
80 u16 reg; 80 u16 reg;
81 u8 bit; 81 u8 bit;
82 82
83 bit = gpio_num % 7; 83 bit = gpio_num % 8;
84 reg = (gpio_num >= 7) ? gpio_ba + 1 : gpio_ba; 84 reg = (gpio_num >= 8) ? gpio_ba + 1 : gpio_ba;
85 85
86 return !!(inb(reg) & (1 << bit)); 86 return !!(inb(reg) & (1 << bit));
87} 87}
@@ -91,8 +91,8 @@ static int it8761e_gpio_direction_in(struct gpio_chip *gc, unsigned gpio_num)
91 u8 curr_dirs; 91 u8 curr_dirs;
92 u8 io_reg, bit; 92 u8 io_reg, bit;
93 93
94 bit = gpio_num % 7; 94 bit = gpio_num % 8;
95 io_reg = (gpio_num >= 7) ? GPIO2X_IO : GPIO1X_IO; 95 io_reg = (gpio_num >= 8) ? GPIO2X_IO : GPIO1X_IO;
96 96
97 spin_lock(&sio_lock); 97 spin_lock(&sio_lock);
98 98
@@ -116,8 +116,8 @@ static void it8761e_gpio_set(struct gpio_chip *gc,
116 u8 curr_vals, bit; 116 u8 curr_vals, bit;
117 u16 reg; 117 u16 reg;
118 118
119 bit = gpio_num % 7; 119 bit = gpio_num % 8;
120 reg = (gpio_num >= 7) ? gpio_ba + 1 : gpio_ba; 120 reg = (gpio_num >= 8) ? gpio_ba + 1 : gpio_ba;
121 121
122 spin_lock(&sio_lock); 122 spin_lock(&sio_lock);
123 123
@@ -135,8 +135,8 @@ static int it8761e_gpio_direction_out(struct gpio_chip *gc,
135{ 135{
136 u8 curr_dirs, io_reg, bit; 136 u8 curr_dirs, io_reg, bit;
137 137
138 bit = gpio_num % 7; 138 bit = gpio_num % 8;
139 io_reg = (gpio_num >= 7) ? GPIO2X_IO : GPIO1X_IO; 139 io_reg = (gpio_num >= 8) ? GPIO2X_IO : GPIO1X_IO;
140 140
141 it8761e_gpio_set(gc, gpio_num, val); 141 it8761e_gpio_set(gc, gpio_num, val);
142 142
@@ -200,7 +200,7 @@ static int __init it8761e_gpio_init(void)
200 return -EBUSY; 200 return -EBUSY;
201 201
202 it8761e_gpio_chip.base = -1; 202 it8761e_gpio_chip.base = -1;
203 it8761e_gpio_chip.ngpio = 14; 203 it8761e_gpio_chip.ngpio = 16;
204 204
205 err = gpiochip_add(&it8761e_gpio_chip); 205 err = gpiochip_add(&it8761e_gpio_chip);
206 if (err < 0) 206 if (err < 0)
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c
index 1db114b09990..f156ab3bb6ed 100644
--- a/drivers/gpio/pca953x.c
+++ b/drivers/gpio/pca953x.c
@@ -252,6 +252,18 @@ static void pca953x_irq_bus_lock(unsigned int irq)
252static void pca953x_irq_bus_sync_unlock(unsigned int irq) 252static void pca953x_irq_bus_sync_unlock(unsigned int irq)
253{ 253{
254 struct pca953x_chip *chip = get_irq_chip_data(irq); 254 struct pca953x_chip *chip = get_irq_chip_data(irq);
255 uint16_t new_irqs;
256 uint16_t level;
257
258 /* Look for any newly setup interrupt */
259 new_irqs = chip->irq_trig_fall | chip->irq_trig_raise;
260 new_irqs &= ~chip->reg_direction;
261
262 while (new_irqs) {
263 level = __ffs(new_irqs);
264 pca953x_gpio_direction_input(&chip->gpio_chip, level);
265 new_irqs &= ~(1 << level);
266 }
255 267
256 mutex_unlock(&chip->irq_lock); 268 mutex_unlock(&chip->irq_lock);
257} 269}
@@ -278,7 +290,7 @@ static int pca953x_irq_set_type(unsigned int irq, unsigned int type)
278 else 290 else
279 chip->irq_trig_raise &= ~mask; 291 chip->irq_trig_raise &= ~mask;
280 292
281 return pca953x_gpio_direction_input(&chip->gpio_chip, level); 293 return 0;
282} 294}
283 295
284static struct irq_chip pca953x_irq_chip = { 296static struct irq_chip pca953x_irq_chip = {
diff --git a/drivers/gpio/pl061.c b/drivers/gpio/pl061.c
index 5ad8f778ced4..105701a1f05b 100644
--- a/drivers/gpio/pl061.c
+++ b/drivers/gpio/pl061.c
@@ -91,6 +91,12 @@ static int pl061_direction_output(struct gpio_chip *gc, unsigned offset,
91 gpiodir = readb(chip->base + GPIODIR); 91 gpiodir = readb(chip->base + GPIODIR);
92 gpiodir |= 1 << offset; 92 gpiodir |= 1 << offset;
93 writeb(gpiodir, chip->base + GPIODIR); 93 writeb(gpiodir, chip->base + GPIODIR);
94
95 /*
96 * gpio value is set again, because pl061 doesn't allow to set value of
97 * a gpio pin before configuring it in OUT mode.
98 */
99 writeb(!!value << offset, chip->base + (1 << (offset + 2)));
94 spin_unlock_irqrestore(&chip->lock, flags); 100 spin_unlock_irqrestore(&chip->lock, flags);
95 101
96 return 0; 102 return 0;
@@ -183,7 +189,7 @@ static int pl061_irq_type(unsigned irq, unsigned trigger)
183 gpioibe &= ~(1 << offset); 189 gpioibe &= ~(1 << offset);
184 if (trigger & IRQ_TYPE_EDGE_RISING) 190 if (trigger & IRQ_TYPE_EDGE_RISING)
185 gpioiev |= 1 << offset; 191 gpioiev |= 1 << offset;
186 else 192 else if (trigger & IRQ_TYPE_EDGE_FALLING)
187 gpioiev &= ~(1 << offset); 193 gpioiev &= ~(1 << offset);
188 } 194 }
189 writeb(gpioibe, chip->base + GPIOIBE); 195 writeb(gpioibe, chip->base + GPIOIBE);
@@ -204,7 +210,7 @@ static struct irq_chip pl061_irqchip = {
204 210
205static void pl061_irq_handler(unsigned irq, struct irq_desc *desc) 211static void pl061_irq_handler(unsigned irq, struct irq_desc *desc)
206{ 212{
207 struct list_head *chip_list = get_irq_chip_data(irq); 213 struct list_head *chip_list = get_irq_data(irq);
208 struct list_head *ptr; 214 struct list_head *ptr;
209 struct pl061_gpio *chip; 215 struct pl061_gpio *chip;
210 216
@@ -297,9 +303,9 @@ static int __init pl061_probe(struct amba_device *dev, struct amba_id *id)
297 goto iounmap; 303 goto iounmap;
298 } 304 }
299 INIT_LIST_HEAD(chip_list); 305 INIT_LIST_HEAD(chip_list);
300 set_irq_chip_data(irq, chip_list); 306 set_irq_data(irq, chip_list);
301 } else 307 } else
302 chip_list = get_irq_chip_data(irq); 308 chip_list = get_irq_data(irq);
303 list_add(&chip->list, chip_list); 309 list_add(&chip->list, chip_list);
304 310
305 for (i = 0; i < PL061_GPIO_NR; i++) { 311 for (i = 0; i < PL061_GPIO_NR; i++) {
diff --git a/drivers/gpio/wm8994-gpio.c b/drivers/gpio/wm8994-gpio.c
index 7607cc61e1dd..2ac9a16d3daa 100644
--- a/drivers/gpio/wm8994-gpio.c
+++ b/drivers/gpio/wm8994-gpio.c
@@ -81,6 +81,18 @@ static void wm8994_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
81 wm8994_set_bits(wm8994, WM8994_GPIO_1 + offset, WM8994_GPN_LVL, value); 81 wm8994_set_bits(wm8994, WM8994_GPIO_1 + offset, WM8994_GPN_LVL, value);
82} 82}
83 83
84static int wm8994_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
85{
86 struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip);
87 struct wm8994 *wm8994 = wm8994_gpio->wm8994;
88
89 if (!wm8994->irq_base)
90 return -EINVAL;
91
92 return wm8994->irq_base + offset;
93}
94
95
84#ifdef CONFIG_DEBUG_FS 96#ifdef CONFIG_DEBUG_FS
85static void wm8994_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) 97static void wm8994_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
86{ 98{