setup.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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, 05 by Ralf Baechle (ralf@linux-mips.org)
  9. * Copyright (C) 2001, 2002, 2003 by Liam Davies (ldavies@agile.tv)
  10. *
  11. */
  12. #include <linux/interrupt.h>
  13. #include <linux/pci.h>
  14. #include <linux/init.h>
  15. #include <linux/pm.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/reboot.h>
  22. #include <asm/gt64120.h>
  23. #include <cobalt.h>
  24. extern void cobalt_machine_restart(char *command);
  25. extern void cobalt_machine_halt(void);
  26. extern void cobalt_machine_power_off(void);
  27. extern void cobalt_early_console(void);
  28. int cobalt_board_id;
  29. const char *get_system_type(void)
  30. {
  31. switch (cobalt_board_id) {
  32. case COBALT_BRD_ID_QUBE1:
  33. return "Cobalt Qube";
  34. case COBALT_BRD_ID_RAQ1:
  35. return "Cobalt RaQ";
  36. case COBALT_BRD_ID_QUBE2:
  37. return "Cobalt Qube2";
  38. case COBALT_BRD_ID_RAQ2:
  39. return "Cobalt RaQ2";
  40. }
  41. return "MIPS Cobalt";
  42. }
  43. void __init plat_timer_setup(struct irqaction *irq)
  44. {
  45. /* Load timer value for HZ (TCLK is 50MHz) */
  46. GT_WRITE(GT_TC0_OFS, 50*1000*1000 / HZ);
  47. /* Enable timer */
  48. GT_WRITE(GT_TC_CONTROL_OFS, GT_TC_CONTROL_ENTC0_MSK | GT_TC_CONTROL_SELTC0_MSK);
  49. /* Register interrupt */
  50. setup_irq(COBALT_GALILEO_IRQ, irq);
  51. /* Enable interrupt */
  52. GT_WRITE(GT_INTRMASK_OFS, GT_INTR_T0EXP_MSK | GT_READ(GT_INTRMASK_OFS));
  53. }
  54. /*
  55. * Cobalt doesn't have PS/2 keyboard/mouse interfaces,
  56. * keyboard conntroller is never used.
  57. * Also PCI-ISA bridge DMA contoroller is never used.
  58. */
  59. static struct resource cobalt_reserved_resources[] = {
  60. { /* dma1 */
  61. .start = 0x00,
  62. .end = 0x1f,
  63. .name = "reserved",
  64. .flags = IORESOURCE_BUSY | IORESOURCE_IO,
  65. },
  66. { /* keyboard */
  67. .start = 0x60,
  68. .end = 0x6f,
  69. .name = "reserved",
  70. .flags = IORESOURCE_BUSY | IORESOURCE_IO,
  71. },
  72. { /* dma page reg */
  73. .start = 0x80,
  74. .end = 0x8f,
  75. .name = "reserved",
  76. .flags = IORESOURCE_BUSY | IORESOURCE_IO,
  77. },
  78. { /* dma2 */
  79. .start = 0xc0,
  80. .end = 0xdf,
  81. .name = "reserved",
  82. .flags = IORESOURCE_BUSY | IORESOURCE_IO,
  83. },
  84. };
  85. void __init plat_mem_setup(void)
  86. {
  87. static struct uart_port uart;
  88. unsigned int devfn = PCI_DEVFN(COBALT_PCICONF_VIA, 0);
  89. int i;
  90. _machine_restart = cobalt_machine_restart;
  91. _machine_halt = cobalt_machine_halt;
  92. pm_power_off = cobalt_machine_power_off;
  93. set_io_port_base(CKSEG1ADDR(GT_DEF_PCI0_IO_BASE));
  94. /* I/O port resource must include LCD/buttons */
  95. ioport_resource.end = 0x0fffffff;
  96. /* These resources have been reserved by VIA SuperI/O chip. */
  97. for (i = 0; i < ARRAY_SIZE(cobalt_reserved_resources); i++)
  98. request_resource(&ioport_resource, cobalt_reserved_resources + i);
  99. /* Read the cobalt id register out of the PCI config space */
  100. PCI_CFG_SET(devfn, (VIA_COBALT_BRD_ID_REG & ~0x3));
  101. cobalt_board_id = GT_READ(GT_PCI0_CFGDATA_OFS);
  102. cobalt_board_id >>= ((VIA_COBALT_BRD_ID_REG & 3) * 8);
  103. cobalt_board_id = VIA_COBALT_BRD_REG_to_ID(cobalt_board_id);
  104. printk("Cobalt board ID: %d\n", cobalt_board_id);
  105. if (cobalt_board_id > COBALT_BRD_ID_RAQ1) {
  106. #ifdef CONFIG_SERIAL_8250
  107. uart.line = 0;
  108. uart.type = PORT_UNKNOWN;
  109. uart.uartclk = 18432000;
  110. uart.irq = COBALT_SERIAL_IRQ;
  111. uart.flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF |
  112. UPF_SKIP_TEST;
  113. uart.iotype = UPIO_MEM;
  114. uart.mapbase = 0x1c800000;
  115. early_serial_setup(&uart);
  116. #endif
  117. }
  118. }
  119. /*
  120. * Prom init. We read our one and only communication with the firmware.
  121. * Grab the amount of installed memory.
  122. * Better boot loaders (CoLo) pass a command line too :-)
  123. */
  124. void __init prom_init(void)
  125. {
  126. int narg, indx, posn, nchr;
  127. unsigned long memsz;
  128. char **argv;
  129. mips_machgroup = MACH_GROUP_COBALT;
  130. memsz = fw_arg0 & 0x7fff0000;
  131. narg = fw_arg0 & 0x0000ffff;
  132. if (narg) {
  133. arcs_cmdline[0] = '\0';
  134. argv = (char **) fw_arg1;
  135. posn = 0;
  136. for (indx = 1; indx < narg; ++indx) {
  137. nchr = strlen(argv[indx]);
  138. if (posn + 1 + nchr + 1 > sizeof(arcs_cmdline))
  139. break;
  140. if (posn)
  141. arcs_cmdline[posn++] = ' ';
  142. strcpy(arcs_cmdline + posn, argv[indx]);
  143. posn += nchr;
  144. }
  145. }
  146. add_memory_region(0x0, memsz, BOOT_MEM_RAM);
  147. }
  148. void __init prom_free_prom_memory(void)
  149. {
  150. /* Nothing to do! */
  151. }