lite5200.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /*
  2. * Platform support file for the Freescale LITE5200 based on MPC52xx.
  3. * A maximum of this file should be moved to syslib/mpc52xx_?????
  4. * so that new platform based on MPC52xx need a minimal platform file
  5. * ( avoid code duplication )
  6. *
  7. *
  8. * Maintainer : Sylvain Munaut <tnt@246tNt.com>
  9. *
  10. * Based on the 2.4 code written by Kent Borg,
  11. * Dale Farnsworth <dale.farnsworth@mvista.com> and
  12. * Wolfgang Denk <wd@denx.de>
  13. *
  14. * Copyright 2004-2005 Sylvain Munaut <tnt@246tNt.com>
  15. * Copyright 2003 Motorola Inc.
  16. * Copyright 2003 MontaVista Software Inc.
  17. * Copyright 2003 DENX Software Engineering (wd@denx.de)
  18. *
  19. * This file is licensed under the terms of the GNU General Public License
  20. * version 2. This program is licensed "as is" without any warranty of any
  21. * kind, whether express or implied.
  22. */
  23. #include <linux/config.h>
  24. #include <linux/initrd.h>
  25. #include <linux/seq_file.h>
  26. #include <linux/kdev_t.h>
  27. #include <linux/root_dev.h>
  28. #include <linux/console.h>
  29. #include <linux/module.h>
  30. #include <asm/bootinfo.h>
  31. #include <asm/io.h>
  32. #include <asm/mpc52xx.h>
  33. #include <asm/ppc_sys.h>
  34. #include <asm/machdep.h>
  35. #include <syslib/mpc52xx_pci.h>
  36. extern int powersave_nap;
  37. /* Board data given by U-Boot */
  38. bd_t __res;
  39. EXPORT_SYMBOL(__res); /* For modules */
  40. /* ======================================================================== */
  41. /* Platform specific code */
  42. /* ======================================================================== */
  43. /* Supported PSC function in "preference" order */
  44. struct mpc52xx_psc_func mpc52xx_psc_functions[] = {
  45. { .id = 0,
  46. .func = "uart",
  47. },
  48. { .id = -1, /* End entry */
  49. .func = NULL,
  50. }
  51. };
  52. static int
  53. lite5200_show_cpuinfo(struct seq_file *m)
  54. {
  55. seq_printf(m, "machine\t\t: Freescale LITE5200\n");
  56. return 0;
  57. }
  58. #ifdef CONFIG_PCI
  59. static int
  60. lite5200_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  61. {
  62. return (pin == 1) && (idsel==24) ? MPC52xx_IRQ0 : -1;
  63. }
  64. #endif
  65. static void __init
  66. lite5200_setup_cpu(void)
  67. {
  68. struct mpc52xx_cdm __iomem *cdm;
  69. struct mpc52xx_gpio __iomem *gpio;
  70. struct mpc52xx_intr __iomem *intr;
  71. struct mpc52xx_xlb __iomem *xlb;
  72. u32 port_config;
  73. u32 intr_ctrl;
  74. /* Map zones */
  75. cdm = ioremap(MPC52xx_PA(MPC52xx_CDM_OFFSET), MPC52xx_CDM_SIZE);
  76. gpio = ioremap(MPC52xx_PA(MPC52xx_GPIO_OFFSET), MPC52xx_GPIO_SIZE);
  77. xlb = ioremap(MPC52xx_PA(MPC52xx_XLB_OFFSET), MPC52xx_XLB_SIZE);
  78. intr = ioremap(MPC52xx_PA(MPC52xx_INTR_OFFSET), MPC52xx_INTR_SIZE);
  79. if (!cdm || !gpio || !xlb || !intr) {
  80. printk("lite5200.c: Error while mapping CDM/GPIO/XLB/INTR during"
  81. "lite5200_setup_cpu\n");
  82. goto unmap_regs;
  83. }
  84. /* Use internal 48 Mhz */
  85. out_8(&cdm->ext_48mhz_en, 0x00);
  86. out_8(&cdm->fd_enable, 0x01);
  87. if (in_be32(&cdm->rstcfg) & 0x40) /* Assumes 33Mhz clock */
  88. out_be16(&cdm->fd_counters, 0x0001);
  89. else
  90. out_be16(&cdm->fd_counters, 0x5555);
  91. /* Get port mux config */
  92. port_config = in_be32(&gpio->port_config);
  93. /* 48Mhz internal, pin is GPIO */
  94. port_config &= ~0x00800000;
  95. /* USB port */
  96. port_config &= ~0x00007000; /* Differential mode - USB1 only */
  97. port_config |= 0x00001000;
  98. /* Commit port config */
  99. out_be32(&gpio->port_config, port_config);
  100. /* Configure the XLB Arbiter */
  101. out_be32(&xlb->master_pri_enable, 0xff);
  102. out_be32(&xlb->master_priority, 0x11111111);
  103. /* Enable ram snooping for 1GB window */
  104. out_be32(&xlb->config, in_be32(&xlb->config) | MPC52xx_XLB_CFG_SNOOP);
  105. out_be32(&xlb->snoop_window, MPC52xx_PCI_TARGET_MEM | 0x1d);
  106. /* IRQ[0-3] setup : IRQ0 - Level Active Low */
  107. /* IRQ[1-3] - Level Active High */
  108. intr_ctrl = in_be32(&intr->ctrl);
  109. intr_ctrl &= ~0x00ff0000;
  110. intr_ctrl |= 0x00c00000;
  111. out_be32(&intr->ctrl, intr_ctrl);
  112. /* Unmap reg zone */
  113. unmap_regs:
  114. if (cdm) iounmap(cdm);
  115. if (gpio) iounmap(gpio);
  116. if (xlb) iounmap(xlb);
  117. if (intr) iounmap(intr);
  118. }
  119. static void __init
  120. lite5200_setup_arch(void)
  121. {
  122. /* CPU & Port mux setup */
  123. lite5200_setup_cpu();
  124. #ifdef CONFIG_PCI
  125. /* PCI Bridge setup */
  126. mpc52xx_find_bridges();
  127. #endif
  128. }
  129. void __init
  130. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  131. unsigned long r6, unsigned long r7)
  132. {
  133. /* Generic MPC52xx platform initialization */
  134. /* TODO Create one and move a max of stuff in it.
  135. Put this init in the syslib */
  136. struct bi_record *bootinfo = find_bootinfo();
  137. if (bootinfo)
  138. parse_bootinfo(bootinfo);
  139. else {
  140. /* Load the bd_t board info structure */
  141. if (r3)
  142. memcpy((void*)&__res,(void*)(r3+KERNELBASE),
  143. sizeof(bd_t));
  144. #ifdef CONFIG_BLK_DEV_INITRD
  145. /* Load the initrd */
  146. if (r4) {
  147. initrd_start = r4 + KERNELBASE;
  148. initrd_end = r5 + KERNELBASE;
  149. }
  150. #endif
  151. /* Load the command line */
  152. if (r6) {
  153. *(char *)(r7+KERNELBASE) = 0;
  154. strcpy(cmd_line, (char *)(r6+KERNELBASE));
  155. }
  156. }
  157. /* PPC Sys identification */
  158. identify_ppc_sys_by_id(mfspr(SPRN_SVR));
  159. /* BAT setup */
  160. mpc52xx_set_bat();
  161. /* No ISA bus by default */
  162. #ifdef CONFIG_PCI
  163. isa_io_base = 0;
  164. isa_mem_base = 0;
  165. #endif
  166. /* Powersave */
  167. /* This is provided as an example on how to do it. But you
  168. need to be aware that NAP disable bus snoop and that may
  169. be required for some devices to work properly, like USB ... */
  170. /* powersave_nap = 1; */
  171. /* Setup the ppc_md struct */
  172. ppc_md.setup_arch = lite5200_setup_arch;
  173. ppc_md.show_cpuinfo = lite5200_show_cpuinfo;
  174. ppc_md.show_percpuinfo = NULL;
  175. ppc_md.init_IRQ = mpc52xx_init_irq;
  176. ppc_md.get_irq = mpc52xx_get_irq;
  177. #ifdef CONFIG_PCI
  178. ppc_md.pci_map_irq = lite5200_map_irq;
  179. #endif
  180. ppc_md.find_end_of_memory = mpc52xx_find_end_of_memory;
  181. ppc_md.setup_io_mappings = mpc52xx_map_io;
  182. ppc_md.restart = mpc52xx_restart;
  183. ppc_md.power_off = mpc52xx_power_off;
  184. ppc_md.halt = mpc52xx_halt;
  185. /* No time keeper on the LITE5200 */
  186. ppc_md.time_init = NULL;
  187. ppc_md.get_rtc_time = NULL;
  188. ppc_md.set_rtc_time = NULL;
  189. ppc_md.calibrate_decr = mpc52xx_calibrate_decr;
  190. #ifdef CONFIG_SERIAL_TEXT_DEBUG
  191. ppc_md.progress = mpc52xx_progress;
  192. #endif
  193. }