18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Alchemy DB/PB1xxx board support.
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#include <asm/prom.h>
78c2ecf20Sopenharmony_ci#include <asm/mach-au1x00/au1000.h>
88c2ecf20Sopenharmony_ci#include <asm/mach-db1x00/bcsr.h>
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciint __init db1000_board_setup(void);
118c2ecf20Sopenharmony_ciint __init db1000_dev_setup(void);
128c2ecf20Sopenharmony_ciint __init db1500_pci_setup(void);
138c2ecf20Sopenharmony_ciint __init db1200_board_setup(void);
148c2ecf20Sopenharmony_ciint __init db1200_dev_setup(void);
158c2ecf20Sopenharmony_ciint __init db1300_board_setup(void);
168c2ecf20Sopenharmony_ciint __init db1300_dev_setup(void);
178c2ecf20Sopenharmony_ciint __init db1550_board_setup(void);
188c2ecf20Sopenharmony_ciint __init db1550_dev_setup(void);
198c2ecf20Sopenharmony_ciint __init db1550_pci_setup(int);
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_cistatic const char *board_type_str(void)
228c2ecf20Sopenharmony_ci{
238c2ecf20Sopenharmony_ci	switch (BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI))) {
248c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_DB1000:
258c2ecf20Sopenharmony_ci		return "DB1000";
268c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_DB1500:
278c2ecf20Sopenharmony_ci		return "DB1500";
288c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_DB1100:
298c2ecf20Sopenharmony_ci		return "DB1100";
308c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_PB1500:
318c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_PB1500R2:
328c2ecf20Sopenharmony_ci		return "PB1500";
338c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_PB1100:
348c2ecf20Sopenharmony_ci		return "PB1100";
358c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_PB1200_DDR1:
368c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_PB1200_DDR2:
378c2ecf20Sopenharmony_ci		return "PB1200";
388c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_DB1200:
398c2ecf20Sopenharmony_ci		return "DB1200";
408c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_DB1300:
418c2ecf20Sopenharmony_ci		return "DB1300";
428c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_DB1550:
438c2ecf20Sopenharmony_ci		return "DB1550";
448c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_PB1550_SDR:
458c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_PB1550_DDR:
468c2ecf20Sopenharmony_ci		return "PB1550";
478c2ecf20Sopenharmony_ci	default:
488c2ecf20Sopenharmony_ci		return "(unknown)";
498c2ecf20Sopenharmony_ci	}
508c2ecf20Sopenharmony_ci}
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ciconst char *get_system_type(void)
538c2ecf20Sopenharmony_ci{
548c2ecf20Sopenharmony_ci	return board_type_str();
558c2ecf20Sopenharmony_ci}
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_civoid __init board_setup(void)
588c2ecf20Sopenharmony_ci{
598c2ecf20Sopenharmony_ci	int ret;
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci	switch (alchemy_get_cputype()) {
628c2ecf20Sopenharmony_ci	case ALCHEMY_CPU_AU1000:
638c2ecf20Sopenharmony_ci	case ALCHEMY_CPU_AU1500:
648c2ecf20Sopenharmony_ci	case ALCHEMY_CPU_AU1100:
658c2ecf20Sopenharmony_ci		ret = db1000_board_setup();
668c2ecf20Sopenharmony_ci		break;
678c2ecf20Sopenharmony_ci	case ALCHEMY_CPU_AU1550:
688c2ecf20Sopenharmony_ci		ret = db1550_board_setup();
698c2ecf20Sopenharmony_ci		break;
708c2ecf20Sopenharmony_ci	case ALCHEMY_CPU_AU1200:
718c2ecf20Sopenharmony_ci		ret = db1200_board_setup();
728c2ecf20Sopenharmony_ci		break;
738c2ecf20Sopenharmony_ci	case ALCHEMY_CPU_AU1300:
748c2ecf20Sopenharmony_ci		ret = db1300_board_setup();
758c2ecf20Sopenharmony_ci		break;
768c2ecf20Sopenharmony_ci	default:
778c2ecf20Sopenharmony_ci		pr_err("unsupported CPU on board\n");
788c2ecf20Sopenharmony_ci		ret = -ENODEV;
798c2ecf20Sopenharmony_ci	}
808c2ecf20Sopenharmony_ci	if (ret)
818c2ecf20Sopenharmony_ci		panic("cannot initialize board support");
828c2ecf20Sopenharmony_ci}
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_cistatic int __init db1xxx_arch_init(void)
858c2ecf20Sopenharmony_ci{
868c2ecf20Sopenharmony_ci	int id = BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI));
878c2ecf20Sopenharmony_ci	if (id == BCSR_WHOAMI_DB1550)
888c2ecf20Sopenharmony_ci		return db1550_pci_setup(0);
898c2ecf20Sopenharmony_ci	else if ((id == BCSR_WHOAMI_PB1550_SDR) ||
908c2ecf20Sopenharmony_ci		 (id == BCSR_WHOAMI_PB1550_DDR))
918c2ecf20Sopenharmony_ci		return db1550_pci_setup(1);
928c2ecf20Sopenharmony_ci	else if ((id == BCSR_WHOAMI_DB1500) || (id == BCSR_WHOAMI_PB1500) ||
938c2ecf20Sopenharmony_ci		 (id == BCSR_WHOAMI_PB1500R2))
948c2ecf20Sopenharmony_ci		return db1500_pci_setup();
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci	return 0;
978c2ecf20Sopenharmony_ci}
988c2ecf20Sopenharmony_ciarch_initcall(db1xxx_arch_init);
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_cistatic int __init db1xxx_dev_init(void)
1018c2ecf20Sopenharmony_ci{
1028c2ecf20Sopenharmony_ci	mips_set_machine_name(board_type_str());
1038c2ecf20Sopenharmony_ci	switch (BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI))) {
1048c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_DB1000:
1058c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_DB1500:
1068c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_DB1100:
1078c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_PB1500:
1088c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_PB1500R2:
1098c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_PB1100:
1108c2ecf20Sopenharmony_ci		return db1000_dev_setup();
1118c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_PB1200_DDR1:
1128c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_PB1200_DDR2:
1138c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_DB1200:
1148c2ecf20Sopenharmony_ci		return db1200_dev_setup();
1158c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_DB1300:
1168c2ecf20Sopenharmony_ci		return db1300_dev_setup();
1178c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_DB1550:
1188c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_PB1550_SDR:
1198c2ecf20Sopenharmony_ci	case BCSR_WHOAMI_PB1550_DDR:
1208c2ecf20Sopenharmony_ci		return db1550_dev_setup();
1218c2ecf20Sopenharmony_ci	}
1228c2ecf20Sopenharmony_ci	return 0;
1238c2ecf20Sopenharmony_ci}
1248c2ecf20Sopenharmony_cidevice_initcall(db1xxx_dev_init);
125