Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / powerpc / sysdev / cpm_gpio.c
blob0badc90be66681302e8999e998b8c4167bc72207
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Common CPM GPIO wrapper for the CPM GPIO ports
5 * Author: Christophe Leroy <christophe.leroy@c-s.fr>
7 * Copyright 2017 CS Systemes d'Information.
9 */
11 #include <linux/module.h>
12 #include <linux/of_device.h>
14 #include <asm/cpm.h>
15 #ifdef CONFIG_8xx_GPIO
16 #include <asm/cpm1.h>
17 #endif
19 static int cpm_gpio_probe(struct platform_device *ofdev)
21 struct device *dev = &ofdev->dev;
22 int (*gp_add)(struct device *dev) = of_device_get_match_data(dev);
24 if (!gp_add)
25 return -ENODEV;
27 return gp_add(dev);
30 static const struct of_device_id cpm_gpio_match[] = {
31 #ifdef CONFIG_8xx_GPIO
33 .compatible = "fsl,cpm1-pario-bank-a",
34 .data = cpm1_gpiochip_add16,
37 .compatible = "fsl,cpm1-pario-bank-b",
38 .data = cpm1_gpiochip_add32,
41 .compatible = "fsl,cpm1-pario-bank-c",
42 .data = cpm1_gpiochip_add16,
45 .compatible = "fsl,cpm1-pario-bank-d",
46 .data = cpm1_gpiochip_add16,
48 /* Port E uses CPM2 layout */
50 .compatible = "fsl,cpm1-pario-bank-e",
51 .data = cpm2_gpiochip_add32,
53 #endif
55 .compatible = "fsl,cpm2-pario-bank",
56 .data = cpm2_gpiochip_add32,
58 {},
60 MODULE_DEVICE_TABLE(of, cpm_gpio_match);
62 static struct platform_driver cpm_gpio_driver = {
63 .probe = cpm_gpio_probe,
64 .driver = {
65 .name = "cpm-gpio",
66 .owner = THIS_MODULE,
67 .of_match_table = cpm_gpio_match,
71 static int __init cpm_gpio_init(void)
73 return platform_driver_register(&cpm_gpio_driver);
75 arch_initcall(cpm_gpio_init);
77 MODULE_AUTHOR("Christophe Leroy <christophe.leroy@c-s.fr>");
78 MODULE_DESCRIPTION("Driver for CPM GPIO");
79 MODULE_LICENSE("GPL");
80 MODULE_ALIAS("platform:cpm-gpio");