blob: bdaac34ae70897dc796e343d8bfe0b4346879311 [file] [log] [blame]
Andrew Isaacsonf137e462005-10-19 23:56:38 -07001/*
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 */
Andrew Isaacsonf137e462005-10-19 23:56:38 -070018#include <linux/kernel.h>
19#include <linux/reboot.h>
20#include <linux/string.h>
21
22#include <asm/bootinfo.h>
23#include <asm/mipsregs.h>
24#include <asm/io.h>
25#include <asm/sibyte/sb1250.h>
26
27#include <asm/sibyte/bcm1480_regs.h>
28#include <asm/sibyte/bcm1480_scd.h>
29#include <asm/sibyte/sb1250_scd.h>
30
31unsigned int sb1_pass;
32unsigned int soc_pass;
33unsigned int soc_type;
34unsigned int periph_rev;
35unsigned int zbbus_mhz;
36
37static unsigned int part_type;
38
39static char *soc_str;
40static char *pass_str;
41
42static inline int setup_bcm1x80_bcm1x55(void);
43
44/* Setup code likely to be common to all SiByte platforms */
45
46static inline int sys_rev_decode(void)
47{
48 int ret = 0;
49
50 switch (soc_type) {
51 case K_SYS_SOC_TYPE_BCM1x80:
52 if (part_type == K_SYS_PART_BCM1480)
53 soc_str = "BCM1480";
54 else if (part_type == K_SYS_PART_BCM1280)
55 soc_str = "BCM1280";
56 else
57 soc_str = "BCM1x80";
58 ret = setup_bcm1x80_bcm1x55();
59 break;
60
61 case K_SYS_SOC_TYPE_BCM1x55:
62 if (part_type == K_SYS_PART_BCM1455)
63 soc_str = "BCM1455";
64 else if (part_type == K_SYS_PART_BCM1255)
65 soc_str = "BCM1255";
66 else
67 soc_str = "BCM1x55";
68 ret = setup_bcm1x80_bcm1x55();
69 break;
70
71 default:
Ralf Baechle36a88532007-03-01 11:56:43 +000072 printk("Unknown part type %x\n", part_type);
Andrew Isaacsonf137e462005-10-19 23:56:38 -070073 ret = 1;
74 break;
75 }
76 return ret;
77}
78
79static inline int setup_bcm1x80_bcm1x55(void)
80{
81 int ret = 0;
82
83 switch (soc_pass) {
84 case K_SYS_REVISION_BCM1480_S0:
85 periph_rev = 1;
86 pass_str = "S0 (pass1)";
87 break;
88 case K_SYS_REVISION_BCM1480_A1:
89 periph_rev = 1;
90 pass_str = "A1 (pass1)";
91 break;
92 case K_SYS_REVISION_BCM1480_A2:
93 periph_rev = 1;
94 pass_str = "A2 (pass1)";
95 break;
96 case K_SYS_REVISION_BCM1480_A3:
97 periph_rev = 1;
98 pass_str = "A3 (pass1)";
99 break;
100 case K_SYS_REVISION_BCM1480_B0:
101 periph_rev = 1;
102 pass_str = "B0 (pass2)";
103 break;
104 default:
Ralf Baechle36a88532007-03-01 11:56:43 +0000105 printk("Unknown %s rev %x\n", soc_str, soc_pass);
Andrew Isaacsonf137e462005-10-19 23:56:38 -0700106 periph_rev = 1;
107 pass_str = "Unknown Revision";
108 break;
109 }
110 return ret;
111}
112
113void bcm1480_setup(void)
114{
115 uint64_t sys_rev;
116 int plldiv;
117
118 sb1_pass = read_c0_prid() & 0xff;
119 sys_rev = __raw_readq(IOADDR(A_SCD_SYSTEM_REVISION));
120 soc_type = SYS_SOC_TYPE(sys_rev);
121 part_type = G_SYS_PART(sys_rev);
122 soc_pass = G_SYS_REVISION(sys_rev);
123
124 if (sys_rev_decode()) {
Ralf Baechle36a88532007-03-01 11:56:43 +0000125 printk("Restart after failure to identify SiByte chip\n");
Andrew Isaacsonf137e462005-10-19 23:56:38 -0700126 machine_restart(NULL);
127 }
128
129 plldiv = G_BCM1480_SYS_PLL_DIV(__raw_readq(IOADDR(A_SCD_SYSTEM_CFG)));
130 zbbus_mhz = ((plldiv >> 1) * 50) + ((plldiv & 1) * 25);
131
Ralf Baechle36a88532007-03-01 11:56:43 +0000132 printk("Broadcom SiByte %s %s @ %d MHz (SB-1A rev %d)\n",
Andrew Isaacsonf137e462005-10-19 23:56:38 -0700133 soc_str, pass_str, zbbus_mhz * 2, sb1_pass);
Ralf Baechle36a88532007-03-01 11:56:43 +0000134 printk("Board type: %s\n", get_system_type());
Andrew Isaacsonf137e462005-10-19 23:56:38 -0700135}