core.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  1. /*
  2. *
  3. * arch/arm/mach-u300/core.c
  4. *
  5. *
  6. * Copyright (C) 2007-2012 ST-Ericsson SA
  7. * License terms: GNU General Public License (GPL) version 2
  8. * Core platform support, IRQ handling and device definitions.
  9. * Author: Linus Walleij <linus.walleij@stericsson.com>
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/spinlock.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/bitops.h>
  16. #include <linux/device.h>
  17. #include <linux/mm.h>
  18. #include <linux/termios.h>
  19. #include <linux/dmaengine.h>
  20. #include <linux/amba/bus.h>
  21. #include <linux/amba/mmci.h>
  22. #include <linux/amba/pl022.h>
  23. #include <linux/amba/serial.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/gpio.h>
  26. #include <linux/clk.h>
  27. #include <linux/err.h>
  28. #include <linux/mtd/nand.h>
  29. #include <linux/mtd/fsmc.h>
  30. #include <linux/pinctrl/machine.h>
  31. #include <linux/pinctrl/pinconf-generic.h>
  32. #include <linux/dma-mapping.h>
  33. #include <linux/platform_data/clk-u300.h>
  34. #include <linux/platform_data/pinctrl-coh901.h>
  35. #include <linux/platform_data/dma-coh901318.h>
  36. #include <linux/irqchip/arm-vic.h>
  37. #include <linux/irqchip.h>
  38. #include <linux/of_platform.h>
  39. #include <linux/clocksource.h>
  40. #include <asm/types.h>
  41. #include <asm/setup.h>
  42. #include <asm/memory.h>
  43. #include <asm/mach/map.h>
  44. #include <asm/mach-types.h>
  45. #include <asm/mach/arch.h>
  46. #include <mach/hardware.h>
  47. #include <mach/syscon.h>
  48. #include <mach/irqs.h>
  49. #include "timer.h"
  50. #include "spi.h"
  51. #include "i2c.h"
  52. #include "u300-gpio.h"
  53. /*
  54. * Static I/O mappings that are needed for booting the U300 platforms. The
  55. * only things we need are the areas where we find the timer, syscon and
  56. * intcon, since the remaining device drivers will map their own memory
  57. * physical to virtual as the need arise.
  58. */
  59. static struct map_desc u300_io_desc[] __initdata = {
  60. {
  61. .virtual = U300_SLOW_PER_VIRT_BASE,
  62. .pfn = __phys_to_pfn(U300_SLOW_PER_PHYS_BASE),
  63. .length = SZ_64K,
  64. .type = MT_DEVICE,
  65. },
  66. {
  67. .virtual = U300_AHB_PER_VIRT_BASE,
  68. .pfn = __phys_to_pfn(U300_AHB_PER_PHYS_BASE),
  69. .length = SZ_32K,
  70. .type = MT_DEVICE,
  71. },
  72. {
  73. .virtual = U300_FAST_PER_VIRT_BASE,
  74. .pfn = __phys_to_pfn(U300_FAST_PER_PHYS_BASE),
  75. .length = SZ_32K,
  76. .type = MT_DEVICE,
  77. },
  78. };
  79. static void __init u300_map_io(void)
  80. {
  81. iotable_init(u300_io_desc, ARRAY_SIZE(u300_io_desc));
  82. }
  83. /*
  84. * Declaration of devices found on the U300 board and
  85. * their respective memory locations.
  86. */
  87. static struct amba_pl011_data uart0_plat_data = {
  88. #ifdef CONFIG_COH901318
  89. .dma_filter = coh901318_filter_id,
  90. .dma_rx_param = (void *) U300_DMA_UART0_RX,
  91. .dma_tx_param = (void *) U300_DMA_UART0_TX,
  92. #endif
  93. };
  94. /* Slow device at 0x3000 offset */
  95. static AMBA_APB_DEVICE(uart0, "uart0", 0, U300_UART0_BASE,
  96. { IRQ_U300_UART0 }, &uart0_plat_data);
  97. /* The U335 have an additional UART1 on the APP CPU */
  98. static struct amba_pl011_data uart1_plat_data = {
  99. #ifdef CONFIG_COH901318
  100. .dma_filter = coh901318_filter_id,
  101. .dma_rx_param = (void *) U300_DMA_UART1_RX,
  102. .dma_tx_param = (void *) U300_DMA_UART1_TX,
  103. #endif
  104. };
  105. /* Fast device at 0x7000 offset */
  106. static AMBA_APB_DEVICE(uart1, "uart1", 0, U300_UART1_BASE,
  107. { IRQ_U300_UART1 }, &uart1_plat_data);
  108. /* AHB device at 0x4000 offset */
  109. static AMBA_APB_DEVICE(pl172, "pl172", 0, U300_EMIF_CFG_BASE, { }, NULL);
  110. /* Fast device at 0x6000 offset */
  111. static AMBA_APB_DEVICE(pl022, "pl022", 0, U300_SPI_BASE,
  112. { IRQ_U300_SPI }, NULL);
  113. /* Fast device at 0x1000 offset */
  114. #define U300_MMCSD_IRQS { IRQ_U300_MMCSD_MCIINTR0, IRQ_U300_MMCSD_MCIINTR1 }
  115. static struct mmci_platform_data mmcsd_platform_data = {
  116. /*
  117. * Do not set ocr_mask or voltage translation function,
  118. * we have a regulator we can control instead.
  119. */
  120. .f_max = 24000000,
  121. .gpio_wp = -1,
  122. .gpio_cd = U300_GPIO_PIN_MMC_CD,
  123. .cd_invert = true,
  124. .capabilities = MMC_CAP_MMC_HIGHSPEED |
  125. MMC_CAP_SD_HIGHSPEED | MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
  126. #ifdef CONFIG_COH901318
  127. .dma_filter = coh901318_filter_id,
  128. .dma_rx_param = (void *) U300_DMA_MMCSD_RX_TX,
  129. /* Don't specify a TX channel, this RX channel is bidirectional */
  130. #endif
  131. };
  132. static AMBA_APB_DEVICE(mmcsd, "mmci", 0, U300_MMCSD_BASE,
  133. U300_MMCSD_IRQS, &mmcsd_platform_data);
  134. /*
  135. * The order of device declaration may be important, since some devices
  136. * have dependencies on other devices being initialized first.
  137. */
  138. static struct amba_device *amba_devs[] __initdata = {
  139. &uart0_device,
  140. &uart1_device,
  141. &pl022_device,
  142. &pl172_device,
  143. &mmcsd_device,
  144. };
  145. /* Here follows a list of all hw resources that the platform devices
  146. * allocate. Note, clock dependencies are not included
  147. */
  148. static struct resource gpio_resources[] = {
  149. {
  150. .start = U300_GPIO_BASE,
  151. .end = (U300_GPIO_BASE + SZ_4K - 1),
  152. .flags = IORESOURCE_MEM,
  153. },
  154. {
  155. .name = "gpio0",
  156. .start = IRQ_U300_GPIO_PORT0,
  157. .end = IRQ_U300_GPIO_PORT0,
  158. .flags = IORESOURCE_IRQ,
  159. },
  160. {
  161. .name = "gpio1",
  162. .start = IRQ_U300_GPIO_PORT1,
  163. .end = IRQ_U300_GPIO_PORT1,
  164. .flags = IORESOURCE_IRQ,
  165. },
  166. {
  167. .name = "gpio2",
  168. .start = IRQ_U300_GPIO_PORT2,
  169. .end = IRQ_U300_GPIO_PORT2,
  170. .flags = IORESOURCE_IRQ,
  171. },
  172. {
  173. .name = "gpio3",
  174. .start = IRQ_U300_GPIO_PORT3,
  175. .end = IRQ_U300_GPIO_PORT3,
  176. .flags = IORESOURCE_IRQ,
  177. },
  178. {
  179. .name = "gpio4",
  180. .start = IRQ_U300_GPIO_PORT4,
  181. .end = IRQ_U300_GPIO_PORT4,
  182. .flags = IORESOURCE_IRQ,
  183. },
  184. {
  185. .name = "gpio5",
  186. .start = IRQ_U300_GPIO_PORT5,
  187. .end = IRQ_U300_GPIO_PORT5,
  188. .flags = IORESOURCE_IRQ,
  189. },
  190. {
  191. .name = "gpio6",
  192. .start = IRQ_U300_GPIO_PORT6,
  193. .end = IRQ_U300_GPIO_PORT6,
  194. .flags = IORESOURCE_IRQ,
  195. },
  196. };
  197. static struct resource keypad_resources[] = {
  198. {
  199. .start = U300_KEYPAD_BASE,
  200. .end = U300_KEYPAD_BASE + SZ_4K - 1,
  201. .flags = IORESOURCE_MEM,
  202. },
  203. {
  204. .name = "coh901461-press",
  205. .start = IRQ_U300_KEYPAD_KEYBF,
  206. .end = IRQ_U300_KEYPAD_KEYBF,
  207. .flags = IORESOURCE_IRQ,
  208. },
  209. {
  210. .name = "coh901461-release",
  211. .start = IRQ_U300_KEYPAD_KEYBR,
  212. .end = IRQ_U300_KEYPAD_KEYBR,
  213. .flags = IORESOURCE_IRQ,
  214. },
  215. };
  216. static struct resource rtc_resources[] = {
  217. {
  218. .start = U300_RTC_BASE,
  219. .end = U300_RTC_BASE + SZ_4K - 1,
  220. .flags = IORESOURCE_MEM,
  221. },
  222. {
  223. .start = IRQ_U300_RTC,
  224. .end = IRQ_U300_RTC,
  225. .flags = IORESOURCE_IRQ,
  226. },
  227. };
  228. /*
  229. * Fsmc does have IRQs: #43 and #44 (NFIF and NFIF2)
  230. * but these are not yet used by the driver.
  231. */
  232. static struct resource fsmc_resources[] = {
  233. {
  234. .name = "nand_addr",
  235. .start = U300_NAND_CS0_PHYS_BASE + PLAT_NAND_ALE,
  236. .end = U300_NAND_CS0_PHYS_BASE + PLAT_NAND_ALE + SZ_16K - 1,
  237. .flags = IORESOURCE_MEM,
  238. },
  239. {
  240. .name = "nand_cmd",
  241. .start = U300_NAND_CS0_PHYS_BASE + PLAT_NAND_CLE,
  242. .end = U300_NAND_CS0_PHYS_BASE + PLAT_NAND_CLE + SZ_16K - 1,
  243. .flags = IORESOURCE_MEM,
  244. },
  245. {
  246. .name = "nand_data",
  247. .start = U300_NAND_CS0_PHYS_BASE,
  248. .end = U300_NAND_CS0_PHYS_BASE + SZ_16K - 1,
  249. .flags = IORESOURCE_MEM,
  250. },
  251. {
  252. .name = "fsmc_regs",
  253. .start = U300_NAND_IF_PHYS_BASE,
  254. .end = U300_NAND_IF_PHYS_BASE + SZ_4K - 1,
  255. .flags = IORESOURCE_MEM,
  256. },
  257. };
  258. static struct resource i2c0_resources[] = {
  259. {
  260. .start = U300_I2C0_BASE,
  261. .end = U300_I2C0_BASE + SZ_4K - 1,
  262. .flags = IORESOURCE_MEM,
  263. },
  264. {
  265. .start = IRQ_U300_I2C0,
  266. .end = IRQ_U300_I2C0,
  267. .flags = IORESOURCE_IRQ,
  268. },
  269. };
  270. static struct resource i2c1_resources[] = {
  271. {
  272. .start = U300_I2C1_BASE,
  273. .end = U300_I2C1_BASE + SZ_4K - 1,
  274. .flags = IORESOURCE_MEM,
  275. },
  276. {
  277. .start = IRQ_U300_I2C1,
  278. .end = IRQ_U300_I2C1,
  279. .flags = IORESOURCE_IRQ,
  280. },
  281. };
  282. static struct resource wdog_resources[] = {
  283. {
  284. .start = U300_WDOG_BASE,
  285. .end = U300_WDOG_BASE + SZ_4K - 1,
  286. .flags = IORESOURCE_MEM,
  287. },
  288. {
  289. .start = IRQ_U300_WDOG,
  290. .end = IRQ_U300_WDOG,
  291. .flags = IORESOURCE_IRQ,
  292. }
  293. };
  294. static struct resource dma_resource[] = {
  295. {
  296. .start = U300_DMAC_BASE,
  297. .end = U300_DMAC_BASE + PAGE_SIZE - 1,
  298. .flags = IORESOURCE_MEM,
  299. },
  300. {
  301. .start = IRQ_U300_DMA,
  302. .end = IRQ_U300_DMA,
  303. .flags = IORESOURCE_IRQ,
  304. }
  305. };
  306. static struct resource pinctrl_resources[] = {
  307. {
  308. .start = U300_SYSCON_BASE,
  309. .end = U300_SYSCON_BASE + SZ_4K - 1,
  310. .flags = IORESOURCE_MEM,
  311. },
  312. };
  313. static struct platform_device wdog_device = {
  314. .name = "coh901327_wdog",
  315. .id = -1,
  316. .num_resources = ARRAY_SIZE(wdog_resources),
  317. .resource = wdog_resources,
  318. };
  319. static struct platform_device i2c0_device = {
  320. .name = "stu300",
  321. .id = 0,
  322. .num_resources = ARRAY_SIZE(i2c0_resources),
  323. .resource = i2c0_resources,
  324. };
  325. static struct platform_device i2c1_device = {
  326. .name = "stu300",
  327. .id = 1,
  328. .num_resources = ARRAY_SIZE(i2c1_resources),
  329. .resource = i2c1_resources,
  330. };
  331. static struct platform_device pinctrl_device = {
  332. .name = "pinctrl-u300",
  333. .id = -1,
  334. .num_resources = ARRAY_SIZE(pinctrl_resources),
  335. .resource = pinctrl_resources,
  336. };
  337. /*
  338. * The different variants have a few different versions of the
  339. * GPIO block, with different number of ports.
  340. */
  341. static struct u300_gpio_platform u300_gpio_plat = {
  342. .ports = 7,
  343. .gpio_base = 0,
  344. };
  345. static struct platform_device gpio_device = {
  346. .name = "u300-gpio",
  347. .id = -1,
  348. .num_resources = ARRAY_SIZE(gpio_resources),
  349. .resource = gpio_resources,
  350. .dev = {
  351. .platform_data = &u300_gpio_plat,
  352. },
  353. };
  354. static struct platform_device keypad_device = {
  355. .name = "keypad",
  356. .id = -1,
  357. .num_resources = ARRAY_SIZE(keypad_resources),
  358. .resource = keypad_resources,
  359. };
  360. static struct platform_device rtc_device = {
  361. .name = "rtc-coh901331",
  362. .id = -1,
  363. .num_resources = ARRAY_SIZE(rtc_resources),
  364. .resource = rtc_resources,
  365. };
  366. static struct mtd_partition u300_partitions[] = {
  367. {
  368. .name = "bootrecords",
  369. .offset = 0,
  370. .size = SZ_128K,
  371. },
  372. {
  373. .name = "free",
  374. .offset = SZ_128K,
  375. .size = 8064 * SZ_1K,
  376. },
  377. {
  378. .name = "platform",
  379. .offset = 8192 * SZ_1K,
  380. .size = 253952 * SZ_1K,
  381. },
  382. };
  383. static struct fsmc_nand_platform_data nand_platform_data = {
  384. .partitions = u300_partitions,
  385. .nr_partitions = ARRAY_SIZE(u300_partitions),
  386. .options = NAND_SKIP_BBTSCAN,
  387. .width = FSMC_NAND_BW8,
  388. };
  389. static struct platform_device nand_device = {
  390. .name = "fsmc-nand",
  391. .id = -1,
  392. .resource = fsmc_resources,
  393. .num_resources = ARRAY_SIZE(fsmc_resources),
  394. .dev = {
  395. .platform_data = &nand_platform_data,
  396. },
  397. };
  398. static struct platform_device dma_device = {
  399. .name = "coh901318",
  400. .id = -1,
  401. .resource = dma_resource,
  402. .num_resources = ARRAY_SIZE(dma_resource),
  403. .dev = {
  404. .coherent_dma_mask = ~0,
  405. },
  406. };
  407. static unsigned long pin_pullup_conf[] = {
  408. PIN_CONF_PACKED(PIN_CONFIG_BIAS_PULL_UP, 1),
  409. };
  410. static unsigned long pin_highz_conf[] = {
  411. PIN_CONF_PACKED(PIN_CONFIG_BIAS_HIGH_IMPEDANCE, 0),
  412. };
  413. /* Pin control settings */
  414. static struct pinctrl_map __initdata u300_pinmux_map[] = {
  415. /* anonymous maps for chip power and EMIFs */
  416. PIN_MAP_MUX_GROUP_HOG_DEFAULT("pinctrl-u300", NULL, "power"),
  417. PIN_MAP_MUX_GROUP_HOG_DEFAULT("pinctrl-u300", NULL, "emif0"),
  418. PIN_MAP_MUX_GROUP_HOG_DEFAULT("pinctrl-u300", NULL, "emif1"),
  419. /* per-device maps for MMC/SD, SPI and UART */
  420. PIN_MAP_MUX_GROUP_DEFAULT("mmci", "pinctrl-u300", NULL, "mmc0"),
  421. PIN_MAP_MUX_GROUP_DEFAULT("pl022", "pinctrl-u300", NULL, "spi0"),
  422. PIN_MAP_MUX_GROUP_DEFAULT("uart0", "pinctrl-u300", NULL, "uart0"),
  423. /* This pin is used for clock return rather than GPIO */
  424. PIN_MAP_CONFIGS_PIN_DEFAULT("mmci", "pinctrl-u300", "PIO APP GPIO 11",
  425. pin_pullup_conf),
  426. /* This pin is used for card detect */
  427. PIN_MAP_CONFIGS_PIN_DEFAULT("mmci", "pinctrl-u300", "PIO MS INS",
  428. pin_highz_conf),
  429. };
  430. /*
  431. * Notice that AMBA devices are initialized before platform devices.
  432. *
  433. */
  434. static struct platform_device *platform_devs[] __initdata = {
  435. &dma_device,
  436. &i2c0_device,
  437. &i2c1_device,
  438. &keypad_device,
  439. &rtc_device,
  440. &pinctrl_device,
  441. &gpio_device,
  442. &nand_device,
  443. &wdog_device,
  444. };
  445. /*
  446. * Interrupts: the U300 platforms have two pl190 ARM PrimeCells connected
  447. * together so some interrupts are connected to the first one and some
  448. * to the second one.
  449. */
  450. static void __init u300_init_irq(void)
  451. {
  452. u32 mask[2] = {0, 0};
  453. struct clk *clk;
  454. int i;
  455. /* initialize clocking early, we want to clock the INTCON */
  456. u300_clk_init(U300_SYSCON_VBASE);
  457. /* Bootstrap EMIF and SEMI clocks */
  458. clk = clk_get_sys("pl172", NULL);
  459. BUG_ON(IS_ERR(clk));
  460. clk_prepare_enable(clk);
  461. clk = clk_get_sys("semi", NULL);
  462. BUG_ON(IS_ERR(clk));
  463. clk_prepare_enable(clk);
  464. /* Clock the interrupt controller */
  465. clk = clk_get_sys("intcon", NULL);
  466. BUG_ON(IS_ERR(clk));
  467. clk_prepare_enable(clk);
  468. for (i = 0; i < U300_VIC_IRQS_END; i++)
  469. set_bit(i, (unsigned long *) &mask[0]);
  470. vic_init((void __iomem *) U300_INTCON0_VBASE, IRQ_U300_INTCON0_START,
  471. mask[0], mask[0]);
  472. vic_init((void __iomem *) U300_INTCON1_VBASE, IRQ_U300_INTCON1_START,
  473. mask[1], mask[1]);
  474. }
  475. /*
  476. * U300 platforms peripheral handling
  477. */
  478. struct db_chip {
  479. u16 chipid;
  480. const char *name;
  481. };
  482. /*
  483. * This is a list of the Digital Baseband chips used in the U300 platform.
  484. */
  485. static struct db_chip db_chips[] __initdata = {
  486. {
  487. .chipid = 0xb800,
  488. .name = "DB3000",
  489. },
  490. {
  491. .chipid = 0xc000,
  492. .name = "DB3100",
  493. },
  494. {
  495. .chipid = 0xc800,
  496. .name = "DB3150",
  497. },
  498. {
  499. .chipid = 0xd800,
  500. .name = "DB3200",
  501. },
  502. {
  503. .chipid = 0xe000,
  504. .name = "DB3250",
  505. },
  506. {
  507. .chipid = 0xe800,
  508. .name = "DB3210",
  509. },
  510. {
  511. .chipid = 0xf000,
  512. .name = "DB3350 P1x",
  513. },
  514. {
  515. .chipid = 0xf100,
  516. .name = "DB3350 P2x",
  517. },
  518. {
  519. .chipid = 0x0000, /* List terminator */
  520. .name = NULL,
  521. }
  522. };
  523. static void __init u300_init_check_chip(void)
  524. {
  525. u16 val;
  526. struct db_chip *chip;
  527. const char *chipname;
  528. const char unknown[] = "UNKNOWN";
  529. /* Read out and print chip ID */
  530. val = readw(U300_SYSCON_VBASE + U300_SYSCON_CIDR);
  531. /* This is in funky bigendian order... */
  532. val = (val & 0xFFU) << 8 | (val >> 8);
  533. chip = db_chips;
  534. chipname = unknown;
  535. for ( ; chip->chipid; chip++) {
  536. if (chip->chipid == (val & 0xFF00U)) {
  537. chipname = chip->name;
  538. break;
  539. }
  540. }
  541. printk(KERN_INFO "Initializing U300 system on %s baseband chip " \
  542. "(chip ID 0x%04x)\n", chipname, val);
  543. if ((val & 0xFF00U) != 0xf000 && (val & 0xFF00U) != 0xf100) {
  544. printk(KERN_ERR "Platform configured for BS335 " \
  545. " with DB3350 but %s detected, expect problems!",
  546. chipname);
  547. }
  548. }
  549. /*
  550. * Some devices and their resources require reserved physical memory from
  551. * the end of the available RAM. This function traverses the list of devices
  552. * and assigns actual addresses to these.
  553. */
  554. static void __init u300_assign_physmem(void)
  555. {
  556. unsigned long curr_start = __pa(high_memory);
  557. int i, j;
  558. for (i = 0; i < ARRAY_SIZE(platform_devs); i++) {
  559. for (j = 0; j < platform_devs[i]->num_resources; j++) {
  560. struct resource *const res =
  561. &platform_devs[i]->resource[j];
  562. if (IORESOURCE_MEM == res->flags &&
  563. 0 == res->start) {
  564. res->start = curr_start;
  565. res->end += curr_start;
  566. curr_start += resource_size(res);
  567. printk(KERN_INFO "core.c: Mapping RAM " \
  568. "%#x-%#x to device %s:%s\n",
  569. res->start, res->end,
  570. platform_devs[i]->name, res->name);
  571. }
  572. }
  573. }
  574. }
  575. static void __init u300_init_machine(void)
  576. {
  577. int i;
  578. u16 val;
  579. /* Check what platform we run and print some status information */
  580. u300_init_check_chip();
  581. /* Initialize SPI device with some board specifics */
  582. u300_spi_init(&pl022_device);
  583. /* Register the AMBA devices in the AMBA bus abstraction layer */
  584. for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
  585. struct amba_device *d = amba_devs[i];
  586. amba_device_register(d, &iomem_resource);
  587. }
  588. u300_assign_physmem();
  589. /* Initialize pinmuxing */
  590. pinctrl_register_mappings(u300_pinmux_map,
  591. ARRAY_SIZE(u300_pinmux_map));
  592. /* Register subdevices on the I2C buses */
  593. u300_i2c_register_board_devices();
  594. /* Register the platform devices */
  595. platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
  596. /* Register subdevices on the SPI bus */
  597. u300_spi_register_board_devices();
  598. /* Enable SEMI self refresh */
  599. val = readw(U300_SYSCON_VBASE + U300_SYSCON_SMCR) |
  600. U300_SYSCON_SMCR_SEMI_SREFREQ_ENABLE;
  601. writew(val, U300_SYSCON_VBASE + U300_SYSCON_SMCR);
  602. }
  603. /* Forward declare this function from the watchdog */
  604. void coh901327_watchdog_reset(void);
  605. static void u300_restart(char mode, const char *cmd)
  606. {
  607. switch (mode) {
  608. case 's':
  609. case 'h':
  610. #ifdef CONFIG_COH901327_WATCHDOG
  611. coh901327_watchdog_reset();
  612. #endif
  613. break;
  614. default:
  615. /* Do nothing */
  616. break;
  617. }
  618. /* Wait for system do die/reset. */
  619. while (1);
  620. }
  621. MACHINE_START(U300, "Ericsson AB U335 S335/B335 Prototype Board")
  622. /* Maintainer: Linus Walleij <linus.walleij@stericsson.com> */
  623. .atag_offset = 0x100,
  624. .map_io = u300_map_io,
  625. .nr_irqs = 0,
  626. .init_irq = u300_init_irq,
  627. .init_time = u300_timer_init,
  628. .init_machine = u300_init_machine,
  629. .restart = u300_restart,
  630. MACHINE_END
  631. #ifdef CONFIG_OF
  632. static struct pl022_ssp_controller spi_plat_data = {
  633. /* If you have several SPI buses this varies, we have only bus 0 */
  634. .bus_id = 0,
  635. /*
  636. * On the APP CPU GPIO 4, 5 and 6 are connected as generic
  637. * chip selects for SPI. (Same on U330, U335 and U365.)
  638. * TODO: make sure the GPIO driver can select these properly
  639. * and do padmuxing accordingly too.
  640. */
  641. .num_chipselect = 3,
  642. .enable_dma = 1,
  643. .dma_filter = coh901318_filter_id,
  644. .dma_rx_param = (void *) U300_DMA_SPI_RX,
  645. .dma_tx_param = (void *) U300_DMA_SPI_TX,
  646. };
  647. /* These are mostly to get the right device names for the clock lookups */
  648. static struct of_dev_auxdata u300_auxdata_lookup[] __initdata = {
  649. OF_DEV_AUXDATA("stericsson,pinctrl-u300", U300_SYSCON_BASE,
  650. "pinctrl-u300", NULL),
  651. OF_DEV_AUXDATA("stericsson,gpio-coh901", U300_GPIO_BASE,
  652. "u300-gpio", &u300_gpio_plat),
  653. OF_DEV_AUXDATA("stericsson,coh901327", U300_WDOG_BASE,
  654. "coh901327_wdog", NULL),
  655. OF_DEV_AUXDATA("stericsson,coh901331", U300_RTC_BASE,
  656. "rtc-coh901331", NULL),
  657. OF_DEV_AUXDATA("stericsson,coh901318", U300_DMAC_BASE,
  658. "coh901318", NULL),
  659. OF_DEV_AUXDATA("stericsson,fsmc-nand", U300_NAND_IF_PHYS_BASE,
  660. "fsmc-nand", NULL),
  661. OF_DEV_AUXDATA("arm,primecell", U300_UART0_BASE,
  662. "uart0", &uart0_plat_data),
  663. OF_DEV_AUXDATA("arm,primecell", U300_UART1_BASE,
  664. "uart1", &uart1_plat_data),
  665. OF_DEV_AUXDATA("arm,primecell", U300_SPI_BASE,
  666. "pl022", &spi_plat_data),
  667. OF_DEV_AUXDATA("st,ddci2c", U300_I2C0_BASE,
  668. "stu300.0", NULL),
  669. OF_DEV_AUXDATA("st,ddci2c", U300_I2C1_BASE,
  670. "stu300.1", NULL),
  671. OF_DEV_AUXDATA("arm,primecell", U300_MMCSD_BASE,
  672. "mmci", &mmcsd_platform_data),
  673. { /* sentinel */ },
  674. };
  675. static void __init u300_init_irq_dt(void)
  676. {
  677. struct clk *clk;
  678. /* initialize clocking early, we want to clock the INTCON */
  679. u300_clk_init(U300_SYSCON_VBASE);
  680. /* Bootstrap EMIF and SEMI clocks */
  681. clk = clk_get_sys("pl172", NULL);
  682. BUG_ON(IS_ERR(clk));
  683. clk_prepare_enable(clk);
  684. clk = clk_get_sys("semi", NULL);
  685. BUG_ON(IS_ERR(clk));
  686. clk_prepare_enable(clk);
  687. /* Clock the interrupt controller */
  688. clk = clk_get_sys("intcon", NULL);
  689. BUG_ON(IS_ERR(clk));
  690. clk_prepare_enable(clk);
  691. irqchip_init();
  692. }
  693. static void __init u300_init_machine_dt(void)
  694. {
  695. u16 val;
  696. /* Check what platform we run and print some status information */
  697. u300_init_check_chip();
  698. u300_assign_physmem();
  699. /* Initialize pinmuxing */
  700. pinctrl_register_mappings(u300_pinmux_map,
  701. ARRAY_SIZE(u300_pinmux_map));
  702. of_platform_populate(NULL, of_default_bus_match_table,
  703. u300_auxdata_lookup, NULL);
  704. /* Enable SEMI self refresh */
  705. val = readw(U300_SYSCON_VBASE + U300_SYSCON_SMCR) |
  706. U300_SYSCON_SMCR_SEMI_SREFREQ_ENABLE;
  707. writew(val, U300_SYSCON_VBASE + U300_SYSCON_SMCR);
  708. }
  709. static const char * u300_board_compat[] = {
  710. "stericsson,u300",
  711. NULL,
  712. };
  713. DT_MACHINE_START(U300_DT, "U300 S335/B335 (Device Tree)")
  714. .map_io = u300_map_io,
  715. .init_irq = u300_init_irq_dt,
  716. .init_time = clocksource_of_init,
  717. .init_machine = u300_init_machine_dt,
  718. .restart = u300_restart,
  719. .dt_compat = u300_board_compat,
  720. MACHINE_END
  721. #endif /* CONFIG_OF */