board-mop500.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. /*
  2. * Copyright (C) 2008-2012 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/clk.h>
  16. #include <linux/io.h>
  17. #include <linux/i2c.h>
  18. #include <linux/platform_data/i2c-nomadik.h>
  19. #include <linux/platform_data/db8500_thermal.h>
  20. #include <linux/gpio.h>
  21. #include <linux/amba/bus.h>
  22. #include <linux/amba/pl022.h>
  23. #include <linux/amba/serial.h>
  24. #include <linux/spi/spi.h>
  25. #include <linux/mfd/abx500/ab8500.h>
  26. #include <linux/regulator/ab8500.h>
  27. #include <linux/regulator/fixed.h>
  28. #include <linux/regulator/driver.h>
  29. #include <linux/regulator/gpio-regulator.h>
  30. #include <linux/mfd/tc3589x.h>
  31. #include <linux/mfd/tps6105x.h>
  32. #include <linux/mfd/abx500/ab8500-gpio.h>
  33. #include <linux/mfd/abx500/ab8500-codec.h>
  34. #include <linux/platform_data/leds-lp55xx.h>
  35. #include <linux/input.h>
  36. #include <linux/gpio_keys.h>
  37. #include <linux/delay.h>
  38. #include <linux/leds.h>
  39. #include <linux/pinctrl/consumer.h>
  40. #include <linux/platform_data/pinctrl-nomadik.h>
  41. #include <linux/platform_data/dma-ste-dma40.h>
  42. #include <asm/mach-types.h>
  43. #include "setup.h"
  44. #include "devices.h"
  45. #include "irqs.h"
  46. #include <linux/platform_data/crypto-ux500.h>
  47. #include "ste-dma40-db8500.h"
  48. #include "db8500-regs.h"
  49. #include "devices-db8500.h"
  50. #include "board-mop500.h"
  51. #include "board-mop500-regulators.h"
  52. static struct fixed_voltage_config snowball_gpio_en_3v3_data = {
  53. .supply_name = "EN-3V3",
  54. .gpio = SNOWBALL_EN_3V3_ETH_GPIO,
  55. .microvolts = 3300000,
  56. .enable_high = 1,
  57. .init_data = &gpio_en_3v3_regulator,
  58. .startup_delay = 5000, /* 1200us */
  59. };
  60. static struct platform_device snowball_gpio_en_3v3_regulator_dev = {
  61. .name = "reg-fixed-voltage",
  62. .id = 1,
  63. .dev = {
  64. .platform_data = &snowball_gpio_en_3v3_data,
  65. },
  66. };
  67. /* Dynamically populated. */
  68. static struct gpio sdi0_reg_gpios[] = {
  69. { 0, GPIOF_OUT_INIT_LOW, "mmci_vsel" },
  70. };
  71. static struct gpio_regulator_state sdi0_reg_states[] = {
  72. { .value = 2900000, .gpios = (0 << 0) },
  73. { .value = 1800000, .gpios = (1 << 0) },
  74. };
  75. static struct gpio_regulator_config sdi0_reg_info = {
  76. .supply_name = "ext-mmc-level-shifter",
  77. .gpios = sdi0_reg_gpios,
  78. .nr_gpios = ARRAY_SIZE(sdi0_reg_gpios),
  79. .states = sdi0_reg_states,
  80. .nr_states = ARRAY_SIZE(sdi0_reg_states),
  81. .type = REGULATOR_VOLTAGE,
  82. .enable_high = 1,
  83. .enabled_at_boot = 0,
  84. .init_data = &sdi0_reg_init_data,
  85. .startup_delay = 100,
  86. };
  87. static struct platform_device sdi0_regulator = {
  88. .name = "gpio-regulator",
  89. .id = -1,
  90. .dev = {
  91. .platform_data = &sdi0_reg_info,
  92. },
  93. };
  94. static struct abx500_gpio_platform_data ab8500_gpio_pdata = {
  95. .gpio_base = MOP500_AB8500_PIN_GPIO(1),
  96. };
  97. /* ab8500-codec */
  98. static struct ab8500_codec_platform_data ab8500_codec_pdata = {
  99. .amics = {
  100. .mic1_type = AMIC_TYPE_DIFFERENTIAL,
  101. .mic2_type = AMIC_TYPE_DIFFERENTIAL,
  102. .mic1a_micbias = AMIC_MICBIAS_VAMIC1,
  103. .mic1b_micbias = AMIC_MICBIAS_VAMIC1,
  104. .mic2_micbias = AMIC_MICBIAS_VAMIC2
  105. },
  106. .ear_cmv = EAR_CMV_0_95V
  107. };
  108. struct ab8500_platform_data ab8500_platdata = {
  109. .irq_base = MOP500_AB8500_IRQ_BASE,
  110. .regulator = &ab8500_regulator_plat_data,
  111. .gpio = &ab8500_gpio_pdata,
  112. .codec = &ab8500_codec_pdata,
  113. };
  114. static struct platform_device u8500_cpufreq_cooling_device = {
  115. .name = "db8500-cpufreq-cooling",
  116. };
  117. /*
  118. * TC35892
  119. */
  120. static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
  121. {
  122. struct device *parent = NULL;
  123. #if 0
  124. /* FIXME: Is the sdi actually part of tc3589x? */
  125. parent = tc3589x->dev;
  126. #endif
  127. mop500_sdi_tc35892_init(parent);
  128. }
  129. static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
  130. .gpio_base = MOP500_EGPIO(0),
  131. .setup = mop500_tc35892_init,
  132. };
  133. static struct tc3589x_platform_data mop500_tc35892_data = {
  134. .block = TC3589x_BLOCK_GPIO,
  135. .gpio = &mop500_tc35892_gpio_data,
  136. .irq_base = MOP500_EGPIO_IRQ_BASE,
  137. };
  138. /* I2C0 devices only available on the first HREF/MOP500 */
  139. static struct i2c_board_info __initdata mop500_i2c0_devices[] = {
  140. {
  141. I2C_BOARD_INFO("tc3589x", 0x42),
  142. .irq = NOMADIK_GPIO_TO_IRQ(217),
  143. .platform_data = &mop500_tc35892_data,
  144. },
  145. };
  146. static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
  147. {
  148. /* Light sensor Rohm BH1780GLI */
  149. I2C_BOARD_INFO("bh1780", 0x29),
  150. },
  151. };
  152. static int __init mop500_i2c_board_init(void)
  153. {
  154. if (machine_is_u8500())
  155. mop500_uib_i2c_add(0, mop500_i2c0_devices,
  156. ARRAY_SIZE(mop500_i2c0_devices));
  157. mop500_uib_i2c_add(2, mop500_i2c2_devices,
  158. ARRAY_SIZE(mop500_i2c2_devices));
  159. return 0;
  160. }
  161. device_initcall(mop500_i2c_board_init);
  162. static void __init mop500_i2c_init(struct device *parent)
  163. {
  164. db8500_add_i2c0(parent, NULL);
  165. db8500_add_i2c1(parent, NULL);
  166. db8500_add_i2c2(parent, NULL);
  167. db8500_add_i2c3(parent, NULL);
  168. }
  169. static struct gpio_keys_button mop500_gpio_keys[] = {
  170. {
  171. .desc = "SFH7741 Proximity Sensor",
  172. .type = EV_SW,
  173. .code = SW_FRONT_PROXIMITY,
  174. .active_low = 0,
  175. .can_disable = 1,
  176. }
  177. };
  178. static struct regulator *prox_regulator;
  179. static int mop500_prox_activate(struct device *dev);
  180. static void mop500_prox_deactivate(struct device *dev);
  181. static struct gpio_keys_platform_data mop500_gpio_keys_data = {
  182. .buttons = mop500_gpio_keys,
  183. .nbuttons = ARRAY_SIZE(mop500_gpio_keys),
  184. .enable = mop500_prox_activate,
  185. .disable = mop500_prox_deactivate,
  186. };
  187. static struct platform_device mop500_gpio_keys_device = {
  188. .name = "gpio-keys",
  189. .id = 0,
  190. .dev = {
  191. .platform_data = &mop500_gpio_keys_data,
  192. },
  193. };
  194. static int mop500_prox_activate(struct device *dev)
  195. {
  196. prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
  197. "vcc");
  198. if (IS_ERR(prox_regulator)) {
  199. dev_err(&mop500_gpio_keys_device.dev,
  200. "no regulator\n");
  201. return PTR_ERR(prox_regulator);
  202. }
  203. return regulator_enable(prox_regulator);
  204. }
  205. static void mop500_prox_deactivate(struct device *dev)
  206. {
  207. regulator_disable(prox_regulator);
  208. regulator_put(prox_regulator);
  209. }
  210. static struct cryp_platform_data u8500_cryp1_platform_data = {
  211. .mem_to_engine = {
  212. .dir = DMA_MEM_TO_DEV,
  213. .dev_type = DB8500_DMA_DEV48_CAC1,
  214. .mode = STEDMA40_MODE_LOGICAL,
  215. },
  216. .engine_to_mem = {
  217. .dir = DMA_DEV_TO_MEM,
  218. .dev_type = DB8500_DMA_DEV48_CAC1,
  219. .mode = STEDMA40_MODE_LOGICAL,
  220. }
  221. };
  222. static struct stedma40_chan_cfg u8500_hash_dma_cfg_tx = {
  223. .dir = DMA_MEM_TO_DEV,
  224. .dev_type = DB8500_DMA_DEV50_HAC1_TX,
  225. .mode = STEDMA40_MODE_LOGICAL,
  226. };
  227. static struct hash_platform_data u8500_hash1_platform_data = {
  228. .mem_to_engine = &u8500_hash_dma_cfg_tx,
  229. .dma_filter = stedma40_filter,
  230. };
  231. /* add any platform devices here - TODO */
  232. static struct platform_device *mop500_platform_devs[] __initdata = {
  233. &mop500_gpio_keys_device,
  234. &sdi0_regulator,
  235. };
  236. #ifdef CONFIG_STE_DMA40
  237. static struct stedma40_chan_cfg ssp0_dma_cfg_rx = {
  238. .mode = STEDMA40_MODE_LOGICAL,
  239. .dir = DMA_DEV_TO_MEM,
  240. .dev_type = DB8500_DMA_DEV8_SSP0,
  241. };
  242. static struct stedma40_chan_cfg ssp0_dma_cfg_tx = {
  243. .mode = STEDMA40_MODE_LOGICAL,
  244. .dir = DMA_MEM_TO_DEV,
  245. .dev_type = DB8500_DMA_DEV8_SSP0,
  246. };
  247. #endif
  248. struct pl022_ssp_controller ssp0_plat = {
  249. .bus_id = 0,
  250. #ifdef CONFIG_STE_DMA40
  251. .enable_dma = 1,
  252. .dma_filter = stedma40_filter,
  253. .dma_rx_param = &ssp0_dma_cfg_rx,
  254. .dma_tx_param = &ssp0_dma_cfg_tx,
  255. #else
  256. .enable_dma = 0,
  257. #endif
  258. /* on this platform, gpio 31,142,144,214 &
  259. * 224 are connected as chip selects
  260. */
  261. .num_chipselect = 5,
  262. };
  263. static void __init mop500_spi_init(struct device *parent)
  264. {
  265. db8500_add_ssp0(parent, &ssp0_plat);
  266. }
  267. #ifdef CONFIG_STE_DMA40
  268. static struct stedma40_chan_cfg uart0_dma_cfg_rx = {
  269. .mode = STEDMA40_MODE_LOGICAL,
  270. .dir = DMA_DEV_TO_MEM,
  271. .dev_type = DB8500_DMA_DEV13_UART0,
  272. };
  273. static struct stedma40_chan_cfg uart0_dma_cfg_tx = {
  274. .mode = STEDMA40_MODE_LOGICAL,
  275. .dir = DMA_MEM_TO_DEV,
  276. .dev_type = DB8500_DMA_DEV13_UART0,
  277. };
  278. static struct stedma40_chan_cfg uart1_dma_cfg_rx = {
  279. .mode = STEDMA40_MODE_LOGICAL,
  280. .dir = DMA_DEV_TO_MEM,
  281. .dev_type = DB8500_DMA_DEV12_UART1,
  282. };
  283. static struct stedma40_chan_cfg uart1_dma_cfg_tx = {
  284. .mode = STEDMA40_MODE_LOGICAL,
  285. .dir = DMA_MEM_TO_DEV,
  286. .dev_type = DB8500_DMA_DEV12_UART1,
  287. };
  288. static struct stedma40_chan_cfg uart2_dma_cfg_rx = {
  289. .mode = STEDMA40_MODE_LOGICAL,
  290. .dir = DMA_DEV_TO_MEM,
  291. .dev_type = DB8500_DMA_DEV11_UART2,
  292. };
  293. static struct stedma40_chan_cfg uart2_dma_cfg_tx = {
  294. .mode = STEDMA40_MODE_LOGICAL,
  295. .dir = DMA_MEM_TO_DEV,
  296. .dev_type = DB8500_DMA_DEV11_UART2,
  297. };
  298. #endif
  299. struct amba_pl011_data uart0_plat = {
  300. #ifdef CONFIG_STE_DMA40
  301. .dma_filter = stedma40_filter,
  302. .dma_rx_param = &uart0_dma_cfg_rx,
  303. .dma_tx_param = &uart0_dma_cfg_tx,
  304. #endif
  305. };
  306. struct amba_pl011_data uart1_plat = {
  307. #ifdef CONFIG_STE_DMA40
  308. .dma_filter = stedma40_filter,
  309. .dma_rx_param = &uart1_dma_cfg_rx,
  310. .dma_tx_param = &uart1_dma_cfg_tx,
  311. #endif
  312. };
  313. struct amba_pl011_data uart2_plat = {
  314. #ifdef CONFIG_STE_DMA40
  315. .dma_filter = stedma40_filter,
  316. .dma_rx_param = &uart2_dma_cfg_rx,
  317. .dma_tx_param = &uart2_dma_cfg_tx,
  318. #endif
  319. };
  320. static void __init mop500_uart_init(struct device *parent)
  321. {
  322. db8500_add_uart0(parent, &uart0_plat);
  323. db8500_add_uart1(parent, &uart1_plat);
  324. db8500_add_uart2(parent, &uart2_plat);
  325. }
  326. static void __init u8500_cryp1_hash1_init(struct device *parent)
  327. {
  328. db8500_add_cryp1(parent, &u8500_cryp1_platform_data);
  329. db8500_add_hash1(parent, &u8500_hash1_platform_data);
  330. }
  331. static struct platform_device *snowball_platform_devs[] __initdata = {
  332. &snowball_gpio_en_3v3_regulator_dev,
  333. &u8500_cpufreq_cooling_device,
  334. &sdi0_regulator,
  335. };
  336. static void __init mop500_init_machine(void)
  337. {
  338. struct device *parent = NULL;
  339. int i;
  340. platform_device_register(&db8500_prcmu_device);
  341. mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
  342. sdi0_reg_info.enable_gpio = GPIO_SDMMC_EN;
  343. sdi0_reg_info.gpios[0].gpio = GPIO_SDMMC_1V8_3V_SEL;
  344. mop500_pinmaps_init();
  345. parent = u8500_init_devices();
  346. for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
  347. mop500_platform_devs[i]->dev.parent = parent;
  348. platform_add_devices(mop500_platform_devs,
  349. ARRAY_SIZE(mop500_platform_devs));
  350. mop500_i2c_init(parent);
  351. mop500_sdi_init(parent);
  352. mop500_spi_init(parent);
  353. mop500_uart_init(parent);
  354. u8500_cryp1_hash1_init(parent);
  355. /* This board has full regulator constraints */
  356. regulator_has_full_constraints();
  357. }
  358. static void __init snowball_init_machine(void)
  359. {
  360. struct device *parent = NULL;
  361. int i;
  362. platform_device_register(&db8500_prcmu_device);
  363. sdi0_reg_info.enable_gpio = SNOWBALL_SDMMC_EN_GPIO;
  364. sdi0_reg_info.gpios[0].gpio = SNOWBALL_SDMMC_1V8_3V_GPIO;
  365. snowball_pinmaps_init();
  366. parent = u8500_init_devices();
  367. for (i = 0; i < ARRAY_SIZE(snowball_platform_devs); i++)
  368. snowball_platform_devs[i]->dev.parent = parent;
  369. platform_add_devices(snowball_platform_devs,
  370. ARRAY_SIZE(snowball_platform_devs));
  371. mop500_i2c_init(parent);
  372. snowball_sdi_init(parent);
  373. mop500_spi_init(parent);
  374. mop500_uart_init(parent);
  375. u8500_cryp1_hash1_init(parent);
  376. /* This board has full regulator constraints */
  377. regulator_has_full_constraints();
  378. }
  379. static void __init hrefv60_init_machine(void)
  380. {
  381. struct device *parent = NULL;
  382. int i;
  383. platform_device_register(&db8500_prcmu_device);
  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. mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
  390. sdi0_reg_info.enable_gpio = HREFV60_SDMMC_EN_GPIO;
  391. sdi0_reg_info.gpios[0].gpio = HREFV60_SDMMC_1V8_3V_GPIO;
  392. hrefv60_pinmaps_init();
  393. parent = u8500_init_devices();
  394. for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
  395. mop500_platform_devs[i]->dev.parent = parent;
  396. platform_add_devices(mop500_platform_devs,
  397. ARRAY_SIZE(mop500_platform_devs));
  398. mop500_i2c_init(parent);
  399. hrefv60_sdi_init(parent);
  400. mop500_spi_init(parent);
  401. mop500_uart_init(parent);
  402. /* This board has full regulator constraints */
  403. regulator_has_full_constraints();
  404. }
  405. MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
  406. /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
  407. .atag_offset = 0x100,
  408. .smp = smp_ops(ux500_smp_ops),
  409. .map_io = u8500_map_io,
  410. .init_irq = ux500_init_irq,
  411. /* we re-use nomadik timer here */
  412. .init_time = ux500_timer_init,
  413. .init_machine = mop500_init_machine,
  414. .init_late = ux500_init_late,
  415. .restart = ux500_restart,
  416. MACHINE_END
  417. MACHINE_START(U8520, "ST-Ericsson U8520 Platform HREFP520")
  418. .atag_offset = 0x100,
  419. .map_io = u8500_map_io,
  420. .init_irq = ux500_init_irq,
  421. .init_time = ux500_timer_init,
  422. .init_machine = mop500_init_machine,
  423. .init_late = ux500_init_late,
  424. .restart = ux500_restart,
  425. MACHINE_END
  426. MACHINE_START(HREFV60, "ST-Ericsson U8500 Platform HREFv60+")
  427. .atag_offset = 0x100,
  428. .smp = smp_ops(ux500_smp_ops),
  429. .map_io = u8500_map_io,
  430. .init_irq = ux500_init_irq,
  431. .init_time = ux500_timer_init,
  432. .init_machine = hrefv60_init_machine,
  433. .init_late = ux500_init_late,
  434. .restart = ux500_restart,
  435. MACHINE_END
  436. MACHINE_START(SNOWBALL, "Calao Systems Snowball platform")
  437. .atag_offset = 0x100,
  438. .smp = smp_ops(ux500_smp_ops),
  439. .map_io = u8500_map_io,
  440. .init_irq = ux500_init_irq,
  441. /* we re-use nomadik timer here */
  442. .init_time = ux500_timer_init,
  443. .init_machine = snowball_init_machine,
  444. .init_late = NULL,
  445. .restart = ux500_restart,
  446. MACHINE_END