xref: /openbmc/linux/arch/mips/sibyte/bcm1480/setup.c (revision 8795a739)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (C) 2000,2001,2002,2003,2004 Broadcom Corporation
4  */
5 #include <linux/init.h>
6 #include <linux/kernel.h>
7 #include <linux/export.h>
8 #include <linux/reboot.h>
9 #include <linux/string.h>
10 
11 #include <asm/bootinfo.h>
12 #include <asm/cpu.h>
13 #include <asm/mipsregs.h>
14 #include <asm/io.h>
15 #include <asm/sibyte/sb1250.h>
16 
17 #include <asm/sibyte/bcm1480_regs.h>
18 #include <asm/sibyte/bcm1480_scd.h>
19 #include <asm/sibyte/sb1250_scd.h>
20 
21 unsigned int sb1_pass;
22 unsigned int soc_pass;
23 unsigned int soc_type;
24 EXPORT_SYMBOL(soc_type);
25 unsigned int periph_rev;
26 EXPORT_SYMBOL_GPL(periph_rev);
27 unsigned int zbbus_mhz;
28 EXPORT_SYMBOL(zbbus_mhz);
29 
30 static unsigned int part_type;
31 
32 static char *soc_str;
33 static char *pass_str;
34 
35 static int __init setup_bcm1x80_bcm1x55(void)
36 {
37 	int ret = 0;
38 
39 	switch (soc_pass) {
40 	case K_SYS_REVISION_BCM1480_S0:
41 		periph_rev = 1;
42 		pass_str = "S0 (pass1)";
43 		break;
44 	case K_SYS_REVISION_BCM1480_A1:
45 		periph_rev = 1;
46 		pass_str = "A1 (pass1)";
47 		break;
48 	case K_SYS_REVISION_BCM1480_A2:
49 		periph_rev = 1;
50 		pass_str = "A2 (pass1)";
51 		break;
52 	case K_SYS_REVISION_BCM1480_A3:
53 		periph_rev = 1;
54 		pass_str = "A3 (pass1)";
55 		break;
56 	case K_SYS_REVISION_BCM1480_B0:
57 		periph_rev = 1;
58 		pass_str = "B0 (pass2)";
59 		break;
60 	default:
61 		printk("Unknown %s rev %x\n", soc_str, soc_pass);
62 		periph_rev = 1;
63 		pass_str = "Unknown Revision";
64 		break;
65 	}
66 
67 	return ret;
68 }
69 
70 /* Setup code likely to be common to all SiByte platforms */
71 
72 static int __init sys_rev_decode(void)
73 {
74 	int ret = 0;
75 
76 	switch (soc_type) {
77 	case K_SYS_SOC_TYPE_BCM1x80:
78 		if (part_type == K_SYS_PART_BCM1480)
79 		    soc_str = "BCM1480";
80 		else if (part_type == K_SYS_PART_BCM1280)
81 		    soc_str = "BCM1280";
82 		else
83 		    soc_str = "BCM1x80";
84 		ret = setup_bcm1x80_bcm1x55();
85 		break;
86 
87 	case K_SYS_SOC_TYPE_BCM1x55:
88 		if (part_type == K_SYS_PART_BCM1455)
89 		    soc_str = "BCM1455";
90 		else if (part_type == K_SYS_PART_BCM1255)
91 		    soc_str = "BCM1255";
92 		else
93 		    soc_str = "BCM1x55";
94 		ret = setup_bcm1x80_bcm1x55();
95 		break;
96 
97 	default:
98 		printk("Unknown part type %x\n", part_type);
99 		ret = 1;
100 		break;
101 	}
102 
103 	return ret;
104 }
105 
106 void __init bcm1480_setup(void)
107 {
108 	uint64_t sys_rev;
109 	int plldiv;
110 
111 	sb1_pass = read_c0_prid() & PRID_REV_MASK;
112 	sys_rev = __raw_readq(IOADDR(A_SCD_SYSTEM_REVISION));
113 	soc_type = SYS_SOC_TYPE(sys_rev);
114 	part_type = G_SYS_PART(sys_rev);
115 	soc_pass = G_SYS_REVISION(sys_rev);
116 
117 	if (sys_rev_decode()) {
118 		printk("Restart after failure to identify SiByte chip\n");
119 		machine_restart(NULL);
120 	}
121 
122 	plldiv = G_BCM1480_SYS_PLL_DIV(__raw_readq(IOADDR(A_SCD_SYSTEM_CFG)));
123 	zbbus_mhz = ((plldiv >> 1) * 50) + ((plldiv & 1) * 25);
124 
125 	printk("Broadcom SiByte %s %s @ %d MHz (SB-1A rev %d)\n",
126 		    soc_str, pass_str, zbbus_mhz * 2, sb1_pass);
127 	printk("Board type: %s\n", get_system_type());
128 }
129