board-mop500.c 5.1 KB

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