summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--arch/arm/Makefile2
-rw-r--r--arch/arm/boards/avnet-zedboard/flash_header.c4
-rw-r--r--arch/arm/boards/beaglebone/lowlevel.c2
-rw-r--r--arch/arm/boards/friendlyarm-tiny210/lowlevel.c2
-rw-r--r--arch/arm/boards/phytec-som-am335x/ram-timings.h11
-rw-r--r--arch/arm/boards/phytec-som-rk3288/lowlevel.c11
-rw-r--r--arch/arm/configs/rk3288_defconfig2
-rw-r--r--arch/arm/cpu/common.c3
-rw-r--r--arch/arm/cpu/start.c2
-rw-r--r--arch/arm/dts/rk3288-phycore-som.dts2
-rw-r--r--arch/arm/include/asm/barebox-arm.h2
-rw-r--r--arch/arm/lib32/barebox.lds.S2
-rw-r--r--arch/arm/lib32/runtime-offset.S1
-rw-r--r--arch/arm/mach-omap/Kconfig1
-rw-r--r--arch/arm/mach-omap/am33xx_generic.c3
-rw-r--r--arch/arm/mach-omap/include/mach/am33xx-silicon.h2
-rw-r--r--arch/efi/Makefile4
-rw-r--r--arch/efi/efi/efi-image.c9
-rw-r--r--arch/efi/lib/elf_x86_64_efi.lds.S1
-rw-r--r--commands/2048.c2
-rw-r--r--commands/bootchooser.c4
-rw-r--r--common/Kconfig2
-rw-r--r--common/Makefile1
-rw-r--r--common/bootm.c2
-rw-r--r--common/menu.c2
-rw-r--r--drivers/ata/ide-sff.c9
-rw-r--r--drivers/mtd/nand/nand_s3c24xx.c2
-rw-r--r--drivers/of/of_path.c2
-rw-r--r--drivers/serial/efi-stdio.c3
-rw-r--r--drivers/serial/serial_ns16550.c19
-rw-r--r--drivers/usb/gadget/Kconfig1
-rw-r--r--dts/Bindings/i2c/i2c.txt8
-rw-r--r--dts/Bindings/interrupt-controller/snps,archs-idu-intc.txt3
-rw-r--r--dts/Bindings/mtd/tango-nand.txt6
-rw-r--r--dts/Bindings/net/mediatek-net.txt2
-rw-r--r--dts/Bindings/net/phy.txt5
-rw-r--r--dts/Bindings/net/ti,dp83867.txt6
-rw-r--r--dts/Bindings/spi/sh-msiof.txt19
-rw-r--r--dts/src/arm/am335x-icev2.dts1
-rw-r--r--dts/src/arm/bcm-nsp.dtsi2
-rw-r--r--dts/src/arm/da850-evm.dts1
-rw-r--r--dts/src/arm/dra7.dtsi1
-rw-r--r--dts/src/arm/dra72-evm-revc.dts2
-rw-r--r--dts/src/arm/imx6qdl-nitrogen6_max.dtsi4
-rw-r--r--dts/src/arm/imx6qdl-nitrogen6_som2.dtsi4
-rw-r--r--dts/src/arm/logicpd-som-lv-37xx-devkit.dts11
-rw-r--r--dts/src/arm/omap5.dtsi1
-rw-r--r--dts/src/arm/qcom-mdm9615.dtsi2
-rw-r--r--dts/src/arm/sun6i-a31-hummingbird.dts4
-rw-r--r--dts/src/arm/sun6i-a31.dtsi1
-rw-r--r--dts/src/arm/sun7i-a20-olinuxino-lime2-emmc.dts2
-rw-r--r--dts/src/arm64/amlogic/meson-gxbb-odroidc2.dts4
-rw-r--r--dts/src/arm64/amlogic/meson-gxbb.dtsi2
-rw-r--r--dts/src/arm64/exynos/exynos5433.dtsi2
-rw-r--r--dts/src/arm64/xilinx/zynqmp-ep108.dts2
-rw-r--r--dts/src/arm64/xilinx/zynqmp.dtsi6
-rw-r--r--include/asm-generic/sections.h3
-rw-r--r--include/readkey.h4
-rw-r--r--lib/libfile.c9
-rw-r--r--lib/readkey.c4
-rw-r--r--scripts/.gitignore1
-rw-r--r--scripts/Makefile4
-rwxr-xr-xscripts/checkpatch.pl2
-rw-r--r--scripts/omap4_usbboot.c (renamed from scripts/omap4_usbboot/omap4_usbboot.c)78
-rw-r--r--scripts/omap4_usbboot/.gitignore1
-rw-r--r--scripts/omap4_usbboot/Makefile5
-rw-r--r--scripts/omap4_usbboot/usb.h61
-rw-r--r--scripts/omap4_usbboot/usb_linux.c397
69 files changed, 217 insertions, 570 deletions
diff --git a/Makefile b/Makefile
index 042486a997..ff2ed8fc0f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
VERSION = 2017
-PATCHLEVEL = 01
+PATCHLEVEL = 02
SUBLEVEL = 0
EXTRAVERSION =
NAME = None
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 96ec588da0..620a3ccb0b 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -32,7 +32,7 @@ endif
# testing for a specific architecture or later rather impossible.
arch-$(CONFIG_CPU_64v8) := -D__LINUX_ARM_ARCH__=8 $(call cc-option,-march=armv8-a)
arch-$(CONFIG_CPU_32v7) :=-D__LINUX_ARM_ARCH__=7 $(call cc-option,-march=armv7-a,-march=armv5t -Wa$(comma)-march=armv7-a)
-arch-$(CONFIG_CPU_32v6) :=-D__LINUX_ARM_ARCH__=6 $(call cc-option,-march=armv6,-march=armv5t -Wa$(comma)-march=armv6)
+arch-$(CONFIG_CPU_32v6) :=-D__LINUX_ARM_ARCH__=6 $(call cc-option,-march=armv6,-march=armv5t -Wa$(comma)-march=armv6)
arch-$(CONFIG_CPU_32v5) :=-D__LINUX_ARM_ARCH__=5 $(call cc-option,-march=armv5te,-march=armv4t)
arch-$(CONFIG_CPU_32v4T) :=-D__LINUX_ARM_ARCH__=4 -march=armv4t
diff --git a/arch/arm/boards/avnet-zedboard/flash_header.c b/arch/arm/boards/avnet-zedboard/flash_header.c
index ea2052405a..d9eb35b0d5 100644
--- a/arch/arm/boards/avnet-zedboard/flash_header.c
+++ b/arch/arm/boards/avnet-zedboard/flash_header.c
@@ -52,10 +52,10 @@ struct zynq_flash_header __flash_header_section flash_header = {
.enc_stat = 0x0,
.user = 0x0,
.flash_offset = 0x8c0,
- .length = barebox_image_size,
+ .length = (unsigned int)&_barebox_image_size,
.res0 = 0x0,
.start_of_exec = 0x0,
- .total_len = barebox_image_size,
+ .total_len = (unsigned int)&_barebox_image_size,
.res1 = 0x1,
.checksum = 0x0,
.res2 = 0x0,
diff --git a/arch/arm/boards/beaglebone/lowlevel.c b/arch/arm/boards/beaglebone/lowlevel.c
index 100f64fdd9..a56b4b6240 100644
--- a/arch/arm/boards/beaglebone/lowlevel.c
+++ b/arch/arm/boards/beaglebone/lowlevel.c
@@ -41,6 +41,7 @@ static const struct am33xx_emif_regs ddr2_regs = {
.emif_tim1 = 0x0666B3C9,
.emif_tim2 = 0x243631CA,
.emif_tim3 = 0x0000033F,
+ .ocp_config = 0x00141414,
.sdram_config = 0x41805332,
.sdram_config2 = 0x41805332,
.sdram_ref_ctrl = 0x0000081A,
@@ -97,6 +98,7 @@ static const struct am33xx_emif_regs ddr3_regs = {
.emif_tim1 = 0x0AAAD4DB,
.emif_tim2 = 0x266B7FDA,
.emif_tim3 = 0x501F867F,
+ .ocp_config = 0x00141414,
.zq_config = 0x50074BE4,
.sdram_config = 0x61C05332,
.sdram_config2 = 0x0,
diff --git a/arch/arm/boards/friendlyarm-tiny210/lowlevel.c b/arch/arm/boards/friendlyarm-tiny210/lowlevel.c
index 3ab8d66060..fea00ef503 100644
--- a/arch/arm/boards/friendlyarm-tiny210/lowlevel.c
+++ b/arch/arm/boards/friendlyarm-tiny210/lowlevel.c
@@ -97,7 +97,7 @@ void __bare_init barebox_arm_reset_vector(void)
debug_led(1, 1);
if (! load_stage2((void*)(ld_var(_text) - 16),
- ld_var(_barebox_image_size) + 16)) {
+ barebox_image_size + 16)) {
debug_led(3, 1);
while (1) { } /* hang */
}
diff --git a/arch/arm/boards/phytec-som-am335x/ram-timings.h b/arch/arm/boards/phytec-som-am335x/ram-timings.h
index 9576d265e5..4ea654db12 100644
--- a/arch/arm/boards/phytec-som-am335x/ram-timings.h
+++ b/arch/arm/boards/phytec-som-am335x/ram-timings.h
@@ -45,6 +45,7 @@ struct am335x_sdram_timings physom_timings[] = {
.emif_tim1 = 0x0AAAD4DB,
.emif_tim2 = 0x26437FDA,
.emif_tim3 = 0x501F83FF,
+ .ocp_config = 0x003d3d3d,
.sdram_config = 0x61C052B2,
.zq_config = 0x50074BE4,
.sdram_ref_ctrl = 0x00000C30,
@@ -66,6 +67,7 @@ struct am335x_sdram_timings physom_timings[] = {
.emif_tim1 = 0x0AAAE4DB,
.emif_tim2 = 0x266B7FDA,
.emif_tim3 = 0x501F867F,
+ .ocp_config = 0x003d3d3d,
.sdram_config = 0x61C05332,
.zq_config = 0x50074BE4,
.sdram_ref_ctrl = 0x00000C30,
@@ -87,6 +89,7 @@ struct am335x_sdram_timings physom_timings[] = {
.emif_tim1 = 0x0AAAD4DB,
.emif_tim2 = 0x26437FDA,
.emif_tim3 = 0x501F83FF,
+ .ocp_config = 0x003d3d3d,
.sdram_config = 0x61C052B2,
.zq_config = 0x50074BE4,
.sdram_ref_ctrl = 0x00000C30,
@@ -106,6 +109,7 @@ struct am335x_sdram_timings physom_timings[] = {
.emif_tim1 = 0x0AAAE4DB,
.emif_tim2 = 0x262F7FDA,
.emif_tim3 = 0x501F82BF,
+ .ocp_config = 0x003d3d3d,
.sdram_config = 0x61C05232,
.zq_config = 0x50074BE4,
.sdram_ref_ctrl = 0x00000C30,
@@ -125,6 +129,7 @@ struct am335x_sdram_timings physom_timings[] = {
.emif_tim1 = 0x0AAAE4DB,
.emif_tim2 = 0x266B7FDA,
.emif_tim3 = 0x501F867F,
+ .ocp_config = 0x003d3d3d,
.sdram_config = 0x61C05332,
.zq_config = 0x50074BE4,
.sdram_ref_ctrl = 0x00000C30
@@ -144,6 +149,7 @@ struct am335x_sdram_timings physom_timings[] = {
.emif_tim1 = 0x0AAAE4DB,
.emif_tim2 = 0x266B7FDA,
.emif_tim3 = 0x501F867F,
+ .ocp_config = 0x003d3d3d,
.sdram_config = 0x61C053B2,
.zq_config = 0x50074BE4,
.sdram_ref_ctrl = 0x00000C30
@@ -163,6 +169,7 @@ struct am335x_sdram_timings physom_timings[] = {
.emif_tim1 = 0x0AAAE4DB,
.emif_tim2 = 0x268F7FDA,
.emif_tim3 = 0x501F88BF,
+ .ocp_config = 0x003d3d3d,
.sdram_config = 0x61C053B2,
.zq_config = 0x50074BE4,
.sdram_ref_ctrl = 0x00000C30
@@ -182,6 +189,7 @@ struct am335x_sdram_timings physom_timings[] = {
.emif_tim1 = 0x0AAAD4DB,
.emif_tim2 = 0x26437FDA,
.emif_tim3 = 0x501F83FF,
+ .ocp_config = 0x003d3d3d,
.sdram_config = 0x61C052B2,
.zq_config = 0x50074BE4,
.sdram_ref_ctrl = 0x00000C30,
@@ -203,6 +211,7 @@ struct am335x_sdram_timings physom_timings[] = {
.emif_tim1 = 0x0AAAD4DB,
.emif_tim2 = 0x266B7FDA,
.emif_tim3 = 0x501F867F,
+ .ocp_config = 0x003d3d3d,
.sdram_config = 0x61C05332,
.zq_config = 0x50074BE4,
.sdram_ref_ctrl = 0x00000C30,
@@ -222,6 +231,7 @@ struct am335x_sdram_timings physom_timings[] = {
.emif_tim1 = 0x0AAAD4DB,
.emif_tim2 = 0x26437FDA,
.emif_tim3 = 0x501F83FF,
+ .ocp_config = 0x003d3d3d,
.sdram_config = 0x61C052B2,
.zq_config = 0x50074BE4,
.sdram_ref_ctrl = 0x00000C30,
@@ -241,6 +251,7 @@ struct am335x_sdram_timings physom_timings[] = {
.emif_tim1 = 0x0AAAD4DB,
.emif_tim2 = 0x268F7FDA,
.emif_tim3 = 0x501F88BF,
+ .ocp_config = 0x003d3d3d,
.sdram_config = 0x61C053B2,
.zq_config = 0x50074BE4,
.sdram_ref_ctrl = 0x00000C30,
diff --git a/arch/arm/boards/phytec-som-rk3288/lowlevel.c b/arch/arm/boards/phytec-som-rk3288/lowlevel.c
index 7804a55bcd..7649ef864a 100644
--- a/arch/arm/boards/phytec-som-rk3288/lowlevel.c
+++ b/arch/arm/boards/phytec-som-rk3288/lowlevel.c
@@ -30,14 +30,13 @@ ENTRY_FUNCTION(start_rk3288_phycore_som, r0, r1, r2)
if (IS_ENABLED(CONFIG_DEBUG_LL)) {
struct rk3288_grf * const grf = (void *)RK3288_GRF_BASE;
- rk_clrsetreg(&grf->gpio4c_iomux,
- GPIO4C1_MASK << GPIO4C1_SHIFT |
- GPIO4C0_MASK << GPIO4C0_SHIFT,
- GPIO4C1_UART0BT_SOUT << GPIO4C1_SHIFT |
- GPIO4C0_UART0BT_SIN << GPIO4C0_SHIFT);
+ rk_clrsetreg(&grf->gpio7ch_iomux,
+ GPIO7C7_MASK << GPIO7C7_SHIFT |
+ GPIO7C6_MASK << GPIO7C6_SHIFT,
+ GPIO7C7_UART2DBG_SOUT << GPIO7C7_SHIFT |
+ GPIO7C6_UART2DBG_SIN << GPIO7C6_SHIFT);
INIT_LL();
}
-
fdt = __dtb_rk3288_phycore_som_start - get_runtime_offset();
barebox_arm_entry(0x0, SZ_1G, fdt);
diff --git a/arch/arm/configs/rk3288_defconfig b/arch/arm/configs/rk3288_defconfig
index f54f4cc3c3..15e6c15a03 100644
--- a/arch/arm/configs/rk3288_defconfig
+++ b/arch/arm/configs/rk3288_defconfig
@@ -26,7 +26,7 @@ CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
CONFIG_RESET_SOURCE=y
CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_LL=y
-CONFIG_DEBUG_ROCKCHIP_UART_PORT=0
+CONFIG_DEBUG_ROCKCHIP_UART_PORT=2
CONFIG_CMD_DMESG=y
CONFIG_LONGHELP=y
CONFIG_CMD_IOMEM=y
diff --git a/arch/arm/cpu/common.c b/arch/arm/cpu/common.c
index 46ce942187..dcd8f0b732 100644
--- a/arch/arm/cpu/common.c
+++ b/arch/arm/cpu/common.c
@@ -78,3 +78,6 @@ int __pure cpu_architecture(void)
return __cpu_architecture;
}
#endif
+
+char __image_start[0] __attribute__((section(".__image_start")));
+char __image_end[0] __attribute__((section(".__image_end"))); \ No newline at end of file
diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index a62b0d5563..171e6ad0eb 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -116,7 +116,7 @@ static inline unsigned long arm_mem_boarddata(unsigned long membase,
{
unsigned long mem;
- mem = arm_mem_barebox_image(membase, endmem, barebox_image_size);
+ mem = arm_mem_barebox_image(membase, endmem, arm_barebox_size);
mem -= ALIGN(size, 64);
return mem;
diff --git a/arch/arm/dts/rk3288-phycore-som.dts b/arch/arm/dts/rk3288-phycore-som.dts
index 5410bd1f76..dd74bcfb11 100644
--- a/arch/arm/dts/rk3288-phycore-som.dts
+++ b/arch/arm/dts/rk3288-phycore-som.dts
@@ -44,7 +44,7 @@
};
chosen {
- stdout-path = &uart0;
+ stdout-path = &uart2;
environment-emmc {
compatible = "barebox,environment";
diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index e8dfd02389..3aea2e070e 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -179,4 +179,6 @@ static inline unsigned long arm_mem_barebox_image(unsigned long membase,
*/
#define MAX_BSS_SIZE SZ_1M
+#define barebox_image_size (__image_end - __image_start)
+
#endif /* _BAREBOX_ARM_H_ */
diff --git a/arch/arm/lib32/barebox.lds.S b/arch/arm/lib32/barebox.lds.S
index ff088b3020..b49c269a43 100644
--- a/arch/arm/lib32/barebox.lds.S
+++ b/arch/arm/lib32/barebox.lds.S
@@ -31,6 +31,7 @@ SECTIONS
#else
. = TEXT_BASE;
#endif
+ .image_start : { *(.__image_start) }
#ifndef CONFIG_PBL_IMAGE
PRE_IMAGE
@@ -117,6 +118,7 @@ SECTIONS
}
_edata = .;
+ .image_end : { *(.__image_end) }
. = ALIGN(4);
__bss_start = .;
diff --git a/arch/arm/lib32/runtime-offset.S b/arch/arm/lib32/runtime-offset.S
index f10c4c8469..7375cb961b 100644
--- a/arch/arm/lib32/runtime-offset.S
+++ b/arch/arm/lib32/runtime-offset.S
@@ -39,7 +39,6 @@ ld_var_entry __rel_dyn_start
ld_var_entry __rel_dyn_end
ld_var_entry __dynsym_start
ld_var_entry __dynsym_end
-ld_var_entry _barebox_image_size
ld_var_entry __bss_start
ld_var_entry __bss_stop
#ifdef __PBL__
diff --git a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig
index 93fa35a208..9c41741b50 100644
--- a/arch/arm/mach-omap/Kconfig
+++ b/arch/arm/mach-omap/Kconfig
@@ -149,6 +149,7 @@ config OMAP_SERIALBOOT
select XYMODEM
select FS_RAMFS
depends on ARCH_AM33XX && SHELL_NONE
+ depends on !CONSOLE_NONE
help
Say Y here if you want to load the 2nd stage barebox.bin with
xmodem after booting from serial line.
diff --git a/arch/arm/mach-omap/am33xx_generic.c b/arch/arm/mach-omap/am33xx_generic.c
index 5eead5c589..513746248e 100644
--- a/arch/arm/mach-omap/am33xx_generic.c
+++ b/arch/arm/mach-omap/am33xx_generic.c
@@ -341,6 +341,9 @@ void am33xx_config_sdram(const struct am33xx_emif_regs *regs)
writel(regs->emif_tim3, AM33XX_EMIF4_0_REG(SDRAM_TIM_3));
writel(regs->emif_tim3, AM33XX_EMIF4_0_REG(SDRAM_TIM_3_SHADOW));
+ if (regs->ocp_config)
+ writel(regs->ocp_config, AM33XX_EMIF4_0_REG(OCP_CONFIG));
+
if (regs->zq_config) {
/*
* A value of 0x2800 for the REF CTRL will give us
diff --git a/arch/arm/mach-omap/include/mach/am33xx-silicon.h b/arch/arm/mach-omap/include/mach/am33xx-silicon.h
index 10595d5ee7..0729369255 100644
--- a/arch/arm/mach-omap/include/mach/am33xx-silicon.h
+++ b/arch/arm/mach-omap/include/mach/am33xx-silicon.h
@@ -114,6 +114,7 @@
#define EMIF4_SDRAM_TIM_3_SHADOW 0x2C
#define EMIF0_SDRAM_MGMT_CTRL 0x38
#define EMIF0_SDRAM_MGMT_CTRL_SHD 0x3C
+#define EMIF4_OCP_CONFIG 0x54
#define EMIF4_ZQ_CONFIG 0xC8
#define EMIF4_DDR_PHY_CTRL_1 0xE4
#define EMIF4_DDR_PHY_CTRL_1_SHADOW 0xE8
@@ -217,6 +218,7 @@ struct am33xx_emif_regs {
u32 emif_tim1;
u32 emif_tim2;
u32 emif_tim3;
+ u32 ocp_config;
u32 sdram_config;
u32 sdram_config2;
u32 zq_config;
diff --git a/arch/efi/Makefile b/arch/efi/Makefile
index b078bd0e35..32a1c152b7 100644
--- a/arch/efi/Makefile
+++ b/arch/efi/Makefile
@@ -28,8 +28,8 @@ cmd_barebox__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_barebox) -o $@ \
quiet_cmd_efi_image = EFI-IMG $@
cmd_efi_image = $(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic \
-j .dynsym -j .rel -j .rela -j .reloc -j __barebox_initcalls \
- -j __barebox_cmd -j .barebox_magicvar -j .bbenv.* \
- --target=$(TARGET) $< $@
+ -j __barebox_exitcalls -j __barebox_cmd -j .barebox_magicvar \
+ -j .bbenv.* --target=$(TARGET) $< $@
KBUILD_BINARY := barebox
diff --git a/arch/efi/efi/efi-image.c b/arch/efi/efi/efi-image.c
index 32e060886a..27f3c1b39c 100644
--- a/arch/efi/efi/efi-image.c
+++ b/arch/efi/efi/efi-image.c
@@ -130,12 +130,16 @@ static int efi_execute_image(const char *file)
efi_status_t efiret;
struct linux_kernel_header *image_header;
const char *options;
+ bool is_driver;
int ret;
ret = efi_load_image(file, &loaded_image, &handle);
if (ret)
return ret;
+ is_driver = (loaded_image->image_code_type == EFI_BOOT_SERVICES_CODE) ||
+ (loaded_image->image_code_type == EFI_RUNTIME_SERVICES_CODE);
+
image_header = (struct linux_kernel_header *)loaded_image->image_base;
if (image_header->boot_flag == 0xAA55 &&
image_header->header == 0x53726448) {
@@ -145,13 +149,15 @@ static int efi_execute_image(const char *file)
loaded_image->load_options = xstrdup_char_to_wchar(options);
loaded_image->load_options_size =
(strlen(options) + 1) * sizeof(wchar_t);
+ shutdown_barebox();
}
efiret = BS->start_image(handle, NULL, NULL);
if (EFI_ERROR(efiret))
pr_err("failed to StartImage: %s\n", efi_strerror(efiret));
- BS->unload_image(handle);
+ if (!is_driver)
+ BS->unload_image(handle);
efi_connect_all();
efi_register_devices();
@@ -255,6 +261,7 @@ static int do_bootm_efi(struct image_data *data)
efi_set_variable_usec("LoaderTimeExecUSec", &efi_systemd_vendor_guid,
get_time_ns()/1000);
+ shutdown_barebox();
linux_efi_handover(handle, boot_header);
return 0;
diff --git a/arch/efi/lib/elf_x86_64_efi.lds.S b/arch/efi/lib/elf_x86_64_efi.lds.S
index e1bc2120fa..93d34d17ab 100644
--- a/arch/efi/lib/elf_x86_64_efi.lds.S
+++ b/arch/efi/lib/elf_x86_64_efi.lds.S
@@ -80,6 +80,7 @@ SECTIONS
*(.rela.data*)
*(.rela.barebox*)
*(.rela.initcall*)
+ *(.rela.exitcall*)
*(.rela.got)
*(.rela.stab)
}
diff --git a/commands/2048.c b/commands/2048.c
index 5ceb5cfb7d..865803a5a6 100644
--- a/commands/2048.c
+++ b/commands/2048.c
@@ -53,7 +53,7 @@ static void getColor(uint16_t value, char *color, size_t length)
static void drawBoard(uint16_t board[SIZE][SIZE])
{
int8_t x,y;
- char color[40], reset[] = "\033[m";
+ char color[40], reset[] = "\033[0m";
printf("\033[H");
printf("2048.c %17d pts\n\n",score);
diff --git a/commands/bootchooser.c b/commands/bootchooser.c
index 91938fe551..ac763a6553 100644
--- a/commands/bootchooser.c
+++ b/commands/bootchooser.c
@@ -134,8 +134,8 @@ BAREBOX_CMD_HELP_START(bootchooser)
BAREBOX_CMD_HELP_TEXT("Control misc behaviour of the bootchooser")
BAREBOX_CMD_HELP_TEXT("")
BAREBOX_CMD_HELP_TEXT("Options:")
-BAREBOX_CMD_HELP_OPT ("-a <n|default> [TARGETS]", "set priority of given targets to 'n' or the default priority")
-BAREBOX_CMD_HELP_OPT ("-p <n|default> [TARGETS]", "set remaining attempts of given targets to 'n' or the default attempts")
+BAREBOX_CMD_HELP_OPT ("-a <n|default> [TARGETS]", "set remaining attempts of given targets to 'n' or the default attempts")
+BAREBOX_CMD_HELP_OPT ("-p <n|default> [TARGETS]", "set priority of given targets to 'n' or the default priority")
BAREBOX_CMD_HELP_OPT ("-i", "Show information about the bootchooser")
BAREBOX_CMD_HELP_OPT ("-s", "Mark the last boot successful")
BAREBOX_CMD_HELP_END
diff --git a/common/Kconfig b/common/Kconfig
index 350e3d49dd..f7ff04664d 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -854,6 +854,8 @@ config DEFAULT_ENVIRONMENT_GENERIC
depends on DEFAULT_ENVIRONMENT
depends on !DEFAULT_ENVIRONMENT_GENERIC_NEW
depends on SHELL_HUSH
+ select COMMAND_SUPPORT
+ select GLOBALVAR
select CMD_GETOPT
select CMD_CRC
select CMD_CRC_CMP
diff --git a/common/Makefile b/common/Makefile
index a36ae5e91f..869b15a92a 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -86,6 +86,7 @@ endif
# dependencies on generated files need to be listed explicitly
$(obj)/version.o: include/generated/compile.h
$(obj)/imd-barebox.o: include/generated/compile.h
+$(obj)/pbl-imd-barebox.o: include/generated/compile.h
# compile.h changes depending on hostname, generation number, etc,
# so we regenerate it always.
diff --git a/common/bootm.c b/common/bootm.c
index 59843195cd..81625d9157 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -684,5 +684,5 @@ BAREBOX_MAGICVAR_NAMED(global_bootm_initrd, global.bootm.initrd, "bootm default
BAREBOX_MAGICVAR_NAMED(global_bootm_initrd_loadaddr, global.bootm.initrd.loadaddr, "bootm default initrd loadaddr");
BAREBOX_MAGICVAR_NAMED(global_bootm_oftree, global.bootm.oftree, "bootm default oftree");
BAREBOX_MAGICVAR_NAMED(global_bootm_verify, global.bootm.verify, "bootm default verify level");
-BAREBOX_MAGICVAR_NAMED(global_bootm_verbose, global.bootm.verify, "bootm default verbosity level (0=quiet)");
+BAREBOX_MAGICVAR_NAMED(global_bootm_verbose, global.bootm.verbose, "bootm default verbosity level (0=quiet)");
BAREBOX_MAGICVAR_NAMED(global_bootm_appendroot, global.bootm.appendroot, "Add root= option to Kernel to mount rootfs from the device the Kernel comes from");
diff --git a/common/menu.c b/common/menu.c
index e757216c5a..31e5c90a0f 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -185,7 +185,7 @@ static void print_menu_entry(struct menu *m, struct menu_entry *me,
__print_entry(me->display);
if (selected)
- puts("\e[m");
+ puts("\e[0m");
}
int menu_set_selected_entry(struct menu *m, struct menu_entry* me)
diff --git a/drivers/ata/ide-sff.c b/drivers/ata/ide-sff.c
index e32cc3fc24..6dc89d79a5 100644
--- a/drivers/ata/ide-sff.c
+++ b/drivers/ata/ide-sff.c
@@ -389,11 +389,10 @@ int ide_port_register(struct ide_port *ide)
ide->port.ops = &ide_ops;
ret = ata_port_register(&ide->port);
- if (!ret)
- ata_port_detect(&ide->port);
-
if (ret)
- free(ide);
+ return ret;
+
+ ata_port_detect(&ide->port);
- return ret;
+ return 0;
}
diff --git a/drivers/mtd/nand/nand_s3c24xx.c b/drivers/mtd/nand/nand_s3c24xx.c
index 83d45172b1..df22735488 100644
--- a/drivers/mtd/nand/nand_s3c24xx.c
+++ b/drivers/mtd/nand/nand_s3c24xx.c
@@ -614,7 +614,7 @@ void __nand_boot_init s3c24x0_nand_load_image(void *dest, int size, int page)
void __nand_boot_init nand_boot(void)
{
void *dest = _text;
- int size = ld_var(_barebox_image_size);
+ int size = barebox_image_size;
int page = 0;
s3c24x0_nand_load_image(dest, size, page);
diff --git a/drivers/of/of_path.c b/drivers/of/of_path.c
index 946b9c7aa1..e0b2dc1247 100644
--- a/drivers/of/of_path.c
+++ b/drivers/of/of_path.c
@@ -66,7 +66,7 @@ static int __of_find_path(struct device_node *node, const char *part, char **out
return -ENODEV;
}
- if (!dev->driver)
+ if (dev->bus && !dev->driver)
return -ENODEV;
device_detect(dev);
diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index bf14c5e24a..5ab917386e 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -99,9 +99,10 @@ static struct efi_ctrlkey ctrlkeys[] = {
{ 0x05, BB_KEY_HOME },
{ 0x06, BB_KEY_END },
{ 0x07, BB_KEY_INSERT },
- { 0x08, BB_KEY_DEL },
+ { 0x08, BB_KEY_DEL7 },
{ 0x09, BB_KEY_PAGEUP },
{ 0x0a, BB_KEY_PAGEDOWN },
+ { 0x17, 27 /* escape key */ },
};
static int efi_read_key(struct efi_console_priv *priv, bool wait)
diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index c6548e3b85..439b7d5517 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -287,12 +287,31 @@ static int ns16550_tstc(struct console_device *cdev)
static void ns16550_probe_dt(struct device_d *dev, struct ns16550_priv *priv)
{
struct device_node *np = dev->device_node;
+ u32 width;
if (!IS_ENABLED(CONFIG_OFDEVICE))
return;
of_property_read_u32(np, "clock-frequency", &priv->plat.clock);
of_property_read_u32(np, "reg-shift", &priv->plat.shift);
+ if (!of_property_read_u32(np, "reg-io-width", &width))
+ switch (width) {
+ case 1:
+ priv->read_reg = ns16550_read_reg_mmio_8;
+ priv->write_reg = ns16550_write_reg_mmio_8;
+ break;
+ case 2:
+ priv->read_reg = ns16550_read_reg_mmio_16;
+ priv->write_reg = ns16550_write_reg_mmio_16;
+ break;
+ case 4:
+ priv->read_reg = ns16550_read_reg_mmio_32;
+ priv->write_reg = ns16550_write_reg_mmio_32;
+ break;
+ default:
+ dev_err(dev, "unsupported reg-io-width (%d)\n",
+ width);
+ }
}
static struct ns16550_drvdata ns16450_drvdata = {
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 81c3723200..eb279ae8df 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -19,6 +19,7 @@ config USB_GADGET_DRIVER_AT91
bool
prompt "at91 gadget driver"
depends on ARCH_AT91
+ depends on !ARCH_SAMA5D4
default y
select USB_GADGET_DUALSPEED
diff --git a/dts/Bindings/i2c/i2c.txt b/dts/Bindings/i2c/i2c.txt
index 5fa691e6f6..cee9d5055f 100644
--- a/dts/Bindings/i2c/i2c.txt
+++ b/dts/Bindings/i2c/i2c.txt
@@ -62,6 +62,9 @@ wants to support one of the below features, it should adapt the bindings below.
"irq" and "wakeup" names are recognized by I2C core, other names are
left to individual drivers.
+- host-notify
+ device uses SMBus host notify protocol instead of interrupt line.
+
- multi-master
states that there is another master active on this bus. The OS can use
this information to adapt power management to keep the arbitration awake
@@ -81,6 +84,11 @@ Binding may contain optional "interrupts" property, describing interrupts
used by the device. I2C core will assign "irq" interrupt (or the very first
interrupt if not using interrupt names) as primary interrupt for the slave.
+Alternatively, devices supporting SMbus Host Notify, and connected to
+adapters that support this feature, may use "host-notify" property. I2C
+core will create a virtual interrupt for Host Notify and assign it as
+primary interrupt for the slave.
+
Also, if device is marked as a wakeup source, I2C core will set up "wakeup"
interrupt for the device. If "wakeup" interrupt name is not present in the
binding, then primary interrupt will be used as wakeup interrupt.
diff --git a/dts/Bindings/interrupt-controller/snps,archs-idu-intc.txt b/dts/Bindings/interrupt-controller/snps,archs-idu-intc.txt
index 0dcb7c7d3e..944657684d 100644
--- a/dts/Bindings/interrupt-controller/snps,archs-idu-intc.txt
+++ b/dts/Bindings/interrupt-controller/snps,archs-idu-intc.txt
@@ -15,6 +15,9 @@ Properties:
Second cell specifies the irq distribution mode to cores
0=Round Robin; 1=cpu0, 2=cpu1, 4=cpu2, 8=cpu3
+ The second cell in interrupts property is deprecated and may be ignored by
+ the kernel.
+
intc accessed via the special ARC AUX register interface, hence "reg" property
is not specified.
diff --git a/dts/Bindings/mtd/tango-nand.txt b/dts/Bindings/mtd/tango-nand.txt
index ad5a02f2ac..cd1bf2ac90 100644
--- a/dts/Bindings/mtd/tango-nand.txt
+++ b/dts/Bindings/mtd/tango-nand.txt
@@ -5,7 +5,7 @@ Required properties:
- compatible: "sigma,smp8758-nand"
- reg: address/size of nfc_reg, nfc_mem, and pbus_reg
- dmas: reference to the DMA channel used by the controller
-- dma-names: "nfc_sbox"
+- dma-names: "rxtx"
- clocks: reference to the system clock
- #address-cells: <1>
- #size-cells: <0>
@@ -17,9 +17,9 @@ Example:
nandc: nand-controller@2c000 {
compatible = "sigma,smp8758-nand";
- reg = <0x2c000 0x30 0x2d000 0x800 0x20000 0x1000>;
+ reg = <0x2c000 0x30>, <0x2d000 0x800>, <0x20000 0x1000>;
dmas = <&dma0 3>;
- dma-names = "nfc_sbox";
+ dma-names = "rxtx";
clocks = <&clkgen SYS_CLK>;
#address-cells = <1>;
#size-cells = <0>;
diff --git a/dts/Bindings/net/mediatek-net.txt b/dts/Bindings/net/mediatek-net.txt
index c010fafc66..c7194e87d5 100644
--- a/dts/Bindings/net/mediatek-net.txt
+++ b/dts/Bindings/net/mediatek-net.txt
@@ -7,7 +7,7 @@ have dual GMAC each represented by a child node..
* Ethernet controller node
Required properties:
-- compatible: Should be "mediatek,mt7623-eth"
+- compatible: Should be "mediatek,mt2701-eth"
- reg: Address and length of the register set for the device
- interrupts: Should contain the three frame engines interrupts in numeric
order. These are fe_int0, fe_int1 and fe_int2.
diff --git a/dts/Bindings/net/phy.txt b/dts/Bindings/net/phy.txt
index ff1bc4b1bb..fb5056b226 100644
--- a/dts/Bindings/net/phy.txt
+++ b/dts/Bindings/net/phy.txt
@@ -19,8 +19,9 @@ Optional Properties:
specifications. If neither of these are specified, the default is to
assume clause 22.
- If the phy's identifier is known then the list may contain an entry
- of the form: "ethernet-phy-idAAAA.BBBB" where
+ If the PHY reports an incorrect ID (or none at all) then the
+ "compatible" list may contain an entry with the correct PHY ID in the
+ form: "ethernet-phy-idAAAA.BBBB" where
AAAA - The value of the 16 bit Phy Identifier 1 register as
4 hex digits. This is the chip vendor OUI bits 3:18
BBBB - The value of the 16 bit Phy Identifier 2 register as
diff --git a/dts/Bindings/net/ti,dp83867.txt b/dts/Bindings/net/ti,dp83867.txt
index 85bf945b89..afe9630a5e 100644
--- a/dts/Bindings/net/ti,dp83867.txt
+++ b/dts/Bindings/net/ti,dp83867.txt
@@ -3,9 +3,11 @@
Required properties:
- reg - The ID number for the phy, usually a small integer
- ti,rx-internal-delay - RGMII Receive Clock Delay - see dt-bindings/net/ti-dp83867.h
- for applicable values
+ for applicable values. Required only if interface type is
+ PHY_INTERFACE_MODE_RGMII_ID or PHY_INTERFACE_MODE_RGMII_RXID
- ti,tx-internal-delay - RGMII Transmit Clock Delay - see dt-bindings/net/ti-dp83867.h
- for applicable values
+ for applicable values. Required only if interface type is
+ PHY_INTERFACE_MODE_RGMII_ID or PHY_INTERFACE_MODE_RGMII_TXID
- ti,fifo-depth - Transmitt FIFO depth- see dt-bindings/net/ti-dp83867.h
for applicable values
diff --git a/dts/Bindings/spi/sh-msiof.txt b/dts/Bindings/spi/sh-msiof.txt
index da6614c637..dc975064fa 100644
--- a/dts/Bindings/spi/sh-msiof.txt
+++ b/dts/Bindings/spi/sh-msiof.txt
@@ -1,17 +1,23 @@
Renesas MSIOF spi controller
Required properties:
-- compatible : "renesas,msiof-<soctype>" for SoCs,
- "renesas,sh-msiof" for SuperH, or
- "renesas,sh-mobile-msiof" for SH Mobile series.
- Examples with soctypes are:
- "renesas,msiof-r8a7790" (R-Car H2)
+- compatible : "renesas,msiof-r8a7790" (R-Car H2)
"renesas,msiof-r8a7791" (R-Car M2-W)
"renesas,msiof-r8a7792" (R-Car V2H)
"renesas,msiof-r8a7793" (R-Car M2-N)
"renesas,msiof-r8a7794" (R-Car E2)
"renesas,msiof-r8a7796" (R-Car M3-W)
"renesas,msiof-sh73a0" (SH-Mobile AG5)
+ "renesas,sh-mobile-msiof" (generic SH-Mobile compatibile device)
+ "renesas,rcar-gen2-msiof" (generic R-Car Gen2 compatible device)
+ "renesas,rcar-gen3-msiof" (generic R-Car Gen3 compatible device)
+ "renesas,sh-msiof" (deprecated)
+
+ When compatible with the generic version, nodes
+ must list the SoC-specific version corresponding
+ to the platform first followed by the generic
+ version.
+
- reg : A list of offsets and lengths of the register sets for
the device.
If only one register set is present, it is to be used
@@ -61,7 +67,8 @@ Documentation/devicetree/bindings/pinctrl/renesas,*.
Example:
msiof0: spi@e6e20000 {
- compatible = "renesas,msiof-r8a7791";
+ compatible = "renesas,msiof-r8a7791",
+ "renesas,rcar-gen2-msiof";
reg = <0 0xe6e20000 0 0x0064>;
interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&mstp0_clks R8A7791_CLK_MSIOF0>;
diff --git a/dts/src/arm/am335x-icev2.dts b/dts/src/arm/am335x-icev2.dts
index 1463df3b5b..8ed46f9d79 100644
--- a/dts/src/arm/am335x-icev2.dts
+++ b/dts/src/arm/am335x-icev2.dts
@@ -170,7 +170,6 @@
AM33XX_IOPAD(0x8fc, PIN_INPUT_PULLUP | MUX_MODE0) /* (G16) mmc0_dat0.mmc0_dat0 */
AM33XX_IOPAD(0x900, PIN_INPUT_PULLUP | MUX_MODE0) /* (G17) mmc0_clk.mmc0_clk */
AM33XX_IOPAD(0x904, PIN_INPUT_PULLUP | MUX_MODE0) /* (G18) mmc0_cmd.mmc0_cmd */
- AM33XX_IOPAD(0x960, PIN_INPUT_PULLUP | MUX_MODE5) /* (C15) spi0_cs1.mmc0_sdcd */
>;
};
diff --git a/dts/src/arm/bcm-nsp.dtsi b/dts/src/arm/bcm-nsp.dtsi
index b6142bda66..15f07f9af3 100644
--- a/dts/src/arm/bcm-nsp.dtsi
+++ b/dts/src/arm/bcm-nsp.dtsi
@@ -160,7 +160,7 @@
axi {
compatible = "simple-bus";
- ranges = <0x00000000 0x18000000 0x0011c40a>;
+ ranges = <0x00000000 0x18000000 0x0011c40c>;
#address-cells = <1>;
#size-cells = <1>;
diff --git a/dts/src/arm/da850-evm.dts b/dts/src/arm/da850-evm.dts
index 41de15fe15..78492a0bbb 100644
--- a/dts/src/arm/da850-evm.dts
+++ b/dts/src/arm/da850-evm.dts
@@ -99,6 +99,7 @@
#size-cells = <1>;
compatible = "m25p64";
spi-max-frequency = <30000000>;
+ m25p,fast-read;
reg = <0>;
partition@0 {
label = "U-Boot-SPL";
diff --git a/dts/src/arm/dra7.dtsi b/dts/src/arm/dra7.dtsi
index 1faf24acd5..5ba161679e 100644
--- a/dts/src/arm/dra7.dtsi
+++ b/dts/src/arm/dra7.dtsi
@@ -1378,6 +1378,7 @@
phy-names = "sata-phy";
clocks = <&sata_ref_clk>;
ti,hwmods = "sata";
+ ports-implemented = <0x1>;
};
rtc: rtc@48838000 {
diff --git a/dts/src/arm/dra72-evm-revc.dts b/dts/src/arm/dra72-evm-revc.dts
index c3d939c966..3f808a47df 100644
--- a/dts/src/arm/dra72-evm-revc.dts
+++ b/dts/src/arm/dra72-evm-revc.dts
@@ -75,6 +75,6 @@
ti,rx-internal-delay = <DP83867_RGMIIDCTL_2_25_NS>;
ti,tx-internal-delay = <DP83867_RGMIIDCTL_250_PS>;
ti,fifo-depth = <DP83867_PHYCR_FIFO_DEPTH_8_B_NIB>;
- ti,min-output-imepdance;
+ ti,min-output-impedance;
};
};
diff --git a/dts/src/arm/imx6qdl-nitrogen6_max.dtsi b/dts/src/arm/imx6qdl-nitrogen6_max.dtsi
index 34887a10c5..47ba97229a 100644
--- a/dts/src/arm/imx6qdl-nitrogen6_max.dtsi
+++ b/dts/src/arm/imx6qdl-nitrogen6_max.dtsi
@@ -319,8 +319,6 @@
compatible = "fsl,imx6q-nitrogen6_max-sgtl5000",
"fsl,imx-audio-sgtl5000";
model = "imx6q-nitrogen6_max-sgtl5000";
- pinctrl-names = "default";
- pinctrl-0 = <&pinctrl_sgtl5000>;
ssi-controller = <&ssi1>;
audio-codec = <&codec>;
audio-routing =
@@ -402,6 +400,8 @@
codec: sgtl5000@0a {
compatible = "fsl,sgtl5000";
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_sgtl5000>;
reg = <0x0a>;
clocks = <&clks IMX6QDL_CLK_CKO>;
VDDA-supply = <&reg_2p5v>;
diff --git a/dts/src/arm/imx6qdl-nitrogen6_som2.dtsi b/dts/src/arm/imx6qdl-nitrogen6_som2.dtsi
index d80f21abea..31d4cc62db 100644
--- a/dts/src/arm/imx6qdl-nitrogen6_som2.dtsi
+++ b/dts/src/arm/imx6qdl-nitrogen6_som2.dtsi
@@ -250,8 +250,6 @@
compatible = "fsl,imx6q-nitrogen6_som2-sgtl5000",
"fsl,imx-audio-sgtl5000";
model = "imx6q-nitrogen6_som2-sgtl5000";
- pinctrl-names = "default";
- pinctrl-0 = <&pinctrl_sgtl5000>;
ssi-controller = <&ssi1>;
audio-codec = <&codec>;
audio-routing =
@@ -320,6 +318,8 @@
codec: sgtl5000@0a {
compatible = "fsl,sgtl5000";
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_sgtl5000>;
reg = <0x0a>;
clocks = <&clks IMX6QDL_CLK_CKO>;
VDDA-supply = <&reg_2p5v>;
diff --git a/dts/src/arm/logicpd-som-lv-37xx-devkit.dts b/dts/src/arm/logicpd-som-lv-37xx-devkit.dts
index da8598402a..38faa90007 100644
--- a/dts/src/arm/logicpd-som-lv-37xx-devkit.dts
+++ b/dts/src/arm/logicpd-som-lv-37xx-devkit.dts
@@ -158,7 +158,7 @@
&mmc1 {
interrupts-extended = <&intc 83 &omap3_pmx_core 0x11a>;
pinctrl-names = "default";
- pinctrl-0 = <&mmc1_pins &mmc1_cd>;
+ pinctrl-0 = <&mmc1_pins>;
wp-gpios = <&gpio4 30 GPIO_ACTIVE_HIGH>; /* gpio_126 */
cd-gpios = <&gpio4 14 IRQ_TYPE_LEVEL_LOW>; /* gpio_110 */
vmmc-supply = <&vmmc1>;
@@ -193,7 +193,8 @@
OMAP3_CORE1_IOPAD(0x214a, PIN_INPUT | MUX_MODE0) /* sdmmc1_dat1.sdmmc1_dat1 */
OMAP3_CORE1_IOPAD(0x214c, PIN_INPUT | MUX_MODE0) /* sdmmc1_dat2.sdmmc1_dat2 */
OMAP3_CORE1_IOPAD(0x214e, PIN_INPUT | MUX_MODE0) /* sdmmc1_dat3.sdmmc1_dat3 */
- OMAP3_CORE1_IOPAD(0x2132, PIN_INPUT_PULLUP | MUX_MODE4) /* cam_strobe.gpio_126 sdmmc1_wp*/
+ OMAP3_CORE1_IOPAD(0x2132, PIN_INPUT_PULLUP | MUX_MODE4) /* cam_strobe.gpio_126 */
+ OMAP3_CORE1_IOPAD(0x212c, PIN_INPUT_PULLUP | MUX_MODE4) /* cam_d11.gpio_110 */
>;
};
@@ -242,12 +243,6 @@
OMAP3_WKUP_IOPAD(0x2a16, PIN_OUTPUT | PIN_OFF_OUTPUT_LOW | MUX_MODE4) /* sys_boot6.gpio_8 */
>;
};
-
- mmc1_cd: pinmux_mmc1_cd {
- pinctrl-single,pins = <
- OMAP3_WKUP_IOPAD(0x212c, PIN_INPUT_PULLUP | MUX_MODE4) /* cam_d11.gpio_110 */
- >;
- };
};
diff --git a/dts/src/arm/omap5.dtsi b/dts/src/arm/omap5.dtsi
index 7cd92babc4..0844737b72 100644
--- a/dts/src/arm/omap5.dtsi
+++ b/dts/src/arm/omap5.dtsi
@@ -988,6 +988,7 @@
phy-names = "sata-phy";
clocks = <&sata_ref_clk>;
ti,hwmods = "sata";
+ ports-implemented = <0x1>;
};
dss: dss@58000000 {
diff --git a/dts/src/arm/qcom-mdm9615.dtsi b/dts/src/arm/qcom-mdm9615.dtsi
index 5ae4ec59e6..c852b69229 100644
--- a/dts/src/arm/qcom-mdm9615.dtsi
+++ b/dts/src/arm/qcom-mdm9615.dtsi
@@ -357,7 +357,7 @@
};
amba {
- compatible = "arm,amba-bus";
+ compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
ranges;
diff --git a/dts/src/arm/sun6i-a31-hummingbird.dts b/dts/src/arm/sun6i-a31-hummingbird.dts
index 735914f6ae..7cae328398 100644
--- a/dts/src/arm/sun6i-a31-hummingbird.dts
+++ b/dts/src/arm/sun6i-a31-hummingbird.dts
@@ -140,6 +140,10 @@
cpu-supply = <&reg_dcdc3>;
};
+&de {
+ status = "okay";
+};
+
&ehci0 {
status = "okay";
};
diff --git a/dts/src/arm/sun6i-a31.dtsi b/dts/src/arm/sun6i-a31.dtsi
index 2b26175d55..e78faaf924 100644
--- a/dts/src/arm/sun6i-a31.dtsi
+++ b/dts/src/arm/sun6i-a31.dtsi
@@ -234,6 +234,7 @@
de: display-engine {
compatible = "allwinner,sun6i-a31-display-engine";
allwinner,pipelines = <&fe0>;
+ status = "disabled";
};
soc@01c00000 {
diff --git a/dts/src/arm/sun7i-a20-olinuxino-lime2-emmc.dts b/dts/src/arm/sun7i-a20-olinuxino-lime2-emmc.dts
index 5ea4915f6d..10d307408f 100644
--- a/dts/src/arm/sun7i-a20-olinuxino-lime2-emmc.dts
+++ b/dts/src/arm/sun7i-a20-olinuxino-lime2-emmc.dts
@@ -56,7 +56,7 @@
};
&pio {
- mmc2_pins_nrst: mmc2@0 {
+ mmc2_pins_nrst: mmc2-rst-pin {
allwinner,pins = "PC16";
allwinner,function = "gpio_out";
allwinner,drive = <SUN4I_PINCTRL_10_MA>;
diff --git a/dts/src/arm64/amlogic/meson-gxbb-odroidc2.dts b/dts/src/arm64/amlogic/meson-gxbb-odroidc2.dts
index 238fbeacd3..5d28e1cdc9 100644
--- a/dts/src/arm64/amlogic/meson-gxbb-odroidc2.dts
+++ b/dts/src/arm64/amlogic/meson-gxbb-odroidc2.dts
@@ -137,6 +137,10 @@
};
};
+&scpi_clocks {
+ status = "disabled";
+};
+
&uart_AO {
status = "okay";
pinctrl-0 = <&uart_ao_a_pins>;
diff --git a/dts/src/arm64/amlogic/meson-gxbb.dtsi b/dts/src/arm64/amlogic/meson-gxbb.dtsi
index 596240c38a..b35307321b 100644
--- a/dts/src/arm64/amlogic/meson-gxbb.dtsi
+++ b/dts/src/arm64/amlogic/meson-gxbb.dtsi
@@ -55,7 +55,7 @@
mboxes = <&mailbox 1 &mailbox 2>;
shmem = <&cpu_scp_lpri &cpu_scp_hpri>;
- clocks {
+ scpi_clocks: clocks {
compatible = "arm,scpi-clocks";
scpi_dvfs: scpi_clocks@0 {
diff --git a/dts/src/arm64/exynos/exynos5433.dtsi b/dts/src/arm64/exynos/exynos5433.dtsi
index 64226d5ae4..135890cd8a 100644
--- a/dts/src/arm64/exynos/exynos5433.dtsi
+++ b/dts/src/arm64/exynos/exynos5433.dtsi
@@ -1367,7 +1367,7 @@
};
amba {
- compatible = "arm,amba-bus";
+ compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
ranges;
diff --git a/dts/src/arm64/xilinx/zynqmp-ep108.dts b/dts/src/arm64/xilinx/zynqmp-ep108.dts
index 358089687a..ef1b9e573a 100644
--- a/dts/src/arm64/xilinx/zynqmp-ep108.dts
+++ b/dts/src/arm64/xilinx/zynqmp-ep108.dts
@@ -27,7 +27,7 @@
stdout-path = "serial0:115200n8";
};
- memory {
+ memory@0 {
device_type = "memory";
reg = <0x0 0x0 0x0 0x40000000>;
};
diff --git a/dts/src/arm64/xilinx/zynqmp.dtsi b/dts/src/arm64/xilinx/zynqmp.dtsi
index 68a908334c..54dc28351c 100644
--- a/dts/src/arm64/xilinx/zynqmp.dtsi
+++ b/dts/src/arm64/xilinx/zynqmp.dtsi
@@ -72,7 +72,7 @@
<1 10 0xf08>;
};
- amba_apu {
+ amba_apu: amba_apu@0 {
compatible = "simple-bus";
#address-cells = <2>;
#size-cells = <1>;
@@ -175,7 +175,7 @@
};
i2c0: i2c@ff020000 {
- compatible = "cdns,i2c-r1p10";
+ compatible = "cdns,i2c-r1p14", "cdns,i2c-r1p10";
status = "disabled";
interrupt-parent = <&gic>;
interrupts = <0 17 4>;
@@ -185,7 +185,7 @@
};
i2c1: i2c@ff030000 {
- compatible = "cdns,i2c-r1p10";
+ compatible = "cdns,i2c-r1p14", "cdns,i2c-r1p10";
status = "disabled";
interrupt-parent = <&gic>;
interrupts = <0 18 4>;
diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
index 984f8b606b..0eb18f614b 100644
--- a/include/asm-generic/sections.h
+++ b/include/asm-generic/sections.h
@@ -6,12 +6,13 @@ extern char __bss_start[], __bss_stop[];
extern char _sdata[], _edata[];
extern char __bare_init_start[], __bare_init_end[];
extern char _end[];
+extern char __image_start[];
extern char __image_end[];
extern void *_barebox_image_size;
extern void *_barebox_bare_init_size;
extern void *_barebox_pbl_size;
-#define barebox_image_size (unsigned int)&_barebox_image_size
+#define barebox_image_size (__image_end - __image_start)
#define barebox_bare_init_size (unsigned int)&_barebox_bare_init_size
#define barebox_pbl_size (unsigned int)&_barebox_pbl_size
diff --git a/include/readkey.h b/include/readkey.h
index 8398ec2e51..ed1cd1542d 100644
--- a/include/readkey.h
+++ b/include/readkey.h
@@ -26,8 +26,8 @@
#define ANSI_CLEAR_SCREEN "\e[2J\e[;H"
-#define printf_reverse(fmt,args...) printf("\e[7m" fmt "\e[m",##args)
-#define puts_reverse(fmt) puts("\e[7m" fmt "\e[m")
+#define printf_reverse(fmt,args...) printf("\e[7m" fmt "\e[0m",##args)
+#define puts_reverse(fmt) puts("\e[7m" fmt "\e[0m")
#define gotoXY(row, col) printf("\e[%d;%dH", col, row)
#define clear() puts("\e[2J")
diff --git a/lib/libfile.c b/lib/libfile.c
index 049ec32d77..6b70306dbd 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -276,13 +276,14 @@ int copy_file(const char *src, const char *dst, int verbose)
goto out;
}
+ mode = O_WRONLY | O_CREAT;
+
ret = stat(dst, &dststat);
- if (ret)
+ if (ret && ret != -ENOENT)
goto out;
- mode = O_WRONLY | O_CREAT;
-
- if (S_ISREG(dststat.st_mode))
+ /* Set O_TRUNC only if file exist and is a regular file */
+ if (!ret && S_ISREG(dststat.st_mode))
mode |= O_TRUNC;
dstfd = open(dst, mode);
diff --git a/lib/readkey.c b/lib/readkey.c
index 2870a5a9fe..e72da0066b 100644
--- a/lib/readkey.c
+++ b/lib/readkey.c
@@ -51,8 +51,8 @@ static const struct esc_cmds esccmds[] = {
int read_key(void)
{
- char c;
- char esc[5];
+ unsigned char c;
+ unsigned char esc[5];
c = getchar();
if (c == 27) {
diff --git a/scripts/.gitignore b/scripts/.gitignore
index 533bffd97d..2a9ae6bdcf 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -25,3 +25,4 @@ mk-am35xx-spi-image
mxsimage
mxsboot
mxs-usb-loader
+omap4_usbboot
diff --git a/scripts/Makefile b/scripts/Makefile
index a5c16b2f31..7f2527d1c2 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -28,9 +28,11 @@ hostprogs-$(CONFIG_ARCH_MXS_USBLOADER) += mxs-usb-loader
HOSTCFLAGS_omap3-usb-loader.o = `pkg-config --cflags libusb-1.0`
HOSTLOADLIBES_omap3-usb-loader = `pkg-config --libs libusb-1.0`
hostprogs-$(CONFIG_OMAP3_USB_LOADER) += omap3-usb-loader
+HOSTCFLAGS_omap4_usbboot.o = `pkg-config --cflags libusb-1.0`
+HOSTLOADLIBES_omap4_usbboot = -lpthread `pkg-config --libs libusb-1.0`
+hostprogs-$(CONFIG_OMAP4_USBBOOT) += omap4_usbboot
subdir-y += mod
-subdir-$(CONFIG_OMAP4_USBBOOT) += omap4_usbboot
subdir-$(CONFIG_ARCH_IMX) += imx
subdir-$(CONFIG_X86) += setupmbr
subdir-$(CONFIG_DTC) += dtc
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f3fd3395f1..48ad4938d9 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2264,7 +2264,7 @@ sub process {
## }
#need space before brace following if, while, etc
- if (($line =~ /\(.*\)\{/ && $line !~ /\($Type\){/) ||
+ if (($line =~ /\(.*\)\{/ && $line !~ /\($Type\)\{/) ||
$line =~ /do\{/) {
ERROR("space required before the open brace '{'\n" . $herecurr);
}
diff --git a/scripts/omap4_usbboot/omap4_usbboot.c b/scripts/omap4_usbboot.c
index 0e5abcb159..329668d1dd 100644
--- a/scripts/omap4_usbboot/omap4_usbboot.c
+++ b/scripts/omap4_usbboot.c
@@ -8,6 +8,8 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
+ *
+ * Inspired by: https://github.com/simu/usbboot-omap4.git
*/
#include <stdio.h>
@@ -18,11 +20,10 @@
#include <fcntl.h>
#include <string.h>
#include <sys/mman.h>
+#include <libusb.h>
#include <pthread.h>
#include <termios.h>
-#include "usb.h"
-
#define USBBOOT_FS_MAGIC 0x5562464D
#define USBBOOT_FS_CMD_OPEN 0x46530000
#define USBBOOT_FS_CMD_CLOSE 0x46530001
@@ -42,6 +43,20 @@
#define host_print(fmt, arg...) printf(HFORMAT fmt TFORMAT, \
HOST_FORMAT, ##arg, TARGET_FORMAT)
+int usb_write(void *h, void const *data, int len)
+{
+ int actual;
+ return libusb_bulk_transfer(h, 0x01, (void *)data, len, &actual, 5000) ?
+ 0 : actual;
+}
+
+int usb_read(void *h, void *data, int len)
+{
+ int actual;
+ return libusb_bulk_transfer(h, 0x81, data, len, &actual, 5000) ?
+ 0 : actual;
+}
+
void panic(struct termios *t_restore)
{
tcsetattr(STDIN_FILENO, TCSANOW, t_restore);
@@ -50,7 +65,7 @@ void panic(struct termios *t_restore)
}
struct thread_vars {
- struct usb_handle *usb;
+ struct libusb_device_handle *usb;
pthread_mutex_t usb_mutex;
struct termios t_restore;
};
@@ -73,7 +88,7 @@ void *listenerTask(void *argument)
return NULL;
}
-int read_asic_id(struct usb_handle *usb)
+int read_asic_id(struct libusb_device_handle *usb)
{
#define LINEWIDTH 16
const uint32_t msg_getid = 0xF0030003;
@@ -174,7 +189,7 @@ struct file_data {
void *data;
};
-int process_file(struct usb_handle *usb, const char *rootfs,
+int process_file(struct libusb_device_handle *usb, const char *rootfs,
struct file_data *fd_vector, struct termios *t_restore)
{
uint32_t i, j, pos, size;
@@ -324,8 +339,8 @@ open_ok:
return ret;
}
-int usb_boot(
- struct usb_handle *usb, void *data, unsigned sz, const char *rootfs)
+int usb_boot(struct libusb_device_handle *usb,
+ void *data, unsigned sz, const char *rootfs)
{
const uint32_t msg_boot = 0xF0030002;
uint32_t msg_size = sz;
@@ -373,30 +388,21 @@ int usb_boot(
printf("%c", i);
fflush(stdout);
}
- usb_close(usb);
pthread_mutex_destroy(&vars.usb_mutex);
tcsetattr(STDIN_FILENO, TCSANOW, &vars.t_restore);
printf(HFORMAT, HOST_FORMAT);
return 0;
}
-int match_omap4_bootloader(struct usb_ifc_info *ifc)
-{
- if (ifc->dev_vendor != 0x0451)
- return -1;
- if ((ifc->dev_product != 0xD010) && (ifc->dev_product != 0xD00F))
- return -1;
- return 0;
-}
-
int main(int argc, char **argv)
{
void *data;
unsigned sz;
struct stat s;
int fd;
- struct usb_handle *usb;
- int once;
+ int ret;
+ struct libusb_context *ctx = NULL;
+ struct libusb_device_handle *usb = NULL;
if (argc != 3) {
printf("usage: %s <xloader> <rootfs>\n", argv[0]);
@@ -416,16 +422,34 @@ int main(int argc, char **argv)
sz = s.st_size;
close(fd);
argv++;
+ if (libusb_init(&ctx)) {
+ printf("cannot initialize libusb\n");
+ return -1;
+ }
printf(HFORMAT, HOST_FORMAT);
- for (once = 1;;) {
- usb = usb_open(match_omap4_bootloader);
- if (usb)
- return usb_boot(usb, data, sz, argv[0]);
- if (once) {
- once = 0;
- printf("waiting for OMAP44xx device...\n");
+ printf("waiting for OMAP44xx device...\n");
+ while (1) {
+ if (!usb)
+ usb = libusb_open_device_with_vid_pid(
+ ctx, 0x0451, 0xD010);
+ if (!usb)
+ usb = libusb_open_device_with_vid_pid(
+ ctx, 0x0451, 0xD00F);
+ if (usb) {
+ libusb_detach_kernel_driver(usb, 0);
+ ret = libusb_set_configuration(usb, 1);
+ if (ret)
+ break;
+ ret = libusb_claim_interface(usb, 0);
+ if (ret)
+ break;
+ ret = usb_boot(usb, data, sz, argv[0]);
+ break;
}
usleep(250000);
}
- return -1;
+ libusb_release_interface(usb, 0);
+ libusb_close(usb);
+ libusb_exit(ctx);
+ return ret;
}
diff --git a/scripts/omap4_usbboot/.gitignore b/scripts/omap4_usbboot/.gitignore
deleted file mode 100644
index 1975a2172f..0000000000
--- a/scripts/omap4_usbboot/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-omap4_usbboot
diff --git a/scripts/omap4_usbboot/Makefile b/scripts/omap4_usbboot/Makefile
deleted file mode 100644
index af6444b0e2..0000000000
--- a/scripts/omap4_usbboot/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-HOSTLOADLIBES_omap4_usbboot = -lpthread
-omap4_usbboot-objs := usb_linux.o omap4_usbboot.o
-hostprogs-$(CONFIG_OMAP4_USBBOOT) += omap4_usbboot
-
-always := $(hostprogs-y)
diff --git a/scripts/omap4_usbboot/usb.h b/scripts/omap4_usbboot/usb.h
deleted file mode 100644
index d50aa6aa6f..0000000000
--- a/scripts/omap4_usbboot/usb.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _USB_H_
-#define _USB_H_
-
-struct usb_ifc_info {
- /* from device descriptor */
- unsigned short dev_vendor;
- unsigned short dev_product;
-
- unsigned char dev_class;
- unsigned char dev_subclass;
- unsigned char dev_protocol;
-
- unsigned char ifc_class;
- unsigned char ifc_subclass;
- unsigned char ifc_protocol;
-
- unsigned char has_bulk_in;
- unsigned char has_bulk_out;
-
- unsigned char writable;
-
- char serial_number[256];
-};
-
-typedef int (*ifc_match_func)(struct usb_ifc_info *ifc);
-
-struct usb_handle *usb_open(ifc_match_func callback);
-int usb_close(struct usb_handle *h);
-int usb_read(struct usb_handle *h, void *_data, int len);
-int usb_write(struct usb_handle *h, const void *_data, int len);
-
-
-#endif
diff --git a/scripts/omap4_usbboot/usb_linux.c b/scripts/omap4_usbboot/usb_linux.c
deleted file mode 100644
index 9a6e0b84d0..0000000000
--- a/scripts/omap4_usbboot/usb_linux.c
+++ /dev/null
@@ -1,397 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <pthread.h>
-#include <ctype.h>
-
-#include <linux/usbdevice_fs.h>
-#include <linux/usbdevice_fs.h>
-#include <linux/version.h>
-#include <linux/usb/ch9.h>
-#include <asm/byteorder.h>
-
-#include "usb.h"
-
-#define MAX_RETRIES 2
-
-#ifdef TRACE_USB
-#define DBG1(x...) fprintf(stderr, x)
-#define DBG(x...) fprintf(stderr, x)
-#else
-#define DBG(x...)
-#define DBG1(x...)
-#endif
-
-struct usb_handle {
- char fname[64];
- int desc;
- unsigned char ep_in;
- unsigned char ep_out;
-};
-
-static inline int badname(const char *name)
-{
- while (*name) {
- if (!isdigit(*name++))
- return 1;
- }
- return 0;
-}
-
-static int check(void *_desc, int len, unsigned type, int size)
-{
- unsigned char *desc = _desc;
-
- if (len < size)
- return -1;
- if (desc[0] < size)
- return -1;
- if (desc[0] > len)
- return -1;
- if (desc[1] != type)
- return -1;
-
- return 0;
-}
-
-static int filter_usb_device(int fd, char *ptr, int len, int writable,
- ifc_match_func callback, int *ept_in_id, int *ept_out_id, int *ifc_id)
-{
- struct usb_device_descriptor *dev;
- struct usb_config_descriptor *cfg;
- struct usb_interface_descriptor *ifc;
- struct usb_endpoint_descriptor *ept;
- struct usb_ifc_info info;
-
- int in, out;
- unsigned i;
- unsigned e;
-
- if (check(ptr, len, USB_DT_DEVICE, USB_DT_DEVICE_SIZE))
- return -1;
- dev = (void *) ptr;
- len -= dev->bLength;
- ptr += dev->bLength;
-
- if (check(ptr, len, USB_DT_CONFIG, USB_DT_CONFIG_SIZE))
- return -1;
- cfg = (void *) ptr;
- len -= cfg->bLength;
- ptr += cfg->bLength;
-
- info.dev_vendor = dev->idVendor;
- info.dev_product = dev->idProduct;
- info.dev_class = dev->bDeviceClass;
- info.dev_subclass = dev->bDeviceSubClass;
- info.dev_protocol = dev->bDeviceProtocol;
- info.writable = writable;
-
- /* read device serial number (if there is one) */
- info.serial_number[0] = 0;
- if (dev->iSerialNumber) {
- struct usbdevfs_ctrltransfer ctrl;
- __u16 buffer[128];
- int result;
-
- memset(buffer, 0, sizeof(buffer));
-
- ctrl.bRequestType = USB_DIR_IN|
- USB_TYPE_STANDARD|USB_RECIP_DEVICE;
- ctrl.bRequest = USB_REQ_GET_DESCRIPTOR;
- ctrl.wValue = (USB_DT_STRING << 8) | dev->iSerialNumber;
- ctrl.wIndex = 0;
- ctrl.wLength = sizeof(buffer);
- ctrl.data = buffer;
- ctrl.timeout = 50;
-
- result = ioctl(fd, USBDEVFS_CONTROL, &ctrl);
- if (result > 0) {
- int i;
- /* skip first word, and copy the rest to the serial
- string, changing shorts to bytes. */
- result /= 2;
- for (i = 1; i < result; i++)
- info.serial_number[i - 1] = buffer[i];
- info.serial_number[i - 1] = 0;
- }
- }
-
- for (i = 0; i < cfg->bNumInterfaces; i++) {
- if (check(ptr, len, USB_DT_INTERFACE, USB_DT_INTERFACE_SIZE))
- return -1;
- ifc = (void *) ptr;
- len -= ifc->bLength;
- ptr += ifc->bLength;
-
- in = -1;
- out = -1;
- info.ifc_class = ifc->bInterfaceClass;
- info.ifc_subclass = ifc->bInterfaceSubClass;
- info.ifc_protocol = ifc->bInterfaceProtocol;
-
- for (e = 0; e < ifc->bNumEndpoints; e++) {
- if (check(ptr, len, USB_DT_ENDPOINT,
- USB_DT_ENDPOINT_SIZE)
- )
- return -1;
- ept = (void *) ptr;
- len -= ept->bLength;
- ptr += ept->bLength;
-
- if ((ept->bmAttributes & 0x03) != 0x02)
- continue;
-
- if (ept->bEndpointAddress & 0x80)
- in = ept->bEndpointAddress;
- else
- out = ept->bEndpointAddress;
- }
-
- info.has_bulk_in = (in != -1);
- info.has_bulk_out = (out != -1);
-
- if (callback(&info) == 0) {
- *ept_in_id = in;
- *ept_out_id = out;
- *ifc_id = ifc->bInterfaceNumber;
- return 0;
- }
- }
-
- return -1;
-}
-
-static struct usb_handle *find_usb_device(
- const char *base, ifc_match_func callback)
-{
- struct usb_handle *usb = 0;
- char busname[64], devname[64];
- char desc[1024];
- int n, in, out, ifc;
-
- DIR *busdir, *devdir;
- struct dirent *de;
- int fd;
- int writable;
-
- busdir = opendir(base);
- if (busdir == 0)
- return 0;
-
- while ((de = readdir(busdir)) && (usb == 0)) {
- if (badname(de->d_name))
- continue;
-
- sprintf(busname, "%s/%s", base, de->d_name);
- devdir = opendir(busname);
- if (devdir == 0)
- continue;
-
- /* DBG("[ scanning %s ]\n", busname); */
- while ((de = readdir(devdir)) && (usb == 0)) {
-
- if (badname(de->d_name))
- continue;
- sprintf(devname, "%s/%s", busname, de->d_name);
-
- /* DBG("[ scanning %s ]\n", devname); */
- writable = 1;
- fd = open(devname, O_RDWR);
- if (fd < 0) {
- /* Check if we have read-only access,
- so we can give a helpful diagnostic
- like "adb devices" does. */
- writable = 0;
- fd = open(devname, O_RDONLY);
- if (fd < 0)
- continue;
- }
-
- n = read(fd, desc, sizeof(desc));
-
- if (filter_usb_device(fd, desc, n, writable,
- callback, &in, &out, &ifc) == 0
- ) {
- usb = calloc(1, sizeof(struct usb_handle));
- strcpy(usb->fname, devname);
- usb->ep_in = in;
- usb->ep_out = out;
- usb->desc = fd;
-
- n = ioctl(fd, USBDEVFS_CLAIMINTERFACE, &ifc);
- if (n != 0) {
- close(fd);
- free(usb);
- usb = 0;
- continue;
- }
- } else
- close(fd);
- }
- closedir(devdir);
- }
- closedir(busdir);
-
- return usb;
-}
-
-int usb_write(struct usb_handle *h, const void *_data, int len)
-{
- unsigned char *data = (unsigned char *) _data;
- unsigned count = 0;
- struct usbdevfs_bulktransfer bulk;
- int n;
-
- if (h->ep_out == 0)
- return -1;
-
- if (len == 0) {
- bulk.ep = h->ep_out;
- bulk.len = 0;
- bulk.data = data;
- bulk.timeout = 0;
-
- n = ioctl(h->desc, USBDEVFS_BULK, &bulk);
- if (n != 0) {
- fprintf(stderr, "ERROR: n = %d, errno = %d (%s)\n",
- n, errno, strerror(errno));
- return -1;
- }
- return 0;
- }
-
- while (len > 0) {
- int xfer;
- xfer = (len > 4096) ? 4096 : len;
-
- bulk.ep = h->ep_out;
- bulk.len = xfer;
- bulk.data = data;
- bulk.timeout = 0;
-
- n = ioctl(h->desc, USBDEVFS_BULK, &bulk);
- if (n != xfer) {
- DBG("ERROR: n = %d, errno = %d (%s)\n",
- n, errno, strerror(errno));
- return -1;
- }
-
- count += xfer;
- len -= xfer;
- data += xfer;
- }
-
- return count;
-}
-
-int usb_read(struct usb_handle *h, void *_data, int len)
-{
- unsigned char *data = (unsigned char *) _data;
- unsigned count = 0;
- struct usbdevfs_bulktransfer bulk;
- int n, retry;
-
- if (h->ep_in == 0)
- return -1;
-
- while (len > 0) {
- int xfer = (len > 4096) ? 4096 : len;
-
- bulk.ep = h->ep_in;
- bulk.len = xfer;
- bulk.data = data;
- bulk.timeout = 0;
- retry = 0;
-
- do {
- DBG("[ usb read %d fd = %d], fname=%s\n",
- xfer, h->desc, h->fname);
- n = ioctl(h->desc, USBDEVFS_BULK, &bulk);
- DBG("[ usb read %d ] = %d, fname=%s, Retry %d\n",
- xfer, n, h->fname, retry);
-
- if (n < 0) {
- DBG1("ERROR: n = %d, errno = %d (%s)\n",
- n, errno, strerror(errno));
- if (++retry > MAX_RETRIES)
- return -1;
- usleep(10000);
- }
- } while (n < 0);
-
- count += n;
- len -= n;
- data += n;
-
- if (n < xfer)
- break;
- }
-
- return count;
-}
-
-void usb_kick(struct usb_handle *h)
-{
- int fd;
-
- fd = h->desc;
- h->desc = -1;
- if (fd >= 0) {
- close(fd);
- DBG("[ usb closed %d ]\n", fd);
- }
-}
-
-int usb_close(struct usb_handle *h)
-{
- int fd;
-
- fd = h->desc;
- h->desc = -1;
- if (fd >= 0) {
- close(fd);
- DBG("[ usb closed %d ]\n", fd);
- }
-
- return 0;
-}
-
-struct usb_handle *usb_open(ifc_match_func callback)
-{
- return find_usb_device("/dev/bus/usb", callback);
-}