board-mop500.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. #define U8500_I2C_RESOURCES(id, size) \
  98. static struct resource u8500_i2c_resources_##id[] = { \
  99. [0] = { \
  100. .start = U8500_I2C##id##_BASE, \
  101. .end = U8500_I2C##id##_BASE + size - 1, \
  102. .flags = IORESOURCE_MEM, \
  103. }, \
  104. [1] = { \
  105. .start = IRQ_I2C##id, \
  106. .end = IRQ_I2C##id, \
  107. .flags = IORESOURCE_IRQ \
  108. } \
  109. }
  110. U8500_I2C_RESOURCES(0, SZ_4K);
  111. U8500_I2C_RESOURCES(1, SZ_4K);
  112. U8500_I2C_RESOURCES(2, SZ_4K);
  113. U8500_I2C_RESOURCES(3, SZ_4K);
  114. #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
  115. static struct nmk_i2c_controller u8500_i2c_##id = { \
  116. /* \
  117. * slave data setup time, which is \
  118. * 250 ns,100ns,10ns which is 14,6,2 \
  119. * respectively for a 48 Mhz \
  120. * i2c clock \
  121. */ \
  122. .slsu = _slsu, \
  123. /* Tx FIFO threshold */ \
  124. .tft = _tft, \
  125. /* Rx FIFO threshold */ \
  126. .rft = _rft, \
  127. /* std. mode operation */ \
  128. .clk_freq = clk, \
  129. .sm = _sm, \
  130. }
  131. /*
  132. * The board uses 4 i2c controllers, initialize all of
  133. * them with slave data setup time of 250 ns,
  134. * Tx & Rx FIFO threshold values as 1 and standard
  135. * mode of operation
  136. */
  137. U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  138. U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  139. U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  140. U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  141. #define U8500_I2C_PDEVICE(cid) \
  142. static struct platform_device i2c_controller##cid = { \
  143. .name = "nmk-i2c", \
  144. .id = cid, \
  145. .num_resources = 2, \
  146. .resource = u8500_i2c_resources_##cid, \
  147. .dev = { \
  148. .platform_data = &u8500_i2c_##cid \
  149. } \
  150. }
  151. U8500_I2C_PDEVICE(0);
  152. U8500_I2C_PDEVICE(1);
  153. U8500_I2C_PDEVICE(2);
  154. U8500_I2C_PDEVICE(3);
  155. static struct amba_device *amba_devs[] __initdata = {
  156. &uart0_device,
  157. &uart1_device,
  158. &uart2_device,
  159. &pl022_device,
  160. };
  161. /* add any platform devices here - TODO */
  162. static struct platform_device *platform_devs[] __initdata = {
  163. &i2c_controller0,
  164. &i2c_controller1,
  165. &i2c_controller2,
  166. &i2c_controller3,
  167. };
  168. static void __init u8500_init_machine(void)
  169. {
  170. int i;
  171. /* Register the active AMBA devices on this board */
  172. for (i = 0; i < ARRAY_SIZE(amba_devs); i++)
  173. amba_device_register(amba_devs[i], &iomem_resource);
  174. platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
  175. spi_register_board_info(u8500_spi_devices,
  176. ARRAY_SIZE(u8500_spi_devices));
  177. u8500_init_devices();
  178. }
  179. MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
  180. /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
  181. .phys_io = U8500_UART2_BASE,
  182. .io_pg_offst = (IO_ADDRESS(U8500_UART2_BASE) >> 18) & 0xfffc,
  183. .boot_params = 0x100,
  184. .map_io = u8500_map_io,
  185. .init_irq = ux500_init_irq,
  186. /* we re-use nomadik timer here */
  187. .timer = &u8500_timer,
  188. .init_machine = u8500_init_machine,
  189. MACHINE_END