blob: b212c072612537d260ed396f7371e7930c67accc [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright 2000 MontaVista Software Inc.
3 * Author: MontaVista Software, Inc.
4 * ppopov@mvista.com or source@mvista.com
5 *
6 * Updates to 2.6, Pete Popov, Embedded Alley Solutions, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
14 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
16 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
19 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 675 Mass Ave, Cambridge, MA 02139, USA.
27 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include <linux/init.h>
29#include <linux/sched.h>
30#include <linux/ioport.h>
31#include <linux/mm.h>
32#include <linux/delay.h>
33#include <linux/interrupt.h>
Pete Popovefe29c02005-09-15 23:42:27 +000034#include <linux/module.h>
Ralf Baechlefcdb27a2006-01-18 17:37:07 +000035#include <linux/pm.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
37#include <asm/cpu.h>
38#include <asm/bootinfo.h>
39#include <asm/irq.h>
40#include <asm/mipsregs.h>
41#include <asm/reboot.h>
42#include <asm/pgtable.h>
43#include <asm/mach-au1x00/au1000.h>
44#include <asm/time.h>
45
Ralf Baechlec21e6d62006-10-31 13:41:59 +000046extern char * prom_getcmdline(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070047extern void __init board_setup(void);
48extern void au1000_restart(char *);
49extern void au1000_halt(void);
50extern void au1000_power_off(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070051extern void au1x_time_init(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070052extern void au1x_timer_setup(struct irqaction *irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053extern void set_cpuspec(void);
54
Ralf Baechle2925aba2006-06-18 01:32:22 +010055void __init plat_mem_setup(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070056{
57 struct cpu_spec *sp;
58 char *argptr;
59 unsigned long prid, cpupll, bclk = 1;
60
61 set_cpuspec();
62 sp = cur_cpu_spec[0];
63
64 board_setup(); /* board specific setup */
65
66 prid = read_c0_prid();
67 cpupll = (au_readl(0xB1900060) & 0x3F) * 12;
68 printk("(PRId %08lx) @ %ldMHZ\n", prid, cpupll);
69
70 bclk = sp->cpu_bclk;
71 if (bclk)
72 {
73 /* Enable BCLK switching */
74 bclk = au_readl(0xB190003C);
75 au_writel(bclk | 0x60, 0xB190003C);
76 printk("BCLK switching enabled!\n");
77 }
78
79 if (sp->cpu_od) {
80 /* Various early Au1000 Errata corrected by this */
81 set_c0_config(1<<19); /* Set Config[OD] */
82 }
83 else {
84 /* Clear to obtain best system bus performance */
85 clear_c0_config(1<<19); /* Clear Config[OD] */
Ralf Baechlea3dddd52006-03-11 08:18:41 +000086 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
88 argptr = prom_getcmdline();
89
Ralf Baechle335bd9d2006-03-26 21:25:57 +010090#ifdef CONFIG_SERIAL_8250_CONSOLE
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 if ((argptr = strstr(argptr, "console=")) == NULL) {
92 argptr = prom_getcmdline();
93 strcat(argptr, " console=ttyS0,115200");
94 }
Ralf Baechle42a3b4f2005-09-03 15:56:17 -070095#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
97#ifdef CONFIG_FB_AU1100
98 if ((argptr = strstr(argptr, "video=")) == NULL) {
99 argptr = prom_getcmdline();
100 /* default panel */
101 /*strcat(argptr, " video=au1100fb:panel:Sharp_320x240_16");*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 }
103#endif
104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105
106#if defined(CONFIG_SOUND_AU1X00) && !defined(CONFIG_SOC_AU1000)
107 /* au1000 does not support vra, au1500 and au1100 do */
108 strcat(argptr, " au1000_audio=vra");
109 argptr = prom_getcmdline();
110#endif
111 _machine_restart = au1000_restart;
112 _machine_halt = au1000_halt;
Ralf Baechlefcdb27a2006-01-18 17:37:07 +0000113 pm_power_off = au1000_power_off;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
115 /* IO/MEM resources. */
116 set_io_port_base(0);
117 ioport_resource.start = IOPORT_RESOURCE_START;
118 ioport_resource.end = IOPORT_RESOURCE_END;
119 iomem_resource.start = IOMEM_RESOURCE_START;
120 iomem_resource.end = IOMEM_RESOURCE_END;
121
122 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_E0S);
123 au_writel(SYS_CNTRL_E0 | SYS_CNTRL_EN0, SYS_COUNTER_CNTRL);
124 au_sync();
125 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T0S);
126 au_writel(0, SYS_TOYTRIM);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127}
128
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129#if defined(CONFIG_64BIT_PHYS_ADDR)
130/* This routine should be valid for all Au1x based boards */
Maciej W. Rozyckic3455b02005-06-30 10:48:40 +0000131phys_t __fixup_bigphys_addr(phys_t phys_addr, phys_t size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 /* Don't fixup 36 bit addresses */
Ralf Baechle722b05a2006-11-07 10:22:31 +0000134 if ((phys_addr >> 32) != 0)
135 return phys_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
137#ifdef CONFIG_PCI
Ralf Baechle722b05a2006-11-07 10:22:31 +0000138 {
139 u32 start, end;
140
141 start = (u32)Au1500_PCI_MEM_START;
142 end = (u32)Au1500_PCI_MEM_END;
143 /* check for pci memory window */
144 if ((phys_addr >= start) && ((phys_addr + size) < end))
145 return (phys_t)
146 ((phys_addr - start) + Au1500_PCI_MEM_START);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 }
148#endif
149
150 /* All Au1x SOCs have a pcmcia controller */
151 /* We setup our 32 bit pseudo addresses to be equal to the
152 * 36 bit addr >> 4, to make it easier to check the address
153 * and fix it.
154 * The Au1x socket 0 phys attribute address is 0xF 4000 0000.
155 * The pseudo address we use is 0xF400 0000. Any address over
156 * 0xF400 0000 is a pcmcia pseudo address.
157 */
158 if ((phys_addr >= 0xF4000000) && (phys_addr < 0xFFFFFFFF)) {
159 return (phys_t)(phys_addr << 4);
160 }
161
162 /* default nop */
163 return phys_addr;
164}
Pete Popovefe29c02005-09-15 23:42:27 +0000165EXPORT_SYMBOL(__fixup_bigphys_addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166#endif