cpu-u8500.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * Copyright (C) 2008-2009 ST-Ericsson
  3. *
  4. * Author: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.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 version 2, as
  8. * published by the Free Software Foundation.
  9. *
  10. */
  11. #include <linux/types.h>
  12. #include <linux/init.h>
  13. #include <linux/device.h>
  14. #include <linux/amba/bus.h>
  15. #include <linux/irq.h>
  16. #include <linux/gpio.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/io.h>
  19. #include <asm/localtimer.h>
  20. #include <asm/mach/map.h>
  21. #include <plat/mtu.h>
  22. #include <mach/hardware.h>
  23. #include <mach/setup.h>
  24. #define GPIO_RESOURCE(block) \
  25. { \
  26. .start = U8500_GPIOBANK##block##_BASE, \
  27. .end = U8500_GPIOBANK##block##_BASE + 127, \
  28. .flags = IORESOURCE_MEM, \
  29. }, \
  30. { \
  31. .start = IRQ_GPIO##block, \
  32. .end = IRQ_GPIO##block, \
  33. .flags = IORESOURCE_IRQ, \
  34. }
  35. #define GPIO_DEVICE(block) \
  36. { \
  37. .name = "gpio", \
  38. .id = block, \
  39. .num_resources = 2, \
  40. .resource = &u8500_gpio_resources[block * 2], \
  41. .dev = { \
  42. .platform_data = &u8500_gpio_data[block], \
  43. }, \
  44. }
  45. #define GPIO_DATA(_name, first) \
  46. { \
  47. .name = _name, \
  48. .first_gpio = first, \
  49. .first_irq = NOMADIK_GPIO_TO_IRQ(first), \
  50. }
  51. static struct nmk_gpio_platform_data u8500_gpio_data[] = {
  52. GPIO_DATA("GPIO-0-31", 0),
  53. GPIO_DATA("GPIO-32-63", 32), /* 37..63 not routed to pin */
  54. GPIO_DATA("GPIO-64-95", 64),
  55. GPIO_DATA("GPIO-96-127", 96), /* 97..127 not routed to pin */
  56. GPIO_DATA("GPIO-128-159", 128),
  57. GPIO_DATA("GPIO-160-191", 160), /* 172..191 not routed to pin */
  58. GPIO_DATA("GPIO-192-223", 192),
  59. GPIO_DATA("GPIO-224-255", 224), /* 231..255 not routed to pin */
  60. GPIO_DATA("GPIO-256-288", 256), /* 258..288 not routed to pin */
  61. };
  62. static struct resource u8500_gpio_resources[] = {
  63. GPIO_RESOURCE(0),
  64. GPIO_RESOURCE(1),
  65. GPIO_RESOURCE(2),
  66. GPIO_RESOURCE(3),
  67. GPIO_RESOURCE(4),
  68. GPIO_RESOURCE(5),
  69. GPIO_RESOURCE(6),
  70. GPIO_RESOURCE(7),
  71. GPIO_RESOURCE(8),
  72. };
  73. static struct platform_device u8500_gpio_devs[] = {
  74. GPIO_DEVICE(0),
  75. GPIO_DEVICE(1),
  76. GPIO_DEVICE(2),
  77. GPIO_DEVICE(3),
  78. GPIO_DEVICE(4),
  79. GPIO_DEVICE(5),
  80. GPIO_DEVICE(6),
  81. GPIO_DEVICE(7),
  82. GPIO_DEVICE(8),
  83. };
  84. static struct platform_device *platform_devs[] __initdata = {
  85. &u8500_gpio_devs[0],
  86. &u8500_gpio_devs[1],
  87. &u8500_gpio_devs[2],
  88. &u8500_gpio_devs[3],
  89. &u8500_gpio_devs[4],
  90. &u8500_gpio_devs[5],
  91. &u8500_gpio_devs[6],
  92. &u8500_gpio_devs[7],
  93. &u8500_gpio_devs[8],
  94. };
  95. /* minimum static i/o mapping required to boot U8500 platforms */
  96. static struct map_desc u8500_io_desc[] __initdata = {
  97. __IO_DEV_DESC(U8500_PRCMU_BASE, SZ_4K),
  98. __IO_DEV_DESC(U8500_GPIO0_BASE, SZ_4K),
  99. __IO_DEV_DESC(U8500_GPIO1_BASE, SZ_4K),
  100. __IO_DEV_DESC(U8500_GPIO2_BASE, SZ_4K),
  101. __IO_DEV_DESC(U8500_GPIO3_BASE, SZ_4K),
  102. };
  103. static struct map_desc u8500ed_io_desc[] __initdata = {
  104. __IO_DEV_DESC(U8500_MTU0_BASE_ED, SZ_4K),
  105. __IO_DEV_DESC(U8500_CLKRST7_BASE_ED, SZ_8K),
  106. };
  107. static struct map_desc u8500v1_io_desc[] __initdata = {
  108. __IO_DEV_DESC(U8500_MTU0_BASE, SZ_4K),
  109. };
  110. void __init u8500_map_io(void)
  111. {
  112. ux500_map_io();
  113. iotable_init(u8500_io_desc, ARRAY_SIZE(u8500_io_desc));
  114. if (cpu_is_u8500ed())
  115. iotable_init(u8500ed_io_desc, ARRAY_SIZE(u8500ed_io_desc));
  116. else
  117. iotable_init(u8500v1_io_desc, ARRAY_SIZE(u8500v1_io_desc));
  118. }
  119. /*
  120. * This function is called from the board init
  121. */
  122. void __init u8500_init_devices(void)
  123. {
  124. /* Register the platform devices */
  125. platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
  126. return ;
  127. }
  128. static void __init u8500_timer_init(void)
  129. {
  130. #ifdef CONFIG_LOCAL_TIMERS
  131. /* Setup the local timer base */
  132. twd_base = __io_address(U8500_TWD_BASE);
  133. #endif
  134. /* Setup the MTU base */
  135. if (cpu_is_u8500ed())
  136. mtu_base = __io_address(U8500_MTU0_BASE_ED);
  137. else
  138. mtu_base = __io_address(U8500_MTU0_BASE);
  139. nmdk_timer_init();
  140. }
  141. struct sys_timer u8500_timer = {
  142. .init = u8500_timer_init,
  143. };