[MIPS] BCM1480: include <linux/init.h>.
[linux-2.6/btrfs-unstable.git] / arch / mips / sibyte / bcm1480 / setup.c
blob7e1aa348b8e078d41302a86979789f654eaf33f3
1 /*
2 * Copyright (C) 2000,2001,2002,2003,2004 Broadcom Corporation
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.
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.
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.
18 #include <linux/init.h>
19 #include <linux/kernel.h>
20 #include <linux/module.h>
21 #include <linux/reboot.h>
22 #include <linux/string.h>
24 #include <asm/bootinfo.h>
25 #include <asm/mipsregs.h>
26 #include <asm/io.h>
27 #include <asm/sibyte/sb1250.h>
29 #include <asm/sibyte/bcm1480_regs.h>
30 #include <asm/sibyte/bcm1480_scd.h>
31 #include <asm/sibyte/sb1250_scd.h>
33 unsigned int sb1_pass;
34 unsigned int soc_pass;
35 unsigned int soc_type;
36 EXPORT_SYMBOL(soc_type);
37 unsigned int periph_rev;
38 unsigned int zbbus_mhz;
39 EXPORT_SYMBOL(zbbus_mhz);
41 static unsigned int part_type;
43 static char *soc_str;
44 static char *pass_str;
46 static inline int setup_bcm1x80_bcm1x55(void);
48 /* Setup code likely to be common to all SiByte platforms */
50 static inline int sys_rev_decode(void)
52 int ret = 0;
54 switch (soc_type) {
55 case K_SYS_SOC_TYPE_BCM1x80:
56 if (part_type == K_SYS_PART_BCM1480)
57 soc_str = "BCM1480";
58 else if (part_type == K_SYS_PART_BCM1280)
59 soc_str = "BCM1280";
60 else
61 soc_str = "BCM1x80";
62 ret = setup_bcm1x80_bcm1x55();
63 break;
65 case K_SYS_SOC_TYPE_BCM1x55:
66 if (part_type == K_SYS_PART_BCM1455)
67 soc_str = "BCM1455";
68 else if (part_type == K_SYS_PART_BCM1255)
69 soc_str = "BCM1255";
70 else
71 soc_str = "BCM1x55";
72 ret = setup_bcm1x80_bcm1x55();
73 break;
75 default:
76 printk("Unknown part type %x\n", part_type);
77 ret = 1;
78 break;
80 return ret;
83 static inline int setup_bcm1x80_bcm1x55(void)
85 int ret = 0;
87 switch (soc_pass) {
88 case K_SYS_REVISION_BCM1480_S0:
89 periph_rev = 1;
90 pass_str = "S0 (pass1)";
91 break;
92 case K_SYS_REVISION_BCM1480_A1:
93 periph_rev = 1;
94 pass_str = "A1 (pass1)";
95 break;
96 case K_SYS_REVISION_BCM1480_A2:
97 periph_rev = 1;
98 pass_str = "A2 (pass1)";
99 break;
100 case K_SYS_REVISION_BCM1480_A3:
101 periph_rev = 1;
102 pass_str = "A3 (pass1)";
103 break;
104 case K_SYS_REVISION_BCM1480_B0:
105 periph_rev = 1;
106 pass_str = "B0 (pass2)";
107 break;
108 default:
109 printk("Unknown %s rev %x\n", soc_str, soc_pass);
110 periph_rev = 1;
111 pass_str = "Unknown Revision";
112 break;
114 return ret;
117 void bcm1480_setup(void)
119 uint64_t sys_rev;
120 int plldiv;
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);
128 if (sys_rev_decode()) {
129 printk("Restart after failure to identify SiByte chip\n");
130 machine_restart(NULL);
133 plldiv = G_BCM1480_SYS_PLL_DIV(__raw_readq(IOADDR(A_SCD_SYSTEM_CFG)));
134 zbbus_mhz = ((plldiv >> 1) * 50) + ((plldiv & 1) * 25);
136 printk("Broadcom SiByte %s %s @ %d MHz (SB-1A rev %d)\n",
137 soc_str, pass_str, zbbus_mhz * 2, sb1_pass);
138 printk("Board type: %s\n", get_system_type());