PageRenderTime 36ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/release/src-rt/linux/linux-2.6/arch/ppc/platforms/85xx/stx_gp3.c

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