blob: ade041e11832fe4424952941fa2924e260844b95 [file] [log] [blame]
Horatiu Vultura834cb82019-01-23 16:39:45 +01001// 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
10enum {
11 BOARD_TYPE_PCB106 = 0xAABBCD00,
12 BOARD_TYPE_PCB105,
13};
14
15int board_early_init_r(void)
16{
17 /* Prepare SPI controller to be used in master mode */
18 writel(0, BASE_CFG + ICPU_SW_MODE);
19
20 /* Address of boot parameters */
21 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE;
22
23 /* LED setup */
24 if (IS_ENABLED(CONFIG_LED))
25 led_default_state();
26
27 return 0;
28}
29
30static void do_board_detect(void)
31{
32 u16 gpio_in_reg;
33
34 /* Set MDIO and MDC */
35 mscc_gpio_set_alternate(9, 2);
36 mscc_gpio_set_alternate(10, 2);
37
38 /* Set GPIO page */
39 mscc_phy_wr(1, 16, 31, 0x10);
40 if (!mscc_phy_rd(1, 16, 15, &gpio_in_reg)) {
41 if (gpio_in_reg & 0x200)
42 gd->board_type = BOARD_TYPE_PCB106;
43 else
44 gd->board_type = BOARD_TYPE_PCB105;
Horatiu Vultura834cb82019-01-23 16:39:45 +010045 } else {
46 gd->board_type = BOARD_TYPE_PCB105;
47 }
Horatiu Vulturc6b2e712019-04-15 11:56:37 +020048 mscc_phy_wr(1, 16, 31, 0x0);
Horatiu Vultura834cb82019-01-23 16:39:45 +010049}
50
51#if defined(CONFIG_MULTI_DTB_FIT)
52int board_fit_config_name_match(const char *name)
53{
54 if (gd->board_type == BOARD_TYPE_PCB106 &&
55 strcmp(name, "serval_pcb106") == 0)
56 return 0;
57
58 if (gd->board_type == BOARD_TYPE_PCB105 &&
59 strcmp(name, "serval_pcb105") == 0)
60 return 0;
61
62 return -1;
63}
64#endif
65
66#if defined(CONFIG_DTB_RESELECT)
67int embedded_dtb_select(void)
68{
69 do_board_detect();
70 fdtdec_setup();
71
72 return 0;
73}
74#endif