Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Toshiba rbtx4927 specific setup |
| 3 | * |
| 4 | * Author: MontaVista Software, Inc. |
| 5 | * source@mvista.com |
| 6 | * |
| 7 | * Copyright 2001-2002 MontaVista Software Inc. |
| 8 | * |
| 9 | * Copyright (C) 1996, 97, 2001, 04 Ralf Baechle (ralf@linux-mips.org) |
| 10 | * Copyright (C) 2000 RidgeRun, Inc. |
| 11 | * Author: RidgeRun, Inc. |
| 12 | * glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com |
| 13 | * |
| 14 | * Copyright 2001 MontaVista Software Inc. |
| 15 | * Author: jsun@mvista.com or jsun@junsun.net |
| 16 | * |
| 17 | * Copyright 2002 MontaVista Software Inc. |
| 18 | * Author: Michael Pruznick, michael_pruznick@mvista.com |
| 19 | * |
| 20 | * Copyright (C) 2000-2001 Toshiba Corporation |
| 21 | * |
| 22 | * Copyright (C) 2004 MontaVista Software Inc. |
| 23 | * Author: Manish Lachwani, mlachwani@mvista.com |
| 24 | * |
| 25 | * This program is free software; you can redistribute it and/or modify it |
| 26 | * under the terms of the GNU General Public License as published by the |
| 27 | * Free Software Foundation; either version 2 of the License, or (at your |
| 28 | * option) any later version. |
| 29 | * |
| 30 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 31 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 32 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 33 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 35 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| 36 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 37 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |
| 38 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE |
| 39 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 40 | * |
| 41 | * You should have received a copy of the GNU General Public License along |
| 42 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 43 | * 675 Mass Ave, Cambridge, MA 02139, USA. |
| 44 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #include <linux/init.h> |
| 46 | #include <linux/kernel.h> |
| 47 | #include <linux/types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #include <linux/ioport.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | #include <linux/interrupt.h> |
Ralf Baechle | fcdb27a | 2006-01-18 17:37:07 +0000 | [diff] [blame] | 50 | #include <linux/pm.h> |
Atsushi Nemoto | a0574e0 | 2007-03-01 00:40:21 +0900 | [diff] [blame] | 51 | #include <linux/platform_device.h> |
Atsushi Nemoto | 2064ba2 | 2007-11-24 01:20:27 +0900 | [diff] [blame] | 52 | #include <linux/clk.h> |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 53 | #include <linux/delay.h> |
Ralf Baechle | fcdb27a | 2006-01-18 17:37:07 +0000 | [diff] [blame] | 54 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | #include <asm/bootinfo.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | #include <asm/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | #include <asm/processor.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | #include <asm/reboot.h> |
| 59 | #include <asm/time.h> |
Atsushi Nemoto | 229f773 | 2007-10-25 01:34:09 +0900 | [diff] [blame] | 60 | #include <asm/txx9tmr.h> |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 61 | #include <asm/txx9/generic.h> |
| 62 | #include <asm/txx9/pci.h> |
Atsushi Nemoto | 22b1d70 | 2008-07-11 00:31:36 +0900 | [diff] [blame] | 63 | #include <asm/txx9/rbtx4927.h> |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 64 | #include <asm/txx9/tx4938.h> /* for TX4937 */ |
Ralf Baechle | 5eaf7a2 | 2005-03-04 17:24:32 +0000 | [diff] [blame] | 65 | #ifdef CONFIG_SERIAL_TXX9 |
Ralf Baechle | 5eaf7a2 | 2005-03-04 17:24:32 +0000 | [diff] [blame] | 66 | #include <linux/serial_core.h> |
| 67 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | /* These functions are used for rebooting or halting the machine*/ |
| 70 | extern void toshiba_rbtx4927_restart(char *command); |
| 71 | extern void toshiba_rbtx4927_halt(void); |
| 72 | extern void toshiba_rbtx4927_power_off(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | extern void toshiba_rbtx4927_irq_setup(void); |
| 74 | |
Sergei Shtylyov | 57340b2 | 2007-02-07 20:41:36 +0300 | [diff] [blame] | 75 | char *prom_getcmdline(void); |
| 76 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | static int tx4927_ccfg_toeon = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | |
| 79 | char *toshiba_name = ""; |
| 80 | |
| 81 | #ifdef CONFIG_PCI |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 82 | static void __init tx4927_pci_setup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | { |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 84 | int extarb = !(__raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_PCIARB); |
| 85 | struct pci_controller *c = &txx9_primary_pcic; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 87 | register_pci_controller(c); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 89 | if (__raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_PCI66) |
| 90 | txx9_pci_option = |
| 91 | (txx9_pci_option & ~TXX9_PCI_OPT_CLK_MASK) | |
| 92 | TXX9_PCI_OPT_CLK_66; /* already configured */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 94 | /* Reset PCI Bus */ |
| 95 | writeb(1, rbtx4927_pcireset_addr); |
| 96 | /* Reset PCIC */ |
| 97 | txx9_set64(&tx4927_ccfgptr->clkctr, TX4927_CLKCTR_PCIRST); |
| 98 | if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) == |
| 99 | TXX9_PCI_OPT_CLK_66) |
| 100 | tx4927_pciclk66_setup(); |
| 101 | mdelay(10); |
| 102 | /* clear PCIC reset */ |
| 103 | txx9_clear64(&tx4927_ccfgptr->clkctr, TX4927_CLKCTR_PCIRST); |
| 104 | writeb(0, rbtx4927_pcireset_addr); |
| 105 | iob(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 107 | tx4927_report_pciclk(); |
| 108 | tx4927_pcic_setup(tx4927_pcicptr, c, extarb); |
| 109 | if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) == |
| 110 | TXX9_PCI_OPT_CLK_AUTO && |
| 111 | txx9_pci66_check(c, 0, 0)) { |
| 112 | /* Reset PCI Bus */ |
| 113 | writeb(1, rbtx4927_pcireset_addr); |
| 114 | /* Reset PCIC */ |
| 115 | txx9_set64(&tx4927_ccfgptr->clkctr, TX4927_CLKCTR_PCIRST); |
| 116 | tx4927_pciclk66_setup(); |
| 117 | mdelay(10); |
| 118 | /* clear PCIC reset */ |
| 119 | txx9_clear64(&tx4927_ccfgptr->clkctr, TX4927_CLKCTR_PCIRST); |
| 120 | writeb(0, rbtx4927_pcireset_addr); |
| 121 | iob(); |
| 122 | /* Reinitialize PCIC */ |
| 123 | tx4927_report_pciclk(); |
| 124 | tx4927_pcic_setup(tx4927_pcicptr, c, extarb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | } |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 126 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 128 | static void __init tx4937_pci_setup(void) |
| 129 | { |
| 130 | int extarb = !(__raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCIARB); |
| 131 | struct pci_controller *c = &txx9_primary_pcic; |
| 132 | |
| 133 | register_pci_controller(c); |
| 134 | |
| 135 | if (__raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCI66) |
| 136 | txx9_pci_option = |
| 137 | (txx9_pci_option & ~TXX9_PCI_OPT_CLK_MASK) | |
| 138 | TXX9_PCI_OPT_CLK_66; /* already configured */ |
| 139 | |
| 140 | /* Reset PCI Bus */ |
| 141 | writeb(1, rbtx4927_pcireset_addr); |
| 142 | /* Reset PCIC */ |
| 143 | txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST); |
| 144 | if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) == |
| 145 | TXX9_PCI_OPT_CLK_66) |
| 146 | tx4938_pciclk66_setup(); |
| 147 | mdelay(10); |
| 148 | /* clear PCIC reset */ |
| 149 | txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST); |
| 150 | writeb(0, rbtx4927_pcireset_addr); |
| 151 | iob(); |
| 152 | |
| 153 | tx4938_report_pciclk(); |
| 154 | tx4927_pcic_setup(tx4938_pcicptr, c, extarb); |
| 155 | if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) == |
| 156 | TXX9_PCI_OPT_CLK_AUTO && |
| 157 | txx9_pci66_check(c, 0, 0)) { |
| 158 | /* Reset PCI Bus */ |
| 159 | writeb(1, rbtx4927_pcireset_addr); |
| 160 | /* Reset PCIC */ |
| 161 | txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST); |
| 162 | tx4938_pciclk66_setup(); |
| 163 | mdelay(10); |
| 164 | /* clear PCIC reset */ |
| 165 | txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST); |
| 166 | writeb(0, rbtx4927_pcireset_addr); |
| 167 | iob(); |
| 168 | /* Reinitialize PCIC */ |
| 169 | tx4938_report_pciclk(); |
| 170 | tx4927_pcic_setup(tx4938_pcicptr, c, extarb); |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | static int __init rbtx4927_arch_init(void) |
| 175 | { |
| 176 | if (mips_machtype == MACH_TOSHIBA_RBTX4937) |
| 177 | tx4937_pci_setup(); |
| 178 | else |
| 179 | tx4927_pci_setup(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | return 0; |
| 181 | } |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 182 | arch_initcall(rbtx4927_arch_init); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | #endif /* CONFIG_PCI */ |
| 184 | |
Atsushi Nemoto | a02eb8d | 2007-08-28 00:28:09 +0900 | [diff] [blame] | 185 | static void __noreturn wait_forever(void) |
| 186 | { |
| 187 | while (1) |
| 188 | if (cpu_wait) |
| 189 | (*cpu_wait)(); |
| 190 | } |
| 191 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | void toshiba_rbtx4927_restart(char *command) |
| 193 | { |
| 194 | printk(KERN_NOTICE "System Rebooting...\n"); |
| 195 | |
| 196 | /* enable the s/w reset register */ |
Atsushi Nemoto | a02eb8d | 2007-08-28 00:28:09 +0900 | [diff] [blame] | 197 | writeb(RBTX4927_SW_RESET_ENABLE_SET, RBTX4927_SW_RESET_ENABLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | |
| 199 | /* wait for enable to be seen */ |
Atsushi Nemoto | a02eb8d | 2007-08-28 00:28:09 +0900 | [diff] [blame] | 200 | while ((readb(RBTX4927_SW_RESET_ENABLE) & |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | RBTX4927_SW_RESET_ENABLE_SET) == 0x00); |
| 202 | |
| 203 | /* do a s/w reset */ |
Atsushi Nemoto | a02eb8d | 2007-08-28 00:28:09 +0900 | [diff] [blame] | 204 | writeb(RBTX4927_SW_RESET_DO_SET, RBTX4927_SW_RESET_DO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | |
| 206 | /* do something passive while waiting for reset */ |
| 207 | local_irq_disable(); |
Atsushi Nemoto | a02eb8d | 2007-08-28 00:28:09 +0900 | [diff] [blame] | 208 | wait_forever(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | /* no return */ |
| 210 | } |
| 211 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | void toshiba_rbtx4927_halt(void) |
| 213 | { |
| 214 | printk(KERN_NOTICE "System Halted\n"); |
| 215 | local_irq_disable(); |
Atsushi Nemoto | a02eb8d | 2007-08-28 00:28:09 +0900 | [diff] [blame] | 216 | wait_forever(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | /* no return */ |
| 218 | } |
| 219 | |
| 220 | void toshiba_rbtx4927_power_off(void) |
| 221 | { |
| 222 | toshiba_rbtx4927_halt(); |
| 223 | /* no return */ |
| 224 | } |
| 225 | |
Atsushi Nemoto | 8b6c232 | 2007-10-24 23:16:56 +0900 | [diff] [blame] | 226 | void __init plat_mem_setup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | { |
Atsushi Nemoto | 229f773 | 2007-10-25 01:34:09 +0900 | [diff] [blame] | 228 | int i; |
Atsushi Nemoto | a02eb8d | 2007-08-28 00:28:09 +0900 | [diff] [blame] | 229 | u32 cp0_config; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | char *argptr; |
| 231 | |
| 232 | printk("CPU is %s\n", toshiba_name); |
| 233 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | /* f/w leaves this on at startup */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | clear_c0_status(ST0_ERL); |
| 236 | |
| 237 | /* enable caches -- HCP5 does this, pmon does not */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | cp0_config = read_c0_config(); |
| 239 | cp0_config = cp0_config & ~(TX49_CONF_IC | TX49_CONF_DC); |
| 240 | write_c0_config(cp0_config); |
| 241 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | ioport_resource.end = 0xffffffff; |
| 243 | iomem_resource.end = 0xffffffff; |
| 244 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | _machine_restart = toshiba_rbtx4927_restart; |
| 246 | _machine_halt = toshiba_rbtx4927_halt; |
Ralf Baechle | fcdb27a | 2006-01-18 17:37:07 +0000 | [diff] [blame] | 247 | pm_power_off = toshiba_rbtx4927_power_off; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | |
Atsushi Nemoto | 229f773 | 2007-10-25 01:34:09 +0900 | [diff] [blame] | 249 | for (i = 0; i < TX4927_NR_TMR; i++) |
| 250 | txx9_tmr_init(TX4927_TMR_REG(0) & 0xfffffffffULL); |
| 251 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | #ifdef CONFIG_PCI |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 253 | txx9_alloc_pci_controller(&txx9_primary_pcic, |
| 254 | RBTX4927_PCIMEM, RBTX4927_PCIMEM_SIZE, |
| 255 | RBTX4927_PCIIO, RBTX4927_PCIIO_SIZE); |
| 256 | #else |
| 257 | set_io_port_base(KSEG1 + RBTX4927_ISA_IO_OFFSET); |
| 258 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | /* |
| 261 | * ASSUMPTION: PCIDIVMODE is configured for PCI 33MHz or 66MHz. |
Sergei Shtylylov | f09678a | 2006-02-04 15:11:14 +0300 | [diff] [blame] | 262 | * |
| 263 | * For TX4927: |
| 264 | * PCIDIVMODE[12:11]'s initial value is given by S9[4:3] (ON:0, OFF:1). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | * CPU 166MHz: PCI 66MHz : PCIDIVMODE: 00 (1/2.5) |
| 266 | * CPU 200MHz: PCI 66MHz : PCIDIVMODE: 01 (1/3) |
| 267 | * CPU 166MHz: PCI 33MHz : PCIDIVMODE: 10 (1/5) |
| 268 | * CPU 200MHz: PCI 33MHz : PCIDIVMODE: 11 (1/6) |
| 269 | * i.e. S9[3]: ON (83MHz), OFF (100MHz) |
Sergei Shtylylov | f09678a | 2006-02-04 15:11:14 +0300 | [diff] [blame] | 270 | * |
| 271 | * For TX4937: |
| 272 | * PCIDIVMODE[12:11]'s initial value is given by S1[5:4] (ON:0, OFF:1) |
| 273 | * PCIDIVMODE[10] is 0. |
| 274 | * CPU 266MHz: PCI 33MHz : PCIDIVMODE: 000 (1/8) |
| 275 | * CPU 266MHz: PCI 66MHz : PCIDIVMODE: 001 (1/4) |
| 276 | * CPU 300MHz: PCI 33MHz : PCIDIVMODE: 010 (1/9) |
| 277 | * CPU 300MHz: PCI 66MHz : PCIDIVMODE: 011 (1/4.5) |
| 278 | * CPU 333MHz: PCI 33MHz : PCIDIVMODE: 100 (1/10) |
| 279 | * CPU 333MHz: PCI 66MHz : PCIDIVMODE: 101 (1/5) |
| 280 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | */ |
Sergei Shtylylov | f09678a | 2006-02-04 15:11:14 +0300 | [diff] [blame] | 282 | if (mips_machtype == MACH_TOSHIBA_RBTX4937) |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 283 | switch ((unsigned long)__raw_readq(&tx4938_ccfgptr->ccfg) & |
| 284 | TX4938_CCFG_PCIDIVMODE_MASK) { |
| 285 | case TX4938_CCFG_PCIDIVMODE_8: |
| 286 | case TX4938_CCFG_PCIDIVMODE_4: |
| 287 | txx9_cpu_clock = 266666666; /* 266MHz */ |
Sergei Shtylylov | f09678a | 2006-02-04 15:11:14 +0300 | [diff] [blame] | 288 | break; |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 289 | case TX4938_CCFG_PCIDIVMODE_9: |
| 290 | case TX4938_CCFG_PCIDIVMODE_4_5: |
| 291 | txx9_cpu_clock = 300000000; /* 300MHz */ |
Sergei Shtylylov | f09678a | 2006-02-04 15:11:14 +0300 | [diff] [blame] | 292 | break; |
| 293 | default: |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 294 | txx9_cpu_clock = 333333333; /* 333MHz */ |
Sergei Shtylylov | f09678a | 2006-02-04 15:11:14 +0300 | [diff] [blame] | 295 | } |
| 296 | else |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 297 | switch ((unsigned long)__raw_readq(&tx4927_ccfgptr->ccfg) & |
| 298 | TX4927_CCFG_PCIDIVMODE_MASK) { |
Sergei Shtylylov | f09678a | 2006-02-04 15:11:14 +0300 | [diff] [blame] | 299 | case TX4927_CCFG_PCIDIVMODE_2_5: |
| 300 | case TX4927_CCFG_PCIDIVMODE_5: |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 301 | txx9_cpu_clock = 166666666; /* 166MHz */ |
Sergei Shtylylov | f09678a | 2006-02-04 15:11:14 +0300 | [diff] [blame] | 302 | break; |
| 303 | default: |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 304 | txx9_cpu_clock = 200000000; /* 200MHz */ |
Sergei Shtylylov | f09678a | 2006-02-04 15:11:14 +0300 | [diff] [blame] | 305 | } |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 306 | /* change default value to udelay/mdelay take reasonable time */ |
| 307 | loops_per_jiffy = txx9_cpu_clock / HZ / 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | |
| 309 | /* CCFG */ |
Atsushi Nemoto | 2064ba2 | 2007-11-24 01:20:27 +0900 | [diff] [blame] | 310 | /* do reset on watchdog */ |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 311 | tx4927_ccfg_set(TX4927_CCFG_WR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | /* enable Timeout BusError */ |
| 313 | if (tx4927_ccfg_toeon) |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 314 | tx4927_ccfg_set(TX4927_CCFG_TOE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | |
Ralf Baechle | 5eaf7a2 | 2005-03-04 17:24:32 +0000 | [diff] [blame] | 316 | #ifdef CONFIG_SERIAL_TXX9 |
| 317 | { |
| 318 | extern int early_serial_txx9_setup(struct uart_port *port); |
Ralf Baechle | 5eaf7a2 | 2005-03-04 17:24:32 +0000 | [diff] [blame] | 319 | struct uart_port req; |
| 320 | for(i = 0; i < 2; i++) { |
| 321 | memset(&req, 0, sizeof(req)); |
| 322 | req.line = i; |
| 323 | req.iotype = UPIO_MEM; |
| 324 | req.membase = (char *)(0xff1ff300 + i * 0x100); |
| 325 | req.mapbase = 0xff1ff300 + i * 0x100; |
Atsushi Nemoto | c87abd7 | 2007-08-02 23:36:02 +0900 | [diff] [blame] | 326 | req.irq = TX4927_IRQ_PIC_BEG + 8 + i; |
Ralf Baechle | 5eaf7a2 | 2005-03-04 17:24:32 +0000 | [diff] [blame] | 327 | req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/; |
| 328 | req.uartclk = 50000000; |
| 329 | early_serial_txx9_setup(&req); |
| 330 | } |
| 331 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | #ifdef CONFIG_SERIAL_TXX9_CONSOLE |
| 333 | argptr = prom_getcmdline(); |
| 334 | if (strstr(argptr, "console=") == NULL) { |
| 335 | strcat(argptr, " console=ttyS0,38400"); |
| 336 | } |
| 337 | #endif |
Ralf Baechle | 5eaf7a2 | 2005-03-04 17:24:32 +0000 | [diff] [blame] | 338 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | |
| 340 | #ifdef CONFIG_ROOT_NFS |
| 341 | argptr = prom_getcmdline(); |
| 342 | if (strstr(argptr, "root=") == NULL) { |
| 343 | strcat(argptr, " root=/dev/nfs rw"); |
| 344 | } |
| 345 | #endif |
| 346 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | #ifdef CONFIG_IP_PNP |
| 348 | argptr = prom_getcmdline(); |
| 349 | if (strstr(argptr, "ip=") == NULL) { |
| 350 | strcat(argptr, " ip=any"); |
| 351 | } |
| 352 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | } |
| 354 | |
Atsushi Nemoto | 8b6c232 | 2007-10-24 23:16:56 +0900 | [diff] [blame] | 355 | void __init plat_time_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | { |
Atsushi Nemoto | 89d63fe | 2008-07-11 00:33:08 +0900 | [diff] [blame^] | 357 | mips_hpt_frequency = txx9_cpu_clock / 2; |
| 358 | if (____raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_TINTDIS) |
Atsushi Nemoto | 229f773 | 2007-10-25 01:34:09 +0900 | [diff] [blame] | 359 | txx9_clockevent_init(TX4927_TMR_REG(0) & 0xfffffffffULL, |
| 360 | TXX9_IRQ_BASE + 17, |
| 361 | 50000000); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | } |
| 363 | |
Atsushi Nemoto | a0574e0 | 2007-03-01 00:40:21 +0900 | [diff] [blame] | 364 | static int __init toshiba_rbtx4927_rtc_init(void) |
| 365 | { |
Atsushi Nemoto | 4614c32 | 2007-05-01 01:49:20 +0900 | [diff] [blame] | 366 | static struct resource __initdata res = { |
Atsushi Nemoto | a0574e0 | 2007-03-01 00:40:21 +0900 | [diff] [blame] | 367 | .start = 0x1c010000, |
| 368 | .end = 0x1c010000 + 0x800 - 1, |
| 369 | .flags = IORESOURCE_MEM, |
| 370 | }; |
| 371 | struct platform_device *dev = |
Atsushi Nemoto | a95e23a | 2007-10-16 01:28:18 -0700 | [diff] [blame] | 372 | platform_device_register_simple("rtc-ds1742", -1, &res, 1); |
Atsushi Nemoto | a0574e0 | 2007-03-01 00:40:21 +0900 | [diff] [blame] | 373 | return IS_ERR(dev) ? PTR_ERR(dev) : 0; |
| 374 | } |
| 375 | device_initcall(toshiba_rbtx4927_rtc_init); |
Atsushi Nemoto | 57e386c | 2007-05-01 00:27:58 +0900 | [diff] [blame] | 376 | |
| 377 | static int __init rbtx4927_ne_init(void) |
| 378 | { |
| 379 | static struct resource __initdata res[] = { |
| 380 | { |
| 381 | .start = RBTX4927_RTL_8019_BASE, |
| 382 | .end = RBTX4927_RTL_8019_BASE + 0x20 - 1, |
| 383 | .flags = IORESOURCE_IO, |
| 384 | }, { |
| 385 | .start = RBTX4927_RTL_8019_IRQ, |
| 386 | .flags = IORESOURCE_IRQ, |
| 387 | } |
| 388 | }; |
| 389 | struct platform_device *dev = |
| 390 | platform_device_register_simple("ne", -1, |
| 391 | res, ARRAY_SIZE(res)); |
| 392 | return IS_ERR(dev) ? PTR_ERR(dev) : 0; |
| 393 | } |
| 394 | device_initcall(rbtx4927_ne_init); |
Atsushi Nemoto | 2064ba2 | 2007-11-24 01:20:27 +0900 | [diff] [blame] | 395 | |
| 396 | /* Watchdog support */ |
| 397 | |
| 398 | static int __init txx9_wdt_init(unsigned long base) |
| 399 | { |
| 400 | struct resource res = { |
| 401 | .start = base, |
| 402 | .end = base + 0x100 - 1, |
| 403 | .flags = IORESOURCE_MEM, |
| 404 | }; |
| 405 | struct platform_device *dev = |
| 406 | platform_device_register_simple("txx9wdt", -1, &res, 1); |
| 407 | return IS_ERR(dev) ? PTR_ERR(dev) : 0; |
| 408 | } |
| 409 | |
| 410 | static int __init rbtx4927_wdt_init(void) |
| 411 | { |
| 412 | return txx9_wdt_init(TX4927_TMR_REG(2) & 0xfffffffffULL); |
| 413 | } |
| 414 | device_initcall(rbtx4927_wdt_init); |
| 415 | |
| 416 | /* Minimum CLK support */ |
| 417 | |
| 418 | struct clk *clk_get(struct device *dev, const char *id) |
| 419 | { |
| 420 | if (!strcmp(id, "imbus_clk")) |
| 421 | return (struct clk *)50000000; |
| 422 | return ERR_PTR(-ENOENT); |
| 423 | } |
| 424 | EXPORT_SYMBOL(clk_get); |
| 425 | |
| 426 | int clk_enable(struct clk *clk) |
| 427 | { |
| 428 | return 0; |
| 429 | } |
| 430 | EXPORT_SYMBOL(clk_enable); |
| 431 | |
| 432 | void clk_disable(struct clk *clk) |
| 433 | { |
| 434 | } |
| 435 | EXPORT_SYMBOL(clk_disable); |
| 436 | |
| 437 | unsigned long clk_get_rate(struct clk *clk) |
| 438 | { |
| 439 | return (unsigned long)clk; |
| 440 | } |
| 441 | EXPORT_SYMBOL(clk_get_rate); |
| 442 | |
| 443 | void clk_put(struct clk *clk) |
| 444 | { |
| 445 | } |
| 446 | EXPORT_SYMBOL(clk_put); |