common.c 21 KB

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