diff options
author | Paul Mundt <lethal@linux-sh.org> | 2012-05-24 02:24:39 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2012-05-24 02:24:39 -0400 |
commit | b98b35815f40f01337e25e3f0d10d57b7cec5126 (patch) | |
tree | 99f7817d40796da67c3f7cc5623690b17ad6b288 /arch/sh/boards | |
parent | 3b1267b90f6b7c080024101696c0454f455761f4 (diff) |
sh: mach-x3proto: Migrate to linear irq domain.
In the interest of getting off of the create_irq() API we can get all of
the functionality we're interested in through a linear IRQ domain. Fairly
straightforward conversion utilizing a single linear domain.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/boards')
-rw-r--r-- | arch/sh/boards/Kconfig | 1 | ||||
-rw-r--r-- | arch/sh/boards/mach-x3proto/gpio.c | 57 |
2 files changed, 32 insertions, 26 deletions
diff --git a/arch/sh/boards/Kconfig b/arch/sh/boards/Kconfig index d893411022d5..f2024a91319f 100644 --- a/arch/sh/boards/Kconfig +++ b/arch/sh/boards/Kconfig | |||
@@ -292,6 +292,7 @@ config SH_X3PROTO | |||
292 | bool "SH-X3 Prototype board" | 292 | bool "SH-X3 Prototype board" |
293 | depends on CPU_SUBTYPE_SHX3 | 293 | depends on CPU_SUBTYPE_SHX3 |
294 | select NO_IOPORT if !PCI | 294 | select NO_IOPORT if !PCI |
295 | select IRQ_DOMAIN | ||
295 | 296 | ||
296 | config SH_MAGIC_PANEL_R2 | 297 | config SH_MAGIC_PANEL_R2 |
297 | bool "Magic Panel R2" | 298 | bool "Magic Panel R2" |
diff --git a/arch/sh/boards/mach-x3proto/gpio.c b/arch/sh/boards/mach-x3proto/gpio.c index f33b2b57019c..3ea65e9b56e8 100644 --- a/arch/sh/boards/mach-x3proto/gpio.c +++ b/arch/sh/boards/mach-x3proto/gpio.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Renesas SH-X3 Prototype Baseboard GPIO Support. | 4 | * Renesas SH-X3 Prototype Baseboard GPIO Support. |
5 | * | 5 | * |
6 | * Copyright (C) 2010 Paul Mundt | 6 | * Copyright (C) 2010 - 2012 Paul Mundt |
7 | * | 7 | * |
8 | * This file is subject to the terms and conditions of the GNU General Public | 8 | * This file is subject to the terms and conditions of the GNU General Public |
9 | * License. See the file "COPYING" in the main directory of this archive | 9 | * License. See the file "COPYING" in the main directory of this archive |
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/irq.h> | 17 | #include <linux/irq.h> |
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/spinlock.h> | 19 | #include <linux/spinlock.h> |
20 | #include <linux/irqdomain.h> | ||
20 | #include <linux/io.h> | 21 | #include <linux/io.h> |
21 | #include <mach/ilsel.h> | 22 | #include <mach/ilsel.h> |
22 | #include <mach/hardware.h> | 23 | #include <mach/hardware.h> |
@@ -26,7 +27,7 @@ | |||
26 | #define KEYDETR 0xb81c0004 | 27 | #define KEYDETR 0xb81c0004 |
27 | 28 | ||
28 | static DEFINE_SPINLOCK(x3proto_gpio_lock); | 29 | static DEFINE_SPINLOCK(x3proto_gpio_lock); |
29 | static unsigned int x3proto_gpio_irq_map[NR_BASEBOARD_GPIOS] = { 0, }; | 30 | static struct irq_domain *x3proto_irq_domain; |
30 | 31 | ||
31 | static int x3proto_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) | 32 | static int x3proto_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) |
32 | { | 33 | { |
@@ -49,7 +50,14 @@ static int x3proto_gpio_get(struct gpio_chip *chip, unsigned gpio) | |||
49 | 50 | ||
50 | static int x3proto_gpio_to_irq(struct gpio_chip *chip, unsigned gpio) | 51 | static int x3proto_gpio_to_irq(struct gpio_chip *chip, unsigned gpio) |
51 | { | 52 | { |
52 | return x3proto_gpio_irq_map[gpio]; | 53 | int virq; |
54 | |||
55 | if (gpio < chip->ngpio) | ||
56 | virq = irq_create_mapping(x3proto_irq_domain, gpio); | ||
57 | else | ||
58 | virq = -ENXIO; | ||
59 | |||
60 | return virq; | ||
53 | } | 61 | } |
54 | 62 | ||
55 | static void x3proto_gpio_irq_handler(unsigned int irq, struct irq_desc *desc) | 63 | static void x3proto_gpio_irq_handler(unsigned int irq, struct irq_desc *desc) |
@@ -62,9 +70,8 @@ static void x3proto_gpio_irq_handler(unsigned int irq, struct irq_desc *desc) | |||
62 | chip->irq_mask_ack(data); | 70 | chip->irq_mask_ack(data); |
63 | 71 | ||
64 | mask = __raw_readw(KEYDETR); | 72 | mask = __raw_readw(KEYDETR); |
65 | |||
66 | for_each_set_bit(pin, &mask, NR_BASEBOARD_GPIOS) | 73 | for_each_set_bit(pin, &mask, NR_BASEBOARD_GPIOS) |
67 | generic_handle_irq(x3proto_gpio_to_irq(NULL, pin)); | 74 | generic_handle_irq(irq_linear_revmap(x3proto_irq_domain, pin)); |
68 | 75 | ||
69 | chip->irq_unmask(data); | 76 | chip->irq_unmask(data); |
70 | } | 77 | } |
@@ -78,10 +85,23 @@ struct gpio_chip x3proto_gpio_chip = { | |||
78 | .ngpio = NR_BASEBOARD_GPIOS, | 85 | .ngpio = NR_BASEBOARD_GPIOS, |
79 | }; | 86 | }; |
80 | 87 | ||
88 | static int x3proto_gpio_irq_map(struct irq_domain *domain, unsigned int virq, | ||
89 | irq_hw_number_t hwirq) | ||
90 | { | ||
91 | irq_set_chip_and_handler_name(virq, &dummy_irq_chip, handle_simple_irq, | ||
92 | "gpio"); | ||
93 | |||
94 | return 0; | ||
95 | } | ||
96 | |||
97 | static struct irq_domain_ops x3proto_gpio_irq_ops = { | ||
98 | .map = x3proto_gpio_irq_map, | ||
99 | .xlate = irq_domain_xlate_twocell, | ||
100 | }; | ||
101 | |||
81 | int __init x3proto_gpio_setup(void) | 102 | int __init x3proto_gpio_setup(void) |
82 | { | 103 | { |
83 | int ilsel; | 104 | int ilsel, ret; |
84 | int ret, i; | ||
85 | 105 | ||
86 | ilsel = ilsel_enable(ILSEL_KEY); | 106 | ilsel = ilsel_enable(ILSEL_KEY); |
87 | if (unlikely(ilsel < 0)) | 107 | if (unlikely(ilsel < 0)) |
@@ -91,21 +111,10 @@ int __init x3proto_gpio_setup(void) | |||
91 | if (unlikely(ret)) | 111 | if (unlikely(ret)) |
92 | goto err_gpio; | 112 | goto err_gpio; |
93 | 113 | ||
94 | for (i = 0; i < NR_BASEBOARD_GPIOS; i++) { | 114 | x3proto_irq_domain = irq_domain_add_linear(NULL, NR_BASEBOARD_GPIOS, |
95 | unsigned long flags; | 115 | &x3proto_gpio_irq_ops, NULL); |
96 | int irq = create_irq(); | 116 | if (unlikely(!x3proto_irq_domain)) |
97 | 117 | goto err_irq; | |
98 | if (unlikely(irq < 0)) { | ||
99 | ret = -EINVAL; | ||
100 | goto err_irq; | ||
101 | } | ||
102 | |||
103 | spin_lock_irqsave(&x3proto_gpio_lock, flags); | ||
104 | x3proto_gpio_irq_map[i] = irq; | ||
105 | irq_set_chip_and_handler_name(irq, &dummy_irq_chip, | ||
106 | handle_simple_irq, "gpio"); | ||
107 | spin_unlock_irqrestore(&x3proto_gpio_lock, flags); | ||
108 | } | ||
109 | 118 | ||
110 | pr_info("registering '%s' support, handling GPIOs %u -> %u, " | 119 | pr_info("registering '%s' support, handling GPIOs %u -> %u, " |
111 | "bound to IRQ %u\n", | 120 | "bound to IRQ %u\n", |
@@ -119,10 +128,6 @@ int __init x3proto_gpio_setup(void) | |||
119 | return 0; | 128 | return 0; |
120 | 129 | ||
121 | err_irq: | 130 | err_irq: |
122 | for (; i >= 0; --i) | ||
123 | if (x3proto_gpio_irq_map[i]) | ||
124 | destroy_irq(x3proto_gpio_irq_map[i]); | ||
125 | |||
126 | ret = gpiochip_remove(&x3proto_gpio_chip); | 131 | ret = gpiochip_remove(&x3proto_gpio_chip); |
127 | if (unlikely(ret)) | 132 | if (unlikely(ret)) |
128 | pr_err("Failed deregistering GPIO\n"); | 133 | pr_err("Failed deregistering GPIO\n"); |