board-mop500.c 6.3 KB

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