board-mop500.c 8.4 KB

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