board-mop500.c 11 KB

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