cpm_gpio.c 1.6 KB

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