setup.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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/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/mach-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. extern void cobalt_early_console(void);
  31. int cobalt_board_id;
  32. const char *get_system_type(void)
  33. {
  34. switch (cobalt_board_id) {
  35. case COBALT_BRD_ID_QUBE1:
  36. return "Cobalt Qube";
  37. case COBALT_BRD_ID_RAQ1:
  38. return "Cobalt RaQ";
  39. case COBALT_BRD_ID_QUBE2:
  40. return "Cobalt Qube2";
  41. case COBALT_BRD_ID_RAQ2:
  42. return "Cobalt RaQ2";
  43. }
  44. return "MIPS Cobalt";
  45. }
  46. void __init plat_timer_setup(struct irqaction *irq)
  47. {
  48. /* Load timer value for 1KHz (TCLK is 50MHz) */
  49. GALILEO_OUTL(50*1000*1000 / 1000, GT_TC0_OFS);
  50. /* Enable timer */
  51. GALILEO_OUTL(GALILEO_ENTC0 | GALILEO_SELTC0, GT_TC_CONTROL_OFS);
  52. /* Register interrupt */
  53. setup_irq(COBALT_GALILEO_IRQ, irq);
  54. /* Enable interrupt */
  55. GALILEO_OUTL(GALILEO_INTR_T0EXP | GALILEO_INL(GT_INTRMASK_OFS), GT_INTRMASK_OFS);
  56. }
  57. extern struct pci_ops gt64111_pci_ops;
  58. static struct resource cobalt_mem_resource = {
  59. .start = GT64111_MEM_BASE,
  60. .end = GT64111_MEM_END,
  61. .name = "PCI memory",
  62. .flags = IORESOURCE_MEM
  63. };
  64. static struct resource cobalt_io_resource = {
  65. .start = 0x1000,
  66. .end = 0xffff,
  67. .name = "PCI I/O",
  68. .flags = IORESOURCE_IO
  69. };
  70. static struct resource cobalt_io_resources[] = {
  71. {
  72. .start = 0x00,
  73. .end = 0x1f,
  74. .name = "dma1",
  75. .flags = IORESOURCE_BUSY
  76. }, {
  77. .start = 0x40,
  78. .end = 0x5f,
  79. .name = "timer",
  80. .flags = IORESOURCE_BUSY
  81. }, {
  82. .start = 0x60,
  83. .end = 0x6f,
  84. .name = "keyboard",
  85. .flags = IORESOURCE_BUSY
  86. }, {
  87. .start = 0x80,
  88. .end = 0x8f,
  89. .name = "dma page reg",
  90. .flags = IORESOURCE_BUSY
  91. }, {
  92. .start = 0xc0,
  93. .end = 0xdf,
  94. .name = "dma2",
  95. .flags = IORESOURCE_BUSY
  96. },
  97. };
  98. #define COBALT_IO_RESOURCES (sizeof(cobalt_io_resources)/sizeof(struct resource))
  99. static struct pci_controller cobalt_pci_controller = {
  100. .pci_ops = &gt64111_pci_ops,
  101. .mem_resource = &cobalt_mem_resource,
  102. .mem_offset = 0,
  103. .io_resource = &cobalt_io_resource,
  104. .io_offset = 0 - GT64111_IO_BASE
  105. };
  106. void __init plat_mem_setup(void)
  107. {
  108. static struct uart_port uart;
  109. unsigned int devfn = PCI_DEVFN(COBALT_PCICONF_VIA, 0);
  110. int i;
  111. _machine_restart = cobalt_machine_restart;
  112. _machine_halt = cobalt_machine_halt;
  113. pm_power_off = cobalt_machine_power_off;
  114. set_io_port_base(CKSEG1ADDR(GT64111_IO_BASE));
  115. /* I/O port resource must include UART and LCD/buttons */
  116. ioport_resource.end = 0x0fffffff;
  117. /* request I/O space for devices used on all i[345]86 PCs */
  118. for (i = 0; i < COBALT_IO_RESOURCES; i++)
  119. request_resource(&ioport_resource, cobalt_io_resources + i);
  120. /* Read the cobalt id register out of the PCI config space */
  121. PCI_CFG_SET(devfn, (VIA_COBALT_BRD_ID_REG & ~0x3));
  122. cobalt_board_id = GALILEO_INL(GT_PCI0_CFGDATA_OFS);
  123. cobalt_board_id >>= ((VIA_COBALT_BRD_ID_REG & 3) * 8);
  124. cobalt_board_id = VIA_COBALT_BRD_REG_to_ID(cobalt_board_id);
  125. printk("Cobalt board ID: %d\n", cobalt_board_id);
  126. #ifdef CONFIG_PCI
  127. register_pci_controller(&cobalt_pci_controller);
  128. #endif
  129. #ifdef CONFIG_SERIAL_8250
  130. if (cobalt_board_id > COBALT_BRD_ID_RAQ1) {
  131. #ifdef CONFIG_EARLY_PRINTK
  132. cobalt_early_console();
  133. #endif
  134. uart.line = 0;
  135. uart.type = PORT_UNKNOWN;
  136. uart.uartclk = 18432000;
  137. uart.irq = COBALT_SERIAL_IRQ;
  138. uart.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
  139. uart.iobase = 0xc800000;
  140. uart.iotype = UPIO_PORT;
  141. early_serial_setup(&uart);
  142. }
  143. #endif
  144. }
  145. /*
  146. * Prom init. We read our one and only communication with the firmware.
  147. * Grab the amount of installed memory.
  148. * Better boot loaders (CoLo) pass a command line too :-)
  149. */
  150. void __init prom_init(void)
  151. {
  152. int narg, indx, posn, nchr;
  153. unsigned long memsz;
  154. char **argv;
  155. mips_machgroup = MACH_GROUP_COBALT;
  156. memsz = fw_arg0 & 0x7fff0000;
  157. narg = fw_arg0 & 0x0000ffff;
  158. if (narg) {
  159. arcs_cmdline[0] = '\0';
  160. argv = (char **) fw_arg1;
  161. posn = 0;
  162. for (indx = 1; indx < narg; ++indx) {
  163. nchr = strlen(argv[indx]);
  164. if (posn + 1 + nchr + 1 > sizeof(arcs_cmdline))
  165. break;
  166. if (posn)
  167. arcs_cmdline[posn++] = ' ';
  168. strcpy(arcs_cmdline + posn, argv[indx]);
  169. posn += nchr;
  170. }
  171. }
  172. add_memory_region(0x0, memsz, BOOT_MEM_RAM);
  173. }
  174. unsigned long __init prom_free_prom_memory(void)
  175. {
  176. /* Nothing to do! */
  177. return 0;
  178. }