cpu-db5500.c 5.1 KB

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