core.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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/pinctrl/machine.h>
  13. #include <linux/pinctrl/pinconf-generic.h>
  14. #include <linux/platform_data/clk-u300.h>
  15. #include <linux/irqchip.h>
  16. #include <linux/of_address.h>
  17. #include <linux/of_platform.h>
  18. #include <linux/clocksource.h>
  19. #include <linux/clk.h>
  20. #include <asm/mach/map.h>
  21. #include <asm/mach/arch.h>
  22. /*
  23. * These are the large blocks of memory allocated for I/O.
  24. * the defines are used for setting up the I/O memory mapping.
  25. */
  26. /* NAND Flash CS0 */
  27. #define U300_NAND_CS0_PHYS_BASE 0x80000000
  28. /* NFIF */
  29. #define U300_NAND_IF_PHYS_BASE 0x9f800000
  30. /* ALE, CLE offset for FSMC NAND */
  31. #define PLAT_NAND_CLE (1 << 16)
  32. #define PLAT_NAND_ALE (1 << 17)
  33. /* AHB Peripherals */
  34. #define U300_AHB_PER_PHYS_BASE 0xa0000000
  35. #define U300_AHB_PER_VIRT_BASE 0xff010000
  36. /* FAST Peripherals */
  37. #define U300_FAST_PER_PHYS_BASE 0xc0000000
  38. #define U300_FAST_PER_VIRT_BASE 0xff020000
  39. /* SLOW Peripherals */
  40. #define U300_SLOW_PER_PHYS_BASE 0xc0010000
  41. #define U300_SLOW_PER_VIRT_BASE 0xff000000
  42. /* Boot ROM */
  43. #define U300_BOOTROM_PHYS_BASE 0xffff0000
  44. #define U300_BOOTROM_VIRT_BASE 0xffff0000
  45. /* SEMI config base */
  46. #define U300_SEMI_CONFIG_BASE 0x2FFE0000
  47. /*
  48. * AHB peripherals
  49. */
  50. /* AHB Peripherals Bridge Controller */
  51. #define U300_AHB_BRIDGE_BASE (U300_AHB_PER_PHYS_BASE+0x0000)
  52. /* Vectored Interrupt Controller 0, servicing 32 interrupts */
  53. #define U300_INTCON0_BASE (U300_AHB_PER_PHYS_BASE+0x1000)
  54. #define U300_INTCON0_VBASE IOMEM(U300_AHB_PER_VIRT_BASE+0x1000)
  55. /* Vectored Interrupt Controller 1, servicing 32 interrupts */
  56. #define U300_INTCON1_BASE (U300_AHB_PER_PHYS_BASE+0x2000)
  57. #define U300_INTCON1_VBASE IOMEM(U300_AHB_PER_VIRT_BASE+0x2000)
  58. /* Memory Stick Pro (MSPRO) controller */
  59. #define U300_MSPRO_BASE (U300_AHB_PER_PHYS_BASE+0x3000)
  60. /* EMIF Configuration Area */
  61. #define U300_EMIF_CFG_BASE (U300_AHB_PER_PHYS_BASE+0x4000)
  62. /*
  63. * FAST peripherals
  64. */
  65. /* FAST bridge control */
  66. #define U300_FAST_BRIDGE_BASE (U300_FAST_PER_PHYS_BASE+0x0000)
  67. /* MMC/SD controller */
  68. #define U300_MMCSD_BASE (U300_FAST_PER_PHYS_BASE+0x1000)
  69. /* PCM I2S0 controller */
  70. #define U300_PCM_I2S0_BASE (U300_FAST_PER_PHYS_BASE+0x2000)
  71. /* PCM I2S1 controller */
  72. #define U300_PCM_I2S1_BASE (U300_FAST_PER_PHYS_BASE+0x3000)
  73. /* I2C0 controller */
  74. #define U300_I2C0_BASE (U300_FAST_PER_PHYS_BASE+0x4000)
  75. /* I2C1 controller */
  76. #define U300_I2C1_BASE (U300_FAST_PER_PHYS_BASE+0x5000)
  77. /* SPI controller */
  78. #define U300_SPI_BASE (U300_FAST_PER_PHYS_BASE+0x6000)
  79. /* Fast UART1 on U335 only */
  80. #define U300_UART1_BASE (U300_FAST_PER_PHYS_BASE+0x7000)
  81. /*
  82. * SLOW peripherals
  83. */
  84. /* SLOW bridge control */
  85. #define U300_SLOW_BRIDGE_BASE (U300_SLOW_PER_PHYS_BASE)
  86. /* SYSCON */
  87. #define U300_SYSCON_BASE (U300_SLOW_PER_PHYS_BASE+0x1000)
  88. #define U300_SYSCON_VBASE IOMEM(U300_SLOW_PER_VIRT_BASE+0x1000)
  89. /* Watchdog */
  90. #define U300_WDOG_BASE (U300_SLOW_PER_PHYS_BASE+0x2000)
  91. /* UART0 */
  92. #define U300_UART0_BASE (U300_SLOW_PER_PHYS_BASE+0x3000)
  93. /* APP side special timer */
  94. #define U300_TIMER_APP_BASE (U300_SLOW_PER_PHYS_BASE+0x4000)
  95. #define U300_TIMER_APP_VBASE IOMEM(U300_SLOW_PER_VIRT_BASE+0x4000)
  96. /* Keypad */
  97. #define U300_KEYPAD_BASE (U300_SLOW_PER_PHYS_BASE+0x5000)
  98. /* GPIO */
  99. #define U300_GPIO_BASE (U300_SLOW_PER_PHYS_BASE+0x6000)
  100. /* RTC */
  101. #define U300_RTC_BASE (U300_SLOW_PER_PHYS_BASE+0x7000)
  102. /* Bus tracer */
  103. #define U300_BUSTR_BASE (U300_SLOW_PER_PHYS_BASE+0x8000)
  104. /* Event handler (hardware queue) */
  105. #define U300_EVHIST_BASE (U300_SLOW_PER_PHYS_BASE+0x9000)
  106. /* Genric Timer */
  107. #define U300_TIMER_BASE (U300_SLOW_PER_PHYS_BASE+0xa000)
  108. /* PPM */
  109. #define U300_PPM_BASE (U300_SLOW_PER_PHYS_BASE+0xb000)
  110. /*
  111. * REST peripherals
  112. */
  113. /* ISP (image signal processor) */
  114. #define U300_ISP_BASE (0xA0008000)
  115. /* DMA Controller base */
  116. #define U300_DMAC_BASE (0xC0020000)
  117. /* MSL Base */
  118. #define U300_MSL_BASE (0xc0022000)
  119. /* APEX Base */
  120. #define U300_APEX_BASE (0xc0030000)
  121. /* Video Encoder Base */
  122. #define U300_VIDEOENC_BASE (0xc0080000)
  123. /* XGAM Base */
  124. #define U300_XGAM_BASE (0xd0000000)
  125. /*
  126. * SYSCON addresses applicable to the core machine.
  127. */
  128. /* Chip ID register 16bit (R/-) */
  129. #define U300_SYSCON_CIDR (0x400)
  130. /* SMCR */
  131. #define U300_SYSCON_SMCR (0x4d0)
  132. #define U300_SYSCON_SMCR_FIELD_MASK (0x000e)
  133. #define U300_SYSCON_SMCR_SEMI_SREFACK_IND (0x0008)
  134. #define U300_SYSCON_SMCR_SEMI_SREFREQ_ENABLE (0x0004)
  135. #define U300_SYSCON_SMCR_SEMI_EXT_BOOT_MODE_ENABLE (0x0002)
  136. /* CPU_SW_DBGEN Software Debug Enable 16bit (R/W) */
  137. #define U300_SYSCON_CSDR (0x4f0)
  138. #define U300_SYSCON_CSDR_SW_DEBUG_ENABLE (0x0001)
  139. /* PRINT_CONTROL Print Control 16bit (R/-) */
  140. #define U300_SYSCON_PCR (0x4f8)
  141. #define U300_SYSCON_PCR_SERV_IND (0x0001)
  142. /* BOOT_CONTROL 16bit (R/-) */
  143. #define U300_SYSCON_BCR (0x4fc)
  144. #define U300_SYSCON_BCR_ACC_CPU_SUBSYS_VINITHI_IND (0x0400)
  145. #define U300_SYSCON_BCR_APP_CPU_SUBSYS_VINITHI_IND (0x0200)
  146. #define U300_SYSCON_BCR_EXTRA_BOOT_OPTION_MASK (0x01FC)
  147. #define U300_SYSCON_BCR_APP_BOOT_SERV_MASK (0x0003)
  148. static void __iomem *syscon_base;
  149. /*
  150. * Static I/O mappings that are needed for booting the U300 platforms. The
  151. * only things we need are the areas where we find the timer, syscon and
  152. * intcon, since the remaining device drivers will map their own memory
  153. * physical to virtual as the need arise.
  154. */
  155. static struct map_desc u300_io_desc[] __initdata = {
  156. {
  157. .virtual = U300_SLOW_PER_VIRT_BASE,
  158. .pfn = __phys_to_pfn(U300_SLOW_PER_PHYS_BASE),
  159. .length = SZ_64K,
  160. .type = MT_DEVICE,
  161. },
  162. {
  163. .virtual = U300_AHB_PER_VIRT_BASE,
  164. .pfn = __phys_to_pfn(U300_AHB_PER_PHYS_BASE),
  165. .length = SZ_32K,
  166. .type = MT_DEVICE,
  167. },
  168. {
  169. .virtual = U300_FAST_PER_VIRT_BASE,
  170. .pfn = __phys_to_pfn(U300_FAST_PER_PHYS_BASE),
  171. .length = SZ_32K,
  172. .type = MT_DEVICE,
  173. },
  174. };
  175. static void __init u300_map_io(void)
  176. {
  177. iotable_init(u300_io_desc, ARRAY_SIZE(u300_io_desc));
  178. }
  179. static unsigned long pin_pullup_conf[] = {
  180. PIN_CONF_PACKED(PIN_CONFIG_BIAS_PULL_UP, 1),
  181. };
  182. static unsigned long pin_highz_conf[] = {
  183. PIN_CONF_PACKED(PIN_CONFIG_BIAS_HIGH_IMPEDANCE, 0),
  184. };
  185. /* Pin control settings */
  186. static struct pinctrl_map __initdata u300_pinmux_map[] = {
  187. /* anonymous maps for chip power and EMIFs */
  188. PIN_MAP_MUX_GROUP_HOG_DEFAULT("pinctrl-u300", NULL, "power"),
  189. PIN_MAP_MUX_GROUP_HOG_DEFAULT("pinctrl-u300", NULL, "emif0"),
  190. PIN_MAP_MUX_GROUP_HOG_DEFAULT("pinctrl-u300", NULL, "emif1"),
  191. /* per-device maps for MMC/SD, SPI and UART */
  192. PIN_MAP_MUX_GROUP_DEFAULT("mmci", "pinctrl-u300", NULL, "mmc0"),
  193. PIN_MAP_MUX_GROUP_DEFAULT("pl022", "pinctrl-u300", NULL, "spi0"),
  194. PIN_MAP_MUX_GROUP_DEFAULT("uart0", "pinctrl-u300", NULL, "uart0"),
  195. /* This pin is used for clock return rather than GPIO */
  196. PIN_MAP_CONFIGS_PIN_DEFAULT("mmci", "pinctrl-u300", "PIO APP GPIO 11",
  197. pin_pullup_conf),
  198. /* This pin is used for card detect */
  199. PIN_MAP_CONFIGS_PIN_DEFAULT("mmci", "pinctrl-u300", "PIO MS INS",
  200. pin_highz_conf),
  201. };
  202. struct db_chip {
  203. u16 chipid;
  204. const char *name;
  205. };
  206. /*
  207. * This is a list of the Digital Baseband chips used in the U300 platform.
  208. */
  209. static struct db_chip db_chips[] __initdata = {
  210. {
  211. .chipid = 0xb800,
  212. .name = "DB3000",
  213. },
  214. {
  215. .chipid = 0xc000,
  216. .name = "DB3100",
  217. },
  218. {
  219. .chipid = 0xc800,
  220. .name = "DB3150",
  221. },
  222. {
  223. .chipid = 0xd800,
  224. .name = "DB3200",
  225. },
  226. {
  227. .chipid = 0xe000,
  228. .name = "DB3250",
  229. },
  230. {
  231. .chipid = 0xe800,
  232. .name = "DB3210",
  233. },
  234. {
  235. .chipid = 0xf000,
  236. .name = "DB3350 P1x",
  237. },
  238. {
  239. .chipid = 0xf100,
  240. .name = "DB3350 P2x",
  241. },
  242. {
  243. .chipid = 0x0000, /* List terminator */
  244. .name = NULL,
  245. }
  246. };
  247. static void __init u300_init_check_chip(void)
  248. {
  249. u16 val;
  250. struct db_chip *chip;
  251. const char *chipname;
  252. const char unknown[] = "UNKNOWN";
  253. /* Read out and print chip ID */
  254. val = readw(syscon_base + U300_SYSCON_CIDR);
  255. /* This is in funky bigendian order... */
  256. val = (val & 0xFFU) << 8 | (val >> 8);
  257. chip = db_chips;
  258. chipname = unknown;
  259. for ( ; chip->chipid; chip++) {
  260. if (chip->chipid == (val & 0xFF00U)) {
  261. chipname = chip->name;
  262. break;
  263. }
  264. }
  265. printk(KERN_INFO "Initializing U300 system on %s baseband chip " \
  266. "(chip ID 0x%04x)\n", chipname, val);
  267. if ((val & 0xFF00U) != 0xf000 && (val & 0xFF00U) != 0xf100) {
  268. printk(KERN_ERR "Platform configured for BS335 " \
  269. " with DB3350 but %s detected, expect problems!",
  270. chipname);
  271. }
  272. }
  273. /* Forward declare this function from the watchdog */
  274. void coh901327_watchdog_reset(void);
  275. static void u300_restart(enum reboot_mode mode, const char *cmd)
  276. {
  277. switch (mode) {
  278. case REBOOT_SOFT:
  279. case REBOOT_HARD:
  280. #ifdef CONFIG_COH901327_WATCHDOG
  281. coh901327_watchdog_reset();
  282. #endif
  283. break;
  284. default:
  285. /* Do nothing */
  286. break;
  287. }
  288. /* Wait for system do die/reset. */
  289. while (1);
  290. }
  291. /* These are mostly to get the right device names for the clock lookups */
  292. static struct of_dev_auxdata u300_auxdata_lookup[] __initdata = {
  293. OF_DEV_AUXDATA("stericsson,pinctrl-u300", U300_SYSCON_BASE,
  294. "pinctrl-u300", NULL),
  295. OF_DEV_AUXDATA("stericsson,gpio-coh901", U300_GPIO_BASE,
  296. "u300-gpio", NULL),
  297. OF_DEV_AUXDATA("stericsson,coh901327", U300_WDOG_BASE,
  298. "coh901327_wdog", NULL),
  299. OF_DEV_AUXDATA("stericsson,coh901331", U300_RTC_BASE,
  300. "rtc-coh901331", NULL),
  301. OF_DEV_AUXDATA("stericsson,coh901318", U300_DMAC_BASE,
  302. "coh901318", NULL),
  303. OF_DEV_AUXDATA("stericsson,fsmc-nand", U300_NAND_IF_PHYS_BASE,
  304. "fsmc-nand", NULL),
  305. OF_DEV_AUXDATA("arm,primecell", U300_UART0_BASE,
  306. "uart0", NULL),
  307. OF_DEV_AUXDATA("arm,primecell", U300_UART1_BASE,
  308. "uart1", NULL),
  309. OF_DEV_AUXDATA("arm,primecell", U300_SPI_BASE,
  310. "pl022", NULL),
  311. OF_DEV_AUXDATA("st,ddci2c", U300_I2C0_BASE,
  312. "stu300.0", NULL),
  313. OF_DEV_AUXDATA("st,ddci2c", U300_I2C1_BASE,
  314. "stu300.1", NULL),
  315. OF_DEV_AUXDATA("arm,primecell", U300_MMCSD_BASE,
  316. "mmci", NULL),
  317. { /* sentinel */ },
  318. };
  319. static void __init u300_init_irq_dt(void)
  320. {
  321. struct device_node *syscon;
  322. struct clk *clk;
  323. syscon = of_find_node_by_path("/syscon@c0011000");
  324. if (!syscon) {
  325. pr_crit("could not find syscon node\n");
  326. return;
  327. }
  328. syscon_base = of_iomap(syscon, 0);
  329. if (!syscon_base) {
  330. pr_crit("could not remap syscon\n");
  331. return;
  332. }
  333. /* initialize clocking early, we want to clock the INTCON */
  334. u300_clk_init(syscon_base);
  335. /* Bootstrap EMIF and SEMI clocks */
  336. clk = clk_get_sys("pl172", NULL);
  337. BUG_ON(IS_ERR(clk));
  338. clk_prepare_enable(clk);
  339. clk = clk_get_sys("semi", NULL);
  340. BUG_ON(IS_ERR(clk));
  341. clk_prepare_enable(clk);
  342. /* Clock the interrupt controller */
  343. clk = clk_get_sys("intcon", NULL);
  344. BUG_ON(IS_ERR(clk));
  345. clk_prepare_enable(clk);
  346. irqchip_init();
  347. }
  348. static void __init u300_init_machine_dt(void)
  349. {
  350. u16 val;
  351. /* Check what platform we run and print some status information */
  352. u300_init_check_chip();
  353. /* Initialize pinmuxing */
  354. pinctrl_register_mappings(u300_pinmux_map,
  355. ARRAY_SIZE(u300_pinmux_map));
  356. of_platform_default_populate(NULL, u300_auxdata_lookup, NULL);
  357. /* Enable SEMI self refresh */
  358. val = readw(syscon_base + U300_SYSCON_SMCR) |
  359. U300_SYSCON_SMCR_SEMI_SREFREQ_ENABLE;
  360. writew(val, syscon_base + U300_SYSCON_SMCR);
  361. }
  362. static const char * u300_board_compat[] = {
  363. "stericsson,u300",
  364. NULL,
  365. };
  366. DT_MACHINE_START(U300_DT, "U300 S335/B335 (Device Tree)")
  367. .map_io = u300_map_io,
  368. .init_irq = u300_init_irq_dt,
  369. .init_time = clocksource_probe,
  370. .init_machine = u300_init_machine_dt,
  371. .restart = u300_restart,
  372. .dt_compat = u300_board_compat,
  373. MACHINE_END