board-mop500.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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 <linux/input/matrix_keypad.h>
  22. #include <asm/mach-types.h>
  23. #include <asm/mach/arch.h>
  24. #include <plat/pincfg.h>
  25. #include <plat/i2c.h>
  26. #include <plat/ske.h>
  27. #include <mach/hardware.h>
  28. #include <mach/setup.h>
  29. #include <mach/devices.h>
  30. #include "pins-db8500.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. /* SKE keypad */
  47. GPIO153_KP_I7,
  48. GPIO154_KP_I6,
  49. GPIO155_KP_I5,
  50. GPIO156_KP_I4,
  51. GPIO157_KP_O7,
  52. GPIO158_KP_O6,
  53. GPIO159_KP_O5,
  54. GPIO160_KP_O4,
  55. GPIO161_KP_I3,
  56. GPIO162_KP_I2,
  57. GPIO163_KP_I1,
  58. GPIO164_KP_I0,
  59. GPIO165_KP_O3,
  60. GPIO166_KP_O2,
  61. GPIO167_KP_O1,
  62. GPIO168_KP_O0,
  63. };
  64. static void ab4500_spi_cs_control(u32 command)
  65. {
  66. /* set the FRM signal, which is CS - TODO */
  67. }
  68. struct pl022_config_chip ab4500_chip_info = {
  69. .lbm = LOOPBACK_DISABLED,
  70. .com_mode = INTERRUPT_TRANSFER,
  71. .iface = SSP_INTERFACE_MOTOROLA_SPI,
  72. /* we can act as master only */
  73. .hierarchy = SSP_MASTER,
  74. .slave_tx_disable = 0,
  75. .endian_rx = SSP_RX_MSB,
  76. .endian_tx = SSP_TX_MSB,
  77. .data_size = SSP_DATA_BITS_24,
  78. .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM,
  79. .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC,
  80. .clk_phase = SSP_CLK_SECOND_EDGE,
  81. .clk_pol = SSP_CLK_POL_IDLE_HIGH,
  82. .cs_control = ab4500_spi_cs_control,
  83. };
  84. static struct ab8500_platform_data ab8500_platdata = {
  85. .irq_base = MOP500_AB8500_IRQ_BASE,
  86. };
  87. static struct spi_board_info u8500_spi_devices[] = {
  88. {
  89. .modalias = "ab8500",
  90. .controller_data = &ab4500_chip_info,
  91. .platform_data = &ab8500_platdata,
  92. .max_speed_hz = 12000000,
  93. .bus_num = 0,
  94. .chip_select = 0,
  95. .mode = SPI_MODE_0,
  96. .irq = IRQ_DB8500_AB8500,
  97. },
  98. };
  99. static struct pl022_ssp_controller ssp0_platform_data = {
  100. .bus_id = 0,
  101. /* pl022 not yet supports dma */
  102. .enable_dma = 0,
  103. /* on this platform, gpio 31,142,144,214 &
  104. * 224 are connected as chip selects
  105. */
  106. .num_chipselect = 5,
  107. };
  108. #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
  109. static struct nmk_i2c_controller u8500_i2c##id##_data = { \
  110. /* \
  111. * slave data setup time, which is \
  112. * 250 ns,100ns,10ns which is 14,6,2 \
  113. * respectively for a 48 Mhz \
  114. * i2c clock \
  115. */ \
  116. .slsu = _slsu, \
  117. /* Tx FIFO threshold */ \
  118. .tft = _tft, \
  119. /* Rx FIFO threshold */ \
  120. .rft = _rft, \
  121. /* std. mode operation */ \
  122. .clk_freq = clk, \
  123. .sm = _sm, \
  124. }
  125. /*
  126. * The board uses 4 i2c controllers, initialize all of
  127. * them with slave data setup time of 250 ns,
  128. * Tx & Rx FIFO threshold values as 1 and standard
  129. * mode of operation
  130. */
  131. U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  132. U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  133. U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  134. U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  135. static struct amba_device *amba_devs[] __initdata = {
  136. &ux500_uart0_device,
  137. &ux500_uart1_device,
  138. &ux500_uart2_device,
  139. &u8500_ssp0_device,
  140. };
  141. static const unsigned int ux500_keymap[] = {
  142. KEY(2, 5, KEY_END),
  143. KEY(4, 1, KEY_POWER),
  144. KEY(3, 5, KEY_VOLUMEDOWN),
  145. KEY(1, 3, KEY_3),
  146. KEY(5, 2, KEY_RIGHT),
  147. KEY(5, 0, KEY_9),
  148. KEY(0, 5, KEY_MENU),
  149. KEY(7, 6, KEY_ENTER),
  150. KEY(4, 5, KEY_0),
  151. KEY(6, 7, KEY_2),
  152. KEY(3, 4, KEY_UP),
  153. KEY(3, 3, KEY_DOWN),
  154. KEY(6, 4, KEY_SEND),
  155. KEY(6, 2, KEY_BACK),
  156. KEY(4, 2, KEY_VOLUMEUP),
  157. KEY(5, 5, KEY_1),
  158. KEY(4, 3, KEY_LEFT),
  159. KEY(3, 2, KEY_7),
  160. };
  161. static const struct matrix_keymap_data ux500_keymap_data = {
  162. .keymap = ux500_keymap,
  163. .keymap_size = ARRAY_SIZE(ux500_keymap),
  164. };
  165. /*
  166. * Nomadik SKE keypad
  167. */
  168. #define ROW_PIN_I0 164
  169. #define ROW_PIN_I1 163
  170. #define ROW_PIN_I2 162
  171. #define ROW_PIN_I3 161
  172. #define ROW_PIN_I4 156
  173. #define ROW_PIN_I5 155
  174. #define ROW_PIN_I6 154
  175. #define ROW_PIN_I7 153
  176. #define COL_PIN_O0 168
  177. #define COL_PIN_O1 167
  178. #define COL_PIN_O2 166
  179. #define COL_PIN_O3 165
  180. #define COL_PIN_O4 160
  181. #define COL_PIN_O5 159
  182. #define COL_PIN_O6 158
  183. #define COL_PIN_O7 157
  184. #define SKE_KPD_MAX_ROWS 8
  185. #define SKE_KPD_MAX_COLS 8
  186. static int ske_kp_rows[] = {
  187. ROW_PIN_I0, ROW_PIN_I1, ROW_PIN_I2, ROW_PIN_I3,
  188. ROW_PIN_I4, ROW_PIN_I5, ROW_PIN_I6, ROW_PIN_I7,
  189. };
  190. /*
  191. * ske_set_gpio_row: request and set gpio rows
  192. */
  193. static int ske_set_gpio_row(int gpio)
  194. {
  195. int ret;
  196. ret = gpio_request(gpio, "ske-kp");
  197. if (ret < 0) {
  198. pr_err("ske_set_gpio_row: gpio request failed\n");
  199. return ret;
  200. }
  201. ret = gpio_direction_output(gpio, 1);
  202. if (ret < 0) {
  203. pr_err("ske_set_gpio_row: gpio direction failed\n");
  204. gpio_free(gpio);
  205. }
  206. return ret;
  207. }
  208. /*
  209. * ske_kp_init - enable the gpio configuration
  210. */
  211. static int ske_kp_init(void)
  212. {
  213. int ret, i;
  214. for (i = 0; i < SKE_KPD_MAX_ROWS; i++) {
  215. ret = ske_set_gpio_row(ske_kp_rows[i]);
  216. if (ret < 0) {
  217. pr_err("ske_kp_init: failed init\n");
  218. return ret;
  219. }
  220. }
  221. return 0;
  222. }
  223. static struct ske_keypad_platform_data ske_keypad_board = {
  224. .init = ske_kp_init,
  225. .keymap_data = &ux500_keymap_data,
  226. .no_autorepeat = true,
  227. .krow = SKE_KPD_MAX_ROWS, /* 8x8 matrix */
  228. .kcol = SKE_KPD_MAX_COLS,
  229. .debounce_ms = 40, /* in millsecs */
  230. };
  231. /* add any platform devices here - TODO */
  232. static struct platform_device *platform_devs[] __initdata = {
  233. &u8500_i2c0_device,
  234. &ux500_i2c1_device,
  235. &ux500_i2c2_device,
  236. &ux500_i2c3_device,
  237. &ux500_ske_keypad_device,
  238. };
  239. static void __init u8500_init_machine(void)
  240. {
  241. int i;
  242. u8500_init_devices();
  243. nmk_config_pins(mop500_pins, ARRAY_SIZE(mop500_pins));
  244. u8500_i2c0_device.dev.platform_data = &u8500_i2c0_data;
  245. ux500_i2c1_device.dev.platform_data = &u8500_i2c1_data;
  246. ux500_i2c2_device.dev.platform_data = &u8500_i2c2_data;
  247. ux500_i2c3_device.dev.platform_data = &u8500_i2c3_data;
  248. ux500_ske_keypad_device.dev.platform_data = &ske_keypad_board;
  249. u8500_ssp0_device.dev.platform_data = &ssp0_platform_data;
  250. /* Register the active AMBA devices on this board */
  251. for (i = 0; i < ARRAY_SIZE(amba_devs); i++)
  252. amba_device_register(amba_devs[i], &iomem_resource);
  253. platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
  254. spi_register_board_info(u8500_spi_devices,
  255. ARRAY_SIZE(u8500_spi_devices));
  256. }
  257. MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
  258. /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
  259. .phys_io = U8500_UART2_BASE,
  260. .io_pg_offst = (IO_ADDRESS(U8500_UART2_BASE) >> 18) & 0xfffc,
  261. .boot_params = 0x100,
  262. .map_io = u8500_map_io,
  263. .init_irq = ux500_init_irq,
  264. /* we re-use nomadik timer here */
  265. .timer = &ux500_timer,
  266. .init_machine = u8500_init_machine,
  267. MACHINE_END