katana.c 25 KB

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