common.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. /*
  2. * arch/arm/mach-mv78xx0/common.c
  3. *
  4. * Core functions for Marvell MV78xx0 SoCs
  5. *
  6. * This file is licensed under the terms of the GNU General Public
  7. * License version 2. This program is licensed "as is" without any
  8. * warranty of any kind, whether express or implied.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/serial_8250.h>
  14. #include <linux/mbus.h>
  15. #include <linux/mv643xx_eth.h>
  16. #include <linux/ata_platform.h>
  17. #include <asm/mach/map.h>
  18. #include <asm/mach/time.h>
  19. #include <mach/mv78xx0.h>
  20. #include <plat/cache-feroceon-l2.h>
  21. #include <plat/ehci-orion.h>
  22. #include <plat/orion_nand.h>
  23. #include <plat/time.h>
  24. #include "common.h"
  25. /*****************************************************************************
  26. * Common bits
  27. ****************************************************************************/
  28. int mv78xx0_core_index(void)
  29. {
  30. u32 extra;
  31. /*
  32. * Read Extra Features register.
  33. */
  34. __asm__("mrc p15, 1, %0, c15, c1, 0" : "=r" (extra));
  35. return !!(extra & 0x00004000);
  36. }
  37. static int get_hclk(void)
  38. {
  39. int hclk;
  40. /*
  41. * HCLK tick rate is configured by DEV_D[7:5] pins.
  42. */
  43. switch ((readl(SAMPLE_AT_RESET_LOW) >> 5) & 7) {
  44. case 0:
  45. hclk = 166666667;
  46. break;
  47. case 1:
  48. hclk = 200000000;
  49. break;
  50. case 2:
  51. hclk = 266666667;
  52. break;
  53. case 3:
  54. hclk = 333333333;
  55. break;
  56. case 4:
  57. hclk = 400000000;
  58. break;
  59. default:
  60. panic("unknown HCLK PLL setting: %.8x\n",
  61. readl(SAMPLE_AT_RESET_LOW));
  62. }
  63. return hclk;
  64. }
  65. static void get_pclk_l2clk(int hclk, int core_index, int *pclk, int *l2clk)
  66. {
  67. u32 cfg;
  68. /*
  69. * Core #0 PCLK/L2CLK is configured by bits [13:8], core #1
  70. * PCLK/L2CLK by bits [19:14].
  71. */
  72. if (core_index == 0) {
  73. cfg = (readl(SAMPLE_AT_RESET_LOW) >> 8) & 0x3f;
  74. } else {
  75. cfg = (readl(SAMPLE_AT_RESET_LOW) >> 14) & 0x3f;
  76. }
  77. /*
  78. * Bits [11:8] ([17:14] for core #1) configure the PCLK:HCLK
  79. * ratio (1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6).
  80. */
  81. *pclk = ((u64)hclk * (2 + (cfg & 0xf))) >> 1;
  82. /*
  83. * Bits [13:12] ([19:18] for core #1) configure the PCLK:L2CLK
  84. * ratio (1, 2, 3).
  85. */
  86. *l2clk = *pclk / (((cfg >> 4) & 3) + 1);
  87. }
  88. static int get_tclk(void)
  89. {
  90. int tclk;
  91. /*
  92. * TCLK tick rate is configured by DEV_A[2:0] strap pins.
  93. */
  94. switch ((readl(SAMPLE_AT_RESET_HIGH) >> 6) & 7) {
  95. case 1:
  96. tclk = 166666667;
  97. break;
  98. case 3:
  99. tclk = 200000000;
  100. break;
  101. default:
  102. panic("unknown TCLK PLL setting: %.8x\n",
  103. readl(SAMPLE_AT_RESET_HIGH));
  104. }
  105. return tclk;
  106. }
  107. /*****************************************************************************
  108. * I/O Address Mapping
  109. ****************************************************************************/
  110. static struct map_desc mv78xx0_io_desc[] __initdata = {
  111. {
  112. .virtual = MV78XX0_CORE_REGS_VIRT_BASE,
  113. .pfn = 0,
  114. .length = MV78XX0_CORE_REGS_SIZE,
  115. .type = MT_DEVICE,
  116. }, {
  117. .virtual = MV78XX0_PCIE_IO_VIRT_BASE(0),
  118. .pfn = __phys_to_pfn(MV78XX0_PCIE_IO_PHYS_BASE(0)),
  119. .length = MV78XX0_PCIE_IO_SIZE * 8,
  120. .type = MT_DEVICE,
  121. }, {
  122. .virtual = MV78XX0_REGS_VIRT_BASE,
  123. .pfn = __phys_to_pfn(MV78XX0_REGS_PHYS_BASE),
  124. .length = MV78XX0_REGS_SIZE,
  125. .type = MT_DEVICE,
  126. },
  127. };
  128. void __init mv78xx0_map_io(void)
  129. {
  130. unsigned long phys;
  131. /*
  132. * Map the right set of per-core registers depending on
  133. * which core we are running on.
  134. */
  135. if (mv78xx0_core_index() == 0) {
  136. phys = MV78XX0_CORE0_REGS_PHYS_BASE;
  137. } else {
  138. phys = MV78XX0_CORE1_REGS_PHYS_BASE;
  139. }
  140. mv78xx0_io_desc[0].pfn = __phys_to_pfn(phys);
  141. iotable_init(mv78xx0_io_desc, ARRAY_SIZE(mv78xx0_io_desc));
  142. }
  143. /*****************************************************************************
  144. * EHCI
  145. ****************************************************************************/
  146. static struct orion_ehci_data mv78xx0_ehci_data = {
  147. .dram = &mv78xx0_mbus_dram_info,
  148. .phy_version = EHCI_PHY_NA,
  149. };
  150. static u64 ehci_dmamask = 0xffffffffUL;
  151. /*****************************************************************************
  152. * EHCI0
  153. ****************************************************************************/
  154. static struct resource mv78xx0_ehci0_resources[] = {
  155. {
  156. .start = USB0_PHYS_BASE,
  157. .end = USB0_PHYS_BASE + 0x0fff,
  158. .flags = IORESOURCE_MEM,
  159. }, {
  160. .start = IRQ_MV78XX0_USB_0,
  161. .end = IRQ_MV78XX0_USB_0,
  162. .flags = IORESOURCE_IRQ,
  163. },
  164. };
  165. static struct platform_device mv78xx0_ehci0 = {
  166. .name = "orion-ehci",
  167. .id = 0,
  168. .dev = {
  169. .dma_mask = &ehci_dmamask,
  170. .coherent_dma_mask = 0xffffffff,
  171. .platform_data = &mv78xx0_ehci_data,
  172. },
  173. .resource = mv78xx0_ehci0_resources,
  174. .num_resources = ARRAY_SIZE(mv78xx0_ehci0_resources),
  175. };
  176. void __init mv78xx0_ehci0_init(void)
  177. {
  178. platform_device_register(&mv78xx0_ehci0);
  179. }
  180. /*****************************************************************************
  181. * EHCI1
  182. ****************************************************************************/
  183. static struct resource mv78xx0_ehci1_resources[] = {
  184. {
  185. .start = USB1_PHYS_BASE,
  186. .end = USB1_PHYS_BASE + 0x0fff,
  187. .flags = IORESOURCE_MEM,
  188. }, {
  189. .start = IRQ_MV78XX0_USB_1,
  190. .end = IRQ_MV78XX0_USB_1,
  191. .flags = IORESOURCE_IRQ,
  192. },
  193. };
  194. static struct platform_device mv78xx0_ehci1 = {
  195. .name = "orion-ehci",
  196. .id = 1,
  197. .dev = {
  198. .dma_mask = &ehci_dmamask,
  199. .coherent_dma_mask = 0xffffffff,
  200. .platform_data = &mv78xx0_ehci_data,
  201. },
  202. .resource = mv78xx0_ehci1_resources,
  203. .num_resources = ARRAY_SIZE(mv78xx0_ehci1_resources),
  204. };
  205. void __init mv78xx0_ehci1_init(void)
  206. {
  207. platform_device_register(&mv78xx0_ehci1);
  208. }
  209. /*****************************************************************************
  210. * EHCI2
  211. ****************************************************************************/
  212. static struct resource mv78xx0_ehci2_resources[] = {
  213. {
  214. .start = USB2_PHYS_BASE,
  215. .end = USB2_PHYS_BASE + 0x0fff,
  216. .flags = IORESOURCE_MEM,
  217. }, {
  218. .start = IRQ_MV78XX0_USB_2,
  219. .end = IRQ_MV78XX0_USB_2,
  220. .flags = IORESOURCE_IRQ,
  221. },
  222. };
  223. static struct platform_device mv78xx0_ehci2 = {
  224. .name = "orion-ehci",
  225. .id = 2,
  226. .dev = {
  227. .dma_mask = &ehci_dmamask,
  228. .coherent_dma_mask = 0xffffffff,
  229. .platform_data = &mv78xx0_ehci_data,
  230. },
  231. .resource = mv78xx0_ehci2_resources,
  232. .num_resources = ARRAY_SIZE(mv78xx0_ehci2_resources),
  233. };
  234. void __init mv78xx0_ehci2_init(void)
  235. {
  236. platform_device_register(&mv78xx0_ehci2);
  237. }
  238. /*****************************************************************************
  239. * GE00
  240. ****************************************************************************/
  241. struct mv643xx_eth_shared_platform_data mv78xx0_ge00_shared_data = {
  242. .t_clk = 0,
  243. .dram = &mv78xx0_mbus_dram_info,
  244. };
  245. static struct resource mv78xx0_ge00_shared_resources[] = {
  246. {
  247. .name = "ge00 base",
  248. .start = GE00_PHYS_BASE + 0x2000,
  249. .end = GE00_PHYS_BASE + 0x3fff,
  250. .flags = IORESOURCE_MEM,
  251. }, {
  252. .name = "ge err irq",
  253. .start = IRQ_MV78XX0_GE_ERR,
  254. .end = IRQ_MV78XX0_GE_ERR,
  255. .flags = IORESOURCE_IRQ,
  256. },
  257. };
  258. static struct platform_device mv78xx0_ge00_shared = {
  259. .name = MV643XX_ETH_SHARED_NAME,
  260. .id = 0,
  261. .dev = {
  262. .platform_data = &mv78xx0_ge00_shared_data,
  263. },
  264. .num_resources = ARRAY_SIZE(mv78xx0_ge00_shared_resources),
  265. .resource = mv78xx0_ge00_shared_resources,
  266. };
  267. static struct resource mv78xx0_ge00_resources[] = {
  268. {
  269. .name = "ge00 irq",
  270. .start = IRQ_MV78XX0_GE00_SUM,
  271. .end = IRQ_MV78XX0_GE00_SUM,
  272. .flags = IORESOURCE_IRQ,
  273. },
  274. };
  275. static struct platform_device mv78xx0_ge00 = {
  276. .name = MV643XX_ETH_NAME,
  277. .id = 0,
  278. .num_resources = 1,
  279. .resource = mv78xx0_ge00_resources,
  280. };
  281. void __init mv78xx0_ge00_init(struct mv643xx_eth_platform_data *eth_data)
  282. {
  283. eth_data->shared = &mv78xx0_ge00_shared;
  284. mv78xx0_ge00.dev.platform_data = eth_data;
  285. platform_device_register(&mv78xx0_ge00_shared);
  286. platform_device_register(&mv78xx0_ge00);
  287. }
  288. /*****************************************************************************
  289. * GE01
  290. ****************************************************************************/
  291. struct mv643xx_eth_shared_platform_data mv78xx0_ge01_shared_data = {
  292. .t_clk = 0,
  293. .dram = &mv78xx0_mbus_dram_info,
  294. .shared_smi = &mv78xx0_ge00_shared,
  295. };
  296. static struct resource mv78xx0_ge01_shared_resources[] = {
  297. {
  298. .name = "ge01 base",
  299. .start = GE01_PHYS_BASE + 0x2000,
  300. .end = GE01_PHYS_BASE + 0x3fff,
  301. .flags = IORESOURCE_MEM,
  302. },
  303. };
  304. static struct platform_device mv78xx0_ge01_shared = {
  305. .name = MV643XX_ETH_SHARED_NAME,
  306. .id = 1,
  307. .dev = {
  308. .platform_data = &mv78xx0_ge01_shared_data,
  309. },
  310. .num_resources = 1,
  311. .resource = mv78xx0_ge01_shared_resources,
  312. };
  313. static struct resource mv78xx0_ge01_resources[] = {
  314. {
  315. .name = "ge01 irq",
  316. .start = IRQ_MV78XX0_GE01_SUM,
  317. .end = IRQ_MV78XX0_GE01_SUM,
  318. .flags = IORESOURCE_IRQ,
  319. },
  320. };
  321. static struct platform_device mv78xx0_ge01 = {
  322. .name = MV643XX_ETH_NAME,
  323. .id = 1,
  324. .num_resources = 1,
  325. .resource = mv78xx0_ge01_resources,
  326. };
  327. void __init mv78xx0_ge01_init(struct mv643xx_eth_platform_data *eth_data)
  328. {
  329. eth_data->shared = &mv78xx0_ge01_shared;
  330. mv78xx0_ge01.dev.platform_data = eth_data;
  331. platform_device_register(&mv78xx0_ge01_shared);
  332. platform_device_register(&mv78xx0_ge01);
  333. }
  334. /*****************************************************************************
  335. * GE10
  336. ****************************************************************************/
  337. struct mv643xx_eth_shared_platform_data mv78xx0_ge10_shared_data = {
  338. .t_clk = 0,
  339. .dram = &mv78xx0_mbus_dram_info,
  340. .shared_smi = &mv78xx0_ge00_shared,
  341. };
  342. static struct resource mv78xx0_ge10_shared_resources[] = {
  343. {
  344. .name = "ge10 base",
  345. .start = GE10_PHYS_BASE + 0x2000,
  346. .end = GE10_PHYS_BASE + 0x3fff,
  347. .flags = IORESOURCE_MEM,
  348. },
  349. };
  350. static struct platform_device mv78xx0_ge10_shared = {
  351. .name = MV643XX_ETH_SHARED_NAME,
  352. .id = 2,
  353. .dev = {
  354. .platform_data = &mv78xx0_ge10_shared_data,
  355. },
  356. .num_resources = 1,
  357. .resource = mv78xx0_ge10_shared_resources,
  358. };
  359. static struct resource mv78xx0_ge10_resources[] = {
  360. {
  361. .name = "ge10 irq",
  362. .start = IRQ_MV78XX0_GE10_SUM,
  363. .end = IRQ_MV78XX0_GE10_SUM,
  364. .flags = IORESOURCE_IRQ,
  365. },
  366. };
  367. static struct platform_device mv78xx0_ge10 = {
  368. .name = MV643XX_ETH_NAME,
  369. .id = 2,
  370. .num_resources = 1,
  371. .resource = mv78xx0_ge10_resources,
  372. };
  373. void __init mv78xx0_ge10_init(struct mv643xx_eth_platform_data *eth_data)
  374. {
  375. eth_data->shared = &mv78xx0_ge10_shared;
  376. mv78xx0_ge10.dev.platform_data = eth_data;
  377. platform_device_register(&mv78xx0_ge10_shared);
  378. platform_device_register(&mv78xx0_ge10);
  379. }
  380. /*****************************************************************************
  381. * GE11
  382. ****************************************************************************/
  383. struct mv643xx_eth_shared_platform_data mv78xx0_ge11_shared_data = {
  384. .t_clk = 0,
  385. .dram = &mv78xx0_mbus_dram_info,
  386. .shared_smi = &mv78xx0_ge00_shared,
  387. };
  388. static struct resource mv78xx0_ge11_shared_resources[] = {
  389. {
  390. .name = "ge11 base",
  391. .start = GE11_PHYS_BASE + 0x2000,
  392. .end = GE11_PHYS_BASE + 0x3fff,
  393. .flags = IORESOURCE_MEM,
  394. },
  395. };
  396. static struct platform_device mv78xx0_ge11_shared = {
  397. .name = MV643XX_ETH_SHARED_NAME,
  398. .id = 3,
  399. .dev = {
  400. .platform_data = &mv78xx0_ge11_shared_data,
  401. },
  402. .num_resources = 1,
  403. .resource = mv78xx0_ge11_shared_resources,
  404. };
  405. static struct resource mv78xx0_ge11_resources[] = {
  406. {
  407. .name = "ge11 irq",
  408. .start = IRQ_MV78XX0_GE11_SUM,
  409. .end = IRQ_MV78XX0_GE11_SUM,
  410. .flags = IORESOURCE_IRQ,
  411. },
  412. };
  413. static struct platform_device mv78xx0_ge11 = {
  414. .name = MV643XX_ETH_NAME,
  415. .id = 3,
  416. .num_resources = 1,
  417. .resource = mv78xx0_ge11_resources,
  418. };
  419. void __init mv78xx0_ge11_init(struct mv643xx_eth_platform_data *eth_data)
  420. {
  421. eth_data->shared = &mv78xx0_ge11_shared;
  422. mv78xx0_ge11.dev.platform_data = eth_data;
  423. platform_device_register(&mv78xx0_ge11_shared);
  424. platform_device_register(&mv78xx0_ge11);
  425. }
  426. /*****************************************************************************
  427. * SATA
  428. ****************************************************************************/
  429. static struct resource mv78xx0_sata_resources[] = {
  430. {
  431. .name = "sata base",
  432. .start = SATA_PHYS_BASE,
  433. .end = SATA_PHYS_BASE + 0x5000 - 1,
  434. .flags = IORESOURCE_MEM,
  435. }, {
  436. .name = "sata irq",
  437. .start = IRQ_MV78XX0_SATA,
  438. .end = IRQ_MV78XX0_SATA,
  439. .flags = IORESOURCE_IRQ,
  440. },
  441. };
  442. static struct platform_device mv78xx0_sata = {
  443. .name = "sata_mv",
  444. .id = 0,
  445. .dev = {
  446. .coherent_dma_mask = 0xffffffff,
  447. },
  448. .num_resources = ARRAY_SIZE(mv78xx0_sata_resources),
  449. .resource = mv78xx0_sata_resources,
  450. };
  451. void __init mv78xx0_sata_init(struct mv_sata_platform_data *sata_data)
  452. {
  453. sata_data->dram = &mv78xx0_mbus_dram_info;
  454. mv78xx0_sata.dev.platform_data = sata_data;
  455. platform_device_register(&mv78xx0_sata);
  456. }
  457. /*****************************************************************************
  458. * UART0
  459. ****************************************************************************/
  460. static struct plat_serial8250_port mv78xx0_uart0_data[] = {
  461. {
  462. .mapbase = UART0_PHYS_BASE,
  463. .membase = (char *)UART0_VIRT_BASE,
  464. .irq = IRQ_MV78XX0_UART_0,
  465. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  466. .iotype = UPIO_MEM,
  467. .regshift = 2,
  468. .uartclk = 0,
  469. }, {
  470. },
  471. };
  472. static struct resource mv78xx0_uart0_resources[] = {
  473. {
  474. .start = UART0_PHYS_BASE,
  475. .end = UART0_PHYS_BASE + 0xff,
  476. .flags = IORESOURCE_MEM,
  477. }, {
  478. .start = IRQ_MV78XX0_UART_0,
  479. .end = IRQ_MV78XX0_UART_0,
  480. .flags = IORESOURCE_IRQ,
  481. },
  482. };
  483. static struct platform_device mv78xx0_uart0 = {
  484. .name = "serial8250",
  485. .id = 0,
  486. .dev = {
  487. .platform_data = mv78xx0_uart0_data,
  488. },
  489. .resource = mv78xx0_uart0_resources,
  490. .num_resources = ARRAY_SIZE(mv78xx0_uart0_resources),
  491. };
  492. void __init mv78xx0_uart0_init(void)
  493. {
  494. platform_device_register(&mv78xx0_uart0);
  495. }
  496. /*****************************************************************************
  497. * UART1
  498. ****************************************************************************/
  499. static struct plat_serial8250_port mv78xx0_uart1_data[] = {
  500. {
  501. .mapbase = UART1_PHYS_BASE,
  502. .membase = (char *)UART1_VIRT_BASE,
  503. .irq = IRQ_MV78XX0_UART_1,
  504. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  505. .iotype = UPIO_MEM,
  506. .regshift = 2,
  507. .uartclk = 0,
  508. }, {
  509. },
  510. };
  511. static struct resource mv78xx0_uart1_resources[] = {
  512. {
  513. .start = UART1_PHYS_BASE,
  514. .end = UART1_PHYS_BASE + 0xff,
  515. .flags = IORESOURCE_MEM,
  516. }, {
  517. .start = IRQ_MV78XX0_UART_1,
  518. .end = IRQ_MV78XX0_UART_1,
  519. .flags = IORESOURCE_IRQ,
  520. },
  521. };
  522. static struct platform_device mv78xx0_uart1 = {
  523. .name = "serial8250",
  524. .id = 1,
  525. .dev = {
  526. .platform_data = mv78xx0_uart1_data,
  527. },
  528. .resource = mv78xx0_uart1_resources,
  529. .num_resources = ARRAY_SIZE(mv78xx0_uart1_resources),
  530. };
  531. void __init mv78xx0_uart1_init(void)
  532. {
  533. platform_device_register(&mv78xx0_uart1);
  534. }
  535. /*****************************************************************************
  536. * UART2
  537. ****************************************************************************/
  538. static struct plat_serial8250_port mv78xx0_uart2_data[] = {
  539. {
  540. .mapbase = UART2_PHYS_BASE,
  541. .membase = (char *)UART2_VIRT_BASE,
  542. .irq = IRQ_MV78XX0_UART_2,
  543. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  544. .iotype = UPIO_MEM,
  545. .regshift = 2,
  546. .uartclk = 0,
  547. }, {
  548. },
  549. };
  550. static struct resource mv78xx0_uart2_resources[] = {
  551. {
  552. .start = UART2_PHYS_BASE,
  553. .end = UART2_PHYS_BASE + 0xff,
  554. .flags = IORESOURCE_MEM,
  555. }, {
  556. .start = IRQ_MV78XX0_UART_2,
  557. .end = IRQ_MV78XX0_UART_2,
  558. .flags = IORESOURCE_IRQ,
  559. },
  560. };
  561. static struct platform_device mv78xx0_uart2 = {
  562. .name = "serial8250",
  563. .id = 2,
  564. .dev = {
  565. .platform_data = mv78xx0_uart2_data,
  566. },
  567. .resource = mv78xx0_uart2_resources,
  568. .num_resources = ARRAY_SIZE(mv78xx0_uart2_resources),
  569. };
  570. void __init mv78xx0_uart2_init(void)
  571. {
  572. platform_device_register(&mv78xx0_uart2);
  573. }
  574. /*****************************************************************************
  575. * UART3
  576. ****************************************************************************/
  577. static struct plat_serial8250_port mv78xx0_uart3_data[] = {
  578. {
  579. .mapbase = UART3_PHYS_BASE,
  580. .membase = (char *)UART3_VIRT_BASE,
  581. .irq = IRQ_MV78XX0_UART_3,
  582. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  583. .iotype = UPIO_MEM,
  584. .regshift = 2,
  585. .uartclk = 0,
  586. }, {
  587. },
  588. };
  589. static struct resource mv78xx0_uart3_resources[] = {
  590. {
  591. .start = UART3_PHYS_BASE,
  592. .end = UART3_PHYS_BASE + 0xff,
  593. .flags = IORESOURCE_MEM,
  594. }, {
  595. .start = IRQ_MV78XX0_UART_3,
  596. .end = IRQ_MV78XX0_UART_3,
  597. .flags = IORESOURCE_IRQ,
  598. },
  599. };
  600. static struct platform_device mv78xx0_uart3 = {
  601. .name = "serial8250",
  602. .id = 3,
  603. .dev = {
  604. .platform_data = mv78xx0_uart3_data,
  605. },
  606. .resource = mv78xx0_uart3_resources,
  607. .num_resources = ARRAY_SIZE(mv78xx0_uart3_resources),
  608. };
  609. void __init mv78xx0_uart3_init(void)
  610. {
  611. platform_device_register(&mv78xx0_uart3);
  612. }
  613. /*****************************************************************************
  614. * Time handling
  615. ****************************************************************************/
  616. static void mv78xx0_timer_init(void)
  617. {
  618. orion_time_init(IRQ_MV78XX0_TIMER_1, get_tclk());
  619. }
  620. struct sys_timer mv78xx0_timer = {
  621. .init = mv78xx0_timer_init,
  622. };
  623. /*****************************************************************************
  624. * General
  625. ****************************************************************************/
  626. static int __init is_l2_writethrough(void)
  627. {
  628. return !!(readl(CPU_CONTROL) & L2_WRITETHROUGH);
  629. }
  630. void __init mv78xx0_init(void)
  631. {
  632. int core_index;
  633. int hclk;
  634. int pclk;
  635. int l2clk;
  636. int tclk;
  637. core_index = mv78xx0_core_index();
  638. hclk = get_hclk();
  639. get_pclk_l2clk(hclk, core_index, &pclk, &l2clk);
  640. tclk = get_tclk();
  641. printk(KERN_INFO "MV78xx0 core #%d, ", core_index);
  642. printk("PCLK = %dMHz, ", (pclk + 499999) / 1000000);
  643. printk("L2 = %dMHz, ", (l2clk + 499999) / 1000000);
  644. printk("HCLK = %dMHz, ", (hclk + 499999) / 1000000);
  645. printk("TCLK = %dMHz\n", (tclk + 499999) / 1000000);
  646. mv78xx0_setup_cpu_mbus();
  647. #ifdef CONFIG_CACHE_FEROCEON_L2
  648. feroceon_l2_init(is_l2_writethrough());
  649. #endif
  650. mv78xx0_ge00_shared_data.t_clk = tclk;
  651. mv78xx0_ge01_shared_data.t_clk = tclk;
  652. mv78xx0_ge10_shared_data.t_clk = tclk;
  653. mv78xx0_ge11_shared_data.t_clk = tclk;
  654. mv78xx0_uart0_data[0].uartclk = tclk;
  655. mv78xx0_uart1_data[0].uartclk = tclk;
  656. mv78xx0_uart2_data[0].uartclk = tclk;
  657. mv78xx0_uart3_data[0].uartclk = tclk;
  658. }