lite5200.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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/initrd.h>
  24. #include <linux/seq_file.h>
  25. #include <linux/kdev_t.h>
  26. #include <linux/root_dev.h>
  27. #include <linux/console.h>
  28. #include <linux/module.h>
  29. #include <asm/bootinfo.h>
  30. #include <asm/io.h>
  31. #include <asm/mpc52xx.h>
  32. #include <asm/ppc_sys.h>
  33. #include <asm/machdep.h>
  34. #include <asm/pci-bridge.h>
  35. extern int powersave_nap;
  36. /* Board data given by U-Boot */
  37. bd_t __res;
  38. EXPORT_SYMBOL(__res); /* For modules */
  39. /* ======================================================================== */
  40. /* Platform specific code */
  41. /* ======================================================================== */
  42. /* Supported PSC function in "preference" order */
  43. struct mpc52xx_psc_func mpc52xx_psc_functions[] = {
  44. { .id = 0,
  45. .func = "uart",
  46. },
  47. { .id = -1, /* End entry */
  48. .func = NULL,
  49. }
  50. };
  51. static int
  52. lite5200_show_cpuinfo(struct seq_file *m)
  53. {
  54. seq_printf(m, "machine\t\t: Freescale LITE5200\n");
  55. return 0;
  56. }
  57. #ifdef CONFIG_PCI
  58. #ifdef CONFIG_LITE5200B
  59. static int
  60. lite5200_map_irq(struct pci_dev *dev, unsigned char idsel,
  61. unsigned char pin)
  62. {
  63. static char pci_irq_table[][4] =
  64. /*
  65. * PCI IDSEL/INTPIN->INTLINE
  66. * A B C D
  67. */
  68. {
  69. {MPC52xx_IRQ0, MPC52xx_IRQ1, MPC52xx_IRQ2, MPC52xx_IRQ3},
  70. {MPC52xx_IRQ1, MPC52xx_IRQ2, MPC52xx_IRQ3, MPC52xx_IRQ0},
  71. };
  72. const long min_idsel = 24, max_idsel = 25, irqs_per_slot = 4;
  73. return PCI_IRQ_TABLE_LOOKUP;
  74. }
  75. #else /* Original Lite */
  76. static int
  77. lite5200_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  78. {
  79. return (pin == 1) && (idsel==24) ? MPC52xx_IRQ0 : -1;
  80. }
  81. #endif
  82. #endif
  83. static void __init
  84. lite5200_setup_cpu(void)
  85. {
  86. struct mpc52xx_gpio __iomem *gpio;
  87. struct mpc52xx_intr __iomem *intr;
  88. u32 port_config;
  89. u32 intr_ctrl;
  90. /* Map zones */
  91. gpio = ioremap(MPC52xx_PA(MPC52xx_GPIO_OFFSET), MPC52xx_GPIO_SIZE);
  92. intr = ioremap(MPC52xx_PA(MPC52xx_INTR_OFFSET), MPC52xx_INTR_SIZE);
  93. if (!gpio || !intr) {
  94. printk(KERN_ERR __FILE__ ": "
  95. "Error while mapping GPIO/INTR during "
  96. "lite5200_setup_cpu\n");
  97. goto unmap_regs;
  98. }
  99. /* Get port mux config */
  100. port_config = in_be32(&gpio->port_config);
  101. /* 48Mhz internal, pin is GPIO */
  102. port_config &= ~0x00800000;
  103. /* USB port */
  104. port_config &= ~0x00007000; /* Differential mode - USB1 only */
  105. port_config |= 0x00001000;
  106. /* ATA CS is on csb_4/5 */
  107. port_config &= ~0x03000000;
  108. port_config |= 0x01000000;
  109. /* Commit port config */
  110. out_be32(&gpio->port_config, port_config);
  111. /* IRQ[0-3] setup */
  112. intr_ctrl = in_be32(&intr->ctrl);
  113. intr_ctrl &= ~0x00ff0000;
  114. #ifdef CONFIG_LITE5200B
  115. /* IRQ[0-3] Level Active Low */
  116. intr_ctrl |= 0x00ff0000;
  117. #else
  118. /* IRQ0 Level Active Low
  119. * IRQ[1-3] Level Active High */
  120. intr_ctrl |= 0x00c00000;
  121. #endif
  122. out_be32(&intr->ctrl, intr_ctrl);
  123. /* Unmap reg zone */
  124. unmap_regs:
  125. if (gpio) iounmap(gpio);
  126. if (intr) iounmap(intr);
  127. }
  128. static void __init
  129. lite5200_setup_arch(void)
  130. {
  131. /* CPU & Port mux setup */
  132. mpc52xx_setup_cpu(); /* Generic */
  133. lite5200_setup_cpu(); /* Platform specific */
  134. #ifdef CONFIG_PCI
  135. /* PCI Bridge setup */
  136. mpc52xx_find_bridges();
  137. #endif
  138. }
  139. void __init
  140. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  141. unsigned long r6, unsigned long r7)
  142. {
  143. /* Generic MPC52xx platform initialization */
  144. /* TODO Create one and move a max of stuff in it.
  145. Put this init in the syslib */
  146. struct bi_record *bootinfo = find_bootinfo();
  147. if (bootinfo)
  148. parse_bootinfo(bootinfo);
  149. else {
  150. /* Load the bd_t board info structure */
  151. if (r3)
  152. memcpy((void*)&__res,(void*)(r3+KERNELBASE),
  153. sizeof(bd_t));
  154. #ifdef CONFIG_BLK_DEV_INITRD
  155. /* Load the initrd */
  156. if (r4) {
  157. initrd_start = r4 + KERNELBASE;
  158. initrd_end = r5 + KERNELBASE;
  159. }
  160. #endif
  161. /* Load the command line */
  162. if (r6) {
  163. *(char *)(r7+KERNELBASE) = 0;
  164. strcpy(cmd_line, (char *)(r6+KERNELBASE));
  165. }
  166. }
  167. /* PPC Sys identification */
  168. identify_ppc_sys_by_id(mfspr(SPRN_SVR));
  169. /* BAT setup */
  170. mpc52xx_set_bat();
  171. /* No ISA bus by default */
  172. #ifdef CONFIG_PCI
  173. isa_io_base = 0;
  174. isa_mem_base = 0;
  175. #endif
  176. /* Powersave */
  177. /* This is provided as an example on how to do it. But you
  178. need to be aware that NAP disable bus snoop and that may
  179. be required for some devices to work properly, like USB ... */
  180. /* powersave_nap = 1; */
  181. /* Setup the ppc_md struct */
  182. ppc_md.setup_arch = lite5200_setup_arch;
  183. ppc_md.show_cpuinfo = lite5200_show_cpuinfo;
  184. ppc_md.show_percpuinfo = NULL;
  185. ppc_md.init_IRQ = mpc52xx_init_irq;
  186. ppc_md.get_irq = mpc52xx_get_irq;
  187. #ifdef CONFIG_PCI
  188. ppc_md.pci_map_irq = lite5200_map_irq;
  189. #endif
  190. ppc_md.find_end_of_memory = mpc52xx_find_end_of_memory;
  191. ppc_md.setup_io_mappings = mpc52xx_map_io;
  192. ppc_md.restart = mpc52xx_restart;
  193. ppc_md.power_off = mpc52xx_power_off;
  194. ppc_md.halt = mpc52xx_halt;
  195. /* No time keeper on the LITE5200 */
  196. ppc_md.time_init = NULL;
  197. ppc_md.get_rtc_time = NULL;
  198. ppc_md.set_rtc_time = NULL;
  199. ppc_md.calibrate_decr = mpc52xx_calibrate_decr;
  200. #ifdef CONFIG_SERIAL_TEXT_DEBUG
  201. ppc_md.progress = mpc52xx_progress;
  202. #endif
  203. }