board-mop500.c 8.9 KB

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