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