setup.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. extern struct pci_ops gt64111_pci_ops;
  55. static struct resource cobalt_mem_resource = {
  56. .start = GT_DEF_PCI0_MEM0_BASE,
  57. .end = GT_DEF_PCI0_MEM0_BASE + GT_DEF_PCI0_MEM0_SIZE - 1,
  58. .name = "PCI memory",
  59. .flags = IORESOURCE_MEM
  60. };
  61. static struct resource cobalt_io_resource = {
  62. .start = 0x1000,
  63. .end = 0xffff,
  64. .name = "PCI I/O",
  65. .flags = IORESOURCE_IO
  66. };
  67. /*
  68. * Cobalt doesn't have PS/2 keyboard/mouse interfaces,
  69. * keyboard conntroller is never used.
  70. * Also PCI-ISA bridge DMA contoroller is never used.
  71. */
  72. static struct resource cobalt_reserved_resources[] = {
  73. { /* dma1 */
  74. .start = 0x00,
  75. .end = 0x1f,
  76. .name = "reserved",
  77. .flags = IORESOURCE_BUSY | IORESOURCE_IO,
  78. },
  79. { /* keyboard */
  80. .start = 0x60,
  81. .end = 0x6f,
  82. .name = "reserved",
  83. .flags = IORESOURCE_BUSY | IORESOURCE_IO,
  84. },
  85. { /* dma page reg */
  86. .start = 0x80,
  87. .end = 0x8f,
  88. .name = "reserved",
  89. .flags = IORESOURCE_BUSY | IORESOURCE_IO,
  90. },
  91. { /* dma2 */
  92. .start = 0xc0,
  93. .end = 0xdf,
  94. .name = "reserved",
  95. .flags = IORESOURCE_BUSY | IORESOURCE_IO,
  96. },
  97. };
  98. static struct pci_controller cobalt_pci_controller = {
  99. .pci_ops = &gt64111_pci_ops,
  100. .mem_resource = &cobalt_mem_resource,
  101. .mem_offset = 0,
  102. .io_resource = &cobalt_io_resource,
  103. .io_offset = 0 - GT_DEF_PCI0_IO_BASE,
  104. };
  105. void __init plat_mem_setup(void)
  106. {
  107. static struct uart_port uart;
  108. unsigned int devfn = PCI_DEVFN(COBALT_PCICONF_VIA, 0);
  109. int i;
  110. _machine_restart = cobalt_machine_restart;
  111. _machine_halt = cobalt_machine_halt;
  112. pm_power_off = cobalt_machine_power_off;
  113. set_io_port_base(CKSEG1ADDR(GT_DEF_PCI0_IO_BASE));
  114. /* I/O port resource must include LCD/buttons */
  115. ioport_resource.end = 0x0fffffff;
  116. /* These resources have been reserved by VIA SuperI/O chip. */
  117. for (i = 0; i < ARRAY_SIZE(cobalt_reserved_resources); i++)
  118. request_resource(&ioport_resource, cobalt_reserved_resources + i);
  119. /* Read the cobalt id register out of the PCI config space */
  120. PCI_CFG_SET(devfn, (VIA_COBALT_BRD_ID_REG & ~0x3));
  121. cobalt_board_id = GT_READ(GT_PCI0_CFGDATA_OFS);
  122. cobalt_board_id >>= ((VIA_COBALT_BRD_ID_REG & 3) * 8);
  123. cobalt_board_id = VIA_COBALT_BRD_REG_to_ID(cobalt_board_id);
  124. printk("Cobalt board ID: %d\n", cobalt_board_id);
  125. #ifdef CONFIG_PCI
  126. register_pci_controller(&cobalt_pci_controller);
  127. #endif
  128. if (cobalt_board_id > COBALT_BRD_ID_RAQ1) {
  129. #ifdef CONFIG_SERIAL_8250
  130. uart.line = 0;
  131. uart.type = PORT_UNKNOWN;
  132. uart.uartclk = 18432000;
  133. uart.irq = COBALT_SERIAL_IRQ;
  134. uart.flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF |
  135. UPF_SKIP_TEST;
  136. uart.iotype = UPIO_MEM;
  137. uart.mapbase = 0x1c800000;
  138. early_serial_setup(&uart);
  139. #endif
  140. }
  141. }
  142. /*
  143. * Prom init. We read our one and only communication with the firmware.
  144. * Grab the amount of installed memory.
  145. * Better boot loaders (CoLo) pass a command line too :-)
  146. */
  147. void __init prom_init(void)
  148. {
  149. int narg, indx, posn, nchr;
  150. unsigned long memsz;
  151. char **argv;
  152. mips_machgroup = MACH_GROUP_COBALT;
  153. memsz = fw_arg0 & 0x7fff0000;
  154. narg = fw_arg0 & 0x0000ffff;
  155. if (narg) {
  156. arcs_cmdline[0] = '\0';
  157. argv = (char **) fw_arg1;
  158. posn = 0;
  159. for (indx = 1; indx < narg; ++indx) {
  160. nchr = strlen(argv[indx]);
  161. if (posn + 1 + nchr + 1 > sizeof(arcs_cmdline))
  162. break;
  163. if (posn)
  164. arcs_cmdline[posn++] = ' ';
  165. strcpy(arcs_cmdline + posn, argv[indx]);
  166. posn += nchr;
  167. }
  168. }
  169. add_memory_region(0x0, memsz, BOOT_MEM_RAM);
  170. }
  171. void __init prom_free_prom_memory(void)
  172. {
  173. /* Nothing to do! */
  174. }