lite5200.c 5.9 KB

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