board-mop500.c 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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 <linux/leds-lp5521.h>
  24. #include <linux/input.h>
  25. #include <linux/gpio_keys.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/mach/arch.h>
  28. #include <plat/pincfg.h>
  29. #include <plat/i2c.h>
  30. #include <mach/hardware.h>
  31. #include <mach/setup.h>
  32. #include <mach/devices.h>
  33. #include <mach/irqs.h>
  34. #include "devices-db8500.h"
  35. #include "pins-db8500.h"
  36. #include "board-mop500.h"
  37. #include "board-mop500-regulators.h"
  38. static pin_cfg_t mop500_pins[] = {
  39. /* SSP0 */
  40. GPIO143_SSP0_CLK,
  41. GPIO144_SSP0_FRM,
  42. GPIO145_SSP0_RXD,
  43. GPIO146_SSP0_TXD,
  44. /* I2C */
  45. GPIO147_I2C0_SCL,
  46. GPIO148_I2C0_SDA,
  47. GPIO16_I2C1_SCL,
  48. GPIO17_I2C1_SDA,
  49. GPIO10_I2C2_SDA,
  50. GPIO11_I2C2_SCL,
  51. GPIO229_I2C3_SDA,
  52. GPIO230_I2C3_SCL,
  53. /* SKE keypad */
  54. GPIO153_KP_I7,
  55. GPIO154_KP_I6,
  56. GPIO155_KP_I5,
  57. GPIO156_KP_I4,
  58. GPIO157_KP_O7,
  59. GPIO158_KP_O6,
  60. GPIO159_KP_O5,
  61. GPIO160_KP_O4,
  62. GPIO161_KP_I3,
  63. GPIO162_KP_I2,
  64. GPIO163_KP_I1,
  65. GPIO164_KP_I0,
  66. GPIO165_KP_O3,
  67. GPIO166_KP_O2,
  68. GPIO167_KP_O1,
  69. GPIO168_KP_O0,
  70. /* GPIO_EXP_INT */
  71. GPIO217_GPIO,
  72. /* STMPE1601 IRQ */
  73. GPIO218_GPIO | PIN_INPUT_PULLUP,
  74. /* touch screen */
  75. GPIO84_GPIO | PIN_INPUT_PULLUP,
  76. };
  77. static struct ab8500_platform_data ab8500_platdata = {
  78. .irq_base = MOP500_AB8500_IRQ_BASE,
  79. .regulator = ab8500_regulators,
  80. .num_regulator = ARRAY_SIZE(ab8500_regulators),
  81. };
  82. static struct resource ab8500_resources[] = {
  83. [0] = {
  84. .start = IRQ_DB8500_AB8500,
  85. .end = IRQ_DB8500_AB8500,
  86. .flags = IORESOURCE_IRQ
  87. }
  88. };
  89. struct platform_device ab8500_device = {
  90. .name = "ab8500-i2c",
  91. .id = 0,
  92. .dev = {
  93. .platform_data = &ab8500_platdata,
  94. },
  95. .num_resources = 1,
  96. .resource = ab8500_resources,
  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. /*
  108. * TC35892
  109. */
  110. static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
  111. {
  112. mop500_sdi_tc35892_init();
  113. }
  114. static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
  115. .gpio_base = MOP500_EGPIO(0),
  116. .setup = mop500_tc35892_init,
  117. };
  118. static struct tc3589x_platform_data mop500_tc35892_data = {
  119. .block = TC3589x_BLOCK_GPIO,
  120. .gpio = &mop500_tc35892_gpio_data,
  121. .irq_base = MOP500_EGPIO_IRQ_BASE,
  122. };
  123. static struct lp5521_led_config lp5521_pri_led[] = {
  124. [0] = {
  125. .chan_nr = 0,
  126. .led_current = 0x2f,
  127. .max_current = 0x5f,
  128. },
  129. [1] = {
  130. .chan_nr = 1,
  131. .led_current = 0x2f,
  132. .max_current = 0x5f,
  133. },
  134. [2] = {
  135. .chan_nr = 2,
  136. .led_current = 0x2f,
  137. .max_current = 0x5f,
  138. },
  139. };
  140. static struct lp5521_platform_data __initdata lp5521_pri_data = {
  141. .label = "lp5521_pri",
  142. .led_config = &lp5521_pri_led[0],
  143. .num_channels = 3,
  144. .clock_mode = LP5521_CLOCK_EXT,
  145. };
  146. static struct lp5521_led_config lp5521_sec_led[] = {
  147. [0] = {
  148. .chan_nr = 0,
  149. .led_current = 0x2f,
  150. .max_current = 0x5f,
  151. },
  152. [1] = {
  153. .chan_nr = 1,
  154. .led_current = 0x2f,
  155. .max_current = 0x5f,
  156. },
  157. [2] = {
  158. .chan_nr = 2,
  159. .led_current = 0x2f,
  160. .max_current = 0x5f,
  161. },
  162. };
  163. static struct lp5521_platform_data __initdata lp5521_sec_data = {
  164. .label = "lp5521_sec",
  165. .led_config = &lp5521_sec_led[0],
  166. .num_channels = 3,
  167. .clock_mode = LP5521_CLOCK_EXT,
  168. };
  169. static struct i2c_board_info mop500_i2c0_devices[] = {
  170. {
  171. I2C_BOARD_INFO("tc3589x", 0x42),
  172. .irq = NOMADIK_GPIO_TO_IRQ(217),
  173. .platform_data = &mop500_tc35892_data,
  174. },
  175. };
  176. static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
  177. {
  178. /* lp5521 LED driver, 1st device */
  179. I2C_BOARD_INFO("lp5521", 0x33),
  180. .platform_data = &lp5521_pri_data,
  181. },
  182. {
  183. /* lp5521 LED driver, 2st device */
  184. I2C_BOARD_INFO("lp5521", 0x34),
  185. .platform_data = &lp5521_sec_data,
  186. },
  187. {
  188. /* Light sensor Rohm BH1780GLI */
  189. I2C_BOARD_INFO("bh1780", 0x29),
  190. },
  191. };
  192. #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
  193. static struct nmk_i2c_controller u8500_i2c##id##_data = { \
  194. /* \
  195. * slave data setup time, which is \
  196. * 250 ns,100ns,10ns which is 14,6,2 \
  197. * respectively for a 48 Mhz \
  198. * i2c clock \
  199. */ \
  200. .slsu = _slsu, \
  201. /* Tx FIFO threshold */ \
  202. .tft = _tft, \
  203. /* Rx FIFO threshold */ \
  204. .rft = _rft, \
  205. /* std. mode operation */ \
  206. .clk_freq = clk, \
  207. .sm = _sm, \
  208. }
  209. /*
  210. * The board uses 4 i2c controllers, initialize all of
  211. * them with slave data setup time of 250 ns,
  212. * Tx & Rx FIFO threshold values as 1 and standard
  213. * mode of operation
  214. */
  215. U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  216. U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  217. U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  218. U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  219. static void __init mop500_i2c_init(void)
  220. {
  221. db8500_add_i2c0(&u8500_i2c0_data);
  222. db8500_add_i2c1(&u8500_i2c1_data);
  223. db8500_add_i2c2(&u8500_i2c2_data);
  224. db8500_add_i2c3(&u8500_i2c3_data);
  225. }
  226. static struct gpio_keys_button mop500_gpio_keys[] = {
  227. {
  228. .desc = "SFH7741 Proximity Sensor",
  229. .type = EV_SW,
  230. .code = SW_FRONT_PROXIMITY,
  231. .gpio = GPIO_PROX_SENSOR,
  232. .active_low = 0,
  233. .can_disable = 1,
  234. }
  235. };
  236. static struct regulator *prox_regulator;
  237. static int mop500_prox_activate(struct device *dev);
  238. static void mop500_prox_deactivate(struct device *dev);
  239. static struct gpio_keys_platform_data mop500_gpio_keys_data = {
  240. .buttons = mop500_gpio_keys,
  241. .nbuttons = ARRAY_SIZE(mop500_gpio_keys),
  242. .enable = mop500_prox_activate,
  243. .disable = mop500_prox_deactivate,
  244. };
  245. static struct platform_device mop500_gpio_keys_device = {
  246. .name = "gpio-keys",
  247. .id = 0,
  248. .dev = {
  249. .platform_data = &mop500_gpio_keys_data,
  250. },
  251. };
  252. static int mop500_prox_activate(struct device *dev)
  253. {
  254. prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
  255. "vcc");
  256. if (IS_ERR(prox_regulator)) {
  257. dev_err(&mop500_gpio_keys_device.dev,
  258. "no regulator\n");
  259. return PTR_ERR(prox_regulator);
  260. }
  261. regulator_enable(prox_regulator);
  262. return 0;
  263. }
  264. static void mop500_prox_deactivate(struct device *dev)
  265. {
  266. regulator_disable(prox_regulator);
  267. regulator_put(prox_regulator);
  268. }
  269. /* add any platform devices here - TODO */
  270. static struct platform_device *platform_devs[] __initdata = {
  271. &mop500_gpio_keys_device,
  272. };
  273. static void __init mop500_spi_init(void)
  274. {
  275. db8500_add_ssp0(&ssp0_platform_data);
  276. }
  277. static void __init mop500_uart_init(void)
  278. {
  279. db8500_add_uart0();
  280. db8500_add_uart1();
  281. db8500_add_uart2();
  282. }
  283. static void __init u8500_init_machine(void)
  284. {
  285. u8500_init_devices();
  286. nmk_config_pins(mop500_pins, ARRAY_SIZE(mop500_pins));
  287. platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
  288. mop500_i2c_init();
  289. mop500_sdi_init();
  290. mop500_spi_init();
  291. mop500_uart_init();
  292. platform_device_register(&ab8500_device);
  293. i2c_register_board_info(0, mop500_i2c0_devices,
  294. ARRAY_SIZE(mop500_i2c0_devices));
  295. i2c_register_board_info(2, mop500_i2c2_devices,
  296. ARRAY_SIZE(mop500_i2c2_devices));
  297. }
  298. MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
  299. /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
  300. .boot_params = 0x100,
  301. .map_io = u8500_map_io,
  302. .init_irq = ux500_init_irq,
  303. /* we re-use nomadik timer here */
  304. .timer = &ux500_timer,
  305. .init_machine = u8500_init_machine,
  306. MACHINE_END