board-mop500.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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/gpio.h>
  17. #include <linux/amba/bus.h>
  18. #include <linux/amba/pl022.h>
  19. #include <linux/spi/spi.h>
  20. #include <linux/mfd/ab8500.h>
  21. #include <asm/mach-types.h>
  22. #include <asm/mach/arch.h>
  23. #include <plat/pincfg.h>
  24. #include <plat/i2c.h>
  25. #include <mach/hardware.h>
  26. #include <mach/setup.h>
  27. #include <mach/devices.h>
  28. #include <mach/irqs.h>
  29. #include "pins-db8500.h"
  30. #include "board-mop500.h"
  31. static pin_cfg_t mop500_pins[] = {
  32. /* SSP0 */
  33. GPIO143_SSP0_CLK,
  34. GPIO144_SSP0_FRM,
  35. GPIO145_SSP0_RXD,
  36. GPIO146_SSP0_TXD,
  37. /* I2C */
  38. GPIO147_I2C0_SCL,
  39. GPIO148_I2C0_SDA,
  40. GPIO16_I2C1_SCL,
  41. GPIO17_I2C1_SDA,
  42. GPIO10_I2C2_SDA,
  43. GPIO11_I2C2_SCL,
  44. GPIO229_I2C3_SDA,
  45. GPIO230_I2C3_SCL,
  46. };
  47. static void ab4500_spi_cs_control(u32 command)
  48. {
  49. /* set the FRM signal, which is CS - TODO */
  50. }
  51. struct pl022_config_chip ab4500_chip_info = {
  52. .lbm = LOOPBACK_DISABLED,
  53. .com_mode = INTERRUPT_TRANSFER,
  54. .iface = SSP_INTERFACE_MOTOROLA_SPI,
  55. /* we can act as master only */
  56. .hierarchy = SSP_MASTER,
  57. .slave_tx_disable = 0,
  58. .endian_rx = SSP_RX_MSB,
  59. .endian_tx = SSP_TX_MSB,
  60. .data_size = SSP_DATA_BITS_24,
  61. .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM,
  62. .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC,
  63. .clk_phase = SSP_CLK_SECOND_EDGE,
  64. .clk_pol = SSP_CLK_POL_IDLE_HIGH,
  65. .cs_control = ab4500_spi_cs_control,
  66. };
  67. static struct ab8500_platform_data ab8500_platdata = {
  68. .irq_base = MOP500_AB8500_IRQ_BASE,
  69. };
  70. static struct resource ab8500_resources[] = {
  71. [0] = {
  72. .start = IRQ_AB8500,
  73. .end = IRQ_AB8500,
  74. .flags = IORESOURCE_IRQ
  75. }
  76. };
  77. struct platform_device ab8500_device = {
  78. .name = "ab8500-i2c",
  79. .id = 0,
  80. .dev = {
  81. .platform_data = &ab8500_platdata,
  82. },
  83. .num_resources = 1,
  84. .resource = ab8500_resources,
  85. };
  86. static struct spi_board_info ab8500_spi_devices[] = {
  87. {
  88. .modalias = "ab8500-spi",
  89. .controller_data = &ab4500_chip_info,
  90. .platform_data = &ab8500_platdata,
  91. .max_speed_hz = 12000000,
  92. .bus_num = 0,
  93. .chip_select = 0,
  94. .mode = SPI_MODE_0,
  95. .irq = IRQ_DB8500_AB8500,
  96. },
  97. };
  98. static struct pl022_ssp_controller ssp0_platform_data = {
  99. .bus_id = 0,
  100. /* pl022 not yet supports dma */
  101. .enable_dma = 0,
  102. /* on this platform, gpio 31,142,144,214 &
  103. * 224 are connected as chip selects
  104. */
  105. .num_chipselect = 5,
  106. };
  107. #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
  108. static struct nmk_i2c_controller u8500_i2c##id##_data = { \
  109. /* \
  110. * slave data setup time, which is \
  111. * 250 ns,100ns,10ns which is 14,6,2 \
  112. * respectively for a 48 Mhz \
  113. * i2c clock \
  114. */ \
  115. .slsu = _slsu, \
  116. /* Tx FIFO threshold */ \
  117. .tft = _tft, \
  118. /* Rx FIFO threshold */ \
  119. .rft = _rft, \
  120. /* std. mode operation */ \
  121. .clk_freq = clk, \
  122. .sm = _sm, \
  123. }
  124. /*
  125. * The board uses 4 i2c controllers, initialize all of
  126. * them with slave data setup time of 250 ns,
  127. * Tx & Rx FIFO threshold values as 1 and standard
  128. * mode of operation
  129. */
  130. U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  131. U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  132. U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  133. U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  134. static struct amba_device *amba_devs[] __initdata = {
  135. &ux500_uart0_device,
  136. &ux500_uart1_device,
  137. &ux500_uart2_device,
  138. &u8500_ssp0_device,
  139. };
  140. /* add any platform devices here - TODO */
  141. static struct platform_device *platform_devs[] __initdata = {
  142. &u8500_i2c0_device,
  143. &ux500_i2c1_device,
  144. &ux500_i2c2_device,
  145. &ux500_i2c3_device,
  146. };
  147. static void __init u8500_init_machine(void)
  148. {
  149. int i;
  150. u8500_init_devices();
  151. nmk_config_pins(mop500_pins, ARRAY_SIZE(mop500_pins));
  152. u8500_i2c0_device.dev.platform_data = &u8500_i2c0_data;
  153. ux500_i2c1_device.dev.platform_data = &u8500_i2c1_data;
  154. ux500_i2c2_device.dev.platform_data = &u8500_i2c2_data;
  155. ux500_i2c3_device.dev.platform_data = &u8500_i2c3_data;
  156. u8500_ssp0_device.dev.platform_data = &ssp0_platform_data;
  157. /* Register the active AMBA devices on this board */
  158. for (i = 0; i < ARRAY_SIZE(amba_devs); i++)
  159. amba_device_register(amba_devs[i], &iomem_resource);
  160. platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
  161. mop500_sdi_init();
  162. /* If HW is early drop (ED) or V1.0 then use SPI to access AB8500 */
  163. if (cpu_is_u8500ed() || cpu_is_u8500v10())
  164. spi_register_board_info(ab8500_spi_devices,
  165. ARRAY_SIZE(ab8500_spi_devices));
  166. else /* If HW is v.1.1 or later use I2C to access AB8500 */
  167. platform_device_register(&ab8500_device);
  168. }
  169. MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
  170. /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
  171. .phys_io = U8500_UART2_BASE,
  172. .io_pg_offst = (IO_ADDRESS(U8500_UART2_BASE) >> 18) & 0xfffc,
  173. .boot_params = 0x100,
  174. .map_io = u8500_map_io,
  175. .init_irq = ux500_init_irq,
  176. /* we re-use nomadik timer here */
  177. .timer = &ux500_timer,
  178. .init_machine = u8500_init_machine,
  179. MACHINE_END