common.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  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. };
  149. static u64 ehci_dmamask = 0xffffffffUL;
  150. /*****************************************************************************
  151. * EHCI0
  152. ****************************************************************************/
  153. static struct resource mv78xx0_ehci0_resources[] = {
  154. {
  155. .start = USB0_PHYS_BASE,
  156. .end = USB0_PHYS_BASE + 0x0fff,
  157. .flags = IORESOURCE_MEM,
  158. }, {
  159. .start = IRQ_MV78XX0_USB_0,
  160. .end = IRQ_MV78XX0_USB_0,
  161. .flags = IORESOURCE_IRQ,
  162. },
  163. };
  164. static struct platform_device mv78xx0_ehci0 = {
  165. .name = "orion-ehci",
  166. .id = 0,
  167. .dev = {
  168. .dma_mask = &ehci_dmamask,
  169. .coherent_dma_mask = 0xffffffff,
  170. .platform_data = &mv78xx0_ehci_data,
  171. },
  172. .resource = mv78xx0_ehci0_resources,
  173. .num_resources = ARRAY_SIZE(mv78xx0_ehci0_resources),
  174. };
  175. void __init mv78xx0_ehci0_init(void)
  176. {
  177. platform_device_register(&mv78xx0_ehci0);
  178. }
  179. /*****************************************************************************
  180. * EHCI1
  181. ****************************************************************************/
  182. static struct resource mv78xx0_ehci1_resources[] = {
  183. {
  184. .start = USB1_PHYS_BASE,
  185. .end = USB1_PHYS_BASE + 0x0fff,
  186. .flags = IORESOURCE_MEM,
  187. }, {
  188. .start = IRQ_MV78XX0_USB_1,
  189. .end = IRQ_MV78XX0_USB_1,
  190. .flags = IORESOURCE_IRQ,
  191. },
  192. };
  193. static struct platform_device mv78xx0_ehci1 = {
  194. .name = "orion-ehci",
  195. .id = 1,
  196. .dev = {
  197. .dma_mask = &ehci_dmamask,
  198. .coherent_dma_mask = 0xffffffff,
  199. .platform_data = &mv78xx0_ehci_data,
  200. },
  201. .resource = mv78xx0_ehci1_resources,
  202. .num_resources = ARRAY_SIZE(mv78xx0_ehci1_resources),
  203. };
  204. void __init mv78xx0_ehci1_init(void)
  205. {
  206. platform_device_register(&mv78xx0_ehci1);
  207. }
  208. /*****************************************************************************
  209. * EHCI2
  210. ****************************************************************************/
  211. static struct resource mv78xx0_ehci2_resources[] = {
  212. {
  213. .start = USB2_PHYS_BASE,
  214. .end = USB2_PHYS_BASE + 0x0fff,
  215. .flags = IORESOURCE_MEM,
  216. }, {
  217. .start = IRQ_MV78XX0_USB_2,
  218. .end = IRQ_MV78XX0_USB_2,
  219. .flags = IORESOURCE_IRQ,
  220. },
  221. };
  222. static struct platform_device mv78xx0_ehci2 = {
  223. .name = "orion-ehci",
  224. .id = 2,
  225. .dev = {
  226. .dma_mask = &ehci_dmamask,
  227. .coherent_dma_mask = 0xffffffff,
  228. .platform_data = &mv78xx0_ehci_data,
  229. },
  230. .resource = mv78xx0_ehci2_resources,
  231. .num_resources = ARRAY_SIZE(mv78xx0_ehci2_resources),
  232. };
  233. void __init mv78xx0_ehci2_init(void)
  234. {
  235. platform_device_register(&mv78xx0_ehci2);
  236. }
  237. /*****************************************************************************
  238. * GE00
  239. ****************************************************************************/
  240. struct mv643xx_eth_shared_platform_data mv78xx0_ge00_shared_data = {
  241. .t_clk = 0,
  242. .dram = &mv78xx0_mbus_dram_info,
  243. };
  244. static struct resource mv78xx0_ge00_shared_resources[] = {
  245. {
  246. .name = "ge00 base",
  247. .start = GE00_PHYS_BASE + 0x2000,
  248. .end = GE00_PHYS_BASE + 0x3fff,
  249. .flags = IORESOURCE_MEM,
  250. }, {
  251. .name = "ge err irq",
  252. .start = IRQ_MV78XX0_GE_ERR,
  253. .end = IRQ_MV78XX0_GE_ERR,
  254. .flags = IORESOURCE_IRQ,
  255. },
  256. };
  257. static struct platform_device mv78xx0_ge00_shared = {
  258. .name = MV643XX_ETH_SHARED_NAME,
  259. .id = 0,
  260. .dev = {
  261. .platform_data = &mv78xx0_ge00_shared_data,
  262. },
  263. .num_resources = ARRAY_SIZE(mv78xx0_ge00_shared_resources),
  264. .resource = mv78xx0_ge00_shared_resources,
  265. };
  266. static struct resource mv78xx0_ge00_resources[] = {
  267. {
  268. .name = "ge00 irq",
  269. .start = IRQ_MV78XX0_GE00_SUM,
  270. .end = IRQ_MV78XX0_GE00_SUM,
  271. .flags = IORESOURCE_IRQ,
  272. },
  273. };
  274. static struct platform_device mv78xx0_ge00 = {
  275. .name = MV643XX_ETH_NAME,
  276. .id = 0,
  277. .num_resources = 1,
  278. .resource = mv78xx0_ge00_resources,
  279. };
  280. void __init mv78xx0_ge00_init(struct mv643xx_eth_platform_data *eth_data)
  281. {
  282. eth_data->shared = &mv78xx0_ge00_shared;
  283. mv78xx0_ge00.dev.platform_data = eth_data;
  284. platform_device_register(&mv78xx0_ge00_shared);
  285. platform_device_register(&mv78xx0_ge00);
  286. }
  287. /*****************************************************************************
  288. * GE01
  289. ****************************************************************************/
  290. struct mv643xx_eth_shared_platform_data mv78xx0_ge01_shared_data = {
  291. .t_clk = 0,
  292. .dram = &mv78xx0_mbus_dram_info,
  293. .shared_smi = &mv78xx0_ge00_shared,
  294. };
  295. static struct resource mv78xx0_ge01_shared_resources[] = {
  296. {
  297. .name = "ge01 base",
  298. .start = GE01_PHYS_BASE + 0x2000,
  299. .end = GE01_PHYS_BASE + 0x3fff,
  300. .flags = IORESOURCE_MEM,
  301. },
  302. };
  303. static struct platform_device mv78xx0_ge01_shared = {
  304. .name = MV643XX_ETH_SHARED_NAME,
  305. .id = 1,
  306. .dev = {
  307. .platform_data = &mv78xx0_ge01_shared_data,
  308. },
  309. .num_resources = 1,
  310. .resource = mv78xx0_ge01_shared_resources,
  311. };
  312. static struct resource mv78xx0_ge01_resources[] = {
  313. {
  314. .name = "ge01 irq",
  315. .start = IRQ_MV78XX0_GE01_SUM,
  316. .end = IRQ_MV78XX0_GE01_SUM,
  317. .flags = IORESOURCE_IRQ,
  318. },
  319. };
  320. static struct platform_device mv78xx0_ge01 = {
  321. .name = MV643XX_ETH_NAME,
  322. .id = 1,
  323. .num_resources = 1,
  324. .resource = mv78xx0_ge01_resources,
  325. };
  326. void __init mv78xx0_ge01_init(struct mv643xx_eth_platform_data *eth_data)
  327. {
  328. eth_data->shared = &mv78xx0_ge01_shared;
  329. mv78xx0_ge01.dev.platform_data = eth_data;
  330. platform_device_register(&mv78xx0_ge01_shared);
  331. platform_device_register(&mv78xx0_ge01);
  332. }
  333. /*****************************************************************************
  334. * GE10
  335. ****************************************************************************/
  336. struct mv643xx_eth_shared_platform_data mv78xx0_ge10_shared_data = {
  337. .t_clk = 0,
  338. .dram = &mv78xx0_mbus_dram_info,
  339. .shared_smi = &mv78xx0_ge00_shared,
  340. };
  341. static struct resource mv78xx0_ge10_shared_resources[] = {
  342. {
  343. .name = "ge10 base",
  344. .start = GE10_PHYS_BASE + 0x2000,
  345. .end = GE10_PHYS_BASE + 0x3fff,
  346. .flags = IORESOURCE_MEM,
  347. },
  348. };
  349. static struct platform_device mv78xx0_ge10_shared = {
  350. .name = MV643XX_ETH_SHARED_NAME,
  351. .id = 2,
  352. .dev = {
  353. .platform_data = &mv78xx0_ge10_shared_data,
  354. },
  355. .num_resources = 1,
  356. .resource = mv78xx0_ge10_shared_resources,
  357. };
  358. static struct resource mv78xx0_ge10_resources[] = {
  359. {
  360. .name = "ge10 irq",
  361. .start = IRQ_MV78XX0_GE10_SUM,
  362. .end = IRQ_MV78XX0_GE10_SUM,
  363. .flags = IORESOURCE_IRQ,
  364. },
  365. };
  366. static struct platform_device mv78xx0_ge10 = {
  367. .name = MV643XX_ETH_NAME,
  368. .id = 2,
  369. .num_resources = 1,
  370. .resource = mv78xx0_ge10_resources,
  371. };
  372. void __init mv78xx0_ge10_init(struct mv643xx_eth_platform_data *eth_data)
  373. {
  374. eth_data->shared = &mv78xx0_ge10_shared;
  375. mv78xx0_ge10.dev.platform_data = eth_data;
  376. platform_device_register(&mv78xx0_ge10_shared);
  377. platform_device_register(&mv78xx0_ge10);
  378. }
  379. /*****************************************************************************
  380. * GE11
  381. ****************************************************************************/
  382. struct mv643xx_eth_shared_platform_data mv78xx0_ge11_shared_data = {
  383. .t_clk = 0,
  384. .dram = &mv78xx0_mbus_dram_info,
  385. .shared_smi = &mv78xx0_ge00_shared,
  386. };
  387. static struct resource mv78xx0_ge11_shared_resources[] = {
  388. {
  389. .name = "ge11 base",
  390. .start = GE11_PHYS_BASE + 0x2000,
  391. .end = GE11_PHYS_BASE + 0x3fff,
  392. .flags = IORESOURCE_MEM,
  393. },
  394. };
  395. static struct platform_device mv78xx0_ge11_shared = {
  396. .name = MV643XX_ETH_SHARED_NAME,
  397. .id = 3,
  398. .dev = {
  399. .platform_data = &mv78xx0_ge11_shared_data,
  400. },
  401. .num_resources = 1,
  402. .resource = mv78xx0_ge11_shared_resources,
  403. };
  404. static struct resource mv78xx0_ge11_resources[] = {
  405. {
  406. .name = "ge11 irq",
  407. .start = IRQ_MV78XX0_GE11_SUM,
  408. .end = IRQ_MV78XX0_GE11_SUM,
  409. .flags = IORESOURCE_IRQ,
  410. },
  411. };
  412. static struct platform_device mv78xx0_ge11 = {
  413. .name = MV643XX_ETH_NAME,
  414. .id = 3,
  415. .num_resources = 1,
  416. .resource = mv78xx0_ge11_resources,
  417. };
  418. void __init mv78xx0_ge11_init(struct mv643xx_eth_platform_data *eth_data)
  419. {
  420. eth_data->shared = &mv78xx0_ge11_shared;
  421. mv78xx0_ge11.dev.platform_data = eth_data;
  422. platform_device_register(&mv78xx0_ge11_shared);
  423. platform_device_register(&mv78xx0_ge11);
  424. }
  425. /*****************************************************************************
  426. * SATA
  427. ****************************************************************************/
  428. static struct resource mv78xx0_sata_resources[] = {
  429. {
  430. .name = "sata base",
  431. .start = SATA_PHYS_BASE,
  432. .end = SATA_PHYS_BASE + 0x5000 - 1,
  433. .flags = IORESOURCE_MEM,
  434. }, {
  435. .name = "sata irq",
  436. .start = IRQ_MV78XX0_SATA,
  437. .end = IRQ_MV78XX0_SATA,
  438. .flags = IORESOURCE_IRQ,
  439. },
  440. };
  441. static struct platform_device mv78xx0_sata = {
  442. .name = "sata_mv",
  443. .id = 0,
  444. .dev = {
  445. .coherent_dma_mask = 0xffffffff,
  446. },
  447. .num_resources = ARRAY_SIZE(mv78xx0_sata_resources),
  448. .resource = mv78xx0_sata_resources,
  449. };
  450. void __init mv78xx0_sata_init(struct mv_sata_platform_data *sata_data)
  451. {
  452. sata_data->dram = &mv78xx0_mbus_dram_info;
  453. mv78xx0_sata.dev.platform_data = sata_data;
  454. platform_device_register(&mv78xx0_sata);
  455. }
  456. /*****************************************************************************
  457. * UART0
  458. ****************************************************************************/
  459. static struct plat_serial8250_port mv78xx0_uart0_data[] = {
  460. {
  461. .mapbase = UART0_PHYS_BASE,
  462. .membase = (char *)UART0_VIRT_BASE,
  463. .irq = IRQ_MV78XX0_UART_0,
  464. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  465. .iotype = UPIO_MEM,
  466. .regshift = 2,
  467. .uartclk = 0,
  468. }, {
  469. },
  470. };
  471. static struct resource mv78xx0_uart0_resources[] = {
  472. {
  473. .start = UART0_PHYS_BASE,
  474. .end = UART0_PHYS_BASE + 0xff,
  475. .flags = IORESOURCE_MEM,
  476. }, {
  477. .start = IRQ_MV78XX0_UART_0,
  478. .end = IRQ_MV78XX0_UART_0,
  479. .flags = IORESOURCE_IRQ,
  480. },
  481. };
  482. static struct platform_device mv78xx0_uart0 = {
  483. .name = "serial8250",
  484. .id = 0,
  485. .dev = {
  486. .platform_data = mv78xx0_uart0_data,
  487. },
  488. .resource = mv78xx0_uart0_resources,
  489. .num_resources = ARRAY_SIZE(mv78xx0_uart0_resources),
  490. };
  491. void __init mv78xx0_uart0_init(void)
  492. {
  493. platform_device_register(&mv78xx0_uart0);
  494. }
  495. /*****************************************************************************
  496. * UART1
  497. ****************************************************************************/
  498. static struct plat_serial8250_port mv78xx0_uart1_data[] = {
  499. {
  500. .mapbase = UART1_PHYS_BASE,
  501. .membase = (char *)UART1_VIRT_BASE,
  502. .irq = IRQ_MV78XX0_UART_1,
  503. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  504. .iotype = UPIO_MEM,
  505. .regshift = 2,
  506. .uartclk = 0,
  507. }, {
  508. },
  509. };
  510. static struct resource mv78xx0_uart1_resources[] = {
  511. {
  512. .start = UART1_PHYS_BASE,
  513. .end = UART1_PHYS_BASE + 0xff,
  514. .flags = IORESOURCE_MEM,
  515. }, {
  516. .start = IRQ_MV78XX0_UART_1,
  517. .end = IRQ_MV78XX0_UART_1,
  518. .flags = IORESOURCE_IRQ,
  519. },
  520. };
  521. static struct platform_device mv78xx0_uart1 = {
  522. .name = "serial8250",
  523. .id = 1,
  524. .dev = {
  525. .platform_data = mv78xx0_uart1_data,
  526. },
  527. .resource = mv78xx0_uart1_resources,
  528. .num_resources = ARRAY_SIZE(mv78xx0_uart1_resources),
  529. };
  530. void __init mv78xx0_uart1_init(void)
  531. {
  532. platform_device_register(&mv78xx0_uart1);
  533. }
  534. /*****************************************************************************
  535. * UART2
  536. ****************************************************************************/
  537. static struct plat_serial8250_port mv78xx0_uart2_data[] = {
  538. {
  539. .mapbase = UART2_PHYS_BASE,
  540. .membase = (char *)UART2_VIRT_BASE,
  541. .irq = IRQ_MV78XX0_UART_2,
  542. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  543. .iotype = UPIO_MEM,
  544. .regshift = 2,
  545. .uartclk = 0,
  546. }, {
  547. },
  548. };
  549. static struct resource mv78xx0_uart2_resources[] = {
  550. {
  551. .start = UART2_PHYS_BASE,
  552. .end = UART2_PHYS_BASE + 0xff,
  553. .flags = IORESOURCE_MEM,
  554. }, {
  555. .start = IRQ_MV78XX0_UART_2,
  556. .end = IRQ_MV78XX0_UART_2,
  557. .flags = IORESOURCE_IRQ,
  558. },
  559. };
  560. static struct platform_device mv78xx0_uart2 = {
  561. .name = "serial8250",
  562. .id = 2,
  563. .dev = {
  564. .platform_data = mv78xx0_uart2_data,
  565. },
  566. .resource = mv78xx0_uart2_resources,
  567. .num_resources = ARRAY_SIZE(mv78xx0_uart2_resources),
  568. };
  569. void __init mv78xx0_uart2_init(void)
  570. {
  571. platform_device_register(&mv78xx0_uart2);
  572. }
  573. /*****************************************************************************
  574. * UART3
  575. ****************************************************************************/
  576. static struct plat_serial8250_port mv78xx0_uart3_data[] = {
  577. {
  578. .mapbase = UART3_PHYS_BASE,
  579. .membase = (char *)UART3_VIRT_BASE,
  580. .irq = IRQ_MV78XX0_UART_3,
  581. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  582. .iotype = UPIO_MEM,
  583. .regshift = 2,
  584. .uartclk = 0,
  585. }, {
  586. },
  587. };
  588. static struct resource mv78xx0_uart3_resources[] = {
  589. {
  590. .start = UART3_PHYS_BASE,
  591. .end = UART3_PHYS_BASE + 0xff,
  592. .flags = IORESOURCE_MEM,
  593. }, {
  594. .start = IRQ_MV78XX0_UART_3,
  595. .end = IRQ_MV78XX0_UART_3,
  596. .flags = IORESOURCE_IRQ,
  597. },
  598. };
  599. static struct platform_device mv78xx0_uart3 = {
  600. .name = "serial8250",
  601. .id = 3,
  602. .dev = {
  603. .platform_data = mv78xx0_uart3_data,
  604. },
  605. .resource = mv78xx0_uart3_resources,
  606. .num_resources = ARRAY_SIZE(mv78xx0_uart3_resources),
  607. };
  608. void __init mv78xx0_uart3_init(void)
  609. {
  610. platform_device_register(&mv78xx0_uart3);
  611. }
  612. /*****************************************************************************
  613. * Time handling
  614. ****************************************************************************/
  615. static void mv78xx0_timer_init(void)
  616. {
  617. orion_time_init(IRQ_MV78XX0_TIMER_1, get_tclk());
  618. }
  619. struct sys_timer mv78xx0_timer = {
  620. .init = mv78xx0_timer_init,
  621. };
  622. /*****************************************************************************
  623. * General
  624. ****************************************************************************/
  625. static int __init is_l2_writethrough(void)
  626. {
  627. return !!(readl(CPU_CONTROL) & L2_WRITETHROUGH);
  628. }
  629. void __init mv78xx0_init(void)
  630. {
  631. int core_index;
  632. int hclk;
  633. int pclk;
  634. int l2clk;
  635. int tclk;
  636. core_index = mv78xx0_core_index();
  637. hclk = get_hclk();
  638. get_pclk_l2clk(hclk, core_index, &pclk, &l2clk);
  639. tclk = get_tclk();
  640. printk(KERN_INFO "MV78xx0 core #%d, ", core_index);
  641. printk("PCLK = %dMHz, ", (pclk + 499999) / 1000000);
  642. printk("L2 = %dMHz, ", (l2clk + 499999) / 1000000);
  643. printk("HCLK = %dMHz, ", (hclk + 499999) / 1000000);
  644. printk("TCLK = %dMHz\n", (tclk + 499999) / 1000000);
  645. mv78xx0_setup_cpu_mbus();
  646. #ifdef CONFIG_CACHE_FEROCEON_L2
  647. feroceon_l2_init(is_l2_writethrough());
  648. #endif
  649. mv78xx0_ge00_shared_data.t_clk = tclk;
  650. mv78xx0_ge01_shared_data.t_clk = tclk;
  651. mv78xx0_ge10_shared_data.t_clk = tclk;
  652. mv78xx0_ge11_shared_data.t_clk = tclk;
  653. mv78xx0_uart0_data[0].uartclk = tclk;
  654. mv78xx0_uart1_data[0].uartclk = tclk;
  655. mv78xx0_uart2_data[0].uartclk = tclk;
  656. mv78xx0_uart3_data[0].uartclk = tclk;
  657. }