board-mop500.c 11 KB

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