platform-gpio-mxs.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it under
  5. * the terms of the GNU General Public License version 2 as published by the
  6. * Free Software Foundation.
  7. */
  8. #include <linux/compiler.h>
  9. #include <linux/err.h>
  10. #include <linux/init.h>
  11. #include <mach/mx23.h>
  12. #include <mach/mx28.h>
  13. #include <mach/devices-common.h>
  14. struct platform_device *__init mxs_add_gpio(
  15. int id, resource_size_t iobase, int irq)
  16. {
  17. struct resource res[] = {
  18. {
  19. .start = iobase,
  20. .end = iobase + SZ_8K - 1,
  21. .flags = IORESOURCE_MEM,
  22. }, {
  23. .start = irq,
  24. .end = irq,
  25. .flags = IORESOURCE_IRQ,
  26. },
  27. };
  28. return platform_device_register_resndata(&mxs_apbh_bus,
  29. "gpio-mxs", id, res, ARRAY_SIZE(res), NULL, 0);
  30. }
  31. static int __init mxs_add_mxs_gpio(void)
  32. {
  33. if (cpu_is_mx23()) {
  34. mxs_add_gpio(0, MX23_PINCTRL_BASE_ADDR, MX23_INT_GPIO0);
  35. mxs_add_gpio(1, MX23_PINCTRL_BASE_ADDR, MX23_INT_GPIO1);
  36. mxs_add_gpio(2, MX23_PINCTRL_BASE_ADDR, MX23_INT_GPIO2);
  37. }
  38. if (cpu_is_mx28()) {
  39. mxs_add_gpio(0, MX28_PINCTRL_BASE_ADDR, MX28_INT_GPIO0);
  40. mxs_add_gpio(1, MX28_PINCTRL_BASE_ADDR, MX28_INT_GPIO1);
  41. mxs_add_gpio(2, MX28_PINCTRL_BASE_ADDR, MX28_INT_GPIO2);
  42. mxs_add_gpio(3, MX28_PINCTRL_BASE_ADDR, MX28_INT_GPIO3);
  43. mxs_add_gpio(4, MX28_PINCTRL_BASE_ADDR, MX28_INT_GPIO4);
  44. }
  45. return 0;
  46. }
  47. postcore_initcall(mxs_add_mxs_gpio);