1 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
3 * Copyright (c) 2018 Microsemi Corporation
12 BOARD_TYPE_PCB110 = 0xAABBCE00,
17 int board_early_init_r(void)
19 /* Prepare SPI controller to be used in master mode */
20 writel(0, BASE_CFG + ICPU_SW_MODE);
21 clrsetbits_le32(BASE_CFG + ICPU_GENERAL_CTRL,
22 ICPU_GENERAL_CTRL_IF_SI_OWNER_M,
23 ICPU_GENERAL_CTRL_IF_SI_OWNER(2));
25 /* Address of boot parameters */
26 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE;
29 if (IS_ENABLED(CONFIG_LED))
35 static void vcoreiii_gpio_set_alternate(int gpio, int mode)
39 void __iomem *reg0, *reg1;
43 reg0 = BASE_DEVCPU_GCB + GPIO_GPIO_ALT(0);
44 reg1 = BASE_DEVCPU_GCB + GPIO_GPIO_ALT(1);
48 reg0 = BASE_DEVCPU_GCB + GPIO_GPIO_ALT1(0);
49 reg1 = BASE_DEVCPU_GCB + GPIO_GPIO_ALT1(1);
54 writel(val0 | mask, reg0);
55 writel(val1 & ~mask, reg1);
56 } else if (mode == 2) {
57 writel(val0 & ~mask, reg0);
58 writel(val1 | mask, reg1);
59 } else if (mode == 3) {
60 writel(val0 | mask, reg0);
61 writel(val1 | mask, reg1);
63 writel(val0 & ~mask, reg0);
64 writel(val1 & ~mask, reg1);
68 int board_phy_config(struct phy_device *phydev)
70 if (gd->board_type == BOARD_TYPE_PCB110 ||
71 gd->board_type == BOARD_TYPE_PCB112) {
72 phy_write(phydev, 0, 31, 0x10);
73 phy_write(phydev, 0, 18, 0x80F0);
74 while (phy_read(phydev, 0, 18) & 0x8000)
76 phy_write(phydev, 0, 31, 0);
78 if (gd->board_type == BOARD_TYPE_PCB111) {
79 phy_write(phydev, 0, 31, 0x10);
80 phy_write(phydev, 0, 18, 0x80A0);
81 while (phy_read(phydev, 0, 18) & 0x8000)
83 phy_write(phydev, 0, 14, 0x800);
84 phy_write(phydev, 0, 31, 0);
90 void board_debug_uart_init(void)
92 /* too early for the pinctrl driver, so configure the UART pins here */
93 vcoreiii_gpio_set_alternate(10, 1);
94 vcoreiii_gpio_set_alternate(11, 1);
97 static void do_board_detect(void)
102 /* MIIM 1 + 2 MDC/MDIO */
103 for (i = 56; i < 60; i++)
104 vcoreiii_gpio_set_alternate(i, 1);
106 /* small delay for settling the pins */
109 if (mscc_phy_rd(0, 0x10, 0x3, &pval) == 0 &&
110 ((pval >> 4) & 0x3F) == 0x3c) {
111 gd->board_type = BOARD_TYPE_PCB112; /* Serval2-NID */
112 } else if (mscc_phy_rd(1, 0x0, 0x3, &pval) == 0 &&
113 ((pval >> 4) & 0x3F) == 0x3c) {
114 gd->board_type = BOARD_TYPE_PCB110; /* Jr2-24 */
117 gd->board_type = BOARD_TYPE_PCB111; /* Jr2-48 */
121 #if defined(CONFIG_MULTI_DTB_FIT)
122 int board_fit_config_name_match(const char *name)
124 if (gd->board_type == BOARD_TYPE_PCB110 &&
125 strcmp(name, "jr2_pcb110") == 0)
128 if (gd->board_type == BOARD_TYPE_PCB111 &&
129 strcmp(name, "jr2_pcb111") == 0)
132 if (gd->board_type == BOARD_TYPE_PCB112 &&
133 strcmp(name, "serval2_pcb112") == 0)
140 #if defined(CONFIG_DTB_RESELECT)
141 int embedded_dtb_select(void)