xref: /linux/arch/mips/alchemy/devboards/db1xxx.c (revision 00a6d7b6762c27d441e9ac8faff36384bc0fc180)
1 /*
2  * Alchemy DB/PB1xxx board support.
3  */
4 
5 #include <asm/mach-au1x00/au1000.h>
6 #include <asm/mach-db1x00/bcsr.h>
7 
8 int __init db1000_board_setup(void);
9 int __init db1000_dev_setup(void);
10 int __init db1500_pci_setup(void);
11 int __init db1200_board_setup(void);
12 int __init db1200_dev_setup(void);
13 int __init db1300_board_setup(void);
14 int __init db1300_dev_setup(void);
15 int __init db1550_board_setup(void);
16 int __init db1550_dev_setup(void);
17 int __init db1550_pci_setup(int);
18 
19 static const char *board_type_str(void)
20 {
21 	switch (BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI))) {
22 	case BCSR_WHOAMI_DB1000:
23 		return "DB1000";
24 	case BCSR_WHOAMI_DB1500:
25 		return "DB1500";
26 	case BCSR_WHOAMI_DB1100:
27 		return "DB1100";
28 	case BCSR_WHOAMI_PB1500:
29 	case BCSR_WHOAMI_PB1500R2:
30 		return "PB1500";
31 	case BCSR_WHOAMI_PB1100:
32 		return "PB1100";
33 	case BCSR_WHOAMI_PB1200_DDR1:
34 	case BCSR_WHOAMI_PB1200_DDR2:
35 		return "PB1200";
36 	case BCSR_WHOAMI_DB1200:
37 		return "DB1200";
38 	case BCSR_WHOAMI_DB1300:
39 		return "DB1300";
40 	case BCSR_WHOAMI_DB1550:
41 		return "DB1550";
42 	case BCSR_WHOAMI_PB1550_SDR:
43 	case BCSR_WHOAMI_PB1550_DDR:
44 		return "PB1550";
45 	default:
46 		return "(unknown)";
47 	}
48 }
49 
50 const char *get_system_type(void)
51 {
52 	return board_type_str();
53 }
54 
55 void __init board_setup(void)
56 {
57 	int ret;
58 
59 	switch (alchemy_get_cputype()) {
60 	case ALCHEMY_CPU_AU1000:
61 	case ALCHEMY_CPU_AU1500:
62 	case ALCHEMY_CPU_AU1100:
63 		ret = db1000_board_setup();
64 		break;
65 	case ALCHEMY_CPU_AU1550:
66 		ret = db1550_board_setup();
67 		break;
68 	case ALCHEMY_CPU_AU1200:
69 		ret = db1200_board_setup();
70 		break;
71 	case ALCHEMY_CPU_AU1300:
72 		ret = db1300_board_setup();
73 		break;
74 	default:
75 		pr_err("unsupported CPU on board\n");
76 		ret = -ENODEV;
77 	}
78 	if (ret)
79 		panic("cannot initialize board support");
80 }
81 
82 static int __init db1xxx_arch_init(void)
83 {
84 	int id = BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI));
85 	if (id == BCSR_WHOAMI_DB1550)
86 		return db1550_pci_setup(0);
87 	else if ((id == BCSR_WHOAMI_PB1550_SDR) ||
88 		 (id == BCSR_WHOAMI_PB1550_DDR))
89 		return db1550_pci_setup(1);
90 	else if ((id == BCSR_WHOAMI_DB1500) || (id == BCSR_WHOAMI_PB1500) ||
91 		 (id == BCSR_WHOAMI_PB1500R2))
92 		return db1500_pci_setup();
93 
94 	return 0;
95 }
96 arch_initcall(db1xxx_arch_init);
97 
98 static int __init db1xxx_dev_init(void)
99 {
100 	switch (BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI))) {
101 	case BCSR_WHOAMI_DB1000:
102 	case BCSR_WHOAMI_DB1500:
103 	case BCSR_WHOAMI_DB1100:
104 	case BCSR_WHOAMI_PB1500:
105 	case BCSR_WHOAMI_PB1500R2:
106 	case BCSR_WHOAMI_PB1100:
107 		return db1000_dev_setup();
108 	case BCSR_WHOAMI_PB1200_DDR1:
109 	case BCSR_WHOAMI_PB1200_DDR2:
110 	case BCSR_WHOAMI_DB1200:
111 		return db1200_dev_setup();
112 	case BCSR_WHOAMI_DB1300:
113 		return db1300_dev_setup();
114 	case BCSR_WHOAMI_DB1550:
115 	case BCSR_WHOAMI_PB1550_SDR:
116 	case BCSR_WHOAMI_PB1550_DDR:
117 		return db1550_dev_setup();
118 	}
119 	return 0;
120 }
121 device_initcall(db1xxx_dev_init);
122