blob: 05ed92c92b696f20d6c1356086ef3f79d94026f6 [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 */
Ralf Baechleda51f9e2007-09-21 09:01:15 +010018#include <linux/init.h>
Andrew Isaacsonf137e462005-10-19 23:56:38 -070019#include <linux/kernel.h>
Ralf Baechle31185132007-07-29 00:00:34 +010020#include <linux/module.h>
Andrew Isaacsonf137e462005-10-19 23:56:38 -070021#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
29#include <asm/sibyte/bcm1480_regs.h>
30#include <asm/sibyte/bcm1480_scd.h>
31#include <asm/sibyte/sb1250_scd.h>
32
33unsigned int sb1_pass;
34unsigned int soc_pass;
35unsigned int soc_type;
Maciej W. Rozyckib45d5272007-07-17 04:03:50 -070036EXPORT_SYMBOL(soc_type);
Andrew Isaacsonf137e462005-10-19 23:56:38 -070037unsigned int periph_rev;
38unsigned int zbbus_mhz;
Ralf Baechle339c3a62007-09-21 08:59:07 +010039EXPORT_SYMBOL(zbbus_mhz);
Andrew Isaacsonf137e462005-10-19 23:56:38 -070040
41static unsigned int part_type;
42
43static char *soc_str;
44static char *pass_str;
45
Ralf Baechle7c4b4772007-10-11 23:46:05 +010046static int __init setup_bcm1x80_bcm1x55(void)
47{
48 int ret = 0;
49
50 switch (soc_pass) {
51 case K_SYS_REVISION_BCM1480_S0:
52 periph_rev = 1;
53 pass_str = "S0 (pass1)";
54 break;
55 case K_SYS_REVISION_BCM1480_A1:
56 periph_rev = 1;
57 pass_str = "A1 (pass1)";
58 break;
59 case K_SYS_REVISION_BCM1480_A2:
60 periph_rev = 1;
61 pass_str = "A2 (pass1)";
62 break;
63 case K_SYS_REVISION_BCM1480_A3:
64 periph_rev = 1;
65 pass_str = "A3 (pass1)";
66 break;
67 case K_SYS_REVISION_BCM1480_B0:
68 periph_rev = 1;
69 pass_str = "B0 (pass2)";
70 break;
71 default:
72 printk("Unknown %s rev %x\n", soc_str, soc_pass);
73 periph_rev = 1;
74 pass_str = "Unknown Revision";
75 break;
76 }
77
78 return ret;
79}
Andrew Isaacsonf137e462005-10-19 23:56:38 -070080
81/* Setup code likely to be common to all SiByte platforms */
82
Ralf Baechle7c4b4772007-10-11 23:46:05 +010083static int __init sys_rev_decode(void)
Andrew Isaacsonf137e462005-10-19 23:56:38 -070084{
85 int ret = 0;
86
87 switch (soc_type) {
Ralf Baechle7c4b4772007-10-11 23:46:05 +010088 case K_SYS_SOC_TYPE_BCM1x80:
Andrew Isaacsonf137e462005-10-19 23:56:38 -070089 if (part_type == K_SYS_PART_BCM1480)
90 soc_str = "BCM1480";
91 else if (part_type == K_SYS_PART_BCM1280)
92 soc_str = "BCM1280";
93 else
94 soc_str = "BCM1x80";
95 ret = setup_bcm1x80_bcm1x55();
96 break;
97
Ralf Baechle7c4b4772007-10-11 23:46:05 +010098 case K_SYS_SOC_TYPE_BCM1x55:
Andrew Isaacsonf137e462005-10-19 23:56:38 -070099 if (part_type == K_SYS_PART_BCM1455)
100 soc_str = "BCM1455";
101 else if (part_type == K_SYS_PART_BCM1255)
102 soc_str = "BCM1255";
103 else
104 soc_str = "BCM1x55";
105 ret = setup_bcm1x80_bcm1x55();
106 break;
107
Ralf Baechle7c4b4772007-10-11 23:46:05 +0100108 default:
Ralf Baechle36a88532007-03-01 11:56:43 +0000109 printk("Unknown part type %x\n", part_type);
Andrew Isaacsonf137e462005-10-19 23:56:38 -0700110 ret = 1;
111 break;
112 }
Ralf Baechle7c4b4772007-10-11 23:46:05 +0100113
Andrew Isaacsonf137e462005-10-19 23:56:38 -0700114 return ret;
115}
116
Ralf Baechle7c4b4772007-10-11 23:46:05 +0100117void __init bcm1480_setup(void)
Andrew Isaacsonf137e462005-10-19 23:56:38 -0700118{
119 uint64_t sys_rev;
120 int plldiv;
121
122 sb1_pass = read_c0_prid() & 0xff;
123 sys_rev = __raw_readq(IOADDR(A_SCD_SYSTEM_REVISION));
124 soc_type = SYS_SOC_TYPE(sys_rev);
125 part_type = G_SYS_PART(sys_rev);
126 soc_pass = G_SYS_REVISION(sys_rev);
127
128 if (sys_rev_decode()) {
Ralf Baechle36a88532007-03-01 11:56:43 +0000129 printk("Restart after failure to identify SiByte chip\n");
Andrew Isaacsonf137e462005-10-19 23:56:38 -0700130 machine_restart(NULL);
131 }
132
133 plldiv = G_BCM1480_SYS_PLL_DIV(__raw_readq(IOADDR(A_SCD_SYSTEM_CFG)));
134 zbbus_mhz = ((plldiv >> 1) * 50) + ((plldiv & 1) * 25);
135
Ralf Baechle36a88532007-03-01 11:56:43 +0000136 printk("Broadcom SiByte %s %s @ %d MHz (SB-1A rev %d)\n",
Andrew Isaacsonf137e462005-10-19 23:56:38 -0700137 soc_str, pass_str, zbbus_mhz * 2, sb1_pass);
Ralf Baechle36a88532007-03-01 11:56:43 +0000138 printk("Board type: %s\n", get_system_type());
Andrew Isaacsonf137e462005-10-19 23:56:38 -0700139}