board-mop500.c 5.6 KB

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