board-mop500.c 7.5 KB

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