board-mop500.c 11 KB

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