xilinx_ml300.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * Xilinx ML300 evaluation board initialization
  3. *
  4. * Author: MontaVista Software, Inc.
  5. * source@mvista.com
  6. *
  7. * 2002-2004 (c) MontaVista Software, Inc. This file is licensed under the
  8. * terms of the GNU General Public License version 2. This program is licensed
  9. * "as is" without any warranty of any kind, whether express or implied.
  10. */
  11. #include <linux/config.h>
  12. #include <linux/init.h>
  13. #include <linux/irq.h>
  14. #include <linux/tty.h>
  15. #include <linux/serial.h>
  16. #include <linux/serial_core.h>
  17. #include <linux/serial_8250.h>
  18. #include <linux/serialP.h>
  19. #include <asm/io.h>
  20. #include <asm/machdep.h>
  21. #include <asm/ppc_sys.h>
  22. #include <syslib/gen550.h>
  23. #include <platforms/4xx/xparameters/xparameters.h>
  24. /*
  25. * As an overview of how the following functions (platform_init,
  26. * ml300_map_io, ml300_setup_arch and ml300_init_IRQ) fit into the
  27. * kernel startup procedure, here's a call tree:
  28. *
  29. * start_here arch/ppc/kernel/head_4xx.S
  30. * early_init arch/ppc/kernel/setup.c
  31. * machine_init arch/ppc/kernel/setup.c
  32. * platform_init this file
  33. * ppc4xx_init arch/ppc/syslib/ppc4xx_setup.c
  34. * parse_bootinfo
  35. * find_bootinfo
  36. * "setup some default ppc_md pointers"
  37. * MMU_init arch/ppc/mm/init.c
  38. * *ppc_md.setup_io_mappings == ml300_map_io this file
  39. * ppc4xx_map_io arch/ppc/syslib/ppc4xx_setup.c
  40. * start_kernel init/main.c
  41. * setup_arch arch/ppc/kernel/setup.c
  42. * #if defined(CONFIG_KGDB)
  43. * *ppc_md.kgdb_map_scc() == gen550_kgdb_map_scc
  44. * #endif
  45. * *ppc_md.setup_arch == ml300_setup_arch this file
  46. * ppc4xx_setup_arch arch/ppc/syslib/ppc4xx_setup.c
  47. * ppc4xx_find_bridges arch/ppc/syslib/ppc405_pci.c
  48. * init_IRQ arch/ppc/kernel/irq.c
  49. * *ppc_md.init_IRQ == ml300_init_IRQ this file
  50. * ppc4xx_init_IRQ arch/ppc/syslib/ppc4xx_setup.c
  51. * ppc4xx_pic_init arch/ppc/syslib/xilinx_pic.c
  52. */
  53. /* Board specifications structures */
  54. struct ppc_sys_spec *cur_ppc_sys_spec;
  55. struct ppc_sys_spec ppc_sys_specs[] = {
  56. {
  57. /* Only one entry, always assume the same design */
  58. .ppc_sys_name = "Xilinx ML300 Reference Design",
  59. .mask = 0x00000000,
  60. .value = 0x00000000,
  61. .num_devices = 1,
  62. .device_list = (enum ppc_sys_devices[])
  63. {
  64. VIRTEX_UART,
  65. },
  66. },
  67. };
  68. #if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
  69. static volatile unsigned *powerdown_base =
  70. (volatile unsigned *) XPAR_POWER_0_POWERDOWN_BASEADDR;
  71. static void
  72. xilinx_power_off(void)
  73. {
  74. local_irq_disable();
  75. out_be32(powerdown_base, XPAR_POWER_0_POWERDOWN_VALUE);
  76. while (1) ;
  77. }
  78. #endif
  79. void __init
  80. ml300_map_io(void)
  81. {
  82. ppc4xx_map_io();
  83. #if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
  84. powerdown_base = ioremap((unsigned long) powerdown_base,
  85. XPAR_POWER_0_POWERDOWN_HIGHADDR -
  86. XPAR_POWER_0_POWERDOWN_BASEADDR + 1);
  87. #endif
  88. }
  89. /* Early serial support functions */
  90. static void __init
  91. ml300_early_serial_init(int num, struct plat_serial8250_port *pdata)
  92. {
  93. #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
  94. struct uart_port serial_req;
  95. memset(&serial_req, 0, sizeof(serial_req));
  96. serial_req.mapbase = pdata->mapbase;
  97. serial_req.membase = pdata->membase;
  98. serial_req.irq = pdata->irq;
  99. serial_req.uartclk = pdata->uartclk;
  100. serial_req.regshift = pdata->regshift;
  101. serial_req.iotype = pdata->iotype;
  102. serial_req.flags = pdata->flags;
  103. gen550_init(num, &serial_req);
  104. #endif
  105. }
  106. void __init
  107. ml300_early_serial_map(void)
  108. {
  109. #ifdef CONFIG_SERIAL_8250
  110. struct plat_serial8250_port *pdata;
  111. int i = 0;
  112. pdata = (struct plat_serial8250_port *) ppc_sys_get_pdata(VIRTEX_UART);
  113. while(pdata && pdata->flags)
  114. {
  115. pdata->membase = ioremap(pdata->mapbase, 0x100);
  116. ml300_early_serial_init(i, pdata);
  117. pdata++;
  118. i++;
  119. }
  120. #endif /* CONFIG_SERIAL_8250 */
  121. }
  122. void __init
  123. ml300_setup_arch(void)
  124. {
  125. ml300_early_serial_map();
  126. ppc4xx_setup_arch(); /* calls ppc4xx_find_bridges() */
  127. /* Identify the system */
  128. printk(KERN_INFO "Xilinx Virtex-II Pro port\n");
  129. printk(KERN_INFO "Port by MontaVista Software, Inc. (source@mvista.com)\n");
  130. }
  131. /* Called after board_setup_irq from ppc4xx_init_IRQ(). */
  132. void __init
  133. ml300_init_irq(void)
  134. {
  135. ppc4xx_init_IRQ();
  136. }
  137. void __init
  138. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  139. unsigned long r6, unsigned long r7)
  140. {
  141. ppc4xx_init(r3, r4, r5, r6, r7);
  142. identify_ppc_sys_by_id(mfspr(SPRN_PVR));
  143. ppc_md.setup_arch = ml300_setup_arch;
  144. ppc_md.setup_io_mappings = ml300_map_io;
  145. ppc_md.init_IRQ = ml300_init_irq;
  146. #if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
  147. ppc_md.power_off = xilinx_power_off;
  148. #endif
  149. #ifdef CONFIG_KGDB
  150. ppc_md.early_serial_map = ml300_early_serial_map;
  151. #endif
  152. }