devices-db8500.c 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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/kernel.h>
  8. #include <linux/platform_device.h>
  9. #include <linux/interrupt.h>
  10. #include <linux/io.h>
  11. #include <linux/gpio.h>
  12. #include <linux/amba/bus.h>
  13. #include <plat/ste_dma40.h>
  14. #include <mach/hardware.h>
  15. #include <mach/setup.h>
  16. #include "ste-dma40-db8500.h"
  17. static struct nmk_gpio_platform_data u8500_gpio_data[] = {
  18. GPIO_DATA("GPIO-0-31", 0),
  19. GPIO_DATA("GPIO-32-63", 32), /* 37..63 not routed to pin */
  20. GPIO_DATA("GPIO-64-95", 64),
  21. GPIO_DATA("GPIO-96-127", 96), /* 98..127 not routed to pin */
  22. GPIO_DATA("GPIO-128-159", 128),
  23. GPIO_DATA("GPIO-160-191", 160), /* 172..191 not routed to pin */
  24. GPIO_DATA("GPIO-192-223", 192),
  25. GPIO_DATA("GPIO-224-255", 224), /* 231..255 not routed to pin */
  26. GPIO_DATA("GPIO-256-288", 256), /* 268..288 not routed to pin */
  27. };
  28. static struct resource u8500_gpio_resources[] = {
  29. GPIO_RESOURCE(0),
  30. GPIO_RESOURCE(1),
  31. GPIO_RESOURCE(2),
  32. GPIO_RESOURCE(3),
  33. GPIO_RESOURCE(4),
  34. GPIO_RESOURCE(5),
  35. GPIO_RESOURCE(6),
  36. GPIO_RESOURCE(7),
  37. GPIO_RESOURCE(8),
  38. };
  39. struct platform_device u8500_gpio_devs[] = {
  40. GPIO_DEVICE(0),
  41. GPIO_DEVICE(1),
  42. GPIO_DEVICE(2),
  43. GPIO_DEVICE(3),
  44. GPIO_DEVICE(4),
  45. GPIO_DEVICE(5),
  46. GPIO_DEVICE(6),
  47. GPIO_DEVICE(7),
  48. GPIO_DEVICE(8),
  49. };
  50. struct amba_device u8500_ssp0_device = {
  51. .dev = {
  52. .coherent_dma_mask = ~0,
  53. .init_name = "ssp0",
  54. },
  55. .res = {
  56. .start = U8500_SSP0_BASE,
  57. .end = U8500_SSP0_BASE + SZ_4K - 1,
  58. .flags = IORESOURCE_MEM,
  59. },
  60. .irq = {IRQ_DB8500_SSP0, NO_IRQ },
  61. /* ST-Ericsson modified id */
  62. .periphid = SSP_PER_ID,
  63. };
  64. static struct resource u8500_i2c0_resources[] = {
  65. [0] = {
  66. .start = U8500_I2C0_BASE,
  67. .end = U8500_I2C0_BASE + SZ_4K - 1,
  68. .flags = IORESOURCE_MEM,
  69. },
  70. [1] = {
  71. .start = IRQ_DB8500_I2C0,
  72. .end = IRQ_DB8500_I2C0,
  73. .flags = IORESOURCE_IRQ,
  74. }
  75. };
  76. struct platform_device u8500_i2c0_device = {
  77. .name = "nmk-i2c",
  78. .id = 0,
  79. .resource = u8500_i2c0_resources,
  80. .num_resources = ARRAY_SIZE(u8500_i2c0_resources),
  81. };
  82. static struct resource u8500_i2c4_resources[] = {
  83. [0] = {
  84. .start = U8500_I2C4_BASE,
  85. .end = U8500_I2C4_BASE + SZ_4K - 1,
  86. .flags = IORESOURCE_MEM,
  87. },
  88. [1] = {
  89. .start = IRQ_DB8500_I2C4,
  90. .end = IRQ_DB8500_I2C4,
  91. .flags = IORESOURCE_IRQ,
  92. }
  93. };
  94. struct platform_device u8500_i2c4_device = {
  95. .name = "nmk-i2c",
  96. .id = 4,
  97. .resource = u8500_i2c4_resources,
  98. .num_resources = ARRAY_SIZE(u8500_i2c4_resources),
  99. };
  100. /*
  101. * SD/MMC
  102. */
  103. struct amba_device u8500_sdi0_device = {
  104. .dev = {
  105. .init_name = "sdi0",
  106. },
  107. .res = {
  108. .start = U8500_SDI0_BASE,
  109. .end = U8500_SDI0_BASE + SZ_4K - 1,
  110. .flags = IORESOURCE_MEM,
  111. },
  112. .irq = {IRQ_DB8500_SDMMC0, NO_IRQ},
  113. };
  114. struct amba_device u8500_sdi1_device = {
  115. .dev = {
  116. .init_name = "sdi1",
  117. },
  118. .res = {
  119. .start = U8500_SDI1_BASE,
  120. .end = U8500_SDI1_BASE + SZ_4K - 1,
  121. .flags = IORESOURCE_MEM,
  122. },
  123. .irq = {IRQ_DB8500_SDMMC1, NO_IRQ},
  124. };
  125. struct amba_device u8500_sdi2_device = {
  126. .dev = {
  127. .init_name = "sdi2",
  128. },
  129. .res = {
  130. .start = U8500_SDI2_BASE,
  131. .end = U8500_SDI2_BASE + SZ_4K - 1,
  132. .flags = IORESOURCE_MEM,
  133. },
  134. .irq = {IRQ_DB8500_SDMMC2, NO_IRQ},
  135. };
  136. struct amba_device u8500_sdi3_device = {
  137. .dev = {
  138. .init_name = "sdi3",
  139. },
  140. .res = {
  141. .start = U8500_SDI3_BASE,
  142. .end = U8500_SDI3_BASE + SZ_4K - 1,
  143. .flags = IORESOURCE_MEM,
  144. },
  145. .irq = {IRQ_DB8500_SDMMC3, NO_IRQ},
  146. };
  147. struct amba_device u8500_sdi4_device = {
  148. .dev = {
  149. .init_name = "sdi4",
  150. },
  151. .res = {
  152. .start = U8500_SDI4_BASE,
  153. .end = U8500_SDI4_BASE + SZ_4K - 1,
  154. .flags = IORESOURCE_MEM,
  155. },
  156. .irq = {IRQ_DB8500_SDMMC4, NO_IRQ},
  157. };
  158. struct amba_device u8500_sdi5_device = {
  159. .dev = {
  160. .init_name = "sdi5",
  161. },
  162. .res = {
  163. .start = U8500_SDI5_BASE,
  164. .end = U8500_SDI5_BASE + SZ_4K - 1,
  165. .flags = IORESOURCE_MEM,
  166. },
  167. .irq = {IRQ_DB8500_SDMMC5, NO_IRQ},
  168. };
  169. static struct resource dma40_resources[] = {
  170. [0] = {
  171. .start = U8500_DMA_BASE,
  172. .end = U8500_DMA_BASE + SZ_4K - 1,
  173. .flags = IORESOURCE_MEM,
  174. .name = "base",
  175. },
  176. [1] = {
  177. .start = U8500_DMA_LCPA_BASE,
  178. .end = U8500_DMA_LCPA_BASE + 2 * SZ_1K - 1,
  179. .flags = IORESOURCE_MEM,
  180. .name = "lcpa",
  181. },
  182. [2] = {
  183. .start = IRQ_DB8500_DMA,
  184. .end = IRQ_DB8500_DMA,
  185. .flags = IORESOURCE_IRQ,
  186. }
  187. };
  188. /* Default configuration for physcial memcpy */
  189. struct stedma40_chan_cfg dma40_memcpy_conf_phy = {
  190. .mode = STEDMA40_MODE_PHYSICAL,
  191. .dir = STEDMA40_MEM_TO_MEM,
  192. .src_info.data_width = STEDMA40_BYTE_WIDTH,
  193. .src_info.psize = STEDMA40_PSIZE_PHY_1,
  194. .src_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
  195. .dst_info.data_width = STEDMA40_BYTE_WIDTH,
  196. .dst_info.psize = STEDMA40_PSIZE_PHY_1,
  197. .dst_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
  198. };
  199. /* Default configuration for logical memcpy */
  200. struct stedma40_chan_cfg dma40_memcpy_conf_log = {
  201. .dir = STEDMA40_MEM_TO_MEM,
  202. .src_info.data_width = STEDMA40_BYTE_WIDTH,
  203. .src_info.psize = STEDMA40_PSIZE_LOG_1,
  204. .src_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
  205. .dst_info.data_width = STEDMA40_BYTE_WIDTH,
  206. .dst_info.psize = STEDMA40_PSIZE_LOG_1,
  207. .dst_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
  208. };
  209. /*
  210. * Mapping between destination event lines and physical device address.
  211. * The event line is tied to a device and therefor the address is constant.
  212. */
  213. static const dma_addr_t dma40_tx_map[DB8500_DMA_NR_DEV];
  214. /* Mapping between source event lines and physical device address */
  215. static const dma_addr_t dma40_rx_map[DB8500_DMA_NR_DEV];
  216. /* Reserved event lines for memcpy only */
  217. static int dma40_memcpy_event[] = {
  218. DB8500_DMA_MEMCPY_TX_0,
  219. DB8500_DMA_MEMCPY_TX_1,
  220. DB8500_DMA_MEMCPY_TX_2,
  221. DB8500_DMA_MEMCPY_TX_3,
  222. DB8500_DMA_MEMCPY_TX_4,
  223. DB8500_DMA_MEMCPY_TX_5,
  224. };
  225. static struct stedma40_platform_data dma40_plat_data = {
  226. .dev_len = DB8500_DMA_NR_DEV,
  227. .dev_rx = dma40_rx_map,
  228. .dev_tx = dma40_tx_map,
  229. .memcpy = dma40_memcpy_event,
  230. .memcpy_len = ARRAY_SIZE(dma40_memcpy_event),
  231. .memcpy_conf_phy = &dma40_memcpy_conf_phy,
  232. .memcpy_conf_log = &dma40_memcpy_conf_log,
  233. .disabled_channels = {-1},
  234. };
  235. struct platform_device u8500_dma40_device = {
  236. .dev = {
  237. .platform_data = &dma40_plat_data,
  238. },
  239. .name = "dma40",
  240. .id = 0,
  241. .num_resources = ARRAY_SIZE(dma40_resources),
  242. .resource = dma40_resources
  243. };
  244. void dma40_u8500ed_fixup(void)
  245. {
  246. dma40_plat_data.memcpy = NULL;
  247. dma40_plat_data.memcpy_len = 0;
  248. dma40_resources[0].start = U8500_DMA_BASE_ED;
  249. dma40_resources[0].end = U8500_DMA_BASE_ED + SZ_4K - 1;
  250. dma40_resources[1].start = U8500_DMA_LCPA_BASE_ED;
  251. dma40_resources[1].end = U8500_DMA_LCPA_BASE_ED + 2 * SZ_1K - 1;
  252. }
  253. struct resource keypad_resources[] = {
  254. [0] = {
  255. .start = U8500_SKE_BASE,
  256. .end = U8500_SKE_BASE + SZ_4K - 1,
  257. .flags = IORESOURCE_MEM,
  258. },
  259. [1] = {
  260. .start = IRQ_DB8500_KB,
  261. .end = IRQ_DB8500_KB,
  262. .flags = IORESOURCE_IRQ,
  263. },
  264. };
  265. struct platform_device ux500_ske_keypad_device = {
  266. .name = "nmk-ske-keypad",
  267. .id = -1,
  268. .num_resources = ARRAY_SIZE(keypad_resources),
  269. .resource = keypad_resources,
  270. };