Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2000, 2001, 2002, 2003 Broadcom Corporation |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; either version 2 |
| 7 | * of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 | */ |
Ralf Baechle | 5ac71fd | 2006-01-29 20:56:43 +0000 | [diff] [blame] | 18 | #include <linux/init.h> |
Ralf Baechle | bb9b813 | 2007-03-09 15:59:56 +0000 | [diff] [blame^] | 19 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <linux/kernel.h> |
| 21 | #include <linux/reboot.h> |
| 22 | #include <linux/string.h> |
| 23 | |
| 24 | #include <asm/bootinfo.h> |
| 25 | #include <asm/mipsregs.h> |
| 26 | #include <asm/io.h> |
| 27 | #include <asm/sibyte/sb1250.h> |
| 28 | #include <asm/sibyte/sb1250_regs.h> |
| 29 | #include <asm/sibyte/sb1250_scd.h> |
| 30 | |
| 31 | unsigned int sb1_pass; |
| 32 | unsigned int soc_pass; |
| 33 | unsigned int soc_type; |
| 34 | unsigned int periph_rev; |
| 35 | unsigned int zbbus_mhz; |
Ralf Baechle | bb9b813 | 2007-03-09 15:59:56 +0000 | [diff] [blame^] | 36 | EXPORT_SYMBOL(zbbus_mhz); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
| 38 | static char *soc_str; |
| 39 | static char *pass_str; |
| 40 | static unsigned int war_pass; /* XXXKW don't overload PASS defines? */ |
| 41 | |
| 42 | static inline int setup_bcm1250(void); |
| 43 | static inline int setup_bcm112x(void); |
| 44 | |
| 45 | /* Setup code likely to be common to all SiByte platforms */ |
| 46 | |
Ralf Baechle | 5ac71fd | 2006-01-29 20:56:43 +0000 | [diff] [blame] | 47 | static int __init sys_rev_decode(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | { |
| 49 | int ret = 0; |
| 50 | |
| 51 | war_pass = soc_pass; |
| 52 | switch (soc_type) { |
| 53 | case K_SYS_SOC_TYPE_BCM1250: |
| 54 | case K_SYS_SOC_TYPE_BCM1250_ALT: |
| 55 | case K_SYS_SOC_TYPE_BCM1250_ALT2: |
| 56 | soc_str = "BCM1250"; |
| 57 | ret = setup_bcm1250(); |
| 58 | break; |
| 59 | case K_SYS_SOC_TYPE_BCM1120: |
| 60 | soc_str = "BCM1120"; |
| 61 | ret = setup_bcm112x(); |
| 62 | break; |
| 63 | case K_SYS_SOC_TYPE_BCM1125: |
| 64 | soc_str = "BCM1125"; |
| 65 | ret = setup_bcm112x(); |
| 66 | break; |
| 67 | case K_SYS_SOC_TYPE_BCM1125H: |
| 68 | soc_str = "BCM1125H"; |
| 69 | ret = setup_bcm112x(); |
| 70 | break; |
| 71 | default: |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 72 | printk("Unknown SOC type %x\n", soc_type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | ret = 1; |
| 74 | break; |
| 75 | } |
| 76 | return ret; |
| 77 | } |
| 78 | |
Ralf Baechle | 5ac71fd | 2006-01-29 20:56:43 +0000 | [diff] [blame] | 79 | static int __init setup_bcm1250(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | { |
| 81 | int ret = 0; |
| 82 | |
| 83 | switch (soc_pass) { |
| 84 | case K_SYS_REVISION_BCM1250_PASS1: |
| 85 | periph_rev = 1; |
| 86 | pass_str = "Pass 1"; |
| 87 | break; |
| 88 | case K_SYS_REVISION_BCM1250_A10: |
| 89 | periph_rev = 2; |
| 90 | pass_str = "A8/A10"; |
| 91 | /* XXXKW different war_pass? */ |
| 92 | war_pass = K_SYS_REVISION_BCM1250_PASS2; |
| 93 | break; |
| 94 | case K_SYS_REVISION_BCM1250_PASS2_2: |
| 95 | periph_rev = 2; |
| 96 | pass_str = "B1"; |
| 97 | break; |
| 98 | case K_SYS_REVISION_BCM1250_B2: |
| 99 | periph_rev = 2; |
| 100 | pass_str = "B2"; |
| 101 | war_pass = K_SYS_REVISION_BCM1250_PASS2_2; |
| 102 | break; |
| 103 | case K_SYS_REVISION_BCM1250_PASS3: |
| 104 | periph_rev = 3; |
| 105 | pass_str = "C0"; |
| 106 | break; |
| 107 | case K_SYS_REVISION_BCM1250_C1: |
| 108 | periph_rev = 3; |
| 109 | pass_str = "C1"; |
| 110 | break; |
| 111 | default: |
| 112 | if (soc_pass < K_SYS_REVISION_BCM1250_PASS2_2) { |
| 113 | periph_rev = 2; |
| 114 | pass_str = "A0-A6"; |
| 115 | war_pass = K_SYS_REVISION_BCM1250_PASS2; |
| 116 | } else { |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 117 | printk("Unknown BCM1250 rev %x\n", soc_pass); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | ret = 1; |
| 119 | } |
| 120 | break; |
| 121 | } |
| 122 | return ret; |
| 123 | } |
| 124 | |
Ralf Baechle | 5ac71fd | 2006-01-29 20:56:43 +0000 | [diff] [blame] | 125 | static int __init setup_bcm112x(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | { |
| 127 | int ret = 0; |
| 128 | |
| 129 | switch (soc_pass) { |
| 130 | case 0: |
| 131 | /* Early build didn't have revid set */ |
| 132 | periph_rev = 3; |
| 133 | pass_str = "A1"; |
| 134 | war_pass = K_SYS_REVISION_BCM112x_A1; |
| 135 | break; |
| 136 | case K_SYS_REVISION_BCM112x_A1: |
| 137 | periph_rev = 3; |
| 138 | pass_str = "A1"; |
| 139 | break; |
| 140 | case K_SYS_REVISION_BCM112x_A2: |
| 141 | periph_rev = 3; |
| 142 | pass_str = "A2"; |
| 143 | break; |
| 144 | default: |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 145 | printk("Unknown %s rev %x\n", soc_str, soc_pass); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | ret = 1; |
| 147 | } |
| 148 | return ret; |
| 149 | } |
| 150 | |
Ralf Baechle | 5ac71fd | 2006-01-29 20:56:43 +0000 | [diff] [blame] | 151 | void __init sb1250_setup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | { |
| 153 | uint64_t sys_rev; |
| 154 | int plldiv; |
| 155 | int bad_config = 0; |
| 156 | |
| 157 | sb1_pass = read_c0_prid() & 0xff; |
Maciej W. Rozycki | 65bda1a | 2005-02-22 21:51:30 +0000 | [diff] [blame] | 158 | sys_rev = __raw_readq(IOADDR(A_SCD_SYSTEM_REVISION)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | soc_type = SYS_SOC_TYPE(sys_rev); |
| 160 | soc_pass = G_SYS_REVISION(sys_rev); |
| 161 | |
| 162 | if (sys_rev_decode()) { |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 163 | printk("Restart after failure to identify SiByte chip\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | machine_restart(NULL); |
| 165 | } |
| 166 | |
Maciej W. Rozycki | 65bda1a | 2005-02-22 21:51:30 +0000 | [diff] [blame] | 167 | plldiv = G_SYS_PLL_DIV(__raw_readq(IOADDR(A_SCD_SYSTEM_CFG))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | zbbus_mhz = ((plldiv >> 1) * 50) + ((plldiv & 1) * 25); |
| 169 | |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 170 | printk("Broadcom SiByte %s %s @ %d MHz (SB1 rev %d)\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | soc_str, pass_str, zbbus_mhz * 2, sb1_pass); |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 172 | printk("Board type: %s\n", get_system_type()); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | |
Ralf Baechle | b6f7880 | 2006-01-29 21:01:42 +0000 | [diff] [blame] | 174 | switch (war_pass) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | case K_SYS_REVISION_BCM1250_PASS1: |
| 176 | #ifndef CONFIG_SB1_PASS_1_WORKAROUNDS |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 177 | printk("@@@@ This is a BCM1250 A0-A2 (Pass 1) board, " |
Ralf Baechle | b6f7880 | 2006-01-29 21:01:42 +0000 | [diff] [blame] | 178 | "and the kernel doesn't have the proper " |
| 179 | "workarounds compiled in. @@@@\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | bad_config = 1; |
| 181 | #endif |
| 182 | break; |
| 183 | case K_SYS_REVISION_BCM1250_PASS2: |
| 184 | /* Pass 2 - easiest as default for now - so many numbers */ |
Ralf Baechle | b6f7880 | 2006-01-29 21:01:42 +0000 | [diff] [blame] | 185 | #if !defined(CONFIG_SB1_PASS_2_WORKAROUNDS) || \ |
| 186 | !defined(CONFIG_SB1_PASS_2_1_WORKAROUNDS) |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 187 | printk("@@@@ This is a BCM1250 A3-A10 board, and the " |
Ralf Baechle | b6f7880 | 2006-01-29 21:01:42 +0000 | [diff] [blame] | 188 | "kernel doesn't have the proper workarounds " |
| 189 | "compiled in. @@@@\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | bad_config = 1; |
| 191 | #endif |
| 192 | #ifdef CONFIG_CPU_HAS_PREFETCH |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 193 | printk("@@@@ Prefetches may be enabled in this kernel, " |
Ralf Baechle | b6f7880 | 2006-01-29 21:01:42 +0000 | [diff] [blame] | 194 | "but are buggy on this board. @@@@\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | bad_config = 1; |
| 196 | #endif |
| 197 | break; |
| 198 | case K_SYS_REVISION_BCM1250_PASS2_2: |
| 199 | #ifndef CONFIG_SB1_PASS_2_WORKAROUNDS |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 200 | printk("@@@@ This is a BCM1250 B1/B2. board, and the " |
Ralf Baechle | b6f7880 | 2006-01-29 21:01:42 +0000 | [diff] [blame] | 201 | "kernel doesn't have the proper workarounds " |
| 202 | "compiled in. @@@@\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | bad_config = 1; |
| 204 | #endif |
Ralf Baechle | b6f7880 | 2006-01-29 21:01:42 +0000 | [diff] [blame] | 205 | #if defined(CONFIG_SB1_PASS_2_1_WORKAROUNDS) || \ |
| 206 | !defined(CONFIG_CPU_HAS_PREFETCH) |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 207 | printk("@@@@ This is a BCM1250 B1/B2, but the kernel is " |
Ralf Baechle | b6f7880 | 2006-01-29 21:01:42 +0000 | [diff] [blame] | 208 | "conservatively configured for an 'A' stepping. " |
| 209 | "@@@@\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | #endif |
| 211 | break; |
| 212 | default: |
| 213 | break; |
| 214 | } |
| 215 | if (bad_config) { |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 216 | printk("Invalid configuration for this chip.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | machine_restart(NULL); |
| 218 | } |
| 219 | } |