katana.c 25 KB

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