#include <dm.h>
#include <env.h>
#include <env_internal.h>
+#include <fdt_support.h>
#include <g_dnl.h>
#include <generic-phy.h>
+#include <hang.h>
#include <i2c.h>
+#include <init.h>
#include <led.h>
+#include <log.h>
+#include <malloc.h>
#include <misc.h>
-#include <mtd.h>
#include <mtd_node.h>
+#include <net.h>
+#include <netdev.h>
#include <phy.h>
#include <remoteproc.h>
#include <reset.h>
#include <asm/arch/stm32.h>
#include <asm/arch/sys_proto.h>
#include <jffs2/load_kernel.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/iopoll.h>
#include <power/regulator.h>
#include <usb/dwc2_udc.h>
const char *fdt_compat;
int fdt_compat_len;
- if (IS_ENABLED(CONFIG_STM32MP1_OPTEE))
- mode = "trusted with OP-TEE";
- else if (IS_ENABLED(CONFIG_STM32MP1_TRUSTED))
+ if (IS_ENABLED(CONFIG_TFABOOT))
mode = "trusted";
else
mode = "basic";
printf(" (%s)", fdt_compat);
puts("\n");
- ret = uclass_get_device_by_driver(UCLASS_MISC,
- DM_GET_DRIVER(stm32mp_bsec),
- &dev);
-
- if (!ret)
- ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD),
- &otp, sizeof(otp));
- if (ret > 0 && otp) {
- printf("Board: MB%04x Var%d Rev.%c-%02d\n",
- otp >> 16,
- (otp >> 12) & 0xF,
- ((otp >> 8) & 0xF) - 1 + 'A',
- otp & 0xF);
+ /* display the STMicroelectronics board identification */
+ if (CONFIG_IS_ENABLED(CMD_STBOARD)) {
+ ret = uclass_get_device_by_driver(UCLASS_MISC,
+ DM_GET_DRIVER(stm32mp_bsec),
+ &dev);
+ if (!ret)
+ ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD),
+ &otp, sizeof(otp));
+ if (ret > 0 && otp)
+ printf("Board: MB%04x Var%d.%d Rev.%c-%02d\n",
+ otp >> 16,
+ (otp >> 12) & 0xF,
+ (otp >> 4) & 0xF,
+ ((otp >> 8) & 0xF) - 1 + 'A',
+ otp & 0xF);
}
return 0;
return dwc2_udc_B_session_valid(dwc2_udc_otg);
}
+
+#define STM32MP1_G_DNL_DFU_PRODUCT_NUM 0xdf11
+#define STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM 0x0afb
+
+int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
+{
+ if (!strcmp(name, "usb_dnl_dfu"))
+ put_unaligned(STM32MP1_G_DNL_DFU_PRODUCT_NUM, &dev->idProduct);
+ else if (!strcmp(name, "usb_dnl_fastboot"))
+ put_unaligned(STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM,
+ &dev->idProduct);
+ else
+ put_unaligned(CONFIG_USB_GADGET_PRODUCT_NUM, &dev->idProduct);
+
+ return 0;
+}
+
#endif /* CONFIG_USB_GADGET */
-#ifdef CONFIG_LED
static int get_led(struct udevice **dev, char *led_string)
{
char *led_name;
struct udevice *dev;
int ret;
+ if (!CONFIG_IS_ENABLED(LED))
+ return 0;
+
ret = get_led(&dev, "u-boot,boot-led");
if (ret)
return ret;
ret = led_set_state(dev, cmd);
return ret;
}
-#endif
static void __maybe_unused led_error_blink(u32 nb_blink)
{
-#ifdef CONFIG_LED
int ret;
struct udevice *led;
u32 i;
-#endif
if (!nb_blink)
return;
-#ifdef CONFIG_LED
- ret = get_led(&led, "u-boot,error-led");
- if (!ret) {
- /* make u-boot,error-led blinking */
- /* if U32_MAX and 125ms interval, for 17.02 years */
- for (i = 0; i < 2 * nb_blink; i++) {
- led_set_state(led, LEDST_TOGGLE);
- mdelay(125);
- WATCHDOG_RESET();
+ if (CONFIG_IS_ENABLED(LED)) {
+ ret = get_led(&led, "u-boot,error-led");
+ if (!ret) {
+ /* make u-boot,error-led blinking */
+ /* if U32_MAX and 125ms interval, for 17.02 years */
+ for (i = 0; i < 2 * nb_blink; i++) {
+ led_set_state(led, LEDST_TOGGLE);
+ mdelay(125);
+ WATCHDOG_RESET();
+ }
+ led_set_state(led, LEDST_ON);
}
}
-#endif
/* infinite: the boot process must be stopped */
if (nb_blink == U32_MAX)
if (max_uV > USB_WARNING_LOW_THRESHOLD_UV &&
max_uV <= USB_START_LOW_THRESHOLD_UV &&
min_uV <= USB_LOW_THRESHOLD_UV) {
- pr_err("* WARNING 1.5mA power supply detected *\n");
+ pr_err("* WARNING 1.5A power supply detected *\n");
nb_blink = 3;
}
static void sysconf_init(void)
{
-#ifndef CONFIG_STM32MP1_TRUSTED
+#ifndef CONFIG_TFABOOT
u8 *syscfg;
#ifdef CONFIG_DM_REGULATOR
struct udevice *pwr_dev;
struct udevice *pwr_reg;
struct udevice *dev;
- int ret;
u32 otp = 0;
#endif
- u32 bootr;
+ int ret;
+ u32 bootr, val;
syscfg = (u8 *)syscon_get_first_range(STM32MP_SYSCON_SYSCFG);
*/
writel(SYSCFG_CMPENSETR_MPU_EN, syscfg + SYSCFG_CMPENSETR);
- while (!(readl(syscfg + SYSCFG_CMPCR) & SYSCFG_CMPCR_READY))
- ;
+ /* poll until ready (1s timeout) */
+ ret = readl_poll_timeout(syscfg + SYSCFG_CMPCR, val,
+ val & SYSCFG_CMPCR_READY,
+ 1000000);
+ if (ret) {
+ pr_err("SYSCFG: I/O compensation failed, timeout.\n");
+ led_error_blink(10);
+ }
+
clrbits_le32(syscfg + SYSCFG_CMPCR, SYSCFG_CMPCR_SW_CTRL);
#endif
}
static bool board_is_dk2(void)
{
- if (CONFIG_IS_ENABLED(TARGET_STM32MP157C_DK2) &&
+ if (CONFIG_IS_ENABLED(TARGET_ST_STM32MP15x) &&
of_machine_is_compatible("st,stm32mp157c-dk2"))
return true;
}
#endif
+static bool board_is_ev1(void)
+{
+ if (CONFIG_IS_ENABLED(TARGET_ST_STM32MP15x) &&
+ (of_machine_is_compatible("st,stm32mp157a-ev1") ||
+ of_machine_is_compatible("st,stm32mp157c-ev1") ||
+ of_machine_is_compatible("st,stm32mp157d-ev1") ||
+ of_machine_is_compatible("st,stm32mp157f-ev1")))
+ return true;
+
+ return false;
+}
+
+/* touchscreen driver: only used for pincontrol configuration */
+static const struct udevice_id goodix_ids[] = {
+ { .compatible = "goodix,gt9147", },
+ { }
+};
+
+U_BOOT_DRIVER(goodix) = {
+ .name = "goodix",
+ .id = UCLASS_NOP,
+ .of_match = goodix_ids,
+};
+
+static void board_ev1_init(void)
+{
+ struct udevice *dev;
+
+ /* configure IRQ line on EV1 for touchscreen before LCD reset */
+ uclass_get_device_by_driver(UCLASS_NOP, DM_GET_DRIVER(goodix), &dev);
+}
+
/* board dependent setup after realloc */
int board_init(void)
{
board_key_check();
+ if (board_is_ev1())
+ board_ev1_init();
+
#ifdef CONFIG_DM_REGULATOR
if (board_is_dk2())
dk2_i2c1_fix();
sysconf_init();
- if (CONFIG_IS_ENABLED(CONFIG_LED))
+ if (CONFIG_IS_ENABLED(LED))
led_default_state();
+ setup_led(LEDST_ON);
+
return 0;
}
int board_late_init(void)
{
- char *boot_device;
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
const void *fdt_compat;
int fdt_compat_len;
fdt_compat = fdt_getprop(gd->fdt_blob, 0, "compatible",
&fdt_compat_len);
if (fdt_compat && fdt_compat_len) {
- if (strncmp(fdt_compat, "st,", 3) != 0)
+ if (strncmp(fdt_compat, "st,", 3) != 0) {
env_set("board_name", fdt_compat);
- else
+ } else {
+ char dtb_name[256];
+ int buf_len = sizeof(dtb_name);
+
env_set("board_name", fdt_compat + 3);
+
+ strncpy(dtb_name, fdt_compat + 3, buf_len);
+ buf_len -= strlen(fdt_compat + 3);
+ strncat(dtb_name, ".dtb", buf_len);
+ env_set("fdtfile", dtb_name);
+ }
}
ret = uclass_get_device_by_driver(UCLASS_MISC,
DM_GET_DRIVER(stm32mp_bsec),
board_check_usb_power();
#endif /* CONFIG_ADC */
- /* Check the boot-source to disable bootdelay */
- boot_device = env_get("boot_device");
- if (!strcmp(boot_device, "serial") || !strcmp(boot_device, "usb"))
- env_set("bootdelay", "0");
-
return 0;
}
void board_quiesce_devices(void)
{
-#ifdef CONFIG_LED
setup_led(LEDST_OFF);
-#endif
}
-/* board interface eth init */
-int board_interface_eth_init(phy_interface_t interface_type,
- bool eth_clk_sel_reg, bool eth_ref_clk_sel_reg)
+/* eth init function : weak called in eqos driver */
+int board_interface_eth_init(struct udevice *dev,
+ phy_interface_t interface_type)
{
u8 *syscfg;
u32 value;
+ bool eth_clk_sel_reg = false;
+ bool eth_ref_clk_sel_reg = false;
+
+ /* Gigabit Ethernet 125MHz clock selection. */
+ eth_clk_sel_reg = dev_read_bool(dev, "st,eth_clk_sel");
+
+ /* Ethernet 50Mhz RMII clock selection */
+ eth_ref_clk_sel_reg =
+ dev_read_bool(dev, "st,eth_ref_clk_sel");
syscfg = (u8 *)syscon_get_first_range(STM32MP_SYSCON_SYSCFG);
#endif
#ifdef CONFIG_ENV_IS_IN_UBI
case BOOT_FLASH_NAND:
+ case BOOT_FLASH_SPINAND:
return ENVL_UBI;
#endif
#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
}
#endif
-#ifdef CONFIG_SYS_MTDPARTS_RUNTIME
-
-#define MTDPARTS_LEN 256
-#define MTDIDS_LEN 128
-
-/**
- * The mtdparts_nand0 and mtdparts_nor0 variable tends to be long.
- * If we need to access it before the env is relocated, then we need
- * to use our own stack buffer. gd->env_buf will be too small.
- *
- * @param buf temporary buffer pointer MTDPARTS_LEN long
- * @return mtdparts variable string, NULL if not found
- */
-static const char *env_get_mtdparts(const char *str, char *buf)
-{
- if (gd->flags & GD_FLG_ENV_READY)
- return env_get(str);
- if (env_get_f(str, buf, MTDPARTS_LEN) != -1)
- return buf;
-
- return NULL;
-}
-
-/**
- * update the variables "mtdids" and "mtdparts" with content of mtdparts_<dev>
- */
-static void board_get_mtdparts(const char *dev,
- char *mtdids,
- char *mtdparts)
-{
- char env_name[32] = "mtdparts_";
- char tmp_mtdparts[MTDPARTS_LEN];
- const char *tmp;
-
- /* name of env variable to read = mtdparts_<dev> */
- strcat(env_name, dev);
- tmp = env_get_mtdparts(env_name, tmp_mtdparts);
- if (tmp) {
- /* mtdids: "<dev>=<dev>, ...." */
- if (mtdids[0] != '\0')
- strcat(mtdids, ",");
- strcat(mtdids, dev);
- strcat(mtdids, "=");
- strcat(mtdids, dev);
-
- /* mtdparts: "mtdparts=<dev>:<mtdparts_<dev>>;..." */
- if (mtdparts[0] != '\0')
- strncat(mtdparts, ";", MTDPARTS_LEN);
- else
- strcat(mtdparts, "mtdparts=");
- strncat(mtdparts, dev, MTDPARTS_LEN);
- strncat(mtdparts, ":", MTDPARTS_LEN);
- strncat(mtdparts, tmp, MTDPARTS_LEN);
- }
-}
-
-void board_mtdparts_default(const char **mtdids, const char **mtdparts)
-{
- struct udevice *dev;
- static char parts[2 * MTDPARTS_LEN + 1];
- static char ids[MTDIDS_LEN + 1];
- static bool mtd_initialized;
-
- if (mtd_initialized) {
- *mtdids = ids;
- *mtdparts = parts;
- return;
- }
-
- memset(parts, 0, sizeof(parts));
- memset(ids, 0, sizeof(ids));
-
- if (!uclass_get_device(UCLASS_MTD, 0, &dev))
- board_get_mtdparts("nand0", ids, parts);
-
- if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev))
- board_get_mtdparts("nor0", ids, parts);
-
- mtd_initialized = true;
- *mtdids = ids;
- *mtdparts = parts;
- debug("%s:mtdids=%s & mtdparts=%s\n", __func__, ids, parts);
-}
-#endif
-
#if defined(CONFIG_OF_BOARD_SETUP)
int ft_board_setup(void *blob, bd_t *bd)
{
#ifdef CONFIG_FDT_FIXUP_PARTITIONS
struct node_info nodes[] = {
{ "st,stm32f469-qspi", MTD_DEV_TYPE_NOR, },
+ { "st,stm32f469-qspi", MTD_DEV_TYPE_SPINAND},
{ "st,stm32mp15-fmc2", MTD_DEV_TYPE_NAND, },
};
fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
printf("Load Remote Processor %d with data@addr=0x%08lx %u bytes:%s\n",
id, fw_image, fw_size, ret ? " Failed!" : " Success!");
- if (!ret) {
+ if (!ret)
rproc_start(id);
- env_set("copro_state", "booted");
- }
}
U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_COPRO, board_copro_image_process);