xref: /linux/drivers/gpio/gpio-mpc5200.c (revision 837c2705a3d5adca3ff5532d9cb6215803bea5f2)
16eae1aceSGrant Likely /*
26eae1aceSGrant Likely  * MPC52xx gpio driver
36eae1aceSGrant Likely  *
46eae1aceSGrant Likely  * Copyright (c) 2008 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
56eae1aceSGrant Likely  *
66eae1aceSGrant Likely  * This program is free software; you can redistribute it and/or modify
76eae1aceSGrant Likely  * it under the terms of the GNU General Public License version 2
86eae1aceSGrant Likely  * as published by the Free Software Foundation.
96eae1aceSGrant Likely  *
106eae1aceSGrant Likely  * This program is distributed in the hope that it will be useful,
116eae1aceSGrant Likely  * but WITHOUT ANY WARRANTY; without even the implied warranty of
126eae1aceSGrant Likely  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
136eae1aceSGrant Likely  * GNU General Public License for more details.
146eae1aceSGrant Likely  *
156eae1aceSGrant Likely  * You should have received a copy of the GNU General Public License
166eae1aceSGrant Likely  * along with this program; if not, write to the Free Software
176eae1aceSGrant Likely  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
186eae1aceSGrant Likely  */
196eae1aceSGrant Likely 
206eae1aceSGrant Likely #include <linux/of.h>
216eae1aceSGrant Likely #include <linux/kernel.h>
226eae1aceSGrant Likely #include <linux/slab.h>
236eae1aceSGrant Likely #include <linux/of_gpio.h>
246eae1aceSGrant Likely #include <linux/io.h>
256eae1aceSGrant Likely #include <linux/of_platform.h>
26bb207ef1SPaul Gortmaker #include <linux/module.h>
276eae1aceSGrant Likely 
286eae1aceSGrant Likely #include <asm/gpio.h>
296eae1aceSGrant Likely #include <asm/mpc52xx.h>
306eae1aceSGrant Likely #include <sysdev/fsl_soc.h>
316eae1aceSGrant Likely 
326eae1aceSGrant Likely static DEFINE_SPINLOCK(gpio_lock);
336eae1aceSGrant Likely 
346eae1aceSGrant Likely struct mpc52xx_gpiochip {
356eae1aceSGrant Likely 	struct of_mm_gpio_chip mmchip;
366eae1aceSGrant Likely 	unsigned int shadow_dvo;
376eae1aceSGrant Likely 	unsigned int shadow_gpioe;
386eae1aceSGrant Likely 	unsigned int shadow_ddr;
396eae1aceSGrant Likely };
406eae1aceSGrant Likely 
416eae1aceSGrant Likely /*
426eae1aceSGrant Likely  * GPIO LIB API implementation for wakeup GPIOs.
436eae1aceSGrant Likely  *
446eae1aceSGrant Likely  * There's a maximum of 8 wakeup GPIOs. Which of these are available
456eae1aceSGrant Likely  * for use depends on your board setup.
466eae1aceSGrant Likely  *
476eae1aceSGrant Likely  * 0 -> GPIO_WKUP_7
486eae1aceSGrant Likely  * 1 -> GPIO_WKUP_6
496eae1aceSGrant Likely  * 2 -> PSC6_1
506eae1aceSGrant Likely  * 3 -> PSC6_0
516eae1aceSGrant Likely  * 4 -> ETH_17
526eae1aceSGrant Likely  * 5 -> PSC3_9
536eae1aceSGrant Likely  * 6 -> PSC2_4
546eae1aceSGrant Likely  * 7 -> PSC1_4
556eae1aceSGrant Likely  *
566eae1aceSGrant Likely  */
576eae1aceSGrant Likely static int mpc52xx_wkup_gpio_get(struct gpio_chip *gc, unsigned int gpio)
586eae1aceSGrant Likely {
596eae1aceSGrant Likely 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
606eae1aceSGrant Likely 	struct mpc52xx_gpio_wkup __iomem *regs = mm_gc->regs;
616eae1aceSGrant Likely 	unsigned int ret;
626eae1aceSGrant Likely 
636eae1aceSGrant Likely 	ret = (in_8(&regs->wkup_ival) >> (7 - gpio)) & 1;
646eae1aceSGrant Likely 
656eae1aceSGrant Likely 	pr_debug("%s: gpio: %d ret: %d\n", __func__, gpio, ret);
666eae1aceSGrant Likely 
676eae1aceSGrant Likely 	return ret;
686eae1aceSGrant Likely }
696eae1aceSGrant Likely 
706eae1aceSGrant Likely static inline void
716eae1aceSGrant Likely __mpc52xx_wkup_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
726eae1aceSGrant Likely {
736eae1aceSGrant Likely 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
74*837c2705SLinus Walleij 	struct mpc52xx_gpiochip *chip = gpiochip_get_data(gc);
756eae1aceSGrant Likely 	struct mpc52xx_gpio_wkup __iomem *regs = mm_gc->regs;
766eae1aceSGrant Likely 
776eae1aceSGrant Likely 	if (val)
786eae1aceSGrant Likely 		chip->shadow_dvo |= 1 << (7 - gpio);
796eae1aceSGrant Likely 	else
806eae1aceSGrant Likely 		chip->shadow_dvo &= ~(1 << (7 - gpio));
816eae1aceSGrant Likely 
826eae1aceSGrant Likely 	out_8(&regs->wkup_dvo, chip->shadow_dvo);
836eae1aceSGrant Likely }
846eae1aceSGrant Likely 
856eae1aceSGrant Likely static void
866eae1aceSGrant Likely mpc52xx_wkup_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
876eae1aceSGrant Likely {
886eae1aceSGrant Likely 	unsigned long flags;
896eae1aceSGrant Likely 
906eae1aceSGrant Likely 	spin_lock_irqsave(&gpio_lock, flags);
916eae1aceSGrant Likely 
926eae1aceSGrant Likely 	__mpc52xx_wkup_gpio_set(gc, gpio, val);
936eae1aceSGrant Likely 
946eae1aceSGrant Likely 	spin_unlock_irqrestore(&gpio_lock, flags);
956eae1aceSGrant Likely 
966eae1aceSGrant Likely 	pr_debug("%s: gpio: %d val: %d\n", __func__, gpio, val);
976eae1aceSGrant Likely }
986eae1aceSGrant Likely 
996eae1aceSGrant Likely static int mpc52xx_wkup_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
1006eae1aceSGrant Likely {
1016eae1aceSGrant Likely 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
102*837c2705SLinus Walleij 	struct mpc52xx_gpiochip *chip = gpiochip_get_data(gc);
1036eae1aceSGrant Likely 	struct mpc52xx_gpio_wkup __iomem *regs = mm_gc->regs;
1046eae1aceSGrant Likely 	unsigned long flags;
1056eae1aceSGrant Likely 
1066eae1aceSGrant Likely 	spin_lock_irqsave(&gpio_lock, flags);
1076eae1aceSGrant Likely 
1086eae1aceSGrant Likely 	/* set the direction */
1096eae1aceSGrant Likely 	chip->shadow_ddr &= ~(1 << (7 - gpio));
1106eae1aceSGrant Likely 	out_8(&regs->wkup_ddr, chip->shadow_ddr);
1116eae1aceSGrant Likely 
1126eae1aceSGrant Likely 	/* and enable the pin */
1136eae1aceSGrant Likely 	chip->shadow_gpioe |= 1 << (7 - gpio);
1146eae1aceSGrant Likely 	out_8(&regs->wkup_gpioe, chip->shadow_gpioe);
1156eae1aceSGrant Likely 
1166eae1aceSGrant Likely 	spin_unlock_irqrestore(&gpio_lock, flags);
1176eae1aceSGrant Likely 
1186eae1aceSGrant Likely 	return 0;
1196eae1aceSGrant Likely }
1206eae1aceSGrant Likely 
1216eae1aceSGrant Likely static int
1226eae1aceSGrant Likely mpc52xx_wkup_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
1236eae1aceSGrant Likely {
1246eae1aceSGrant Likely 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
1256eae1aceSGrant Likely 	struct mpc52xx_gpio_wkup __iomem *regs = mm_gc->regs;
126*837c2705SLinus Walleij 	struct mpc52xx_gpiochip *chip = gpiochip_get_data(gc);
1276eae1aceSGrant Likely 	unsigned long flags;
1286eae1aceSGrant Likely 
1296eae1aceSGrant Likely 	spin_lock_irqsave(&gpio_lock, flags);
1306eae1aceSGrant Likely 
1316eae1aceSGrant Likely 	__mpc52xx_wkup_gpio_set(gc, gpio, val);
1326eae1aceSGrant Likely 
1336eae1aceSGrant Likely 	/* Then set direction */
1346eae1aceSGrant Likely 	chip->shadow_ddr |= 1 << (7 - gpio);
1356eae1aceSGrant Likely 	out_8(&regs->wkup_ddr, chip->shadow_ddr);
1366eae1aceSGrant Likely 
1376eae1aceSGrant Likely 	/* Finally enable the pin */
1386eae1aceSGrant Likely 	chip->shadow_gpioe |= 1 << (7 - gpio);
1396eae1aceSGrant Likely 	out_8(&regs->wkup_gpioe, chip->shadow_gpioe);
1406eae1aceSGrant Likely 
1416eae1aceSGrant Likely 	spin_unlock_irqrestore(&gpio_lock, flags);
1426eae1aceSGrant Likely 
1436eae1aceSGrant Likely 	pr_debug("%s: gpio: %d val: %d\n", __func__, gpio, val);
1446eae1aceSGrant Likely 
1456eae1aceSGrant Likely 	return 0;
1466eae1aceSGrant Likely }
1476eae1aceSGrant Likely 
1483836309dSBill Pemberton static int mpc52xx_wkup_gpiochip_probe(struct platform_device *ofdev)
1496eae1aceSGrant Likely {
1506eae1aceSGrant Likely 	struct mpc52xx_gpiochip *chip;
1516eae1aceSGrant Likely 	struct mpc52xx_gpio_wkup __iomem *regs;
1526eae1aceSGrant Likely 	struct gpio_chip *gc;
1536eae1aceSGrant Likely 	int ret;
1546eae1aceSGrant Likely 
155f91b2dbbSRicardo Ribalda Delgado 	chip = devm_kzalloc(&ofdev->dev, sizeof(*chip), GFP_KERNEL);
1566eae1aceSGrant Likely 	if (!chip)
1576eae1aceSGrant Likely 		return -ENOMEM;
1586eae1aceSGrant Likely 
159f91b2dbbSRicardo Ribalda Delgado 	platform_set_drvdata(ofdev, chip);
160f91b2dbbSRicardo Ribalda Delgado 
1616eae1aceSGrant Likely 	gc = &chip->mmchip.gc;
1626eae1aceSGrant Likely 
1636eae1aceSGrant Likely 	gc->ngpio            = 8;
1646eae1aceSGrant Likely 	gc->direction_input  = mpc52xx_wkup_gpio_dir_in;
1656eae1aceSGrant Likely 	gc->direction_output = mpc52xx_wkup_gpio_dir_out;
1666eae1aceSGrant Likely 	gc->get              = mpc52xx_wkup_gpio_get;
1676eae1aceSGrant Likely 	gc->set              = mpc52xx_wkup_gpio_set;
1686eae1aceSGrant Likely 
169*837c2705SLinus Walleij 	ret = of_mm_gpiochip_add_data(ofdev->dev.of_node, &chip->mmchip, chip);
1706eae1aceSGrant Likely 	if (ret)
1716eae1aceSGrant Likely 		return ret;
1726eae1aceSGrant Likely 
1736eae1aceSGrant Likely 	regs = chip->mmchip.regs;
1746eae1aceSGrant Likely 	chip->shadow_gpioe = in_8(&regs->wkup_gpioe);
1756eae1aceSGrant Likely 	chip->shadow_ddr = in_8(&regs->wkup_ddr);
1766eae1aceSGrant Likely 	chip->shadow_dvo = in_8(&regs->wkup_dvo);
1776eae1aceSGrant Likely 
1786eae1aceSGrant Likely 	return 0;
1796eae1aceSGrant Likely }
1806eae1aceSGrant Likely 
1816eae1aceSGrant Likely static int mpc52xx_gpiochip_remove(struct platform_device *ofdev)
1826eae1aceSGrant Likely {
183f91b2dbbSRicardo Ribalda Delgado 	struct mpc52xx_gpiochip *chip = platform_get_drvdata(ofdev);
184f91b2dbbSRicardo Ribalda Delgado 
185f91b2dbbSRicardo Ribalda Delgado 	of_mm_gpiochip_remove(&chip->mmchip);
186f91b2dbbSRicardo Ribalda Delgado 
187f91b2dbbSRicardo Ribalda Delgado 	return 0;
1886eae1aceSGrant Likely }
1896eae1aceSGrant Likely 
1906eae1aceSGrant Likely static const struct of_device_id mpc52xx_wkup_gpiochip_match[] = {
1916eae1aceSGrant Likely 	{ .compatible = "fsl,mpc5200-gpio-wkup", },
1926eae1aceSGrant Likely 	{}
1936eae1aceSGrant Likely };
1946eae1aceSGrant Likely 
1956eae1aceSGrant Likely static struct platform_driver mpc52xx_wkup_gpiochip_driver = {
1966eae1aceSGrant Likely 	.driver = {
1976eae1aceSGrant Likely 		.name = "mpc5200-gpio-wkup",
1986eae1aceSGrant Likely 		.of_match_table = mpc52xx_wkup_gpiochip_match,
1996eae1aceSGrant Likely 	},
2006eae1aceSGrant Likely 	.probe = mpc52xx_wkup_gpiochip_probe,
2016eae1aceSGrant Likely 	.remove = mpc52xx_gpiochip_remove,
2026eae1aceSGrant Likely };
2036eae1aceSGrant Likely 
2046eae1aceSGrant Likely /*
2056eae1aceSGrant Likely  * GPIO LIB API implementation for simple GPIOs
2066eae1aceSGrant Likely  *
2076eae1aceSGrant Likely  * There's a maximum of 32 simple GPIOs. Which of these are available
2086eae1aceSGrant Likely  * for use depends on your board setup.
2096eae1aceSGrant Likely  * The numbering reflects the bit numbering in the port registers:
2106eae1aceSGrant Likely  *
2116eae1aceSGrant Likely  *  0..1  > reserved
2126eae1aceSGrant Likely  *  2..3  > IRDA
2136eae1aceSGrant Likely  *  4..7  > ETHR
2146eae1aceSGrant Likely  *  8..11 > reserved
2156eae1aceSGrant Likely  * 12..15 > USB
2166eae1aceSGrant Likely  * 16..17 > reserved
2176eae1aceSGrant Likely  * 18..23 > PSC3
2186eae1aceSGrant Likely  * 24..27 > PSC2
2196eae1aceSGrant Likely  * 28..31 > PSC1
2206eae1aceSGrant Likely  */
2216eae1aceSGrant Likely static int mpc52xx_simple_gpio_get(struct gpio_chip *gc, unsigned int gpio)
2226eae1aceSGrant Likely {
2236eae1aceSGrant Likely 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
2246eae1aceSGrant Likely 	struct mpc52xx_gpio __iomem *regs = mm_gc->regs;
2256eae1aceSGrant Likely 	unsigned int ret;
2266eae1aceSGrant Likely 
2276eae1aceSGrant Likely 	ret = (in_be32(&regs->simple_ival) >> (31 - gpio)) & 1;
2286eae1aceSGrant Likely 
2296eae1aceSGrant Likely 	return ret;
2306eae1aceSGrant Likely }
2316eae1aceSGrant Likely 
2326eae1aceSGrant Likely static inline void
2336eae1aceSGrant Likely __mpc52xx_simple_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
2346eae1aceSGrant Likely {
2356eae1aceSGrant Likely 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
236*837c2705SLinus Walleij 	struct mpc52xx_gpiochip *chip = gpiochip_get_data(gc);
2376eae1aceSGrant Likely 	struct mpc52xx_gpio __iomem *regs = mm_gc->regs;
2386eae1aceSGrant Likely 
2396eae1aceSGrant Likely 	if (val)
2406eae1aceSGrant Likely 		chip->shadow_dvo |= 1 << (31 - gpio);
2416eae1aceSGrant Likely 	else
2426eae1aceSGrant Likely 		chip->shadow_dvo &= ~(1 << (31 - gpio));
2436eae1aceSGrant Likely 	out_be32(&regs->simple_dvo, chip->shadow_dvo);
2446eae1aceSGrant Likely }
2456eae1aceSGrant Likely 
2466eae1aceSGrant Likely static void
2476eae1aceSGrant Likely mpc52xx_simple_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
2486eae1aceSGrant Likely {
2496eae1aceSGrant Likely 	unsigned long flags;
2506eae1aceSGrant Likely 
2516eae1aceSGrant Likely 	spin_lock_irqsave(&gpio_lock, flags);
2526eae1aceSGrant Likely 
2536eae1aceSGrant Likely 	__mpc52xx_simple_gpio_set(gc, gpio, val);
2546eae1aceSGrant Likely 
2556eae1aceSGrant Likely 	spin_unlock_irqrestore(&gpio_lock, flags);
2566eae1aceSGrant Likely 
2576eae1aceSGrant Likely 	pr_debug("%s: gpio: %d val: %d\n", __func__, gpio, val);
2586eae1aceSGrant Likely }
2596eae1aceSGrant Likely 
2606eae1aceSGrant Likely static int mpc52xx_simple_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
2616eae1aceSGrant Likely {
2626eae1aceSGrant Likely 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
263*837c2705SLinus Walleij 	struct mpc52xx_gpiochip *chip = gpiochip_get_data(gc);
2646eae1aceSGrant Likely 	struct mpc52xx_gpio __iomem *regs = mm_gc->regs;
2656eae1aceSGrant Likely 	unsigned long flags;
2666eae1aceSGrant Likely 
2676eae1aceSGrant Likely 	spin_lock_irqsave(&gpio_lock, flags);
2686eae1aceSGrant Likely 
2696eae1aceSGrant Likely 	/* set the direction */
2706eae1aceSGrant Likely 	chip->shadow_ddr &= ~(1 << (31 - gpio));
2716eae1aceSGrant Likely 	out_be32(&regs->simple_ddr, chip->shadow_ddr);
2726eae1aceSGrant Likely 
2736eae1aceSGrant Likely 	/* and enable the pin */
2746eae1aceSGrant Likely 	chip->shadow_gpioe |= 1 << (31 - gpio);
2756eae1aceSGrant Likely 	out_be32(&regs->simple_gpioe, chip->shadow_gpioe);
2766eae1aceSGrant Likely 
2776eae1aceSGrant Likely 	spin_unlock_irqrestore(&gpio_lock, flags);
2786eae1aceSGrant Likely 
2796eae1aceSGrant Likely 	return 0;
2806eae1aceSGrant Likely }
2816eae1aceSGrant Likely 
2826eae1aceSGrant Likely static int
2836eae1aceSGrant Likely mpc52xx_simple_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
2846eae1aceSGrant Likely {
2856eae1aceSGrant Likely 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
286*837c2705SLinus Walleij 	struct mpc52xx_gpiochip *chip = gpiochip_get_data(gc);
2876eae1aceSGrant Likely 	struct mpc52xx_gpio __iomem *regs = mm_gc->regs;
2886eae1aceSGrant Likely 	unsigned long flags;
2896eae1aceSGrant Likely 
2906eae1aceSGrant Likely 	spin_lock_irqsave(&gpio_lock, flags);
2916eae1aceSGrant Likely 
2926eae1aceSGrant Likely 	/* First set initial value */
2936eae1aceSGrant Likely 	__mpc52xx_simple_gpio_set(gc, gpio, val);
2946eae1aceSGrant Likely 
2956eae1aceSGrant Likely 	/* Then set direction */
2966eae1aceSGrant Likely 	chip->shadow_ddr |= 1 << (31 - gpio);
2976eae1aceSGrant Likely 	out_be32(&regs->simple_ddr, chip->shadow_ddr);
2986eae1aceSGrant Likely 
2996eae1aceSGrant Likely 	/* Finally enable the pin */
3006eae1aceSGrant Likely 	chip->shadow_gpioe |= 1 << (31 - gpio);
3016eae1aceSGrant Likely 	out_be32(&regs->simple_gpioe, chip->shadow_gpioe);
3026eae1aceSGrant Likely 
3036eae1aceSGrant Likely 	spin_unlock_irqrestore(&gpio_lock, flags);
3046eae1aceSGrant Likely 
3056eae1aceSGrant Likely 	pr_debug("%s: gpio: %d val: %d\n", __func__, gpio, val);
3066eae1aceSGrant Likely 
3076eae1aceSGrant Likely 	return 0;
3086eae1aceSGrant Likely }
3096eae1aceSGrant Likely 
3103836309dSBill Pemberton static int mpc52xx_simple_gpiochip_probe(struct platform_device *ofdev)
3116eae1aceSGrant Likely {
3126eae1aceSGrant Likely 	struct mpc52xx_gpiochip *chip;
3136eae1aceSGrant Likely 	struct gpio_chip *gc;
3146eae1aceSGrant Likely 	struct mpc52xx_gpio __iomem *regs;
3156eae1aceSGrant Likely 	int ret;
3166eae1aceSGrant Likely 
317f91b2dbbSRicardo Ribalda Delgado 	chip = devm_kzalloc(&ofdev->dev, sizeof(*chip), GFP_KERNEL);
3186eae1aceSGrant Likely 	if (!chip)
3196eae1aceSGrant Likely 		return -ENOMEM;
3206eae1aceSGrant Likely 
321f91b2dbbSRicardo Ribalda Delgado 	platform_set_drvdata(ofdev, chip);
322f91b2dbbSRicardo Ribalda Delgado 
3236eae1aceSGrant Likely 	gc = &chip->mmchip.gc;
3246eae1aceSGrant Likely 
3256eae1aceSGrant Likely 	gc->ngpio            = 32;
3266eae1aceSGrant Likely 	gc->direction_input  = mpc52xx_simple_gpio_dir_in;
3276eae1aceSGrant Likely 	gc->direction_output = mpc52xx_simple_gpio_dir_out;
3286eae1aceSGrant Likely 	gc->get              = mpc52xx_simple_gpio_get;
3296eae1aceSGrant Likely 	gc->set              = mpc52xx_simple_gpio_set;
3306eae1aceSGrant Likely 
331*837c2705SLinus Walleij 	ret = of_mm_gpiochip_add_data(ofdev->dev.of_node, &chip->mmchip, chip);
3326eae1aceSGrant Likely 	if (ret)
3336eae1aceSGrant Likely 		return ret;
3346eae1aceSGrant Likely 
3356eae1aceSGrant Likely 	regs = chip->mmchip.regs;
3366eae1aceSGrant Likely 	chip->shadow_gpioe = in_be32(&regs->simple_gpioe);
3376eae1aceSGrant Likely 	chip->shadow_ddr = in_be32(&regs->simple_ddr);
3386eae1aceSGrant Likely 	chip->shadow_dvo = in_be32(&regs->simple_dvo);
3396eae1aceSGrant Likely 
3406eae1aceSGrant Likely 	return 0;
3416eae1aceSGrant Likely }
3426eae1aceSGrant Likely 
3436eae1aceSGrant Likely static const struct of_device_id mpc52xx_simple_gpiochip_match[] = {
3446eae1aceSGrant Likely 	{ .compatible = "fsl,mpc5200-gpio", },
3456eae1aceSGrant Likely 	{}
3466eae1aceSGrant Likely };
3476eae1aceSGrant Likely 
3486eae1aceSGrant Likely static struct platform_driver mpc52xx_simple_gpiochip_driver = {
3496eae1aceSGrant Likely 	.driver = {
3506eae1aceSGrant Likely 		.name = "mpc5200-gpio",
3516eae1aceSGrant Likely 		.of_match_table = mpc52xx_simple_gpiochip_match,
3526eae1aceSGrant Likely 	},
3536eae1aceSGrant Likely 	.probe = mpc52xx_simple_gpiochip_probe,
3546eae1aceSGrant Likely 	.remove = mpc52xx_gpiochip_remove,
3556eae1aceSGrant Likely };
3566eae1aceSGrant Likely 
35720d7090fSThierry Reding static struct platform_driver * const drivers[] = {
35820d7090fSThierry Reding 	&mpc52xx_wkup_gpiochip_driver,
35920d7090fSThierry Reding 	&mpc52xx_simple_gpiochip_driver,
36020d7090fSThierry Reding };
36120d7090fSThierry Reding 
3626eae1aceSGrant Likely static int __init mpc52xx_gpio_init(void)
3636eae1aceSGrant Likely {
36420d7090fSThierry Reding 	return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
3656eae1aceSGrant Likely }
3666eae1aceSGrant Likely 
3676eae1aceSGrant Likely /* Make sure we get initialised before anyone else tries to use us */
3686eae1aceSGrant Likely subsys_initcall(mpc52xx_gpio_init);
3696eae1aceSGrant Likely 
370f91b2dbbSRicardo Ribalda Delgado static void __exit mpc52xx_gpio_exit(void)
371f91b2dbbSRicardo Ribalda Delgado {
37220d7090fSThierry Reding 	platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
373f91b2dbbSRicardo Ribalda Delgado }
374f91b2dbbSRicardo Ribalda Delgado module_exit(mpc52xx_gpio_exit);
3756eae1aceSGrant Likely 
3766eae1aceSGrant Likely MODULE_DESCRIPTION("Freescale MPC52xx gpio driver");
3776eae1aceSGrant Likely MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de");
3786eae1aceSGrant Likely MODULE_LICENSE("GPL v2");
3796eae1aceSGrant Likely 
380