xilinx_ml300.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * arch/ppc/platforms/4xx/xilinx_ml300.c
  3. *
  4. * Xilinx ML300 evaluation board initialization
  5. *
  6. * Author: MontaVista Software, Inc.
  7. * source@mvista.com
  8. *
  9. * 2002-2004 (c) MontaVista Software, Inc. This file is licensed under the
  10. * terms of the GNU General Public License version 2. This program is licensed
  11. * "as is" without any warranty of any kind, whether express or implied.
  12. */
  13. #include <linux/config.h>
  14. #include <linux/init.h>
  15. #include <linux/irq.h>
  16. #include <linux/tty.h>
  17. #include <linux/serial.h>
  18. #include <linux/serial_core.h>
  19. #include <linux/serialP.h>
  20. #include <asm/io.h>
  21. #include <asm/machdep.h>
  22. #include <asm/ocp.h>
  23. #include <platforms/4xx/virtex-ii_pro.h> /* for NR_SER_PORTS */
  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. #if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
  54. static volatile unsigned *powerdown_base =
  55. (volatile unsigned *) XPAR_POWER_0_POWERDOWN_BASEADDR;
  56. static void
  57. xilinx_power_off(void)
  58. {
  59. local_irq_disable();
  60. out_be32(powerdown_base, XPAR_POWER_0_POWERDOWN_VALUE);
  61. while (1) ;
  62. }
  63. #endif
  64. void __init
  65. ml300_map_io(void)
  66. {
  67. ppc4xx_map_io();
  68. #if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
  69. powerdown_base = ioremap((unsigned long) powerdown_base,
  70. XPAR_POWER_0_POWERDOWN_HIGHADDR -
  71. XPAR_POWER_0_POWERDOWN_BASEADDR + 1);
  72. #endif
  73. }
  74. static void __init
  75. ml300_early_serial_map(void)
  76. {
  77. #ifdef CONFIG_SERIAL_8250
  78. struct serial_state old_ports[] = { SERIAL_PORT_DFNS };
  79. struct uart_port port;
  80. int i;
  81. /* Setup ioremapped serial port access */
  82. for (i = 0; i < ARRAY_SIZE(old_ports); i++ ) {
  83. memset(&port, 0, sizeof(port));
  84. port.membase = ioremap((phys_addr_t)(old_ports[i].iomem_base), 16);
  85. port.irq = old_ports[i].irq;
  86. port.uartclk = old_ports[i].baud_base * 16;
  87. port.regshift = old_ports[i].iomem_reg_shift;
  88. port.iotype = SERIAL_IO_MEM;
  89. port.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST;
  90. port.line = i;
  91. if (early_serial_setup(&port) != 0) {
  92. printk("Early serial init of port %d failed\n", i);
  93. }
  94. }
  95. #endif /* CONFIG_SERIAL_8250 */
  96. }
  97. void __init
  98. ml300_setup_arch(void)
  99. {
  100. ppc4xx_setup_arch(); /* calls ppc4xx_find_bridges() */
  101. ml300_early_serial_map();
  102. /* Identify the system */
  103. printk(KERN_INFO "Xilinx Virtex-II Pro port\n");
  104. printk(KERN_INFO "Port by MontaVista Software, Inc. (source@mvista.com)\n");
  105. }
  106. /* Called after board_setup_irq from ppc4xx_init_IRQ(). */
  107. void __init
  108. ml300_init_irq(void)
  109. {
  110. ppc4xx_init_IRQ();
  111. }
  112. void __init
  113. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  114. unsigned long r6, unsigned long r7)
  115. {
  116. ppc4xx_init(r3, r4, r5, r6, r7);
  117. ppc_md.setup_arch = ml300_setup_arch;
  118. ppc_md.setup_io_mappings = ml300_map_io;
  119. ppc_md.init_IRQ = ml300_init_irq;
  120. #if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
  121. ppc_md.power_off = xilinx_power_off;
  122. #endif
  123. #ifdef CONFIG_KGDB
  124. ppc_md.early_serial_map = ml300_early_serial_map;
  125. #endif
  126. }