board-mop500.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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/amba/serial.h>
  21. #include <linux/spi/spi.h>
  22. #include <linux/mfd/ab8500.h>
  23. #include <linux/mfd/tc3589x.h>
  24. #include <linux/leds-lp5521.h>
  25. #include <linux/input.h>
  26. #include <linux/gpio_keys.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/mach/arch.h>
  29. #include <plat/pincfg.h>
  30. #include <plat/i2c.h>
  31. #include <plat/ste_dma40.h>
  32. #include <mach/hardware.h>
  33. #include <mach/setup.h>
  34. #include <mach/devices.h>
  35. #include <mach/irqs.h>
  36. #include "ste-dma40-db8500.h"
  37. #include "devices-db8500.h"
  38. #include "pins-db8500.h"
  39. #include "board-mop500.h"
  40. #include "board-mop500-regulators.h"
  41. static pin_cfg_t mop500_pins[] = {
  42. /* SSP0 */
  43. GPIO143_SSP0_CLK,
  44. GPIO144_SSP0_FRM,
  45. GPIO145_SSP0_RXD,
  46. GPIO146_SSP0_TXD,
  47. /* I2C */
  48. GPIO147_I2C0_SCL,
  49. GPIO148_I2C0_SDA,
  50. GPIO16_I2C1_SCL,
  51. GPIO17_I2C1_SDA,
  52. GPIO10_I2C2_SDA,
  53. GPIO11_I2C2_SCL,
  54. GPIO229_I2C3_SDA,
  55. GPIO230_I2C3_SCL,
  56. /* SKE keypad */
  57. GPIO153_KP_I7,
  58. GPIO154_KP_I6,
  59. GPIO155_KP_I5,
  60. GPIO156_KP_I4,
  61. GPIO157_KP_O7,
  62. GPIO158_KP_O6,
  63. GPIO159_KP_O5,
  64. GPIO160_KP_O4,
  65. GPIO161_KP_I3,
  66. GPIO162_KP_I2,
  67. GPIO163_KP_I1,
  68. GPIO164_KP_I0,
  69. GPIO165_KP_O3,
  70. GPIO166_KP_O2,
  71. GPIO167_KP_O1,
  72. GPIO168_KP_O0,
  73. /* GPIO_EXP_INT */
  74. GPIO217_GPIO,
  75. /* STMPE1601 IRQ */
  76. GPIO218_GPIO | PIN_INPUT_PULLUP,
  77. /* touch screen */
  78. GPIO84_GPIO | PIN_INPUT_PULLUP,
  79. /* USB OTG */
  80. GPIO256_USB_NXT | PIN_PULL_DOWN,
  81. GPIO257_USB_STP | PIN_PULL_UP,
  82. GPIO258_USB_XCLK | PIN_PULL_DOWN,
  83. GPIO259_USB_DIR | PIN_PULL_DOWN,
  84. GPIO260_USB_DAT7 | PIN_PULL_DOWN,
  85. GPIO261_USB_DAT6 | PIN_PULL_DOWN,
  86. GPIO262_USB_DAT5 | PIN_PULL_DOWN,
  87. GPIO263_USB_DAT4 | PIN_PULL_DOWN,
  88. GPIO264_USB_DAT3 | PIN_PULL_DOWN,
  89. GPIO265_USB_DAT2 | PIN_PULL_DOWN,
  90. GPIO266_USB_DAT1 | PIN_PULL_DOWN,
  91. GPIO267_USB_DAT0 | PIN_PULL_DOWN,
  92. };
  93. static struct ab8500_platform_data ab8500_platdata = {
  94. .irq_base = MOP500_AB8500_IRQ_BASE,
  95. .regulator = ab8500_regulators,
  96. .num_regulator = ARRAY_SIZE(ab8500_regulators),
  97. };
  98. static struct resource ab8500_resources[] = {
  99. [0] = {
  100. .start = IRQ_DB8500_AB8500,
  101. .end = IRQ_DB8500_AB8500,
  102. .flags = IORESOURCE_IRQ
  103. }
  104. };
  105. struct platform_device ab8500_device = {
  106. .name = "ab8500-i2c",
  107. .id = 0,
  108. .dev = {
  109. .platform_data = &ab8500_platdata,
  110. },
  111. .num_resources = 1,
  112. .resource = ab8500_resources,
  113. };
  114. /*
  115. * TC35892
  116. */
  117. static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
  118. {
  119. mop500_sdi_tc35892_init();
  120. }
  121. static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
  122. .gpio_base = MOP500_EGPIO(0),
  123. .setup = mop500_tc35892_init,
  124. };
  125. static struct tc3589x_platform_data mop500_tc35892_data = {
  126. .block = TC3589x_BLOCK_GPIO,
  127. .gpio = &mop500_tc35892_gpio_data,
  128. .irq_base = MOP500_EGPIO_IRQ_BASE,
  129. };
  130. static struct lp5521_led_config lp5521_pri_led[] = {
  131. [0] = {
  132. .chan_nr = 0,
  133. .led_current = 0x2f,
  134. .max_current = 0x5f,
  135. },
  136. [1] = {
  137. .chan_nr = 1,
  138. .led_current = 0x2f,
  139. .max_current = 0x5f,
  140. },
  141. [2] = {
  142. .chan_nr = 2,
  143. .led_current = 0x2f,
  144. .max_current = 0x5f,
  145. },
  146. };
  147. static struct lp5521_platform_data __initdata lp5521_pri_data = {
  148. .label = "lp5521_pri",
  149. .led_config = &lp5521_pri_led[0],
  150. .num_channels = 3,
  151. .clock_mode = LP5521_CLOCK_EXT,
  152. };
  153. static struct lp5521_led_config lp5521_sec_led[] = {
  154. [0] = {
  155. .chan_nr = 0,
  156. .led_current = 0x2f,
  157. .max_current = 0x5f,
  158. },
  159. [1] = {
  160. .chan_nr = 1,
  161. .led_current = 0x2f,
  162. .max_current = 0x5f,
  163. },
  164. [2] = {
  165. .chan_nr = 2,
  166. .led_current = 0x2f,
  167. .max_current = 0x5f,
  168. },
  169. };
  170. static struct lp5521_platform_data __initdata lp5521_sec_data = {
  171. .label = "lp5521_sec",
  172. .led_config = &lp5521_sec_led[0],
  173. .num_channels = 3,
  174. .clock_mode = LP5521_CLOCK_EXT,
  175. };
  176. static struct i2c_board_info mop500_i2c0_devices[] = {
  177. {
  178. I2C_BOARD_INFO("tc3589x", 0x42),
  179. .irq = NOMADIK_GPIO_TO_IRQ(217),
  180. .platform_data = &mop500_tc35892_data,
  181. },
  182. };
  183. static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
  184. {
  185. /* lp5521 LED driver, 1st device */
  186. I2C_BOARD_INFO("lp5521", 0x33),
  187. .platform_data = &lp5521_pri_data,
  188. },
  189. {
  190. /* lp5521 LED driver, 2st device */
  191. I2C_BOARD_INFO("lp5521", 0x34),
  192. .platform_data = &lp5521_sec_data,
  193. },
  194. {
  195. /* Light sensor Rohm BH1780GLI */
  196. I2C_BOARD_INFO("bh1780", 0x29),
  197. },
  198. };
  199. #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
  200. static struct nmk_i2c_controller u8500_i2c##id##_data = { \
  201. /* \
  202. * slave data setup time, which is \
  203. * 250 ns,100ns,10ns which is 14,6,2 \
  204. * respectively for a 48 Mhz \
  205. * i2c clock \
  206. */ \
  207. .slsu = _slsu, \
  208. /* Tx FIFO threshold */ \
  209. .tft = _tft, \
  210. /* Rx FIFO threshold */ \
  211. .rft = _rft, \
  212. /* std. mode operation */ \
  213. .clk_freq = clk, \
  214. .sm = _sm, \
  215. }
  216. /*
  217. * The board uses 4 i2c controllers, initialize all of
  218. * them with slave data setup time of 250 ns,
  219. * Tx & Rx FIFO threshold values as 1 and standard
  220. * mode of operation
  221. */
  222. U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  223. U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  224. U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  225. U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
  226. static void __init mop500_i2c_init(void)
  227. {
  228. db8500_add_i2c0(&u8500_i2c0_data);
  229. db8500_add_i2c1(&u8500_i2c1_data);
  230. db8500_add_i2c2(&u8500_i2c2_data);
  231. db8500_add_i2c3(&u8500_i2c3_data);
  232. }
  233. static struct gpio_keys_button mop500_gpio_keys[] = {
  234. {
  235. .desc = "SFH7741 Proximity Sensor",
  236. .type = EV_SW,
  237. .code = SW_FRONT_PROXIMITY,
  238. .gpio = GPIO_PROX_SENSOR,
  239. .active_low = 0,
  240. .can_disable = 1,
  241. }
  242. };
  243. static struct regulator *prox_regulator;
  244. static int mop500_prox_activate(struct device *dev);
  245. static void mop500_prox_deactivate(struct device *dev);
  246. static struct gpio_keys_platform_data mop500_gpio_keys_data = {
  247. .buttons = mop500_gpio_keys,
  248. .nbuttons = ARRAY_SIZE(mop500_gpio_keys),
  249. .enable = mop500_prox_activate,
  250. .disable = mop500_prox_deactivate,
  251. };
  252. static struct platform_device mop500_gpio_keys_device = {
  253. .name = "gpio-keys",
  254. .id = 0,
  255. .dev = {
  256. .platform_data = &mop500_gpio_keys_data,
  257. },
  258. };
  259. static int mop500_prox_activate(struct device *dev)
  260. {
  261. prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
  262. "vcc");
  263. if (IS_ERR(prox_regulator)) {
  264. dev_err(&mop500_gpio_keys_device.dev,
  265. "no regulator\n");
  266. return PTR_ERR(prox_regulator);
  267. }
  268. regulator_enable(prox_regulator);
  269. return 0;
  270. }
  271. static void mop500_prox_deactivate(struct device *dev)
  272. {
  273. regulator_disable(prox_regulator);
  274. regulator_put(prox_regulator);
  275. }
  276. /* add any platform devices here - TODO */
  277. static struct platform_device *platform_devs[] __initdata = {
  278. &mop500_gpio_keys_device,
  279. };
  280. #ifdef CONFIG_STE_DMA40
  281. static struct stedma40_chan_cfg ssp0_dma_cfg_rx = {
  282. .mode = STEDMA40_MODE_LOGICAL,
  283. .dir = STEDMA40_PERIPH_TO_MEM,
  284. .src_dev_type = DB8500_DMA_DEV8_SSP0_RX,
  285. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  286. .src_info.data_width = STEDMA40_BYTE_WIDTH,
  287. .dst_info.data_width = STEDMA40_BYTE_WIDTH,
  288. };
  289. static struct stedma40_chan_cfg ssp0_dma_cfg_tx = {
  290. .mode = STEDMA40_MODE_LOGICAL,
  291. .dir = STEDMA40_MEM_TO_PERIPH,
  292. .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
  293. .dst_dev_type = DB8500_DMA_DEV8_SSP0_TX,
  294. .src_info.data_width = STEDMA40_BYTE_WIDTH,
  295. .dst_info.data_width = STEDMA40_BYTE_WIDTH,
  296. };
  297. #endif
  298. static struct pl022_ssp_controller ssp0_platform_data = {
  299. .bus_id = 0,
  300. #ifdef CONFIG_STE_DMA40
  301. .enable_dma = 1,
  302. .dma_filter = stedma40_filter,
  303. .dma_rx_param = &ssp0_dma_cfg_rx,
  304. .dma_tx_param = &ssp0_dma_cfg_tx,
  305. #else
  306. .enable_dma = 0,
  307. #endif
  308. /* on this platform, gpio 31,142,144,214 &
  309. * 224 are connected as chip selects
  310. */
  311. .num_chipselect = 5,
  312. };
  313. static void __init mop500_spi_init(void)
  314. {
  315. db8500_add_ssp0(&ssp0_platform_data);
  316. }
  317. #ifdef CONFIG_STE_DMA40
  318. static struct stedma40_chan_cfg uart0_dma_cfg_rx = {
  319. .mode = STEDMA40_MODE_LOGICAL,
  320. .dir = STEDMA40_PERIPH_TO_MEM,
  321. .src_dev_type = DB8500_DMA_DEV13_UART0_RX,
  322. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  323. .src_info.data_width = STEDMA40_BYTE_WIDTH,
  324. .dst_info.data_width = STEDMA40_BYTE_WIDTH,
  325. };
  326. static struct stedma40_chan_cfg uart0_dma_cfg_tx = {
  327. .mode = STEDMA40_MODE_LOGICAL,
  328. .dir = STEDMA40_MEM_TO_PERIPH,
  329. .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
  330. .dst_dev_type = DB8500_DMA_DEV13_UART0_TX,
  331. .src_info.data_width = STEDMA40_BYTE_WIDTH,
  332. .dst_info.data_width = STEDMA40_BYTE_WIDTH,
  333. };
  334. static struct stedma40_chan_cfg uart1_dma_cfg_rx = {
  335. .mode = STEDMA40_MODE_LOGICAL,
  336. .dir = STEDMA40_PERIPH_TO_MEM,
  337. .src_dev_type = DB8500_DMA_DEV12_UART1_RX,
  338. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  339. .src_info.data_width = STEDMA40_BYTE_WIDTH,
  340. .dst_info.data_width = STEDMA40_BYTE_WIDTH,
  341. };
  342. static struct stedma40_chan_cfg uart1_dma_cfg_tx = {
  343. .mode = STEDMA40_MODE_LOGICAL,
  344. .dir = STEDMA40_MEM_TO_PERIPH,
  345. .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
  346. .dst_dev_type = DB8500_DMA_DEV12_UART1_TX,
  347. .src_info.data_width = STEDMA40_BYTE_WIDTH,
  348. .dst_info.data_width = STEDMA40_BYTE_WIDTH,
  349. };
  350. static struct stedma40_chan_cfg uart2_dma_cfg_rx = {
  351. .mode = STEDMA40_MODE_LOGICAL,
  352. .dir = STEDMA40_PERIPH_TO_MEM,
  353. .src_dev_type = DB8500_DMA_DEV11_UART2_RX,
  354. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  355. .src_info.data_width = STEDMA40_BYTE_WIDTH,
  356. .dst_info.data_width = STEDMA40_BYTE_WIDTH,
  357. };
  358. static struct stedma40_chan_cfg uart2_dma_cfg_tx = {
  359. .mode = STEDMA40_MODE_LOGICAL,
  360. .dir = STEDMA40_MEM_TO_PERIPH,
  361. .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
  362. .dst_dev_type = DB8500_DMA_DEV11_UART2_TX,
  363. .src_info.data_width = STEDMA40_BYTE_WIDTH,
  364. .dst_info.data_width = STEDMA40_BYTE_WIDTH,
  365. };
  366. #endif
  367. static struct amba_pl011_data uart0_plat = {
  368. #ifdef CONFIG_STE_DMA40
  369. .dma_filter = stedma40_filter,
  370. .dma_rx_param = &uart0_dma_cfg_rx,
  371. .dma_tx_param = &uart0_dma_cfg_tx,
  372. #endif
  373. };
  374. static struct amba_pl011_data uart1_plat = {
  375. #ifdef CONFIG_STE_DMA40
  376. .dma_filter = stedma40_filter,
  377. .dma_rx_param = &uart1_dma_cfg_rx,
  378. .dma_tx_param = &uart1_dma_cfg_tx,
  379. #endif
  380. };
  381. static struct amba_pl011_data uart2_plat = {
  382. #ifdef CONFIG_STE_DMA40
  383. .dma_filter = stedma40_filter,
  384. .dma_rx_param = &uart2_dma_cfg_rx,
  385. .dma_tx_param = &uart2_dma_cfg_tx,
  386. #endif
  387. };
  388. static void __init mop500_uart_init(void)
  389. {
  390. db8500_add_uart0(&uart0_plat);
  391. db8500_add_uart1(&uart1_plat);
  392. db8500_add_uart2(&uart2_plat);
  393. }
  394. static void __init u8500_init_machine(void)
  395. {
  396. u8500_init_devices();
  397. nmk_config_pins(mop500_pins, ARRAY_SIZE(mop500_pins));
  398. platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
  399. mop500_i2c_init();
  400. mop500_sdi_init();
  401. mop500_spi_init();
  402. mop500_uart_init();
  403. platform_device_register(&ab8500_device);
  404. i2c_register_board_info(0, mop500_i2c0_devices,
  405. ARRAY_SIZE(mop500_i2c0_devices));
  406. i2c_register_board_info(2, mop500_i2c2_devices,
  407. ARRAY_SIZE(mop500_i2c2_devices));
  408. }
  409. MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
  410. /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
  411. .boot_params = 0x100,
  412. .map_io = u8500_map_io,
  413. .init_irq = ux500_init_irq,
  414. /* we re-use nomadik timer here */
  415. .timer = &ux500_timer,
  416. .init_machine = u8500_init_machine,
  417. MACHINE_END