diff options
| -rw-r--r-- | drivers/gpio/gpio-da9052.c | 21 | ||||
| -rw-r--r-- | drivers/gpio/gpio-ml-ioh.c | 32 | ||||
| -rw-r--r-- | drivers/gpio/gpio-mpc8xxx.c | 18 | ||||
| -rw-r--r-- | drivers/gpio/gpio-pl061.c | 4 |
4 files changed, 52 insertions, 23 deletions
diff --git a/drivers/gpio/gpio-da9052.c b/drivers/gpio/gpio-da9052.c index 038f5eb8b13d..f8ce29ef9f88 100644 --- a/drivers/gpio/gpio-da9052.c +++ b/drivers/gpio/gpio-da9052.c | |||
| @@ -22,7 +22,6 @@ | |||
| 22 | #include <linux/mfd/da9052/da9052.h> | 22 | #include <linux/mfd/da9052/da9052.h> |
| 23 | #include <linux/mfd/da9052/reg.h> | 23 | #include <linux/mfd/da9052/reg.h> |
| 24 | #include <linux/mfd/da9052/pdata.h> | 24 | #include <linux/mfd/da9052/pdata.h> |
| 25 | #include <linux/mfd/da9052/gpio.h> | ||
| 26 | 25 | ||
| 27 | #define DA9052_INPUT 1 | 26 | #define DA9052_INPUT 1 |
| 28 | #define DA9052_OUTPUT_OPENDRAIN 2 | 27 | #define DA9052_OUTPUT_OPENDRAIN 2 |
| @@ -43,6 +42,9 @@ | |||
| 43 | #define DA9052_GPIO_MASK_UPPER_NIBBLE 0xF0 | 42 | #define DA9052_GPIO_MASK_UPPER_NIBBLE 0xF0 |
| 44 | #define DA9052_GPIO_MASK_LOWER_NIBBLE 0x0F | 43 | #define DA9052_GPIO_MASK_LOWER_NIBBLE 0x0F |
| 45 | #define DA9052_GPIO_NIBBLE_SHIFT 4 | 44 | #define DA9052_GPIO_NIBBLE_SHIFT 4 |
| 45 | #define DA9052_IRQ_GPI0 16 | ||
| 46 | #define DA9052_GPIO_ODD_SHIFT 7 | ||
| 47 | #define DA9052_GPIO_EVEN_SHIFT 3 | ||
| 46 | 48 | ||
| 47 | struct da9052_gpio { | 49 | struct da9052_gpio { |
| 48 | struct da9052 *da9052; | 50 | struct da9052 *da9052; |
| @@ -104,33 +106,26 @@ static int da9052_gpio_get(struct gpio_chip *gc, unsigned offset) | |||
| 104 | static void da9052_gpio_set(struct gpio_chip *gc, unsigned offset, int value) | 106 | static void da9052_gpio_set(struct gpio_chip *gc, unsigned offset, int value) |
| 105 | { | 107 | { |
| 106 | struct da9052_gpio *gpio = to_da9052_gpio(gc); | 108 | struct da9052_gpio *gpio = to_da9052_gpio(gc); |
| 107 | unsigned char register_value = 0; | ||
| 108 | int ret; | 109 | int ret; |
| 109 | 110 | ||
| 110 | if (da9052_gpio_port_odd(offset)) { | 111 | if (da9052_gpio_port_odd(offset)) { |
| 111 | if (value) { | ||
| 112 | register_value = DA9052_GPIO_ODD_PORT_MODE; | ||
| 113 | ret = da9052_reg_update(gpio->da9052, (offset >> 1) + | 112 | ret = da9052_reg_update(gpio->da9052, (offset >> 1) + |
| 114 | DA9052_GPIO_0_1_REG, | 113 | DA9052_GPIO_0_1_REG, |
| 115 | DA9052_GPIO_ODD_PORT_MODE, | 114 | DA9052_GPIO_ODD_PORT_MODE, |
| 116 | register_value); | 115 | value << DA9052_GPIO_ODD_SHIFT); |
| 117 | if (ret != 0) | 116 | if (ret != 0) |
| 118 | dev_err(gpio->da9052->dev, | 117 | dev_err(gpio->da9052->dev, |
| 119 | "Failed to updated gpio odd reg,%d", | 118 | "Failed to updated gpio odd reg,%d", |
| 120 | ret); | 119 | ret); |
| 121 | } | ||
| 122 | } else { | 120 | } else { |
| 123 | if (value) { | ||
| 124 | register_value = DA9052_GPIO_EVEN_PORT_MODE; | ||
| 125 | ret = da9052_reg_update(gpio->da9052, (offset >> 1) + | 121 | ret = da9052_reg_update(gpio->da9052, (offset >> 1) + |
| 126 | DA9052_GPIO_0_1_REG, | 122 | DA9052_GPIO_0_1_REG, |
| 127 | DA9052_GPIO_EVEN_PORT_MODE, | 123 | DA9052_GPIO_EVEN_PORT_MODE, |
| 128 | register_value); | 124 | value << DA9052_GPIO_EVEN_SHIFT); |
| 129 | if (ret != 0) | 125 | if (ret != 0) |
| 130 | dev_err(gpio->da9052->dev, | 126 | dev_err(gpio->da9052->dev, |
| 131 | "Failed to updated gpio even reg,%d", | 127 | "Failed to updated gpio even reg,%d", |
| 132 | ret); | 128 | ret); |
| 133 | } | ||
| 134 | } | 129 | } |
| 135 | } | 130 | } |
| 136 | 131 | ||
| @@ -201,9 +196,9 @@ static struct gpio_chip reference_gp __devinitdata = { | |||
| 201 | .direction_input = da9052_gpio_direction_input, | 196 | .direction_input = da9052_gpio_direction_input, |
| 202 | .direction_output = da9052_gpio_direction_output, | 197 | .direction_output = da9052_gpio_direction_output, |
| 203 | .to_irq = da9052_gpio_to_irq, | 198 | .to_irq = da9052_gpio_to_irq, |
| 204 | .can_sleep = 1; | 199 | .can_sleep = 1, |
| 205 | .ngpio = 16; | 200 | .ngpio = 16, |
| 206 | .base = -1; | 201 | .base = -1, |
| 207 | }; | 202 | }; |
| 208 | 203 | ||
| 209 | static int __devinit da9052_gpio_probe(struct platform_device *pdev) | 204 | static int __devinit da9052_gpio_probe(struct platform_device *pdev) |
diff --git a/drivers/gpio/gpio-ml-ioh.c b/drivers/gpio/gpio-ml-ioh.c index ea8e73869250..461958fc2264 100644 --- a/drivers/gpio/gpio-ml-ioh.c +++ b/drivers/gpio/gpio-ml-ioh.c | |||
| @@ -332,6 +332,34 @@ static void ioh_irq_mask(struct irq_data *d) | |||
| 332 | &chip->reg->regs[chip->ch].imask); | 332 | &chip->reg->regs[chip->ch].imask); |
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | static void ioh_irq_disable(struct irq_data *d) | ||
| 336 | { | ||
| 337 | struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); | ||
| 338 | struct ioh_gpio *chip = gc->private; | ||
| 339 | unsigned long flags; | ||
| 340 | u32 ien; | ||
| 341 | |||
| 342 | spin_lock_irqsave(&chip->spinlock, flags); | ||
| 343 | ien = ioread32(&chip->reg->regs[chip->ch].ien); | ||
| 344 | ien &= ~(1 << (d->irq - chip->irq_base)); | ||
| 345 | iowrite32(ien, &chip->reg->regs[chip->ch].ien); | ||
| 346 | spin_unlock_irqrestore(&chip->spinlock, flags); | ||
| 347 | } | ||
| 348 | |||
| 349 | static void ioh_irq_enable(struct irq_data *d) | ||
| 350 | { | ||
| 351 | struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); | ||
| 352 | struct ioh_gpio *chip = gc->private; | ||
| 353 | unsigned long flags; | ||
| 354 | u32 ien; | ||
| 355 | |||
| 356 | spin_lock_irqsave(&chip->spinlock, flags); | ||
| 357 | ien = ioread32(&chip->reg->regs[chip->ch].ien); | ||
| 358 | ien |= 1 << (d->irq - chip->irq_base); | ||
| 359 | iowrite32(ien, &chip->reg->regs[chip->ch].ien); | ||
| 360 | spin_unlock_irqrestore(&chip->spinlock, flags); | ||
| 361 | } | ||
| 362 | |||
| 335 | static irqreturn_t ioh_gpio_handler(int irq, void *dev_id) | 363 | static irqreturn_t ioh_gpio_handler(int irq, void *dev_id) |
| 336 | { | 364 | { |
| 337 | struct ioh_gpio *chip = dev_id; | 365 | struct ioh_gpio *chip = dev_id; |
| @@ -339,7 +367,7 @@ static irqreturn_t ioh_gpio_handler(int irq, void *dev_id) | |||
| 339 | int i, j; | 367 | int i, j; |
| 340 | int ret = IRQ_NONE; | 368 | int ret = IRQ_NONE; |
| 341 | 369 | ||
| 342 | for (i = 0; i < 8; i++) { | 370 | for (i = 0; i < 8; i++, chip++) { |
| 343 | reg_val = ioread32(&chip->reg->regs[i].istatus); | 371 | reg_val = ioread32(&chip->reg->regs[i].istatus); |
| 344 | for (j = 0; j < num_ports[i]; j++) { | 372 | for (j = 0; j < num_ports[i]; j++) { |
| 345 | if (reg_val & BIT(j)) { | 373 | if (reg_val & BIT(j)) { |
| @@ -370,6 +398,8 @@ static __devinit void ioh_gpio_alloc_generic_chip(struct ioh_gpio *chip, | |||
| 370 | ct->chip.irq_mask = ioh_irq_mask; | 398 | ct->chip.irq_mask = ioh_irq_mask; |
| 371 | ct->chip.irq_unmask = ioh_irq_unmask; | 399 | ct->chip.irq_unmask = ioh_irq_unmask; |
| 372 | ct->chip.irq_set_type = ioh_irq_type; | 400 | ct->chip.irq_set_type = ioh_irq_type; |
| 401 | ct->chip.irq_disable = ioh_irq_disable; | ||
| 402 | ct->chip.irq_enable = ioh_irq_enable; | ||
| 373 | 403 | ||
| 374 | irq_setup_generic_chip(gc, IRQ_MSK(num), IRQ_GC_INIT_MASK_CACHE, | 404 | irq_setup_generic_chip(gc, IRQ_MSK(num), IRQ_GC_INIT_MASK_CACHE, |
| 375 | IRQ_NOREQUEST | IRQ_NOPROBE, 0); | 405 | IRQ_NOREQUEST | IRQ_NOPROBE, 0); |
diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c index ec3fcf0a7e12..5cd04b65c556 100644 --- a/drivers/gpio/gpio-mpc8xxx.c +++ b/drivers/gpio/gpio-mpc8xxx.c | |||
| @@ -132,6 +132,15 @@ static int mpc8xxx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val | |||
| 132 | return 0; | 132 | return 0; |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | static int mpc5121_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) | ||
| 136 | { | ||
| 137 | /* GPIO 28..31 are input only on MPC5121 */ | ||
| 138 | if (gpio >= 28) | ||
| 139 | return -EINVAL; | ||
| 140 | |||
| 141 | return mpc8xxx_gpio_dir_out(gc, gpio, val); | ||
| 142 | } | ||
| 143 | |||
| 135 | static int mpc8xxx_gpio_to_irq(struct gpio_chip *gc, unsigned offset) | 144 | static int mpc8xxx_gpio_to_irq(struct gpio_chip *gc, unsigned offset) |
| 136 | { | 145 | { |
| 137 | struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); | 146 | struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); |
| @@ -340,11 +349,10 @@ static void __init mpc8xxx_add_controller(struct device_node *np) | |||
| 340 | mm_gc->save_regs = mpc8xxx_gpio_save_regs; | 349 | mm_gc->save_regs = mpc8xxx_gpio_save_regs; |
| 341 | gc->ngpio = MPC8XXX_GPIO_PINS; | 350 | gc->ngpio = MPC8XXX_GPIO_PINS; |
| 342 | gc->direction_input = mpc8xxx_gpio_dir_in; | 351 | gc->direction_input = mpc8xxx_gpio_dir_in; |
| 343 | gc->direction_output = mpc8xxx_gpio_dir_out; | 352 | gc->direction_output = of_device_is_compatible(np, "fsl,mpc5121-gpio") ? |
| 344 | if (of_device_is_compatible(np, "fsl,mpc8572-gpio")) | 353 | mpc5121_gpio_dir_out : mpc8xxx_gpio_dir_out; |
| 345 | gc->get = mpc8572_gpio_get; | 354 | gc->get = of_device_is_compatible(np, "fsl,mpc8572-gpio") ? |
| 346 | else | 355 | mpc8572_gpio_get : mpc8xxx_gpio_get; |
| 347 | gc->get = mpc8xxx_gpio_get; | ||
| 348 | gc->set = mpc8xxx_gpio_set; | 356 | gc->set = mpc8xxx_gpio_set; |
| 349 | gc->to_irq = mpc8xxx_gpio_to_irq; | 357 | gc->to_irq = mpc8xxx_gpio_to_irq; |
| 350 | 358 | ||
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c index 093c90bd3c1d..4102f63230fd 100644 --- a/drivers/gpio/gpio-pl061.c +++ b/drivers/gpio/gpio-pl061.c | |||
| @@ -238,10 +238,6 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id) | |||
| 238 | int ret, irq, i; | 238 | int ret, irq, i; |
| 239 | static DECLARE_BITMAP(init_irq, NR_IRQS); | 239 | static DECLARE_BITMAP(init_irq, NR_IRQS); |
| 240 | 240 | ||
| 241 | pdata = dev->dev.platform_data; | ||
| 242 | if (pdata == NULL) | ||
| 243 | return -ENODEV; | ||
| 244 | |||
| 245 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | 241 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); |
| 246 | if (chip == NULL) | 242 | if (chip == NULL) |
| 247 | return -ENOMEM; | 243 | return -ENOMEM; |
