xilinx_ml403.c 4.6 KB

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