katana.c 25 KB

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