blob: f2eefbe99916420065fea5be04724549f45d4ffb [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>
Ralf Baechle31185132007-07-29 00:00:34 +010019#include <linux/module.h>
Andrew Isaacsonf137e462005-10-19 23:56:38 -070020#include <linux/reboot.h>
21#include <linux/string.h>
22
23#include <asm/bootinfo.h>
24#include <asm/mipsregs.h>
25#include <asm/io.h>
26#include <asm/sibyte/sb1250.h>
27
28#include <asm/sibyte/bcm1480_regs.h>
29#include <asm/sibyte/bcm1480_scd.h>
30#include <asm/sibyte/sb1250_scd.h>
31
32unsigned int sb1_pass;
33unsigned int soc_pass;
34unsigned int soc_type;
Maciej W. Rozyckib45d5272007-07-17 04:03:50 -070035EXPORT_SYMBOL(soc_type);
Andrew Isaacsonf137e462005-10-19 23:56:38 -070036unsigned int periph_rev;
37unsigned int zbbus_mhz;
Ralf Baechle339c3a62007-09-21 08:59:07 +010038EXPORT_SYMBOL(zbbus_mhz);
Andrew Isaacsonf137e462005-10-19 23:56:38 -070039
40static unsigned int part_type;
41
42static char *soc_str;
43static char *pass_str;
44
45static inline int setup_bcm1x80_bcm1x55(void);
46
47/* Setup code likely to be common to all SiByte platforms */
48
49static inline int sys_rev_decode(void)
50{
51 int ret = 0;
52
53 switch (soc_type) {
54 case K_SYS_SOC_TYPE_BCM1x80:
55 if (part_type == K_SYS_PART_BCM1480)
56 soc_str = "BCM1480";
57 else if (part_type == K_SYS_PART_BCM1280)
58 soc_str = "BCM1280";
59 else
60 soc_str = "BCM1x80";
61 ret = setup_bcm1x80_bcm1x55();
62 break;
63
64 case K_SYS_SOC_TYPE_BCM1x55:
65 if (part_type == K_SYS_PART_BCM1455)
66 soc_str = "BCM1455";
67 else if (part_type == K_SYS_PART_BCM1255)
68 soc_str = "BCM1255";
69 else
70 soc_str = "BCM1x55";
71 ret = setup_bcm1x80_bcm1x55();
72 break;
73
74 default:
Ralf Baechle36a88532007-03-01 11:56:43 +000075 printk("Unknown part type %x\n", part_type);
Andrew Isaacsonf137e462005-10-19 23:56:38 -070076 ret = 1;
77 break;
78 }
79 return ret;
80}
81
82static inline int setup_bcm1x80_bcm1x55(void)
83{
84 int ret = 0;
85
86 switch (soc_pass) {
87 case K_SYS_REVISION_BCM1480_S0:
88 periph_rev = 1;
89 pass_str = "S0 (pass1)";
90 break;
91 case K_SYS_REVISION_BCM1480_A1:
92 periph_rev = 1;
93 pass_str = "A1 (pass1)";
94 break;
95 case K_SYS_REVISION_BCM1480_A2:
96 periph_rev = 1;
97 pass_str = "A2 (pass1)";
98 break;
99 case K_SYS_REVISION_BCM1480_A3:
100 periph_rev = 1;
101 pass_str = "A3 (pass1)";
102 break;
103 case K_SYS_REVISION_BCM1480_B0:
104 periph_rev = 1;
105 pass_str = "B0 (pass2)";
106 break;
107 default:
Ralf Baechle36a88532007-03-01 11:56:43 +0000108 printk("Unknown %s rev %x\n", soc_str, soc_pass);
Andrew Isaacsonf137e462005-10-19 23:56:38 -0700109 periph_rev = 1;
110 pass_str = "Unknown Revision";
111 break;
112 }
113 return ret;
114}
115
116void bcm1480_setup(void)
117{
118 uint64_t sys_rev;
119 int plldiv;
120
121 sb1_pass = read_c0_prid() & 0xff;
122 sys_rev = __raw_readq(IOADDR(A_SCD_SYSTEM_REVISION));
123 soc_type = SYS_SOC_TYPE(sys_rev);
124 part_type = G_SYS_PART(sys_rev);
125 soc_pass = G_SYS_REVISION(sys_rev);
126
127 if (sys_rev_decode()) {
Ralf Baechle36a88532007-03-01 11:56:43 +0000128 printk("Restart after failure to identify SiByte chip\n");
Andrew Isaacsonf137e462005-10-19 23:56:38 -0700129 machine_restart(NULL);
130 }
131
132 plldiv = G_BCM1480_SYS_PLL_DIV(__raw_readq(IOADDR(A_SCD_SYSTEM_CFG)));
133 zbbus_mhz = ((plldiv >> 1) * 50) + ((plldiv & 1) * 25);
134
Ralf Baechle36a88532007-03-01 11:56:43 +0000135 printk("Broadcom SiByte %s %s @ %d MHz (SB-1A rev %d)\n",
Andrew Isaacsonf137e462005-10-19 23:56:38 -0700136 soc_str, pass_str, zbbus_mhz * 2, sb1_pass);
Ralf Baechle36a88532007-03-01 11:56:43 +0000137 printk("Board type: %s\n", get_system_type());
Andrew Isaacsonf137e462005-10-19 23:56:38 -0700138}