setup.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. *
  3. * 2.6 port, Embedded Alley Solutions, Inc
  4. *
  5. * Based on Per Hallsmark, per.hallsmark@mvista.com
  6. *
  7. * This program is free software; you can distribute it and/or modify it
  8. * under the terms of the GNU General Public License (Version 2) as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  14. * for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
  19. */
  20. #include <linux/config.h>
  21. #include <linux/init.h>
  22. #include <linux/sched.h>
  23. #include <linux/ioport.h>
  24. #include <linux/mm.h>
  25. #include <linux/delay.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/serial_ip3106.h>
  28. #include <linux/pm.h>
  29. #include <asm/cpu.h>
  30. #include <asm/bootinfo.h>
  31. #include <asm/irq.h>
  32. #include <asm/mipsregs.h>
  33. #include <asm/reboot.h>
  34. #include <asm/pgtable.h>
  35. #include <asm/time.h>
  36. #include <glb.h>
  37. #include <int.h>
  38. #include <pci.h>
  39. #include <uart.h>
  40. #include <nand.h>
  41. extern void prom_printf(char *fmt, ...);
  42. extern void __init board_setup(void);
  43. extern void pnx8550_machine_restart(char *);
  44. extern void pnx8550_machine_halt(void);
  45. extern void pnx8550_machine_power_off(void);
  46. extern struct resource ioport_resource;
  47. extern struct resource iomem_resource;
  48. extern void (*board_time_init)(void);
  49. extern void pnx8550_time_init(void);
  50. extern void (*board_timer_setup)(struct irqaction *irq);
  51. extern void pnx8550_timer_setup(struct irqaction *irq);
  52. extern void rs_kgdb_hook(int tty_no);
  53. extern void prom_printf(char *fmt, ...);
  54. extern char *prom_getcmdline(void);
  55. struct resource standard_io_resources[] = {
  56. {
  57. .start = .0x00,
  58. .end = 0x1f,
  59. .name = "dma1",
  60. .flags = IORESOURCE_BUSY
  61. }, {
  62. .start = 0x40,
  63. .end = 0x5f,
  64. .name = "timer",
  65. .flags = IORESOURCE_BUSY
  66. }, {
  67. .start = 0x80,
  68. .end = 0x8f,
  69. .name = "dma page reg",
  70. .flags = IORESOURCE_BUSY
  71. }, {
  72. .start = 0xc0,
  73. .end = 0xdf,
  74. .name = "dma2",
  75. .flags = IORESOURCE_BUSY
  76. },
  77. };
  78. #define STANDARD_IO_RESOURCES (sizeof(standard_io_resources)/sizeof(struct resource))
  79. extern struct resource pci_io_resource;
  80. extern struct resource pci_mem_resource;
  81. /* Return the total size of DRAM-memory, (RANK0 + RANK1) */
  82. unsigned long get_system_mem_size(void)
  83. {
  84. /* Read IP2031_RANK0_ADDR_LO */
  85. unsigned long dram_r0_lo = inl(PCI_BASE | 0x65010);
  86. /* Read IP2031_RANK1_ADDR_HI */
  87. unsigned long dram_r1_hi = inl(PCI_BASE | 0x65018);
  88. return dram_r1_hi - dram_r0_lo + 1;
  89. }
  90. int pnx8550_console_port = -1;
  91. void __init plat_mem_setup(void)
  92. {
  93. int i;
  94. char* argptr;
  95. board_setup(); /* board specific setup */
  96. _machine_restart = pnx8550_machine_restart;
  97. _machine_halt = pnx8550_machine_halt;
  98. pm_power_off = pnx8550_machine_power_off;
  99. board_time_init = pnx8550_time_init;
  100. board_timer_setup = pnx8550_timer_setup;
  101. /* Clear the Global 2 Register, PCI Inta Output Enable Registers
  102. Bit 1:Enable DAC Powerdown
  103. -> 0:DACs are enabled and are working normally
  104. 1:DACs are powerdown
  105. Bit 0:Enable of PCI inta output
  106. -> 0 = Disable PCI inta output
  107. 1 = Enable PCI inta output
  108. */
  109. PNX8550_GLB2_ENAB_INTA_O = 0;
  110. /* IO/MEM resources. */
  111. set_io_port_base(KSEG1);
  112. ioport_resource.start = 0;
  113. ioport_resource.end = ~0;
  114. iomem_resource.start = 0;
  115. iomem_resource.end = ~0;
  116. /* Request I/O space for devices on this board */
  117. for (i = 0; i < STANDARD_IO_RESOURCES; i++)
  118. request_resource(&ioport_resource, standard_io_resources + i);
  119. /* Place the Mode Control bit for GPIO pin 16 in primary function */
  120. /* Pin 16 is used by UART1, UA1_TX */
  121. outl((PNX8550_GPIO_MODE_PRIMOP << PNX8550_GPIO_MC_16_BIT) |
  122. (PNX8550_GPIO_MODE_PRIMOP << PNX8550_GPIO_MC_17_BIT),
  123. PNX8550_GPIO_MC1);
  124. argptr = prom_getcmdline();
  125. if ((argptr = strstr(argptr, "console=ttyS")) != NULL) {
  126. argptr += strlen("console=ttyS");
  127. pnx8550_console_port = *argptr == '0' ? 0 : 1;
  128. /* We must initialize the UART (console) before prom_printf */
  129. /* Set LCR to 8-bit and BAUD to 38400 (no 5) */
  130. ip3106_lcr(UART_BASE, pnx8550_console_port) =
  131. IP3106_UART_LCR_8BIT;
  132. ip3106_baud(UART_BASE, pnx8550_console_port) = 5;
  133. }
  134. #ifdef CONFIG_KGDB
  135. argptr = prom_getcmdline();
  136. if ((argptr = strstr(argptr, "kgdb=ttyS")) != NULL) {
  137. int line;
  138. argptr += strlen("kgdb=ttyS");
  139. line = *argptr == '0' ? 0 : 1;
  140. rs_kgdb_hook(line);
  141. prom_printf("KGDB: Using ttyS%i for session, "
  142. "please connect your debugger\n", line ? 1 : 0);
  143. }
  144. #endif
  145. return;
  146. }