1 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
3 * Copyright (c) 2018 Microsemi Corporation
12 #include <linux/delay.h>
15 BOARD_TYPE_PCB110 = 0xAABBCE00,
20 int board_early_init_r(void)
22 /* Prepare SPI controller to be used in master mode */
23 writel(0, BASE_CFG + ICPU_SW_MODE);
24 clrsetbits_le32(BASE_CFG + ICPU_GENERAL_CTRL,
25 ICPU_GENERAL_CTRL_IF_SI_OWNER_M,
26 ICPU_GENERAL_CTRL_IF_SI_OWNER(2));
28 /* Address of boot parameters */
29 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE;
32 if (IS_ENABLED(CONFIG_LED))
38 static void vcoreiii_gpio_set_alternate(int gpio, int mode)
42 void __iomem *reg0, *reg1;
46 reg0 = BASE_DEVCPU_GCB + GPIO_GPIO_ALT(0);
47 reg1 = BASE_DEVCPU_GCB + GPIO_GPIO_ALT(1);
51 reg0 = BASE_DEVCPU_GCB + GPIO_GPIO_ALT1(0);
52 reg1 = BASE_DEVCPU_GCB + GPIO_GPIO_ALT1(1);
57 writel(val0 | mask, reg0);
58 writel(val1 & ~mask, reg1);
59 } else if (mode == 2) {
60 writel(val0 & ~mask, reg0);
61 writel(val1 | mask, reg1);
62 } else if (mode == 3) {
63 writel(val0 | mask, reg0);
64 writel(val1 | mask, reg1);
66 writel(val0 & ~mask, reg0);
67 writel(val1 & ~mask, reg1);
71 int board_phy_config(struct phy_device *phydev)
73 if (gd->board_type == BOARD_TYPE_PCB110 ||
74 gd->board_type == BOARD_TYPE_PCB112) {
75 phy_write(phydev, 0, 31, 0x10);
76 phy_write(phydev, 0, 18, 0x80F0);
77 while (phy_read(phydev, 0, 18) & 0x8000)
79 phy_write(phydev, 0, 31, 0);
81 if (gd->board_type == BOARD_TYPE_PCB111) {
82 phy_write(phydev, 0, 31, 0x10);
83 phy_write(phydev, 0, 18, 0x80A0);
84 while (phy_read(phydev, 0, 18) & 0x8000)
86 phy_write(phydev, 0, 14, 0x800);
87 phy_write(phydev, 0, 31, 0);
93 void board_debug_uart_init(void)
95 /* too early for the pinctrl driver, so configure the UART pins here */
96 vcoreiii_gpio_set_alternate(10, 1);
97 vcoreiii_gpio_set_alternate(11, 1);
100 static void do_board_detect(void)
105 /* MIIM 1 + 2 MDC/MDIO */
106 for (i = 56; i < 60; i++)
107 vcoreiii_gpio_set_alternate(i, 1);
109 /* small delay for settling the pins */
112 if (mscc_phy_rd(0, 0x10, 0x3, &pval) == 0 &&
113 ((pval >> 4) & 0x3F) == 0x3c) {
114 gd->board_type = BOARD_TYPE_PCB112; /* Serval2-NID */
115 } else if (mscc_phy_rd(1, 0x0, 0x3, &pval) == 0 &&
116 ((pval >> 4) & 0x3F) == 0x3c) {
117 gd->board_type = BOARD_TYPE_PCB110; /* Jr2-24 */
120 gd->board_type = BOARD_TYPE_PCB111; /* Jr2-48 */
124 #if defined(CONFIG_MULTI_DTB_FIT)
125 int board_fit_config_name_match(const char *name)
127 if (gd->board_type == BOARD_TYPE_PCB110 &&
128 strcmp(name, "jr2_pcb110") == 0)
131 if (gd->board_type == BOARD_TYPE_PCB111 &&
132 strcmp(name, "jr2_pcb111") == 0)
135 if (gd->board_type == BOARD_TYPE_PCB112 &&
136 strcmp(name, "serval2_pcb112") == 0)
143 #if defined(CONFIG_DTB_RESELECT)
144 int embedded_dtb_select(void)