cpu-db5500.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*
  2. * Copyright (C) ST-Ericsson SA 2010
  3. *
  4. * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
  5. * License terms: GNU General Public License (GPL) version 2
  6. */
  7. #include <linux/platform_device.h>
  8. #include <linux/amba/bus.h>
  9. #include <linux/io.h>
  10. #include <linux/irq.h>
  11. #include <asm/mach/map.h>
  12. #include <asm/pmu.h>
  13. #include <plat/gpio-nomadik.h>
  14. #include <mach/hardware.h>
  15. #include <mach/devices.h>
  16. #include <mach/setup.h>
  17. #include <mach/irqs.h>
  18. #include <mach/usb.h>
  19. #include "devices-db5500.h"
  20. #include "ste-dma40-db5500.h"
  21. static struct map_desc u5500_uart_io_desc[] __initdata = {
  22. __IO_DEV_DESC(U5500_UART0_BASE, SZ_4K),
  23. __IO_DEV_DESC(U5500_UART2_BASE, SZ_4K),
  24. };
  25. static struct map_desc u5500_io_desc[] __initdata = {
  26. __IO_DEV_DESC(U5500_GIC_CPU_BASE, SZ_4K),
  27. __IO_DEV_DESC(U5500_GIC_DIST_BASE, SZ_4K),
  28. __IO_DEV_DESC(U5500_L2CC_BASE, SZ_4K),
  29. __IO_DEV_DESC(U5500_TWD_BASE, SZ_4K),
  30. __IO_DEV_DESC(U5500_MTU0_BASE, SZ_4K),
  31. __IO_DEV_DESC(U5500_SCU_BASE, SZ_4K),
  32. __IO_DEV_DESC(U5500_BACKUPRAM0_BASE, SZ_8K),
  33. __IO_DEV_DESC(U5500_GPIO0_BASE, SZ_4K),
  34. __IO_DEV_DESC(U5500_GPIO1_BASE, SZ_4K),
  35. __IO_DEV_DESC(U5500_GPIO2_BASE, SZ_4K),
  36. __IO_DEV_DESC(U5500_GPIO3_BASE, SZ_4K),
  37. __IO_DEV_DESC(U5500_GPIO4_BASE, SZ_4K),
  38. __IO_DEV_DESC(U5500_PRCMU_BASE, SZ_4K),
  39. __IO_DEV_DESC(U5500_PRCMU_TCDM_BASE, SZ_4K),
  40. };
  41. static struct resource mbox0_resources[] = {
  42. {
  43. .name = "mbox_peer",
  44. .start = U5500_MBOX0_PEER_START,
  45. .end = U5500_MBOX0_PEER_END,
  46. .flags = IORESOURCE_MEM,
  47. },
  48. {
  49. .name = "mbox_local",
  50. .start = U5500_MBOX0_LOCAL_START,
  51. .end = U5500_MBOX0_LOCAL_END,
  52. .flags = IORESOURCE_MEM,
  53. },
  54. {
  55. .name = "mbox_irq",
  56. .start = MBOX_PAIR0_VIRT_IRQ,
  57. .end = MBOX_PAIR0_VIRT_IRQ,
  58. .flags = IORESOURCE_IRQ,
  59. }
  60. };
  61. static struct resource mbox1_resources[] = {
  62. {
  63. .name = "mbox_peer",
  64. .start = U5500_MBOX1_PEER_START,
  65. .end = U5500_MBOX1_PEER_END,
  66. .flags = IORESOURCE_MEM,
  67. },
  68. {
  69. .name = "mbox_local",
  70. .start = U5500_MBOX1_LOCAL_START,
  71. .end = U5500_MBOX1_LOCAL_END,
  72. .flags = IORESOURCE_MEM,
  73. },
  74. {
  75. .name = "mbox_irq",
  76. .start = MBOX_PAIR1_VIRT_IRQ,
  77. .end = MBOX_PAIR1_VIRT_IRQ,
  78. .flags = IORESOURCE_IRQ,
  79. }
  80. };
  81. static struct resource mbox2_resources[] = {
  82. {
  83. .name = "mbox_peer",
  84. .start = U5500_MBOX2_PEER_START,
  85. .end = U5500_MBOX2_PEER_END,
  86. .flags = IORESOURCE_MEM,
  87. },
  88. {
  89. .name = "mbox_local",
  90. .start = U5500_MBOX2_LOCAL_START,
  91. .end = U5500_MBOX2_LOCAL_END,
  92. .flags = IORESOURCE_MEM,
  93. },
  94. {
  95. .name = "mbox_irq",
  96. .start = MBOX_PAIR2_VIRT_IRQ,
  97. .end = MBOX_PAIR2_VIRT_IRQ,
  98. .flags = IORESOURCE_IRQ,
  99. }
  100. };
  101. static struct platform_device mbox0_device = {
  102. .id = 0,
  103. .name = "mbox",
  104. .resource = mbox0_resources,
  105. .num_resources = ARRAY_SIZE(mbox0_resources),
  106. };
  107. static struct platform_device mbox1_device = {
  108. .id = 1,
  109. .name = "mbox",
  110. .resource = mbox1_resources,
  111. .num_resources = ARRAY_SIZE(mbox1_resources),
  112. };
  113. static struct platform_device mbox2_device = {
  114. .id = 2,
  115. .name = "mbox",
  116. .resource = mbox2_resources,
  117. .num_resources = ARRAY_SIZE(mbox2_resources),
  118. };
  119. static struct platform_device *db5500_platform_devs[] __initdata = {
  120. &mbox0_device,
  121. &mbox1_device,
  122. &mbox2_device,
  123. };
  124. static resource_size_t __initdata db5500_gpio_base[] = {
  125. U5500_GPIOBANK0_BASE,
  126. U5500_GPIOBANK1_BASE,
  127. U5500_GPIOBANK2_BASE,
  128. U5500_GPIOBANK3_BASE,
  129. U5500_GPIOBANK4_BASE,
  130. U5500_GPIOBANK5_BASE,
  131. U5500_GPIOBANK6_BASE,
  132. U5500_GPIOBANK7_BASE,
  133. };
  134. static void __init db5500_add_gpios(void)
  135. {
  136. struct nmk_gpio_platform_data pdata = {
  137. /* No custom data yet */
  138. };
  139. dbx500_add_gpios(ARRAY_AND_SIZE(db5500_gpio_base),
  140. IRQ_DB5500_GPIO0, &pdata);
  141. }
  142. void __init u5500_map_io(void)
  143. {
  144. /*
  145. * Map the UARTs early so that the DEBUG_LL stuff continues to work.
  146. */
  147. iotable_init(u5500_uart_io_desc, ARRAY_SIZE(u5500_uart_io_desc));
  148. ux500_map_io();
  149. iotable_init(u5500_io_desc, ARRAY_SIZE(u5500_io_desc));
  150. _PRCMU_BASE = __io_address(U5500_PRCMU_BASE);
  151. }
  152. static void __init db5500_pmu_init(void)
  153. {
  154. struct resource res[] = {
  155. [0] = {
  156. .start = IRQ_DB5500_PMU0,
  157. .end = IRQ_DB5500_PMU0,
  158. .flags = IORESOURCE_IRQ,
  159. },
  160. [1] = {
  161. .start = IRQ_DB5500_PMU1,
  162. .end = IRQ_DB5500_PMU1,
  163. .flags = IORESOURCE_IRQ,
  164. },
  165. };
  166. platform_device_register_simple("arm-pmu", ARM_PMU_DEVICE_CPU,
  167. res, ARRAY_SIZE(res));
  168. }
  169. static int usb_db5500_rx_dma_cfg[] = {
  170. DB5500_DMA_DEV4_USB_OTG_IEP_1_9,
  171. DB5500_DMA_DEV5_USB_OTG_IEP_2_10,
  172. DB5500_DMA_DEV6_USB_OTG_IEP_3_11,
  173. DB5500_DMA_DEV20_USB_OTG_IEP_4_12,
  174. DB5500_DMA_DEV21_USB_OTG_IEP_5_13,
  175. DB5500_DMA_DEV22_USB_OTG_IEP_6_14,
  176. DB5500_DMA_DEV23_USB_OTG_IEP_7_15,
  177. DB5500_DMA_DEV38_USB_OTG_IEP_8
  178. };
  179. static int usb_db5500_tx_dma_cfg[] = {
  180. DB5500_DMA_DEV4_USB_OTG_OEP_1_9,
  181. DB5500_DMA_DEV5_USB_OTG_OEP_2_10,
  182. DB5500_DMA_DEV6_USB_OTG_OEP_3_11,
  183. DB5500_DMA_DEV20_USB_OTG_OEP_4_12,
  184. DB5500_DMA_DEV21_USB_OTG_OEP_5_13,
  185. DB5500_DMA_DEV22_USB_OTG_OEP_6_14,
  186. DB5500_DMA_DEV23_USB_OTG_OEP_7_15,
  187. DB5500_DMA_DEV38_USB_OTG_OEP_8
  188. };
  189. void __init u5500_init_devices(void)
  190. {
  191. db5500_add_gpios();
  192. db5500_pmu_init();
  193. db5500_dma_init();
  194. db5500_add_rtc();
  195. db5500_add_usb(usb_db5500_rx_dma_cfg, usb_db5500_tx_dma_cfg);
  196. platform_add_devices(db5500_platform_devs,
  197. ARRAY_SIZE(db5500_platform_devs));
  198. }