setup.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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/init.h>
  21. #include <linux/sched.h>
  22. #include <linux/ioport.h>
  23. #include <linux/irq.h>
  24. #include <linux/mm.h>
  25. #include <linux/delay.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/serial_pnx8xxx.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 __init board_setup(void);
  42. extern void pnx8550_machine_restart(char *);
  43. extern void pnx8550_machine_halt(void);
  44. extern struct resource ioport_resource;
  45. extern struct resource iomem_resource;
  46. extern char *prom_getcmdline(void);
  47. struct resource standard_io_resources[] = {
  48. {
  49. .start = 0x00,
  50. .end = 0x1f,
  51. .name = "dma1",
  52. .flags = IORESOURCE_BUSY
  53. }, {
  54. .start = 0x40,
  55. .end = 0x5f,
  56. .name = "timer",
  57. .flags = IORESOURCE_BUSY
  58. }, {
  59. .start = 0x80,
  60. .end = 0x8f,
  61. .name = "dma page reg",
  62. .flags = IORESOURCE_BUSY
  63. }, {
  64. .start = 0xc0,
  65. .end = 0xdf,
  66. .name = "dma2",
  67. .flags = IORESOURCE_BUSY
  68. },
  69. };
  70. #define STANDARD_IO_RESOURCES ARRAY_SIZE(standard_io_resources)
  71. extern struct resource pci_io_resource;
  72. extern struct resource pci_mem_resource;
  73. /* Return the total size of DRAM-memory, (RANK0 + RANK1) */
  74. unsigned long get_system_mem_size(void)
  75. {
  76. /* Read IP2031_RANK0_ADDR_LO */
  77. unsigned long dram_r0_lo = inl(PCI_BASE | 0x65010);
  78. /* Read IP2031_RANK1_ADDR_HI */
  79. unsigned long dram_r1_hi = inl(PCI_BASE | 0x65018);
  80. return dram_r1_hi - dram_r0_lo + 1;
  81. }
  82. int pnx8550_console_port = -1;
  83. void __init plat_mem_setup(void)
  84. {
  85. int i;
  86. char* argptr;
  87. board_setup(); /* board specific setup */
  88. _machine_restart = pnx8550_machine_restart;
  89. _machine_halt = pnx8550_machine_halt;
  90. pm_power_off = pnx8550_machine_halt;
  91. /* Clear the Global 2 Register, PCI Inta Output Enable Registers
  92. Bit 1:Enable DAC Powerdown
  93. -> 0:DACs are enabled and are working normally
  94. 1:DACs are powerdown
  95. Bit 0:Enable of PCI inta output
  96. -> 0 = Disable PCI inta output
  97. 1 = Enable PCI inta output
  98. */
  99. PNX8550_GLB2_ENAB_INTA_O = 0;
  100. /* IO/MEM resources. */
  101. set_io_port_base(PNX8550_PORT_BASE);
  102. ioport_resource.start = 0;
  103. ioport_resource.end = ~0;
  104. iomem_resource.start = 0;
  105. iomem_resource.end = ~0;
  106. /* Request I/O space for devices on this board */
  107. for (i = 0; i < STANDARD_IO_RESOURCES; i++)
  108. request_resource(&ioport_resource, standard_io_resources + i);
  109. /* Place the Mode Control bit for GPIO pin 16 in primary function */
  110. /* Pin 16 is used by UART1, UA1_TX */
  111. outl((PNX8550_GPIO_MODE_PRIMOP << PNX8550_GPIO_MC_16_BIT) |
  112. (PNX8550_GPIO_MODE_PRIMOP << PNX8550_GPIO_MC_17_BIT),
  113. PNX8550_GPIO_MC1);
  114. argptr = prom_getcmdline();
  115. if ((argptr = strstr(argptr, "console=ttyS")) != NULL) {
  116. argptr += strlen("console=ttyS");
  117. pnx8550_console_port = *argptr == '0' ? 0 : 1;
  118. /* We must initialize the UART (console) before early printk */
  119. /* Set LCR to 8-bit and BAUD to 38400 (no 5) */
  120. ip3106_lcr(UART_BASE, pnx8550_console_port) =
  121. PNX8XXX_UART_LCR_8BIT;
  122. ip3106_baud(UART_BASE, pnx8550_console_port) = 5;
  123. }
  124. }