board-mop500.c 13 KB

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