katana.c 25 KB

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