core.c 18 KB

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