dataMonitoring.c 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. /*
  2. *
  3. * arch/arm/mach-u300/core.c
  4. *
  5. *
  6. * Copyright (C) 2007-2012 ST-Ericsson SA
  7. * License terms: GNU General Public License (GPL) version 2
  8. * Core platform support, IRQ handling and device definitions.
  9. * Author: Linus Walleij <linus.walleij@stericsson.com>
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/spinlock.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/bitops.h>
  16. #include <linux/device.h>
  17. #include <linux/mm.h>
  18. #include <linux/termios.h>
  19. #include <linux/dmaengine.h>
  20. #include <linux/amba/bus.h>
  21. #include <linux/amba/mmci.h>
  22. #include <linux/amba/serial.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/gpio.h>
  25. #include <linux/clk.h>
  26. #include <linux/err.h>
  27. #include <linux/mtd/nand.h>
  28. #include <linux/mtd/fsmc.h>
  29. #include <linux/pinctrl/machine.h>
  30. #include <linux/pinctrl/pinconf-generic.h>
  31. #include <linux/dma-mapping.h>
  32. #include <linux/platform_data/clk-u300.h>
  33. #include <linux/platform_data/pinctrl-coh901.h>
  34. #include <asm/types.h>
  35. #include <asm/setup.h>
  36. #include <asm/memory.h>
  37. #include <asm/hardware/vic.h>
  38. #include <asm/mach/map.h>
  39. #include <asm/mach-types.h>
  40. #include <asm/mach/arch.h>
  41. #include <mach/coh901318.h>
  42. #include <mach/hardware.h>
  43. #include <mach/syscon.h>
  44. #include <mach/irqs.h>
  45. #include "timer.h"
  46. #include "spi.h"
  47. #include "i2c.h"
  48. #include "u300-gpio.h"
  49. #include "dma_channels.h"
  50. /*
  51. * Static I/O mappings that are needed for booting the U300 platforms. The
  52. * only things we need are the areas where we find the timer, syscon and
  53. * intcon, since the remaining device drivers will map their own memory
  54. * physical to virtual as the need arise.
  55. */
  56. static struct map_desc u300_io_desc[] __initdata = {
  57. {
  58. .virtual = U300_SLOW_PER_VIRT_BASE,
  59. .pfn = __phys_to_pfn(U300_SLOW_PER_PHYS_BASE),
  60. .length = SZ_64K,
  61. .type = MT_DEVICE,
  62. },
  63. {
  64. .virtual = U300_AHB_PER_VIRT_BASE,
  65. .pfn = __phys_to_pfn(U300_AHB_PER_PHYS_BASE),
  66. .length = SZ_32K,
  67. .type = MT_DEVICE,
  68. },
  69. {
  70. .virtual = U300_FAST_PER_VIRT_BASE,
  71. .pfn = __phys_to_pfn(U300_FAST_PER_PHYS_BASE),
  72. .length = SZ_32K,
  73. .type = MT_DEVICE,
  74. },
  75. };
  76. static void __init u300_map_io(void)
  77. {
  78. iotable_init(u300_io_desc, ARRAY_SIZE(u300_io_desc));
  79. }
  80. /*
  81. * Declaration of devices found on the U300 board and
  82. * their respective memory locations.
  83. */
  84. static struct amba_pl011_data uart0_plat_data = {
  85. #ifdef CONFIG_COH901318
  86. .dma_filter = coh901318_filter_id,
  87. .dma_rx_param = (void *) U300_DMA_UART0_RX,
  88. .dma_tx_param = (void *) U300_DMA_UART0_TX,
  89. #endif
  90. };
  91. /* Slow device at 0x3000 offset */
  92. static AMBA_APB_DEVICE(uart0, "uart0", 0, U300_UART0_BASE,
  93. { IRQ_U300_UART0 }, &uart0_plat_data);
  94. /* The U335 have an additional UART1 on the APP CPU */
  95. static struct amba_pl011_data uart1_plat_data = {
  96. #ifdef CONFIG_COH901318
  97. .dma_filter = coh901318_filter_id,
  98. .dma_rx_param = (void *) U300_DMA_UART1_RX,
  99. .dma_tx_param = (void *) U300_DMA_UART1_TX,
  100. #endif
  101. };
  102. /* Fast device at 0x7000 offset */
  103. static AMBA_APB_DEVICE(uart1, "uart1", 0, U300_UART1_BASE,
  104. { IRQ_U300_UART1 }, &uart1_plat_data);
  105. /* AHB device at 0x4000 offset */
  106. static AMBA_APB_DEVICE(pl172, "pl172", 0, U300_EMIF_CFG_BASE, { }, NULL);
  107. /* Fast device at 0x6000 offset */
  108. static AMBA_APB_DEVICE(pl022, "pl022", 0, U300_SPI_BASE,
  109. { IRQ_U300_SPI }, NULL);
  110. /* Fast device at 0x1000 offset */
  111. #define U300_MMCSD_IRQS { IRQ_U300_MMCSD_MCIINTR0, IRQ_U300_MMCSD_MCIINTR1 }
  112. static struct mmci_platform_data mmcsd_platform_data = {
  113. /*
  114. * Do not set ocr_mask or voltage translation function,
  115. * we have a regulator we can control instead.
  116. */
  117. .f_max = 24000000,
  118. .gpio_wp = -1,
  119. .gpio_cd = U300_GPIO_PIN_MMC_CD,
  120. .cd_invert = true,
  121. .capabilities = MMC_CAP_MMC_HIGHSPEED |
  122. MMC_CAP_SD_HIGHSPEED | MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
  123. #ifdef CONFIG_COH901318
  124. .dma_filter = coh901318_filter_id,
  125. .dma_rx_param = (void *) U300_DMA_MMCSD_RX_TX,
  126. /* Don't specify a TX channel, this RX channel is bidirectional */
  127. #endif
  128. };
  129. static AMBA_APB_DEVICE(mmcsd, "mmci", 0, U300_MMCSD_BASE,
  130. U300_MMCSD_IRQS, &mmcsd_platform_data);
  131. /*
  132. * The order of device declaration may be important, since some devices
  133. * have dependencies on other devices being initialized first.
  134. */
  135. static struct amba_device *amba_devs[] __initdata = {
  136. &uart0_device,
  137. &uart1_device,
  138. &pl022_device,
  139. &pl172_device,
  140. &mmcsd_device,
  141. };
  142. /* Here follows a list of all hw resources that the platform devices
  143. * allocate. Note, clock dependencies are not included
  144. */
  145. static struct resource gpio_resources[] = {
  146. {
  147. .start = U300_GPIO_BASE,
  148. .end = (U300_GPIO_BASE + SZ_4K - 1),
  149. .flags = IORESOURCE_MEM,
  150. },
  151. {
  152. .name = "gpio0",
  153. .start = IRQ_U300_GPIO_PORT0,
  154. .end = IRQ_U300_GPIO_PORT0,
  155. .flags = IORESOURCE_IRQ,
  156. },
  157. {
  158. .name = "gpio1",
  159. .start = IRQ_U300_GPIO_PORT1,
  160. .end = IRQ_U300_GPIO_PORT1,
  161. .flags = IORESOURCE_IRQ,
  162. },
  163. {
  164. .name = "gpio2",
  165. .start = IRQ_U300_GPIO_PORT2,
  166. .end = IRQ_U300_GPIO_PORT2,
  167. .flags = IORESOURCE_IRQ,
  168. },
  169. {
  170. .name = "gpio3",
  171. .start = IRQ_U300_GPIO_PORT3,
  172. .end = IRQ_U300_GPIO_PORT3,
  173. .flags = IORESOURCE_IRQ,
  174. },
  175. {
  176. .name = "gpio4",
  177. .start = IRQ_U300_GPIO_PORT4,
  178. .end = IRQ_U300_GPIO_PORT4,
  179. .flags = IORESOURCE_IRQ,
  180. },
  181. {
  182. .name = "gpio5",
  183. .start = IRQ_U300_GPIO_PORT5,
  184. .end = IRQ_U300_GPIO_PORT5,
  185. .flags = IORESOURCE_IRQ,
  186. },
  187. {
  188. .name = "gpio6",
  189. .start = IRQ_U300_GPIO_PORT6,
  190. .end = IRQ_U300_GPIO_PORT6,
  191. .flags = IORESOURCE_IRQ,
  192. },
  193. };
  194. static struct resource keypad_resources[] = {
  195. {
  196. .start = U300_KEYPAD_BASE,
  197. .end = U300_KEYPAD_BASE + SZ_4K - 1,
  198. .flags = IORESOURCE_MEM,
  199. },
  200. {
  201. .name = "coh901461-press",
  202. .start = IRQ_U300_KEYPAD_KEYBF,
  203. .end = IRQ_U300_KEYPAD_KEYBF,
  204. .flags = IORESOURCE_IRQ,
  205. },
  206. {
  207. .name = "coh901461-release",
  208. .start = IRQ_U300_KEYPAD_KEYBR,
  209. .end = IRQ_U300_KEYPAD_KEYBR,
  210. .flags = IORESOURCE_IRQ,
  211. },
  212. };
  213. static struct resource rtc_resources[] = {
  214. {
  215. .start = U300_RTC_BASE,
  216. .end = U300_RTC_BASE + SZ_4K - 1,
  217. .flags = IORESOURCE_MEM,
  218. },
  219. {
  220. .start = IRQ_U300_RTC,
  221. .end = IRQ_U300_RTC,
  222. .flags = IORESOURCE_IRQ,
  223. },
  224. };
  225. /*
  226. * Fsmc does have IRQs: #43 and #44 (NFIF and NFIF2)
  227. * but these are not yet used by the driver.
  228. */
  229. static struct resource fsmc_resources[] = {
  230. {
  231. .name = "nand_addr",
  232. .start = U300_NAND_CS0_PHYS_BASE + PLAT_NAND_ALE,
  233. .end = U300_NAND_CS0_PHYS_BASE + PLAT_NAND_ALE + SZ_16K - 1,
  234. .flags = IORESOURCE_MEM,
  235. },
  236. {
  237. .name = "nand_cmd",
  238. .start = U300_NAND_CS0_PHYS_BASE + PLAT_NAND_CLE,
  239. .end = U300_NAND_CS0_PHYS_BASE + PLAT_NAND_CLE + SZ_16K - 1,
  240. .flags = IORESOURCE_MEM,
  241. },
  242. {
  243. .name = "nand_data",
  244. .start = U300_NAND_CS0_PHYS_BASE,
  245. .end = U300_NAND_CS0_PHYS_BASE + SZ_16K - 1,
  246. .flags = IORESOURCE_MEM,
  247. },
  248. {
  249. .name = "fsmc_regs",
  250. .start = U300_NAND_IF_PHYS_BASE,
  251. .end = U300_NAND_IF_PHYS_BASE + SZ_4K - 1,
  252. .flags = IORESOURCE_MEM,
  253. },
  254. };
  255. static struct resource i2c0_resources[] = {
  256. {
  257. .start = U300_I2C0_BASE,
  258. .end = U300_I2C0_BASE + SZ_4K - 1,
  259. .flags = IORESOURCE_MEM,
  260. },
  261. {
  262. .start = IRQ_U300_I2C0,
  263. .end = IRQ_U300_I2C0,
  264. .flags = IORESOURCE_IRQ,
  265. },
  266. };
  267. static struct resource i2c1_resources[] = {
  268. {
  269. .start = U300_I2C1_BASE,
  270. .end = U300_I2C1_BASE + SZ_4K - 1,
  271. .flags = IORESOURCE_MEM,
  272. },
  273. {
  274. .start = IRQ_U300_I2C1,
  275. .end = IRQ_U300_I2C1,
  276. .flags = IORESOURCE_IRQ,
  277. },
  278. };
  279. static struct resource wdog_resources[] = {
  280. {
  281. .start = U300_WDOG_BASE,
  282. .end = U300_WDOG_BASE + SZ_4K - 1,
  283. .flags = IORESOURCE_MEM,
  284. },
  285. {
  286. .start = IRQ_U300_WDOG,
  287. .end = IRQ_U300_WDOG,
  288. .flags = IORESOURCE_IRQ,
  289. }
  290. };
  291. static struct resource dma_resource[] = {
  292. {
  293. .start = U300_DMAC_BASE,
  294. .end = U300_DMAC_BASE + PAGE_SIZE - 1,
  295. .flags = IORESOURCE_MEM,
  296. },
  297. {
  298. .start = IRQ_U300_DMA,
  299. .end = IRQ_U300_DMA,
  300. .flags = IORESOURCE_IRQ,
  301. }
  302. };
  303. /* points out all dma slave channels.
  304. * Syntax is [A1, B1, A2, B2, .... ,-1,-1]
  305. * Select all channels from A to B, end of list is marked with -1,-1
  306. */
  307. static int dma_slave_channels[] = {