board-mop500.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835
  1. /*
  2. * Copyright (C) 2008-2009 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/io.h>
  16. #include <linux/i2c.h>
  17. #include <linux/gpio.h>
  18. #include <linux/amba/bus.h>
  19. #include <linux/amba/pl022.h>
  20. #include <linux/amba/serial.h>
  21. #include <linux/spi/spi.h>
  22. #include <linux/mfd/abx500/ab8500.h>
  23. #include <linux/regulator/ab8500.h>
  24. #include <linux/mfd/tc3589x.h>
  25. #include <linux/mfd/tps6105x.h>
  26. #include <linux/mfd/abx500/ab8500-gpio.h>
  27. #include <linux/leds-lp5521.h>
  28. #include <linux/input.h>
  29. #include <linux/smsc911x.h>
  30. #include <linux/gpio_keys.h>
  31. #include <linux/delay.h>
  32. #include <linux/of.h>
  33. #include <linux/of_platform.h>
  34. #include <linux/leds.h>
  35. #include <asm/mach-types.h>
  36. #include <asm/mach/arch.h>
  37. #include <asm/hardware/gic.h>
  38. #include <plat/i2c.h>
  39. #include <plat/ste_dma40.h>
  40. #include <plat/pincfg.h>
  41. #include <plat/gpio-nomadik.h>
  42. #include <mach/hardware.h>
  43. #include <mach/setup.h>
  44. #include <mach/devices.h>
  45. #include <mach/irqs.h>
  46. #include "pins-db8500.h"
  47. #include "ste-dma40-db8500.h"
  48. #include "devices-db8500.h"
  49. #include "board-mop500.h"
  50. #include "board-mop500-regulators.h"
  51. static struct gpio_led snowball_led_array[] = {
  52. {
  53. .name = "user_led",
  54. .default_trigger = "none",
  55. .gpio = 142,
  56. },
  57. };
  58. static struct gpio_led_platform_data snowball_led_data = {
  59. .leds = snowball_led_array,
  60. .num_leds = ARRAY_SIZE(snowball_led_array),
  61. };
  62. static struct platform_device snowball_led_dev = {
  63. .name = "leds-gpio",
  64. .dev = {
  65. .platform_data = &snowball_led_data,
  66. },
  67. };
  68. static struct ab8500_gpio_platform_data ab8500_gpio_pdata = {
  69. .gpio_base = MOP500_AB8500_PIN_GPIO(1),
  70. .irq_base = MOP500_AB8500_VIR_GPIO_IRQ_BASE,
  71. /* config_reg is the initial configuration of ab8500 pins.
  72. * The pins can be configured as GPIO or alt functions based
  73. * on value present in GpioSel1 to GpioSel6 and AlternatFunction
  74. * register. This is the array of 7 configuration settings.
  75. * One has to compile time decide these settings. Below is the
  76. * explanation of these setting
  77. * GpioSel1 = 0x00 => Pins GPIO1 to GPIO8 are not used as GPIO
  78. * GpioSel2 = 0x1E => Pins GPIO10 to GPIO13 are configured as GPIO
  79. * GpioSel3 = 0x80 => Pin GPIO24 is configured as GPIO
  80. * GpioSel4 = 0x01 => Pin GPIo25 is configured as GPIO
  81. * GpioSel5 = 0x7A => Pins GPIO34, GPIO36 to GPIO39 are conf as GPIO
  82. * GpioSel6 = 0x00 => Pins GPIO41 & GPIo42 are not configured as GPIO
  83. * AlternaFunction = 0x00 => If Pins GPIO10 to 13 are not configured
  84. * as GPIO then this register selectes the alternate fucntions
  85. */
  86. .config_reg = {0x00, 0x1E, 0x80, 0x01,
  87. 0x7A, 0x00, 0x00},
  88. };
  89. static struct gpio_keys_button snowball_key_array[] = {
  90. {
  91. .gpio = 32,
  92. .type = EV_KEY,
  93. .code = KEY_1,
  94. .desc = "userpb",
  95. .active_low = 1,
  96. .debounce_interval = 50,
  97. .wakeup = 1,
  98. },
  99. {
  100. .gpio = 151,
  101. .type = EV_KEY,
  102. .code = KEY_2,
  103. .desc = "extkb1",
  104. .active_low = 1,
  105. .debounce_interval = 50,
  106. .wakeup = 1,
  107. },
  108. {
  109. .gpio = 152,
  110. .type = EV_KEY,
  111. .code = KEY_3,
  112. .desc = "extkb2",
  113. .active_low = 1,
  114. .debounce_interval = 50,
  115. .wakeup = 1,
  116. },
  117. {
  118. .gpio = 161,
  119. .type = EV_KEY,
  120. .code = KEY_4,
  121. .desc = "extkb3",
  122. .active_low = 1,
  123. .debounce_interval = 50,
  124. .wakeup = 1,
  125. },
  126. {
  127. .gpio = 162,
  128. .type = EV_KEY,
  129. .code = KEY_5,
  130. .desc = "extkb4",
  131. .active_low = 1,
  132. .debounce_interval = 50,
  133. .wakeup = 1,
  134. },
  135. };
  136. static struct gpio_keys_platform_data snowball_key_data = {
  137. .buttons = snowball_key_array,
  138. .nbuttons = ARRAY_SIZE(snowball_key_array),
  139. };
  140. static struct platform_device snowball_key_dev = {
  141. .name = "gpio-keys",
  142. .id = -1,
  143. .dev = {
  144. .platform_data = &snowball_key_data,
  145. }
  146. };
  147. static struct smsc911x_platform_config snowball_sbnet_cfg = {
  148. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
  149. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  150. .flags = SMSC911X_USE_16BIT | SMSC911X_FORCE_INTERNAL_PHY,
  151. .shift = 1,
  152. };
  153. static struct resource sbnet_res[] = {
  154. {
  155. .name = "smsc911x-memory",
  156. .start = (0x5000 << 16),
  157. .end = (0x5000 << 16) + 0xffff,
  158. .flags = IORESOURCE_MEM,
  159. },
  160. {
  161. .start = NOMADIK_GPIO_TO_IRQ(140),
  162. .end = NOMADIK_GPIO_TO_IRQ(140),
  163. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  164. },
  165. };
  166. static struct platform_device snowball_sbnet_dev = {
  167. .name = "smsc911x",
  168. .num_resources = ARRAY_SIZE(sbnet_res),
  169. .resource = sbnet_res,
  170. .dev = {
  171. .platform_data = &snowball_sbnet_cfg,
  172. },
  173. };
  174. static struct ab8500_platform_data ab8500_platdata = {
  175. .irq_base = MOP500_AB8500_IRQ_BASE,
  176. .regulator_reg_init = ab8500_regulator_reg_init,
  177. .num_regulator_reg_init = ARRAY_SIZE(ab8500_regulator_reg_init),
  178. .regulator = ab8500_regulators,
  179. .num_regulator = ARRAY_SIZE(ab8500_regulators),
  180. .gpio = &ab8500_gpio_pdata,
  181. };
  182. static struct resource ab8500_resources[] = {
  183. [0] = {
  184. .start = IRQ_DB8500_AB8500,
  185. .end = IRQ_DB8500_AB8500,
  186. .flags = IORESOURCE_IRQ
  187. }
  188. };
  189. struct platform_device ab8500_device = {
  190. .name = "ab8500-i2c",
  191. .id = 0,
  192. .dev = {
  193. .platform_data = &ab8500_platdata,
  194. },
  195. .num_resources = 1,
  196. .resource = ab8500_resources,
  197. };
  198. /*
  199. * TPS61052
  200. */
  201. static struct tps6105x_platform_data mop500_tps61052_data = {
  202. .mode = TPS6105X_MODE_VOLTAGE,
  203. .regulator_data = &tps61052_regulator,
  204. };
  205. /*
  206. * TC35892
  207. */
  208. static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
  209. {
  210. struct device *parent = NULL;
  211. #if 0
  212. /* FIXME: Is the sdi actually part of tc3589x? */
  213. parent = tc3589x->dev;
  214. #endif
  215. mop500_sdi_tc35892_init(parent);
  216. }
  217. static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
  218. .gpio_base = MOP500_EGPIO(0),
  219. .setup = mop500_tc35892_init,
  220. };
  221. static struct tc3589x_platform_data mop500_tc35892_data = {
  222. .block = TC3589x_BLOCK_GPIO,
  223. .gpio = &mop500_tc35892_gpio_data,
  224. .irq_base = MOP500_EGPIO_IRQ_BASE,
  225. };
  226. static struct lp5521_led_config lp5521_pri_led[] = {
  227. [0] = {
  228. .chan_nr = 0,
  229. .led_current = 0x2f,
  230. .max_current = 0x5f,
  231. },
  232. [1] = {
  233. .chan_nr = 1,
  234. .led_current = 0x2f,
  235. .max_current = 0x5f,
  236. },
  237. [2] = {
  238. .chan_nr = 2,
  239. .led_current = 0x2f,
  240. .max_current = 0x5f,
  241. },
  242. };
  243. static struct lp5521_platform_data __initdata lp5521_pri_data = {
  244. .label = "lp5521_pri",
  245. .led_config = &lp5521_pri_led[0],
  246. .num_channels = 3,
  247. .clock_mode = LP5521_CLOCK_EXT,
  248. };
  249. static struct lp5521_led_config lp5521_sec_led[] = {
  250. [0] = {
  251. .chan_nr = 0,
  252. .led_current = 0x2f,
  253. .max_current = 0x5f,
  254. },
  255. [1] = {
  256. .chan_nr = 1,
  257. .led_current = 0x2f,
  258. .max_current = 0x5f,
  259. },
  260. [2] = {
  261. .chan_nr = 2,
  262. .led_current = 0x2f,
  263. .max_current = 0x5f,
  264. },
  265. };
  266. static struct lp5521_platform_data __initdata lp5521_sec_data = {
  267. .label = "lp5521_sec",
  268. .led_config = &lp5521_sec_led[0],
  269. .num_channels = 3,
  270. .clock_mode = LP5521_CLOCK_EXT,
  271. };
  272. static struct i2c_board_info __initdata mop500_i2c0_devices[] = {
  273. {
  274. I2C_BOARD_INFO("tc3589x", 0x42),
  275. .irq = NOMADIK_GPIO_TO_IRQ(217),
  276. .platform_data = &mop500_tc35892_data,
  277. },
  278. /* I2C0 devices only available prior to HREFv60 */
  279. {
  280. I2C_BOARD_INFO("tps61052", 0x33),
  281. .platform_data = &mop500_tps61052_data,
  282. },
  283. };
  284. #define NUM_PRE_V60_I2C0_DEVICES 1
  285. static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
  286. {
  287. /* lp5521 LED driver, 1st device */
  288. I2C_BOARD_INFO("lp5521", 0x33),
  289. .platform_data = &lp5521_pri_data,
  290. },
  291. {
  292. /* lp5521 LED driver, 2st device */
  293. I2C_BOARD_INFO("lp5521", 0x34),
  294. .platform_data = &lp5521_sec_data,
  295. },
  296. {
  297. /* Light sensor Rohm BH1780GLI */
  298. I2C_BOARD_INFO("bh1780", 0x29),
  299. },
  300. };
  301. #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, t_out, _sm) \
  302. static struct nmk_i2c_controller u8500_i2c##id##_data = { \
  303. /* \
  304. * slave data setup time, which is \
  305. * 250 ns,100ns,10ns which is 14,6,2 \
  306. * respectively for a 48 Mhz \
  307. * i2c clock \
  308. */ \
  309. .slsu = _slsu, \
  310. /* Tx FIFO threshold */ \
  311. .tft = _tft, \
  312. /* Rx FIFO threshold */ \
  313. .rft = _rft, \
  314. /* std. mode operation */ \
  315. .clk_freq = clk, \
  316. /* Slave response timeout(ms) */\
  317. .timeout = t_out, \
  318. .sm = _sm, \
  319. }
  320. /*
  321. * The board uses 4 i2c controllers, initialize all of
  322. * them with slave data setup time of 250 ns,
  323. * Tx & Rx FIFO threshold values as 8 and standard
  324. * mode of operation
  325. */
  326. U8500_I2C_CONTROLLER(0, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST);
  327. U8500_I2C_CONTROLLER(1, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST);
  328. U8500_I2C_CONTROLLER(2, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST);
  329. U8500_I2C_CONTROLLER(3, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST);
  330. static void __init mop500_i2c_init(struct device *parent)
  331. {
  332. db8500_add_i2c0(parent, &u8500_i2c0_data);
  333. db8500_add_i2c1(parent, &u8500_i2c1_data);
  334. db8500_add_i2c2(parent, &u8500_i2c2_data);
  335. db8500_add_i2c3(parent, &u8500_i2c3_data);
  336. }
  337. static struct gpio_keys_button mop500_gpio_keys[] = {
  338. {
  339. .desc = "SFH7741 Proximity Sensor",
  340. .type = EV_SW,
  341. .code = SW_FRONT_PROXIMITY,
  342. .active_low = 0,
  343. .can_disable = 1,
  344. }
  345. };
  346. static struct regulator *prox_regulator;
  347. static int mop500_prox_activate(struct device *dev);
  348. static void mop500_prox_deactivate(struct device *dev);
  349. static struct gpio_keys_platform_data mop500_gpio_keys_data = {
  350. .buttons = mop500_gpio_keys,
  351. .nbuttons = ARRAY_SIZE(mop500_gpio_keys),
  352. .enable = mop500_prox_activate,
  353. .disable = mop500_prox_deactivate,
  354. };
  355. static struct platform_device mop500_gpio_keys_device = {
  356. .name = "gpio-keys",
  357. .id = 0,
  358. .dev = {
  359. .platform_data = &mop500_gpio_keys_data,
  360. },
  361. };
  362. static int mop500_prox_activate(struct device *dev)
  363. {
  364. prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
  365. "vcc");
  366. if (IS_ERR(prox_regulator)) {
  367. dev_err(&mop500_gpio_keys_device.dev,
  368. "no regulator\n");
  369. return PTR_ERR(prox_regulator);
  370. }
  371. regulator_enable(prox_regulator);
  372. return 0;
  373. }
  374. static void mop500_prox_deactivate(struct device *dev)
  375. {
  376. regulator_disable(prox_regulator);
  377. regulator_put(prox_regulator);
  378. }
  379. /* add any platform devices here - TODO */
  380. static struct platform_device *mop500_platform_devs[] __initdata = {
  381. &mop500_gpio_keys_device,
  382. &ab8500_device,
  383. };
  384. #ifdef CONFIG_STE_DMA40
  385. static struct stedma40_chan_cfg ssp0_dma_cfg_rx = {
  386. .mode = STEDMA40_MODE_LOGICAL,
  387. .dir = STEDMA40_PERIPH_TO_MEM,
  388. .src_dev_type = DB8500_DMA_DEV8_SSP0_RX,
  389. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  390. .src_info.data_width = STEDMA40_BYTE_WIDTH,
  391. .dst_info.data_width = STEDMA40_BYTE_WIDTH,
  392. };
  393. static struct stedma40_chan_cfg ssp0_dma_cfg_tx = {
  394. .mode = STEDMA40_MODE_LOGICAL,
  395. .dir = STEDMA40_MEM_TO_PERIPH,
  396. .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
  397. .dst_dev_type = DB8500_DMA_DEV8_SSP0_TX,
  398. .src_info.data_width = STEDMA40_BYTE_WIDTH,
  399. .dst_info.data_width = STEDMA40_BYTE_WIDTH,
  400. };
  401. #endif
  402. static struct pl022_ssp_controller ssp0_plat = {
  403. .bus_id = 0,
  404. #ifdef CONFIG_STE_DMA40
  405. .enable_dma = 1,
  406. .dma_filter = stedma40_filter,
  407. .dma_rx_param = &ssp0_dma_cfg_rx,
  408. .dma_tx_param = &ssp0_dma_cfg_tx,
  409. #else
  410. .enable_dma = 0,
  411. #endif
  412. /* on this platform, gpio 31,142,144,214 &
  413. * 224 are connected as chip selects
  414. */
  415. .num_chipselect = 5,
  416. };
  417. static void __init mop500_spi_init(struct device *parent)
  418. {
  419. db8500_add_ssp0(parent, &ssp0_plat);
  420. }
  421. #ifdef CONFIG_STE_DMA40
  422. static struct stedma40_chan_cfg uart0_dma_cfg_rx = {
  423. .mode = STEDMA40_MODE_LOGICAL,
  424. .dir = STEDMA40_PERIPH_TO_MEM,
  425. .src_dev_type = DB8500_DMA_DEV13_UART0_RX,
  426. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  427. .src_info.data_width = STEDMA40_BYTE_WIDTH,
  428. .dst_info.data_width = STEDMA40_BYTE_WIDTH,
  429. };
  430. static struct stedma40_chan_cfg uart0_dma_cfg_tx = {
  431. .mode = STEDMA40_MODE_LOGICAL,
  432. .dir = STEDMA40_MEM_TO_PERIPH,
  433. .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
  434. .dst_dev_type = DB8500_DMA_DEV13_UART0_TX,
  435. .src_info.data_width = STEDMA40_BYTE_WIDTH,
  436. .dst_info.data_width = STEDMA40_BYTE_WIDTH,
  437. };
  438. static struct stedma40_chan_cfg uart1_dma_cfg_rx = {
  439. .mode = STEDMA40_MODE_LOGICAL,
  440. .dir = STEDMA40_PERIPH_TO_MEM,
  441. .src_dev_type = DB8500_DMA_DEV12_UART1_RX,
  442. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  443. .src_info.data_width = STEDMA40_BYTE_WIDTH,
  444. .dst_info.data_width = STEDMA40_BYTE_WIDTH,
  445. };
  446. static struct stedma40_chan_cfg uart1_dma_cfg_tx = {
  447. .mode = STEDMA40_MODE_LOGICAL,
  448. .dir = STEDMA40_MEM_TO_PERIPH,
  449. .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
  450. .dst_dev_type = DB8500_DMA_DEV12_UART1_TX,
  451. .src_info.data_width = STEDMA40_BYTE_WIDTH,
  452. .dst_info.data_width = STEDMA40_BYTE_WIDTH,
  453. };
  454. static struct stedma40_chan_cfg uart2_dma_cfg_rx = {
  455. .mode = STEDMA40_MODE_LOGICAL,
  456. .dir = STEDMA40_PERIPH_TO_MEM,
  457. .src_dev_type = DB8500_DMA_DEV11_UART2_RX,
  458. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  459. .src_info.data_width = STEDMA40_BYTE_WIDTH,
  460. .dst_info.data_width = STEDMA40_BYTE_WIDTH,
  461. };
  462. static struct stedma40_chan_cfg uart2_dma_cfg_tx = {
  463. .mode = STEDMA40_MODE_LOGICAL,
  464. .dir = STEDMA40_MEM_TO_PERIPH,
  465. .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
  466. .dst_dev_type = DB8500_DMA_DEV11_UART2_TX,
  467. .src_info.data_width = STEDMA40_BYTE_WIDTH,
  468. .dst_info.data_width = STEDMA40_BYTE_WIDTH,
  469. };
  470. #endif
  471. static pin_cfg_t mop500_pins_uart0[] = {
  472. GPIO0_U0_CTSn | PIN_INPUT_PULLUP,
  473. GPIO1_U0_RTSn | PIN_OUTPUT_HIGH,
  474. GPIO2_U0_RXD | PIN_INPUT_PULLUP,
  475. GPIO3_U0_TXD | PIN_OUTPUT_HIGH,
  476. };
  477. #define PRCC_K_SOFTRST_SET 0x18
  478. #define PRCC_K_SOFTRST_CLEAR 0x1C
  479. static void ux500_uart0_reset(void)
  480. {
  481. void __iomem *prcc_rst_set, *prcc_rst_clr;
  482. prcc_rst_set = (void __iomem *)IO_ADDRESS(U8500_CLKRST1_BASE +
  483. PRCC_K_SOFTRST_SET);
  484. prcc_rst_clr = (void __iomem *)IO_ADDRESS(U8500_CLKRST1_BASE +
  485. PRCC_K_SOFTRST_CLEAR);
  486. /* Activate soft reset PRCC_K_SOFTRST_CLEAR */
  487. writel((readl(prcc_rst_clr) | 0x1), prcc_rst_clr);
  488. udelay(1);
  489. /* Release soft reset PRCC_K_SOFTRST_SET */
  490. writel((readl(prcc_rst_set) | 0x1), prcc_rst_set);
  491. udelay(1);
  492. }
  493. static void ux500_uart0_init(void)
  494. {
  495. int ret;
  496. ret = nmk_config_pins(mop500_pins_uart0,
  497. ARRAY_SIZE(mop500_pins_uart0));
  498. if (ret < 0)
  499. pr_err("pl011: uart pins_enable failed\n");
  500. }
  501. static void ux500_uart0_exit(void)
  502. {
  503. int ret;
  504. ret = nmk_config_pins_sleep(mop500_pins_uart0,
  505. ARRAY_SIZE(mop500_pins_uart0));
  506. if (ret < 0)
  507. pr_err("pl011: uart pins_disable failed\n");
  508. }
  509. static struct amba_pl011_data uart0_plat = {
  510. #ifdef CONFIG_STE_DMA40
  511. .dma_filter = stedma40_filter,
  512. .dma_rx_param = &uart0_dma_cfg_rx,
  513. .dma_tx_param = &uart0_dma_cfg_tx,
  514. #endif
  515. .init = ux500_uart0_init,
  516. .exit = ux500_uart0_exit,
  517. .reset = ux500_uart0_reset,
  518. };
  519. static struct amba_pl011_data uart1_plat = {
  520. #ifdef CONFIG_STE_DMA40
  521. .dma_filter = stedma40_filter,
  522. .dma_rx_param = &uart1_dma_cfg_rx,
  523. .dma_tx_param = &uart1_dma_cfg_tx,
  524. #endif
  525. };
  526. static struct amba_pl011_data uart2_plat = {
  527. #ifdef CONFIG_STE_DMA40
  528. .dma_filter = stedma40_filter,
  529. .dma_rx_param = &uart2_dma_cfg_rx,
  530. .dma_tx_param = &uart2_dma_cfg_tx,
  531. #endif
  532. };
  533. static void __init mop500_uart_init(struct device *parent)
  534. {
  535. db8500_add_uart0(parent, &uart0_plat);
  536. db8500_add_uart1(parent, &uart1_plat);
  537. db8500_add_uart2(parent, &uart2_plat);
  538. }
  539. static struct platform_device *snowball_platform_devs[] __initdata = {
  540. &snowball_led_dev,
  541. &snowball_key_dev,
  542. &snowball_sbnet_dev,
  543. &ab8500_device,
  544. };
  545. static void __init mop500_init_machine(void)
  546. {
  547. struct device *parent = NULL;
  548. int i2c0_devs;
  549. int i;
  550. mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
  551. parent = u8500_init_devices();
  552. mop500_pins_init();
  553. /* FIXME: parent of ab8500 should be prcmu */
  554. for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
  555. mop500_platform_devs[i]->dev.parent = parent;
  556. platform_add_devices(mop500_platform_devs,
  557. ARRAY_SIZE(mop500_platform_devs));
  558. mop500_i2c_init(parent);
  559. mop500_sdi_init(parent);
  560. mop500_spi_init(parent);
  561. mop500_uart_init(parent);
  562. i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
  563. i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
  564. i2c_register_board_info(2, mop500_i2c2_devices,
  565. ARRAY_SIZE(mop500_i2c2_devices));
  566. /* This board has full regulator constraints */
  567. regulator_has_full_constraints();
  568. }
  569. static void __init snowball_init_machine(void)
  570. {
  571. struct device *parent = NULL;
  572. int i2c0_devs;
  573. int i;
  574. parent = u8500_init_devices();
  575. snowball_pins_init();
  576. for (i = 0; i < ARRAY_SIZE(snowball_platform_devs); i++)
  577. snowball_platform_devs[i]->dev.parent = parent;
  578. platform_add_devices(snowball_platform_devs,
  579. ARRAY_SIZE(snowball_platform_devs));
  580. mop500_i2c_init(parent);
  581. snowball_sdi_init(parent);
  582. mop500_spi_init(parent);
  583. mop500_uart_init(parent);
  584. i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
  585. i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
  586. i2c_register_board_info(2, mop500_i2c2_devices,
  587. ARRAY_SIZE(mop500_i2c2_devices));
  588. /* This board has full regulator constraints */
  589. regulator_has_full_constraints();
  590. }
  591. static void __init hrefv60_init_machine(void)
  592. {
  593. struct device *parent = NULL;
  594. int i2c0_devs;
  595. int i;
  596. /*
  597. * The HREFv60 board removed a GPIO expander and routed
  598. * all these GPIO pins to the internal GPIO controller
  599. * instead.
  600. */
  601. mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
  602. parent = u8500_init_devices();
  603. hrefv60_pins_init();
  604. for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
  605. mop500_platform_devs[i]->dev.parent = parent;
  606. platform_add_devices(mop500_platform_devs,
  607. ARRAY_SIZE(mop500_platform_devs));
  608. mop500_i2c_init(parent);
  609. hrefv60_sdi_init(parent);
  610. mop500_spi_init(parent);
  611. mop500_uart_init(parent);
  612. i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
  613. i2c0_devs -= NUM_PRE_V60_I2C0_DEVICES;
  614. i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
  615. i2c_register_board_info(2, mop500_i2c2_devices,
  616. ARRAY_SIZE(mop500_i2c2_devices));
  617. /* This board has full regulator constraints */
  618. regulator_has_full_constraints();
  619. }
  620. MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
  621. /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
  622. .atag_offset = 0x100,
  623. .map_io = u8500_map_io,
  624. .init_irq = ux500_init_irq,
  625. /* we re-use nomadik timer here */
  626. .timer = &ux500_timer,
  627. .handle_irq = gic_handle_irq,
  628. .init_machine = mop500_init_machine,
  629. MACHINE_END
  630. MACHINE_START(HREFV60, "ST-Ericsson U8500 Platform HREFv60+")
  631. .atag_offset = 0x100,
  632. .map_io = u8500_map_io,
  633. .init_irq = ux500_init_irq,
  634. .timer = &ux500_timer,
  635. .handle_irq = gic_handle_irq,
  636. .init_machine = hrefv60_init_machine,
  637. MACHINE_END
  638. MACHINE_START(SNOWBALL, "Calao Systems Snowball platform")
  639. .atag_offset = 0x100,
  640. .map_io = u8500_map_io,
  641. .init_irq = ux500_init_irq,
  642. /* we re-use nomadik timer here */
  643. .timer = &ux500_timer,
  644. .handle_irq = gic_handle_irq,
  645. .init_machine = snowball_init_machine,
  646. MACHINE_END
  647. #ifdef CONFIG_MACH_UX500_DT
  648. struct of_dev_auxdata u8500_auxdata_lookup[] __initdata = {
  649. OF_DEV_AUXDATA("arm,pl011", 0x80120000, "uart0", &uart0_plat),
  650. OF_DEV_AUXDATA("arm,pl011", 0x80121000, "uart1", &uart1_plat),
  651. OF_DEV_AUXDATA("arm,pl011", 0x80007000, "uart2", &uart2_plat),
  652. OF_DEV_AUXDATA("arm,pl022", 0x80002000, "ssp0", &ssp0_plat),
  653. {},
  654. };
  655. static const struct of_device_id u8500_soc_node[] = {
  656. /* only create devices below soc node */
  657. { .compatible = "stericsson,db8500", },
  658. { },
  659. };
  660. static void __init u8500_init_machine(void)
  661. {
  662. struct device *parent = NULL;
  663. int i2c0_devs;
  664. int i;
  665. parent = u8500_init_devices();
  666. i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
  667. for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
  668. mop500_platform_devs[i]->dev.parent = parent;
  669. for (i = 0; i < ARRAY_SIZE(snowball_platform_devs); i++)
  670. snowball_platform_devs[i]->dev.parent = parent;
  671. /* automatically probe child nodes of db8500 device */
  672. of_platform_populate(NULL, u8500_soc_node, u8500_auxdata_lookup, parent);
  673. if (of_machine_is_compatible("st-ericsson,mop500")) {
  674. mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
  675. mop500_pins_init();
  676. platform_add_devices(mop500_platform_devs,
  677. ARRAY_SIZE(mop500_platform_devs));
  678. mop500_sdi_init(parent);
  679. } else if (of_machine_is_compatible("calaosystems,snowball-a9500")) {
  680. snowball_pins_init();
  681. platform_add_devices(snowball_platform_devs,
  682. ARRAY_SIZE(snowball_platform_devs));
  683. snowball_sdi_init(parent);
  684. } else if (of_machine_is_compatible("st-ericsson,hrefv60+")) {
  685. /*
  686. * The HREFv60 board removed a GPIO expander and routed
  687. * all these GPIO pins to the internal GPIO controller
  688. * instead.
  689. */
  690. mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
  691. i2c0_devs -= NUM_PRE_V60_I2C0_DEVICES;
  692. hrefv60_pins_init();
  693. platform_add_devices(mop500_platform_devs,
  694. ARRAY_SIZE(mop500_platform_devs));
  695. hrefv60_sdi_init(parent);
  696. }
  697. mop500_i2c_init(parent);
  698. i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
  699. i2c_register_board_info(2, mop500_i2c2_devices,
  700. ARRAY_SIZE(mop500_i2c2_devices));
  701. /* This board has full regulator constraints */
  702. regulator_has_full_constraints();
  703. }
  704. static const char * u8500_dt_board_compat[] = {
  705. "calaosystems,snowball-a9500",
  706. "st-ericsson,hrefv60+",
  707. "st-ericsson,u8500",
  708. "st-ericsson,mop500",
  709. NULL,
  710. };
  711. DT_MACHINE_START(U8500_DT, "ST-Ericsson U8500 platform (Device Tree Support)")
  712. .map_io = u8500_map_io,
  713. .init_irq = ux500_init_irq,
  714. /* we re-use nomadik timer here */
  715. .timer = &ux500_timer,
  716. .handle_irq = gic_handle_irq,
  717. .init_machine = u8500_init_machine,
  718. .dt_compat = u8500_dt_board_compat,
  719. MACHINE_END
  720. #endif