board-mop500.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /*
  2. * Copyright (C) 2008-2009 ST-Ericsson
  3. *
  4. * Author: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2, as
  8. * published by the Free Software Foundation.
  9. *
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/io.h>
  16. #include <linux/amba/bus.h>
  17. #include <linux/amba/pl022.h>
  18. #include <linux/spi/spi.h>
  19. #include <asm/localtimer.h>
  20. #include <asm/mach-types.h>
  21. #include <asm/mach/arch.h>
  22. #include <plat/mtu.h>
  23. #include <plat/i2c.h>
  24. #include <mach/hardware.h>
  25. #include <mach/setup.h>
  26. #define __MEM_4K_RESOURCE(x) \
  27. .res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM}
  28. /* These are active devices on this board */
  29. static struct amba_device uart0_device = {
  30. .dev = { .init_name = "uart0" },
  31. __MEM_4K_RESOURCE(U8500_UART0_BASE),
  32. .irq = {IRQ_UART0, NO_IRQ},
  33. };
  34. static struct amba_device uart1_device = {
  35. .dev = { .init_name = "uart1" },
  36. __MEM_4K_RESOURCE(U8500_UART1_BASE),
  37. .irq = {IRQ_UART1, NO_IRQ},
  38. };
  39. static struct amba_device uart2_device = {
  40. .dev = { .init_name = "uart2" },
  41. __MEM_4K_RESOURCE(U8500_UART2_BASE),
  42. .irq = {IRQ_UART2, NO_IRQ},
  43. };
  44. static void ab4500_spi_cs_control(u32 command)
  45. {
  46. /* set the FRM signal, which is CS - TODO */
  47. }
  48. struct pl022_config_chip ab4500_chip_info = {
  49. .lbm = LOOPBACK_DISABLED,
  50. .com_mode = INTERRUPT_TRANSFER,
  51. .iface = SSP_INTERFACE_MOTOROLA_SPI,
  52. /* we can act as master only */
  53. .hierarchy = SSP_MASTER,
  54. .slave_tx_disable = 0,
  55. .endian_rx = SSP_RX_MSB,
  56. .endian_tx = SSP_TX_MSB,
  57. .data_size = SSP_DATA_BITS_24,
  58. .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM,
  59. .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC,
  60. .clk_phase = SSP_CLK_SECOND_EDGE,
  61. .clk_pol = SSP_CLK_POL_IDLE_HIGH,
  62. .cs_control = ab4500_spi_cs_control,
  63. };
  64. static struct spi_board_info u8500_spi_devices[] = {
  65. {
  66. .modalias = "ab4500",
  67. .controller_data = &ab4500_chip_info,
  68. .max_speed_hz = 12000000,
  69. .bus_num = 0,
  70. .chip_select = 0,
  71. .mode = SPI_MODE_0,
  72. .irq = IRQ_AB4500,
  73. },
  74. };
  75. static struct pl022_ssp_controller ssp0_platform_data = {
  76. .bus_id = 0,
  77. /* pl022 not yet supports dma */
  78. .enable_dma = 0,
  79. /* on this platform, gpio 31,142,144,214 &
  80. * 224 are connected as chip selects
  81. */
  82. .num_chipselect = 5,
  83. };
  84. static struct amba_device pl022_device = {
  85. .dev = {
  86. .coherent_dma_mask = ~0,
  87. .init_name = "pl022",
  88. .platform_data = &ssp0_platform_data,
  89. },
  90. .res = {
  91. .start = U8500_SSP0_BASE,
  92. .end = U8500_SSP0_BASE + SZ_4K - 1,
  93. .flags = IORESOURCE_MEM,
  94. },
  95. .irq = {IRQ_SSP0, NO_IRQ },
  96. /* ST-Ericsson modified id */
  97. .periphid = SSP_PER_ID,
  98. };
  99. static struct amba_device pl031_device = {
  100. .dev = {
  101. .init_name = "pl031",
  102. },
  103. .res = {
  104. .start = U8500_RTC_BASE,
  105. .end = U8500_RTC_BASE + SZ_4K - 1,
  106. .flags = IORESOURCE_MEM,
  107. },
  108. .irq = {IRQ_RTC_RTT, NO_IRQ},
  109. };
  110. #define U8500_I2C_RESOURCES(id, size) \
  111. static struct resource u8500_i2c_resources_##id[] = { \
  112. [0] = { \
  113. .start = U8500_I2C##id##_BASE, \
  114. .end = U8500_I2C##id##_BASE + size - 1, \
  115. .flags = IORESOURCE_MEM, \
  116. }, \
  117. [1] = { \
  118. .start = IRQ_I2C##id, \
  119. .end = IRQ_I2C##id, \
  120. .flags = IORESOURCE_IRQ \
  121. } \
  122. }
  123. U8500_I2C_RESOURCES(0, SZ_4K);
  124. U8500_I2C_RESOURCES(1, SZ_4K);
  125. U8500_I2C_RESOURCES(2, SZ_4K);
  126. U8500_I2C_RESOURCES(3, SZ_4K);
  127. #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
  128. static struct nmk_i2c_controller u8500_i2c_##id = { \
  129. /* \
  130. * slave data setup time, which is \
  131. * 250 ns,100ns,10ns which is 14,6,2 \
  132. * respectively for a 48 Mhz \
  133. * i2c clock \
  134. */ \
  135. .slsu = _slsu, \
  136. /* Tx FIFO threshold */ \
  137. .tft = _tft, \
  138. /* Rx FIFO threshold */ \
  139. .rft = _rft, \
  140. /* std. mode operation */ \
  141. .clk_freq = clk, \
  142. .sm = _sm, \
  143. }
  144. /*
  145. * The board uses 4 i2c controllers, initialize all of
  146. * them with slave data setup time of 250 ns,
  147. * Tx & Rx FIFO threshold values as 1 and standard
  148. * mode of operation
  149. */
  150. U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  151. U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  152. U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  153. U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  154. #define U8500_I2C_PDEVICE(cid) \
  155. static struct platform_device i2c_controller##cid = { \
  156. .name = "nmk-i2c", \
  157. .id = cid, \
  158. .num_resources = 2, \
  159. .resource = u8500_i2c_resources_##cid, \
  160. .dev = { \
  161. .platform_data = &u8500_i2c_##cid \
  162. } \
  163. }
  164. U8500_I2C_PDEVICE(0);
  165. U8500_I2C_PDEVICE(1);
  166. U8500_I2C_PDEVICE(2);
  167. U8500_I2C_PDEVICE(3);
  168. static struct amba_device *amba_devs[] __initdata = {
  169. &uart0_device,
  170. &uart1_device,
  171. &uart2_device,
  172. &pl022_device,
  173. &pl031_device,
  174. };
  175. /* add any platform devices here - TODO */
  176. static struct platform_device *platform_devs[] __initdata = {
  177. &i2c_controller0,
  178. &i2c_controller1,
  179. &i2c_controller2,
  180. &i2c_controller3,
  181. };
  182. static void __init u8500_timer_init(void)
  183. {
  184. #ifdef CONFIG_LOCAL_TIMERS
  185. /* Setup the local timer base */
  186. twd_base = __io_address(U8500_TWD_BASE);
  187. #endif
  188. /* Setup the MTU base */
  189. mtu_base = __io_address(U8500_MTU0_BASE);
  190. nmdk_timer_init();
  191. }
  192. static struct sys_timer u8500_timer = {
  193. .init = u8500_timer_init,
  194. };
  195. static void __init u8500_init_machine(void)
  196. {
  197. int i;
  198. /* Register the active AMBA devices on this board */
  199. for (i = 0; i < ARRAY_SIZE(amba_devs); i++)
  200. amba_device_register(amba_devs[i], &iomem_resource);
  201. platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
  202. spi_register_board_info(u8500_spi_devices,
  203. ARRAY_SIZE(u8500_spi_devices));
  204. u8500_init_devices();
  205. }
  206. MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
  207. /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
  208. .phys_io = U8500_UART2_BASE,
  209. .io_pg_offst = (IO_ADDRESS(U8500_UART2_BASE) >> 18) & 0xfffc,
  210. .boot_params = 0x100,
  211. .map_io = u8500_map_io,
  212. .init_irq = u8500_init_irq,
  213. /* we re-use nomadik timer here */
  214. .timer = &u8500_timer,
  215. .init_machine = u8500_init_machine,
  216. MACHINE_END