board-mop500.c 9.8 KB

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