aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms
diff options
context:
space:
mode:
authorAnton Vorontsov <avorontsov@ru.mvista.com>2010-06-08 09:48:16 -0400
committerGrant Likely <grant.likely@secretlab.ca>2010-07-05 18:14:30 -0400
commita19e3da5bc5fc6c10ab73f310bea80f3845b4531 (patch)
tree49b6e952f48e56d9701f92e0c24044a14b676a34 /arch/powerpc/platforms
parentcedb1881ba32f7e9cd49250bd79debccbe52b094 (diff)
of/gpio: Kill of_gpio_chip and add members directly to gpio_chip
The OF gpio infrastructure is great for describing GPIO connections within the device tree. However, using a GPIO binding still requires changes to the gpio controller just to add an of_gpio structure. In most cases, the gpio controller doesn't actually need any special support and the simple OF gpio mapping function is more than sufficient. Additional, the current scheme of using of_gpio_chip requires a convoluted scheme to maintain 1:1 mappings between of_gpio_chip and gpio_chip instances. If the struct of_gpio_chip data members were moved into struct gpio_chip, then it would simplify the processing of OF gpio bindings, and it would make it trivial to use device tree OF connections on existing gpiolib controller drivers. This patch eliminates the of_gpio_chip structure and moves the relevant fields into struct gpio_chip (conditional on CONFIG_OF_GPIO). This move simplifies the existing code and prepares for adding automatic device tree support to existing drivers. Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Anton Vorontsov <avorontsov@ru.mvista.com> Cc: Grant Likely <grant.likely@secretlab.ca> Cc: David Brownell <dbrownell@users.sourceforge.net> Cc: Bill Gatliff <bgat@billgatliff.com> Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'arch/powerpc/platforms')
-rw-r--r--arch/powerpc/platforms/52xx/mpc52xx_gpio.c32
-rw-r--r--arch/powerpc/platforms/52xx/mpc52xx_gpt.c29
-rw-r--r--arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c15
-rw-r--r--arch/powerpc/platforms/86xx/gef_gpio.c24
4 files changed, 48 insertions, 52 deletions
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_gpio.c b/arch/powerpc/platforms/52xx/mpc52xx_gpio.c
index ca5305a5bd61..fd0912eeffe2 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_gpio.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_gpio.c
@@ -152,21 +152,21 @@ static int __devinit mpc52xx_wkup_gpiochip_probe(struct of_device *ofdev,
152{ 152{
153 struct mpc52xx_gpiochip *chip; 153 struct mpc52xx_gpiochip *chip;
154 struct mpc52xx_gpio_wkup __iomem *regs; 154 struct mpc52xx_gpio_wkup __iomem *regs;
155 struct of_gpio_chip *ofchip; 155 struct gpio_chip *gc;
156 int ret; 156 int ret;
157 157
158 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 158 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
159 if (!chip) 159 if (!chip)
160 return -ENOMEM; 160 return -ENOMEM;
161 161
162 ofchip = &chip->mmchip.of_gc; 162 gc = &chip->mmchip.gc;
163 163
164 ofchip->gpio_cells = 2; 164 gc->of_gpio_n_cells = 2;
165 ofchip->gc.ngpio = 8; 165 gc->ngpio = 8;
166 ofchip->gc.direction_input = mpc52xx_wkup_gpio_dir_in; 166 gc->direction_input = mpc52xx_wkup_gpio_dir_in;
167 ofchip->gc.direction_output = mpc52xx_wkup_gpio_dir_out; 167 gc->direction_output = mpc52xx_wkup_gpio_dir_out;
168 ofchip->gc.get = mpc52xx_wkup_gpio_get; 168 gc->get = mpc52xx_wkup_gpio_get;
169 ofchip->gc.set = mpc52xx_wkup_gpio_set; 169 gc->set = mpc52xx_wkup_gpio_set;
170 170
171 ret = of_mm_gpiochip_add(ofdev->dev.of_node, &chip->mmchip); 171 ret = of_mm_gpiochip_add(ofdev->dev.of_node, &chip->mmchip);
172 if (ret) 172 if (ret)
@@ -315,7 +315,7 @@ static int __devinit mpc52xx_simple_gpiochip_probe(struct of_device *ofdev,
315 const struct of_device_id *match) 315 const struct of_device_id *match)
316{ 316{
317 struct mpc52xx_gpiochip *chip; 317 struct mpc52xx_gpiochip *chip;
318 struct of_gpio_chip *ofchip; 318 struct gpio_chip *gc;
319 struct mpc52xx_gpio __iomem *regs; 319 struct mpc52xx_gpio __iomem *regs;
320 int ret; 320 int ret;
321 321
@@ -323,14 +323,14 @@ static int __devinit mpc52xx_simple_gpiochip_probe(struct of_device *ofdev,
323 if (!chip) 323 if (!chip)
324 return -ENOMEM; 324 return -ENOMEM;
325 325
326 ofchip = &chip->mmchip.of_gc; 326 gc = &chip->mmchip.gc;
327 327
328 ofchip->gpio_cells = 2; 328 gc->of_gpio_n_cells = 2;
329 ofchip->gc.ngpio = 32; 329 gc->ngpio = 32;
330 ofchip->gc.direction_input = mpc52xx_simple_gpio_dir_in; 330 gc->direction_input = mpc52xx_simple_gpio_dir_in;
331 ofchip->gc.direction_output = mpc52xx_simple_gpio_dir_out; 331 gc->direction_output = mpc52xx_simple_gpio_dir_out;
332 ofchip->gc.get = mpc52xx_simple_gpio_get; 332 gc->get = mpc52xx_simple_gpio_get;
333 ofchip->gc.set = mpc52xx_simple_gpio_set; 333 gc->set = mpc52xx_simple_gpio_set;
334 334
335 ret = of_mm_gpiochip_add(ofdev->dev.of_node, &chip->mmchip); 335 ret = of_mm_gpiochip_add(ofdev->dev.of_node, &chip->mmchip);
336 if (ret) 336 if (ret)
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c
index 46c93578cbf0..3f2ee47f1d01 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c
@@ -78,7 +78,7 @@ MODULE_LICENSE("GPL");
78 * @dev: pointer to device structure 78 * @dev: pointer to device structure
79 * @regs: virtual address of GPT registers 79 * @regs: virtual address of GPT registers
80 * @lock: spinlock to coordinate between different functions. 80 * @lock: spinlock to coordinate between different functions.
81 * @of_gc: of_gpio_chip instance structure; used when GPIO is enabled 81 * @gc: gpio_chip instance structure; used when GPIO is enabled
82 * @irqhost: Pointer to irq_host instance; used when IRQ mode is supported 82 * @irqhost: Pointer to irq_host instance; used when IRQ mode is supported
83 * @wdt_mode: only relevant for gpt0: bit 0 (MPC52xx_GPT_CAN_WDT) indicates 83 * @wdt_mode: only relevant for gpt0: bit 0 (MPC52xx_GPT_CAN_WDT) indicates
84 * if the gpt may be used as wdt, bit 1 (MPC52xx_GPT_IS_WDT) indicates 84 * if the gpt may be used as wdt, bit 1 (MPC52xx_GPT_IS_WDT) indicates
@@ -94,7 +94,7 @@ struct mpc52xx_gpt_priv {
94 u8 wdt_mode; 94 u8 wdt_mode;
95 95
96#if defined(CONFIG_GPIOLIB) 96#if defined(CONFIG_GPIOLIB)
97 struct of_gpio_chip of_gc; 97 struct gpio_chip gc;
98#endif 98#endif
99}; 99};
100 100
@@ -280,7 +280,7 @@ mpc52xx_gpt_irq_setup(struct mpc52xx_gpt_priv *gpt, struct device_node *node)
280#if defined(CONFIG_GPIOLIB) 280#if defined(CONFIG_GPIOLIB)
281static inline struct mpc52xx_gpt_priv *gc_to_mpc52xx_gpt(struct gpio_chip *gc) 281static inline struct mpc52xx_gpt_priv *gc_to_mpc52xx_gpt(struct gpio_chip *gc)
282{ 282{
283 return container_of(to_of_gpio_chip(gc), struct mpc52xx_gpt_priv,of_gc); 283 return container_of(gc, struct mpc52xx_gpt_priv, gc);
284} 284}
285 285
286static int mpc52xx_gpt_gpio_get(struct gpio_chip *gc, unsigned int gpio) 286static int mpc52xx_gpt_gpio_get(struct gpio_chip *gc, unsigned int gpio)
@@ -336,28 +336,27 @@ mpc52xx_gpt_gpio_setup(struct mpc52xx_gpt_priv *gpt, struct device_node *node)
336 if (!of_find_property(node, "gpio-controller", NULL)) 336 if (!of_find_property(node, "gpio-controller", NULL))
337 return; 337 return;
338 338
339 gpt->of_gc.gc.label = kstrdup(node->full_name, GFP_KERNEL); 339 gpt->gc.label = kstrdup(node->full_name, GFP_KERNEL);
340 if (!gpt->of_gc.gc.label) { 340 if (!gpt->gc.label) {
341 dev_err(gpt->dev, "out of memory\n"); 341 dev_err(gpt->dev, "out of memory\n");
342 return; 342 return;
343 } 343 }
344 344
345 gpt->of_gc.gpio_cells = 2; 345 gpt->gc.ngpio = 1;
346 gpt->of_gc.gc.ngpio = 1; 346 gpt->gc.direction_input = mpc52xx_gpt_gpio_dir_in;
347 gpt->of_gc.gc.direction_input = mpc52xx_gpt_gpio_dir_in; 347 gpt->gc.direction_output = mpc52xx_gpt_gpio_dir_out;
348 gpt->of_gc.gc.direction_output = mpc52xx_gpt_gpio_dir_out; 348 gpt->gc.get = mpc52xx_gpt_gpio_get;
349 gpt->of_gc.gc.get = mpc52xx_gpt_gpio_get; 349 gpt->gc.set = mpc52xx_gpt_gpio_set;
350 gpt->of_gc.gc.set = mpc52xx_gpt_gpio_set; 350 gpt->gc.base = -1;
351 gpt->of_gc.gc.base = -1; 351 gpt->gc.of_gpio_n_cells = 2;
352 gpt->of_gc.xlate = of_gpio_simple_xlate; 352 gpt->gc.of_xlate = of_gpio_simple_xlate;
353 node->data = &gpt->of_gc;
354 of_node_get(node); 353 of_node_get(node);
355 354
356 /* Setup external pin in GPIO mode */ 355 /* Setup external pin in GPIO mode */
357 clrsetbits_be32(&gpt->regs->mode, MPC52xx_GPT_MODE_MS_MASK, 356 clrsetbits_be32(&gpt->regs->mode, MPC52xx_GPT_MODE_MS_MASK,
358 MPC52xx_GPT_MODE_MS_GPIO); 357 MPC52xx_GPT_MODE_MS_GPIO);
359 358
360 rc = gpiochip_add(&gpt->of_gc.gc); 359 rc = gpiochip_add(&gpt->gc);
361 if (rc) 360 if (rc)
362 dev_err(gpt->dev, "gpiochip_add() failed; rc=%i\n", rc); 361 dev_err(gpt->dev, "gpiochip_add() failed; rc=%i\n", rc);
363 362
diff --git a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
index d119a7c1c17a..e49f4bd2f991 100644
--- a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
+++ b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
@@ -37,7 +37,7 @@ struct mcu {
37 struct mutex lock; 37 struct mutex lock;
38 struct device_node *np; 38 struct device_node *np;
39 struct i2c_client *client; 39 struct i2c_client *client;
40 struct of_gpio_chip of_gc; 40 struct gpio_chip gc;
41 u8 reg_ctrl; 41 u8 reg_ctrl;
42}; 42};
43 43
@@ -56,8 +56,7 @@ static void mcu_power_off(void)
56 56
57static void mcu_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) 57static void mcu_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
58{ 58{
59 struct of_gpio_chip *of_gc = to_of_gpio_chip(gc); 59 struct mcu *mcu = container_of(gc, struct mcu, gc);
60 struct mcu *mcu = container_of(of_gc, struct mcu, of_gc);
61 u8 bit = 1 << (4 + gpio); 60 u8 bit = 1 << (4 + gpio);
62 61
63 mutex_lock(&mcu->lock); 62 mutex_lock(&mcu->lock);
@@ -79,8 +78,7 @@ static int mcu_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
79static int mcu_gpiochip_add(struct mcu *mcu) 78static int mcu_gpiochip_add(struct mcu *mcu)
80{ 79{
81 struct device_node *np; 80 struct device_node *np;
82 struct of_gpio_chip *of_gc = &mcu->of_gc; 81 struct gpio_chip *gc = &mcu->gc;
83 struct gpio_chip *gc = &of_gc->gc;
84 int ret; 82 int ret;
85 83
86 np = of_find_compatible_node(NULL, NULL, "fsl,mcu-mpc8349emitx"); 84 np = of_find_compatible_node(NULL, NULL, "fsl,mcu-mpc8349emitx");
@@ -94,10 +92,9 @@ static int mcu_gpiochip_add(struct mcu *mcu)
94 gc->base = -1; 92 gc->base = -1;
95 gc->set = mcu_gpio_set; 93 gc->set = mcu_gpio_set;
96 gc->direction_output = mcu_gpio_dir_out; 94 gc->direction_output = mcu_gpio_dir_out;
97 of_gc->gpio_cells = 2; 95 gc->of_gpio_n_cells = 2;
98 of_gc->xlate = of_gpio_simple_xlate; 96 gc->of_xlate = of_gpio_simple_xlate;
99 97
100 np->data = of_gc;
101 mcu->np = np; 98 mcu->np = np;
102 99
103 /* 100 /*
@@ -114,7 +111,7 @@ static int mcu_gpiochip_remove(struct mcu *mcu)
114{ 111{
115 int ret; 112 int ret;
116 113
117 ret = gpiochip_remove(&mcu->of_gc.gc); 114 ret = gpiochip_remove(&mcu->gc);
118 if (ret) 115 if (ret)
119 return ret; 116 return ret;
120 of_node_put(mcu->np); 117 of_node_put(mcu->np);
diff --git a/arch/powerpc/platforms/86xx/gef_gpio.c b/arch/powerpc/platforms/86xx/gef_gpio.c
index b8cb08dbd89c..4ff7b1e7bbad 100644
--- a/arch/powerpc/platforms/86xx/gef_gpio.c
+++ b/arch/powerpc/platforms/86xx/gef_gpio.c
@@ -118,12 +118,12 @@ static int __init gef_gpio_init(void)
118 } 118 }
119 119
120 /* Setup pointers to chip functions */ 120 /* Setup pointers to chip functions */
121 gef_gpio_chip->of_gc.gpio_cells = 2; 121 gef_gpio_chip->gc.of_gpio_n_cells = 2;
122 gef_gpio_chip->of_gc.gc.ngpio = 19; 122 gef_gpio_chip->gc.ngpio = 19;
123 gef_gpio_chip->of_gc.gc.direction_input = gef_gpio_dir_in; 123 gef_gpio_chip->gc.direction_input = gef_gpio_dir_in;
124 gef_gpio_chip->of_gc.gc.direction_output = gef_gpio_dir_out; 124 gef_gpio_chip->gc.direction_output = gef_gpio_dir_out;
125 gef_gpio_chip->of_gc.gc.get = gef_gpio_get; 125 gef_gpio_chip->gc.get = gef_gpio_get;
126 gef_gpio_chip->of_gc.gc.set = gef_gpio_set; 126 gef_gpio_chip->gc.set = gef_gpio_set;
127 127
128 /* This function adds a memory mapped GPIO chip */ 128 /* This function adds a memory mapped GPIO chip */
129 retval = of_mm_gpiochip_add(np, gef_gpio_chip); 129 retval = of_mm_gpiochip_add(np, gef_gpio_chip);
@@ -146,12 +146,12 @@ static int __init gef_gpio_init(void)
146 } 146 }
147 147
148 /* Setup pointers to chip functions */ 148 /* Setup pointers to chip functions */
149 gef_gpio_chip->of_gc.gpio_cells = 2; 149 gef_gpio_chip->gc.of_gpio_n_cells = 2;
150 gef_gpio_chip->of_gc.gc.ngpio = 6; 150 gef_gpio_chip->gc.ngpio = 6;
151 gef_gpio_chip->of_gc.gc.direction_input = gef_gpio_dir_in; 151 gef_gpio_chip->gc.direction_input = gef_gpio_dir_in;
152 gef_gpio_chip->of_gc.gc.direction_output = gef_gpio_dir_out; 152 gef_gpio_chip->gc.direction_output = gef_gpio_dir_out;
153 gef_gpio_chip->of_gc.gc.get = gef_gpio_get; 153 gef_gpio_chip->gc.get = gef_gpio_get;
154 gef_gpio_chip->of_gc.gc.set = gef_gpio_set; 154 gef_gpio_chip->gc.set = gef_gpio_set;
155 155
156 /* This function adds a memory mapped GPIO chip */ 156 /* This function adds a memory mapped GPIO chip */
157 retval = of_mm_gpiochip_add(np, gef_gpio_chip); 157 retval = of_mm_gpiochip_add(np, gef_gpio_chip);