lite5200.c 5.8 KB

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