mpc8560_ads.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. /*
  2. * MPC8560ADS board specific routines
  3. *
  4. * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  5. *
  6. * Copyright 2004 Freescale Semiconductor Inc.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. */
  13. #include <linux/stddef.h>
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/errno.h>
  17. #include <linux/reboot.h>
  18. #include <linux/pci.h>
  19. #include <linux/kdev_t.h>
  20. #include <linux/major.h>
  21. #include <linux/console.h>
  22. #include <linux/delay.h>
  23. #include <linux/seq_file.h>
  24. #include <linux/root_dev.h>
  25. #include <linux/serial.h>
  26. #include <linux/tty.h> /* for linux/serial_core.h */
  27. #include <linux/serial_core.h>
  28. #include <linux/initrd.h>
  29. #include <linux/module.h>
  30. #include <linux/fsl_devices.h>
  31. #include <linux/fs_enet_pd.h>
  32. #include <asm/system.h>
  33. #include <asm/pgtable.h>
  34. #include <asm/page.h>
  35. #include <asm/atomic.h>
  36. #include <asm/time.h>
  37. #include <asm/io.h>
  38. #include <asm/machdep.h>
  39. #include <asm/open_pic.h>
  40. #include <asm/bootinfo.h>
  41. #include <asm/pci-bridge.h>
  42. #include <asm/mpc85xx.h>
  43. #include <asm/irq.h>
  44. #include <asm/immap_85xx.h>
  45. #include <asm/kgdb.h>
  46. #include <asm/ppc_sys.h>
  47. #include <asm/cpm2.h>
  48. #include <mm/mmu_decl.h>
  49. #include <syslib/cpm2_pic.h>
  50. #include <syslib/ppc85xx_common.h>
  51. #include <syslib/ppc85xx_setup.h>
  52. /* ************************************************************************
  53. *
  54. * Setup the architecture
  55. *
  56. */
  57. static void init_fcc_ioports(void)
  58. {
  59. struct immap *immap;
  60. struct io_port *io;
  61. u32 tempval;
  62. immap = cpm2_immr;
  63. io = &immap->im_ioport;
  64. /* FCC2/3 are on the ports B/C. */
  65. tempval = in_be32(&io->iop_pdirb);
  66. tempval &= ~PB2_DIRB0;
  67. tempval |= PB2_DIRB1;
  68. out_be32(&io->iop_pdirb, tempval);
  69. tempval = in_be32(&io->iop_psorb);
  70. tempval &= ~PB2_PSORB0;
  71. tempval |= PB2_PSORB1;
  72. out_be32(&io->iop_psorb, tempval);
  73. tempval = in_be32(&io->iop_pparb);
  74. tempval |= (PB2_DIRB0 | PB2_DIRB1);
  75. out_be32(&io->iop_pparb, tempval);
  76. tempval = in_be32(&io->iop_pdirb);
  77. tempval &= ~PB3_DIRB0;
  78. tempval |= PB3_DIRB1;
  79. out_be32(&io->iop_pdirb, tempval);
  80. tempval = in_be32(&io->iop_psorb);
  81. tempval &= ~PB3_PSORB0;
  82. tempval |= PB3_PSORB1;
  83. out_be32(&io->iop_psorb, tempval);
  84. tempval = in_be32(&io->iop_pparb);
  85. tempval |= (PB3_DIRB0 | PB3_DIRB1);
  86. out_be32(&io->iop_pparb, tempval);
  87. tempval = in_be32(&io->iop_pdirc);
  88. tempval |= PC3_DIRC1;
  89. out_be32(&io->iop_pdirc, tempval);
  90. tempval = in_be32(&io->iop_pparc);
  91. tempval |= PC3_DIRC1;
  92. out_be32(&io->iop_pparc, tempval);
  93. /* Port C has clocks...... */
  94. tempval = in_be32(&io->iop_psorc);
  95. tempval &= ~(CLK_TRX);
  96. out_be32(&io->iop_psorc, tempval);
  97. tempval = in_be32(&io->iop_pdirc);
  98. tempval &= ~(CLK_TRX);
  99. out_be32(&io->iop_pdirc, tempval);
  100. tempval = in_be32(&io->iop_pparc);
  101. tempval |= (CLK_TRX);
  102. out_be32(&io->iop_pparc, tempval);
  103. /* Configure Serial Interface clock routing.
  104. * First, clear all FCC bits to zero,
  105. * then set the ones we want.
  106. */
  107. immap->im_cpmux.cmx_fcr &= ~(CPMUX_CLK_MASK);
  108. immap->im_cpmux.cmx_fcr |= CPMUX_CLK_ROUTE;
  109. }
  110. static void __init
  111. mpc8560ads_setup_arch(void)
  112. {
  113. bd_t *binfo = (bd_t *) __res;
  114. unsigned int freq;
  115. struct gianfar_platform_data *pdata;
  116. struct gianfar_mdio_data *mdata;
  117. struct fs_platform_info *fpi;
  118. cpm2_reset();
  119. /* get the core frequency */
  120. freq = binfo->bi_intfreq;
  121. if (ppc_md.progress)
  122. ppc_md.progress("mpc8560ads_setup_arch()", 0);
  123. /* Set loops_per_jiffy to a half-way reasonable value,
  124. for use until calibrate_delay gets called. */
  125. loops_per_jiffy = freq / HZ;
  126. #ifdef CONFIG_PCI
  127. /* setup PCI host bridges */
  128. mpc85xx_setup_hose();
  129. #endif
  130. /* setup the board related info for the MDIO bus */
  131. mdata = (struct gianfar_mdio_data *) ppc_sys_get_pdata(MPC85xx_MDIO);
  132. mdata->irq[0] = MPC85xx_IRQ_EXT5;
  133. mdata->irq[1] = MPC85xx_IRQ_EXT5;
  134. mdata->irq[2] = -1;
  135. mdata->irq[3] = MPC85xx_IRQ_EXT5;
  136. mdata->irq[31] = -1;
  137. /* setup the board related information for the enet controllers */
  138. pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1);
  139. if (pdata) {
  140. pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
  141. pdata->bus_id = 0;
  142. pdata->phy_id = 0;
  143. memcpy(pdata->mac_addr, binfo->bi_enetaddr, 6);
  144. }
  145. pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC2);
  146. if (pdata) {
  147. pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
  148. pdata->bus_id = 0;
  149. pdata->phy_id = 1;
  150. memcpy(pdata->mac_addr, binfo->bi_enet1addr, 6);
  151. }
  152. init_fcc_ioports();
  153. ppc_sys_device_remove(MPC85xx_CPM_FCC1);
  154. fpi = (struct fs_platform_info *) ppc_sys_get_pdata(MPC85xx_CPM_FCC2);
  155. if (fpi) {
  156. memcpy(fpi->macaddr, binfo->bi_enet2addr, 6);
  157. fpi->bus_id = "0:02";
  158. fpi->phy_addr = 2;
  159. fpi->dpram_offset = (u32)cpm2_immr->im_dprambase;
  160. fpi->fcc_regs_c = (u32)&cpm2_immr->im_fcc_c[1];
  161. }
  162. fpi = (struct fs_platform_info *) ppc_sys_get_pdata(MPC85xx_CPM_FCC3);
  163. if (fpi) {
  164. memcpy(fpi->macaddr, binfo->bi_enet2addr, 6);
  165. fpi->macaddr[5] += 1;
  166. fpi->bus_id = "0:03";
  167. fpi->phy_addr = 3;
  168. fpi->dpram_offset = (u32)cpm2_immr->im_dprambase;
  169. fpi->fcc_regs_c = (u32)&cpm2_immr->im_fcc_c[2];
  170. }
  171. #ifdef CONFIG_BLK_DEV_INITRD
  172. if (initrd_start)
  173. ROOT_DEV = Root_RAM0;
  174. else
  175. #endif
  176. #ifdef CONFIG_ROOT_NFS
  177. ROOT_DEV = Root_NFS;
  178. #else
  179. ROOT_DEV = Root_HDA1;
  180. #endif
  181. }
  182. static irqreturn_t cpm2_cascade(int irq, void *dev_id)
  183. {
  184. while ((irq = cpm2_get_irq()) >= 0)
  185. __do_IRQ(irq);
  186. return IRQ_HANDLED;
  187. }
  188. static struct irqaction cpm2_irqaction = {
  189. .handler = cpm2_cascade,
  190. .flags = IRQF_DISABLED,
  191. .mask = CPU_MASK_NONE,
  192. .name = "cpm2_cascade",
  193. };
  194. static void __init
  195. mpc8560_ads_init_IRQ(void)
  196. {
  197. /* Setup OpenPIC */
  198. mpc85xx_ads_init_IRQ();
  199. /* Setup CPM2 PIC */
  200. cpm2_init_IRQ();
  201. setup_irq(MPC85xx_IRQ_CPM, &cpm2_irqaction);
  202. return;
  203. }
  204. /* ************************************************************************ */
  205. void __init
  206. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  207. unsigned long r6, unsigned long r7)
  208. {
  209. /* parse_bootinfo must always be called first */
  210. parse_bootinfo(find_bootinfo());
  211. /*
  212. * If we were passed in a board information, copy it into the
  213. * residual data area.
  214. */
  215. if (r3) {
  216. memcpy((void *) __res, (void *) (r3 + KERNELBASE),
  217. sizeof (bd_t));
  218. }
  219. #if defined(CONFIG_BLK_DEV_INITRD)
  220. /*
  221. * If the init RAM disk has been configured in, and there's a valid
  222. * starting address for it, set it up.
  223. */
  224. if (r4) {
  225. initrd_start = r4 + KERNELBASE;
  226. initrd_end = r5 + KERNELBASE;
  227. }
  228. #endif /* CONFIG_BLK_DEV_INITRD */
  229. /* Copy the kernel command line arguments to a safe place. */
  230. if (r6) {
  231. *(char *) (r7 + KERNELBASE) = 0;
  232. strcpy(cmd_line, (char *) (r6 + KERNELBASE));
  233. }
  234. identify_ppc_sys_by_id(mfspr(SPRN_SVR));
  235. /* setup the PowerPC module struct */
  236. ppc_md.setup_arch = mpc8560ads_setup_arch;
  237. ppc_md.show_cpuinfo = mpc85xx_ads_show_cpuinfo;
  238. ppc_md.init_IRQ = mpc8560_ads_init_IRQ;
  239. ppc_md.get_irq = openpic_get_irq;
  240. ppc_md.restart = mpc85xx_restart;
  241. ppc_md.power_off = mpc85xx_power_off;
  242. ppc_md.halt = mpc85xx_halt;
  243. ppc_md.find_end_of_memory = mpc85xx_find_end_of_memory;
  244. ppc_md.time_init = NULL;
  245. ppc_md.set_rtc_time = NULL;
  246. ppc_md.get_rtc_time = NULL;
  247. ppc_md.calibrate_decr = mpc85xx_calibrate_decr;
  248. if (ppc_md.progress)
  249. ppc_md.progress("mpc8560ads_init(): exit", 0);
  250. return;
  251. }