devices.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * CLPS711X common devices definitions
  3. *
  4. * Author: Alexander Shiyan <shc_work@mail.ru>, 2013
  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; either version 2 of the License, or
  9. * (at your option) any later version.
  10. */
  11. #include <linux/platform_device.h>
  12. #include <linux/sizes.h>
  13. #include <mach/hardware.h>
  14. static const phys_addr_t clps711x_gpios[][2] __initconst = {
  15. { PADR, PADDR },
  16. { PBDR, PBDDR },
  17. { PCDR, PCDDR },
  18. { PDDR, PDDDR },
  19. { PEDR, PEDDR },
  20. };
  21. static void __init clps711x_add_gpio(void)
  22. {
  23. unsigned i;
  24. struct resource gpio_res[2];
  25. memset(gpio_res, 0, sizeof(gpio_res));
  26. gpio_res[0].flags = IORESOURCE_MEM;
  27. gpio_res[1].flags = IORESOURCE_MEM;
  28. for (i = 0; i < ARRAY_SIZE(clps711x_gpios); i++) {
  29. gpio_res[0].start = CLPS711X_PHYS_BASE + clps711x_gpios[i][0];
  30. gpio_res[0].end = gpio_res[0].start;
  31. gpio_res[1].start = CLPS711X_PHYS_BASE + clps711x_gpios[i][1];
  32. gpio_res[1].end = gpio_res[1].start;
  33. platform_device_register_simple("clps711x-gpio", i,
  34. gpio_res, ARRAY_SIZE(gpio_res));
  35. }
  36. }
  37. const struct resource clps711x_syscon_res[] __initconst = {
  38. /* SYSCON1, SYSFLG1 */
  39. DEFINE_RES_MEM(CLPS711X_PHYS_BASE + SYSCON1, SZ_128),
  40. /* SYSCON2, SYSFLG2 */
  41. DEFINE_RES_MEM(CLPS711X_PHYS_BASE + SYSCON2, SZ_128),
  42. /* SYSCON3 */
  43. DEFINE_RES_MEM(CLPS711X_PHYS_BASE + SYSCON3, SZ_64),
  44. };
  45. static void __init clps711x_add_syscon(void)
  46. {
  47. unsigned i;
  48. for (i = 0; i < ARRAY_SIZE(clps711x_syscon_res); i++)
  49. platform_device_register_simple("clps711x-syscon", i + 1,
  50. &clps711x_syscon_res[i], 1);
  51. }
  52. void __init clps711x_devices_init(void)
  53. {
  54. clps711x_add_gpio();
  55. clps711x_add_syscon();
  56. }