summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2022-06-29 09:00:56 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-06-29 09:00:56 +0200
commitbd0e1e5dde37cb927ad9e5d225d55d0cb636a53d (patch)
tree52390373b797d525e283ada7609b22bdc4fe25d2
parent8828e1226981b6a31b12a643768cac63fae3576e (diff)
parent370f346bca176a93d034af2c0021b5da9a6101ad (diff)
downloadbarebox-bd0e1e5dde37cb927ad9e5d225d55d0cb636a53d.tar.gz
barebox-bd0e1e5dde37cb927ad9e5d225d55d0cb636a53d.tar.xz
Merge branch 'for-next/misc'
-rw-r--r--.gitignore2
-rw-r--r--arch/arm/Kconfig4
-rw-r--r--arch/arm/boards/clep7212/Makefile4
-rw-r--r--arch/arm/boards/clep7212/board.c15
-rw-r--r--arch/arm/boards/clep7212/clep7212.c57
-rw-r--r--arch/arm/boards/clep7212/lowlevel.c23
-rw-r--r--arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c1
-rw-r--r--arch/arm/boards/kindle-mx50/board.c3
-rw-r--r--arch/arm/boards/myirtech-x335x/lowlevel.c20
-rw-r--r--arch/arm/boards/vscom-baltos/board.c3
-rw-r--r--arch/arm/boards/zii-imx51-rdu1/board.c2
-rw-r--r--arch/arm/configs/at91sam9n12ek_defconfig5
-rw-r--r--arch/arm/configs/clps711x_defconfig5
-rw-r--r--arch/arm/dts/Makefile1
-rw-r--r--arch/arm/dts/am335x-myirtech-myd.dts7
-rw-r--r--arch/arm/dts/ep7212-clep7212.dts64
-rw-r--r--arch/arm/mach-clps711x/Kconfig9
-rw-r--r--arch/arm/mach-clps711x/Makefile2
-rw-r--r--arch/arm/mach-clps711x/clock.c46
-rw-r--r--arch/arm/mach-clps711x/common.c149
-rw-r--r--arch/arm/mach-clps711x/include/mach/clps711x.h28
-rw-r--r--arch/arm/mach-clps711x/include/mach/debug_ll.h21
-rw-r--r--arch/arm/mach-clps711x/include/mach/devices.h9
-rw-r--r--arch/arm/mach-clps711x/lowlevel.c72
-rw-r--r--arch/arm/mach-clps711x/reset.c29
-rw-r--r--arch/arm/mach-imx/cpu_init.c1
-rw-r--r--arch/arm/mach-imx/imx8m.c1
-rw-r--r--arch/arm/mach-omap/xload.c14
-rw-r--r--arch/arm/mach-stm32mp/ddrctrl.c1
-rw-r--r--arch/sandbox/board/devices.c1
-rw-r--r--arch/sandbox/board/hostfile.c2
-rw-r--r--arch/sandbox/os/common.c1
-rw-r--r--commands/bootm.c1
-rw-r--r--commands/clk.c10
-rw-r--r--commands/crc.c14
-rw-r--r--commands/hwclock.c4
-rw-r--r--commands/loadb.c4
-rw-r--r--commands/loads.c4
-rw-r--r--commands/ls.c10
-rw-r--r--commands/memtester/memtester.c2
-rw-r--r--commands/spd_decode.c3
-rw-r--r--commands/state.c3
-rw-r--r--common/Kconfig5
-rw-r--r--common/block.c8
-rw-r--r--common/bootchooser.c12
-rw-r--r--common/bootsource.c8
-rw-r--r--common/efi/payload/init.c3
-rw-r--r--common/env.c32
-rw-r--r--common/fastboot.c3
-rw-r--r--common/hush.c1
-rw-r--r--common/memory.c21
-rw-r--r--common/menutree.c12
-rw-r--r--common/reset_source.c20
-rw-r--r--common/state/backend_format_raw.c2
-rw-r--r--crypto/rsa.c1
-rw-r--r--drivers/clk/imx/clk-imx6sl.c1
-rw-r--r--drivers/clk/imx/clk-imx6sx.c1
-rw-r--r--drivers/clocksource/clps711x.c7
-rw-r--r--drivers/gpio/gpio-clps711x.c7
-rw-r--r--drivers/mci/mci-core.c33
-rw-r--r--drivers/mtd/nand/nand_s3c24xx.c2
-rw-r--r--drivers/net/cpsw.c1
-rw-r--r--drivers/net/phy/phy.c1
-rw-r--r--drivers/net/rtl8169.c34
-rw-r--r--drivers/net/virtio.c1
-rw-r--r--drivers/nvmem/eeprom_93xx46.c2
-rw-r--r--drivers/nvmem/rmem.c2
-rw-r--r--drivers/of/Makefile1
-rw-r--r--drivers/of/fdt.c11
-rw-r--r--drivers/of/reserved-mem.c71
-rw-r--r--drivers/regulator/fixed.c13
-rw-r--r--drivers/serial/serial_clps711x.c57
-rw-r--r--drivers/serial/serial_ns16550.c1
-rw-r--r--drivers/soc/Makefile4
-rw-r--r--drivers/spi/atmel-quadspi.c2
-rw-r--r--drivers/usb/gadget/fsl_udc.c1
-rw-r--r--drivers/usb/host/ohci-hcd.c1
-rw-r--r--drivers/video/imx-ipu-v3/imx-hdmi.c1
-rw-r--r--drivers/video/imx-ipu-v3/imx-ldb.c1
-rw-r--r--drivers/video/omap.c1
-rw-r--r--drivers/virtio/virtio_pci_common.h1
-rw-r--r--fs/devfs.c7
-rw-r--r--fs/fs.c1
-rw-r--r--fs/legacy.c1
-rw-r--r--fs/nfs.c1
-rw-r--r--fs/pstore/fs.c2
-rw-r--r--fs/pstore/ram_core.c1
-rw-r--r--fs/uimagefs.c1
-rw-r--r--images/Makefile1
-rw-r--r--images/Makefile.clps711x8
-rw-r--r--include/block.h9
-rw-r--r--include/environment.h7
-rw-r--r--include/globalvar.h2
-rw-r--r--include/mci.h2
-rw-r--r--include/of.h16
-rw-r--r--include/reset_source.h7
-rw-r--r--include/soc/imx8m/ddr.h1
-rw-r--r--lib/decompress_unlz4.c1
-rw-r--r--lib/libfile.c3
-rw-r--r--lib/parameter.c8
-rw-r--r--net/dns.c2
-rw-r--r--net/ifup.c1
-rw-r--r--net/nfs.c1
-rw-r--r--scripts/bareboximd.c2
-rw-r--r--scripts/common.c1
-rw-r--r--scripts/kwbimage.c1
-rw-r--r--scripts/stb_image.h4
107 files changed, 697 insertions, 437 deletions
diff --git a/.gitignore b/.gitignore
index 0382202bf7..cb87e9314f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -60,6 +60,8 @@ Module.symvers
# Generated files
Documentation/commands/*.rst
doctrees/
+log/
+makeall_builddir/
# stgit generated dirs
patches-*
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 299e0ab080..8a1d75c19b 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -66,9 +66,13 @@ config ARCH_CLPS711X
select CLKDEV_LOOKUP
select CLOCKSOURCE_CLPS711X
select COMMON_CLK
+ select COMMON_CLK_OF_PROVIDER
select CPU_32v4T
select GPIOLIB
+ select HAS_DEBUG_LL
+ select HAVE_PBL_MULTI_IMAGES
select MFD_SYSCON
+ select RELOCATABLE
config ARCH_DAVINCI
bool "TI Davinci"
diff --git a/arch/arm/boards/clep7212/Makefile b/arch/arm/boards/clep7212/Makefile
index 096120e567..85d92c8a7f 100644
--- a/arch/arm/boards/clep7212/Makefile
+++ b/arch/arm/boards/clep7212/Makefile
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-only
-obj-y += clep7212.o
+obj-y += board.o
lwl-y += lowlevel.o
-bbenv-y += defaultenv-clep7212
+bbenv-$(CONFIG_DEFAULT_ENVIRONMENT) += defaultenv-clep7212
diff --git a/arch/arm/boards/clep7212/board.c b/arch/arm/boards/clep7212/board.c
new file mode 100644
index 0000000000..b3983f2f49
--- /dev/null
+++ b/arch/arm/boards/clep7212/board.c
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+// SPDX-FileCopyrightText: Alexander Shiyan <shc_work@mail.ru>
+
+#include <envfs.h>
+#include <init.h>
+#include <of.h>
+
+static __init int clep7212_init(void)
+{
+ if (of_machine_is_compatible("cirrus,clep7212"))
+ defaultenv_append_directory(defaultenv_clep7212);
+
+ return 0;
+}
+device_initcall(clep7212_init);
diff --git a/arch/arm/boards/clep7212/clep7212.c b/arch/arm/boards/clep7212/clep7212.c
deleted file mode 100644
index 3b497a6bd2..0000000000
--- a/arch/arm/boards/clep7212/clep7212.c
+++ /dev/null
@@ -1,57 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2012 Alexander Shiyan <shc_work@mail.ru>
-
-#include <common.h>
-#include <driver.h>
-#include <envfs.h>
-#include <init.h>
-#include <partition.h>
-#include <io.h>
-#include <linux/sizes.h>
-#include <asm/armlinux.h>
-#include <asm/mmu.h>
-#include <generated/mach-types.h>
-
-#include <mach/clps711x.h>
-#include <mach/devices.h>
-
-static int clps711x_devices_init(void)
-{
- u32 serial_h = 0, serial_l = readl(UNIQID);
- void *cfi_io;
-
- /* Setup Chipselects */
- clps711x_setup_memcfg(0, MEMCFG_WAITSTATE_6_1 | MEMCFG_BUS_WIDTH_16);
- clps711x_setup_memcfg(1, MEMCFG_WAITSTATE_6_1 | MEMCFG_BUS_WIDTH_8);
- clps711x_setup_memcfg(2, MEMCFG_WAITSTATE_8_3 | MEMCFG_BUS_WIDTH_16 |
- MEMCFG_CLKENB);
- clps711x_setup_memcfg(3, MEMCFG_WAITSTATE_7_1 | MEMCFG_BUS_WIDTH_32);
-
- cfi_io = map_io_sections(CS0_BASE, (void *)0x90000000, SZ_32M);
- add_cfi_flash_device(DEVICE_ID_DYNAMIC, (unsigned long)cfi_io, SZ_32M,
- IORESOURCE_MEM);
-
- devfs_add_partition("nor0", 0x00000, SZ_512K, DEVFS_PARTITION_FIXED,
- "self0");
- devfs_add_partition("nor0", SZ_256K, SZ_256K, DEVFS_PARTITION_FIXED,
- "env0");
-
- armlinux_set_architecture(MACH_TYPE_CLEP7212);
- armlinux_set_serial(((u64)serial_h << 32) | serial_l);
-
- defaultenv_append_directory(defaultenv_clep7212);
-
- return 0;
-}
-device_initcall(clps711x_devices_init);
-
-static int clps711x_console_init(void)
-{
- barebox_set_model("Cirrus Logic CLEP7212");
- barebox_set_hostname("clep7212");
-
- clps711x_add_uart(0);
-
- return 0;
-}
-console_initcall(clps711x_console_init);
diff --git a/arch/arm/boards/clep7212/lowlevel.c b/arch/arm/boards/clep7212/lowlevel.c
index 41827dfa16..09f2762fac 100644
--- a/arch/arm/boards/clep7212/lowlevel.c
+++ b/arch/arm/boards/clep7212/lowlevel.c
@@ -1,22 +1,21 @@
// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2012 Alexander Shiyan <shc_work@mail.ru>
+// SPDX-FileCopyrightText: Alexander Shiyan <shc_work@mail.ru>
#include <common.h>
-#include <init.h>
-
-#include <asm/barebox-arm-head.h>
-
+#include <asm/barebox-arm.h>
+#include <linux/sizes.h>
#include <mach/clps711x.h>
-#ifdef CONFIG_CLPS711X_RAISE_CPUFREQ
-# define CLPS711X_CPU_PLL_MULT 50
-#else
-# define CLPS711X_CPU_PLL_MULT 40
-#endif
+extern char __dtb_ep7212_clep7212_start[];
-void __naked __bare_init barebox_arm_reset_vector(uint32_t r0, uint32_t r1, uint32_t r2)
+ENTRY_FUNCTION_WITHSTACK(start_ep7212_clep7212,
+ CS6_BASE + 48 * SZ_1K, r0, r1, r2)
{
+ void *fdt;
+
arm_cpu_lowlevel_init();
- clps711x_barebox_entry(CLPS711X_CPU_PLL_MULT, NULL);
+ fdt = __dtb_ep7212_clep7212_start;
+
+ clps711x_start(fdt + get_runtime_offset());
}
diff --git a/arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c b/arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c
index 14100747e0..350576fa52 100644
--- a/arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c
+++ b/arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c
@@ -25,7 +25,6 @@
#include <mach/clock.h>
#include <mach/mci.h>
#include <mach/iomux.h>
-#include <generated/mach-types.h>
static struct mxs_mci_platform_data mci_pdata = {
.caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED,
diff --git a/arch/arm/boards/kindle-mx50/board.c b/arch/arm/boards/kindle-mx50/board.c
index 8fc5af8320..4cfd68a258 100644
--- a/arch/arm/boards/kindle-mx50/board.c
+++ b/arch/arm/boards/kindle-mx50/board.c
@@ -84,10 +84,9 @@ static char *mac;
static void kindle_rev_init(void)
{
int ret;
- size_t size;
void *buf;
const char userdata[] = "/dev/mmc2.boot0.userdata";
- ret = read_file_2(userdata, &size, &buf, 128);
+ ret = read_file_2(userdata, NULL, &buf, 128);
if (ret && ret != -EFBIG) {
pr_err("Could not read board info from %s\n", userdata);
return;
diff --git a/arch/arm/boards/myirtech-x335x/lowlevel.c b/arch/arm/boards/myirtech-x335x/lowlevel.c
index e867a0be7d..c43761ca23 100644
--- a/arch/arm/boards/myirtech-x335x/lowlevel.c
+++ b/arch/arm/boards/myirtech-x335x/lowlevel.c
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/* SPDX-FileCopyrightText: Alexander Shiyan <shc_work@mail.ru> */
+#include <common.h>
#include <io.h>
#include <asm/barebox-arm-head.h>
#include <asm/barebox-arm.h>
@@ -41,12 +42,13 @@ static const struct am33xx_cmd_control ddr3_cmd_ctrl = {
/* CPU module contains 512MB (2*256MB) DDR3 SDRAM (2*128MB compatible),
* so we configure EMIF for 512MB then detect real size of memory.
*/
-static const struct am33xx_emif_regs ddr3_regs = {
+static struct am33xx_emif_regs ddr3_regs = {
.emif_read_latency = 0x00100007,
.emif_tim1 = 0x0aaad4db,
.emif_tim2 = 0x266b7fda,
.emif_tim3 = 0x501f867f,
.zq_config = 0x50074be4,
+ /* MT41K256M8DA */
.sdram_config = 0x61c05332,
.sdram_config2 = 0x00,
.sdram_ref_ctrl = 0xc30,
@@ -87,6 +89,12 @@ ENTRY_FUNCTION(start_am33xx_myirtech_sram, bootinfo, r1, r2)
am335x_sdram_init(0x18b, &ddr3_cmd_ctrl, &ddr3_regs, &ddr3_data);
+ if (get_ram_size((void *)AM33XX_DRAM_ADDR_SPACE_START, SZ_512M) < SZ_512M) {
+ /* MT41K128M8DA */
+ ddr3_regs.sdram_config = 0x61c04ab2;
+ am335x_sdram_init(0x18b, &ddr3_cmd_ctrl, &ddr3_regs, &ddr3_data);
+ }
+
if (IS_ENABLED(CONFIG_DEBUG_LL)) {
am33xx_uart_soft_reset(IOMEM(AM33XX_UART0_BASE));
am33xx_enable_uart0_pin_mux();
@@ -94,22 +102,16 @@ ENTRY_FUNCTION(start_am33xx_myirtech_sram, bootinfo, r1, r2)
putc_ll('>');
}
- barebox_arm_entry(AM33XX_DRAM_ADDR_SPACE_START, SZ_256M, fdt);
+ am335x_barebox_entry(fdt);
}
ENTRY_FUNCTION(start_am33xx_myirtech_sdram, r0, r1, r2)
{
void *fdt;
- u32 sdram_size;
fdt = __dtb_z_am335x_myirtech_myd_start;
fdt += get_runtime_offset();
- /* Detect 256M/512M module variant */
- __raw_writel(SZ_512M, AM33XX_DRAM_ADDR_SPACE_START + SZ_256M);
- __raw_writel(SZ_256M, AM33XX_DRAM_ADDR_SPACE_START + 0);
- sdram_size = __raw_readl(AM33XX_DRAM_ADDR_SPACE_START + SZ_256M);
-
- barebox_arm_entry(AM33XX_DRAM_ADDR_SPACE_START, sdram_size, fdt);
+ am335x_barebox_entry(fdt);
}
diff --git a/arch/arm/boards/vscom-baltos/board.c b/arch/arm/boards/vscom-baltos/board.c
index 59782d2990..83c7dbc8b0 100644
--- a/arch/arm/boards/vscom-baltos/board.c
+++ b/arch/arm/boards/vscom-baltos/board.c
@@ -85,7 +85,6 @@ static uint8_t get_dip_switch(uint16_t id, uint32_t rev)
static int baltos_read_eeprom(void)
{
struct bsp_vs_hwparam hw_param;
- size_t size;
char *buf, var_buf[32];
int rc;
unsigned char mac_addr[6];
@@ -95,7 +94,7 @@ static int baltos_read_eeprom(void)
return 0;
rc = read_file_2("/dev/eeprom0",
- &size,
+ NULL,
(void *)&buf,
sizeof(hw_param));
if (rc && rc != -EFBIG)
diff --git a/arch/arm/boards/zii-imx51-rdu1/board.c b/arch/arm/boards/zii-imx51-rdu1/board.c
index 42c99ecc1e..0b5271b8de 100644
--- a/arch/arm/boards/zii-imx51-rdu1/board.c
+++ b/arch/arm/boards/zii-imx51-rdu1/board.c
@@ -27,8 +27,6 @@
#include <linux/sizes.h>
#include <linux/nvmem-consumer.h>
-#include <envfs.h>
-
static int zii_rdu1_init(void)
{
const char *hostname;
diff --git a/arch/arm/configs/at91sam9n12ek_defconfig b/arch/arm/configs/at91sam9n12ek_defconfig
index b7c3a4b1f4..ce97ad62dc 100644
--- a/arch/arm/configs/at91sam9n12ek_defconfig
+++ b/arch/arm/configs/at91sam9n12ek_defconfig
@@ -4,12 +4,12 @@ CONFIG_BAREBOX_MAX_IMAGE_SIZE=0x40000
CONFIG_AEABI=y
CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
CONFIG_PBL_IMAGE=y
+CONFIG_IMAGE_COMPRESSION_XZKERN=y
CONFIG_MMU=y
CONFIG_MALLOC_SIZE=0xa00000
CONFIG_EXPERIMENTAL=y
CONFIG_MALLOC_TLSF=y
CONFIG_PROMPT="9G20-EK:"
-CONFIG_GLOB=y
CONFIG_PROMPT_HUSH_PS2="y"
CONFIG_HUSH_FANCY_PROMPT=y
CONFIG_CMDLINE_EDITING=y
@@ -60,9 +60,6 @@ CONFIG_MTD=y
# CONFIG_MTD_OOB_DEVICE is not set
CONFIG_MTD_M25P80=y
CONFIG_NAND=y
-# CONFIG_NAND_ECC_SOFT is not set
-# CONFIG_NAND_ECC_HW_SYNDROME is not set
-# CONFIG_NAND_ECC_HW_NONE is not set
CONFIG_NAND_ATMEL=y
CONFIG_NAND_ATMEL_PMECC=y
CONFIG_USB_GADGET=y
diff --git a/arch/arm/configs/clps711x_defconfig b/arch/arm/configs/clps711x_defconfig
index d9eab565b9..684ae79e22 100644
--- a/arch/arm/configs/clps711x_defconfig
+++ b/arch/arm/configs/clps711x_defconfig
@@ -1,8 +1,8 @@
CONFIG_ARCH_CLPS711X=y
+CONFIG_CLPS711X_RAISE_CPUFREQ=y
CONFIG_AEABI=y
CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
# CONFIG_MEMINFO is not set
-CONFIG_PBL_IMAGE=y
CONFIG_MMU=y
CONFIG_EXPERIMENTAL=y
CONFIG_BAUDRATE=57600
@@ -28,6 +28,8 @@ CONFIG_CMD_TIMEOUT=y
CONFIG_CMD_CRC=y
CONFIG_CMD_CRC_CMP=y
CONFIG_CMD_FLASH=y
+CONFIG_OFDEVICE=y
+CONFIG_OF_BAREBOX_DRIVERS=y
# CONFIG_SPI is not set
CONFIG_MTD=y
CONFIG_DRIVER_CFI=y
@@ -36,6 +38,7 @@ CONFIG_DRIVER_CFI=y
CONFIG_DISK=y
CONFIG_DISK_WRITE=y
CONFIG_DISK_INTF_PLATFORM_IDE=y
+# CONFIG_PINCTRL is not set
CONFIG_FS_CRAMFS=y
CONFIG_FS_FAT=y
CONFIG_FS_FAT_LFN=y
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 46e5e67672..d67d10bde8 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -8,6 +8,7 @@ lwl-$(CONFIG_MACH_ADVANTECH_ROM_742X) += imx6dl-advantech-rom-7421.dtb.o
lwl-$(CONFIG_MACH_AFI_GF) += am335x-afi-gf.dtb.o
lwl-$(CONFIG_MACH_BEAGLEBONE) += am335x-bone.dtb.o am335x-boneblack.dtb.o am335x-bone-common.dtb.o
lwl-$(CONFIG_MACH_CANON_A1100) += canon-a1100.dtb.o
+lwl-$(CONFIG_MACH_CLEP7212) += ep7212-clep7212.dtb.o
lwl-$(CONFIG_MACH_CM_FX6) += imx6dl-cm-fx6.dtb.o imx6q-cm-fx6.dtb.o imx6q-utilite.dtb.o
lwl-$(CONFIG_MACH_DFI_FS700_M60) += imx6q-dfi-fs700-m60-6q.dtb.o imx6dl-dfi-fs700-m60-6s.dtb.o
lwl-$(CONFIG_MACH_DUCKBILL) += imx28-duckbill.dtb.o
diff --git a/arch/arm/dts/am335x-myirtech-myd.dts b/arch/arm/dts/am335x-myirtech-myd.dts
index 6ec65e533d..1ea0f2a440 100644
--- a/arch/arm/dts/am335x-myirtech-myd.dts
+++ b/arch/arm/dts/am335x-myirtech-myd.dts
@@ -6,6 +6,13 @@
#include <arm/am335x-myirtech-myd.dts>
/ {
+ aliases {
+ gpio0 = &gpio0;
+ gpio1 = &gpio1;
+ gpio2 = &gpio2;
+ gpio3 = &gpio3;
+ };
+
chosen {
environment {
compatible = "barebox,environment";
diff --git a/arch/arm/dts/ep7212-clep7212.dts b/arch/arm/dts/ep7212-clep7212.dts
new file mode 100644
index 0000000000..84c5e79548
--- /dev/null
+++ b/arch/arm/dts/ep7212-clep7212.dts
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: GPL-2.0+
+/* Author: Alexander Shiyan <shc_work@mail.ru> */
+
+#include <arm/ep7211.dtsi>
+
+/ {
+ model = "Cirrus Logic EP7212";
+ compatible = "cirrus,clep7212", "cirrus,ep7212", "cirrus,ep7209";
+
+ memory@c0000000 {
+ device_type = "memory";
+ reg = <0xc0000000 0x02000000>;
+ };
+
+ chosen {
+ stdout-path = &uart1;
+
+ environment {
+ compatible = "barebox,environment";
+ device-path = &flash, "partname:env";
+ };
+ };
+};
+
+&bus {
+ /* Setup Memory Timings */
+ /* CS0 = WAITSTATE_6_1 | BUS_WIDTH_16 */
+ /* CS1 = WAITSTATE_6_1 | BUS_WIDTH_8 */
+ /* CS2 = WAITSTATE_8_3 | BUS_WIDTH_16 | CLKENB */
+ /* CS3 = WAITSTATE_7_1 | BUS_WIDTH_32 */
+ barebox,ep7209-memcfg1 = <0x25802b28>;
+
+ flash: nor@0,0 {
+ compatible = "cfi-flash";
+ reg = <0 0x00000000 0x02000000>;
+ bank-width = <2>;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "boot";
+ reg = <0x00000 0x80000>;
+ };
+
+ partition@80000 {
+ label = "env";
+ reg = <0x80000 0x40000>;
+ };
+
+ partition@c0000 {
+ label = "kernel";
+ reg = <0xc0000 0x340000>;
+ };
+
+ partition@400000 {
+ label = "root";
+ reg = <0x400000 0>;
+ };
+ };
+ };
+};
diff --git a/arch/arm/mach-clps711x/Kconfig b/arch/arm/mach-clps711x/Kconfig
index 52cf8468c0..6cf6bc37a2 100644
--- a/arch/arm/mach-clps711x/Kconfig
+++ b/arch/arm/mach-clps711x/Kconfig
@@ -16,7 +16,6 @@ menu "CLPS711X specific settings"
config CLPS711X_RAISE_CPUFREQ
bool "Raise CPU frequency to 90 MHz"
- depends on MACH_CLEP7212
help
Raise CPU frequency to 90 MHz. This operation can be performed
only for devices which allow to operate at 90 MHz.
@@ -24,12 +23,4 @@ config CLPS711X_RAISE_CPUFREQ
endmenu
-config ARCH_TEXT_BASE
- hex
- default 0xc0740000 if MACH_CLEP7212
-
-config BAREBOX_MAX_IMAGE_SIZE
- hex
- default 0x00080000 if MACH_CLEP7212
-
endif
diff --git a/arch/arm/mach-clps711x/Makefile b/arch/arm/mach-clps711x/Makefile
index 4d5950d9b5..871c5f7e9c 100644
--- a/arch/arm/mach-clps711x/Makefile
+++ b/arch/arm/mach-clps711x/Makefile
@@ -1,4 +1,4 @@
# SPDX-License-Identifier: GPL-2.0-only
-obj-y += clock.o devices.o reset.o
+obj-y += clock.o common.o
lwl-y += lowlevel.o
diff --git a/arch/arm/mach-clps711x/clock.c b/arch/arm/mach-clps711x/clock.c
index 2c5137c582..8674b8c801 100644
--- a/arch/arm/mach-clps711x/clock.c
+++ b/arch/arm/mach-clps711x/clock.c
@@ -1,11 +1,5 @@
-/*
- * Copyright (C) 2012-2016 Alexander Shiyan <shc_work@mail.ru>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- */
+// SPDX-License-Identifier: GPL-2.0-or-later
+// SPDX-FileCopyrightText: Alexander Shiyan <shc_work@mail.ru>
#include <common.h>
#include <init.h>
@@ -21,13 +15,15 @@
#define CLPS711X_EXT_FREQ 13000000
static struct clk *clks[CLPS711X_CLK_MAX];
+static struct clk_onecell_data clk_data;
-static struct clk_div_table tdiv_tbl[] = {
+static const struct clk_div_table tdiv_tbl[] = {
{ .val = 0, .div = 256, },
{ .val = 1, .div = 1, },
+ { }
};
-static __init int clps711x_clk_init(void)
+static int clps711x_clk_probe(struct device_d *dev)
{
unsigned int f_cpu, f_bus, f_uart, f_timer_ref, pll;
u32 tmp;
@@ -50,7 +46,7 @@ static __init int clps711x_clk_init(void)
f_bus = 36864000 / 2;
}
- f_uart = f_bus / 10;
+ f_uart = DIV_ROUND_CLOSEST(f_bus, 10);
if (tmp & SYSFLG2_CKMODE) {
tmp = readw(SYSCON2);
@@ -72,23 +68,25 @@ static __init int clps711x_clk_init(void)
clks[CLPS711X_CLK_UART] = clk_fixed("uart", f_uart);
clks[CLPS711X_CLK_TIMERREF] = clk_fixed("timer_ref", f_timer_ref);
clks[CLPS711X_CLK_TIMER1] = clk_divider_table("timer1", "timer_ref", 0,
- IOMEM(SYSCON1), 5, 1, tdiv_tbl, ARRAY_SIZE(tdiv_tbl));
+ IOMEM(SYSCON1), 5, 1, tdiv_tbl, 0);
clks[CLPS711X_CLK_TIMER2] = clk_divider_table("timer2", "timer_ref", 0,
- IOMEM(SYSCON1), 7, 1, tdiv_tbl, ARRAY_SIZE(tdiv_tbl));
+ IOMEM(SYSCON1), 7, 1, tdiv_tbl, 0);
- clkdev_add_physbase(clks[CLPS711X_CLK_UART], UARTDR1, NULL);
- clkdev_add_physbase(clks[CLPS711X_CLK_UART], UARTDR2, NULL);
- clkdev_add_physbase(clks[CLPS711X_CLK_TIMER2], TC2D, NULL);
+ clk_data.clks = clks;
+ clk_data.clk_num = CLPS711X_CLK_MAX;
+ of_clk_add_provider(dev->device_node, of_clk_src_onecell_get, &clk_data);
return 0;
}
-postcore_initcall(clps711x_clk_init);
-static __init int clps711x_core_init(void)
-{
- add_generic_device("clps711x-cs", DEVICE_ID_SINGLE, NULL,
- TC2D, SZ_2, IORESOURCE_MEM, NULL);
+static const struct of_device_id __maybe_unused clps711x_clk_dt_ids[] = {
+ { .compatible = "cirrus,ep7209-clk", },
+ { }
+};
- return 0;
-}
-coredevice_initcall(clps711x_core_init);
+static struct driver_d clps711x_clk_driver = {
+ .probe = clps711x_clk_probe,
+ .name = "clps711x-clk",
+ .of_compatible = DRV_OF_COMPAT(clps711x_clk_dt_ids),
+};
+postcore_platform_driver(clps711x_clk_driver);
diff --git a/arch/arm/mach-clps711x/common.c b/arch/arm/mach-clps711x/common.c
new file mode 100644
index 0000000000..c0b817872d
--- /dev/null
+++ b/arch/arm/mach-clps711x/common.c
@@ -0,0 +1,149 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+// SPDX-FileCopyrightText: Alexander Shiyan <shc_work@mail.ru>
+
+#include <common.h>
+#include <driver.h>
+#include <restart.h>
+#include <asm/io.h>
+#include <asm/mmu.h>
+#include <mach/clps711x.h>
+
+#define CLPS711X_MAP_ADDR 0x90000000
+
+static u32 remap_size = 0;
+
+static void __noreturn clps711x_restart(struct restart_handler *rst)
+{
+ shutdown_barebox();
+
+ asm("mov pc, #0");
+
+ hang();
+}
+
+static __init int is_clps711x_compatible(void)
+{
+ return of_machine_is_compatible("cirrus,ep7209");
+}
+
+static __init int clps711x_init(void)
+{
+ char *serial;
+
+ if (!is_clps711x_compatible())
+ return 0;
+
+ restart_handler_register_fn("vector", clps711x_restart);
+
+ serial = basprintf("%08x%08x", 0, readl(UNIQID));
+
+ barebox_set_serial_number(serial);
+
+ free(serial);
+
+ return 0;
+}
+postcore_initcall(clps711x_init);
+
+static int __init clps711x_bus_map(void)
+{
+ if (is_clps711x_compatible() && remap_size)
+ map_io_sections(0, (void *)CLPS711X_MAP_ADDR, remap_size);
+
+ return 0;
+}
+postmmu_initcall(clps711x_bus_map);
+
+/* Scan for devices that start at zero address and maps them
+ * to a different unused address.
+ * To start the kernel, a fixup is used that rewrites the address
+ * of the patched device to its original state.
+ */
+
+static void clps711x_bus_patch(struct device_node *node,
+ u32 compare, u32 change)
+{
+ const __be32 *ranges;
+ int rsize;
+
+ ranges = of_get_property(node, "ranges", &rsize);
+
+ if (ranges) {
+ int banks = rsize / (sizeof(u32) * 4);
+ __be32 *fixed, *fixedptr;
+
+ fixed = xmalloc(rsize);
+ fixedptr = fixed;
+
+ while (banks--) {
+ u32 bank, cell, addr, size;
+
+ bank = be32_to_cpu(*ranges++);
+ cell = be32_to_cpu(*ranges++);
+ addr = be32_to_cpu(*ranges++);
+ size = be32_to_cpu(*ranges++);
+
+ if (addr == compare) {
+ addr = change;
+ remap_size = size;
+ }
+
+ *fixedptr++ = cpu_to_be32(bank);
+ *fixedptr++ = cpu_to_be32(cell);
+ *fixedptr++ = cpu_to_be32(addr);
+ *fixedptr++ = cpu_to_be32(size);
+ }
+
+ of_set_property(node, "ranges", fixed, rsize, 0);
+
+ free(fixed);
+ }
+}
+
+static int clps711x_bus_fixup(struct device_node *root, void *context)
+{
+ struct device_node *node = context;
+
+ if (remap_size)
+ clps711x_bus_patch(node, CLPS711X_MAP_ADDR, 0);
+
+ return 0;
+}
+
+static int clps711x_bus_probe(struct device_d *dev)
+{
+ u32 mcfg;
+
+ /* Setup bus timings */
+ if (!of_property_read_u32(dev->device_node,
+ "barebox,ep7209-memcfg1", &mcfg))
+ writel(mcfg, MEMCFG1);
+ if (!of_property_read_u32(dev->device_node,
+ "barebox,ep7209-memcfg2", &mcfg))
+ writel(mcfg, MEMCFG2);
+
+ clps711x_bus_patch(dev->device_node, 0, CLPS711X_MAP_ADDR);
+
+ of_platform_populate(dev->device_node, NULL, dev);
+
+ of_register_fixup(clps711x_bus_fixup, dev->device_node);
+
+ return 0;
+}
+
+static const struct of_device_id __maybe_unused clps711x_bus_dt_ids[] = {
+ { .compatible = "cirrus,ep7209-bus", },
+ { }
+};
+
+static struct driver_d clps711x_bus_driver = {
+ .name = "clps711x-bus",
+ .probe = clps711x_bus_probe,
+ .of_compatible = DRV_OF_COMPAT(clps711x_bus_dt_ids),
+};
+
+static int __init clps711x_bus_init(void)
+{
+ return platform_driver_register(&clps711x_bus_driver);
+}
+core_initcall(clps711x_bus_init);
diff --git a/arch/arm/mach-clps711x/include/mach/clps711x.h b/arch/arm/mach-clps711x/include/mach/clps711x.h
index 957b2b8477..9aef7f3fd3 100644
--- a/arch/arm/mach-clps711x/include/mach/clps711x.h
+++ b/arch/arm/mach-clps711x/include/mach/clps711x.h
@@ -1,13 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
/*
- * Hardware definitions for Cirrus Logic CLPS711X
- *
- * Copyright (C) 2000 Deep Blue Solutions Ltd.
- * Copyright (C) 2012 Alexander Shiyan <shc_work@mail.ru>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * Copyright (C) 2000 Deep Blue Solutions Ltd.
+ * Copyright (C) 2012-2022 Alexander Shiyan <shc_work@mail.ru>
*/
#ifndef __MACH_CLPS711X_H
@@ -159,6 +153,10 @@
#define SYSCON2_CLKENSL (1 << 13)
#define SYSCON2_BUZFREQ (1 << 14)
+#define SYSCON_UARTEN (1 << 8)
+#define SYSFLG_UBUSY (1 << 11)
+#define SYSFLG_UTXFF (1 << 23)
+
#define SYNCIO_FRMLEN(x) (((x) & 0x1f) << 8)
#define SYNCIO_SMCKEN (1 << 13)
#define SYNCIO_TXFRMEN (1 << 14)
@@ -247,6 +245,16 @@
#define MEMCFG_WAITSTATE_2_0 (14 << 2)
#define MEMCFG_WAITSTATE_1_0 (15 << 2)
-void clps711x_barebox_entry(u32, void *);
+#define UBRLCR_BREAK (1 << 12)
+#define UBRLCR_PRTEN (1 << 13)
+#define UBRLCR_EVENPRT (1 << 14)
+#define UBRLCR_XSTOP (1 << 15)
+#define UBRLCR_FIFOEN (1 << 16)
+#define UBRLCR_WRDLEN5 (0 << 17)
+#define UBRLCR_WRDLEN6 (1 << 17)
+#define UBRLCR_WRDLEN7 (2 << 17)
+#define UBRLCR_WRDLEN8 (3 << 17)
+
+void clps711x_start(void *);
#endif
diff --git a/arch/arm/mach-clps711x/include/mach/debug_ll.h b/arch/arm/mach-clps711x/include/mach/debug_ll.h
new file mode 100644
index 0000000000..342bb7628a
--- /dev/null
+++ b/arch/arm/mach-clps711x/include/mach/debug_ll.h
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+// SPDX-FileCopyrightText: Alexander Shiyan <shc_work@mail.ru>
+
+#ifndef __MACH_DEBUG_LL_H__
+#define __MACH_DEBUG_LL_H__
+
+#include <asm/io.h>
+#include <mach/clps711x.h>
+
+static inline void PUTC_LL(char c)
+{
+ do {
+ } while (readl(SYSFLG1) & SYSFLG_UTXFF);
+
+ writew(c, UARTDR1);
+
+ do {
+ } while (readl(SYSFLG1) & SYSFLG_UBUSY);
+}
+
+#endif
diff --git a/arch/arm/mach-clps711x/include/mach/devices.h b/arch/arm/mach-clps711x/include/mach/devices.h
deleted file mode 100644
index 77c43be25c..0000000000
--- a/arch/arm/mach-clps711x/include/mach/devices.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-
-#ifndef __MACH_DEVICES_H
-#define __MACH_DEVICES_H
-
-void clps711x_setup_memcfg(int bank, u32 val);
-void clps711x_add_uart(unsigned int id);
-
-#endif
diff --git a/arch/arm/mach-clps711x/lowlevel.c b/arch/arm/mach-clps711x/lowlevel.c
index 35b8b35e87..608f0778d7 100644
--- a/arch/arm/mach-clps711x/lowlevel.c
+++ b/arch/arm/mach-clps711x/lowlevel.c
@@ -1,25 +1,31 @@
-/*
- * Copyright (C) 2012 Alexander Shiyan <shc_work@mail.ru>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- */
+// SPDX-License-Identifier: GPL-2.0-or-later
+// SPDX-FileCopyrightText: Alexander Shiyan <shc_work@mail.ru>
+#include <asm/io.h>
+#include <asm/barebox-arm.h>
#include <common.h>
-#include <init.h>
+#include <debug_ll.h>
#include <linux/sizes.h>
+#include <mach/clps711x.h>
-#include <asm/io.h>
-#include <asm/barebox-arm.h>
-#include <asm/barebox-arm-head.h>
+#define DEBUG_LL_BAUDRATE (57600)
-#include <mach/clps711x.h>
+static inline void setup_uart(const u32 bus_speed)
+{
+ u32 baud_base = DIV_ROUND_CLOSEST(bus_speed, 10);
+ u32 baud_divisor =
+ DIV_ROUND_CLOSEST(baud_base, DEBUG_LL_BAUDRATE * 16) - 1;
+
+ writel(baud_divisor | UBRLCR_FIFOEN | UBRLCR_WRDLEN8, UBRLCR1);
+ writel(0, STFCLR);
+ writel(SYSCON_UARTEN, SYSCON1);
-void __naked __bare_init clps711x_barebox_entry(u32 pllmult, void *data)
+ putc_ll('>');
+}
+
+void clps711x_start(void *fdt)
{
- u32 cpu, bus;
+ u32 bus, pll;
/* Check if we running from external 13 MHz clock */
if (!(readl(SYSFLG2) & SYSFLG2_CKMODE)) {
@@ -27,24 +33,17 @@ void __naked __bare_init clps711x_barebox_entry(u32 pllmult, void *data)
writel(SYSCON3_CLKCTL0 | SYSCON3_CLKCTL1, SYSCON3);
asm("nop");
- /* Check valid multiplier, default to 74 MHz */
- if ((pllmult < 20) || (pllmult > 50))
- pllmult = 40;
+ if (IS_ENABLED(CONFIG_CLPS711X_RAISE_CPUFREQ)) {
+ /* Setup PLL to 92160000 Hz */
+ writel(50 << 24, PLLW);
+ asm("nop");
+ }
- /* Setup PLL */
- writel(pllmult << 24, PLLW);
- asm("nop");
-
- /* Check for old CPUs without PLL */
- if ((readl(PLLR) >> 24) != pllmult)
- cpu = 73728000;
- else
- cpu = pllmult * 3686400;
-
- if (cpu >= 36864000)
- bus = cpu / 2;
+ pll = readl(PLLR) >> 24;
+ if (pll)
+ bus = (pll * 3686400) / 4;
else
- bus = 36864000 / 2;
+ bus = 73728000 / 4;
} else {
bus = 13000000;
/* Setup bus wait state scaling factor to 1 */
@@ -52,6 +51,13 @@ void __naked __bare_init clps711x_barebox_entry(u32 pllmult, void *data)
asm("nop");
}
+
+ /* Disable UART, IrDa, LCD */
+ writel(0, SYSCON1);
+
+ if (IS_ENABLED(CONFIG_DEBUG_LL))
+ setup_uart(bus);
+
/* CLKEN select, SDRAM width=32 */
writel(SYSCON2_CLKENSL, SYSCON2);
@@ -62,12 +68,10 @@ void __naked __bare_init clps711x_barebox_entry(u32 pllmult, void *data)
/* Setup Refresh Rate (64ms 8K Blocks) */
writel((64 * bus) / (8192 * 1000), SDRFPR);
- /* Disable UART, IrDa, LCD */
- writel(0, SYSCON1);
/* Disable PWM */
writew(0, PMPCON);
/* Disable LED flasher */
writew(0, LEDFLSH);
- barebox_arm_entry(SDRAM0_BASE, SZ_8M, data);
+ barebox_arm_entry(SDRAM0_BASE, SZ_8M, fdt);
}
diff --git a/arch/arm/mach-clps711x/reset.c b/arch/arm/mach-clps711x/reset.c
deleted file mode 100644
index 90ddb8f5d2..0000000000
--- a/arch/arm/mach-clps711x/reset.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2012 Alexander Shiyan <shc_work@mail.ru>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- */
-
-#include <common.h>
-#include <init.h>
-#include <restart.h>
-
-static void __noreturn clps711x_restart_soc(struct restart_handler *rst)
-{
- shutdown_barebox();
-
- asm("mov pc, #0");
-
- hang();
-}
-
-static int restart_register_feature(void)
-{
- restart_handler_register_fn("vector", clps711x_restart_soc);
-
- return 0;
-}
-coredevice_initcall(restart_register_feature);
diff --git a/arch/arm/mach-imx/cpu_init.c b/arch/arm/mach-imx/cpu_init.c
index 559692c765..ea36215419 100644
--- a/arch/arm/mach-imx/cpu_init.c
+++ b/arch/arm/mach-imx/cpu_init.c
@@ -10,7 +10,6 @@
#include <mach/imx7-regs.h>
#include <mach/imx8mq-regs.h>
#include <mach/imx8m-ccm-regs.h>
-#include <common.h>
#include <io.h>
#include <asm/syscounter.h>
#include <asm/system.h>
diff --git a/arch/arm/mach-imx/imx8m.c b/arch/arm/mach-imx/imx8m.c
index 6b7cdac541..8b275bd6f6 100644
--- a/arch/arm/mach-imx/imx8m.c
+++ b/arch/arm/mach-imx/imx8m.c
@@ -13,7 +13,6 @@
#include <mach/ocotp.h>
#include <mach/imx8mp-regs.h>
#include <mach/imx8mq-regs.h>
-#include <mach/imx8m-ccm-regs.h>
#include <soc/imx8m/clk-early.h>
#include <linux/iopoll.h>
diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
index 6d3704b8cf..6a02e2b589 100644
--- a/arch/arm/mach-omap/xload.c
+++ b/arch/arm/mach-omap/xload.c
@@ -115,7 +115,6 @@ static void *omap_xload_boot_mmc(void)
{
int ret;
void *buf;
- int len;
const char *diskdev;
char *partname;
@@ -137,9 +136,9 @@ static void *omap_xload_boot_mmc(void)
free(partname);
- buf = read_file("/barebox.bin", &len);
+ buf = read_file("/barebox.bin", NULL);
if (!buf)
- buf = read_file("/boot/barebox.bin", &len);
+ buf = read_file("/boot/barebox.bin", NULL);
if (!buf) {
printf("could not read barebox.bin from sd card\n");
return NULL;
@@ -156,7 +155,6 @@ static void *omap_xload_boot_spi(struct omap_barebox_part *part)
static void *omap4_xload_boot_usb(void){
int ret;
void *buf;
- int len;
ret = mount("omap4_usbboot", "omap4_usbbootfs", "/", NULL);
if (ret) {
@@ -164,7 +162,7 @@ static void *omap4_xload_boot_usb(void){
return NULL;
}
- buf = read_file("/barebox.bin", &len);
+ buf = read_file("/barebox.bin", NULL);
if (!buf)
printf("could not read barebox.bin from omap4_usbbootfs\n");
@@ -175,7 +173,6 @@ static void *omap_serial_boot(void){
struct console_device *cdev;
int ret;
void *buf;
- int len;
int fd;
/* need temporary place to store file */
@@ -203,7 +200,7 @@ static void *omap_serial_boot(void){
return NULL;
}
- buf = read_file("/barebox.bin", &len);
+ buf = read_file("/barebox.bin", NULL);
if (!buf)
printf("could not read barebox.bin from serial\n");
@@ -216,7 +213,6 @@ static void *am33xx_net_boot(void)
{
void *buf = NULL;
int err;
- int len;
struct dhcp_req_param dhcp_param;
const char *bootfile;
IPaddr_t ip;
@@ -276,7 +272,7 @@ static void *am33xx_net_boot(void)
file = basprintf("%s/%s", TFTP_MOUNT, bootfile);
- buf = read_file(file, &len);
+ buf = read_file(file, NULL);
if (!buf)
printf("could not read %s.\n", bootfile);
diff --git a/arch/arm/mach-stm32mp/ddrctrl.c b/arch/arm/mach-stm32mp/ddrctrl.c
index ed211cf58e..31bddba764 100644
--- a/arch/arm/mach-stm32mp/ddrctrl.c
+++ b/arch/arm/mach-stm32mp/ddrctrl.c
@@ -5,7 +5,6 @@
#include <common.h>
#include <init.h>
-#include <mach/stm32.h>
#include <mach/ddr_regs.h>
#include <mach/entry.h>
#include <mach/stm32.h>
diff --git a/arch/sandbox/board/devices.c b/arch/sandbox/board/devices.c
index 26152a8b90..f7305a8ead 100644
--- a/arch/sandbox/board/devices.c
+++ b/arch/sandbox/board/devices.c
@@ -6,7 +6,6 @@
#include <common.h>
#include <driver.h>
-#include <mach/linux.h>
#include <init.h>
#include <mach/linux.h>
#include <asm/io.h>
diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c
index 7df69f8cfc..52165adec8 100644
--- a/arch/sandbox/board/hostfile.c
+++ b/arch/sandbox/board/hostfile.c
@@ -26,8 +26,6 @@
#include <mach/hostfile.h>
#include <xfuncs.h>
-#include <linux/err.h>
-
struct hf_priv {
union {
struct block_device blk;
diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index e36e3972bc..2878eda29e 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -40,7 +40,6 @@
#include <sys/ioctl.h>
#include <linux/fs.h>
#include <sys/time.h>
-#include <signal.h>
/*
* ...except the ones needed to connect with barebox
*/
diff --git a/commands/bootm.c b/commands/bootm.c
index f54a4827eb..95d267135c 100644
--- a/commands/bootm.c
+++ b/commands/bootm.c
@@ -17,7 +17,6 @@
#include <fs.h>
#include <errno.h>
#include <bootm.h>
-#include <of.h>
#include <rtc.h>
#include <init.h>
#include <of.h>
diff --git a/commands/clk.c b/commands/clk.c
index dfbc7c988f..b1741b9da4 100644
--- a/commands/clk.c
+++ b/commands/clk.c
@@ -139,13 +139,9 @@ static int do_clk_get_rate(int argc, char *argv[])
rate = clk_get_rate(clk);
- if (variable_name) {
- char *t;
-
- t = basprintf("%lu", rate);
- setenv(variable_name, t);
- free(t);
- } else
+ if (variable_name)
+ pr_setenv(variable_name, "%lu", rate);
+ else
printf("%lu\n", rate);
return COMMAND_SUCCESS;
diff --git a/commands/crc.c b/commands/crc.c
index 80ecf7fe29..23ffd4360b 100644
--- a/commands/crc.c
+++ b/commands/crc.c
@@ -83,17 +83,11 @@ static int do_crc(int argc, char *argv[])
printf("CRC32 for %s 0x%08lx ... 0x%08lx ==> 0x%08lx",
filename, (ulong)start, (ulong)start + total - 1, crc);
- if (crcvarname) {
- char *crcstr = basprintf("0x%lx", crc);
- setenv(crcvarname, crcstr);
- kfree(crcstr);
- }
+ if (crcvarname)
+ pr_setenv(crcvarname, "0x%lx", crc);
- if (sizevarname) {
- char *sizestr = basprintf("0x%lx", total);
- setenv(sizevarname, sizestr);
- kfree(sizestr);
- }
+ if (sizevarname)
+ pr_setenv(sizevarname, "0x%lx", total);
#ifdef CONFIG_CMD_CRC_CMP
if (vfilename) {
diff --git a/commands/hwclock.c b/commands/hwclock.c
index abb0500e6a..c594e070ac 100644
--- a/commands/hwclock.c
+++ b/commands/hwclock.c
@@ -153,11 +153,9 @@ static int do_hwclock(int argc, char *argv[])
if (env_name) {
unsigned long time;
- char t[12];
rtc_tm_to_time(&tm, &time);
- snprintf(t, 12, "%lu", time);
- setenv(env_name, t);
+ pr_setenv(env_name, "%lu", time);
} else {
printf("%s\n", time_str(&tm));
}
diff --git a/commands/loadb.c b/commands/loadb.c
index 17d3af84b5..7ab989f459 100644
--- a/commands/loadb.c
+++ b/commands/loadb.c
@@ -542,7 +542,6 @@ packet_error:
static ulong load_serial_bin(void)
{
int size, i;
- char buf[32];
/* Try to allocate the buffer we shall write to files */
write_buffer = malloc(MAX_WRITE_BUFFER);
@@ -576,8 +575,7 @@ static ulong load_serial_bin(void)
write_idx = 0;
}
printf("## Total Size = 0x%08x = %d Bytes\n", size, size);
- sprintf(buf, "%X", size);
- setenv("filesize", buf);
+ pr_setenv("filesize", "%X", size);
err_quit:
free(write_buffer);
diff --git a/commands/loads.c b/commands/loads.c
index 8260673c51..7c5df31251 100644
--- a/commands/loads.c
+++ b/commands/loads.c
@@ -65,7 +65,6 @@ static ulong load_serial(ulong offset)
int type; /* return code for record type */
ulong addr; /* load address from S-Record */
ulong size; /* number of bytes transferred */
- char buf[32];
ulong store_addr;
ulong start_addr = ~0;
ulong end_addr = 0;
@@ -100,8 +99,7 @@ static ulong load_serial(ulong offset)
"## Total Size = 0x%08lX = %ld Bytes\n",
start_addr, end_addr, size, size
);
- sprintf(buf, "%lX", size);
- setenv("filesize", buf);
+ pr_setenv("filesize", "%lX", size);
return addr;
case SREC_START:
break;
diff --git a/commands/ls.c b/commands/ls.c
index bedf2e1c42..1192aed971 100644
--- a/commands/ls.c
+++ b/commands/ls.c
@@ -63,10 +63,10 @@ int ls(const char *path, ulong flags)
if (stat(path, &s))
return -errno;
- if (flags & LS_SHOWARG && s.st_mode & S_IFDIR)
+ if (flags & LS_SHOWARG && S_ISDIR(s.st_mode))
printf("%s:\n", path);
- if (!(s.st_mode & S_IFDIR)) {
+ if (!S_ISDIR(s.st_mode)) {
ls_one(path, path);
return 0;
}
@@ -112,7 +112,7 @@ int ls(const char *path, ulong flags)
continue;
}
- if (s.st_mode & S_IFDIR)
+ if (S_ISDIR(s.st_mode))
ls(tmp, flags);
}
@@ -171,7 +171,7 @@ static int do_ls(int argc, char *argv[])
continue;
}
- if (!(s.st_mode & S_IFDIR)) {
+ if (!S_ISDIR(s.st_mode)) {
if (flags & LS_COLUMN)
string_list_add_sorted(&sl, argv[o]);
else
@@ -197,7 +197,7 @@ static int do_ls(int argc, char *argv[])
continue;
}
- if (s.st_mode & S_IFDIR) {
+ if (S_ISDIR(s.st_mode)) {
ret = ls(argv[o], flags);
if (ret) {
perror("ls");
diff --git a/commands/memtester/memtester.c b/commands/memtester/memtester.c
index 130dc97c83..f4adbfc855 100644
--- a/commands/memtester/memtester.c
+++ b/commands/memtester/memtester.c
@@ -113,7 +113,7 @@ static int do_memtester(int argc, char **argv) {
strerror(errno));
return COMMAND_ERROR_USAGE;
} else {
- if (!S_ISCHR(statbuf.st_mode)) {
+ if (!S_ISCHR(statbuf.st_mode) && !S_ISBLK(statbuf.st_mode)) {
printf("can not mmap non-char device %s\n",
optarg);
return COMMAND_ERROR_USAGE;
diff --git a/commands/spd_decode.c b/commands/spd_decode.c
index e8ee339a91..fa8fe86cf8 100644
--- a/commands/spd_decode.c
+++ b/commands/spd_decode.c
@@ -16,13 +16,12 @@
static int do_spd_decode(int argc, char *argv[])
{
int ret;
- size_t size;
void *data;
if (argc != 2)
return COMMAND_ERROR_USAGE;
- ret = read_file_2(argv[1], &size, &data, 256);
+ ret = read_file_2(argv[1], NULL, &data, 256);
if (ret && ret != -EFBIG) {
printf("unable to read %s: %s\n", argv[1], strerror(-ret));
return COMMAND_ERROR;
diff --git a/commands/state.c b/commands/state.c
index e7cb9902f7..56ef93b19f 100644
--- a/commands/state.c
+++ b/commands/state.c
@@ -53,6 +53,9 @@ static int do_state(int argc, char *argv[])
ret = state_save(state);
}
+ if (ret == -ENOMEDIUM)
+ ret = 0;
+
return ret;
}
diff --git a/common/Kconfig b/common/Kconfig
index f7a6a96e87..3ff45d6c9d 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1004,6 +1004,11 @@ config STATE
select ENVIRONMENT_VARIABLES
select OFTREE
select PARAMETER
+ help
+ barebox state is a generic framework for atomic power fail-safe
+ variable storage and retrieval. It can be used to safely maintain
+ data over reboots and to exchange information with Linux, e.g.
+ for redundant boot with bootchooser.
config STATE_CRYPTO
bool "HMAC based authentication support"
diff --git a/common/block.c b/common/block.c
index 1d386edcfd..19bb81df2c 100644
--- a/common/block.c
+++ b/common/block.c
@@ -361,6 +361,14 @@ static struct cdev_operations block_ops = {
.discard_range = block_op_discard_range,
};
+struct block_device *cdev_get_block_device(struct cdev *cdev)
+{
+ if (!cdev || cdev->ops != &block_ops)
+ return NULL;
+
+ return container_of(cdev, struct block_device, cdev);
+}
+
int blockdevice_register(struct block_device *blk)
{
loff_t size = (loff_t)blk->num_blocks * BLOCKSIZE(blk);
diff --git a/common/bootchooser.c b/common/bootchooser.c
index 75dfbc6166..eb3dda52ab 100644
--- a/common/bootchooser.c
+++ b/common/bootchooser.c
@@ -128,7 +128,7 @@ static void pr_target(struct bootchooser_target *target)
printf(" disabled due to %s\n", reason);
}
-static int pr_setenv(struct bootchooser *bc, const char *fmt, ...)
+static int bc_setenv(struct bootchooser *bc, const char *fmt, ...)
{
va_list ap;
int ret = 0;
@@ -162,7 +162,7 @@ err:
return ret;
}
-static const char *pr_getenv(const char *fmt, ...)
+static const char *bc_getenv(const char *fmt, ...)
{
va_list ap;
char *str;
@@ -258,7 +258,7 @@ static struct bootchooser_target *bootchooser_target_new(struct bootchooser *bc,
target->remaining_attempts = 0;
}
- val = pr_getenv("%s.boot", target->prefix);
+ val = bc_getenv("%s.boot", target->prefix);
if (!val)
val = target->name;
target->boot = xstrdup(val);
@@ -497,17 +497,17 @@ int bootchooser_save(struct bootchooser *bc)
int ret;
if (bc->last_chosen)
- pr_setenv(bc, "%s.last_chosen=%d", bc->state_prefix,
+ bc_setenv(bc, "%s.last_chosen=%d", bc->state_prefix,
bc->last_chosen->id);
list_for_each_entry(target, &bc->targets, list) {
- ret = pr_setenv(bc, "%s.remaining_attempts=%d",
+ ret = bc_setenv(bc, "%s.remaining_attempts=%d",
target->state_prefix,
target->remaining_attempts);
if (ret)
return ret;
- ret = pr_setenv(bc, "%s.priority=%d",
+ ret = bc_setenv(bc, "%s.priority=%d",
target->state_prefix, target->priority);
if (ret)
return ret;
diff --git a/common/bootsource.c b/common/bootsource.c
index 1f8d053a81..79dacfd1d0 100644
--- a/common/bootsource.c
+++ b/common/bootsource.c
@@ -113,16 +113,12 @@ void bootsource_set(enum bootsource src)
void bootsource_set_instance(int instance)
{
- char buf[32];
-
bootsource_instance = instance;
if (instance < 0)
- sprintf(buf, "unknown");
+ setenv("bootsource_instance","unknown");
else
- snprintf(buf, sizeof(buf), "%d", instance);
-
- setenv("bootsource_instance", buf);
+ pr_setenv("bootsource_instance", "%d", instance);
}
enum bootsource bootsource_get(void)
diff --git a/common/efi/payload/init.c b/common/efi/payload/init.c
index 1541683186..6976285fb3 100644
--- a/common/efi/payload/init.c
+++ b/common/efi/payload/init.c
@@ -31,7 +31,6 @@
#include <binfmt.h>
#include <wchar.h>
#include <envfs.h>
-#include <efi.h>
#include <efi/efi-payload.h>
#include <efi/efi-device.h>
#include <libfile.h>
@@ -360,7 +359,7 @@ static int efi_late_init(void)
return PTR_ERR(state);
ret = state_load(state);
- if (ret)
+ if (ret != -ENOMEDIUM)
pr_warn("Failed to load persistent state, continuing with defaults, %d\n",
ret);
diff --git a/common/env.c b/common/env.c
index 05add63f62..5ac1e62b8c 100644
--- a/common/env.c
+++ b/common/env.c
@@ -244,13 +244,12 @@ static int dev_setenv(const char *name, const char *val)
/**
* setenv - set environment variables
- * @_name - Variable name
+ * @name - Variable name
* @value - the value to set, empty string not handled specially
*
* Returns 0 for success and a negative error code otherwise
* Use unsetenv() to unset.
*/
-
int setenv(const char *_name, const char *value)
{
char *name = strdup(_name);
@@ -277,6 +276,35 @@ out:
}
EXPORT_SYMBOL(setenv);
+/**
+ * pr_setenv - set environment variables
+ * @name - Variable name
+ * @fmt - the format string to use
+ *
+ * Returns 0 for success and a negative error code otherwise
+ * Use unsetenv() to unset.
+ */
+int pr_setenv(const char *name, const char *fmt, ...)
+{
+ va_list ap;
+ int ret = 0;
+ char *value;
+ int len;
+
+ va_start(ap, fmt);
+ len = vasprintf(&value, fmt, ap);
+ va_end(ap);
+
+ if (len < 0)
+ return -ENOMEM;
+
+ ret = setenv(name, value);
+ free(value);
+
+ return ret;
+}
+EXPORT_SYMBOL(pr_setenv);
+
int export(const char *varname)
{
const char *val = getenv_raw(&context->local, varname);
diff --git a/common/fastboot.c b/common/fastboot.c
index f8ed40c86e..330a06f5a3 100644
--- a/common/fastboot.c
+++ b/common/fastboot.c
@@ -673,7 +673,8 @@ static void cb_flash(struct fastboot *fb, const char *cmd)
goto out;
}
- if (IS_ENABLED(CONFIG_BAREBOX_UPDATE) && filetype_is_barebox_image(filetype)) {
+ if (IS_ENABLED(CONFIG_BAREBOX_UPDATE) &&
+ (filetype_is_barebox_image(filetype) || strstarts(fentry->name, "bbu-"))) {
void *buf;
struct bbu_handler *handler;
struct bbu_data data = {
diff --git a/common/hush.c b/common/hush.c
index d80df7a181..6a089fabf1 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -112,7 +112,6 @@
#include <slice.h>
#include <getopt.h>
#include <libfile.h>
-#include <libbb.h>
#include <magicvar.h>
#include <linux/list.h>
#include <binfmt.h>
diff --git a/common/memory.c b/common/memory.c
index 95995bb6e3..fd782c7f24 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -3,6 +3,8 @@
* Copyright (c) 2011 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
*/
+#define pr_fmt(fmt) "memory: " fmt
+
#include <common.h>
#include <memory.h>
#include <of.h>
@@ -12,6 +14,7 @@
#include <asm-generic/memory_layout.h>
#include <asm/sections.h>
#include <malloc.h>
+#include <of.h>
/*
* Begin and End of memory area for malloc(), and current "brk"
@@ -53,9 +56,20 @@ void mem_malloc_init(void *start, void *end)
mem_malloc_initialized = 1;
}
-#if !defined __SANDBOX__
+static int request_reservation(const struct resource *res)
+{
+ if (!(res->flags & IORESOURCE_EXCLUSIVE))
+ return 0;
+
+ pr_debug("region %s %pa-%pa\n", res->name, &res->start, &res->end);
+
+ request_sdram_region(res->name, res->start, resource_size(res));
+ return 0;
+}
+
static int mem_malloc_resource(void)
{
+#if !defined __SANDBOX__
/*
* Normally it's a bug when one of these fails,
* but we have some setups where some of these
@@ -77,13 +91,14 @@ static int mem_malloc_resource(void)
(unsigned long)&__bss_start,
(unsigned long)&__bss_stop -
(unsigned long)&__bss_start);
+#endif
#ifdef STACK_BASE
request_sdram_region("stack", STACK_BASE, STACK_SIZE);
#endif
- return 0;
+
+ return of_reserved_mem_walk(request_reservation);
}
coredevice_initcall(mem_malloc_resource);
-#endif
static void *sbrk_no_zero(ptrdiff_t increment)
{
diff --git a/common/menutree.c b/common/menutree.c
index 9a14005ea2..751350d754 100644
--- a/common/menutree.c
+++ b/common/menutree.c
@@ -34,14 +34,7 @@ static void menutree_action(struct menu *m, struct menu_entry *me)
static void setenv_bool(const char *var, bool val)
{
- const char *str;
-
- if (val)
- str = "1";
- else
- str = "0";
-
- setenv(var, str);
+ pr_setenv(var, "%d", val);
}
static void menutree_box(struct menu *m, struct menu_entry *me)
@@ -87,7 +80,6 @@ int menutree(const char *path, int toplevel)
glob_t g = {};
int i;
char *globpath, *display;
- size_t size;
menu = menu_alloc();
@@ -100,7 +92,7 @@ int menutree(const char *path, int toplevel)
}
globpath = basprintf("%s/title", path);
- display = read_file(globpath, &size);
+ display = read_file(globpath, NULL);
free(globpath);
if (!display) {
eprintf("no title found in %s/title\n", path);
diff --git a/common/reset_source.c b/common/reset_source.c
index 3554cbd0fb..774ea5fc8c 100644
--- a/common/reset_source.c
+++ b/common/reset_source.c
@@ -76,7 +76,9 @@ EXPORT_SYMBOL(reset_source_set_prinst);
void reset_source_set_device(struct device_d *dev, enum reset_src_type st)
{
- int priority = of_get_reset_source_priority(dev->device_node);
+ unsigned int priority = RESET_SOURCE_DEFAULT_PRIORITY;
+
+ of_property_read_u32(dev->device_node, "reset-source-priority", &priority);
__reset_source_set(dev, st, priority, -1);
}
@@ -92,19 +94,3 @@ static int reset_source_init(void)
return 0;
}
coredevice_initcall(reset_source_init);
-
-/**
- * of_get_reset_source_priority() - get the desired reset source priority from
- * device tree
- * @node: The device_node to read the property from
- *
- * return: The priority
- */
-unsigned int of_get_reset_source_priority(struct device_node *node)
-{
- unsigned int priority = RESET_SOURCE_DEFAULT_PRIORITY;
-
- of_property_read_u32(node, "reset-source-priority", &priority);
-
- return priority;
-}
diff --git a/common/state/backend_format_raw.c b/common/state/backend_format_raw.c
index 1fecdeb9cf..7835f977c9 100644
--- a/common/state/backend_format_raw.c
+++ b/common/state/backend_format_raw.c
@@ -16,14 +16,12 @@
*/
#include <common.h>
-#include <common.h>
#include <crypto/keystore.h>
#include <digest.h>
#include <linux/kernel.h>
#include <malloc.h>
#include <crc.h>
#include <of.h>
-#include <crc.h>
#include "state.h"
diff --git a/crypto/rsa.c b/crypto/rsa.c
index e97e5192ab..fc21efdb6d 100644
--- a/crypto/rsa.c
+++ b/crypto/rsa.c
@@ -15,7 +15,6 @@
#include <asm/byteorder.h>
#include <errno.h>
#include <rsa.h>
-#include <asm/types.h>
#include <asm/unaligned.h>
#define UINT64_MULT32(v, multby) (((uint64_t)(v)) * ((uint32_t)(multby)))
diff --git a/drivers/clk/imx/clk-imx6sl.c b/drivers/clk/imx/clk-imx6sl.c
index 8d0766c055..466893f82f 100644
--- a/drivers/clk/imx/clk-imx6sl.c
+++ b/drivers/clk/imx/clk-imx6sl.c
@@ -7,7 +7,6 @@
#include <common.h>
#include <init.h>
#include <driver.h>
-#include <linux/clk.h>
#include <io.h>
#include <of.h>
#include <linux/clkdev.h>
diff --git a/drivers/clk/imx/clk-imx6sx.c b/drivers/clk/imx/clk-imx6sx.c
index bacde8b893..c11829259e 100644
--- a/drivers/clk/imx/clk-imx6sx.c
+++ b/drivers/clk/imx/clk-imx6sx.c
@@ -7,7 +7,6 @@
#include <common.h>
#include <init.h>
#include <driver.h>
-#include <linux/clk.h>
#include <io.h>
#include <of.h>
#include <linux/clkdev.h>
diff --git a/drivers/clocksource/clps711x.c b/drivers/clocksource/clps711x.c
index 1fe7f6c891..d6ab695afa 100644
--- a/drivers/clocksource/clps711x.c
+++ b/drivers/clocksource/clps711x.c
@@ -27,6 +27,11 @@ static int clps711x_cs_probe(struct device_d *dev)
struct resource *iores;
u32 rate;
struct clk *timer_clk;
+ int id;
+
+ id = of_alias_get_id(dev->device_node, "timer");
+ if (id != 1)
+ return 0;
timer_clk = clk_get(dev, NULL);
if (IS_ERR(timer_clk))
@@ -46,7 +51,7 @@ static int clps711x_cs_probe(struct device_d *dev)
return init_clock(&clps711x_cs);
}
-static __maybe_unused struct of_device_id clps711x_timer_dt_ids[] = {
+static const struct of_device_id __maybe_unused clps711x_timer_dt_ids[] = {
{ .compatible = "cirrus,ep7209-timer", },
{ }
};
diff --git a/drivers/gpio/gpio-clps711x.c b/drivers/gpio/gpio-clps711x.c
index a1965b33e4..cb4bd4025c 100644
--- a/drivers/gpio/gpio-clps711x.c
+++ b/drivers/gpio/gpio-clps711x.c
@@ -10,13 +10,10 @@
static int clps711x_gpio_probe(struct device_d *dev)
{
struct resource *iores;
- int err, id = dev->id;
+ int err, id = of_alias_get_id(dev->device_node, "gpio");
void __iomem *dat, *dir = NULL, *dir_inv = NULL;
struct bgpio_chip *bgc;
- if (dev->device_node)
- id = of_alias_get_id(dev->device_node, "gpio");
-
if (id < 0 || id > 4)
return -ENODEV;
@@ -62,7 +59,7 @@ out_err:
return err;
}
-static struct of_device_id __maybe_unused clps711x_gpio_dt_ids[] = {
+static const struct of_device_id __maybe_unused clps711x_gpio_dt_ids[] = {
{ .compatible = "cirrus,ep7209-gpio", },
{ /* sentinel */ }
};
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 82e2f82f53..b8f71e1598 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -571,6 +571,7 @@ static int mmc_change_freq(struct mci *mci)
mci->ext_csd_part_config = mci->ext_csd[EXT_CSD_PARTITION_CONFIG];
mci->bootpart = (mci->ext_csd_part_config >> 3) & 0x7;
+ mci->boot_ack_enable = (mci->ext_csd_part_config >> 6) & 0x1;
}
if (IS_ENABLED(CONFIG_MCI_MMC_GPP_PARTITIONS))
@@ -1654,6 +1655,17 @@ static int mci_set_boot(struct param_d *param, void *priv)
EXT_CSD_PARTITION_CONFIG, mci->ext_csd_part_config);
}
+static int mci_set_boot_ack(struct param_d *param, void *priv)
+{
+ struct mci *mci = priv;
+
+ mci->ext_csd_part_config &= ~(0x1 << 6);
+ mci->ext_csd_part_config |= mci->boot_ack_enable << 6;
+
+ return mci_switch(mci,
+ EXT_CSD_PARTITION_CONFIG, mci->ext_csd_part_config);
+}
+
static const char *mci_boot_names[] = {
"disabled",
"boot0",
@@ -1736,6 +1748,7 @@ static int mci_card_probe(struct mci *mci)
{
struct mci_host *host = mci->host;
int i, rc, disknum, ret;
+ bool has_bootpart = false;
if (host->card_present && !host->card_present(host) &&
!host->non_removable) {
@@ -1810,12 +1823,20 @@ static int mci_card_probe(struct mci *mci)
rc = mci_register_partition(part);
if (IS_ENABLED(CONFIG_MCI_MMC_BOOT_PARTITIONS) &&
- part->area_type == MMC_BLK_DATA_AREA_BOOT &&
- !mci->param_boot) {
- mci->param_boot = dev_add_param_enum(&mci->dev, "boot",
- mci_set_boot, NULL, &mci->bootpart,
- mci_boot_names, ARRAY_SIZE(mci_boot_names), mci);
- }
+ part->area_type == MMC_BLK_DATA_AREA_BOOT)
+ has_bootpart = true;
+ }
+
+ if (has_bootpart) {
+ mci->param_boot =
+ dev_add_param_enum(&mci->dev, "boot", mci_set_boot,
+ NULL, &mci->bootpart, mci_boot_names,
+ ARRAY_SIZE(mci_boot_names), mci);
+
+ mci->param_boot_ack =
+ dev_add_param_bool(&mci->dev, "boot_ack",
+ mci_set_boot_ack, NULL,
+ &mci->boot_ack_enable, mci);
}
dev_dbg(&mci->dev, "SD Card successfully added\n");
diff --git a/drivers/mtd/nand/nand_s3c24xx.c b/drivers/mtd/nand/nand_s3c24xx.c
index dfe570086f..b0f16f1d62 100644
--- a/drivers/mtd/nand/nand_s3c24xx.c
+++ b/drivers/mtd/nand/nand_s3c24xx.c
@@ -592,8 +592,6 @@ void __nand_boot_init s3c24x0_nand_load_image(void *dest, int size, int page)
disable_nand_controller(host);
}
-#include <asm/sections.h>
-
void __nand_boot_init nand_boot(void)
{
void *dest = _text;
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index 748aa861f1..73671ae2d4 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -9,7 +9,6 @@
#include <command.h>
#include <dma.h>
-#include <net.h>
#include <malloc.h>
#include <net.h>
#include <linux/phy.h>
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index adff9dadd1..60b5839b40 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -18,7 +18,6 @@
#include <net.h>
#include <malloc.h>
#include <linux/phy.h>
-#include <linux/phy.h>
#include <linux/err.h>
#define PHY_AN_TIMEOUT 10
diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c
index 80997dc89f..341f5f240e 100644
--- a/drivers/net/rtl8169.c
+++ b/drivers/net/rtl8169.c
@@ -230,13 +230,13 @@ static void rtl8169_init_ring(struct rtl8169_priv *priv)
for (i = 0; i < NUM_RX_DESC; i++) {
if (i == (NUM_RX_DESC - 1))
priv->rx_desc[i].status =
- BD_STAT_OWN | BD_STAT_EOR | PKT_BUF_SIZE;
+ cpu_to_le32(BD_STAT_OWN | BD_STAT_EOR | PKT_BUF_SIZE);
else
priv->rx_desc[i].status =
- BD_STAT_OWN | PKT_BUF_SIZE;
+ cpu_to_le32(BD_STAT_OWN | PKT_BUF_SIZE);
priv->rx_desc[i].buf_addr =
- virt_to_phys(priv->rx_buf + i * PKT_BUF_SIZE);
+ cpu_to_le32(virt_to_phys(priv->rx_buf + i * PKT_BUF_SIZE));
}
}
@@ -358,21 +358,21 @@ static int rtl8169_eth_send(struct eth_device *edev, void *packet,
priv->tx_desc[entry].buf_Haddr = 0;
priv->tx_desc[entry].buf_addr =
- virt_to_phys(priv->tx_buf + entry * PKT_BUF_SIZE);
+ cpu_to_le32(virt_to_phys(priv->tx_buf + entry * PKT_BUF_SIZE));
if (entry != (NUM_TX_DESC - 1)) {
priv->tx_desc[entry].status =
- BD_STAT_OWN | BD_STAT_FS | BD_STAT_LS |
- ((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN);
+ cpu_to_le32(BD_STAT_OWN | BD_STAT_FS | BD_STAT_LS |
+ ((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN));
} else {
priv->tx_desc[entry].status =
- BD_STAT_OWN | BD_STAT_EOR | BD_STAT_FS | BD_STAT_LS |
- ((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN);
+ cpu_to_le32(BD_STAT_OWN | BD_STAT_EOR | BD_STAT_FS | BD_STAT_LS |
+ ((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN));
}
RTL_W8(priv, TxPoll, 0x40);
- while (priv->tx_desc[entry].status & BD_STAT_OWN)
+ while (le32_to_cpu(priv->tx_desc[entry].status) & BD_STAT_OWN)
;
dma_sync_single_for_cpu((unsigned long)priv->tx_buf + entry *
@@ -391,9 +391,9 @@ static int rtl8169_eth_rx(struct eth_device *edev)
entry = priv->cur_rx % NUM_RX_DESC;
- if ((priv->rx_desc[entry].status & BD_STAT_OWN) == 0) {
- if (!(priv->rx_desc[entry].status & BD_STAT_RX_RES)) {
- pkt_size = (priv->rx_desc[entry].status & 0x1fff) - 4;
+ if ((le32_to_cpu(priv->rx_desc[entry].status) & BD_STAT_OWN) == 0) {
+ if (!(le32_to_cpu(priv->rx_desc[entry].status) & BD_STAT_RX_RES)) {
+ pkt_size = (le32_to_cpu(priv->rx_desc[entry].status) & 0x1fff) - 4;
dma_sync_single_for_cpu((unsigned long)priv->rx_buf
+ entry * PKT_BUF_SIZE,
@@ -407,14 +407,14 @@ static int rtl8169_eth_rx(struct eth_device *edev)
pkt_size, DMA_FROM_DEVICE);
if (entry == NUM_RX_DESC - 1)
- priv->rx_desc[entry].status = BD_STAT_OWN |
- BD_STAT_EOR | PKT_BUF_SIZE;
+ priv->rx_desc[entry].status = cpu_to_le32(BD_STAT_OWN |
+ BD_STAT_EOR | PKT_BUF_SIZE);
else
priv->rx_desc[entry].status =
- BD_STAT_OWN | PKT_BUF_SIZE;
+ cpu_to_le32(BD_STAT_OWN | PKT_BUF_SIZE);
priv->rx_desc[entry].buf_addr =
- virt_to_phys(priv->rx_buf +
- entry * PKT_BUF_SIZE);
+ cpu_to_le32(virt_to_phys(priv->rx_buf +
+ entry * PKT_BUF_SIZE));
} else {
dev_err(&edev->dev, "rx error\n");
}
diff --git a/drivers/net/virtio.c b/drivers/net/virtio.c
index b40c948689..8605f67ae2 100644
--- a/drivers/net/virtio.c
+++ b/drivers/net/virtio.c
@@ -9,7 +9,6 @@
#include <malloc.h>
#include <net.h>
#include <init.h>
-#include <net.h>
#include <linux/virtio.h>
#include <linux/virtio_ring.h>
#include <uapi/linux/virtio_net.h>
diff --git a/drivers/nvmem/eeprom_93xx46.c b/drivers/nvmem/eeprom_93xx46.c
index 2f598fbc97..0d19bc2877 100644
--- a/drivers/nvmem/eeprom_93xx46.c
+++ b/drivers/nvmem/eeprom_93xx46.c
@@ -10,8 +10,6 @@
#include <driver.h>
#include <of.h>
#include <spi/spi.h>
-#include <of.h>
-#include <spi/spi.h>
#include <malloc.h>
#include <gpio.h>
#include <of_gpio.h>
diff --git a/drivers/nvmem/rmem.c b/drivers/nvmem/rmem.c
index cd735e5ef3..b9331f48ff 100644
--- a/drivers/nvmem/rmem.c
+++ b/drivers/nvmem/rmem.c
@@ -31,7 +31,7 @@ static int rmem_probe(struct device_d *dev)
struct resource *mem;
struct rmem *priv;
- mem = dev_request_mem_resource(dev, 0);
+ mem = dev_get_resource(dev, IORESOURCE_MEM, 0);
if (IS_ERR(mem))
return PTR_ERR(mem);
diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index ca8da71cb4..4785128bd9 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -5,6 +5,7 @@ obj-$(CONFIG_OF_GPIO) += of_gpio.o
obj-$(CONFIG_OF_PCI) += of_pci.o
obj-y += partition.o
obj-y += of_net.o
+obj-y += reserved-mem.o
obj-$(CONFIG_MTD) += of_mtd.o
obj-$(CONFIG_OF_BAREBOX_DRIVERS) += barebox.o
obj-$(CONFIG_OF_OVERLAY) += overlay.o resolver.o of_firmware.o
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 5ccbd1bb69..42f45bbd4f 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -70,7 +70,6 @@ static int of_unflatten_reservemap(struct device_node *root,
int n;
struct property *p;
struct device_node *memreserve;
- __be32 cells;
n = of_reservemap_num_entries(fdt);
if (n <= 0)
@@ -80,16 +79,6 @@ static int of_unflatten_reservemap(struct device_node *root,
if (!memreserve)
return -ENOMEM;
- cells = cpu_to_be32(2);
-
- p = of_new_property(memreserve, "#address-cells", &cells, sizeof(__be32));
- if (!p)
- return -ENOMEM;
-
- p = of_new_property(memreserve, "#size-cells", &cells, sizeof(__be32));
- if (!p)
- return -ENOMEM;
-
p = of_new_property(memreserve, "reg",
(void *)fdt + be32_to_cpu(fdt->off_mem_rsvmap),
n * sizeof(struct fdt_reserve_entry));
diff --git a/drivers/of/reserved-mem.c b/drivers/of/reserved-mem.c
new file mode 100644
index 0000000000..34e61dfea3
--- /dev/null
+++ b/drivers/of/reserved-mem.c
@@ -0,0 +1,71 @@
+// SPDX-License-Identifier: GPL-2.0-only
+// SPDX-FileCopyrightText: 2021 Rouven Czerwinski <r.czerwinski@pengutronix.de>, Pengutronix
+
+#include <stdio.h>
+#include <of.h>
+#include <of_address.h>
+
+#define MEMRESERVE_NCELLS 2
+#define MEMRESERVE_FLAGS (IORESOURCE_MEM | IORESOURCE_EXCLUSIVE)
+
+int of_reserved_mem_walk(int (*handler)(const struct resource *res))
+{
+ struct device_node *node, *child;
+ int ncells = 0;
+ const __be32 *reg;
+ int ret;
+
+ node = of_find_node_by_path("/reserved-memory");
+ if (node) {
+ for_each_available_child_of_node(node, child) {
+ struct resource resource = {};
+
+ /* skip e.g. linux,cma */
+ if (!of_get_property(child, "reg", NULL))
+ continue;
+
+ of_address_to_resource(child, 0, &resource);
+
+ resource.name = child->name;
+ resource.flags = MEMRESERVE_FLAGS;
+
+ ret = handler(&resource);
+ if (ret)
+ return ret;
+ }
+ }
+
+ node = of_find_node_by_path("/memreserve");
+ reg = of_get_property(node, "reg", &ncells);
+ ncells /= sizeof(__be32);
+ if (reg) {
+ char name[sizeof "fdt-memreserve-4294967295"];
+ int i = 0, n = 0;
+
+ while (i < ncells) {
+ struct resource resource = {};
+ u64 size;
+
+ snprintf(name, sizeof(name), "fdt-memreserve-%u", n++);
+ resource.name = name;
+ resource.flags = MEMRESERVE_FLAGS;
+
+ resource.start = of_read_number(reg + i, MEMRESERVE_NCELLS);
+ i += MEMRESERVE_NCELLS;
+
+ size = of_read_number(reg + i, MEMRESERVE_NCELLS);
+ i += MEMRESERVE_NCELLS;
+
+ if (!size)
+ continue;
+
+ resource.end = resource.start + size - 1;
+
+ ret = handler(&resource);
+ if (ret)
+ return ret;
+ }
+ }
+
+ return 0;
+}
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index f068fded62..ae16df8a0c 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -50,7 +50,9 @@ const static struct regulator_ops fixed_ops = {
static int regulator_fixed_probe(struct device_d *dev)
{
+ struct device_node *np = dev->device_node;
struct regulator_fixed *fix;
+ u32 delay;
int ret;
if (!dev->device_node)
@@ -59,7 +61,7 @@ static int regulator_fixed_probe(struct device_d *dev)
fix = xzalloc(sizeof(*fix));
fix->gpio = -EINVAL;
- if (of_get_property(dev->device_node, "gpio", NULL)) {
+ if (of_get_property(np, "gpio", NULL)) {
fix->gpio = gpiod_get(dev, NULL, GPIOD_ASIS);
if (fix->gpio < 0) {
ret = fix->gpio;
@@ -71,13 +73,16 @@ static int regulator_fixed_probe(struct device_d *dev)
fix->rdev.desc = &fix->rdesc;
fix->rdev.dev = dev;
- if (of_find_property(dev->device_node, "regulator-always-on", NULL) ||
- of_find_property(dev->device_node, "regulator-boot-on", NULL)) {
+ if (!of_property_read_u32(np, "off-on-delay-us", &delay))
+ fix->rdesc.off_on_delay = delay;
+
+ if (of_find_property(np, "regulator-always-on", NULL) ||
+ of_find_property(np, "regulator-boot-on", NULL)) {
fix->always_on = 1;
regulator_fixed_enable(&fix->rdev);
}
- ret = of_regulator_register(&fix->rdev, dev->device_node);
+ ret = of_regulator_register(&fix->rdev, np);
if (ret)
return ret;
diff --git a/drivers/serial/serial_clps711x.c b/drivers/serial/serial_clps711x.c
index 7aac0970bf..81eb85429e 100644
--- a/drivers/serial/serial_clps711x.c
+++ b/drivers/serial/serial_clps711x.c
@@ -35,7 +35,7 @@
struct clps711x_uart {
void __iomem *base;
- void __iomem *syscon;
+ struct regmap *regmap;
struct clk *uart_clk;
struct console_device cdev;
};
@@ -61,8 +61,7 @@ static void clps711x_init_port(struct console_device *cdev)
u32 tmp;
/* Disable the UART */
- tmp = readl(s->syscon + SYSCON);
- writel(tmp & ~SYSCON_UARTEN, s->syscon + SYSCON);
+ regmap_update_bits(s->regmap, SYSCON, SYSCON_UARTEN, 0);
/* Setup Line Control Register */
tmp = readl(s->base + UBRLCR) & UBRLCR_BAUD_MASK;
@@ -70,17 +69,19 @@ static void clps711x_init_port(struct console_device *cdev)
writel(tmp, s->base + UBRLCR);
/* Enable the UART */
- tmp = readl(s->syscon + SYSCON);
- writel(tmp | SYSCON_UARTEN, s->syscon + SYSCON);
+ regmap_update_bits(s->regmap, SYSCON, SYSCON_UARTEN, SYSCON_UARTEN);
}
static void clps711x_putc(struct console_device *cdev, char c)
{
struct clps711x_uart *s = cdev->dev->priv;
+ u32 tmp;
/* Wait until there is space in the FIFO */
do {
- } while (readl(s->syscon + SYSFLG) & SYSFLG_UTXFF);
+ regmap_read(s->regmap, SYSFLG, &tmp);
+
+ } while (tmp & SYSFLG_UTXFF);
/* Send the character */
writew(c, s->base + UARTDR);
@@ -90,10 +91,12 @@ static int clps711x_getc(struct console_device *cdev)
{
struct clps711x_uart *s = cdev->dev->priv;
u16 data;
+ u32 tmp;
/* Wait until there is data in the FIFO */
do {
- } while (readl(s->syscon + SYSFLG) & SYSFLG_URXFE);
+ regmap_read(s->regmap, SYSFLG, &tmp);
+ } while (tmp & SYSFLG_URXFE);
data = readw(s->base + UARTDR);
@@ -107,32 +110,32 @@ static int clps711x_getc(struct console_device *cdev)
static int clps711x_tstc(struct console_device *cdev)
{
struct clps711x_uart *s = cdev->dev->priv;
+ u32 tmp;
+
+ regmap_read(s->regmap, SYSFLG, &tmp);
- return !(readl(s->syscon + SYSFLG) & SYSFLG_URXFE);
+ return !(tmp & SYSFLG_URXFE);
}
static void clps711x_flush(struct console_device *cdev)
{
struct clps711x_uart *s = cdev->dev->priv;
+ u32 tmp;
do {
- } while (readl(s->syscon + SYSFLG) & SYSFLG_UBUSY);
+ regmap_read(s->regmap, SYSFLG, &tmp);
+ } while (tmp & SYSFLG_UBUSY);
}
static int clps711x_probe(struct device_d *dev)
{
+ struct device_node *syscon;
struct clps711x_uart *s;
- int err, id = dev->id;
- char syscon_dev[8];
const char *devname;
-
- if (dev->device_node)
- id = of_alias_get_id(dev->device_node, "serial");
-
- if (id != 0 && id != 1)
- return -EINVAL;
+ int err;
s = xzalloc(sizeof(struct clps711x_uart));
+
s->uart_clk = clk_get(dev, NULL);
if (IS_ERR(s->uart_clk)) {
err = PTR_ERR(s->uart_clk);
@@ -140,19 +143,15 @@ static int clps711x_probe(struct device_d *dev)
}
s->base = dev_get_mem_region(dev, 0);
- if (IS_ERR(s->base))
- return PTR_ERR(s->base);
-
- if (!dev->device_node) {
- sprintf(syscon_dev, "syscon%i", id + 1);
- s->syscon = syscon_base_lookup_by_pdevname(syscon_dev);
- } else {
- s->syscon = syscon_base_lookup_by_phandle(dev->device_node,
- "syscon");
+ if (IS_ERR(s->base)) {
+ err = PTR_ERR(s->base);
+ goto out_err;
}
- if (IS_ERR(s->syscon)) {
- err = PTR_ERR(s->syscon);
+ syscon = of_parse_phandle(dev->device_node, "syscon", 0);
+ s->regmap = syscon_node_to_regmap(syscon);
+ if (IS_ERR(s->regmap)) {
+ err = PTR_ERR(s->regmap);
goto out_err;
}
@@ -182,7 +181,7 @@ out_err:
return err;
}
-static struct of_device_id __maybe_unused clps711x_uart_dt_ids[] = {
+static const struct of_device_id __maybe_unused clps711x_uart_dt_ids[] = {
{ .compatible = "cirrus,ep7209-uart", },
{ /* sentinel */ }
};
diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index 0d67ec4358..8da53ab5aa 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -171,7 +171,6 @@ static inline unsigned int ns16550_calc_divisor(struct console_device *cdev,
unsigned int clk = plat->clock;
return (clk / MODE_X_DIV / baudrate);
-
}
/**
diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
index e5b319e6da..a23e81ffb3 100644
--- a/drivers/soc/Makefile
+++ b/drivers/soc/Makefile
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0-only
-obj-y += imx/
+obj-$(CONFIG_ARCH_IMX) += imx/
+obj-$(CONFIG_KVX) += kvx/
obj-$(CONFIG_CPU_SIFIVE) += sifive/
obj-$(CONFIG_SOC_STARFIVE) += starfive/
-obj-$(CONFIG_KVX) += kvx/
diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c
index bf6d17cc5c..55ebccc877 100644
--- a/drivers/spi/atmel-quadspi.c
+++ b/drivers/spi/atmel-quadspi.c
@@ -27,8 +27,6 @@
#include <linux/clk.h>
#include <linux/err.h>
-#include <linux/clk.h>
-#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/spi/spi-mem.h>
#include <of_device.h>
diff --git a/drivers/usb/gadget/fsl_udc.c b/drivers/usb/gadget/fsl_udc.c
index ec004f1939..e8bdab5765 100644
--- a/drivers/usb/gadget/fsl_udc.c
+++ b/drivers/usb/gadget/fsl_udc.c
@@ -1,6 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
#include <common.h>
-#include <dma.h>
#include <errno.h>
#include <dma.h>
#include <init.h>
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index f277f65b97..ce5d39166b 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -27,7 +27,6 @@
* to activate workaround for bug #41 or this driver will NOT work!
*/
#include <common.h>
-#include <dma.h>
#include <clock.h>
#include <dma.h>
#include <malloc.h>
diff --git a/drivers/video/imx-ipu-v3/imx-hdmi.c b/drivers/video/imx-ipu-v3/imx-hdmi.c
index f454303fd8..d63f2c2111 100644
--- a/drivers/video/imx-ipu-v3/imx-hdmi.c
+++ b/drivers/video/imx-ipu-v3/imx-hdmi.c
@@ -15,7 +15,6 @@
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/math64.h>
-#include <linux/clk.h>
#include <i2c/i2c.h>
#include <video/media-bus-format.h>
#include <video/vpl.h>
diff --git a/drivers/video/imx-ipu-v3/imx-ldb.c b/drivers/video/imx-ipu-v3/imx-ldb.c
index ba34349d62..4c934bc72e 100644
--- a/drivers/video/imx-ipu-v3/imx-ldb.c
+++ b/drivers/video/imx-ipu-v3/imx-ldb.c
@@ -19,7 +19,6 @@
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/math64.h>
-#include <linux/clk.h>
#include <mach/imx6-regs.h>
#include <mach/imx53-regs.h>
diff --git a/drivers/video/omap.c b/drivers/video/omap.c
index ca41ab36fc..189b95d241 100644
--- a/drivers/video/omap.c
+++ b/drivers/video/omap.c
@@ -16,7 +16,6 @@
#include <io.h>
#include <common.h>
#include <malloc.h>
-#include <common.h>
#include <clock.h>
#include <linux/err.h>
diff --git a/drivers/virtio/virtio_pci_common.h b/drivers/virtio/virtio_pci_common.h
index 8f97d12188..b4720fa1fc 100644
--- a/drivers/virtio/virtio_pci_common.h
+++ b/drivers/virtio/virtio_pci_common.h
@@ -17,7 +17,6 @@
*/
#include <linux/list.h>
-#include <linux/list.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/virtio.h>
diff --git a/fs/devfs.c b/fs/devfs.c
index deb244feea..49cd48f6d8 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -29,6 +29,7 @@
#include <linux/mtd/mtd.h>
#include <linux/mtd/mtd-abi.h>
#include <partition.h>
+#include <block.h>
struct devfs_inode {
struct inode inode;
@@ -231,6 +232,7 @@ static struct inode *devfs_get_inode(struct super_block *sb, const struct inode
default:
return NULL;
case S_IFCHR:
+ case S_IFBLK:
inode->i_op = &devfs_file_inode_operations;
inode->i_fop = &devfs_file_operations;
break;
@@ -250,12 +252,15 @@ static struct dentry *devfs_lookup(struct inode *dir, struct dentry *dentry,
struct devfs_inode *dinode;
struct inode *inode;
struct cdev *cdev;
+ umode_t mode;
cdev = cdev_by_name(dentry->name);
if (!cdev)
return ERR_PTR(-ENOENT);
- inode = devfs_get_inode(dir->i_sb, dir, S_IFCHR);
+ mode = cdev_get_block_device(cdev) ? S_IFBLK : S_IFCHR;
+
+ inode = devfs_get_inode(dir->i_sb, dir, mode);
if (!inode)
return ERR_PTR(-ENOMEM);
diff --git a/fs/fs.c b/fs/fs.c
index 5fb9f1402e..460fc2f7f1 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -3215,7 +3215,6 @@ static int automount_mount(struct dentry *dentry)
/*
* Some debug commands, helpful to debug the dcache implementation
*/
-#include <command.h>
static int do_lookup_dentry(int argc, char *argv[])
{
diff --git a/fs/legacy.c b/fs/legacy.c
index fc6a18f408..779f546294 100644
--- a/fs/legacy.c
+++ b/fs/legacy.c
@@ -288,6 +288,7 @@ static struct inode *legacy_get_inode(struct super_block *sb, const struct inode
return NULL;
case S_IFREG:
case S_IFCHR:
+ case S_IFBLK:
inode->i_op = &legacy_file_inode_operations;
break;
case S_IFDIR:
diff --git a/fs/nfs.c b/fs/nfs.c
index 057641edc8..fae7b722f5 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -26,7 +26,6 @@
#include <errno.h>
#include <libgen.h>
#include <fcntl.h>
-#include <fs.h>
#include <init.h>
#include <linux/stat.h>
#include <linux/err.h>
diff --git a/fs/pstore/fs.c b/fs/pstore/fs.c
index e9c7ae7adb..b41c87665c 100644
--- a/fs/pstore/fs.c
+++ b/fs/pstore/fs.c
@@ -21,7 +21,6 @@
#include <fs.h>
#include <errno.h>
#include <fcntl.h>
-#include <fs.h>
#include <malloc.h>
#include <init.h>
#include <linux/stat.h>
@@ -30,7 +29,6 @@
#include <libbb.h>
#include <rtc.h>
#include <libfile.h>
-#include <linux/pstore.h>
#include "internal.h"
struct list_head allpstore = LIST_HEAD_INIT(allpstore);
diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
index 06be47ce53..76b8a109be 100644
--- a/fs/pstore/ram_core.c
+++ b/fs/pstore/ram_core.c
@@ -20,7 +20,6 @@
#include <linux/rslib.h>
#include <linux/pstore_ram.h>
#include <linux/string.h>
-#include <linux/rslib.h>
#include <stdio.h>
#include <malloc.h>
#include <memory.h>
diff --git a/fs/uimagefs.c b/fs/uimagefs.c
index 72641c58b5..daaa3ad24b 100644
--- a/fs/uimagefs.c
+++ b/fs/uimagefs.c
@@ -9,7 +9,6 @@
#include <fs.h>
#include <errno.h>
#include <fcntl.h>
-#include <fs.h>
#include <malloc.h>
#include <init.h>
#include <linux/stat.h>
diff --git a/images/Makefile b/images/Makefile
index 5e2b9ecaaa..a148cf4176 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -152,6 +152,7 @@ include $(srctree)/images/Makefile.ar231x
include $(srctree)/images/Makefile.ath79
include $(srctree)/images/Makefile.bcm283x
include $(srctree)/images/Makefile.bcm47xx
+include $(srctree)/images/Makefile.clps711x
include $(srctree)/images/Makefile.imx
include $(srctree)/images/Makefile.loongson
include $(srctree)/images/Makefile.malta
diff --git a/images/Makefile.clps711x b/images/Makefile.clps711x
new file mode 100644
index 0000000000..d76911d627
--- /dev/null
+++ b/images/Makefile.clps711x
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# barebox image generation Makefile for CLPS711X images
+#
+
+pblb-$(CONFIG_MACH_CLEP7212) += start_ep7212_clep7212
+FILE_barebox-ep7212-clep7212.img = start_ep7212_clep7212.pblb
+image-$(CONFIG_MACH_CLEP7212) += barebox-ep7212-clep7212.img
diff --git a/include/block.h b/include/block.h
index d3a154bf73..1fb40e942f 100644
--- a/include/block.h
+++ b/include/block.h
@@ -49,4 +49,13 @@ static inline int block_flush(struct block_device *blk)
return cdev_flush(&blk->cdev);
}
+#ifdef CONFIG_BLOCK
+struct block_device *cdev_get_block_device(struct cdev *cdev);
+#else
+static inline struct block_device *cdev_get_block_device(struct cdev *cdev)
+{
+ return NULL;
+}
+#endif
+
#endif /* __BLOCK_H */
diff --git a/include/environment.h b/include/environment.h
index 19e522cfb6..1557c3a1d7 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -32,6 +32,7 @@ char *var_name(struct variable_d *);
#ifdef CONFIG_ENVIRONMENT_VARIABLES
const char *getenv(const char *);
int setenv(const char *, const char *);
+int pr_setenv(const char *, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
void export_env_ull(const char *name, unsigned long long val);
int getenv_ull(const char *name, unsigned long long *val);
int getenv_ul(const char *name, unsigned long *val);
@@ -49,6 +50,12 @@ static inline int setenv(const char *var, const char *val)
return 0;
}
+static inline __attribute__ ((format(__printf__, 2, 3))) int pr_setenv(
+ const char *var, const char *fmt, ...)
+{
+ return 0;
+}
+
static inline void export_env_ull(const char *name, unsigned long long val) {}
static inline int getenv_ull(const char *name, unsigned long long *val)
diff --git a/include/globalvar.h b/include/globalvar.h
index 476bb920f3..ff1da6c927 100644
--- a/include/globalvar.h
+++ b/include/globalvar.h
@@ -101,6 +101,8 @@ static inline char *globalvar_get_match(const char *match, const char *separator
static inline void globalvar_set_match(const char *match, const char *val) {}
+static inline void globalvar_set(const char *name, const char *val) {}
+
static inline int nvvar_load(void)
{
return 0;
diff --git a/include/mci.h b/include/mci.h
index 922aeaecf3..2098b4fbf0 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -463,7 +463,9 @@ struct mci {
u8 *ext_csd;
int probe;
struct param_d *param_boot;
+ struct param_d *param_boot_ack;
int bootpart;
+ int boot_ack_enable;
struct mci_part part[MMC_NUM_PHY_PARTITION];
int nr_parts;
diff --git a/include/of.h b/include/of.h
index 46b96277d5..3c5f14e167 100644
--- a/include/of.h
+++ b/include/of.h
@@ -58,12 +58,12 @@ struct of_reserve_map {
};
int of_add_reserve_entry(resource_size_t start, resource_size_t end);
-struct of_reserve_map *of_get_reserve_map(void);
void of_clean_reserve_map(void);
void fdt_add_reserve_map(void *fdt);
struct device_d;
struct driver_d;
+struct resource;
int of_fix_tree(struct device_node *);
@@ -116,6 +116,7 @@ struct device_node *of_unflatten_dtb_const(const void *infdt, int size);
struct cdev;
#ifdef CONFIG_OFTREE
+extern struct of_reserve_map *of_get_reserve_map(void);
extern int of_bus_n_addr_cells(struct device_node *np);
extern int of_n_addr_cells(struct device_node *np);
extern int of_bus_n_size_cells(struct device_node *np);
@@ -317,7 +318,15 @@ struct device_node *of_find_node_by_path_or_alias(struct device_node *root,
int of_autoenable_device_by_path(char *path);
int of_autoenable_i2c_by_component(char *path);
int of_prepend_machine_compatible(struct device_node *root, const char *compat);
+
+int of_reserved_mem_walk(int (*handler)(const struct resource *res));
+
#else
+static inline struct of_reserve_map *of_get_reserve_map(void)
+{
+ return NULL;
+}
+
static inline bool of_node_name_eq(const struct device_node *np, const char *name)
{
return false;
@@ -841,6 +850,11 @@ static inline int of_prepend_machine_compatible(struct device_node *root,
return -ENODEV;
}
+static inline int of_reserved_mem_walk(int (*handler)(const struct resource *res))
+{
+ return 0;
+}
+
#endif
#define for_each_property_of_node(dn, pp) \
diff --git a/include/reset_source.h b/include/reset_source.h
index 023b1fe4a0..a98c61ae0e 100644
--- a/include/reset_source.h
+++ b/include/reset_source.h
@@ -32,8 +32,6 @@ void reset_source_set_device(struct device_d *dev, enum reset_src_type st);
void reset_source_set_prinst(enum reset_src_type,
unsigned int priority, int instance);
-unsigned int of_get_reset_source_priority(struct device_node *node);
-
#else
static inline enum reset_src_type reset_source_get(void)
@@ -69,11 +67,6 @@ static inline void reset_source_set_prinst(enum reset_src_type type,
static inline void reset_source_set_instance(enum reset_src_type type, int instance)
{
}
-
-static inline unsigned int of_get_reset_source_priority(struct device_node *node)
-{
- return 0;
-}
#endif
#define RESET_SOURCE_DEFAULT_PRIORITY 100
diff --git a/include/soc/imx8m/ddr.h b/include/soc/imx8m/ddr.h
index 147a7d499a..c81c4d82c5 100644
--- a/include/soc/imx8m/ddr.h
+++ b/include/soc/imx8m/ddr.h
@@ -8,7 +8,6 @@
#include <io.h>
#include <asm/types.h>
-#include <soc/imx8m/ddr.h>
#define DDRC_DDR_SS_GPR0 0x3d000000
#define DDRC_IPS_BASE_ADDR_0 0x3f400000
diff --git a/lib/decompress_unlz4.c b/lib/decompress_unlz4.c
index 46a010ad4c..2c04eac71c 100644
--- a/lib/decompress_unlz4.c
+++ b/lib/decompress_unlz4.c
@@ -10,7 +10,6 @@
#ifdef STATIC
#define PREBOOT
-#include <linux/decompress/mm.h>
#include "lz4/lz4_decompress.c"
#else
#include <linux/decompress/unlz4.h>
diff --git a/lib/libfile.c b/lib/libfile.c
index 1f533133c5..3b7985fbca 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -162,7 +162,6 @@ char *read_file_line(const char *fmt, ...)
va_list args;
char *filename;
char *buf, *line = NULL;
- size_t size;
int ret;
struct stat s;
@@ -177,7 +176,7 @@ char *read_file_line(const char *fmt, ...)
if (s.st_size > 1024)
goto out;
- buf = read_file(filename, &size);
+ buf = read_file(filename, NULL);
if (!buf)
goto out;
diff --git a/lib/parameter.c b/lib/parameter.c
index adc3c7cdea..6642d73b6c 100644
--- a/lib/parameter.c
+++ b/lib/parameter.c
@@ -258,12 +258,14 @@ static int param_string_set(struct device_d *dev, struct param_d *p, const char
if (!val)
val = "";
- value_new = xstrdup(val);
- value_new = strim(value_new);
+ value_new = xstrdup(skip_spaces(val));
+ strim(value_new);
*ps->value = value_new;
- if (!ps->set)
+ if (!ps->set) {
+ free(value_save);
return 0;
+ }
ret = ps->set(p, p->driver_priv);
if (ret) {
diff --git a/net/dns.c b/net/dns.c
index 8b5e8d59e8..fdddb3f915 100644
--- a/net/dns.c
+++ b/net/dns.c
@@ -226,7 +226,7 @@ int resolv(const char *host, IPaddr_t *ip)
nameserver = net_get_nameserver();
if (!nameserver) {
pr_err("no nameserver specified in $global.net.nameserver\n");
- return 0;
+ return -ENOENT;
}
pr_debug("resolving host %s via nameserver %pI4\n", host, &nameserver);
diff --git a/net/ifup.c b/net/ifup.c
index 1870f74017..e4d5374db3 100644
--- a/net/ifup.c
+++ b/net/ifup.c
@@ -17,7 +17,6 @@
#include <string.h>
#include <driver.h>
#include <init.h>
-#include <globalvar.h>
#include <magicvar.h>
#include <linux/stat.h>
diff --git a/net/nfs.c b/net/nfs.c
index 9bd0b8f05f..df0840e4e7 100644
--- a/net/nfs.c
+++ b/net/nfs.c
@@ -31,7 +31,6 @@
#include <malloc.h>
#include <libgen.h>
#include <fs.h>
-#include <libgen.h>
#include <fcntl.h>
#include <errno.h>
#include <progress.h>
diff --git a/scripts/bareboximd.c b/scripts/bareboximd.c
index d01bd27007..ab47ad27e4 100644
--- a/scripts/bareboximd.c
+++ b/scripts/bareboximd.c
@@ -4,7 +4,6 @@
#include <stdio.h>
#include <sys/types.h>
#include <stdint.h>
-#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
@@ -15,7 +14,6 @@
#include <stdarg.h>
#include <linux/err.h>
#include <linux/kernel.h>
-#include <sys/mman.h>
#include "common.h"
#include "common.c"
diff --git a/scripts/common.c b/scripts/common.c
index 0eb263d041..e2c53c5aef 100644
--- a/scripts/common.c
+++ b/scripts/common.c
@@ -1,6 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <stdio.h>
-#include <sys/types.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/scripts/kwbimage.c b/scripts/kwbimage.c
index 28c9a68e18..f9d052752d 100644
--- a/scripts/kwbimage.c
+++ b/scripts/kwbimage.c
@@ -38,7 +38,6 @@
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
-#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <libgen.h>
diff --git a/scripts/stb_image.h b/scripts/stb_image.h
index 742fac74f7..cad4fe2901 100644
--- a/scripts/stb_image.h
+++ b/scripts/stb_image.h
@@ -561,10 +561,6 @@ STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const ch
#include <math.h> // ldexp, pow
#endif
-#ifndef STBI_NO_STDIO
-#include <stdio.h>
-#endif
-
#ifndef STBI_ASSERT
#include <assert.h>
#define STBI_ASSERT(x) assert(x)