katana.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  1. /*
  2. * arch/ppc/platforms/katana.c
  3. *
  4. * Board setup routines for the Artesyn Katana cPCI boards.
  5. *
  6. * Author: Tim Montgomery <timm@artesyncp.com>
  7. * Maintained by: Mark A. Greer <mgreer@mvista.com>
  8. *
  9. * Based on code done by Rabeeh Khoury - rabeeh@galileo.co.il
  10. * Based on code done by - Mark A. Greer <mgreer@mvista.com>
  11. *
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU General Public License as published by the
  14. * Free Software Foundation; either version 2 of the License, or (at your
  15. * option) any later version.
  16. */
  17. /*
  18. * Supports the Artesyn 750i, 752i, and 3750. The 752i is virtually identical
  19. * to the 750i except that it has an mv64460 bridge.
  20. */
  21. #include <linux/config.h>
  22. #include <linux/kernel.h>
  23. #include <linux/pci.h>
  24. #include <linux/kdev_t.h>
  25. #include <linux/console.h>
  26. #include <linux/initrd.h>
  27. #include <linux/root_dev.h>
  28. #include <linux/delay.h>
  29. #include <linux/seq_file.h>
  30. #include <linux/mtd/physmap.h>
  31. #include <linux/mv643xx.h>
  32. #ifdef CONFIG_BOOTIMG
  33. #include <linux/bootimg.h>
  34. #endif
  35. #include <asm/io.h>
  36. #include <asm/page.h>
  37. #include <asm/time.h>
  38. #include <asm/smp.h>
  39. #include <asm/todc.h>
  40. #include <asm/bootinfo.h>
  41. #include <asm/ppcboot.h>
  42. #include <asm/mv64x60.h>
  43. #include <platforms/katana.h>
  44. static struct mv64x60_handle bh;
  45. static katana_id_t katana_id;
  46. static void __iomem *cpld_base;
  47. static void __iomem *sram_base;
  48. static u32 katana_flash_size_0;
  49. static u32 katana_flash_size_1;
  50. static u32 katana_bus_frequency;
  51. unsigned char __res[sizeof(bd_t)];
  52. /* PCI Interrupt routing */
  53. static int __init
  54. katana_irq_lookup_750i(unsigned char idsel, unsigned char pin)
  55. {
  56. static char pci_irq_table[][4] = {
  57. /*
  58. * PCI IDSEL/INTPIN->INTLINE
  59. * A B C D
  60. */
  61. /* IDSEL 4 (PMC 1) */
  62. { KATANA_PCI_INTB_IRQ_750i, KATANA_PCI_INTC_IRQ_750i,
  63. KATANA_PCI_INTD_IRQ_750i, KATANA_PCI_INTA_IRQ_750i },
  64. /* IDSEL 5 (PMC 2) */
  65. { KATANA_PCI_INTC_IRQ_750i, KATANA_PCI_INTD_IRQ_750i,
  66. KATANA_PCI_INTA_IRQ_750i, KATANA_PCI_INTB_IRQ_750i },
  67. /* IDSEL 6 (T8110) */
  68. {KATANA_PCI_INTD_IRQ_750i, 0, 0, 0 },
  69. };
  70. const long min_idsel = 4, max_idsel = 6, irqs_per_slot = 4;
  71. return PCI_IRQ_TABLE_LOOKUP;
  72. }
  73. static int __init
  74. katana_irq_lookup_3750(unsigned char idsel, unsigned char pin)
  75. {
  76. static char pci_irq_table[][4] = {
  77. /*
  78. * PCI IDSEL/INTPIN->INTLINE
  79. * A B C D
  80. */
  81. { KATANA_PCI_INTA_IRQ_3750, 0, 0, 0 }, /* IDSEL 3 (BCM5691) */
  82. { KATANA_PCI_INTB_IRQ_3750, 0, 0, 0 }, /* IDSEL 4 (MV64360 #2)*/
  83. { KATANA_PCI_INTC_IRQ_3750, 0, 0, 0 }, /* IDSEL 5 (MV64360 #3)*/
  84. };
  85. const long min_idsel = 3, max_idsel = 5, irqs_per_slot = 4;
  86. return PCI_IRQ_TABLE_LOOKUP;
  87. }
  88. static int __init
  89. katana_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  90. {
  91. switch (katana_id) {
  92. case KATANA_ID_750I:
  93. case KATANA_ID_752I:
  94. return katana_irq_lookup_750i(idsel, pin);
  95. case KATANA_ID_3750:
  96. return katana_irq_lookup_3750(idsel, pin);
  97. default:
  98. printk(KERN_ERR "Bogus board ID\n");
  99. return 0;
  100. }
  101. }
  102. /* Board info retrieval routines */
  103. void __init
  104. katana_get_board_id(void)
  105. {
  106. switch (in_8(cpld_base + KATANA_CPLD_PRODUCT_ID)) {
  107. case KATANA_PRODUCT_ID_3750:
  108. katana_id = KATANA_ID_3750;
  109. break;
  110. case KATANA_PRODUCT_ID_750i:
  111. katana_id = KATANA_ID_750I;
  112. break;
  113. case KATANA_PRODUCT_ID_752i:
  114. katana_id = KATANA_ID_752I;
  115. break;
  116. default:
  117. printk(KERN_ERR "Unsupported board\n");
  118. }
  119. }
  120. int __init
  121. katana_get_proc_num(void)
  122. {
  123. u16 val;
  124. u8 save_exclude;
  125. static int proc = -1;
  126. static u8 first_time = 1;
  127. if (first_time) {
  128. if (katana_id != KATANA_ID_3750)
  129. proc = 0;
  130. else {
  131. save_exclude = mv64x60_pci_exclude_bridge;
  132. mv64x60_pci_exclude_bridge = 0;
  133. early_read_config_word(bh.hose_a, 0,
  134. PCI_DEVFN(0,0), PCI_DEVICE_ID, &val);
  135. mv64x60_pci_exclude_bridge = save_exclude;
  136. switch(val) {
  137. case PCI_DEVICE_ID_KATANA_3750_PROC0:
  138. proc = 0;
  139. break;
  140. case PCI_DEVICE_ID_KATANA_3750_PROC1:
  141. proc = 1;
  142. break;
  143. case PCI_DEVICE_ID_KATANA_3750_PROC2:
  144. proc = 2;
  145. break;
  146. default:
  147. printk(KERN_ERR "Bogus Device ID\n");
  148. }
  149. }
  150. first_time = 0;
  151. }
  152. return proc;
  153. }
  154. static inline int
  155. katana_is_monarch(void)
  156. {
  157. return in_8(cpld_base + KATANA_CPLD_BD_CFG_3) &
  158. KATANA_CPLD_BD_CFG_3_MONARCH;
  159. }
  160. static void __init
  161. katana_setup_bridge(void)
  162. {
  163. struct pci_controller hose;
  164. struct mv64x60_setup_info si;
  165. void __iomem *vaddr;
  166. int i;
  167. u16 val;
  168. u8 save_exclude;
  169. /*
  170. * Some versions of the Katana firmware mistakenly change the vendor
  171. * & device id fields in the bridge's pci device (visible via pci
  172. * config accesses). This breaks mv64x60_init() because those values
  173. * are used to identify the type of bridge that's there. Artesyn
  174. * claims that the subsystem vendor/device id's will have the correct
  175. * Marvell values so this code puts back the correct values from there.
  176. */
  177. memset(&hose, 0, sizeof(hose));
  178. vaddr = ioremap(CONFIG_MV64X60_NEW_BASE, MV64x60_INTERNAL_SPACE_SIZE);
  179. setup_indirect_pci_nomap(&hose, vaddr + MV64x60_PCI0_CONFIG_ADDR,
  180. vaddr + MV64x60_PCI0_CONFIG_DATA);
  181. save_exclude = mv64x60_pci_exclude_bridge;
  182. mv64x60_pci_exclude_bridge = 0;
  183. early_read_config_word(&hose, 0, PCI_DEVFN(0, 0), PCI_VENDOR_ID, &val);
  184. if (val != PCI_VENDOR_ID_MARVELL) {
  185. early_read_config_word(&hose, 0, PCI_DEVFN(0, 0),
  186. PCI_SUBSYSTEM_VENDOR_ID, &val);
  187. early_write_config_word(&hose, 0, PCI_DEVFN(0, 0),
  188. PCI_VENDOR_ID, val);
  189. early_read_config_word(&hose, 0, PCI_DEVFN(0, 0),
  190. PCI_SUBSYSTEM_ID, &val);
  191. early_write_config_word(&hose, 0, PCI_DEVFN(0, 0),
  192. PCI_DEVICE_ID, val);
  193. }
  194. mv64x60_pci_exclude_bridge = save_exclude;
  195. iounmap(vaddr);
  196. memset(&si, 0, sizeof(si));
  197. si.phys_reg_base = CONFIG_MV64X60_NEW_BASE;
  198. si.pci_1.enable_bus = 1;
  199. si.pci_1.pci_io.cpu_base = KATANA_PCI1_IO_START_PROC_ADDR;
  200. si.pci_1.pci_io.pci_base_hi = 0;
  201. si.pci_1.pci_io.pci_base_lo = KATANA_PCI1_IO_START_PCI_ADDR;
  202. si.pci_1.pci_io.size = KATANA_PCI1_IO_SIZE;
  203. si.pci_1.pci_io.swap = MV64x60_CPU2PCI_SWAP_NONE;
  204. si.pci_1.pci_mem[0].cpu_base = KATANA_PCI1_MEM_START_PROC_ADDR;
  205. si.pci_1.pci_mem[0].pci_base_hi = KATANA_PCI1_MEM_START_PCI_HI_ADDR;
  206. si.pci_1.pci_mem[0].pci_base_lo = KATANA_PCI1_MEM_START_PCI_LO_ADDR;
  207. si.pci_1.pci_mem[0].size = KATANA_PCI1_MEM_SIZE;
  208. si.pci_1.pci_mem[0].swap = MV64x60_CPU2PCI_SWAP_NONE;
  209. si.pci_1.pci_cmd_bits = 0;
  210. si.pci_1.latency_timer = 0x80;
  211. for (i = 0; i < MV64x60_CPU2MEM_WINDOWS; i++) {
  212. #if defined(CONFIG_NOT_COHERENT_CACHE)
  213. si.cpu_prot_options[i] = 0;
  214. si.enet_options[i] = MV64360_ENET2MEM_SNOOP_NONE;
  215. si.mpsc_options[i] = MV64360_MPSC2MEM_SNOOP_NONE;
  216. si.idma_options[i] = MV64360_IDMA2MEM_SNOOP_NONE;
  217. si.pci_1.acc_cntl_options[i] =
  218. MV64360_PCI_ACC_CNTL_SNOOP_NONE |
  219. MV64360_PCI_ACC_CNTL_SWAP_NONE |
  220. MV64360_PCI_ACC_CNTL_MBURST_128_BYTES |
  221. MV64360_PCI_ACC_CNTL_RDSIZE_256_BYTES;
  222. #else
  223. si.cpu_prot_options[i] = 0;
  224. si.enet_options[i] = MV64360_ENET2MEM_SNOOP_NONE; /* errata */
  225. si.mpsc_options[i] = MV64360_MPSC2MEM_SNOOP_NONE; /* errata */
  226. si.idma_options[i] = MV64360_IDMA2MEM_SNOOP_NONE; /* errata */
  227. si.pci_1.acc_cntl_options[i] =
  228. MV64360_PCI_ACC_CNTL_SNOOP_WB |
  229. MV64360_PCI_ACC_CNTL_SWAP_NONE |
  230. MV64360_PCI_ACC_CNTL_MBURST_32_BYTES |
  231. MV64360_PCI_ACC_CNTL_RDSIZE_32_BYTES;
  232. #endif
  233. }
  234. /* Lookup PCI host bridges */
  235. if (mv64x60_init(&bh, &si))
  236. printk(KERN_WARNING "Bridge initialization failed.\n");
  237. pci_dram_offset = 0; /* sys mem at same addr on PCI & cpu bus */
  238. ppc_md.pci_swizzle = common_swizzle;
  239. ppc_md.pci_map_irq = katana_map_irq;
  240. ppc_md.pci_exclude_device = mv64x60_pci_exclude_device;
  241. mv64x60_set_bus(&bh, 1, 0);
  242. bh.hose_b->first_busno = 0;
  243. bh.hose_b->last_busno = 0xff;
  244. }
  245. /* Bridge & platform setup routines */
  246. void __init
  247. katana_intr_setup(void)
  248. {
  249. /* MPP 8, 9, and 10 */
  250. mv64x60_clr_bits(&bh, MV64x60_MPP_CNTL_1, 0xfff);
  251. /* MPP 14 */
  252. if ((katana_id == KATANA_ID_750I) || (katana_id == KATANA_ID_752I))
  253. mv64x60_clr_bits(&bh, MV64x60_MPP_CNTL_1, 0x0f000000);
  254. /*
  255. * Define GPP 8,9,and 10 interrupt polarity as active low
  256. * input signal and level triggered
  257. */
  258. mv64x60_set_bits(&bh, MV64x60_GPP_LEVEL_CNTL, 0x700);
  259. mv64x60_clr_bits(&bh, MV64x60_GPP_IO_CNTL, 0x700);
  260. if ((katana_id == KATANA_ID_750I) || (katana_id == KATANA_ID_752I)) {
  261. mv64x60_set_bits(&bh, MV64x60_GPP_LEVEL_CNTL, (1<<14));
  262. mv64x60_clr_bits(&bh, MV64x60_GPP_IO_CNTL, (1<<14));
  263. }
  264. /* Config GPP intr ctlr to respond to level trigger */
  265. mv64x60_set_bits(&bh, MV64x60_COMM_ARBITER_CNTL, (1<<10));
  266. /* Erranum FEr PCI-#8 */
  267. mv64x60_clr_bits(&bh, MV64x60_PCI0_CMD, (1<<5) | (1<<9));
  268. mv64x60_clr_bits(&bh, MV64x60_PCI1_CMD, (1<<5) | (1<<9));
  269. /*
  270. * Dismiss and then enable interrupt on GPP interrupt cause
  271. * for CPU #0
  272. */
  273. mv64x60_write(&bh, MV64x60_GPP_INTR_CAUSE, ~0x700);
  274. mv64x60_set_bits(&bh, MV64x60_GPP_INTR_MASK, 0x700);
  275. if ((katana_id == KATANA_ID_750I) || (katana_id == KATANA_ID_752I)) {
  276. mv64x60_write(&bh, MV64x60_GPP_INTR_CAUSE, ~(1<<14));
  277. mv64x60_set_bits(&bh, MV64x60_GPP_INTR_MASK, (1<<14));
  278. }
  279. /*
  280. * Dismiss and then enable interrupt on CPU #0 high cause reg
  281. * BIT25 summarizes GPP interrupts 8-15
  282. */
  283. mv64x60_set_bits(&bh, MV64360_IC_CPU0_INTR_MASK_HI, (1<<25));
  284. }
  285. void __init
  286. katana_setup_peripherals(void)
  287. {
  288. u32 base;
  289. /* Set up windows for boot CS, soldered & socketed flash, and CPLD */
  290. mv64x60_set_32bit_window(&bh, MV64x60_CPU2BOOT_WIN,
  291. KATANA_BOOT_WINDOW_BASE, KATANA_BOOT_WINDOW_SIZE, 0);
  292. bh.ci->enable_window_32bit(&bh, MV64x60_CPU2BOOT_WIN);
  293. /* Assume firmware set up window sizes correctly for dev 0 & 1 */
  294. mv64x60_get_32bit_window(&bh, MV64x60_CPU2DEV_0_WIN, &base,
  295. &katana_flash_size_0);
  296. if (katana_flash_size_0 > 0) {
  297. mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_0_WIN,
  298. KATANA_SOLDERED_FLASH_BASE, katana_flash_size_0, 0);
  299. bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_0_WIN);
  300. }
  301. mv64x60_get_32bit_window(&bh, MV64x60_CPU2DEV_1_WIN, &base,
  302. &katana_flash_size_1);
  303. if (katana_flash_size_1 > 0) {
  304. mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_1_WIN,
  305. (KATANA_SOLDERED_FLASH_BASE + katana_flash_size_0),
  306. katana_flash_size_1, 0);
  307. bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_1_WIN);
  308. }
  309. mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_2_WIN,
  310. KATANA_SOCKET_BASE, KATANA_SOCKETED_FLASH_SIZE, 0);
  311. bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_2_WIN);
  312. mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_3_WIN,
  313. KATANA_CPLD_BASE, KATANA_CPLD_SIZE, 0);
  314. bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_3_WIN);
  315. cpld_base = ioremap(KATANA_CPLD_BASE, KATANA_CPLD_SIZE);
  316. mv64x60_set_32bit_window(&bh, MV64x60_CPU2SRAM_WIN,
  317. KATANA_INTERNAL_SRAM_BASE, MV64360_SRAM_SIZE, 0);
  318. bh.ci->enable_window_32bit(&bh, MV64x60_CPU2SRAM_WIN);
  319. sram_base = ioremap(KATANA_INTERNAL_SRAM_BASE, MV64360_SRAM_SIZE);
  320. /* Set up Enet->SRAM window */
  321. mv64x60_set_32bit_window(&bh, MV64x60_ENET2MEM_4_WIN,
  322. KATANA_INTERNAL_SRAM_BASE, MV64360_SRAM_SIZE, 0x2);
  323. bh.ci->enable_window_32bit(&bh, MV64x60_ENET2MEM_4_WIN);
  324. /* Give enet r/w access to memory region */
  325. mv64x60_set_bits(&bh, MV64360_ENET2MEM_ACC_PROT_0, (0x3 << (4 << 1)));
  326. mv64x60_set_bits(&bh, MV64360_ENET2MEM_ACC_PROT_1, (0x3 << (4 << 1)));
  327. mv64x60_set_bits(&bh, MV64360_ENET2MEM_ACC_PROT_2, (0x3 << (4 << 1)));
  328. mv64x60_clr_bits(&bh, MV64x60_PCI1_PCI_DECODE_CNTL, (1 << 3));
  329. mv64x60_clr_bits(&bh, MV64x60_TIMR_CNTR_0_3_CNTL,
  330. ((1 << 0) | (1 << 8) | (1 << 16) | (1 << 24)));
  331. /* Must wait until window set up before retrieving board id */
  332. katana_get_board_id();
  333. /* Enumerate pci bus (must know board id before getting proc number) */
  334. if (katana_get_proc_num() == 0)
  335. bh.hose_b->last_busno = pciauto_bus_scan(bh.hose_b, 0);
  336. #if defined(CONFIG_NOT_COHERENT_CACHE)
  337. mv64x60_write(&bh, MV64360_SRAM_CONFIG, 0x00160000);
  338. #else
  339. mv64x60_write(&bh, MV64360_SRAM_CONFIG, 0x001600b2);
  340. #endif
  341. /*
  342. * Setting the SRAM to 0. Note that this generates parity errors on
  343. * internal data path in SRAM since it's first time accessing it
  344. * while after reset it's not configured.
  345. */
  346. memset(sram_base, 0, MV64360_SRAM_SIZE);
  347. /* Only processor zero [on 3750] is an PCI interrupt controller */
  348. if (katana_get_proc_num() == 0)
  349. katana_intr_setup();
  350. }
  351. static void __init
  352. katana_enable_ipmi(void)
  353. {
  354. u8 reset_out;
  355. /* Enable access to IPMI ctlr by clearing IPMI PORTSEL bit in CPLD */
  356. reset_out = in_8(cpld_base + KATANA_CPLD_RESET_OUT);
  357. reset_out &= ~KATANA_CPLD_RESET_OUT_PORTSEL;
  358. out_8(cpld_base + KATANA_CPLD_RESET_OUT, reset_out);
  359. }
  360. static void __init
  361. katana_setup_arch(void)
  362. {
  363. if (ppc_md.progress)
  364. ppc_md.progress("katana_setup_arch: enter", 0);
  365. set_tb(0, 0);
  366. #ifdef CONFIG_BLK_DEV_INITRD
  367. if (initrd_start)
  368. ROOT_DEV = Root_RAM0;
  369. else
  370. #endif
  371. #ifdef CONFIG_ROOT_NFS
  372. ROOT_DEV = Root_NFS;
  373. #else
  374. ROOT_DEV = Root_SDA2;
  375. #endif
  376. /*
  377. * Set up the L2CR register.
  378. *
  379. * 750FX has only L2E, L2PE (bits 2-8 are reserved)
  380. * DD2.0 has bug that requires the L2 to be in WRT mode
  381. * avoid dirty data in cache
  382. */
  383. if (PVR_REV(mfspr(SPRN_PVR)) == 0x0200) {
  384. printk(KERN_INFO "DD2.0 detected. Setting L2 cache"
  385. "to Writethrough mode\n");
  386. _set_L2CR(L2CR_L2E | L2CR_L2PE | L2CR_L2WT);
  387. } else
  388. _set_L2CR(L2CR_L2E | L2CR_L2PE);
  389. if (ppc_md.progress)
  390. ppc_md.progress("katana_setup_arch: calling setup_bridge", 0);
  391. katana_setup_bridge();
  392. katana_setup_peripherals();
  393. katana_enable_ipmi();
  394. katana_bus_frequency = katana_bus_freq(cpld_base);
  395. printk(KERN_INFO "Artesyn Communication Products, LLC - Katana(TM)\n");
  396. if (ppc_md.progress)
  397. ppc_md.progress("katana_setup_arch: exit", 0);
  398. }
  399. /* Platform device data fixup routines. */
  400. #if defined(CONFIG_SERIAL_MPSC)
  401. static void __init
  402. katana_fixup_mpsc_pdata(struct platform_device *pdev)
  403. {
  404. struct mpsc_pdata *pdata;
  405. pdata = (struct mpsc_pdata *)pdev->dev.platform_data;
  406. pdata->max_idle = 40;
  407. pdata->default_baud = KATANA_DEFAULT_BAUD;
  408. pdata->brg_clk_src = KATANA_MPSC_CLK_SRC;
  409. /*
  410. * TCLK (not SysCLk) is routed to BRG, then to the MPSC. On most parts,
  411. * TCLK == SysCLK but on 64460, they are separate pins.
  412. * SysCLK can go up to 200 MHz but TCLK can only go up to 133 MHz.
  413. */
  414. pdata->brg_clk_freq = min(katana_bus_frequency, MV64x60_TCLK_FREQ_MAX);
  415. }
  416. #endif
  417. #if defined(CONFIG_MV643XX_ETH)
  418. static void __init
  419. katana_fixup_eth_pdata(struct platform_device *pdev)
  420. {
  421. struct mv643xx_eth_platform_data *eth_pd;
  422. static u16 phy_addr[] = {
  423. KATANA_ETH0_PHY_ADDR,
  424. KATANA_ETH1_PHY_ADDR,
  425. KATANA_ETH2_PHY_ADDR,
  426. };
  427. eth_pd = pdev->dev.platform_data;
  428. eth_pd->force_phy_addr = 1;
  429. eth_pd->phy_addr = phy_addr[pdev->id];
  430. eth_pd->tx_queue_size = KATANA_ETH_TX_QUEUE_SIZE;
  431. eth_pd->rx_queue_size = KATANA_ETH_RX_QUEUE_SIZE;
  432. }
  433. #endif
  434. static int __init
  435. katana_platform_notify(struct device *dev)
  436. {
  437. static struct {
  438. char *bus_id;
  439. void ((*rtn)(struct platform_device *pdev));
  440. } dev_map[] = {
  441. #if defined(CONFIG_SERIAL_MPSC)
  442. { MPSC_CTLR_NAME ".0", katana_fixup_mpsc_pdata },
  443. { MPSC_CTLR_NAME ".1", katana_fixup_mpsc_pdata },
  444. #endif
  445. #if defined(CONFIG_MV643XX_ETH)
  446. { MV643XX_ETH_NAME ".0", katana_fixup_eth_pdata },
  447. { MV643XX_ETH_NAME ".1", katana_fixup_eth_pdata },
  448. { MV643XX_ETH_NAME ".2", katana_fixup_eth_pdata },
  449. #endif
  450. };
  451. struct platform_device *pdev;
  452. int i;
  453. if (dev && dev->bus_id)
  454. for (i=0; i<ARRAY_SIZE(dev_map); i++)
  455. if (!strncmp(dev->bus_id, dev_map[i].bus_id,
  456. BUS_ID_SIZE)) {
  457. pdev = container_of(dev,
  458. struct platform_device, dev);
  459. dev_map[i].rtn(pdev);
  460. }
  461. return 0;
  462. }
  463. #ifdef CONFIG_MTD_PHYSMAP
  464. #ifndef MB
  465. #define MB (1 << 20)
  466. #endif
  467. /*
  468. * MTD Layout depends on amount of soldered FLASH in system. Sizes in MB.
  469. *
  470. * FLASH Amount: 128 64 32 16
  471. * ------------- --- -- -- --
  472. * Monitor: 1 1 1 1
  473. * Primary Kernel: 1.5 1.5 1.5 1.5
  474. * Primary fs: 30 30 <end> <end>
  475. * Secondary Kernel: 1.5 1.5 N/A N/A
  476. * Secondary fs: <end> <end> N/A N/A
  477. * User: <overlays entire FLASH except for "Monitor" section>
  478. */
  479. static int __init
  480. katana_setup_mtd(void)
  481. {
  482. u32 size;
  483. int ptbl_entries;
  484. static struct mtd_partition *ptbl;
  485. size = katana_flash_size_0 + katana_flash_size_1;
  486. if (!size)
  487. return -ENOMEM;
  488. ptbl_entries = (size >= (64*MB)) ? 6 : 4;
  489. if ((ptbl = kmalloc(ptbl_entries * sizeof(struct mtd_partition),
  490. GFP_KERNEL)) == NULL) {
  491. printk(KERN_WARNING "Can't alloc MTD partition table\n");
  492. return -ENOMEM;
  493. }
  494. memset(ptbl, 0, ptbl_entries * sizeof(struct mtd_partition));
  495. ptbl[0].name = "Monitor";
  496. ptbl[0].size = KATANA_MTD_MONITOR_SIZE;
  497. ptbl[1].name = "Primary Kernel";
  498. ptbl[1].offset = MTDPART_OFS_NXTBLK;
  499. ptbl[1].size = 0x00180000; /* 1.5 MB */
  500. ptbl[2].name = "Primary Filesystem";
  501. ptbl[2].offset = MTDPART_OFS_APPEND;
  502. ptbl[2].size = MTDPART_SIZ_FULL; /* Correct for 16 & 32 MB */
  503. ptbl[ptbl_entries-1].name = "User FLASH";
  504. ptbl[ptbl_entries-1].offset = KATANA_MTD_MONITOR_SIZE;
  505. ptbl[ptbl_entries-1].size = MTDPART_SIZ_FULL;
  506. if (size >= (64*MB)) {
  507. ptbl[2].size = 30*MB;
  508. ptbl[3].name = "Secondary Kernel";
  509. ptbl[3].offset = MTDPART_OFS_NXTBLK;
  510. ptbl[3].size = 0x00180000; /* 1.5 MB */
  511. ptbl[4].name = "Secondary Filesystem";
  512. ptbl[4].offset = MTDPART_OFS_APPEND;
  513. ptbl[4].size = MTDPART_SIZ_FULL;
  514. }
  515. physmap_map.size = size;
  516. physmap_set_partitions(ptbl, ptbl_entries);
  517. return 0;
  518. }
  519. arch_initcall(katana_setup_mtd);
  520. #endif
  521. static void
  522. katana_restart(char *cmd)
  523. {
  524. ulong i = 10000000;
  525. /* issue hard reset to the reset command register */
  526. out_8(cpld_base + KATANA_CPLD_RST_CMD, KATANA_CPLD_RST_CMD_HR);
  527. while (i-- > 0) ;
  528. panic("restart failed\n");
  529. }
  530. static void
  531. katana_halt(void)
  532. {
  533. u8 v;
  534. if (katana_id == KATANA_ID_752I) {
  535. v = in_8(cpld_base + HSL_PLD_BASE + HSL_PLD_HOT_SWAP_OFF);
  536. v |= HSL_PLD_HOT_SWAP_LED_BIT;
  537. out_8(cpld_base + HSL_PLD_BASE + HSL_PLD_HOT_SWAP_OFF, v);
  538. }
  539. while (1) ;
  540. /* NOTREACHED */
  541. }
  542. static void
  543. katana_power_off(void)
  544. {
  545. katana_halt();
  546. /* NOTREACHED */
  547. }
  548. static int
  549. katana_show_cpuinfo(struct seq_file *m)
  550. {
  551. seq_printf(m, "vendor\t\t: Artesyn Communication Products, LLC\n");
  552. seq_printf(m, "board\t\t: ");
  553. switch (katana_id) {
  554. case KATANA_ID_3750:
  555. seq_printf(m, "Katana 3750\n");
  556. break;
  557. case KATANA_ID_750I:
  558. seq_printf(m, "Katana 750i\n");
  559. break;
  560. case KATANA_ID_752I:
  561. seq_printf(m, "Katana 752i\n");
  562. break;
  563. default:
  564. seq_printf(m, "Unknown\n");
  565. break;
  566. }
  567. seq_printf(m, "product ID\t: 0x%x\n",
  568. in_8(cpld_base + KATANA_CPLD_PRODUCT_ID));
  569. seq_printf(m, "hardware rev\t: 0x%x\n",
  570. in_8(cpld_base+KATANA_CPLD_HARDWARE_VER));
  571. seq_printf(m, "PLD rev\t\t: 0x%x\n",
  572. in_8(cpld_base + KATANA_CPLD_PLD_VER));
  573. seq_printf(m, "PLB freq\t: %ldMhz\n",
  574. (long)katana_bus_frequency / 1000000);
  575. seq_printf(m, "PCI\t\t: %sMonarch\n", katana_is_monarch()? "" : "Non-");
  576. return 0;
  577. }
  578. static void __init
  579. katana_calibrate_decr(void)
  580. {
  581. u32 freq;
  582. freq = katana_bus_frequency / 4;
  583. printk(KERN_INFO "time_init: decrementer frequency = %lu.%.6lu MHz\n",
  584. (long)freq / 1000000, (long)freq % 1000000);
  585. tb_ticks_per_jiffy = freq / HZ;
  586. tb_to_us = mulhwu_scale_factor(freq, 1000000);
  587. }
  588. unsigned long __init
  589. katana_find_end_of_memory(void)
  590. {
  591. return mv64x60_get_mem_size(CONFIG_MV64X60_NEW_BASE,
  592. MV64x60_TYPE_MV64360);
  593. }
  594. #if defined(CONFIG_I2C_MV64XXX) && defined(CONFIG_SENSORS_M41T00)
  595. extern ulong m41t00_get_rtc_time(void);
  596. extern int m41t00_set_rtc_time(ulong);
  597. static int __init
  598. katana_rtc_hookup(void)
  599. {
  600. struct timespec tv;
  601. ppc_md.get_rtc_time = m41t00_get_rtc_time;
  602. ppc_md.set_rtc_time = m41t00_set_rtc_time;
  603. tv.tv_nsec = 0;
  604. tv.tv_sec = (ppc_md.get_rtc_time)();
  605. do_settimeofday(&tv);
  606. return 0;
  607. }
  608. late_initcall(katana_rtc_hookup);
  609. #endif
  610. static inline void
  611. katana_set_bat(void)
  612. {
  613. mb();
  614. mtspr(SPRN_DBAT2U, 0xf0001ffe);
  615. mtspr(SPRN_DBAT2L, 0xf000002a);
  616. mb();
  617. }
  618. #if defined(CONFIG_SERIAL_TEXT_DEBUG) && defined(CONFIG_SERIAL_MPSC_CONSOLE)
  619. static void __init
  620. katana_map_io(void)
  621. {
  622. io_block_mapping(0xf8100000, 0xf8100000, 0x00020000, _PAGE_IO);
  623. }
  624. #endif
  625. void __init
  626. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  627. unsigned long r6, unsigned long r7)
  628. {
  629. parse_bootinfo(find_bootinfo());
  630. /* ASSUMPTION: If both r3 (bd_t pointer) and r6 (cmdline pointer)
  631. * are non-zero, then we should use the board info from the bd_t
  632. * structure and the cmdline pointed to by r6 instead of the
  633. * information from birecs, if any. Otherwise, use the information
  634. * from birecs as discovered by the preceeding call to
  635. * parse_bootinfo(). This rule should work with both PPCBoot, which
  636. * uses a bd_t board info structure, and the kernel boot wrapper,
  637. * which uses birecs.
  638. */
  639. if (r3 && r6) {
  640. /* copy board info structure */
  641. memcpy( (void *)__res,(void *)(r3+KERNELBASE), sizeof(bd_t) );
  642. /* copy command line */
  643. *(char *)(r7+KERNELBASE) = 0;
  644. strcpy(cmd_line, (char *)(r6+KERNELBASE));
  645. }
  646. isa_mem_base = 0;
  647. ppc_md.setup_arch = katana_setup_arch;
  648. ppc_md.show_cpuinfo = katana_show_cpuinfo;
  649. ppc_md.init_IRQ = mv64360_init_irq;
  650. ppc_md.get_irq = mv64360_get_irq;
  651. ppc_md.restart = katana_restart;
  652. ppc_md.power_off = katana_power_off;
  653. ppc_md.halt = katana_halt;
  654. ppc_md.find_end_of_memory = katana_find_end_of_memory;
  655. ppc_md.calibrate_decr = katana_calibrate_decr;
  656. #if defined(CONFIG_SERIAL_TEXT_DEBUG) && defined(CONFIG_SERIAL_MPSC_CONSOLE)
  657. ppc_md.setup_io_mappings = katana_map_io;
  658. ppc_md.progress = mv64x60_mpsc_progress;
  659. mv64x60_progress_init(CONFIG_MV64X60_NEW_BASE);
  660. #endif
  661. #if defined(CONFIG_SERIAL_MPSC) || defined(CONFIG_MV643XX_ETH)
  662. platform_notify = katana_platform_notify;
  663. #endif
  664. katana_set_bat(); /* Need for katana_find_end_of_memory and progress */
  665. }