board-mop500.c 11 KB

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