diff options
author | Keerthy <j-keerthy@ti.com> | 2017-01-17 11:19:11 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2017-01-26 04:00:20 -0500 |
commit | 8f7cf8c65746d94d58fa94edc134a22a7e528de4 (patch) | |
tree | 47d8d74c073a61d20814eaa7d2393787ea484655 /drivers/gpio/gpio-davinci.c | |
parent | fbc2a294f29e726787a0f5238b27137904f26b81 (diff) |
gpio: davinci: Remove gpio2regs function
gpio2regs is written making an assumption that driver supports only
one instance of gpio controller. Removing this and adding a generic
array so as to support multiple instances of gpio controllers.
Signed-off-by: Keerthy <j-keerthy@ti.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-davinci.c')
-rw-r--r-- | drivers/gpio/gpio-davinci.c | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index 163f81e3db83..bb47de3daafa 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c | |||
@@ -43,25 +43,7 @@ typedef struct irq_chip *(*gpio_get_irq_chip_cb_t)(unsigned int irq); | |||
43 | #define MAX_LABEL_SIZE 20 | 43 | #define MAX_LABEL_SIZE 20 |
44 | 44 | ||
45 | static void __iomem *gpio_base; | 45 | static void __iomem *gpio_base; |
46 | 46 | static unsigned int offset_array[5] = {0x10, 0x38, 0x60, 0x88, 0xb0}; | |
47 | static struct davinci_gpio_regs __iomem *gpio2regs(unsigned gpio) | ||
48 | { | ||
49 | void __iomem *ptr; | ||
50 | |||
51 | if (gpio < 32 * 1) | ||
52 | ptr = gpio_base + 0x10; | ||
53 | else if (gpio < 32 * 2) | ||
54 | ptr = gpio_base + 0x38; | ||
55 | else if (gpio < 32 * 3) | ||
56 | ptr = gpio_base + 0x60; | ||
57 | else if (gpio < 32 * 4) | ||
58 | ptr = gpio_base + 0x88; | ||
59 | else if (gpio < 32 * 5) | ||
60 | ptr = gpio_base + 0xb0; | ||
61 | else | ||
62 | ptr = NULL; | ||
63 | return ptr; | ||
64 | } | ||
65 | 47 | ||
66 | static inline struct davinci_gpio_regs __iomem *irq2regs(struct irq_data *d) | 48 | static inline struct davinci_gpio_regs __iomem *irq2regs(struct irq_data *d) |
67 | { | 49 | { |
@@ -262,7 +244,7 @@ static int davinci_gpio_probe(struct platform_device *pdev) | |||
262 | #endif | 244 | #endif |
263 | spin_lock_init(&chips[i].lock); | 245 | spin_lock_init(&chips[i].lock); |
264 | 246 | ||
265 | regs = gpio2regs(base); | 247 | regs = gpio_base + offset_array[i]; |
266 | if (!regs) | 248 | if (!regs) |
267 | return -ENXIO; | 249 | return -ENXIO; |
268 | chips[i].regs = regs; | 250 | chips[i].regs = regs; |
@@ -417,7 +399,9 @@ static int | |||
417 | davinci_gpio_irq_map(struct irq_domain *d, unsigned int irq, | 399 | davinci_gpio_irq_map(struct irq_domain *d, unsigned int irq, |
418 | irq_hw_number_t hw) | 400 | irq_hw_number_t hw) |
419 | { | 401 | { |
420 | struct davinci_gpio_regs __iomem *g = gpio2regs(hw); | 402 | struct davinci_gpio_controller *chips = |
403 | (struct davinci_gpio_controller *)d->host_data; | ||
404 | struct davinci_gpio_regs __iomem *g = chips[hw / 32].regs; | ||
421 | 405 | ||
422 | irq_set_chip_and_handler_name(irq, &gpio_irqchip, handle_simple_irq, | 406 | irq_set_chip_and_handler_name(irq, &gpio_irqchip, handle_simple_irq, |
423 | "davinci_gpio"); | 407 | "davinci_gpio"); |
@@ -554,7 +538,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev) | |||
554 | irq_chip->irq_set_type = gpio_irq_type_unbanked; | 538 | irq_chip->irq_set_type = gpio_irq_type_unbanked; |
555 | 539 | ||
556 | /* default trigger: both edges */ | 540 | /* default trigger: both edges */ |
557 | g = gpio2regs(0); | 541 | g = chips[0].regs; |
558 | writel_relaxed(~0, &g->set_falling); | 542 | writel_relaxed(~0, &g->set_falling); |
559 | writel_relaxed(~0, &g->set_rising); | 543 | writel_relaxed(~0, &g->set_rising); |
560 | 544 | ||
@@ -573,8 +557,11 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev) | |||
573 | * then chain through our own handler. | 557 | * then chain through our own handler. |
574 | */ | 558 | */ |
575 | for (gpio = 0, bank = 0; gpio < ngpio; bank++, bank_irq++, gpio += 16) { | 559 | for (gpio = 0, bank = 0; gpio < ngpio; bank++, bank_irq++, gpio += 16) { |
576 | /* disabled by default, enabled only as needed */ | 560 | /* disabled by default, enabled only as needed |
577 | g = gpio2regs(gpio); | 561 | * There are register sets for 32 GPIOs. 2 banks of 16 |
562 | * GPIOs are covered by each set of registers hence divide by 2 | ||
563 | */ | ||
564 | g = chips[bank / 2].regs; | ||
578 | writel_relaxed(~0, &g->clr_falling); | 565 | writel_relaxed(~0, &g->clr_falling); |
579 | writel_relaxed(~0, &g->clr_rising); | 566 | writel_relaxed(~0, &g->clr_rising); |
580 | 567 | ||