blob: 1a0cc3eef57f8417c7351d26dc9bc664506e44b0 [file] [log] [blame]
Pete Popovbdf21b12005-07-14 17:47:57 +00001/*
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 */
Pete Popovbdf21b12005-07-14 17:47:57 +000020#include <linux/init.h>
21#include <linux/sched.h>
22#include <linux/ioport.h>
Ralf Baechle50785a52006-07-09 20:42:40 +010023#include <linux/irq.h>
Pete Popovbdf21b12005-07-14 17:47:57 +000024#include <linux/mm.h>
25#include <linux/delay.h>
26#include <linux/interrupt.h>
27#include <linux/serial_ip3106.h>
Ralf Baechlefcdb27a2006-01-18 17:37:07 +000028#include <linux/pm.h>
Pete Popovbdf21b12005-07-14 17:47:57 +000029
30#include <asm/cpu.h>
31#include <asm/bootinfo.h>
32#include <asm/irq.h>
33#include <asm/mipsregs.h>
34#include <asm/reboot.h>
35#include <asm/pgtable.h>
36#include <asm/time.h>
37
38#include <glb.h>
39#include <int.h>
40#include <pci.h>
41#include <uart.h>
42#include <nand.h>
43
44extern void prom_printf(char *fmt, ...);
45
46extern void __init board_setup(void);
47extern void pnx8550_machine_restart(char *);
48extern void pnx8550_machine_halt(void);
49extern void pnx8550_machine_power_off(void);
50extern struct resource ioport_resource;
51extern struct resource iomem_resource;
52extern void (*board_time_init)(void);
53extern void pnx8550_time_init(void);
Pete Popovbdf21b12005-07-14 17:47:57 +000054extern void pnx8550_timer_setup(struct irqaction *irq);
55extern void rs_kgdb_hook(int tty_no);
56extern void prom_printf(char *fmt, ...);
57extern char *prom_getcmdline(void);
58
59struct resource standard_io_resources[] = {
Ralf Baechle5e46c3a2006-06-04 15:14:05 -070060 {
61 .start = .0x00,
62 .end = 0x1f,
63 .name = "dma1",
64 .flags = IORESOURCE_BUSY
65 }, {
66 .start = 0x40,
67 .end = 0x5f,
68 .name = "timer",
69 .flags = IORESOURCE_BUSY
70 }, {
71 .start = 0x80,
72 .end = 0x8f,
73 .name = "dma page reg",
74 .flags = IORESOURCE_BUSY
75 }, {
76 .start = 0xc0,
77 .end = 0xdf,
78 .name = "dma2",
79 .flags = IORESOURCE_BUSY
80 },
Pete Popovbdf21b12005-07-14 17:47:57 +000081};
82
83#define STANDARD_IO_RESOURCES (sizeof(standard_io_resources)/sizeof(struct resource))
84
85extern struct resource pci_io_resource;
86extern struct resource pci_mem_resource;
87
88/* Return the total size of DRAM-memory, (RANK0 + RANK1) */
89unsigned long get_system_mem_size(void)
90{
91 /* Read IP2031_RANK0_ADDR_LO */
92 unsigned long dram_r0_lo = inl(PCI_BASE | 0x65010);
93 /* Read IP2031_RANK1_ADDR_HI */
94 unsigned long dram_r1_hi = inl(PCI_BASE | 0x65018);
95
96 return dram_r1_hi - dram_r0_lo + 1;
97}
98
99int pnx8550_console_port = -1;
100
Ralf Baechle2925aba2006-06-18 01:32:22 +0100101void __init plat_mem_setup(void)
Pete Popovbdf21b12005-07-14 17:47:57 +0000102{
103 int i;
104 char* argptr;
105
106 board_setup(); /* board specific setup */
107
108 _machine_restart = pnx8550_machine_restart;
109 _machine_halt = pnx8550_machine_halt;
Ralf Baechlefcdb27a2006-01-18 17:37:07 +0000110 pm_power_off = pnx8550_machine_power_off;
Pete Popovbdf21b12005-07-14 17:47:57 +0000111
112 board_time_init = pnx8550_time_init;
113 board_timer_setup = pnx8550_timer_setup;
114
115 /* Clear the Global 2 Register, PCI Inta Output Enable Registers
116 Bit 1:Enable DAC Powerdown
117 -> 0:DACs are enabled and are working normally
118 1:DACs are powerdown
119 Bit 0:Enable of PCI inta output
120 -> 0 = Disable PCI inta output
121 1 = Enable PCI inta output
122 */
123 PNX8550_GLB2_ENAB_INTA_O = 0;
124
125 /* IO/MEM resources. */
126 set_io_port_base(KSEG1);
127 ioport_resource.start = 0;
128 ioport_resource.end = ~0;
129 iomem_resource.start = 0;
130 iomem_resource.end = ~0;
131
132 /* Request I/O space for devices on this board */
133 for (i = 0; i < STANDARD_IO_RESOURCES; i++)
134 request_resource(&ioport_resource, standard_io_resources + i);
135
136 /* Place the Mode Control bit for GPIO pin 16 in primary function */
137 /* Pin 16 is used by UART1, UA1_TX */
138 outl((PNX8550_GPIO_MODE_PRIMOP << PNX8550_GPIO_MC_16_BIT) |
139 (PNX8550_GPIO_MODE_PRIMOP << PNX8550_GPIO_MC_17_BIT),
140 PNX8550_GPIO_MC1);
141
142 argptr = prom_getcmdline();
143 if ((argptr = strstr(argptr, "console=ttyS")) != NULL) {
144 argptr += strlen("console=ttyS");
145 pnx8550_console_port = *argptr == '0' ? 0 : 1;
146
147 /* We must initialize the UART (console) before prom_printf */
148 /* Set LCR to 8-bit and BAUD to 38400 (no 5) */
149 ip3106_lcr(UART_BASE, pnx8550_console_port) =
150 IP3106_UART_LCR_8BIT;
151 ip3106_baud(UART_BASE, pnx8550_console_port) = 5;
152 }
153
154#ifdef CONFIG_KGDB
155 argptr = prom_getcmdline();
156 if ((argptr = strstr(argptr, "kgdb=ttyS")) != NULL) {
157 int line;
158 argptr += strlen("kgdb=ttyS");
159 line = *argptr == '0' ? 0 : 1;
160 rs_kgdb_hook(line);
161 prom_printf("KGDB: Using ttyS%i for session, "
162 "please connect your debugger\n", line ? 1 : 0);
163 }
164#endif
165 return;
166}