board-mop500.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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. .block = TC3589x_BLOCK_GPIO,
  110. .gpio = &mop500_tc35892_gpio_data,
  111. .irq_base = MOP500_EGPIO_IRQ_BASE,
  112. };
  113. static struct i2c_board_info mop500_i2c0_devices[] = {
  114. {
  115. I2C_BOARD_INFO("tc3589x", 0x42),
  116. .irq = NOMADIK_GPIO_TO_IRQ(217),
  117. .platform_data = &mop500_tc35892_data,
  118. },
  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 void __init mop500_i2c_init(void)
  148. {
  149. db8500_add_i2c0(&u8500_i2c0_data);
  150. db8500_add_i2c1(&u8500_i2c1_data);
  151. db8500_add_i2c2(&u8500_i2c2_data);
  152. db8500_add_i2c3(&u8500_i2c3_data);
  153. }
  154. static const unsigned int ux500_keymap[] = {
  155. KEY(2, 5, KEY_END),
  156. KEY(4, 1, KEY_POWER),
  157. KEY(3, 5, KEY_VOLUMEDOWN),
  158. KEY(1, 3, KEY_3),
  159. KEY(5, 2, KEY_RIGHT),
  160. KEY(5, 0, KEY_9),
  161. KEY(0, 5, KEY_MENU),
  162. KEY(7, 6, KEY_ENTER),
  163. KEY(4, 5, KEY_0),
  164. KEY(6, 7, KEY_2),
  165. KEY(3, 4, KEY_UP),
  166. KEY(3, 3, KEY_DOWN),
  167. KEY(6, 4, KEY_SEND),
  168. KEY(6, 2, KEY_BACK),
  169. KEY(4, 2, KEY_VOLUMEUP),
  170. KEY(5, 5, KEY_1),
  171. KEY(4, 3, KEY_LEFT),
  172. KEY(3, 2, KEY_7),
  173. };
  174. static const struct matrix_keymap_data ux500_keymap_data = {
  175. .keymap = ux500_keymap,
  176. .keymap_size = ARRAY_SIZE(ux500_keymap),
  177. };
  178. /*
  179. * Nomadik SKE keypad
  180. */
  181. #define ROW_PIN_I0 164
  182. #define ROW_PIN_I1 163
  183. #define ROW_PIN_I2 162
  184. #define ROW_PIN_I3 161
  185. #define ROW_PIN_I4 156
  186. #define ROW_PIN_I5 155
  187. #define ROW_PIN_I6 154
  188. #define ROW_PIN_I7 153
  189. #define COL_PIN_O0 168
  190. #define COL_PIN_O1 167
  191. #define COL_PIN_O2 166
  192. #define COL_PIN_O3 165
  193. #define COL_PIN_O4 160
  194. #define COL_PIN_O5 159
  195. #define COL_PIN_O6 158
  196. #define COL_PIN_O7 157
  197. #define SKE_KPD_MAX_ROWS 8
  198. #define SKE_KPD_MAX_COLS 8
  199. static int ske_kp_rows[] = {
  200. ROW_PIN_I0, ROW_PIN_I1, ROW_PIN_I2, ROW_PIN_I3,
  201. ROW_PIN_I4, ROW_PIN_I5, ROW_PIN_I6, ROW_PIN_I7,
  202. };
  203. /*
  204. * ske_set_gpio_row: request and set gpio rows
  205. */
  206. static int ske_set_gpio_row(int gpio)
  207. {
  208. int ret;
  209. ret = gpio_request(gpio, "ske-kp");
  210. if (ret < 0) {
  211. pr_err("ske_set_gpio_row: gpio request failed\n");
  212. return ret;
  213. }
  214. ret = gpio_direction_output(gpio, 1);
  215. if (ret < 0) {
  216. pr_err("ske_set_gpio_row: gpio direction failed\n");
  217. gpio_free(gpio);
  218. }
  219. return ret;
  220. }
  221. /*
  222. * ske_kp_init - enable the gpio configuration
  223. */
  224. static int ske_kp_init(void)
  225. {
  226. int ret, i;
  227. for (i = 0; i < SKE_KPD_MAX_ROWS; i++) {
  228. ret = ske_set_gpio_row(ske_kp_rows[i]);
  229. if (ret < 0) {
  230. pr_err("ske_kp_init: failed init\n");
  231. return ret;
  232. }
  233. }
  234. return 0;
  235. }
  236. static struct ske_keypad_platform_data ske_keypad_board = {
  237. .init = ske_kp_init,
  238. .keymap_data = &ux500_keymap_data,
  239. .no_autorepeat = true,
  240. .krow = SKE_KPD_MAX_ROWS, /* 8x8 matrix */
  241. .kcol = SKE_KPD_MAX_COLS,
  242. .debounce_ms = 40, /* in millsecs */
  243. };
  244. /* add any platform devices here - TODO */
  245. static struct platform_device *platform_devs[] __initdata = {
  246. &ux500_ske_keypad_device,
  247. };
  248. static void __init mop500_spi_init(void)
  249. {
  250. db8500_add_ssp0(&ssp0_platform_data);
  251. }
  252. static void __init mop500_uart_init(void)
  253. {
  254. db8500_add_uart0();
  255. db8500_add_uart1();
  256. db8500_add_uart2();
  257. }
  258. static void __init u8500_init_machine(void)
  259. {
  260. u8500_init_devices();
  261. nmk_config_pins(mop500_pins, ARRAY_SIZE(mop500_pins));
  262. platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
  263. mop500_i2c_init();
  264. mop500_sdi_init();
  265. mop500_spi_init();
  266. mop500_uart_init();
  267. platform_device_register(&ab8500_device);
  268. i2c_register_board_info(0, mop500_i2c0_devices,
  269. ARRAY_SIZE(mop500_i2c0_devices));
  270. }
  271. MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
  272. /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
  273. .boot_params = 0x100,
  274. .map_io = u8500_map_io,
  275. .init_irq = ux500_init_irq,
  276. /* we re-use nomadik timer here */
  277. .timer = &ux500_timer,
  278. .init_machine = u8500_init_machine,
  279. MACHINE_END