board-mop500.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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/i2c.h>
  17. #include <linux/gpio.h>
  18. #include <linux/amba/bus.h>
  19. #include <linux/amba/pl022.h>
  20. #include <linux/spi/spi.h>
  21. #include <linux/mfd/ab8500.h>
  22. #include <linux/mfd/tc3589x.h>
  23. #include <asm/mach-types.h>
  24. #include <asm/mach/arch.h>
  25. #include <plat/pincfg.h>
  26. #include <plat/i2c.h>
  27. #include <plat/ske.h>
  28. #include <mach/hardware.h>
  29. #include <mach/setup.h>
  30. #include <mach/devices.h>
  31. #include <mach/irqs.h>
  32. #include "devices-db8500.h"
  33. #include "pins-db8500.h"
  34. #include "board-mop500.h"
  35. static pin_cfg_t mop500_pins[] = {
  36. /* SSP0 */
  37. GPIO143_SSP0_CLK,
  38. GPIO144_SSP0_FRM,
  39. GPIO145_SSP0_RXD,
  40. GPIO146_SSP0_TXD,
  41. /* I2C */
  42. GPIO147_I2C0_SCL,
  43. GPIO148_I2C0_SDA,
  44. GPIO16_I2C1_SCL,
  45. GPIO17_I2C1_SDA,
  46. GPIO10_I2C2_SDA,
  47. GPIO11_I2C2_SCL,
  48. GPIO229_I2C3_SDA,
  49. GPIO230_I2C3_SCL,
  50. /* SKE keypad */
  51. GPIO153_KP_I7,
  52. GPIO154_KP_I6,
  53. GPIO155_KP_I5,
  54. GPIO156_KP_I4,
  55. GPIO157_KP_O7,
  56. GPIO158_KP_O6,
  57. GPIO159_KP_O5,
  58. GPIO160_KP_O4,
  59. GPIO161_KP_I3,
  60. GPIO162_KP_I2,
  61. GPIO163_KP_I1,
  62. GPIO164_KP_I0,
  63. GPIO165_KP_O3,
  64. GPIO166_KP_O2,
  65. GPIO167_KP_O1,
  66. GPIO168_KP_O0,
  67. GPIO217_GPIO, /* GPIO_EXP_INT */
  68. };
  69. static struct ab8500_platform_data ab8500_platdata = {
  70. .irq_base = MOP500_AB8500_IRQ_BASE,
  71. };
  72. static struct resource ab8500_resources[] = {
  73. [0] = {
  74. .start = IRQ_DB8500_AB8500,
  75. .end = IRQ_DB8500_AB8500,
  76. .flags = IORESOURCE_IRQ
  77. }
  78. };
  79. struct platform_device ab8500_device = {
  80. .name = "ab8500-i2c",
  81. .id = 0,
  82. .dev = {
  83. .platform_data = &ab8500_platdata,
  84. },
  85. .num_resources = 1,
  86. .resource = ab8500_resources,
  87. };
  88. static struct pl022_ssp_controller ssp0_platform_data = {
  89. .bus_id = 0,
  90. /* pl022 not yet supports dma */
  91. .enable_dma = 0,
  92. /* on this platform, gpio 31,142,144,214 &
  93. * 224 are connected as chip selects
  94. */
  95. .num_chipselect = 5,
  96. };
  97. /*
  98. * TC35892
  99. */
  100. static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
  101. {
  102. mop500_sdi_tc35892_init();
  103. }
  104. static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
  105. .gpio_base = MOP500_EGPIO(0),
  106. .setup = mop500_tc35892_init,
  107. };
  108. static struct tc3589x_platform_data mop500_tc35892_data = {
  109. .gpio = &mop500_tc35892_gpio_data,
  110. .irq_base = MOP500_EGPIO_IRQ_BASE,
  111. };
  112. static struct i2c_board_info mop500_i2c0_devices[] = {
  113. {
  114. I2C_BOARD_INFO("tc3589x", 0x42),
  115. .irq = NOMADIK_GPIO_TO_IRQ(217),
  116. .platform_data = &mop500_tc35892_data,
  117. },
  118. };
  119. #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
  120. static struct nmk_i2c_controller u8500_i2c##id##_data = { \
  121. /* \
  122. * slave data setup time, which is \
  123. * 250 ns,100ns,10ns which is 14,6,2 \
  124. * respectively for a 48 Mhz \
  125. * i2c clock \
  126. */ \
  127. .slsu = _slsu, \
  128. /* Tx FIFO threshold */ \
  129. .tft = _tft, \
  130. /* Rx FIFO threshold */ \
  131. .rft = _rft, \
  132. /* std. mode operation */ \
  133. .clk_freq = clk, \
  134. .sm = _sm, \
  135. }
  136. /*
  137. * The board uses 4 i2c controllers, initialize all of
  138. * them with slave data setup time of 250 ns,
  139. * Tx & Rx FIFO threshold values as 1 and standard
  140. * mode of operation
  141. */
  142. U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  143. U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  144. U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  145. U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  146. static void __init mop500_i2c_init(void)
  147. {
  148. db8500_add_i2c0(&u8500_i2c0_data);
  149. db8500_add_i2c1(&u8500_i2c1_data);
  150. db8500_add_i2c2(&u8500_i2c2_data);
  151. db8500_add_i2c3(&u8500_i2c3_data);
  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. &ux500_ske_keypad_device,
  246. };
  247. static void __init mop500_spi_init(void)
  248. {
  249. db8500_add_ssp0(&ssp0_platform_data);
  250. }
  251. static void __init mop500_uart_init(void)
  252. {
  253. db8500_add_uart0();
  254. db8500_add_uart1();
  255. db8500_add_uart2();
  256. }
  257. static void __init u8500_init_machine(void)
  258. {
  259. u8500_init_devices();
  260. nmk_config_pins(mop500_pins, ARRAY_SIZE(mop500_pins));
  261. platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
  262. mop500_i2c_init();
  263. mop500_sdi_init();
  264. mop500_spi_init();
  265. mop500_uart_init();
  266. platform_device_register(&ab8500_device);
  267. i2c_register_board_info(0, mop500_i2c0_devices,
  268. ARRAY_SIZE(mop500_i2c0_devices));
  269. }
  270. MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
  271. /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
  272. .boot_params = 0x100,
  273. .map_io = u8500_map_io,
  274. .init_irq = ux500_init_irq,
  275. /* we re-use nomadik timer here */
  276. .timer = &ux500_timer,
  277. .init_machine = u8500_init_machine,
  278. MACHINE_END