From aff82bcd06add43c74836354ca79d57b8ceb4293 Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Wed, 13 May 2020 13:46:36 +0200 Subject: mci: core: add device parameter for eMMC boot ack This adds an easy way to enable the boot acknowledge function of a eMMC device, without the need to frob the EXT_CSD setting via the mmc_extcsd command. A boot ack is required whenever the boot partitions are read via the fast initialization boot protocol. Signed-off-by: Lucas Stach Link: https://lore.barebox.org/20200513114636.811-1-l.stach@pengutronix.de Signed-off-by: Sascha Hauer --- drivers/mci/mci-core.c | 33 +++++++++++++++++++++++++++------ include/mci.h | 2 ++ 2 files changed, 29 insertions(+), 6 deletions(-) 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/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; -- cgit v1.2.3 From c7d771e1ab9bb8d5f27823b39e9392a79066ce6e Mon Sep 17 00:00:00 2001 From: Alexander Shiyan Date: Tue, 24 May 2022 09:04:11 +0300 Subject: ARM: clps711x: Switch to devicetree usage This is a complex patch that switches the ARM CLPS711X architecture to work with the device tree. Includes changes to board initialization and any architecture drivers used. Signed-off-by: Alexander Shiyan Link: https://lore.barebox.org/20220524060411.7754-1-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer --- arch/arm/Kconfig | 4 + arch/arm/boards/clep7212/Makefile | 4 +- arch/arm/boards/clep7212/board.c | 15 +++ arch/arm/boards/clep7212/clep7212.c | 57 ---------- arch/arm/boards/clep7212/lowlevel.c | 23 ++-- arch/arm/configs/clps711x_defconfig | 5 +- arch/arm/dts/Makefile | 1 + arch/arm/dts/ep7212-clep7212.dts | 64 +++++++++++ arch/arm/mach-clps711x/Kconfig | 9 -- arch/arm/mach-clps711x/Makefile | 2 +- arch/arm/mach-clps711x/clock.c | 46 ++++---- arch/arm/mach-clps711x/common.c | 149 +++++++++++++++++++++++++ arch/arm/mach-clps711x/include/mach/clps711x.h | 28 +++-- arch/arm/mach-clps711x/include/mach/debug_ll.h | 21 ++++ arch/arm/mach-clps711x/include/mach/devices.h | 9 -- arch/arm/mach-clps711x/lowlevel.c | 72 ++++++------ arch/arm/mach-clps711x/reset.c | 29 ----- drivers/clocksource/clps711x.c | 7 +- drivers/gpio/gpio-clps711x.c | 7 +- drivers/serial/serial_clps711x.c | 57 +++++----- images/Makefile | 1 + images/Makefile.clps711x | 8 ++ 22 files changed, 395 insertions(+), 223 deletions(-) create mode 100644 arch/arm/boards/clep7212/board.c delete mode 100644 arch/arm/boards/clep7212/clep7212.c create mode 100644 arch/arm/dts/ep7212-clep7212.dts create mode 100644 arch/arm/mach-clps711x/common.c create mode 100644 arch/arm/mach-clps711x/include/mach/debug_ll.h delete mode 100644 arch/arm/mach-clps711x/include/mach/devices.h delete mode 100644 arch/arm/mach-clps711x/reset.c create mode 100644 images/Makefile.clps711x 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 + +#include +#include +#include + +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 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -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 +// SPDX-FileCopyrightText: Alexander Shiyan #include -#include - -#include - +#include +#include #include -#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/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/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 */ + +#include + +/ { + 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 - * - * 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 #include #include @@ -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 + +#include +#include +#include +#include +#include +#include + +#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 - * - * 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 */ #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 + +#ifndef __MACH_DEBUG_LL_H__ +#define __MACH_DEBUG_LL_H__ + +#include +#include + +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 - * - * 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 +#include +#include #include -#include +#include #include +#include -#include -#include -#include +#define DEBUG_LL_BAUDRATE (57600) -#include +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 - * - * 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 -#include -#include - -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/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/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/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 -- cgit v1.2.3 From 6fda9e093fb81513ea0c359cbd02c55a87ccede2 Mon Sep 17 00:00:00 2001 From: Alexander Shiyan Date: Wed, 25 May 2022 08:26:32 +0300 Subject: .gitignore: Add directories generated by MAKEALL script Signed-off-by: Alexander Shiyan Link: https://lore.barebox.org/20220525052632.3169-1-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) 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-* -- cgit v1.2.3 From 7662c931313a94fff6630717735c53fd52d2f981 Mon Sep 17 00:00:00 2001 From: Alexander Shiyan Date: Tue, 24 May 2022 10:21:35 +0300 Subject: ARM: myir-x335x: Fix memory size detect Unfortunately, the memory size detect does not work properly. Let's use the standard get_ram_size() function in the preloader and just reinitialize the memory if it returns 256MB. Signed-off-by: Alexander Shiyan Link: https://lore.barebox.org/20220524072135.18007-1-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer --- arch/arm/boards/myirtech-x335x/lowlevel.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) 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 */ +#include #include #include #include @@ -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); } -- cgit v1.2.3 From e7aeb9cca371869545b87943fe9dd38c6cf00b6d Mon Sep 17 00:00:00 2001 From: Alexander Shiyan Date: Tue, 24 May 2022 10:30:48 +0300 Subject: ARM: DTS: myir-x335x: Add GPIO aliases For the correct work of GPIO driver, we need to define aliases. Let's add them to the devicetree. Signed-off-by: Alexander Shiyan Reviewed-by: Ahmad Fatoum Link: https://lore.barebox.org/20220524073048.18467-1-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer --- arch/arm/dts/am335x-myirtech-myd.dts | 7 +++++++ 1 file changed, 7 insertions(+) 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 / { + aliases { + gpio0 = &gpio0; + gpio1 = &gpio1; + gpio2 = &gpio2; + gpio3 = &gpio3; + }; + chosen { environment { compatible = "barebox,environment"; -- cgit v1.2.3 From 32a2ce0791926b860d825fc085942ea2137a810d Mon Sep 17 00:00:00 2001 From: Alexander Shiyan Date: Wed, 1 Jun 2022 09:02:22 +0300 Subject: ARM: at91sam9n12ek: Use xz compression The binary created with at91sam9n12ek_defconfig got too big over time. Use xz compression to match the bounds. CHKFILESIZE images/start_pbl.pblb images/start_pbl.pblb size 270996 > maximum size 262144 Signed-off-by: Alexander Shiyan Link: https://lore.barebox.org/20220601060226.3756-2-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer --- arch/arm/configs/at91sam9n12ek_defconfig | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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 -- cgit v1.2.3 From dddc5191d72263ad6fc4322a1cebcaea023919ac Mon Sep 17 00:00:00 2001 From: Alexander Shiyan Date: Wed, 1 Jun 2022 09:02:24 +0300 Subject: drivers: soc: Fix unconditional compilation of imx directory As a side change, this patch sorts entries alphabetically. Signed-off-by: Alexander Shiyan Link: https://lore.barebox.org/20220601060226.3756-4-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer --- drivers/soc/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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/ -- cgit v1.2.3 From a7e2fc8d5da3955af8a69dc006e3e8c3cddb921d Mon Sep 17 00:00:00 2001 From: Alexander Shiyan Date: Wed, 1 Jun 2022 09:02:25 +0300 Subject: globalvar: Add missing empty prototype for globalvar_set() common/fastboot.c: In function 'cb_boot': common/fastboot.c:396:2: error: implicit declaration of function 'globalvar_set' globalvar_set("bootm.image", ""); Signed-off-by: Alexander Shiyan Link: https://lore.barebox.org/20220601060226.3756-5-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer --- include/globalvar.h | 2 ++ 1 file changed, 2 insertions(+) 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; -- cgit v1.2.3 From 7cceef54a045ca8b9b33145b708d843b371718ba Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Thu, 2 Jun 2022 21:59:15 +0200 Subject: commands: ls: explicitly check for directories with S_ISDIR S_ISDIR(mode) is implemented as (mode & S_IFMT) == S_IFDIR, which accounts for file modes setting multiple bits. So far, this was not the case, but upcoming S_IFBLK equals (S_IFCHR | S_IFDIR), which would fail the existing checks, so prepare for that by fixing them. No functional change. There are no other instances of this elsewhere in the code base. Signed-off-by: Ahmad Fatoum Link: https://lore.barebox.org/20220602195916.9061-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer --- commands/ls.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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"); -- cgit v1.2.3 From 84173bf3d0ccc4036a16c4b074642aea59648063 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Thu, 2 Jun 2022 21:59:16 +0200 Subject: block: set S_IFBLK for block devices instead of S_IFCHR In barebox, block devices are a special case of character devices. Nevertheless, differentiation can be useful to allow scripts iterating over all block devices without accounting for naming, e.g. for dev in /dev/*; do test -b $dev && echo $dev: blockdevice done Add the necessary support. This will break scripts that assume test -c blockdevice to be true, but that's a quite improbable check. Tested-by: Jules Maselbas Signed-off-by: Ahmad Fatoum Link: https://lore.barebox.org/20220602195916.9061-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer --- commands/memtester/memtester.c | 2 +- common/block.c | 8 ++++++++ fs/devfs.c | 7 ++++++- fs/legacy.c | 1 + include/block.h | 9 +++++++++ 5 files changed, 25 insertions(+), 2 deletions(-) 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/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/fs/devfs.c b/fs/devfs.c index deb244feea..49cd48f6d8 100644 --- a/fs/devfs.c +++ b/fs/devfs.c @@ -29,6 +29,7 @@ #include #include #include +#include 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/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/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 */ -- cgit v1.2.3 From 870a96a80ba69f2e7d0312a84adecb70bd11ae4a Mon Sep 17 00:00:00 2001 From: Alexander Shiyan Date: Tue, 7 Jun 2022 08:19:57 +0300 Subject: treewide: Remove duplicate incudes Fix warning fwterated by checkincludes.pl: ./net/nfs.c: libgen.h is included more than once. ./net/ifup.c: globalvar.h is included more than once. ./crypto/rsa.c: asm/types.h is included more than once. ./lib/decompress_unlz4.c: linux/decompress/mm.h is included more than once. ./scripts/stb_image.h: stdio.h is included more than once. ./scripts/kwbimage.c: unistd.h is included more than once. ./scripts/common.c: sys/types.h is included more than once. ./scripts/bareboximd.c: sys/types.h is included more than once. ./scripts/bareboximd.c: sys/mman.h is included more than once. ./fs/pstore/ram_core.c: linux/rslib.h is included more than once. ./fs/pstore/fs.c: fs.h is included more than once. ./fs/pstore/fs.c: linux/pstore.h is included more than once. ./fs/nfs.c: fs.h is included more than once. ./fs/uimagefs.c: fs.h is included more than once. ./fs/fs.c: command.h is included more than once. ./arch/sandbox/board/hostfile.c: linux/err.h is included more than once. ./arch/sandbox/board/devices.c: mach/linux.h is included more than once. ./arch/sandbox/os/common.c: signal.h is included more than once. ./arch/arm/boards/zii-imx51-rdu1/board.c: envfs.h is included more than once. ./arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c: generated/mach-types.h is ./arch/arm/mach-stm32mp/ddrctrl.c: mach/stm32.h is included more than once. ./arch/arm/mach-imx/cpu_init.c: common.h is included more than once. ./arch/arm/mach-imx/imx8m.c: mach/imx8m-ccm-regs.h is included more than once. ./common/efi/payload/init.c: efi.h is included more than once. ./common/state/backend_format_raw.c: common.h is included more than once. ./common/state/backend_format_raw.c: crc.h is included more than once. ./common/hush.c: libbb.h is included more than once. ./drivers/spi/atmel-quadspi.c: linux/clk.h is included more than once. ./drivers/spi/atmel-quadspi.c: linux/err.h is included more than once. ./drivers/net/virtio.c: net.h is included more than once. ./drivers/net/phy/phy.c: linux/phy.h is included more than once. ./drivers/net/cpsw.c: net.h is included more than once. ./drivers/virtio/virtio_pci_common.h: linux/list.h is included more than once. ./drivers/usb/host/ohci-hcd.c: dma.h is included more than once. ./drivers/usb/gadget/fsl_udc.c: dma.h is included more than once. ./drivers/nvmem/eeprom_93xx46.c: spi/spi.h is included more than once. ./drivers/nvmem/eeprom_93xx46.c: of.h is included more than once. ./drivers/video/imx-ipu-v3/imx-ldb.c: linux/clk.h is included more than once. ./drivers/video/imx-ipu-v3/imx-hdmi.c: linux/clk.h is included more than once. ./drivers/video/omap.c: common.h is included more than once. ./drivers/mtd/nand/nand_s3c24xx.c: asm/sections.h is included more than once. ./drivers/clk/imx/clk-imx6sx.c: linux/clk.h is included more than once. ./drivers/clk/imx/clk-imx6sl.c: linux/clk.h is included more than once. ./commands/bootm.c: of.h is included more than once. Signed-off-by: Alexander Shiyan Link: https://lore.barebox.org/20220607051957.2497-1-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer --- arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c | 1 - arch/arm/boards/zii-imx51-rdu1/board.c | 2 -- arch/arm/mach-imx/cpu_init.c | 1 - arch/arm/mach-imx/imx8m.c | 1 - arch/arm/mach-stm32mp/ddrctrl.c | 1 - arch/sandbox/board/devices.c | 1 - arch/sandbox/board/hostfile.c | 2 -- arch/sandbox/os/common.c | 1 - commands/bootm.c | 1 - common/efi/payload/init.c | 1 - common/hush.c | 1 - common/state/backend_format_raw.c | 2 -- crypto/rsa.c | 1 - drivers/clk/imx/clk-imx6sl.c | 1 - drivers/clk/imx/clk-imx6sx.c | 1 - drivers/mtd/nand/nand_s3c24xx.c | 2 -- drivers/net/cpsw.c | 1 - drivers/net/phy/phy.c | 1 - drivers/net/virtio.c | 1 - drivers/nvmem/eeprom_93xx46.c | 2 -- drivers/spi/atmel-quadspi.c | 2 -- drivers/usb/gadget/fsl_udc.c | 1 - drivers/usb/host/ohci-hcd.c | 1 - drivers/video/imx-ipu-v3/imx-hdmi.c | 1 - drivers/video/imx-ipu-v3/imx-ldb.c | 1 - drivers/video/omap.c | 1 - drivers/virtio/virtio_pci_common.h | 1 - fs/fs.c | 1 - fs/nfs.c | 1 - fs/pstore/fs.c | 2 -- fs/pstore/ram_core.c | 1 - fs/uimagefs.c | 1 - lib/decompress_unlz4.c | 1 - net/ifup.c | 1 - net/nfs.c | 1 - scripts/bareboximd.c | 2 -- scripts/common.c | 1 - scripts/kwbimage.c | 1 - scripts/stb_image.h | 4 ---- 39 files changed, 50 deletions(-) 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 #include #include -#include 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/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 #include -#include - static int zii_rdu1_init(void) { const char *hostname; 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 #include #include -#include #include #include #include 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 #include #include -#include #include #include 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 #include -#include #include #include #include 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 #include -#include #include #include #include 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 #include -#include - 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 #include #include -#include /* * ...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 #include #include -#include #include #include #include diff --git a/common/efi/payload/init.c b/common/efi/payload/init.c index 1541683186..e2bddabc9a 100644 --- a/common/efi/payload/init.c +++ b/common/efi/payload/init.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include 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 #include #include -#include #include #include #include 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 @@ -15,7 +15,6 @@ * */ -#include #include #include #include @@ -23,7 +22,6 @@ #include #include #include -#include #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 #include #include -#include #include #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 #include #include -#include #include #include #include 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 #include #include -#include #include #include #include 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 - 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 #include -#include #include #include #include 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 #include #include -#include #include #define PHY_AN_TIMEOUT 10 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 #include #include -#include #include #include #include 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 #include #include -#include -#include #include #include #include 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 #include -#include -#include #include #include #include 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 -#include #include #include #include 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 -#include #include #include #include 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 #include #include -#include #include #include