xilinx_ml403.c 4.5 KB

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