setup.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*
  2. * Setup pointers to hardware dependent routines.
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. *
  8. * Copyright (C) 1996, 1997, 2004 by Ralf Baechle (ralf@linux-mips.org)
  9. * Copyright (C) 2001, 2002, 2003 by Liam Davies (ldavies@agile.tv)
  10. *
  11. */
  12. #include <linux/config.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/pci.h>
  15. #include <linux/init.h>
  16. #include <linux/serial.h>
  17. #include <linux/serial_core.h>
  18. #include <asm/bootinfo.h>
  19. #include <asm/time.h>
  20. #include <asm/io.h>
  21. #include <asm/irq.h>
  22. #include <asm/processor.h>
  23. #include <asm/reboot.h>
  24. #include <asm/gt64120.h>
  25. #include <asm/serial.h>
  26. #include <asm/cobalt/cobalt.h>
  27. extern void cobalt_machine_restart(char *command);
  28. extern void cobalt_machine_halt(void);
  29. extern void cobalt_machine_power_off(void);
  30. int cobalt_board_id;
  31. const char *get_system_type(void)
  32. {
  33. switch (cobalt_board_id) {
  34. case COBALT_BRD_ID_QUBE1:
  35. return "Cobalt Qube";
  36. case COBALT_BRD_ID_RAQ1:
  37. return "Cobalt RaQ";
  38. case COBALT_BRD_ID_QUBE2:
  39. return "Cobalt Qube2";
  40. case COBALT_BRD_ID_RAQ2:
  41. return "Cobalt RaQ2";
  42. }
  43. return "MIPS Cobalt";
  44. }
  45. static void __init cobalt_timer_setup(struct irqaction *irq)
  46. {
  47. /* Load timer value for 1KHz (TCLK is 50MHz) */
  48. GALILEO_OUTL(50*1000*1000 / 1000, GT_TC0_OFS);
  49. /* Enable timer */
  50. GALILEO_OUTL(GALILEO_ENTC0 | GALILEO_SELTC0, GT_TC_CONTROL_OFS);
  51. /* Register interrupt */
  52. setup_irq(COBALT_GALILEO_IRQ, irq);
  53. /* Enable interrupt */
  54. GALILEO_OUTL(GALILEO_INTR_T0EXP | GALILEO_INL(GT_INTRMASK_OFS), GT_INTRMASK_OFS);
  55. }
  56. extern struct pci_ops gt64111_pci_ops;
  57. static struct resource cobalt_mem_resource = {
  58. "PCI memory", GT64111_MEM_BASE, GT64111_MEM_END, IORESOURCE_MEM
  59. };
  60. static struct resource cobalt_io_resource = {
  61. "PCI I/O", 0x1000, 0xffff, IORESOURCE_IO
  62. };
  63. static struct resource cobalt_io_resources[] = {
  64. { "dma1", 0x00, 0x1f, IORESOURCE_BUSY },
  65. { "timer", 0x40, 0x5f, IORESOURCE_BUSY },
  66. { "keyboard", 0x60, 0x6f, IORESOURCE_BUSY },
  67. { "dma page reg", 0x80, 0x8f, IORESOURCE_BUSY },
  68. { "dma2", 0xc0, 0xdf, IORESOURCE_BUSY },
  69. };
  70. #define COBALT_IO_RESOURCES (sizeof(cobalt_io_resources)/sizeof(struct resource))
  71. static struct pci_controller cobalt_pci_controller = {
  72. .pci_ops = &gt64111_pci_ops,
  73. .mem_resource = &cobalt_mem_resource,
  74. .mem_offset = 0,
  75. .io_resource = &cobalt_io_resource,
  76. .io_offset = 0 - GT64111_IO_BASE
  77. };
  78. void __init plat_setup(void)
  79. {
  80. static struct uart_port uart;
  81. unsigned int devfn = PCI_DEVFN(COBALT_PCICONF_VIA, 0);
  82. int i;
  83. _machine_restart = cobalt_machine_restart;
  84. _machine_halt = cobalt_machine_halt;
  85. _machine_power_off = cobalt_machine_power_off;
  86. board_timer_setup = cobalt_timer_setup;
  87. set_io_port_base(CKSEG1ADDR(GT64111_IO_BASE));
  88. /* I/O port resource must include UART and LCD/buttons */
  89. ioport_resource.end = 0x0fffffff;
  90. /*
  91. * This is a prom style console. We just poke at the
  92. * UART to make it talk.
  93. * Only use this console if you really screw up and can't
  94. * get to the stage of setting up a real serial console.
  95. */
  96. /*ns16550_setup_console();*/
  97. /* request I/O space for devices used on all i[345]86 PCs */
  98. for (i = 0; i < COBALT_IO_RESOURCES; i++)
  99. request_resource(&ioport_resource, cobalt_io_resources + i);
  100. /* Read the cobalt id register out of the PCI config space */
  101. PCI_CFG_SET(devfn, (VIA_COBALT_BRD_ID_REG & ~0x3));
  102. cobalt_board_id = GALILEO_INL(GT_PCI0_CFGDATA_OFS);
  103. cobalt_board_id >>= ((VIA_COBALT_BRD_ID_REG & 3) * 8);
  104. cobalt_board_id = VIA_COBALT_BRD_REG_to_ID(cobalt_board_id);
  105. printk("Cobalt board ID: %d\n", cobalt_board_id);
  106. #ifdef CONFIG_PCI
  107. register_pci_controller(&cobalt_pci_controller);
  108. #endif
  109. #ifdef CONFIG_SERIAL_8250
  110. if (cobalt_board_id > COBALT_BRD_ID_RAQ1) {
  111. uart.line = 0;
  112. uart.type = PORT_UNKNOWN;
  113. uart.uartclk = 18432000;
  114. uart.irq = COBALT_SERIAL_IRQ;
  115. uart.flags = STD_COM_FLAGS;
  116. uart.iobase = 0xc800000;
  117. uart.iotype = UPIO_PORT;
  118. early_serial_setup(&uart);
  119. }
  120. #endif
  121. }
  122. /*
  123. * Prom init. We read our one and only communication with the firmware.
  124. * Grab the amount of installed memory.
  125. * Better boot loaders (CoLo) pass a command line too :-)
  126. */
  127. void __init prom_init(void)
  128. {
  129. int narg, indx, posn, nchr;
  130. unsigned long memsz;
  131. char **argv;
  132. mips_machgroup = MACH_GROUP_COBALT;
  133. memsz = fw_arg0 & 0x7fff0000;
  134. narg = fw_arg0 & 0x0000ffff;
  135. if (narg) {
  136. arcs_cmdline[0] = '\0';
  137. argv = (char **) fw_arg1;
  138. posn = 0;
  139. for (indx = 1; indx < narg; ++indx) {
  140. nchr = strlen(argv[indx]);
  141. if (posn + 1 + nchr + 1 > sizeof(arcs_cmdline))
  142. break;
  143. if (posn)
  144. arcs_cmdline[posn++] = ' ';
  145. strcpy(arcs_cmdline + posn, argv[indx]);
  146. posn += nchr;
  147. }
  148. }
  149. add_memory_region(0x0, memsz, BOOT_MEM_RAM);
  150. }
  151. unsigned long __init prom_free_prom_memory(void)
  152. {
  153. /* Nothing to do! */
  154. return 0;
  155. }