xilinx_ml300.c 4.6 KB

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