gpio.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Coldfire generic GPIO support
  3. *
  4. * (C) Copyright 2009, Steven King <sfking@fdwdc.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; version 2 of the License.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <asm/coldfire.h>
  18. #include <asm/mcfsim.h>
  19. #include <asm/mcfgpio.h>
  20. static struct mcf_gpio_chip mcf_gpio_chips[] = {
  21. {
  22. .gpio_chip = {
  23. .label = "PA",
  24. .request = mcf_gpio_request,
  25. .free = mcf_gpio_free,
  26. .direction_input = mcf_gpio_direction_input,
  27. .direction_output = mcf_gpio_direction_output,
  28. .get = mcf_gpio_get_value,
  29. .set = mcf_gpio_set_value,
  30. .ngpio = 16,
  31. },
  32. .pddr = (void __iomem *) MCFSIM_PADDR,
  33. .podr = (void __iomem *) MCFSIM_PADAT,
  34. .ppdr = (void __iomem *) MCFSIM_PADAT,
  35. },
  36. {
  37. .gpio_chip = {
  38. .label = "PB",
  39. .request = mcf_gpio_request,
  40. .free = mcf_gpio_free,
  41. .direction_input = mcf_gpio_direction_input,
  42. .direction_output = mcf_gpio_direction_output,
  43. .get = mcf_gpio_get_value,
  44. .set = mcf_gpio_set_value,
  45. .base = 16,
  46. .ngpio = 16,
  47. },
  48. .pddr = (void __iomem *) MCFSIM_PBDDR,
  49. .podr = (void __iomem *) MCFSIM_PBDAT,
  50. .ppdr = (void __iomem *) MCFSIM_PBDAT,
  51. },
  52. {
  53. .gpio_chip = {
  54. .label = "PC",
  55. .request = mcf_gpio_request,
  56. .free = mcf_gpio_free,
  57. .direction_input = mcf_gpio_direction_input,
  58. .direction_output = mcf_gpio_direction_output,
  59. .get = mcf_gpio_get_value,
  60. .set = mcf_gpio_set_value,
  61. .base = 32,
  62. .ngpio = 16,
  63. },
  64. .pddr = (void __iomem *) MCFSIM_PCDDR,
  65. .podr = (void __iomem *) MCFSIM_PCDAT,
  66. .ppdr = (void __iomem *) MCFSIM_PCDAT,
  67. },
  68. };
  69. static int __init mcf_gpio_init(void)
  70. {
  71. unsigned i = 0;
  72. while (i < ARRAY_SIZE(mcf_gpio_chips))
  73. (void)gpiochip_add((struct gpio_chip *)&mcf_gpio_chips[i++]);
  74. return 0;
  75. }
  76. core_initcall(mcf_gpio_init);