cpu-db5500.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. /* SCU base also covers GIC CPU BASE and TWD with its 4K page */
  27. __IO_DEV_DESC(U5500_SCU_BASE, SZ_4K),
  28. __IO_DEV_DESC(U5500_GIC_DIST_BASE, SZ_4K),
  29. __IO_DEV_DESC(U5500_L2CC_BASE, SZ_4K),
  30. __IO_DEV_DESC(U5500_MTU0_BASE, SZ_4K),
  31. __IO_DEV_DESC(U5500_BACKUPRAM0_BASE, SZ_8K),
  32. __IO_DEV_DESC(U5500_GPIO0_BASE, SZ_4K),
  33. __IO_DEV_DESC(U5500_GPIO1_BASE, SZ_4K),
  34. __IO_DEV_DESC(U5500_GPIO2_BASE, SZ_4K),
  35. __IO_DEV_DESC(U5500_GPIO3_BASE, SZ_4K),
  36. __IO_DEV_DESC(U5500_GPIO4_BASE, SZ_4K),
  37. __IO_DEV_DESC(U5500_PRCMU_BASE, SZ_4K),
  38. __IO_DEV_DESC(U5500_PRCMU_TCDM_BASE, SZ_4K),
  39. };
  40. static struct resource mbox0_resources[] = {
  41. {
  42. .name = "mbox_peer",
  43. .start = U5500_MBOX0_PEER_START,
  44. .end = U5500_MBOX0_PEER_END,
  45. .flags = IORESOURCE_MEM,
  46. },
  47. {
  48. .name = "mbox_local",
  49. .start = U5500_MBOX0_LOCAL_START,
  50. .end = U5500_MBOX0_LOCAL_END,
  51. .flags = IORESOURCE_MEM,
  52. },
  53. {
  54. .name = "mbox_irq",
  55. .start = MBOX_PAIR0_VIRT_IRQ,
  56. .end = MBOX_PAIR0_VIRT_IRQ,
  57. .flags = IORESOURCE_IRQ,
  58. }
  59. };
  60. static struct resource mbox1_resources[] = {
  61. {
  62. .name = "mbox_peer",
  63. .start = U5500_MBOX1_PEER_START,
  64. .end = U5500_MBOX1_PEER_END,
  65. .flags = IORESOURCE_MEM,
  66. },
  67. {
  68. .name = "mbox_local",
  69. .start = U5500_MBOX1_LOCAL_START,
  70. .end = U5500_MBOX1_LOCAL_END,
  71. .flags = IORESOURCE_MEM,
  72. },
  73. {
  74. .name = "mbox_irq",
  75. .start = MBOX_PAIR1_VIRT_IRQ,
  76. .end = MBOX_PAIR1_VIRT_IRQ,
  77. .flags = IORESOURCE_IRQ,
  78. }
  79. };
  80. static struct resource mbox2_resources[] = {
  81. {
  82. .name = "mbox_peer",
  83. .start = U5500_MBOX2_PEER_START,
  84. .end = U5500_MBOX2_PEER_END,
  85. .flags = IORESOURCE_MEM,
  86. },
  87. {
  88. .name = "mbox_local",
  89. .start = U5500_MBOX2_LOCAL_START,
  90. .end = U5500_MBOX2_LOCAL_END,
  91. .flags = IORESOURCE_MEM,
  92. },
  93. {
  94. .name = "mbox_irq",
  95. .start = MBOX_PAIR2_VIRT_IRQ,
  96. .end = MBOX_PAIR2_VIRT_IRQ,
  97. .flags = IORESOURCE_IRQ,
  98. }
  99. };
  100. static struct platform_device mbox0_device = {
  101. .id = 0,
  102. .name = "mbox",
  103. .resource = mbox0_resources,
  104. .num_resources = ARRAY_SIZE(mbox0_resources),
  105. };
  106. static struct platform_device mbox1_device = {
  107. .id = 1,
  108. .name = "mbox",
  109. .resource = mbox1_resources,
  110. .num_resources = ARRAY_SIZE(mbox1_resources),
  111. };
  112. static struct platform_device mbox2_device = {
  113. .id = 2,
  114. .name = "mbox",
  115. .resource = mbox2_resources,
  116. .num_resources = ARRAY_SIZE(mbox2_resources),
  117. };
  118. static struct platform_device *db5500_platform_devs[] __initdata = {
  119. &mbox0_device,
  120. &mbox1_device,
  121. &mbox2_device,
  122. };
  123. static resource_size_t __initdata db5500_gpio_base[] = {
  124. U5500_GPIOBANK0_BASE,
  125. U5500_GPIOBANK1_BASE,
  126. U5500_GPIOBANK2_BASE,
  127. U5500_GPIOBANK3_BASE,
  128. U5500_GPIOBANK4_BASE,
  129. U5500_GPIOBANK5_BASE,
  130. U5500_GPIOBANK6_BASE,
  131. U5500_GPIOBANK7_BASE,
  132. };
  133. static void __init db5500_add_gpios(struct device *parent)
  134. {
  135. struct nmk_gpio_platform_data pdata = {
  136. /* No custom data yet */
  137. };
  138. dbx500_add_gpios(parent, ARRAY_AND_SIZE(db5500_gpio_base),
  139. IRQ_DB5500_GPIO0, &pdata);
  140. }
  141. void __init u5500_map_io(void)
  142. {
  143. /*
  144. * Map the UARTs early so that the DEBUG_LL stuff continues to work.
  145. */
  146. iotable_init(u5500_uart_io_desc, ARRAY_SIZE(u5500_uart_io_desc));
  147. ux500_map_io();
  148. iotable_init(u5500_io_desc, ARRAY_SIZE(u5500_io_desc));
  149. _PRCMU_BASE = __io_address(U5500_PRCMU_BASE);
  150. }
  151. static void __init db5500_pmu_init(void)
  152. {
  153. struct resource res[] = {
  154. [0] = {
  155. .start = IRQ_DB5500_PMU0,
  156. .end = IRQ_DB5500_PMU0,
  157. .flags = IORESOURCE_IRQ,
  158. },
  159. [1] = {
  160. .start = IRQ_DB5500_PMU1,
  161. .end = IRQ_DB5500_PMU1,
  162. .flags = IORESOURCE_IRQ,
  163. },
  164. };
  165. platform_device_register_simple("arm-pmu", ARM_PMU_DEVICE_CPU,
  166. res, ARRAY_SIZE(res));
  167. }
  168. static int usb_db5500_rx_dma_cfg[] = {
  169. DB5500_DMA_DEV4_USB_OTG_IEP_1_9,
  170. DB5500_DMA_DEV5_USB_OTG_IEP_2_10,
  171. DB5500_DMA_DEV6_USB_OTG_IEP_3_11,
  172. DB5500_DMA_DEV20_USB_OTG_IEP_4_12,
  173. DB5500_DMA_DEV21_USB_OTG_IEP_5_13,
  174. DB5500_DMA_DEV22_USB_OTG_IEP_6_14,
  175. DB5500_DMA_DEV23_USB_OTG_IEP_7_15,
  176. DB5500_DMA_DEV38_USB_OTG_IEP_8
  177. };
  178. static int usb_db5500_tx_dma_cfg[] = {
  179. DB5500_DMA_DEV4_USB_OTG_OEP_1_9,
  180. DB5500_DMA_DEV5_USB_OTG_OEP_2_10,
  181. DB5500_DMA_DEV6_USB_OTG_OEP_3_11,
  182. DB5500_DMA_DEV20_USB_OTG_OEP_4_12,
  183. DB5500_DMA_DEV21_USB_OTG_OEP_5_13,
  184. DB5500_DMA_DEV22_USB_OTG_OEP_6_14,
  185. DB5500_DMA_DEV23_USB_OTG_OEP_7_15,
  186. DB5500_DMA_DEV38_USB_OTG_OEP_8
  187. };
  188. static const char *db5500_read_soc_id(void)
  189. {
  190. return kasprintf(GFP_KERNEL, "u5500 currently unsupported\n");
  191. }
  192. static struct device * __init db5500_soc_device_init(void)
  193. {
  194. const char *soc_id = db5500_read_soc_id();
  195. return ux500_soc_device_init(soc_id);
  196. }
  197. struct device * __init u5500_init_devices(void)
  198. {
  199. struct device *parent;
  200. int i;
  201. parent = db5500_soc_device_init();
  202. db5500_add_gpios(parent);
  203. db5500_pmu_init();
  204. db5500_dma_init(parent);
  205. db5500_add_rtc(parent);
  206. db5500_add_usb(parent, usb_db5500_rx_dma_cfg, usb_db5500_tx_dma_cfg);
  207. for (i = 0; i < ARRAY_SIZE(db5500_platform_devs); i++)
  208. db5500_platform_devs[i]->dev.parent = parent;
  209. platform_add_devices(db5500_platform_devs,
  210. ARRAY_SIZE(db5500_platform_devs));
  211. return parent;
  212. }