1 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
3 * Copyright (c) 2018 Microsemi Corporation
14 BOARD_TYPE_PCB110 = 0xAABBCE00,
19 int board_early_init_r(void)
21 /* Prepare SPI controller to be used in master mode */
22 writel(0, BASE_CFG + ICPU_SW_MODE);
23 clrsetbits_le32(BASE_CFG + ICPU_GENERAL_CTRL,
24 ICPU_GENERAL_CTRL_IF_SI_OWNER_M,
25 ICPU_GENERAL_CTRL_IF_SI_OWNER(2));
27 /* Address of boot parameters */
28 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE;
31 if (IS_ENABLED(CONFIG_LED))
37 static void vcoreiii_gpio_set_alternate(int gpio, int mode)
41 void __iomem *reg0, *reg1;
45 reg0 = BASE_DEVCPU_GCB + GPIO_GPIO_ALT(0);
46 reg1 = BASE_DEVCPU_GCB + GPIO_GPIO_ALT(1);
50 reg0 = BASE_DEVCPU_GCB + GPIO_GPIO_ALT1(0);
51 reg1 = BASE_DEVCPU_GCB + GPIO_GPIO_ALT1(1);
56 writel(val0 | mask, reg0);
57 writel(val1 & ~mask, reg1);
58 } else if (mode == 2) {
59 writel(val0 & ~mask, reg0);
60 writel(val1 | mask, reg1);
61 } else if (mode == 3) {
62 writel(val0 | mask, reg0);
63 writel(val1 | mask, reg1);
65 writel(val0 & ~mask, reg0);
66 writel(val1 & ~mask, reg1);
70 int board_phy_config(struct phy_device *phydev)
72 if (gd->board_type == BOARD_TYPE_PCB110 ||
73 gd->board_type == BOARD_TYPE_PCB112) {
74 phy_write(phydev, 0, 31, 0x10);
75 phy_write(phydev, 0, 18, 0x80F0);
76 while (phy_read(phydev, 0, 18) & 0x8000)
78 phy_write(phydev, 0, 31, 0);
80 if (gd->board_type == BOARD_TYPE_PCB111) {
81 phy_write(phydev, 0, 31, 0x10);
82 phy_write(phydev, 0, 18, 0x80A0);
83 while (phy_read(phydev, 0, 18) & 0x8000)
85 phy_write(phydev, 0, 14, 0x800);
86 phy_write(phydev, 0, 31, 0);
92 void board_debug_uart_init(void)
94 /* too early for the pinctrl driver, so configure the UART pins here */
95 vcoreiii_gpio_set_alternate(10, 1);
96 vcoreiii_gpio_set_alternate(11, 1);
99 static void do_board_detect(void)
104 /* MIIM 1 + 2 MDC/MDIO */
105 for (i = 56; i < 60; i++)
106 vcoreiii_gpio_set_alternate(i, 1);
108 /* small delay for settling the pins */
111 if (mscc_phy_rd(0, 0x10, 0x3, &pval) == 0 &&
112 ((pval >> 4) & 0x3F) == 0x3c) {
113 gd->board_type = BOARD_TYPE_PCB112; /* Serval2-NID */
114 } else if (mscc_phy_rd(1, 0x0, 0x3, &pval) == 0 &&
115 ((pval >> 4) & 0x3F) == 0x3c) {
116 gd->board_type = BOARD_TYPE_PCB110; /* Jr2-24 */
119 gd->board_type = BOARD_TYPE_PCB111; /* Jr2-48 */
123 #if defined(CONFIG_MULTI_DTB_FIT)
124 int board_fit_config_name_match(const char *name)
126 if (gd->board_type == BOARD_TYPE_PCB110 &&
127 strcmp(name, "jr2_pcb110") == 0)
130 if (gd->board_type == BOARD_TYPE_PCB111 &&
131 strcmp(name, "jr2_pcb111") == 0)
134 if (gd->board_type == BOARD_TYPE_PCB112 &&
135 strcmp(name, "serval2_pcb112") == 0)
142 #if defined(CONFIG_DTB_RESELECT)
143 int embedded_dtb_select(void)