xref: /linux/drivers/gpio/gpio-mpc5200.c (revision 6eae1ace68ab775e9d47f1f8e40c811ac39f733f)
1*6eae1aceSGrant Likely /*
2*6eae1aceSGrant Likely  * MPC52xx gpio driver
3*6eae1aceSGrant Likely  *
4*6eae1aceSGrant Likely  * Copyright (c) 2008 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
5*6eae1aceSGrant Likely  *
6*6eae1aceSGrant Likely  * This program is free software; you can redistribute it and/or modify
7*6eae1aceSGrant Likely  * it under the terms of the GNU General Public License version 2
8*6eae1aceSGrant Likely  * as published by the Free Software Foundation.
9*6eae1aceSGrant Likely  *
10*6eae1aceSGrant Likely  * This program is distributed in the hope that it will be useful,
11*6eae1aceSGrant Likely  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12*6eae1aceSGrant Likely  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13*6eae1aceSGrant Likely  * GNU General Public License for more details.
14*6eae1aceSGrant Likely  *
15*6eae1aceSGrant Likely  * You should have received a copy of the GNU General Public License
16*6eae1aceSGrant Likely  * along with this program; if not, write to the Free Software
17*6eae1aceSGrant Likely  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18*6eae1aceSGrant Likely  */
19*6eae1aceSGrant Likely 
20*6eae1aceSGrant Likely #include <linux/of.h>
21*6eae1aceSGrant Likely #include <linux/kernel.h>
22*6eae1aceSGrant Likely #include <linux/slab.h>
23*6eae1aceSGrant Likely #include <linux/of_gpio.h>
24*6eae1aceSGrant Likely #include <linux/io.h>
25*6eae1aceSGrant Likely #include <linux/of_platform.h>
26*6eae1aceSGrant Likely 
27*6eae1aceSGrant Likely #include <asm/gpio.h>
28*6eae1aceSGrant Likely #include <asm/mpc52xx.h>
29*6eae1aceSGrant Likely #include <sysdev/fsl_soc.h>
30*6eae1aceSGrant Likely 
31*6eae1aceSGrant Likely static DEFINE_SPINLOCK(gpio_lock);
32*6eae1aceSGrant Likely 
33*6eae1aceSGrant Likely struct mpc52xx_gpiochip {
34*6eae1aceSGrant Likely 	struct of_mm_gpio_chip mmchip;
35*6eae1aceSGrant Likely 	unsigned int shadow_dvo;
36*6eae1aceSGrant Likely 	unsigned int shadow_gpioe;
37*6eae1aceSGrant Likely 	unsigned int shadow_ddr;
38*6eae1aceSGrant Likely };
39*6eae1aceSGrant Likely 
40*6eae1aceSGrant Likely /*
41*6eae1aceSGrant Likely  * GPIO LIB API implementation for wakeup GPIOs.
42*6eae1aceSGrant Likely  *
43*6eae1aceSGrant Likely  * There's a maximum of 8 wakeup GPIOs. Which of these are available
44*6eae1aceSGrant Likely  * for use depends on your board setup.
45*6eae1aceSGrant Likely  *
46*6eae1aceSGrant Likely  * 0 -> GPIO_WKUP_7
47*6eae1aceSGrant Likely  * 1 -> GPIO_WKUP_6
48*6eae1aceSGrant Likely  * 2 -> PSC6_1
49*6eae1aceSGrant Likely  * 3 -> PSC6_0
50*6eae1aceSGrant Likely  * 4 -> ETH_17
51*6eae1aceSGrant Likely  * 5 -> PSC3_9
52*6eae1aceSGrant Likely  * 6 -> PSC2_4
53*6eae1aceSGrant Likely  * 7 -> PSC1_4
54*6eae1aceSGrant Likely  *
55*6eae1aceSGrant Likely  */
56*6eae1aceSGrant Likely static int mpc52xx_wkup_gpio_get(struct gpio_chip *gc, unsigned int gpio)
57*6eae1aceSGrant Likely {
58*6eae1aceSGrant Likely 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
59*6eae1aceSGrant Likely 	struct mpc52xx_gpio_wkup __iomem *regs = mm_gc->regs;
60*6eae1aceSGrant Likely 	unsigned int ret;
61*6eae1aceSGrant Likely 
62*6eae1aceSGrant Likely 	ret = (in_8(&regs->wkup_ival) >> (7 - gpio)) & 1;
63*6eae1aceSGrant Likely 
64*6eae1aceSGrant Likely 	pr_debug("%s: gpio: %d ret: %d\n", __func__, gpio, ret);
65*6eae1aceSGrant Likely 
66*6eae1aceSGrant Likely 	return ret;
67*6eae1aceSGrant Likely }
68*6eae1aceSGrant Likely 
69*6eae1aceSGrant Likely static inline void
70*6eae1aceSGrant Likely __mpc52xx_wkup_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
71*6eae1aceSGrant Likely {
72*6eae1aceSGrant Likely 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
73*6eae1aceSGrant Likely 	struct mpc52xx_gpiochip *chip = container_of(mm_gc,
74*6eae1aceSGrant Likely 			struct mpc52xx_gpiochip, mmchip);
75*6eae1aceSGrant Likely 	struct mpc52xx_gpio_wkup __iomem *regs = mm_gc->regs;
76*6eae1aceSGrant Likely 
77*6eae1aceSGrant Likely 	if (val)
78*6eae1aceSGrant Likely 		chip->shadow_dvo |= 1 << (7 - gpio);
79*6eae1aceSGrant Likely 	else
80*6eae1aceSGrant Likely 		chip->shadow_dvo &= ~(1 << (7 - gpio));
81*6eae1aceSGrant Likely 
82*6eae1aceSGrant Likely 	out_8(&regs->wkup_dvo, chip->shadow_dvo);
83*6eae1aceSGrant Likely }
84*6eae1aceSGrant Likely 
85*6eae1aceSGrant Likely static void
86*6eae1aceSGrant Likely mpc52xx_wkup_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
87*6eae1aceSGrant Likely {
88*6eae1aceSGrant Likely 	unsigned long flags;
89*6eae1aceSGrant Likely 
90*6eae1aceSGrant Likely 	spin_lock_irqsave(&gpio_lock, flags);
91*6eae1aceSGrant Likely 
92*6eae1aceSGrant Likely 	__mpc52xx_wkup_gpio_set(gc, gpio, val);
93*6eae1aceSGrant Likely 
94*6eae1aceSGrant Likely 	spin_unlock_irqrestore(&gpio_lock, flags);
95*6eae1aceSGrant Likely 
96*6eae1aceSGrant Likely 	pr_debug("%s: gpio: %d val: %d\n", __func__, gpio, val);
97*6eae1aceSGrant Likely }
98*6eae1aceSGrant Likely 
99*6eae1aceSGrant Likely static int mpc52xx_wkup_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
100*6eae1aceSGrant Likely {
101*6eae1aceSGrant Likely 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
102*6eae1aceSGrant Likely 	struct mpc52xx_gpiochip *chip = container_of(mm_gc,
103*6eae1aceSGrant Likely 			struct mpc52xx_gpiochip, mmchip);
104*6eae1aceSGrant Likely 	struct mpc52xx_gpio_wkup __iomem *regs = mm_gc->regs;
105*6eae1aceSGrant Likely 	unsigned long flags;
106*6eae1aceSGrant Likely 
107*6eae1aceSGrant Likely 	spin_lock_irqsave(&gpio_lock, flags);
108*6eae1aceSGrant Likely 
109*6eae1aceSGrant Likely 	/* set the direction */
110*6eae1aceSGrant Likely 	chip->shadow_ddr &= ~(1 << (7 - gpio));
111*6eae1aceSGrant Likely 	out_8(&regs->wkup_ddr, chip->shadow_ddr);
112*6eae1aceSGrant Likely 
113*6eae1aceSGrant Likely 	/* and enable the pin */
114*6eae1aceSGrant Likely 	chip->shadow_gpioe |= 1 << (7 - gpio);
115*6eae1aceSGrant Likely 	out_8(&regs->wkup_gpioe, chip->shadow_gpioe);
116*6eae1aceSGrant Likely 
117*6eae1aceSGrant Likely 	spin_unlock_irqrestore(&gpio_lock, flags);
118*6eae1aceSGrant Likely 
119*6eae1aceSGrant Likely 	return 0;
120*6eae1aceSGrant Likely }
121*6eae1aceSGrant Likely 
122*6eae1aceSGrant Likely static int
123*6eae1aceSGrant Likely mpc52xx_wkup_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
124*6eae1aceSGrant Likely {
125*6eae1aceSGrant Likely 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
126*6eae1aceSGrant Likely 	struct mpc52xx_gpio_wkup __iomem *regs = mm_gc->regs;
127*6eae1aceSGrant Likely 	struct mpc52xx_gpiochip *chip = container_of(mm_gc,
128*6eae1aceSGrant Likely 			struct mpc52xx_gpiochip, mmchip);
129*6eae1aceSGrant Likely 	unsigned long flags;
130*6eae1aceSGrant Likely 
131*6eae1aceSGrant Likely 	spin_lock_irqsave(&gpio_lock, flags);
132*6eae1aceSGrant Likely 
133*6eae1aceSGrant Likely 	__mpc52xx_wkup_gpio_set(gc, gpio, val);
134*6eae1aceSGrant Likely 
135*6eae1aceSGrant Likely 	/* Then set direction */
136*6eae1aceSGrant Likely 	chip->shadow_ddr |= 1 << (7 - gpio);
137*6eae1aceSGrant Likely 	out_8(&regs->wkup_ddr, chip->shadow_ddr);
138*6eae1aceSGrant Likely 
139*6eae1aceSGrant Likely 	/* Finally enable the pin */
140*6eae1aceSGrant Likely 	chip->shadow_gpioe |= 1 << (7 - gpio);
141*6eae1aceSGrant Likely 	out_8(&regs->wkup_gpioe, chip->shadow_gpioe);
142*6eae1aceSGrant Likely 
143*6eae1aceSGrant Likely 	spin_unlock_irqrestore(&gpio_lock, flags);
144*6eae1aceSGrant Likely 
145*6eae1aceSGrant Likely 	pr_debug("%s: gpio: %d val: %d\n", __func__, gpio, val);
146*6eae1aceSGrant Likely 
147*6eae1aceSGrant Likely 	return 0;
148*6eae1aceSGrant Likely }
149*6eae1aceSGrant Likely 
150*6eae1aceSGrant Likely static int __devinit mpc52xx_wkup_gpiochip_probe(struct platform_device *ofdev)
151*6eae1aceSGrant Likely {
152*6eae1aceSGrant Likely 	struct mpc52xx_gpiochip *chip;
153*6eae1aceSGrant Likely 	struct mpc52xx_gpio_wkup __iomem *regs;
154*6eae1aceSGrant Likely 	struct gpio_chip *gc;
155*6eae1aceSGrant Likely 	int ret;
156*6eae1aceSGrant Likely 
157*6eae1aceSGrant Likely 	chip = kzalloc(sizeof(*chip), GFP_KERNEL);
158*6eae1aceSGrant Likely 	if (!chip)
159*6eae1aceSGrant Likely 		return -ENOMEM;
160*6eae1aceSGrant Likely 
161*6eae1aceSGrant Likely 	gc = &chip->mmchip.gc;
162*6eae1aceSGrant Likely 
163*6eae1aceSGrant Likely 	gc->ngpio            = 8;
164*6eae1aceSGrant Likely 	gc->direction_input  = mpc52xx_wkup_gpio_dir_in;
165*6eae1aceSGrant Likely 	gc->direction_output = mpc52xx_wkup_gpio_dir_out;
166*6eae1aceSGrant Likely 	gc->get              = mpc52xx_wkup_gpio_get;
167*6eae1aceSGrant Likely 	gc->set              = mpc52xx_wkup_gpio_set;
168*6eae1aceSGrant Likely 
169*6eae1aceSGrant Likely 	ret = of_mm_gpiochip_add(ofdev->dev.of_node, &chip->mmchip);
170*6eae1aceSGrant Likely 	if (ret)
171*6eae1aceSGrant Likely 		return ret;
172*6eae1aceSGrant Likely 
173*6eae1aceSGrant Likely 	regs = chip->mmchip.regs;
174*6eae1aceSGrant Likely 	chip->shadow_gpioe = in_8(&regs->wkup_gpioe);
175*6eae1aceSGrant Likely 	chip->shadow_ddr = in_8(&regs->wkup_ddr);
176*6eae1aceSGrant Likely 	chip->shadow_dvo = in_8(&regs->wkup_dvo);
177*6eae1aceSGrant Likely 
178*6eae1aceSGrant Likely 	return 0;
179*6eae1aceSGrant Likely }
180*6eae1aceSGrant Likely 
181*6eae1aceSGrant Likely static int mpc52xx_gpiochip_remove(struct platform_device *ofdev)
182*6eae1aceSGrant Likely {
183*6eae1aceSGrant Likely 	return -EBUSY;
184*6eae1aceSGrant Likely }
185*6eae1aceSGrant Likely 
186*6eae1aceSGrant Likely static const struct of_device_id mpc52xx_wkup_gpiochip_match[] = {
187*6eae1aceSGrant Likely 	{ .compatible = "fsl,mpc5200-gpio-wkup", },
188*6eae1aceSGrant Likely 	{}
189*6eae1aceSGrant Likely };
190*6eae1aceSGrant Likely 
191*6eae1aceSGrant Likely static struct platform_driver mpc52xx_wkup_gpiochip_driver = {
192*6eae1aceSGrant Likely 	.driver = {
193*6eae1aceSGrant Likely 		.name = "mpc5200-gpio-wkup",
194*6eae1aceSGrant Likely 		.owner = THIS_MODULE,
195*6eae1aceSGrant Likely 		.of_match_table = mpc52xx_wkup_gpiochip_match,
196*6eae1aceSGrant Likely 	},
197*6eae1aceSGrant Likely 	.probe = mpc52xx_wkup_gpiochip_probe,
198*6eae1aceSGrant Likely 	.remove = mpc52xx_gpiochip_remove,
199*6eae1aceSGrant Likely };
200*6eae1aceSGrant Likely 
201*6eae1aceSGrant Likely /*
202*6eae1aceSGrant Likely  * GPIO LIB API implementation for simple GPIOs
203*6eae1aceSGrant Likely  *
204*6eae1aceSGrant Likely  * There's a maximum of 32 simple GPIOs. Which of these are available
205*6eae1aceSGrant Likely  * for use depends on your board setup.
206*6eae1aceSGrant Likely  * The numbering reflects the bit numbering in the port registers:
207*6eae1aceSGrant Likely  *
208*6eae1aceSGrant Likely  *  0..1  > reserved
209*6eae1aceSGrant Likely  *  2..3  > IRDA
210*6eae1aceSGrant Likely  *  4..7  > ETHR
211*6eae1aceSGrant Likely  *  8..11 > reserved
212*6eae1aceSGrant Likely  * 12..15 > USB
213*6eae1aceSGrant Likely  * 16..17 > reserved
214*6eae1aceSGrant Likely  * 18..23 > PSC3
215*6eae1aceSGrant Likely  * 24..27 > PSC2
216*6eae1aceSGrant Likely  * 28..31 > PSC1
217*6eae1aceSGrant Likely  */
218*6eae1aceSGrant Likely static int mpc52xx_simple_gpio_get(struct gpio_chip *gc, unsigned int gpio)
219*6eae1aceSGrant Likely {
220*6eae1aceSGrant Likely 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
221*6eae1aceSGrant Likely 	struct mpc52xx_gpio __iomem *regs = mm_gc->regs;
222*6eae1aceSGrant Likely 	unsigned int ret;
223*6eae1aceSGrant Likely 
224*6eae1aceSGrant Likely 	ret = (in_be32(&regs->simple_ival) >> (31 - gpio)) & 1;
225*6eae1aceSGrant Likely 
226*6eae1aceSGrant Likely 	return ret;
227*6eae1aceSGrant Likely }
228*6eae1aceSGrant Likely 
229*6eae1aceSGrant Likely static inline void
230*6eae1aceSGrant Likely __mpc52xx_simple_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
231*6eae1aceSGrant Likely {
232*6eae1aceSGrant Likely 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
233*6eae1aceSGrant Likely 	struct mpc52xx_gpiochip *chip = container_of(mm_gc,
234*6eae1aceSGrant Likely 			struct mpc52xx_gpiochip, mmchip);
235*6eae1aceSGrant Likely 	struct mpc52xx_gpio __iomem *regs = mm_gc->regs;
236*6eae1aceSGrant Likely 
237*6eae1aceSGrant Likely 	if (val)
238*6eae1aceSGrant Likely 		chip->shadow_dvo |= 1 << (31 - gpio);
239*6eae1aceSGrant Likely 	else
240*6eae1aceSGrant Likely 		chip->shadow_dvo &= ~(1 << (31 - gpio));
241*6eae1aceSGrant Likely 	out_be32(&regs->simple_dvo, chip->shadow_dvo);
242*6eae1aceSGrant Likely }
243*6eae1aceSGrant Likely 
244*6eae1aceSGrant Likely static void
245*6eae1aceSGrant Likely mpc52xx_simple_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
246*6eae1aceSGrant Likely {
247*6eae1aceSGrant Likely 	unsigned long flags;
248*6eae1aceSGrant Likely 
249*6eae1aceSGrant Likely 	spin_lock_irqsave(&gpio_lock, flags);
250*6eae1aceSGrant Likely 
251*6eae1aceSGrant Likely 	__mpc52xx_simple_gpio_set(gc, gpio, val);
252*6eae1aceSGrant Likely 
253*6eae1aceSGrant Likely 	spin_unlock_irqrestore(&gpio_lock, flags);
254*6eae1aceSGrant Likely 
255*6eae1aceSGrant Likely 	pr_debug("%s: gpio: %d val: %d\n", __func__, gpio, val);
256*6eae1aceSGrant Likely }
257*6eae1aceSGrant Likely 
258*6eae1aceSGrant Likely static int mpc52xx_simple_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
259*6eae1aceSGrant Likely {
260*6eae1aceSGrant Likely 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
261*6eae1aceSGrant Likely 	struct mpc52xx_gpiochip *chip = container_of(mm_gc,
262*6eae1aceSGrant Likely 			struct mpc52xx_gpiochip, mmchip);
263*6eae1aceSGrant Likely 	struct mpc52xx_gpio __iomem *regs = mm_gc->regs;
264*6eae1aceSGrant Likely 	unsigned long flags;
265*6eae1aceSGrant Likely 
266*6eae1aceSGrant Likely 	spin_lock_irqsave(&gpio_lock, flags);
267*6eae1aceSGrant Likely 
268*6eae1aceSGrant Likely 	/* set the direction */
269*6eae1aceSGrant Likely 	chip->shadow_ddr &= ~(1 << (31 - gpio));
270*6eae1aceSGrant Likely 	out_be32(&regs->simple_ddr, chip->shadow_ddr);
271*6eae1aceSGrant Likely 
272*6eae1aceSGrant Likely 	/* and enable the pin */
273*6eae1aceSGrant Likely 	chip->shadow_gpioe |= 1 << (31 - gpio);
274*6eae1aceSGrant Likely 	out_be32(&regs->simple_gpioe, chip->shadow_gpioe);
275*6eae1aceSGrant Likely 
276*6eae1aceSGrant Likely 	spin_unlock_irqrestore(&gpio_lock, flags);
277*6eae1aceSGrant Likely 
278*6eae1aceSGrant Likely 	return 0;
279*6eae1aceSGrant Likely }
280*6eae1aceSGrant Likely 
281*6eae1aceSGrant Likely static int
282*6eae1aceSGrant Likely mpc52xx_simple_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
283*6eae1aceSGrant Likely {
284*6eae1aceSGrant Likely 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
285*6eae1aceSGrant Likely 	struct mpc52xx_gpiochip *chip = container_of(mm_gc,
286*6eae1aceSGrant Likely 			struct mpc52xx_gpiochip, mmchip);
287*6eae1aceSGrant Likely 	struct mpc52xx_gpio __iomem *regs = mm_gc->regs;
288*6eae1aceSGrant Likely 	unsigned long flags;
289*6eae1aceSGrant Likely 
290*6eae1aceSGrant Likely 	spin_lock_irqsave(&gpio_lock, flags);
291*6eae1aceSGrant Likely 
292*6eae1aceSGrant Likely 	/* First set initial value */
293*6eae1aceSGrant Likely 	__mpc52xx_simple_gpio_set(gc, gpio, val);
294*6eae1aceSGrant Likely 
295*6eae1aceSGrant Likely 	/* Then set direction */
296*6eae1aceSGrant Likely 	chip->shadow_ddr |= 1 << (31 - gpio);
297*6eae1aceSGrant Likely 	out_be32(&regs->simple_ddr, chip->shadow_ddr);
298*6eae1aceSGrant Likely 
299*6eae1aceSGrant Likely 	/* Finally enable the pin */
300*6eae1aceSGrant Likely 	chip->shadow_gpioe |= 1 << (31 - gpio);
301*6eae1aceSGrant Likely 	out_be32(&regs->simple_gpioe, chip->shadow_gpioe);
302*6eae1aceSGrant Likely 
303*6eae1aceSGrant Likely 	spin_unlock_irqrestore(&gpio_lock, flags);
304*6eae1aceSGrant Likely 
305*6eae1aceSGrant Likely 	pr_debug("%s: gpio: %d val: %d\n", __func__, gpio, val);
306*6eae1aceSGrant Likely 
307*6eae1aceSGrant Likely 	return 0;
308*6eae1aceSGrant Likely }
309*6eae1aceSGrant Likely 
310*6eae1aceSGrant Likely static int __devinit mpc52xx_simple_gpiochip_probe(struct platform_device *ofdev)
311*6eae1aceSGrant Likely {
312*6eae1aceSGrant Likely 	struct mpc52xx_gpiochip *chip;
313*6eae1aceSGrant Likely 	struct gpio_chip *gc;
314*6eae1aceSGrant Likely 	struct mpc52xx_gpio __iomem *regs;
315*6eae1aceSGrant Likely 	int ret;
316*6eae1aceSGrant Likely 
317*6eae1aceSGrant Likely 	chip = kzalloc(sizeof(*chip), GFP_KERNEL);
318*6eae1aceSGrant Likely 	if (!chip)
319*6eae1aceSGrant Likely 		return -ENOMEM;
320*6eae1aceSGrant Likely 
321*6eae1aceSGrant Likely 	gc = &chip->mmchip.gc;
322*6eae1aceSGrant Likely 
323*6eae1aceSGrant Likely 	gc->ngpio            = 32;
324*6eae1aceSGrant Likely 	gc->direction_input  = mpc52xx_simple_gpio_dir_in;
325*6eae1aceSGrant Likely 	gc->direction_output = mpc52xx_simple_gpio_dir_out;
326*6eae1aceSGrant Likely 	gc->get              = mpc52xx_simple_gpio_get;
327*6eae1aceSGrant Likely 	gc->set              = mpc52xx_simple_gpio_set;
328*6eae1aceSGrant Likely 
329*6eae1aceSGrant Likely 	ret = of_mm_gpiochip_add(ofdev->dev.of_node, &chip->mmchip);
330*6eae1aceSGrant Likely 	if (ret)
331*6eae1aceSGrant Likely 		return ret;
332*6eae1aceSGrant Likely 
333*6eae1aceSGrant Likely 	regs = chip->mmchip.regs;
334*6eae1aceSGrant Likely 	chip->shadow_gpioe = in_be32(&regs->simple_gpioe);
335*6eae1aceSGrant Likely 	chip->shadow_ddr = in_be32(&regs->simple_ddr);
336*6eae1aceSGrant Likely 	chip->shadow_dvo = in_be32(&regs->simple_dvo);
337*6eae1aceSGrant Likely 
338*6eae1aceSGrant Likely 	return 0;
339*6eae1aceSGrant Likely }
340*6eae1aceSGrant Likely 
341*6eae1aceSGrant Likely static const struct of_device_id mpc52xx_simple_gpiochip_match[] = {
342*6eae1aceSGrant Likely 	{ .compatible = "fsl,mpc5200-gpio", },
343*6eae1aceSGrant Likely 	{}
344*6eae1aceSGrant Likely };
345*6eae1aceSGrant Likely 
346*6eae1aceSGrant Likely static struct platform_driver mpc52xx_simple_gpiochip_driver = {
347*6eae1aceSGrant Likely 	.driver = {
348*6eae1aceSGrant Likely 		.name = "mpc5200-gpio",
349*6eae1aceSGrant Likely 		.owner = THIS_MODULE,
350*6eae1aceSGrant Likely 		.of_match_table = mpc52xx_simple_gpiochip_match,
351*6eae1aceSGrant Likely 	},
352*6eae1aceSGrant Likely 	.probe = mpc52xx_simple_gpiochip_probe,
353*6eae1aceSGrant Likely 	.remove = mpc52xx_gpiochip_remove,
354*6eae1aceSGrant Likely };
355*6eae1aceSGrant Likely 
356*6eae1aceSGrant Likely static int __init mpc52xx_gpio_init(void)
357*6eae1aceSGrant Likely {
358*6eae1aceSGrant Likely 	if (platform_driver_register(&mpc52xx_wkup_gpiochip_driver))
359*6eae1aceSGrant Likely 		printk(KERN_ERR "Unable to register wakeup GPIO driver\n");
360*6eae1aceSGrant Likely 
361*6eae1aceSGrant Likely 	if (platform_driver_register(&mpc52xx_simple_gpiochip_driver))
362*6eae1aceSGrant Likely 		printk(KERN_ERR "Unable to register simple GPIO driver\n");
363*6eae1aceSGrant Likely 
364*6eae1aceSGrant Likely 	return 0;
365*6eae1aceSGrant Likely }
366*6eae1aceSGrant Likely 
367*6eae1aceSGrant Likely 
368*6eae1aceSGrant Likely /* Make sure we get initialised before anyone else tries to use us */
369*6eae1aceSGrant Likely subsys_initcall(mpc52xx_gpio_init);
370*6eae1aceSGrant Likely 
371*6eae1aceSGrant Likely /* No exit call at the moment as we cannot unregister of gpio chips */
372*6eae1aceSGrant Likely 
373*6eae1aceSGrant Likely MODULE_DESCRIPTION("Freescale MPC52xx gpio driver");
374*6eae1aceSGrant Likely MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de");
375*6eae1aceSGrant Likely MODULE_LICENSE("GPL v2");
376*6eae1aceSGrant Likely 
377