xref: /openbmc/u-boot/board/mscc/luton/luton.c (revision 90571a4a)
1 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2 /*
3  * Copyright (c) 2018 Microsemi Corporation
4  */
5 
6 #include <common.h>
7 #include <asm/io.h>
8 #include <led.h>
9 
10 DECLARE_GLOBAL_DATA_PTR;
11 
12 enum {
13 	BOARD_TYPE_PCB090 = 0xAABBCD00,
14 	BOARD_TYPE_PCB091,
15 };
16 
17 void board_debug_uart_init(void)
18 {
19 	/* too early for the pinctrl driver, so configure the UART pins here */
20 	mscc_gpio_set_alternate(30, 1);
21 	mscc_gpio_set_alternate(31, 1);
22 }
23 
24 int board_early_init_r(void)
25 {
26 	/* Prepare SPI controller to be used in master mode */
27 	writel(0, BASE_CFG + ICPU_SW_MODE);
28 
29 	/* Address of boot parameters */
30 	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE;
31 
32 	/* LED setup */
33 	if (IS_ENABLED(CONFIG_LED))
34 		led_default_state();
35 
36 	return 0;
37 }
38 
39 static void do_board_detect(void)
40 {
41 	u32 chipid = (readl(BASE_DEVCPU_GCB + CHIP_ID) >> 12) & 0xFFFF;
42 
43 	if (chipid == 0x7428 || chipid == 0x7424)
44 		gd->board_type = BOARD_TYPE_PCB091;    // Lu10
45 	else
46 		gd->board_type = BOARD_TYPE_PCB090;    // Lu26
47 }
48 
49 #if defined(CONFIG_MULTI_DTB_FIT)
50 int board_fit_config_name_match(const char *name)
51 {
52 	if (gd->board_type == BOARD_TYPE_PCB090 &&
53 	    strcmp(name, "luton_pcb090") == 0)
54 		return 0;
55 
56 	if (gd->board_type == BOARD_TYPE_PCB091 &&
57 	    strcmp(name, "luton_pcb091") == 0)
58 		return 0;
59 
60 	return -1;
61 }
62 #endif
63 
64 #if defined(CONFIG_DTB_RESELECT)
65 int embedded_dtb_select(void)
66 {
67 	do_board_detect();
68 	fdtdec_setup();
69 
70 	return 0;
71 }
72 #endif
73