devices-db8500.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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. static struct resource dma40_resources[] = {
  101. [0] = {
  102. .start = U8500_DMA_BASE,
  103. .end = U8500_DMA_BASE + SZ_4K - 1,
  104. .flags = IORESOURCE_MEM,
  105. .name = "base",
  106. },
  107. [1] = {
  108. .start = U8500_DMA_LCPA_BASE,
  109. .end = U8500_DMA_LCPA_BASE + 2 * SZ_1K - 1,
  110. .flags = IORESOURCE_MEM,
  111. .name = "lcpa",
  112. },
  113. [2] = {
  114. .start = IRQ_DB8500_DMA,
  115. .end = IRQ_DB8500_DMA,
  116. .flags = IORESOURCE_IRQ,
  117. }
  118. };
  119. /* Default configuration for physcial memcpy */
  120. struct stedma40_chan_cfg dma40_memcpy_conf_phy = {
  121. .channel_type = (STEDMA40_CHANNEL_IN_PHY_MODE |
  122. STEDMA40_LOW_PRIORITY_CHANNEL |
  123. STEDMA40_PCHAN_BASIC_MODE),
  124. .dir = STEDMA40_MEM_TO_MEM,
  125. .src_info.endianess = STEDMA40_LITTLE_ENDIAN,
  126. .src_info.data_width = STEDMA40_BYTE_WIDTH,
  127. .src_info.psize = STEDMA40_PSIZE_PHY_1,
  128. .src_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
  129. .dst_info.endianess = STEDMA40_LITTLE_ENDIAN,
  130. .dst_info.data_width = STEDMA40_BYTE_WIDTH,
  131. .dst_info.psize = STEDMA40_PSIZE_PHY_1,
  132. .dst_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
  133. };
  134. /* Default configuration for logical memcpy */
  135. struct stedma40_chan_cfg dma40_memcpy_conf_log = {
  136. .channel_type = (STEDMA40_CHANNEL_IN_LOG_MODE |
  137. STEDMA40_LOW_PRIORITY_CHANNEL |
  138. STEDMA40_LCHAN_SRC_LOG_DST_LOG |
  139. STEDMA40_NO_TIM_FOR_LINK),
  140. .dir = STEDMA40_MEM_TO_MEM,
  141. .src_info.endianess = STEDMA40_LITTLE_ENDIAN,
  142. .src_info.data_width = STEDMA40_BYTE_WIDTH,
  143. .src_info.psize = STEDMA40_PSIZE_LOG_1,
  144. .src_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
  145. .dst_info.endianess = STEDMA40_LITTLE_ENDIAN,
  146. .dst_info.data_width = STEDMA40_BYTE_WIDTH,
  147. .dst_info.psize = STEDMA40_PSIZE_LOG_1,
  148. .dst_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
  149. };
  150. /*
  151. * Mapping between destination event lines and physical device address.
  152. * The event line is tied to a device and therefor the address is constant.
  153. */
  154. static const dma_addr_t dma40_tx_map[STEDMA40_NR_DEV];
  155. /* Mapping between source event lines and physical device address */
  156. static const dma_addr_t dma40_rx_map[STEDMA40_NR_DEV];
  157. /* Reserved event lines for memcpy only */
  158. static int dma40_memcpy_event[] = {
  159. STEDMA40_MEMCPY_TX_0,
  160. STEDMA40_MEMCPY_TX_1,
  161. STEDMA40_MEMCPY_TX_2,
  162. STEDMA40_MEMCPY_TX_3,
  163. STEDMA40_MEMCPY_TX_4,
  164. STEDMA40_MEMCPY_TX_5,
  165. };
  166. static struct stedma40_platform_data dma40_plat_data = {
  167. .dev_len = STEDMA40_NR_DEV,
  168. .dev_rx = dma40_rx_map,
  169. .dev_tx = dma40_tx_map,
  170. .memcpy = dma40_memcpy_event,
  171. .memcpy_len = ARRAY_SIZE(dma40_memcpy_event),
  172. .memcpy_conf_phy = &dma40_memcpy_conf_phy,
  173. .memcpy_conf_log = &dma40_memcpy_conf_log,
  174. .llis_per_log = 8,
  175. .disabled_channels = {-1},
  176. };
  177. struct platform_device u8500_dma40_device = {
  178. .dev = {
  179. .platform_data = &dma40_plat_data,
  180. },
  181. .name = "dma40",
  182. .id = 0,
  183. .num_resources = ARRAY_SIZE(dma40_resources),
  184. .resource = dma40_resources
  185. };
  186. void dma40_u8500ed_fixup(void)
  187. {
  188. dma40_plat_data.memcpy = NULL;
  189. dma40_plat_data.memcpy_len = 0;
  190. dma40_resources[0].start = U8500_DMA_BASE_ED;
  191. dma40_resources[0].end = U8500_DMA_BASE_ED + SZ_4K - 1;
  192. dma40_resources[1].start = U8500_DMA_LCPA_BASE_ED;
  193. dma40_resources[1].end = U8500_DMA_LCPA_BASE_ED + 2 * SZ_1K - 1;
  194. }