cpm_gpio.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Common CPM GPIO wrapper for the CPM GPIO ports
  4. *
  5. * Author: Christophe Leroy <christophe.leroy@c-s.fr>
  6. *
  7. * Copyright 2017 CS Systemes d'Information.
  8. *
  9. */
  10. #include <linux/module.h>
  11. #include <linux/of.h>
  12. #include <linux/platform_device.h>
  13. #include <asm/cpm.h>
  14. #ifdef CONFIG_8xx_GPIO
  15. #include <asm/cpm1.h>
  16. #endif
  17. static int cpm_gpio_probe(struct platform_device *ofdev)
  18. {
  19. struct device *dev = &ofdev->dev;
  20. int (*gp_add)(struct device *dev) = of_device_get_match_data(dev);
  21. if (!gp_add)
  22. return -ENODEV;
  23. return gp_add(dev);
  24. }
  25. static const struct of_device_id cpm_gpio_match[] = {
  26. #ifdef CONFIG_8xx_GPIO
  27. {
  28. .compatible = "fsl,cpm1-pario-bank-a",
  29. .data = cpm1_gpiochip_add16,
  30. },
  31. {
  32. .compatible = "fsl,cpm1-pario-bank-b",
  33. .data = cpm1_gpiochip_add32,
  34. },
  35. {
  36. .compatible = "fsl,cpm1-pario-bank-c",
  37. .data = cpm1_gpiochip_add16,
  38. },
  39. {
  40. .compatible = "fsl,cpm1-pario-bank-d",
  41. .data = cpm1_gpiochip_add16,
  42. },
  43. /* Port E uses CPM2 layout */
  44. {
  45. .compatible = "fsl,cpm1-pario-bank-e",
  46. .data = cpm2_gpiochip_add32,
  47. },
  48. #endif
  49. {
  50. .compatible = "fsl,cpm2-pario-bank",
  51. .data = cpm2_gpiochip_add32,
  52. },
  53. {},
  54. };
  55. MODULE_DEVICE_TABLE(of, cpm_gpio_match);
  56. static struct platform_driver cpm_gpio_driver = {
  57. .probe = cpm_gpio_probe,
  58. .driver = {
  59. .name = "cpm-gpio",
  60. .of_match_table = cpm_gpio_match,
  61. },
  62. };
  63. static int __init cpm_gpio_init(void)
  64. {
  65. return platform_driver_register(&cpm_gpio_driver);
  66. }
  67. arch_initcall(cpm_gpio_init);
  68. MODULE_AUTHOR("Christophe Leroy <christophe.leroy@c-s.fr>");
  69. MODULE_DESCRIPTION("Driver for CPM GPIO");
  70. MODULE_LICENSE("GPL");
  71. MODULE_ALIAS("platform:cpm-gpio");