setup.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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/mach-cobalt/cobalt.h>
  26. extern void cobalt_machine_restart(char *command);
  27. extern void cobalt_machine_halt(void);
  28. extern void cobalt_machine_power_off(void);
  29. extern void cobalt_early_console(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. void __init plat_timer_setup(struct irqaction *irq)
  46. {
  47. /* Load timer value for HZ (TCLK is 50MHz) */
  48. GT_WRITE(GT_TC0_OFS, 50*1000*1000 / HZ);
  49. /* Enable timer */
  50. GT_WRITE(GT_TC_CONTROL_OFS, GT_TC_CONTROL_ENTC0_MSK | GT_TC_CONTROL_SELTC0_MSK);
  51. /* Register interrupt */
  52. setup_irq(COBALT_GALILEO_IRQ, irq);
  53. /* Enable interrupt */
  54. GT_WRITE(GT_INTRMASK_OFS, GT_INTR_T0EXP_MSK | GT_READ(GT_INTRMASK_OFS));
  55. }
  56. extern struct pci_ops gt64111_pci_ops;
  57. static struct resource cobalt_mem_resource = {
  58. .start = GT_DEF_PCI0_MEM0_BASE,
  59. .end = GT_DEF_PCI0_MEM0_BASE + GT_DEF_PCI0_MEM0_SIZE - 1,
  60. .name = "PCI memory",
  61. .flags = IORESOURCE_MEM
  62. };
  63. static struct resource cobalt_io_resource = {
  64. .start = 0x1000,
  65. .end = 0xffff,
  66. .name = "PCI I/O",
  67. .flags = IORESOURCE_IO
  68. };
  69. static struct resource cobalt_io_resources[] = {
  70. {
  71. .start = 0x00,
  72. .end = 0x1f,
  73. .name = "dma1",
  74. .flags = IORESOURCE_BUSY
  75. }, {
  76. .start = 0x40,
  77. .end = 0x5f,
  78. .name = "timer",
  79. .flags = IORESOURCE_BUSY
  80. }, {
  81. .start = 0x60,
  82. .end = 0x6f,
  83. .name = "keyboard",
  84. .flags = IORESOURCE_BUSY
  85. }, {
  86. .start = 0x80,
  87. .end = 0x8f,
  88. .name = "dma page reg",
  89. .flags = IORESOURCE_BUSY
  90. }, {
  91. .start = 0xc0,
  92. .end = 0xdf,
  93. .name = "dma2",
  94. .flags = IORESOURCE_BUSY
  95. },
  96. };
  97. #define COBALT_IO_RESOURCES (sizeof(cobalt_io_resources)/sizeof(struct resource))
  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 UART and LCD/buttons */
  115. ioport_resource.end = 0x0fffffff;
  116. /* request I/O space for devices used on all i[345]86 PCs */
  117. for (i = 0; i < COBALT_IO_RESOURCES; i++)
  118. request_resource(&ioport_resource, cobalt_io_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. #ifdef CONFIG_SERIAL_8250
  129. if (cobalt_board_id > COBALT_BRD_ID_RAQ1) {
  130. #ifdef CONFIG_EARLY_PRINTK
  131. cobalt_early_console();
  132. #endif
  133. uart.line = 0;
  134. uart.type = PORT_UNKNOWN;
  135. uart.uartclk = 18432000;
  136. uart.irq = COBALT_SERIAL_IRQ;
  137. uart.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
  138. uart.iobase = 0xc800000;
  139. uart.iotype = UPIO_PORT;
  140. early_serial_setup(&uart);
  141. }
  142. #endif
  143. }
  144. /*
  145. * Prom init. We read our one and only communication with the firmware.
  146. * Grab the amount of installed memory.
  147. * Better boot loaders (CoLo) pass a command line too :-)
  148. */
  149. void __init prom_init(void)
  150. {
  151. int narg, indx, posn, nchr;
  152. unsigned long memsz;
  153. char **argv;
  154. mips_machgroup = MACH_GROUP_COBALT;
  155. memsz = fw_arg0 & 0x7fff0000;
  156. narg = fw_arg0 & 0x0000ffff;
  157. if (narg) {
  158. arcs_cmdline[0] = '\0';
  159. argv = (char **) fw_arg1;
  160. posn = 0;
  161. for (indx = 1; indx < narg; ++indx) {
  162. nchr = strlen(argv[indx]);
  163. if (posn + 1 + nchr + 1 > sizeof(arcs_cmdline))
  164. break;
  165. if (posn)
  166. arcs_cmdline[posn++] = ' ';
  167. strcpy(arcs_cmdline + posn, argv[indx]);
  168. posn += nchr;
  169. }
  170. }
  171. add_memory_region(0x0, memsz, BOOT_MEM_RAM);
  172. }
  173. void __init prom_free_prom_memory(void)
  174. {
  175. /* Nothing to do! */
  176. }