board-mop500.c 24 KB

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