Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
Sergei Shtylyov | ce28f94 | 2008-04-23 22:43:55 +0400 | [diff] [blame^] | 28 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | #include <linux/init.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include <linux/ioport.h> |
Pete Popov | efe29c0 | 2005-09-15 23:42:27 +0000 | [diff] [blame] | 31 | #include <linux/module.h> |
Ralf Baechle | fcdb27a | 2006-01-18 17:37:07 +0000 | [diff] [blame] | 32 | #include <linux/pm.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include <asm/mipsregs.h> |
| 35 | #include <asm/reboot.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include <asm/time.h> |
| 37 | |
Yoichi Yuasa | 25b31cb | 2007-10-15 19:11:24 +0900 | [diff] [blame] | 38 | #include <au1000.h> |
| 39 | #include <prom.h> |
| 40 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | extern void __init board_setup(void); |
| 42 | extern void au1000_restart(char *); |
| 43 | extern void au1000_halt(void); |
| 44 | extern void au1000_power_off(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | extern void set_cpuspec(void); |
| 46 | |
Ralf Baechle | 2925aba | 2006-06-18 01:32:22 +0100 | [diff] [blame] | 47 | void __init plat_mem_setup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | { |
| 49 | struct cpu_spec *sp; |
| 50 | char *argptr; |
Sergei Shtylyov | 758e285 | 2008-03-27 16:09:31 +0300 | [diff] [blame] | 51 | unsigned long prid, cpufreq, bclk = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
| 53 | set_cpuspec(); |
| 54 | sp = cur_cpu_spec[0]; |
| 55 | |
| 56 | board_setup(); /* board specific setup */ |
| 57 | |
| 58 | prid = read_c0_prid(); |
Sergei Shtylyov | 758e285 | 2008-03-27 16:09:31 +0300 | [diff] [blame] | 59 | if (sp->cpu_pll_wo) |
| 60 | #ifdef CONFIG_SOC_AU1000_FREQUENCY |
| 61 | cpufreq = CONFIG_SOC_AU1000_FREQUENCY / 1000000; |
| 62 | #else |
| 63 | cpufreq = 396; |
| 64 | #endif |
| 65 | else |
| 66 | cpufreq = (au_readl(SYS_CPUPLL) & 0x3F) * 12; |
| 67 | printk(KERN_INFO "(PRID %08lx) @ %ld MHz\n", prid, cpufreq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
| 69 | bclk = sp->cpu_bclk; |
| 70 | if (bclk) |
| 71 | { |
| 72 | /* Enable BCLK switching */ |
| 73 | bclk = au_readl(0xB190003C); |
| 74 | au_writel(bclk | 0x60, 0xB190003C); |
| 75 | printk("BCLK switching enabled!\n"); |
| 76 | } |
| 77 | |
| 78 | if (sp->cpu_od) { |
| 79 | /* Various early Au1000 Errata corrected by this */ |
| 80 | set_c0_config(1<<19); /* Set Config[OD] */ |
| 81 | } |
| 82 | else { |
| 83 | /* Clear to obtain best system bus performance */ |
| 84 | clear_c0_config(1<<19); /* Clear Config[OD] */ |
Ralf Baechle | a3dddd5 | 2006-03-11 08:18:41 +0000 | [diff] [blame] | 85 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | |
| 87 | argptr = prom_getcmdline(); |
| 88 | |
Ralf Baechle | 335bd9d | 2006-03-26 21:25:57 +0100 | [diff] [blame] | 89 | #ifdef CONFIG_SERIAL_8250_CONSOLE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | if ((argptr = strstr(argptr, "console=")) == NULL) { |
| 91 | argptr = prom_getcmdline(); |
| 92 | strcat(argptr, " console=ttyS0,115200"); |
| 93 | } |
Ralf Baechle | 42a3b4f | 2005-09-03 15:56:17 -0700 | [diff] [blame] | 94 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | |
| 96 | #ifdef CONFIG_FB_AU1100 |
| 97 | if ((argptr = strstr(argptr, "video=")) == NULL) { |
| 98 | argptr = prom_getcmdline(); |
| 99 | /* default panel */ |
| 100 | /*strcat(argptr, " video=au1100fb:panel:Sharp_320x240_16");*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | } |
| 102 | #endif |
| 103 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | |
| 105 | #if defined(CONFIG_SOUND_AU1X00) && !defined(CONFIG_SOC_AU1000) |
| 106 | /* au1000 does not support vra, au1500 and au1100 do */ |
| 107 | strcat(argptr, " au1000_audio=vra"); |
| 108 | argptr = prom_getcmdline(); |
| 109 | #endif |
| 110 | _machine_restart = au1000_restart; |
| 111 | _machine_halt = au1000_halt; |
Ralf Baechle | fcdb27a | 2006-01-18 17:37:07 +0000 | [diff] [blame] | 112 | pm_power_off = au1000_power_off; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | |
| 114 | /* IO/MEM resources. */ |
| 115 | set_io_port_base(0); |
| 116 | ioport_resource.start = IOPORT_RESOURCE_START; |
| 117 | ioport_resource.end = IOPORT_RESOURCE_END; |
| 118 | iomem_resource.start = IOMEM_RESOURCE_START; |
| 119 | iomem_resource.end = IOMEM_RESOURCE_END; |
| 120 | |
| 121 | while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_E0S); |
| 122 | au_writel(SYS_CNTRL_E0 | SYS_CNTRL_EN0, SYS_COUNTER_CNTRL); |
| 123 | au_sync(); |
| 124 | while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T0S); |
| 125 | au_writel(0, SYS_TOYTRIM); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | } |
| 127 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | #if defined(CONFIG_64BIT_PHYS_ADDR) |
| 129 | /* This routine should be valid for all Au1x based boards */ |
Maciej W. Rozycki | c3455b0 | 2005-06-30 10:48:40 +0000 | [diff] [blame] | 130 | phys_t __fixup_bigphys_addr(phys_t phys_addr, phys_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | /* Don't fixup 36 bit addresses */ |
Ralf Baechle | 722b05a | 2006-11-07 10:22:31 +0000 | [diff] [blame] | 133 | if ((phys_addr >> 32) != 0) |
| 134 | return phys_addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | |
| 136 | #ifdef CONFIG_PCI |
Ralf Baechle | 722b05a | 2006-11-07 10:22:31 +0000 | [diff] [blame] | 137 | { |
Sergei Shtylyov | b87bb40 | 2007-12-10 20:36:50 +0300 | [diff] [blame] | 138 | u32 start = (u32)Au1500_PCI_MEM_START; |
| 139 | u32 end = (u32)Au1500_PCI_MEM_END; |
Ralf Baechle | 722b05a | 2006-11-07 10:22:31 +0000 | [diff] [blame] | 140 | |
Sergei Shtylyov | b87bb40 | 2007-12-10 20:36:50 +0300 | [diff] [blame] | 141 | /* Check for PCI memory window */ |
| 142 | if (phys_addr >= start && (phys_addr + size - 1) <= end) |
Ralf Baechle | 722b05a | 2006-11-07 10:22:31 +0000 | [diff] [blame] | 143 | return (phys_t) |
| 144 | ((phys_addr - start) + Au1500_PCI_MEM_START); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | } |
| 146 | #endif |
| 147 | |
| 148 | /* All Au1x SOCs have a pcmcia controller */ |
| 149 | /* We setup our 32 bit pseudo addresses to be equal to the |
| 150 | * 36 bit addr >> 4, to make it easier to check the address |
| 151 | * and fix it. |
| 152 | * The Au1x socket 0 phys attribute address is 0xF 4000 0000. |
| 153 | * The pseudo address we use is 0xF400 0000. Any address over |
| 154 | * 0xF400 0000 is a pcmcia pseudo address. |
| 155 | */ |
| 156 | if ((phys_addr >= 0xF4000000) && (phys_addr < 0xFFFFFFFF)) { |
| 157 | return (phys_t)(phys_addr << 4); |
| 158 | } |
| 159 | |
| 160 | /* default nop */ |
| 161 | return phys_addr; |
| 162 | } |
Pete Popov | efe29c0 | 2005-09-15 23:42:27 +0000 | [diff] [blame] | 163 | EXPORT_SYMBOL(__fixup_bigphys_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | #endif |