From 6c9a83502facf265406bc87f7a6949cc3c66872d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 9 Nov 2020 07:12:24 -0700 Subject: [PATCH 1/8] x86: zimage: Update cmdline parameter to be an env var With the updated changes to bootargs substitution[1], the zboot command needs to be updated to get its command line from an environment variable instead of a memory address. This is because the command-line string must be updated to convert %U to ${uuid}, etc. In any case it is more flexible to use a environment variable and it is best to do this before the release to avoid a subsequent change. Update the command accordingly. [1] http://patchwork.ozlabs.org/project/uboot/list/?series=212481 Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- arch/x86/lib/zimage.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index 50fb16d2dac..24a503d011e 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -60,8 +60,8 @@ * BZIMAGE_LOAD_ADDR or ZIMAGE_LOAD_ADDR * @base_ptr: Pointer to the boot parameters, typically at address * DEFAULT_SETUP_BASE - * @cmdline: Address of 'override' command line, or 0 to use the one in the - * setup block + * @cmdline: Environment variable containing the 'override' command line, or + * NULL to use the one in the setup block */ struct zboot_state { ulong bzimage_addr; @@ -70,7 +70,7 @@ struct zboot_state { ulong initrd_size; ulong load_address; struct boot_params *base_ptr; - ulong cmdline; + char *cmdline; } state; enum { @@ -406,7 +406,7 @@ static int do_zboot_start(struct cmd_tbl *cmdtp, int flag, int argc, state.bzimage_addr = 0; } if (argc >= 7) - state.cmdline = simple_strtoul(argv[6], NULL, 16); + state.cmdline = env_get(argv[6]); return 0; } @@ -452,7 +452,7 @@ static int do_zboot_setup(struct cmd_tbl *cmdtp, int flag, int argc, } ret = setup_zimage(base_ptr, (char *)base_ptr + COMMAND_LINE_OFFSET, 0, state.initrd_addr, state.initrd_size, - state.cmdline); + (ulong)state.cmdline); if (ret) { puts("Setting up boot parameters failed ...\n"); return CMD_RET_FAILURE; @@ -743,8 +743,9 @@ U_BOOT_CMDREP_COMPLETE( " initrd size - The size of the initrd image to use, if any.\n" " setup - The address of the kernel setup region, if this\n" " is not at addr\n" - " cmdline - The address of the kernel command line, to\n" - " override U-Boot's normal cmdline generation\n" + " cmdline - Environment variable containing the kernel\n" + " command line, to override U-Boot's normal\n" + " cmdline generation\n" "\n" "Sub-commands to do part of the zboot sequence:\n" "\tstart [addr [arg ...]] - specify arguments\n" From 1b6314be50df11d9c07ba3c13618bac9df838d07 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 9 Nov 2020 07:12:25 -0700 Subject: [PATCH 2/8] x86: coral: Update the boot script Make use of the new bootargs substitution mechanism and zboot command syntax. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- include/configs/chromebook_coral.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/configs/chromebook_coral.h b/include/configs/chromebook_coral.h index d4d32758e99..6e8e8ec1709 100644 --- a/include/configs/chromebook_coral.h +++ b/include/configs/chromebook_coral.h @@ -15,10 +15,13 @@ "read mmc 2:2 100000 0 80; setexpr loader *001004f0; " \ "setexpr size *00100518; setexpr blocks $size / 200; " \ "read mmc 2:2 100000 80 $blocks; setexpr setup $loader - 1000; " \ - "setexpr cmdline $loader - 2000; " \ - "part uuid mmc 2:2 uuid; setenv bootargs_U $uuid; " \ - "zboot start 100000 0 0 0 $setup $cmdline; " \ - "zboot load; zboot setup; zboot dump; zboot go" + "setexpr cmdline_ptr $loader - 2000; " \ + "setexpr.s cmdline *$cmdline_ptr; " \ + "setexpr cmdline gsub %U \\\\${uuid}; " \ + "if part uuid mmc 2:2 uuid; then " \ + "zboot start 100000 0 0 0 $setup cmdline; " \ + "zboot load; zboot setup; zboot dump; zboot go;" \ + "fi" #include #include From 21096c0af3733b63c1e9ee7772d95a0551b4fc85 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Fri, 27 Nov 2020 14:40:48 +0200 Subject: [PATCH 3/8] x86: tangier: Find proper memory region for relocation It appears that U-Boot works by luck on Intel Edison board because the amount of RAM is less than 1 GB and standard way of calculating the top of it work for this configuration. However, this won't work if the amount of RAM is different and split differently in address space. We have to find the suitable window correctly. Find proper memory region for relocation by scanning MMAP SFI table in board_get_usable_ram_top() callback. According to the address map documentation the Main Memory is guaranteed to lie in the 0..2 GB range, that's why we limit search by this range. Fixes: e71de54a4943 ("x86: Add Intel Tangier support") Signed-off-by: Andy Shevchenko Reviewed-by: Simon Glass Reviewed-by: Bin Meng [bmeng: fixed a typo in the commit message] Signed-off-by: Bin Meng --- arch/x86/cpu/tangier/sdram.c | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/arch/x86/cpu/tangier/sdram.c b/arch/x86/cpu/tangier/sdram.c index df3b9e4ec97..afb08476ed3 100644 --- a/arch/x86/cpu/tangier/sdram.c +++ b/arch/x86/cpu/tangier/sdram.c @@ -196,6 +196,49 @@ unsigned int install_e820_map(unsigned int max_entries, return sfi_setup_e820(max_entries, entries); } +/* + * This function looks for the highest region of memory lower than 2GB which + * has enough space for U-Boot where U-Boot is aligned on a page boundary. It + * overrides the default implementation found elsewhere which simply picks the + * end of RAM, wherever that may be. The location of the stack, the relocation + * address, and how far U-Boot is moved by relocation are set in the global + * data structure. + */ +ulong board_get_usable_ram_top(ulong total_size) +{ + struct sfi_table_simple *sb; + struct sfi_mem_entry *mentry; + ulong dest_addr = 0; + u32 i; + + sb = sfi_search_mmap(); + if (!sb) + panic("No available memory found for relocation"); + + sfi_for_each_mentry(i, sb, mentry) { + unsigned long long start, end; + + if (mentry->type != SFI_MEM_CONV) + continue; + + start = mentry->phys_start; + end = start + (mentry->pages << 12); + + /* Filter memory over 2GB. */ + if (end > 0x7fffffffULL) + end = 0x80000000ULL; + /* Skip this region if it's too small. */ + if (end - start < total_size) + continue; + + /* Use this address if it's the largest so far. */ + if (end > dest_addr) + dest_addr = end; + } + + return dest_addr; +} + int dram_init_banksize(void) { sfi_get_bank_size(); From 5384a3f56ce19a0b394ff892c94d06092073b19b Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Fri, 27 Nov 2020 14:41:16 +0200 Subject: [PATCH 4/8] x86: edison: Drop unneeded DM_PCI_COMPAT None of the driver for Edison is using DM_PCI_COMPAT, hence drop it. Signed-off-by: Andy Shevchenko Reviewed-by: Simon Glass Reviewed-by: Bin Meng --- configs/edison_defconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/configs/edison_defconfig b/configs/edison_defconfig index c69c3f883c1..ab2811eca9d 100644 --- a/configs/edison_defconfig +++ b/configs/edison_defconfig @@ -37,7 +37,6 @@ CONFIG_DFU_TIMEOUT=y CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_SUPPORT_EMMC_BOOT=y -CONFIG_DM_PCI_COMPAT=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_MANUFACTURER="Intel" CONFIG_USB_GADGET_VENDOR_NUM=0x8087 From 35d29a8f55bec00bd59ed1e35fb900198c27bdb1 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Wed, 2 Dec 2020 12:35:32 +0200 Subject: [PATCH 5/8] x86: edison: Add CPU to compatible string Like in the rest of x86 boards append CPU to the board compatible string. Signed-off-by: Andy Shevchenko Reviewed-by: Simon Glass Reviewed-by: Bin Meng --- arch/x86/dts/edison.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/dts/edison.dts b/arch/x86/dts/edison.dts index bc84bc892e7..97cc6ec386c 100644 --- a/arch/x86/dts/edison.dts +++ b/arch/x86/dts/edison.dts @@ -16,7 +16,7 @@ / { model = "Intel Edison"; - compatible = "intel,edison"; + compatible = "intel,edison", "intel,tangier"; aliases { serial0 = &serial0; From d067fb763680815fec05c21533d2aa23523a8b10 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 3 Dec 2020 17:40:11 +0200 Subject: [PATCH 6/8] x86: edison: BINMAN selection is specific to the board The platforms based on Intel Tangier may have different requirements how to create bootloader bundle to supply to a device. Currently the BINMAN approach is for Intel Edison only. Signed-off-by: Andy Shevchenko Reviewed-by: Simon Glass Reviewed-by: Bin Meng --- arch/x86/cpu/tangier/Kconfig | 1 - board/intel/edison/Kconfig | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/cpu/tangier/Kconfig b/arch/x86/cpu/tangier/Kconfig index 571470c74b2..d2b7edecd60 100644 --- a/arch/x86/cpu/tangier/Kconfig +++ b/arch/x86/cpu/tangier/Kconfig @@ -12,7 +12,6 @@ config INTEL_TANGIER imply MMC_SDHCI_TANGIER imply USB imply USB_DWC3 - imply BINMAN if INTEL_TANGIER diff --git a/board/intel/edison/Kconfig b/board/intel/edison/Kconfig index 05d65445e40..23b2af4821d 100644 --- a/board/intel/edison/Kconfig +++ b/board/intel/edison/Kconfig @@ -31,5 +31,6 @@ config BOARD_SPECIFIC_OPTIONS # dummy select INTEL_TANGIER select BOARD_LATE_INIT select MD5 + imply BINMAN endif From 23cdbba8b199f2f35c28e40dbb59a5e935dbbae9 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 3 Dec 2020 19:45:01 +0200 Subject: [PATCH 7/8] x86: edison: Use dwc3-generic driver for Intel Edison Use generic Synopsys DesignWare 3 driver on Intel Edison. For now it's just a stub which allows future refactoring. Signed-off-by: Andy Shevchenko Reviewed-by: Simon Glass Reviewed-by: Bin Meng --- arch/x86/cpu/tangier/Kconfig | 3 +++ arch/x86/dts/edison.dts | 4 ++++ drivers/usb/dwc3/dwc3-generic.c | 1 + 3 files changed, 8 insertions(+) diff --git a/arch/x86/cpu/tangier/Kconfig b/arch/x86/cpu/tangier/Kconfig index d2b7edecd60..94d9d74a325 100644 --- a/arch/x86/cpu/tangier/Kconfig +++ b/arch/x86/cpu/tangier/Kconfig @@ -10,8 +10,11 @@ config INTEL_TANGIER imply MMC_SDHCI imply MMC_SDHCI_SDMA imply MMC_SDHCI_TANGIER + imply MISC imply USB + imply USB_XHCI_HCD imply USB_DWC3 + imply USB_DWC3_GENERIC if INTEL_TANGIER diff --git a/arch/x86/dts/edison.dts b/arch/x86/dts/edison.dts index 97cc6ec386c..600d6d25624 100644 --- a/arch/x86/dts/edison.dts +++ b/arch/x86/dts/edison.dts @@ -105,6 +105,10 @@ reg = <0xff009000 0x1000>; }; + usb: usb@f9100000 { + compatible = "intel,tangier-dwc3"; + }; + watchdog: wdt@0 { compatible = "intel,tangier-wdt"; }; diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index a936f71d2e5..222358d3959 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -449,6 +449,7 @@ static const struct udevice_id dwc3_glue_ids[] = { { .compatible = "rockchip,rk3328-dwc3" }, { .compatible = "rockchip,rk3399-dwc3" }, { .compatible = "qcom,dwc3" }, + { .compatible = "intel,tangier-dwc3" }, { } }; From f89e8acbc81ee6d9e57f0156c3ee6de44528c8b7 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 3 Dec 2020 19:45:02 +0200 Subject: [PATCH 8/8] x86: edison: Switch to DM_USB_GADGET DM is the modern default approach for the drivers in U-Boot. It also allows to configure code via Device Tree. Move Intel Edison to use DM_USB_GADGET and drop hard coded values. Signed-off-by: Andy Shevchenko Reviewed-by: Simon Glass Reviewed-by: Bin Meng --- arch/x86/cpu/tangier/Kconfig | 4 ---- arch/x86/dts/edison.dts | 8 ++++++++ board/intel/edison/edison.c | 35 ----------------------------------- configs/edison_defconfig | 1 + 4 files changed, 9 insertions(+), 39 deletions(-) diff --git a/arch/x86/cpu/tangier/Kconfig b/arch/x86/cpu/tangier/Kconfig index 94d9d74a325..19aaf165d6a 100644 --- a/arch/x86/cpu/tangier/Kconfig +++ b/arch/x86/cpu/tangier/Kconfig @@ -29,8 +29,4 @@ config SYS_CAR_SIZE Space in bytes in eSRAM used as Cache-As-RAM (CAR). Note this size must not exceed eSRAM's total size. -config SYS_USB_OTG_BASE - hex - default 0xf9100000 - endif diff --git a/arch/x86/dts/edison.dts b/arch/x86/dts/edison.dts index 600d6d25624..8d245bffc2f 100644 --- a/arch/x86/dts/edison.dts +++ b/arch/x86/dts/edison.dts @@ -107,6 +107,14 @@ usb: usb@f9100000 { compatible = "intel,tangier-dwc3"; + #address-cells = <1>; + #size-cells = <1>; + + dwc3: dwc3 { + reg = <0xf9100000 0x100000>; + maximum-speed = "high-speed"; + dr_mode = "peripheral"; + }; }; watchdog: wdt@0 { diff --git a/board/intel/edison/edison.c b/board/intel/edison/edison.c index 652f9755155..11e7f74e47c 100644 --- a/board/intel/edison/edison.c +++ b/board/intel/edison/edison.c @@ -3,15 +3,10 @@ * Copyright (c) 2017 Intel Corporation */ #include -#include #include #include #include #include -#include -#include - -#include #include #include @@ -27,36 +22,6 @@ int board_early_init_r(void) return 0; } -static struct dwc3_device dwc3_device_data = { - .maximum_speed = USB_SPEED_HIGH, - .base = CONFIG_SYS_USB_OTG_BASE, - .dr_mode = USB_DR_MODE_PERIPHERAL, - .index = 0, -}; - -int usb_gadget_handle_interrupts(int controller_index) -{ - dwc3_uboot_handle_interrupt(controller_index); - WATCHDOG_RESET(); - return 0; -} - -int board_usb_init(int index, enum usb_init_type init) -{ - if (index == 0 && init == USB_INIT_DEVICE) - return dwc3_uboot_init(&dwc3_device_data); - return -EINVAL; -} - -int board_usb_cleanup(int index, enum usb_init_type init) -{ - if (index == 0 && init == USB_INIT_DEVICE) { - dwc3_uboot_exit(index); - return 0; - } - return -EINVAL; -} - static void assign_serial(void) { struct mmc *mmc = find_mmc_device(0); diff --git a/configs/edison_defconfig b/configs/edison_defconfig index ab2811eca9d..304a172a1b9 100644 --- a/configs/edison_defconfig +++ b/configs/edison_defconfig @@ -37,6 +37,7 @@ CONFIG_DFU_TIMEOUT=y CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_SUPPORT_EMMC_BOOT=y +CONFIG_DM_USB_GADGET=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_MANUFACTURER="Intel" CONFIG_USB_GADGET_VENDOR_NUM=0x8087