stx_gp3.c 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. /*
  2. * arch/ppc/platforms/85xx/stx_gp3.c
  3. *
  4. * STx GP3 board specific routines
  5. *
  6. * Dan Malek <dan@embeddededge.com>
  7. * Copyright 2004 Embedded Edge, LLC
  8. *
  9. * Copied from mpc8560_ads.c
  10. * Copyright 2002, 2003 Motorola Inc.
  11. *
  12. * Ported to 2.6, Matt Porter <mporter@kernel.crashing.org>
  13. * Copyright 2004-2005 MontaVista Software, Inc.
  14. *
  15. * This program is free software; you can redistribute it and/or modify it
  16. * under the terms of the GNU General Public License as published by the
  17. * Free Software Foundation; either version 2 of the License, or (at your
  18. * option) any later version.
  19. */
  20. #include <linux/config.h>
  21. #include <linux/stddef.h>
  22. #include <linux/kernel.h>
  23. #include <linux/init.h>
  24. #include <linux/errno.h>
  25. #include <linux/reboot.h>
  26. #include <linux/pci.h>
  27. #include <linux/kdev_t.h>
  28. #include <linux/major.h>
  29. #include <linux/blkdev.h>
  30. #include <linux/console.h>
  31. #include <linux/delay.h>
  32. #include <linux/root_dev.h>
  33. #include <linux/seq_file.h>
  34. #include <linux/serial.h>
  35. #include <linux/initrd.h>
  36. #include <linux/module.h>
  37. #include <linux/fsl_devices.h>
  38. #include <linux/interrupt.h>
  39. #include <linux/rio.h>
  40. #include <asm/system.h>
  41. #include <asm/pgtable.h>
  42. #include <asm/page.h>
  43. #include <asm/atomic.h>
  44. #include <asm/time.h>
  45. #include <asm/io.h>
  46. #include <asm/machdep.h>
  47. #include <asm/open_pic.h>
  48. #include <asm/bootinfo.h>
  49. #include <asm/pci-bridge.h>
  50. #include <asm/mpc85xx.h>
  51. #include <asm/irq.h>
  52. #include <asm/immap_85xx.h>
  53. #include <asm/cpm2.h>
  54. #include <asm/mpc85xx.h>
  55. #include <asm/ppc_sys.h>
  56. #include <syslib/cpm2_pic.h>
  57. #include <syslib/ppc85xx_common.h>
  58. #include <syslib/ppc85xx_rio.h>
  59. unsigned char __res[sizeof(bd_t)];
  60. #ifndef CONFIG_PCI
  61. unsigned long isa_io_base = 0;
  62. unsigned long isa_mem_base = 0;
  63. unsigned long pci_dram_offset = 0;
  64. #endif
  65. /* Internal interrupts are all Level Sensitive, and Positive Polarity */
  66. static u8 gp3_openpic_initsenses[] __initdata = {
  67. MPC85XX_INTERNAL_IRQ_SENSES,
  68. 0x0, /* External 0: */
  69. #if defined(CONFIG_PCI)
  70. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 1: PCI slot 0 */
  71. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 2: PCI slot 1 */
  72. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 3: PCI slot 2 */
  73. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 4: PCI slot 3 */
  74. #else
  75. 0x0, /* External 1: */
  76. 0x0, /* External 2: */
  77. 0x0, /* External 3: */
  78. 0x0, /* External 4: */
  79. #endif
  80. 0x0, /* External 5: */
  81. 0x0, /* External 6: */
  82. 0x0, /* External 7: */
  83. 0x0, /* External 8: */
  84. 0x0, /* External 9: */
  85. 0x0, /* External 10: */
  86. 0x0, /* External 11: */
  87. };
  88. static const char *GFAR_PHY_2 = "phy0:2";
  89. static const char *GFAR_PHY_4 = "phy0:4";
  90. /*
  91. * Setup the architecture
  92. */
  93. static void __init
  94. gp3_setup_arch(void)
  95. {
  96. bd_t *binfo = (bd_t *) __res;
  97. unsigned int freq;
  98. struct gianfar_platform_data *pdata;
  99. struct gianfar_mdio_data *mdata;
  100. cpm2_reset();
  101. /* get the core frequency */
  102. freq = binfo->bi_intfreq;
  103. if (ppc_md.progress)
  104. ppc_md.progress("gp3_setup_arch()", 0);
  105. /* Set loops_per_jiffy to a half-way reasonable value,
  106. for use until calibrate_delay gets called. */
  107. loops_per_jiffy = freq / HZ;
  108. #ifdef CONFIG_PCI
  109. /* setup PCI host bridges */
  110. mpc85xx_setup_hose();
  111. #endif
  112. /* setup the board related info for the MDIO bus */
  113. mdata = (struct gianfar_mdio_data *) ppc_sys_get_pdata(MPC85xx_MDIO);
  114. mdata->irq[2] = MPC85xx_IRQ_EXT5;
  115. mdata->irq[4] = MPC85xx_IRQ_EXT5;
  116. mdata->irq[31] = -1;
  117. mdata->paddr += binfo->bi_immr_base;
  118. /* setup the board related information for the enet controllers */
  119. pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1);
  120. if (pdata) {
  121. /* pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR; */
  122. pdata->bus_id = GFAR_PHY_2;
  123. memcpy(pdata->mac_addr, binfo->bi_enetaddr, 6);
  124. }
  125. pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC2);
  126. if (pdata) {
  127. /* pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR; */
  128. pdata->bus_id = GFAR_PHY_4;
  129. memcpy(pdata->mac_addr, binfo->bi_enet1addr, 6);
  130. }
  131. #ifdef CONFIG_BLK_DEV_INITRD
  132. if (initrd_start)
  133. ROOT_DEV = Root_RAM0;
  134. else
  135. #endif
  136. #ifdef CONFIG_ROOT_NFS
  137. ROOT_DEV = Root_NFS;
  138. #else
  139. ROOT_DEV = Root_HDA1;
  140. #endif
  141. printk ("bi_immr_base = %8.8lx\n", binfo->bi_immr_base);
  142. }
  143. static irqreturn_t cpm2_cascade(int irq, void *dev_id, struct pt_regs *regs)
  144. {
  145. while ((irq = cpm2_get_irq(regs)) >= 0)
  146. __do_IRQ(irq, regs);
  147. return IRQ_HANDLED;
  148. }
  149. static struct irqaction cpm2_irqaction = {
  150. .handler = cpm2_cascade,
  151. .flags = SA_INTERRUPT,
  152. .mask = CPU_MASK_NONE,
  153. .name = "cpm2_cascade",
  154. };
  155. static void __init
  156. gp3_init_IRQ(void)
  157. {
  158. bd_t *binfo = (bd_t *) __res;
  159. /*
  160. * Setup OpenPIC
  161. */
  162. /* Determine the Physical Address of the OpenPIC regs */
  163. phys_addr_t OpenPIC_PAddr =
  164. binfo->bi_immr_base + MPC85xx_OPENPIC_OFFSET;
  165. OpenPIC_Addr = ioremap(OpenPIC_PAddr, MPC85xx_OPENPIC_SIZE);
  166. OpenPIC_InitSenses = gp3_openpic_initsenses;
  167. OpenPIC_NumInitSenses = sizeof (gp3_openpic_initsenses);
  168. /* Skip reserved space and internal sources */
  169. openpic_set_sources(0, 32, OpenPIC_Addr + 0x10200);
  170. /* Map PIC IRQs 0-11 */
  171. openpic_set_sources(48, 12, OpenPIC_Addr + 0x10000);
  172. /*
  173. * Let openpic interrupts starting from an offset, to
  174. * leave space for cascading interrupts underneath.
  175. */
  176. openpic_init(MPC85xx_OPENPIC_IRQ_OFFSET);
  177. /* Setup CPM2 PIC */
  178. cpm2_init_IRQ();
  179. setup_irq(MPC85xx_IRQ_CPM, &cpm2_irqaction);
  180. return;
  181. }
  182. static int
  183. gp3_show_cpuinfo(struct seq_file *m)
  184. {
  185. uint pvid, svid, phid1;
  186. bd_t *binfo = (bd_t *) __res;
  187. uint memsize;
  188. unsigned int freq;
  189. extern unsigned long total_memory; /* in mm/init */
  190. /* get the core frequency */
  191. freq = binfo->bi_intfreq;
  192. pvid = mfspr(SPRN_PVR);
  193. svid = mfspr(SPRN_SVR);
  194. memsize = total_memory;
  195. seq_printf(m, "Vendor\t\t: RPC Electronics STx \n");
  196. seq_printf(m, "Machine\t\t: GP3 - MPC%s\n", cur_ppc_sys_spec->ppc_sys_name);
  197. seq_printf(m, "bus freq\t: %u.%.6u MHz\n", freq / 1000000,
  198. freq % 1000000);
  199. seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
  200. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  201. /* Display cpu Pll setting */
  202. phid1 = mfspr(SPRN_HID1);
  203. seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
  204. /* Display the amount of memory */
  205. seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
  206. return 0;
  207. }
  208. #ifdef CONFIG_PCI
  209. int mpc85xx_map_irq(struct pci_dev *dev, unsigned char idsel,
  210. unsigned char pin)
  211. {
  212. static char pci_irq_table[][4] =
  213. /*
  214. * PCI IDSEL/INTPIN->INTLINE
  215. * A B C D
  216. */
  217. {
  218. {PIRQA, PIRQB, PIRQC, PIRQD},
  219. {PIRQD, PIRQA, PIRQB, PIRQC},
  220. {PIRQC, PIRQD, PIRQA, PIRQB},
  221. {PIRQB, PIRQC, PIRQD, PIRQA},
  222. };
  223. const long min_idsel = 12, max_idsel = 15, irqs_per_slot = 4;
  224. return PCI_IRQ_TABLE_LOOKUP;
  225. }
  226. int mpc85xx_exclude_device(u_char bus, u_char devfn)
  227. {
  228. if (bus == 0 && PCI_SLOT(devfn) == 0)
  229. return PCIBIOS_DEVICE_NOT_FOUND;
  230. else
  231. return PCIBIOS_SUCCESSFUL;
  232. }
  233. #endif /* CONFIG_PCI */
  234. #ifdef CONFIG_RAPIDIO
  235. void
  236. platform_rio_init(void)
  237. {
  238. /*
  239. * The STx firmware configures the RapidIO Local Access Window
  240. * at 0xc0000000 with a size of 512MB.
  241. */
  242. mpc85xx_rio_setup(0xc0000000, 0x20000000);
  243. }
  244. #endif /* CONFIG_RAPIDIO */
  245. void __init
  246. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  247. unsigned long r6, unsigned long r7)
  248. {
  249. /* parse_bootinfo must always be called first */
  250. parse_bootinfo(find_bootinfo());
  251. /*
  252. * If we were passed in a board information, copy it into the
  253. * residual data area.
  254. */
  255. if (r3) {
  256. memcpy((void *) __res, (void *) (r3 + KERNELBASE),
  257. sizeof (bd_t));
  258. }
  259. #if defined(CONFIG_BLK_DEV_INITRD)
  260. /*
  261. * If the init RAM disk has been configured in, and there's a valid
  262. * starting address for it, set it up.
  263. */
  264. if (r4) {
  265. initrd_start = r4 + KERNELBASE;
  266. initrd_end = r5 + KERNELBASE;
  267. }
  268. #endif /* CONFIG_BLK_DEV_INITRD */
  269. /* Copy the kernel command line arguments to a safe place. */
  270. if (r6) {
  271. *(char *) (r7 + KERNELBASE) = 0;
  272. strcpy(cmd_line, (char *) (r6 + KERNELBASE));
  273. }
  274. identify_ppc_sys_by_id(mfspr(SPRN_SVR));
  275. /* setup the PowerPC module struct */
  276. ppc_md.setup_arch = gp3_setup_arch;
  277. ppc_md.show_cpuinfo = gp3_show_cpuinfo;
  278. ppc_md.init_IRQ = gp3_init_IRQ;
  279. ppc_md.get_irq = openpic_get_irq;
  280. ppc_md.restart = mpc85xx_restart;
  281. ppc_md.power_off = mpc85xx_power_off;
  282. ppc_md.halt = mpc85xx_halt;
  283. ppc_md.find_end_of_memory = mpc85xx_find_end_of_memory;
  284. ppc_md.calibrate_decr = mpc85xx_calibrate_decr;
  285. if (ppc_md.progress)
  286. ppc_md.progress("platform_init(): exit", 0);
  287. return;
  288. }