common.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  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 <asm/arch/mv78xx0.h>
  20. #include <asm/plat-orion/cache-feroceon-l2.h>
  21. #include <asm/plat-orion/ehci-orion.h>
  22. #include <asm/plat-orion/orion_nand.h>
  23. #include <asm/plat-orion/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. };
  252. static struct platform_device mv78xx0_ge00_shared = {
  253. .name = MV643XX_ETH_SHARED_NAME,
  254. .id = 0,
  255. .dev = {
  256. .platform_data = &mv78xx0_ge00_shared_data,
  257. },
  258. .num_resources = 1,
  259. .resource = mv78xx0_ge00_shared_resources,
  260. };
  261. static struct resource mv78xx0_ge00_resources[] = {
  262. {
  263. .name = "ge00 irq",
  264. .start = IRQ_MV78XX0_GE00_SUM,
  265. .end = IRQ_MV78XX0_GE00_SUM,
  266. .flags = IORESOURCE_IRQ,
  267. },
  268. };
  269. static struct platform_device mv78xx0_ge00 = {
  270. .name = MV643XX_ETH_NAME,
  271. .id = 0,
  272. .num_resources = 1,
  273. .resource = mv78xx0_ge00_resources,
  274. };
  275. void __init mv78xx0_ge00_init(struct mv643xx_eth_platform_data *eth_data)
  276. {
  277. eth_data->shared = &mv78xx0_ge00_shared;
  278. mv78xx0_ge00.dev.platform_data = eth_data;
  279. platform_device_register(&mv78xx0_ge00_shared);
  280. platform_device_register(&mv78xx0_ge00);
  281. }
  282. /*****************************************************************************
  283. * GE01
  284. ****************************************************************************/
  285. struct mv643xx_eth_shared_platform_data mv78xx0_ge01_shared_data = {
  286. .t_clk = 0,
  287. .dram = &mv78xx0_mbus_dram_info,
  288. };
  289. static struct resource mv78xx0_ge01_shared_resources[] = {
  290. {
  291. .name = "ge01 base",
  292. .start = GE01_PHYS_BASE + 0x2000,
  293. .end = GE01_PHYS_BASE + 0x3fff,
  294. .flags = IORESOURCE_MEM,
  295. },
  296. };
  297. static struct platform_device mv78xx0_ge01_shared = {
  298. .name = MV643XX_ETH_SHARED_NAME,
  299. .id = 1,
  300. .dev = {
  301. .platform_data = &mv78xx0_ge01_shared_data,
  302. },
  303. .num_resources = 1,
  304. .resource = mv78xx0_ge01_shared_resources,
  305. };
  306. static struct resource mv78xx0_ge01_resources[] = {
  307. {
  308. .name = "ge01 irq",
  309. .start = IRQ_MV78XX0_GE01_SUM,
  310. .end = IRQ_MV78XX0_GE01_SUM,
  311. .flags = IORESOURCE_IRQ,
  312. },
  313. };
  314. static struct platform_device mv78xx0_ge01 = {
  315. .name = MV643XX_ETH_NAME,
  316. .id = 1,
  317. .num_resources = 1,
  318. .resource = mv78xx0_ge01_resources,
  319. };
  320. void __init mv78xx0_ge01_init(struct mv643xx_eth_platform_data *eth_data)
  321. {
  322. eth_data->shared = &mv78xx0_ge01_shared;
  323. eth_data->shared_smi = &mv78xx0_ge00_shared;
  324. mv78xx0_ge01.dev.platform_data = eth_data;
  325. platform_device_register(&mv78xx0_ge01_shared);
  326. platform_device_register(&mv78xx0_ge01);
  327. }
  328. /*****************************************************************************
  329. * GE10
  330. ****************************************************************************/
  331. struct mv643xx_eth_shared_platform_data mv78xx0_ge10_shared_data = {
  332. .t_clk = 0,
  333. .dram = &mv78xx0_mbus_dram_info,
  334. };
  335. static struct resource mv78xx0_ge10_shared_resources[] = {
  336. {
  337. .name = "ge10 base",
  338. .start = GE10_PHYS_BASE + 0x2000,
  339. .end = GE10_PHYS_BASE + 0x3fff,
  340. .flags = IORESOURCE_MEM,
  341. },
  342. };
  343. static struct platform_device mv78xx0_ge10_shared = {
  344. .name = MV643XX_ETH_SHARED_NAME,
  345. .id = 2,
  346. .dev = {
  347. .platform_data = &mv78xx0_ge10_shared_data,
  348. },
  349. .num_resources = 1,
  350. .resource = mv78xx0_ge10_shared_resources,
  351. };
  352. static struct resource mv78xx0_ge10_resources[] = {
  353. {
  354. .name = "ge10 irq",
  355. .start = IRQ_MV78XX0_GE10_SUM,
  356. .end = IRQ_MV78XX0_GE10_SUM,
  357. .flags = IORESOURCE_IRQ,
  358. },
  359. };
  360. static struct platform_device mv78xx0_ge10 = {
  361. .name = MV643XX_ETH_NAME,
  362. .id = 2,
  363. .num_resources = 1,
  364. .resource = mv78xx0_ge10_resources,
  365. };
  366. void __init mv78xx0_ge10_init(struct mv643xx_eth_platform_data *eth_data)
  367. {
  368. eth_data->shared = &mv78xx0_ge10_shared;
  369. eth_data->shared_smi = &mv78xx0_ge00_shared;
  370. mv78xx0_ge10.dev.platform_data = eth_data;
  371. platform_device_register(&mv78xx0_ge10_shared);
  372. platform_device_register(&mv78xx0_ge10);
  373. }
  374. /*****************************************************************************
  375. * GE11
  376. ****************************************************************************/
  377. struct mv643xx_eth_shared_platform_data mv78xx0_ge11_shared_data = {
  378. .t_clk = 0,
  379. .dram = &mv78xx0_mbus_dram_info,
  380. };
  381. static struct resource mv78xx0_ge11_shared_resources[] = {
  382. {
  383. .name = "ge11 base",
  384. .start = GE11_PHYS_BASE + 0x2000,
  385. .end = GE11_PHYS_BASE + 0x3fff,
  386. .flags = IORESOURCE_MEM,
  387. },
  388. };
  389. static struct platform_device mv78xx0_ge11_shared = {
  390. .name = MV643XX_ETH_SHARED_NAME,
  391. .id = 3,
  392. .dev = {
  393. .platform_data = &mv78xx0_ge11_shared_data,
  394. },
  395. .num_resources = 1,
  396. .resource = mv78xx0_ge11_shared_resources,
  397. };
  398. static struct resource mv78xx0_ge11_resources[] = {
  399. {
  400. .name = "ge11 irq",
  401. .start = IRQ_MV78XX0_GE11_SUM,
  402. .end = IRQ_MV78XX0_GE11_SUM,
  403. .flags = IORESOURCE_IRQ,
  404. },
  405. };
  406. static struct platform_device mv78xx0_ge11 = {
  407. .name = MV643XX_ETH_NAME,
  408. .id = 3,
  409. .num_resources = 1,
  410. .resource = mv78xx0_ge11_resources,
  411. };
  412. void __init mv78xx0_ge11_init(struct mv643xx_eth_platform_data *eth_data)
  413. {
  414. eth_data->shared = &mv78xx0_ge11_shared;
  415. eth_data->shared_smi = &mv78xx0_ge00_shared;
  416. mv78xx0_ge11.dev.platform_data = eth_data;
  417. platform_device_register(&mv78xx0_ge11_shared);
  418. platform_device_register(&mv78xx0_ge11);
  419. }
  420. /*****************************************************************************
  421. * SATA
  422. ****************************************************************************/
  423. static struct resource mv78xx0_sata_resources[] = {
  424. {
  425. .name = "sata base",
  426. .start = SATA_PHYS_BASE,
  427. .end = SATA_PHYS_BASE + 0x5000 - 1,
  428. .flags = IORESOURCE_MEM,
  429. }, {
  430. .name = "sata irq",
  431. .start = IRQ_MV78XX0_SATA,
  432. .end = IRQ_MV78XX0_SATA,
  433. .flags = IORESOURCE_IRQ,
  434. },
  435. };
  436. static struct platform_device mv78xx0_sata = {
  437. .name = "sata_mv",
  438. .id = 0,
  439. .dev = {
  440. .coherent_dma_mask = 0xffffffff,
  441. },
  442. .num_resources = ARRAY_SIZE(mv78xx0_sata_resources),
  443. .resource = mv78xx0_sata_resources,
  444. };
  445. void __init mv78xx0_sata_init(struct mv_sata_platform_data *sata_data)
  446. {
  447. sata_data->dram = &mv78xx0_mbus_dram_info;
  448. mv78xx0_sata.dev.platform_data = sata_data;
  449. platform_device_register(&mv78xx0_sata);
  450. }
  451. /*****************************************************************************
  452. * UART0
  453. ****************************************************************************/
  454. static struct plat_serial8250_port mv78xx0_uart0_data[] = {
  455. {
  456. .mapbase = UART0_PHYS_BASE,
  457. .membase = (char *)UART0_VIRT_BASE,
  458. .irq = IRQ_MV78XX0_UART_0,
  459. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  460. .iotype = UPIO_MEM,
  461. .regshift = 2,
  462. .uartclk = 0,
  463. }, {
  464. },
  465. };
  466. static struct resource mv78xx0_uart0_resources[] = {
  467. {
  468. .start = UART0_PHYS_BASE,
  469. .end = UART0_PHYS_BASE + 0xff,
  470. .flags = IORESOURCE_MEM,
  471. }, {
  472. .start = IRQ_MV78XX0_UART_0,
  473. .end = IRQ_MV78XX0_UART_0,
  474. .flags = IORESOURCE_IRQ,
  475. },
  476. };
  477. static struct platform_device mv78xx0_uart0 = {
  478. .name = "serial8250",
  479. .id = 0,
  480. .dev = {
  481. .platform_data = mv78xx0_uart0_data,
  482. },
  483. .resource = mv78xx0_uart0_resources,
  484. .num_resources = ARRAY_SIZE(mv78xx0_uart0_resources),
  485. };
  486. void __init mv78xx0_uart0_init(void)
  487. {
  488. platform_device_register(&mv78xx0_uart0);
  489. }
  490. /*****************************************************************************
  491. * UART1
  492. ****************************************************************************/
  493. static struct plat_serial8250_port mv78xx0_uart1_data[] = {
  494. {
  495. .mapbase = UART1_PHYS_BASE,
  496. .membase = (char *)UART1_VIRT_BASE,
  497. .irq = IRQ_MV78XX0_UART_1,
  498. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  499. .iotype = UPIO_MEM,
  500. .regshift = 2,
  501. .uartclk = 0,
  502. }, {
  503. },
  504. };
  505. static struct resource mv78xx0_uart1_resources[] = {
  506. {
  507. .start = UART1_PHYS_BASE,
  508. .end = UART1_PHYS_BASE + 0xff,
  509. .flags = IORESOURCE_MEM,
  510. }, {
  511. .start = IRQ_MV78XX0_UART_1,
  512. .end = IRQ_MV78XX0_UART_1,
  513. .flags = IORESOURCE_IRQ,
  514. },
  515. };
  516. static struct platform_device mv78xx0_uart1 = {
  517. .name = "serial8250",
  518. .id = 1,
  519. .dev = {
  520. .platform_data = mv78xx0_uart1_data,
  521. },
  522. .resource = mv78xx0_uart1_resources,
  523. .num_resources = ARRAY_SIZE(mv78xx0_uart1_resources),
  524. };
  525. void __init mv78xx0_uart1_init(void)
  526. {
  527. platform_device_register(&mv78xx0_uart1);
  528. }
  529. /*****************************************************************************
  530. * UART2
  531. ****************************************************************************/
  532. static struct plat_serial8250_port mv78xx0_uart2_data[] = {
  533. {
  534. .mapbase = UART2_PHYS_BASE,
  535. .membase = (char *)UART2_VIRT_BASE,
  536. .irq = IRQ_MV78XX0_UART_2,
  537. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  538. .iotype = UPIO_MEM,
  539. .regshift = 2,
  540. .uartclk = 0,
  541. }, {
  542. },
  543. };
  544. static struct resource mv78xx0_uart2_resources[] = {
  545. {
  546. .start = UART2_PHYS_BASE,
  547. .end = UART2_PHYS_BASE + 0xff,
  548. .flags = IORESOURCE_MEM,
  549. }, {
  550. .start = IRQ_MV78XX0_UART_2,
  551. .end = IRQ_MV78XX0_UART_2,
  552. .flags = IORESOURCE_IRQ,
  553. },
  554. };
  555. static struct platform_device mv78xx0_uart2 = {
  556. .name = "serial8250",
  557. .id = 2,
  558. .dev = {
  559. .platform_data = mv78xx0_uart2_data,
  560. },
  561. .resource = mv78xx0_uart2_resources,
  562. .num_resources = ARRAY_SIZE(mv78xx0_uart2_resources),
  563. };
  564. void __init mv78xx0_uart2_init(void)
  565. {
  566. platform_device_register(&mv78xx0_uart2);
  567. }
  568. /*****************************************************************************
  569. * UART3
  570. ****************************************************************************/
  571. static struct plat_serial8250_port mv78xx0_uart3_data[] = {
  572. {
  573. .mapbase = UART3_PHYS_BASE,
  574. .membase = (char *)UART3_VIRT_BASE,
  575. .irq = IRQ_MV78XX0_UART_3,
  576. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  577. .iotype = UPIO_MEM,
  578. .regshift = 2,
  579. .uartclk = 0,
  580. }, {
  581. },
  582. };
  583. static struct resource mv78xx0_uart3_resources[] = {
  584. {
  585. .start = UART3_PHYS_BASE,
  586. .end = UART3_PHYS_BASE + 0xff,
  587. .flags = IORESOURCE_MEM,
  588. }, {
  589. .start = IRQ_MV78XX0_UART_3,
  590. .end = IRQ_MV78XX0_UART_3,
  591. .flags = IORESOURCE_IRQ,
  592. },
  593. };
  594. static struct platform_device mv78xx0_uart3 = {
  595. .name = "serial8250",
  596. .id = 3,
  597. .dev = {
  598. .platform_data = mv78xx0_uart3_data,
  599. },
  600. .resource = mv78xx0_uart3_resources,
  601. .num_resources = ARRAY_SIZE(mv78xx0_uart3_resources),
  602. };
  603. void __init mv78xx0_uart3_init(void)
  604. {
  605. platform_device_register(&mv78xx0_uart3);
  606. }
  607. /*****************************************************************************
  608. * Time handling
  609. ****************************************************************************/
  610. static void mv78xx0_timer_init(void)
  611. {
  612. orion_time_init(IRQ_MV78XX0_TIMER_1, get_tclk());
  613. }
  614. struct sys_timer mv78xx0_timer = {
  615. .init = mv78xx0_timer_init,
  616. };
  617. /*****************************************************************************
  618. * General
  619. ****************************************************************************/
  620. static int __init is_l2_writethrough(void)
  621. {
  622. return !!(readl(CPU_CONTROL) & L2_WRITETHROUGH);
  623. }
  624. void __init mv78xx0_init(void)
  625. {
  626. int core_index;
  627. int hclk;
  628. int pclk;
  629. int l2clk;
  630. int tclk;
  631. core_index = mv78xx0_core_index();
  632. hclk = get_hclk();
  633. get_pclk_l2clk(hclk, core_index, &pclk, &l2clk);
  634. tclk = get_tclk();
  635. printk(KERN_INFO "MV78xx0 core #%d, ", core_index);
  636. printk("PCLK = %dMHz, ", (pclk + 499999) / 1000000);
  637. printk("L2 = %dMHz, ", (l2clk + 499999) / 1000000);
  638. printk("HCLK = %dMHz, ", (hclk + 499999) / 1000000);
  639. printk("TCLK = %dMHz\n", (tclk + 499999) / 1000000);
  640. mv78xx0_setup_cpu_mbus();
  641. #ifdef CONFIG_CACHE_FEROCEON_L2
  642. feroceon_l2_init(is_l2_writethrough());
  643. #endif
  644. mv78xx0_ge00_shared_data.t_clk = tclk;
  645. mv78xx0_ge01_shared_data.t_clk = tclk;
  646. mv78xx0_ge10_shared_data.t_clk = tclk;
  647. mv78xx0_ge11_shared_data.t_clk = tclk;
  648. mv78xx0_uart0_data[0].uartclk = tclk;
  649. mv78xx0_uart1_data[0].uartclk = tclk;
  650. mv78xx0_uart2_data[0].uartclk = tclk;
  651. mv78xx0_uart3_data[0].uartclk = tclk;
  652. }