Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2000,2001,2002,2003,2004 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 | da51f9e | 2007-09-21 09:01:15 +0100 | [diff] [blame] | 18 | #include <linux/init.h> |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 19 | #include <linux/kernel.h> |
Ralf Baechle | 3118513 | 2007-07-29 00:00:34 +0100 | [diff] [blame] | 20 | #include <linux/module.h> |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 21 | #include <linux/reboot.h> |
| 22 | #include <linux/string.h> |
| 23 | |
| 24 | #include <asm/bootinfo.h> |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 25 | #include <asm/cpu.h> |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 26 | #include <asm/mipsregs.h> |
| 27 | #include <asm/io.h> |
| 28 | #include <asm/sibyte/sb1250.h> |
| 29 | |
| 30 | #include <asm/sibyte/bcm1480_regs.h> |
| 31 | #include <asm/sibyte/bcm1480_scd.h> |
| 32 | #include <asm/sibyte/sb1250_scd.h> |
| 33 | |
| 34 | unsigned int sb1_pass; |
| 35 | unsigned int soc_pass; |
| 36 | unsigned int soc_type; |
Maciej W. Rozycki | b45d527 | 2007-07-17 04:03:50 -0700 | [diff] [blame] | 37 | EXPORT_SYMBOL(soc_type); |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 38 | unsigned int periph_rev; |
| 39 | unsigned int zbbus_mhz; |
Ralf Baechle | 339c3a6 | 2007-09-21 08:59:07 +0100 | [diff] [blame] | 40 | EXPORT_SYMBOL(zbbus_mhz); |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 41 | |
| 42 | static unsigned int part_type; |
| 43 | |
| 44 | static char *soc_str; |
| 45 | static char *pass_str; |
| 46 | |
Ralf Baechle | 7c4b477 | 2007-10-11 23:46:05 +0100 | [diff] [blame] | 47 | static int __init setup_bcm1x80_bcm1x55(void) |
| 48 | { |
| 49 | int ret = 0; |
| 50 | |
| 51 | switch (soc_pass) { |
| 52 | case K_SYS_REVISION_BCM1480_S0: |
| 53 | periph_rev = 1; |
| 54 | pass_str = "S0 (pass1)"; |
| 55 | break; |
| 56 | case K_SYS_REVISION_BCM1480_A1: |
| 57 | periph_rev = 1; |
| 58 | pass_str = "A1 (pass1)"; |
| 59 | break; |
| 60 | case K_SYS_REVISION_BCM1480_A2: |
| 61 | periph_rev = 1; |
| 62 | pass_str = "A2 (pass1)"; |
| 63 | break; |
| 64 | case K_SYS_REVISION_BCM1480_A3: |
| 65 | periph_rev = 1; |
| 66 | pass_str = "A3 (pass1)"; |
| 67 | break; |
| 68 | case K_SYS_REVISION_BCM1480_B0: |
| 69 | periph_rev = 1; |
| 70 | pass_str = "B0 (pass2)"; |
| 71 | break; |
| 72 | default: |
| 73 | printk("Unknown %s rev %x\n", soc_str, soc_pass); |
| 74 | periph_rev = 1; |
| 75 | pass_str = "Unknown Revision"; |
| 76 | break; |
| 77 | } |
| 78 | |
| 79 | return ret; |
| 80 | } |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 81 | |
| 82 | /* Setup code likely to be common to all SiByte platforms */ |
| 83 | |
Ralf Baechle | 7c4b477 | 2007-10-11 23:46:05 +0100 | [diff] [blame] | 84 | static int __init sys_rev_decode(void) |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 85 | { |
| 86 | int ret = 0; |
| 87 | |
| 88 | switch (soc_type) { |
Ralf Baechle | 7c4b477 | 2007-10-11 23:46:05 +0100 | [diff] [blame] | 89 | case K_SYS_SOC_TYPE_BCM1x80: |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 90 | if (part_type == K_SYS_PART_BCM1480) |
| 91 | soc_str = "BCM1480"; |
| 92 | else if (part_type == K_SYS_PART_BCM1280) |
| 93 | soc_str = "BCM1280"; |
| 94 | else |
| 95 | soc_str = "BCM1x80"; |
| 96 | ret = setup_bcm1x80_bcm1x55(); |
| 97 | break; |
| 98 | |
Ralf Baechle | 7c4b477 | 2007-10-11 23:46:05 +0100 | [diff] [blame] | 99 | case K_SYS_SOC_TYPE_BCM1x55: |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 100 | if (part_type == K_SYS_PART_BCM1455) |
| 101 | soc_str = "BCM1455"; |
| 102 | else if (part_type == K_SYS_PART_BCM1255) |
| 103 | soc_str = "BCM1255"; |
| 104 | else |
| 105 | soc_str = "BCM1x55"; |
| 106 | ret = setup_bcm1x80_bcm1x55(); |
| 107 | break; |
| 108 | |
Ralf Baechle | 7c4b477 | 2007-10-11 23:46:05 +0100 | [diff] [blame] | 109 | default: |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 110 | printk("Unknown part type %x\n", part_type); |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 111 | ret = 1; |
| 112 | break; |
| 113 | } |
Ralf Baechle | 7c4b477 | 2007-10-11 23:46:05 +0100 | [diff] [blame] | 114 | |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 115 | return ret; |
| 116 | } |
| 117 | |
Ralf Baechle | 7c4b477 | 2007-10-11 23:46:05 +0100 | [diff] [blame] | 118 | void __init bcm1480_setup(void) |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 119 | { |
| 120 | uint64_t sys_rev; |
| 121 | int plldiv; |
| 122 | |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 123 | sb1_pass = read_c0_prid() & PRID_REV_MASK; |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 124 | sys_rev = __raw_readq(IOADDR(A_SCD_SYSTEM_REVISION)); |
| 125 | soc_type = SYS_SOC_TYPE(sys_rev); |
| 126 | part_type = G_SYS_PART(sys_rev); |
| 127 | soc_pass = G_SYS_REVISION(sys_rev); |
| 128 | |
| 129 | if (sys_rev_decode()) { |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 130 | printk("Restart after failure to identify SiByte chip\n"); |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 131 | machine_restart(NULL); |
| 132 | } |
| 133 | |
| 134 | plldiv = G_BCM1480_SYS_PLL_DIV(__raw_readq(IOADDR(A_SCD_SYSTEM_CFG))); |
| 135 | zbbus_mhz = ((plldiv >> 1) * 50) + ((plldiv & 1) * 25); |
| 136 | |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 137 | printk("Broadcom SiByte %s %s @ %d MHz (SB-1A rev %d)\n", |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 138 | soc_str, pass_str, zbbus_mhz * 2, sb1_pass); |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 139 | printk("Board type: %s\n", get_system_type()); |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 140 | } |