cpu-db5500.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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.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 db5500_pmu_resources[] = {
  42. [0] = {
  43. .start = IRQ_DB5500_PMU0,
  44. .end = IRQ_DB5500_PMU0,
  45. .flags = IORESOURCE_IRQ,
  46. },
  47. [1] = {
  48. .start = IRQ_DB5500_PMU1,
  49. .end = IRQ_DB5500_PMU1,
  50. .flags = IORESOURCE_IRQ,
  51. },
  52. };
  53. static struct platform_device db5500_pmu_device = {
  54. .name = "arm-pmu",
  55. .id = ARM_PMU_DEVICE_CPU,
  56. .num_resources = ARRAY_SIZE(db5500_pmu_resources),
  57. .resource = db5500_pmu_resources,
  58. };
  59. static struct resource mbox0_resources[] = {
  60. {
  61. .name = "mbox_peer",
  62. .start = U5500_MBOX0_PEER_START,
  63. .end = U5500_MBOX0_PEER_END,
  64. .flags = IORESOURCE_MEM,
  65. },
  66. {
  67. .name = "mbox_local",
  68. .start = U5500_MBOX0_LOCAL_START,
  69. .end = U5500_MBOX0_LOCAL_END,
  70. .flags = IORESOURCE_MEM,
  71. },
  72. {
  73. .name = "mbox_irq",
  74. .start = MBOX_PAIR0_VIRT_IRQ,
  75. .end = MBOX_PAIR0_VIRT_IRQ,
  76. .flags = IORESOURCE_IRQ,
  77. }
  78. };
  79. static struct resource mbox1_resources[] = {
  80. {
  81. .name = "mbox_peer",
  82. .start = U5500_MBOX1_PEER_START,
  83. .end = U5500_MBOX1_PEER_END,
  84. .flags = IORESOURCE_MEM,
  85. },
  86. {
  87. .name = "mbox_local",
  88. .start = U5500_MBOX1_LOCAL_START,
  89. .end = U5500_MBOX1_LOCAL_END,
  90. .flags = IORESOURCE_MEM,
  91. },
  92. {
  93. .name = "mbox_irq",
  94. .start = MBOX_PAIR1_VIRT_IRQ,
  95. .end = MBOX_PAIR1_VIRT_IRQ,
  96. .flags = IORESOURCE_IRQ,
  97. }
  98. };
  99. static struct resource mbox2_resources[] = {
  100. {
  101. .name = "mbox_peer",
  102. .start = U5500_MBOX2_PEER_START,
  103. .end = U5500_MBOX2_PEER_END,
  104. .flags = IORESOURCE_MEM,
  105. },
  106. {
  107. .name = "mbox_local",
  108. .start = U5500_MBOX2_LOCAL_START,
  109. .end = U5500_MBOX2_LOCAL_END,
  110. .flags = IORESOURCE_MEM,
  111. },
  112. {
  113. .name = "mbox_irq",
  114. .start = MBOX_PAIR2_VIRT_IRQ,
  115. .end = MBOX_PAIR2_VIRT_IRQ,
  116. .flags = IORESOURCE_IRQ,
  117. }
  118. };
  119. static struct platform_device mbox0_device = {
  120. .id = 0,
  121. .name = "mbox",
  122. .resource = mbox0_resources,
  123. .num_resources = ARRAY_SIZE(mbox0_resources),
  124. };
  125. static struct platform_device mbox1_device = {
  126. .id = 1,
  127. .name = "mbox",
  128. .resource = mbox1_resources,
  129. .num_resources = ARRAY_SIZE(mbox1_resources),
  130. };
  131. static struct platform_device mbox2_device = {
  132. .id = 2,
  133. .name = "mbox",
  134. .resource = mbox2_resources,
  135. .num_resources = ARRAY_SIZE(mbox2_resources),
  136. };
  137. static struct platform_device *db5500_platform_devs[] __initdata = {
  138. &db5500_pmu_device,
  139. &mbox0_device,
  140. &mbox1_device,
  141. &mbox2_device,
  142. };
  143. static resource_size_t __initdata db5500_gpio_base[] = {
  144. U5500_GPIOBANK0_BASE,
  145. U5500_GPIOBANK1_BASE,
  146. U5500_GPIOBANK2_BASE,
  147. U5500_GPIOBANK3_BASE,
  148. U5500_GPIOBANK4_BASE,
  149. U5500_GPIOBANK5_BASE,
  150. U5500_GPIOBANK6_BASE,
  151. U5500_GPIOBANK7_BASE,
  152. };
  153. static void __init db5500_add_gpios(void)
  154. {
  155. struct nmk_gpio_platform_data pdata = {
  156. /* No custom data yet */
  157. };
  158. dbx500_add_gpios(ARRAY_AND_SIZE(db5500_gpio_base),
  159. IRQ_DB5500_GPIO0, &pdata);
  160. }
  161. void __init u5500_map_io(void)
  162. {
  163. /*
  164. * Map the UARTs early so that the DEBUG_LL stuff continues to work.
  165. */
  166. iotable_init(u5500_uart_io_desc, ARRAY_SIZE(u5500_uart_io_desc));
  167. ux500_map_io();
  168. iotable_init(u5500_io_desc, ARRAY_SIZE(u5500_io_desc));
  169. _PRCMU_BASE = __io_address(U5500_PRCMU_BASE);
  170. }
  171. static int usb_db5500_rx_dma_cfg[] = {
  172. DB5500_DMA_DEV4_USB_OTG_IEP_1_9,
  173. DB5500_DMA_DEV5_USB_OTG_IEP_2_10,
  174. DB5500_DMA_DEV6_USB_OTG_IEP_3_11,
  175. DB5500_DMA_DEV20_USB_OTG_IEP_4_12,
  176. DB5500_DMA_DEV21_USB_OTG_IEP_5_13,
  177. DB5500_DMA_DEV22_USB_OTG_IEP_6_14,
  178. DB5500_DMA_DEV23_USB_OTG_IEP_7_15,
  179. DB5500_DMA_DEV38_USB_OTG_IEP_8
  180. };
  181. static int usb_db5500_tx_dma_cfg[] = {
  182. DB5500_DMA_DEV4_USB_OTG_OEP_1_9,
  183. DB5500_DMA_DEV5_USB_OTG_OEP_2_10,
  184. DB5500_DMA_DEV6_USB_OTG_OEP_3_11,
  185. DB5500_DMA_DEV20_USB_OTG_OEP_4_12,
  186. DB5500_DMA_DEV21_USB_OTG_OEP_5_13,
  187. DB5500_DMA_DEV22_USB_OTG_OEP_6_14,
  188. DB5500_DMA_DEV23_USB_OTG_OEP_7_15,
  189. DB5500_DMA_DEV38_USB_OTG_OEP_8
  190. };
  191. void __init u5500_init_devices(void)
  192. {
  193. db5500_add_gpios();
  194. db5500_dma_init();
  195. db5500_add_rtc();
  196. db5500_add_usb(usb_db5500_rx_dma_cfg, usb_db5500_tx_dma_cfg);
  197. platform_add_devices(db5500_platform_devs,
  198. ARRAY_SIZE(db5500_platform_devs));
  199. }