]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - board/gateworks/venice/venice.c
1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2021 Gateworks Corporation
9 #include <linux/delay.h>
13 #include <asm/arch/clock.h>
14 #include <asm/arch/sys_proto.h>
16 #include <asm/unaligned.h>
20 DECLARE_GLOBAL_DATA_PTR
;
22 int board_phys_sdram_size(phys_size_t
*size
)
28 /* get size from dt which SPL updated per EEPROM config */
29 offset
= fdt_path_offset(gd
->fdt_blob
, "/memory");
33 val
= fdt_getprop(gd
->fdt_blob
, offset
, "reg", &len
);
34 if (len
< sizeof(*val
) * 2)
36 *size
= get_unaligned_be64(&val
[1]);
41 int board_fit_config_name_match(const char *name
)
49 dtb
= gsc_get_dtb_name(i
++, buf
, sizeof(buf
));
50 if (!strcmp(dtb
, name
)) {
52 printf("DTB : %s\n", name
);
60 #if (IS_ENABLED(CONFIG_FEC_MXC))
61 static int setup_fec(void)
63 struct iomuxc_gpr_base_regs
*gpr
=
64 (struct iomuxc_gpr_base_regs
*)IOMUXC_GPR_BASE_ADDR
;
66 /* Use 125M anatop REF_CLK1 for ENET1, not from external */
67 clrsetbits_le32(&gpr
->gpr
[1], 0x2000, 0);
72 int board_phy_config(struct phy_device
*phydev
)
76 switch (phydev
->phy_id
) {
77 case 0x2000a231: /* TI DP83867 GbE PHY */
79 /* LED configuration */
81 val
|= 0x5 << 4; /* LED1(Amber;Speed) : 1000BT link */
82 val
|= 0xb << 8; /* LED2(Green;Link/Act): blink for TX/RX act */
83 phy_write(phydev
, MDIO_DEVAD_NONE
, 24, val
);
87 if (phydev
->drv
->config
)
88 phydev
->drv
->config(phydev
);
92 #endif // IS_ENABLED(CONFIG_FEC_MXC)
98 if (IS_ENABLED(CONFIG_FEC_MXC
))
106 int board_late_init(void)
116 /* Set board serial/model */
117 if (!env_get("serial#"))
118 env_set_ulong("serial#", gsc_get_serial());
119 env_set("model", gsc_get_model());
121 /* Set fdt_file vars */
124 str
= gsc_get_dtb_name(i
, fdt
, sizeof(fdt
));
126 sprintf(env
, "fdt_file%d", i
+ 1);
137 sprintf(env
, "eth%daddr", i
);
139 sprintf(env
, "ethaddr");
142 ret
= gsc_getmac(i
, enetaddr
);
144 eth_env_set_enetaddr(env
, enetaddr
);
152 int board_mmc_get_env_dev(int devno
)
157 int ft_board_setup(void *blob
, struct bd_info
*bd
)
161 /* set board model dt prop */
162 fdt_setprop_string(blob
, 0, "board", gsc_get_model());
164 /* update temp thresholds */
165 off
= fdt_path_offset(blob
, "/thermal-zones/cpu-thermal/trips");
167 int minc
, maxc
, prop
;
169 get_cpu_temp_grade(&minc
, &maxc
);
170 fdt_for_each_subnode(prop
, blob
, off
) {
171 const char *type
= fdt_getprop(blob
, prop
, "type", NULL
);
173 if (type
&& (!strcmp("critical", type
)))
174 fdt_setprop_u32(blob
, prop
, "temperature", maxc
* 1000);
175 else if (type
&& (!strcmp("passive", type
)))
176 fdt_setprop_u32(blob
, prop
, "temperature", (maxc
- 10) * 1000);