summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/boards/stm32mp.rst19
-rw-r--r--Documentation/user/booting-linux.rst6
-rw-r--r--Makefile2
-rw-r--r--arch/arm/boards/Makefile1
-rw-r--r--arch/arm/boards/sama5d27-giantboard/Makefile1
-rw-r--r--arch/arm/boards/sama5d27-giantboard/lowlevel.c63
-rw-r--r--arch/arm/boards/sama5d27-som1/lowlevel.c21
-rw-r--r--arch/arm/dts/Makefile1
-rw-r--r--arch/arm/dts/at91-sama5d27_giantboard.dts299
-rw-r--r--arch/arm/lib64/armlinux.c15
-rw-r--r--arch/arm/mach-at91/Kconfig13
-rw-r--r--arch/arm/mach-at91/Makefile1
-rw-r--r--arch/arm/mach-at91/at91sam9_rst.c72
-rw-r--r--common/block.c25
-rw-r--r--drivers/pinctrl/pinctrl-single.c2
-rw-r--r--drivers/usb/core/hub.c3
-rw-r--r--drivers/usb/gadget/f_fastboot.c2
-rw-r--r--drivers/usb/musb/musb_core.c5
-rw-r--r--drivers/usb/musb/musb_dsps.c55
-rw-r--r--drivers/usb/musb/phy-am335x-control.c25
-rw-r--r--drivers/usb/musb/phy-am335x.c22
-rw-r--r--drivers/usb/musb/phy-am335x.h6
-rw-r--r--fs/devfs.c21
-rw-r--r--fs/fs.c25
-rw-r--r--images/Makefile.at914
-rw-r--r--include/block.h3
-rw-r--r--include/driver.h1
-rw-r--r--include/fs.h3
-rw-r--r--lib/libfile.c2
29 files changed, 655 insertions, 63 deletions
diff --git a/Documentation/boards/stm32mp.rst b/Documentation/boards/stm32mp.rst
index 6d97b0d6d4..de793ab3c9 100644
--- a/Documentation/boards/stm32mp.rst
+++ b/Documentation/boards/stm32mp.rst
@@ -35,7 +35,7 @@ The resulting images will be placed under ``images/``:
Flashing barebox
----------------
-An appropriate image for the boot media can be generated with following
+An appropriate image for a SD-Card can be generated with following
``genimage(1)`` config::
image @STM32MP_BOARD@.img {
@@ -61,7 +61,22 @@ An appropriate image for the boot media can be generated with following
}
}
-Image can then be flashed on e.g. a SD-Card.
+For eMMC, the boot partitions are used as the FSBL partitions and so the user
+partitions may look like this:
+
+ image @STM32MP_BOARD@.img {
+ partition ssbl {
+ image = "barebox-@STM32MP_BOARD@.img"
+ size = 1M
+ }
+ partition barebox-environment {
+ image = "/dev/null"
+ size = 1M
+ }
+ }
+
+The fsbl1 and fsbl2 can be flashed by writing to barebox ``/dev/mmcX.boot0`` and
+``/dev/mmcX.boot1`` respectively or from a booted operating system.
Boot source selection
---------------------
diff --git a/Documentation/user/booting-linux.rst b/Documentation/user/booting-linux.rst
index 12cd505e71..983b56deef 100644
--- a/Documentation/user/booting-linux.rst
+++ b/Documentation/user/booting-linux.rst
@@ -158,7 +158,7 @@ Bootloader Spec
barebox supports booting according to the bootloader spec:
-http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/
+https://systemd.io/BOOT_LOADER_SPECIFICATION/
It follows another philosophy than the :ref:`boot_entries`. With Boot Entries
booting is completely configured in the bootloader. Bootloader Spec Entries
@@ -232,10 +232,6 @@ device where the entry is found on. This makes it possible to use the same rootf
image on different devices without having to specify a different root= option each
time.
-Additionally to the options defined in the original spec, Barebox has the
-``devicetree-overlay`` option. This is a string value that refer to overlays
-that will be applied to the device tree before passing it to Linux.
-
Network boot
------------
diff --git a/Makefile b/Makefile
index d923463ed5..fe7da86b76 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
VERSION = 2020
-PATCHLEVEL = 02
+PATCHLEVEL = 03
SUBLEVEL = 0
EXTRAVERSION =
NAME = None
diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
index 6cb40d084b..edc600b41e 100644
--- a/arch/arm/boards/Makefile
+++ b/arch/arm/boards/Makefile
@@ -112,6 +112,7 @@ obj-$(CONFIG_MACH_RPI_COMMON) += raspberry-pi/
obj-$(CONFIG_MACH_SABRELITE) += freescale-mx6-sabrelite/
obj-$(CONFIG_MACH_SABRESD) += freescale-mx6-sabresd/
obj-$(CONFIG_MACH_FREESCALE_IMX6SX_SABRESDB) += freescale-mx6sx-sabresdb/
+obj-$(CONFIG_MACH_SAMA5D27_GIANTBOARD) += sama5d27-giantboard/
obj-$(CONFIG_MACH_SAMA5D27_SOM1) += sama5d27-som1/
obj-$(CONFIG_MACH_SAMA5D3XEK) += sama5d3xek/
obj-$(CONFIG_MACH_SAMA5D3_XPLAINED) += sama5d3_xplained/
diff --git a/arch/arm/boards/sama5d27-giantboard/Makefile b/arch/arm/boards/sama5d27-giantboard/Makefile
new file mode 100644
index 0000000000..b08c4a93ca
--- /dev/null
+++ b/arch/arm/boards/sama5d27-giantboard/Makefile
@@ -0,0 +1 @@
+lwl-y += lowlevel.o
diff --git a/arch/arm/boards/sama5d27-giantboard/lowlevel.c b/arch/arm/boards/sama5d27-giantboard/lowlevel.c
new file mode 100644
index 0000000000..0236c424c1
--- /dev/null
+++ b/arch/arm/boards/sama5d27-giantboard/lowlevel.c
@@ -0,0 +1,63 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2019 Ahmad Fatoum, Pengutronix
+ */
+
+#include <common.h>
+#include <init.h>
+
+#include <asm/barebox-arm-head.h>
+#include <asm/barebox-arm.h>
+#include <mach/at91_pmc_ll.h>
+
+#include <mach/hardware.h>
+#include <mach/iomux.h>
+#include <debug_ll.h>
+#include <mach/at91_dbgu.h>
+
+/* PCK = 492MHz, MCK = 164MHz */
+#define MASTER_CLOCK 164000000
+
+static inline void sama5d2_pmc_enable_periph_clock(int clk)
+{
+ at91_pmc_sam9x5_enable_periph_clock(IOMEM(SAMA5D2_BASE_PMC), clk);
+}
+
+static void dbgu_init(void)
+{
+ unsigned mck = MASTER_CLOCK / 2;
+
+ sama5d2_pmc_enable_periph_clock(SAMA5D2_ID_PIOD);
+
+ at91_mux_pio4_set_A_periph(IOMEM(SAMA5D2_BASE_PIOD),
+ pin_to_mask(AT91_PIN_PD3)); /* DBGU TXD */
+
+ sama5d2_pmc_enable_periph_clock(SAMA5D2_ID_UART1);
+
+ at91_dbgu_setup_ll(IOMEM(SAMA5D2_BASE_UART1), mck, 115200);
+
+ putc_ll('>');
+}
+
+extern char __dtb_z_at91_sama5d27_giantboard_start[];
+
+static noinline void giantboard_entry(void)
+{
+ void *fdt;
+
+ if (IS_ENABLED(CONFIG_DEBUG_LL))
+ dbgu_init();
+
+ fdt = __dtb_z_at91_sama5d27_giantboard_start + get_runtime_offset();
+
+ barebox_arm_entry(SAMA5_DDRCS, SZ_128M, fdt);
+}
+
+ENTRY_FUNCTION(start_sama5d27_giantboard, r0, r1, r2)
+{
+ arm_cpu_lowlevel_init();
+
+ arm_setup_stack(SAMA5D2_SRAM_BASE + SAMA5D2_SRAM_SIZE);
+
+ giantboard_entry();
+}
diff --git a/arch/arm/boards/sama5d27-som1/lowlevel.c b/arch/arm/boards/sama5d27-som1/lowlevel.c
index 7df5a4772d..62d35be912 100644
--- a/arch/arm/boards/sama5d27-som1/lowlevel.c
+++ b/arch/arm/boards/sama5d27-som1/lowlevel.c
@@ -22,8 +22,10 @@
/* PCK = 492MHz, MCK = 164MHz */
#define MASTER_CLOCK 164000000
-#define sama5d2_pmc_enable_periph_clock(clk) \
- at91_pmc_sam9x5_enable_periph_clock(IOMEM(SAMA5D2_BASE_PMC), clk)
+static inline void sama5d2_pmc_enable_periph_clock(int clk)
+{
+ at91_pmc_sam9x5_enable_periph_clock(IOMEM(SAMA5D2_BASE_PMC), clk);
+}
static void ek_turn_led(unsigned color)
{
@@ -63,14 +65,10 @@ static void ek_dbgu_init(void)
extern char __dtb_z_at91_sama5d27_som1_ek_start[];
-ENTRY_FUNCTION(start_sama5d27_som1_ek, r0, r1, r2)
+static noinline void som1_entry(void)
{
void *fdt;
- arm_cpu_lowlevel_init();
-
- arm_setup_stack(SAMA5D2_SRAM_BASE + SAMA5D2_SRAM_SIZE - 16);
-
if (IS_ENABLED(CONFIG_DEBUG_LL))
ek_dbgu_init();
@@ -79,3 +77,12 @@ ENTRY_FUNCTION(start_sama5d27_som1_ek, r0, r1, r2)
ek_turn_led(RGB_LED_GREEN);
barebox_arm_entry(SAMA5_DDRCS, SZ_128M, fdt);
}
+
+ENTRY_FUNCTION(start_sama5d27_som1_ek, r0, r1, r2)
+{
+ arm_cpu_lowlevel_init();
+
+ arm_setup_stack(SAMA5D2_SRAM_BASE + SAMA5D2_SRAM_SIZE);
+
+ som1_entry();
+}
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index e8dca0b851..20eafb6afd 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -137,6 +137,7 @@ lwl-dtb-$(CONFIG_MACH_ZII_VF610_DEV) += \
lwl-dtb-$(CONFIG_MACH_AT91SAM9263EK_DT) += at91sam9263ek.dtb.o
lwl-dtb-$(CONFIG_MACH_MICROCHIP_KSZ9477_EVB) += at91-microchip-ksz9477-evb.dtb.o
lwl-dtb-$(CONFIG_MACH_SAMA5D27_SOM1) += at91-sama5d27_som1_ek.dtb.o
+lwl-dtb-$(CONFIG_MACH_SAMA5D27_GIANTBOARD) += at91-sama5d27_giantboard.dtb.o
lwl-dtb-$(CONFIG_MACH_AT91SAM9X5EK) += at91sam9x5ek.dtb.o
lwl-dtb-$(CONFIG_MACH_XILINX_ZCU104) += zynqmp-zcu104-revA.dtb.o
diff --git a/arch/arm/dts/at91-sama5d27_giantboard.dts b/arch/arm/dts/at91-sama5d27_giantboard.dts
new file mode 100644
index 0000000000..940379e430
--- /dev/null
+++ b/arch/arm/dts/at91-sama5d27_giantboard.dts
@@ -0,0 +1,299 @@
+// SPDX-License-Identifer: GPL-2.0-or-later OR X11
+/*
+ * at91-sama5d27_giantboard.dts - Device Tree file for SAMA5D27 Giant Board
+ *
+ * Copyright (c) 2017, Microchip Technology Inc.
+ * 2016 Nicolas Ferre <nicolas.ferre@atmel.com>
+ * 2017 Cristian Birsan <cristian.birsan@microchip.com>
+ * 2017 Claudiu Beznea <claudiu.beznea@microchip.com>
+ * 2019 Ahmad Fatoum <a.fatoum@pengutronix.de>
+ */
+
+/dts-v1/;
+
+#include <arm/sama5d2.dtsi>
+#include <arm/sama5d2-pinfunc.h>
+#include <dt-bindings/mfd/atmel-flexcom.h>
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/regulator/active-semi,8945a-regulator.h>
+
+/ {
+ model = "Giant Board";
+ compatible = "groboards,sama5d27-giantboard", "atmel,sama5d27", "atmel,sama5d2", "atmel,sama5";
+
+ chosen {
+ stdout-path = &uart1;
+ };
+
+ leds {
+ compatible = "gpio-leds";
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_led_gpio_default>;
+
+ orange {
+ label = "orange";
+ gpios = <&pioA PIN_PA6 GPIO_ACTIVE_HIGH>;
+ linux,default-trigger = "mmc0";
+ };
+ };
+
+ memory {
+ reg = <0x20000000 0x8000000>;
+ };
+};
+
+&slow_xtal {
+ clock-frequency = <32768>;
+};
+
+&main_xtal {
+ clock-frequency = <24000000>;
+};
+
+&usb0 {
+ status = "okay";
+};
+
+&sdmmc1 {
+ bus-width = <4>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_sdmmc1_default>;
+ status = "okay";
+};
+
+&spi0 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_spi0_default>;
+ status = "disabled";
+};
+
+&uart1 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_uart1_default>;
+ atmel,use-dma-rx;
+ atmel,use-dma-tx;
+ status = "okay";
+};
+
+&shutdown_controller {
+ atmel,shdwc-debouncer = <976>;
+ atmel,wakeup-rtc-timer;
+
+ input@0 {
+ reg = <0>;
+ atmel,wakeup-type = "low";
+ };
+};
+
+&watchdog {
+ status = "okay";
+};
+
+&i2c0 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_i2c0_default>;
+ dmas = <0>, <0>;
+};
+
+&i2c1 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_i2c1_default>;
+ dmas = <0>, <0>;
+ i2c-sda-hold-time-ns = <350>;
+ status = "okay";
+
+ pmic@5b {
+ compatible = "active-semi,act8945a";
+ reg = <0x5b>;
+ active-semi,vsel-low;
+
+ regulators {
+ vdd_1v8_reg: REG_DCDC1 {
+ regulator-name = "VDD_1V8";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <1800000>;
+ regulator-always-on;
+
+ regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_FIXED>,
+ <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+ regulator-initial-mode = <ACT8945A_REGULATOR_MODE_FIXED>;
+
+ regulator-state-mem {
+ regulator-on-in-suspend;
+ regulator-suspend-min-microvolt=<1850000>;
+ regulator-suspend-max-microvolt=<1850000>;
+ regulator-changeable-in-suspend;
+ regulator-mode=<ACT8945A_REGULATOR_MODE_LOWPOWER>;
+ };
+ };
+
+ vdd_1v2_reg: REG_DCDC2 {
+ regulator-name = "VDD_1V2";
+ regulator-min-microvolt = <1100000>;
+ regulator-max-microvolt = <1300000>;
+ regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_FIXED>,
+ <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+ regulator-initial-mode = <ACT8945A_REGULATOR_MODE_FIXED>;
+ regulator-always-on;
+
+ regulator-state-mem {
+ regulator-off-in-suspend;
+ };
+ };
+
+ vdd_3v3_reg: REG_DCDC3 {
+ regulator-name = "VDD_3V3";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_FIXED>,
+ <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+ regulator-initial-mode = <ACT8945A_REGULATOR_MODE_FIXED>;
+ regulator-always-on;
+
+ regulator-state-mem {
+ regulator-off-in-suspend;
+ };
+ };
+
+ vdd_fuse_reg: REG_LDO1 {
+ regulator-name = "VDD_FUSE";
+ regulator-min-microvolt = <2500000>;
+ regulator-max-microvolt = <2500000>;
+ regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_NORMAL>,
+ <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+ regulator-initial-mode = <ACT8945A_REGULATOR_MODE_NORMAL>;
+ regulator-always-on;
+
+ regulator-state-mem {
+ regulator-off-in-suspend;
+ };
+ };
+
+ vdd_3v3_lp_reg: REG_LDO2 {
+ regulator-name = "VDD_3V3_LP";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_NORMAL>,
+ <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+ regulator-initial-mode = <ACT8945A_REGULATOR_MODE_NORMAL>;
+ regulator-always-on;
+
+ regulator-state-mem {
+ regulator-off-in-suspend;
+ };
+ };
+
+ vdd_led_reg: REG_LDO3 {
+ regulator-name = "VDD_LED";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_NORMAL>,
+ <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+ regulator-initial-mode = <ACT8945A_REGULATOR_MODE_NORMAL>;
+ regulator-always-on;
+
+ regulator-state-mem {
+ regulator-off-in-suspend;
+ };
+ };
+
+ vdd_sdhc_1v8_reg: REG_LDO4 {
+ regulator-name = "VDD_SDHC_1V8";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <1800000>;
+ regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_NORMAL>,
+ <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+ regulator-initial-mode = <ACT8945A_REGULATOR_MODE_NORMAL>;
+ regulator-always-on;
+
+ regulator-state-mem {
+ regulator-off-in-suspend;
+ };
+ };
+ };
+
+ charger {
+ compatible = "active-semi,act8945a-charger";
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_charger_chglev &pinctrl_charger_lbo &pinctrl_charger_irq>;
+ interrupt-parent = <&pioA>;
+ interrupts = <PIN_PB13 IRQ_TYPE_EDGE_RISING>;
+
+ active-semi,chglev-gpios = <&pioA PIN_PA12 GPIO_ACTIVE_HIGH>;
+ active-semi,lbo-gpios = <&pioA PIN_PC8 GPIO_ACTIVE_LOW>;
+ active-semi,input-voltage-threshold-microvolt = <6600>;
+ active-semi,precondition-timeout = <40>;
+ active-semi,total-timeout = <3>;
+ };
+ };
+};
+
+&adc {
+ vddana-supply = <&vdd_3v3_reg>;
+ vref-supply = <&vdd_3v3_reg>;
+ status = "disabled";
+};
+
+&pioA {
+ pinctrl_i2c0_default: i2c0_default {
+ pinmux = <PIN_PB31__TWD0>,
+ <PIN_PC0__TWCK0>;
+ bias-disable;
+ };
+
+ pinctrl_i2c1_default: i2c1_default {
+ pinmux = <PIN_PD4__TWD1>,
+ <PIN_PD5__TWCK1>;
+ bias-disable;
+ };
+
+ pinctrl_led_gpio_default: led_gpio_default {
+ pinmux = <PIN_PA6__GPIO>;
+ bias-pull-down;
+ };
+
+ pinctrl_sdmmc1_default: sdmmc1_default {
+ cmd_data {
+ pinmux = <PIN_PA28__SDMMC1_CMD>,
+ <PIN_PA18__SDMMC1_DAT0>,
+ <PIN_PA19__SDMMC1_DAT1>,
+ <PIN_PA20__SDMMC1_DAT2>,
+ <PIN_PA21__SDMMC1_DAT3>;
+ bias-pull-up;
+ };
+
+ conf-ck_cd {
+ pinmux = <PIN_PA22__SDMMC1_CK>,
+ <PIN_PA30__SDMMC1_CD>;
+ bias-disable;
+ };
+ };
+
+ pinctrl_spi0_default: spi0_default {
+ pinmux = <PIN_PA14__SPI0_SPCK>,
+ <PIN_PA15__SPI0_MOSI>,
+ <PIN_PA16__SPI0_MISO>;
+ bias-disable;
+ };
+
+ pinctrl_uart1_default: uart1_default {
+ pinmux = <PIN_PD2__URXD1>,
+ <PIN_PD3__UTXD1>;
+ bias-disable;
+ };
+
+ pinctrl_charger_chglev: charger_chglev {
+ pinmux = <PIN_PA12__GPIO>;
+ bias-disable;
+ };
+
+ pinctrl_charger_irq: charger_irq {
+ pinmux = <PIN_PB13__GPIO>;
+ bias-disable;
+ };
+
+ pinctrl_charger_lbo: charger_lbo {
+ pinmux = <PIN_PC8__GPIO>;
+ bias-pull-up;
+ };
+};
diff --git a/arch/arm/lib64/armlinux.c b/arch/arm/lib64/armlinux.c
index 31bd987f10..bcff770793 100644
--- a/arch/arm/lib64/armlinux.c
+++ b/arch/arm/lib64/armlinux.c
@@ -33,6 +33,8 @@
static int do_bootm_linux(struct image_data *data)
{
+ const void *kernel_header =
+ data->os_fit ? data->fit_kernel : data->os_header;
void (*fn)(unsigned long dtb, unsigned long x1, unsigned long x2,
unsigned long x3);
resource_size_t start, end;
@@ -41,8 +43,8 @@ static int do_bootm_linux(struct image_data *data)
int ret;
void *fdt;
- text_offset = le64_to_cpup(data->os_header + 8);
- image_size = le64_to_cpup(data->os_header + 16);
+ text_offset = le64_to_cpup(kernel_header + 8);
+ image_size = le64_to_cpup(kernel_header+ 16);
ret = memory_bank_first_find_space(&start, &end);
if (ret)
@@ -101,6 +103,12 @@ static struct image_handler aarch64_linux_handler = {
.filetype = filetype_arm64_linux_image,
};
+static struct image_handler aarch64_fit_handler = {
+ .name = "FIT image",
+ .bootm = do_bootm_linux,
+ .filetype = filetype_oftree,
+};
+
static int do_bootm_barebox(struct image_data *data)
{
void (*fn)(unsigned long x0, unsigned long x1, unsigned long x2,
@@ -144,6 +152,9 @@ static int aarch64_register_image_handler(void)
register_image_handler(&aarch64_linux_handler);
register_image_handler(&aarch64_barebox_handler);
+ if (IS_ENABLED(CONFIG_FITIMAGE))
+ register_image_handler(&aarch64_fit_handler);
+
return 0;
}
late_initcall(aarch64_register_image_handler);
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 5267102bf9..eb14cd2c28 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -41,12 +41,16 @@ config AT91SAM926X_BOARD_INIT
config AT91SAM9_SMC
bool
+config HAVE_AT91SAM9_RST
+ bool
+
config SOC_AT91SAM9
bool
select CPU_ARM926T
select AT91SAM9_SMC
select CLOCKSOURCE_ATMEL_PIT
select PINCTRL
+ select HAVE_AT91SAM9_RST
select HAVE_AT91_SMD
select HAVE_AT91_USB_CLK
select HAVE_AT91_UTMI
@@ -54,6 +58,7 @@ config SOC_AT91SAM9
config SOC_SAMA5
bool
+ select HAVE_AT91SAM9_RST
select CPU_V7
config SOC_SAMA5D2
@@ -582,6 +587,14 @@ config MACH_SAMA5D27_SOM1
help
Select this if you are using Microchip's sama5d27 SoM evaluation kit
+config MACH_SAMA5D27_GIANTBOARD
+ bool "Groboards SAMA5D27 Giant Board"
+ select SOC_SAMA5D2
+ select OFDEVICE
+ select COMMON_CLK_OF_PROVIDER
+ help
+ Select this if you are using the Groboards sama5d27 Giantboard
+
endif
comment "AT91 Board Options"
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 66d0b700f6..89aff54b8a 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -13,6 +13,7 @@ obj-y += at91sam9_reset.o
obj-y += at91sam9g45_reset.o
obj-$(CONFIG_AT91SAM9_SMC) += sam9_smc.o
+obj-$(CONFIG_HAVE_AT91SAM9_RST) += at91sam9_rst.o
# CPU-specific support
obj-$(CONFIG_SOC_AT91RM9200) += at91rm9200.o at91rm9200_time.o at91rm9200_devices.o
diff --git a/arch/arm/mach-at91/at91sam9_rst.c b/arch/arm/mach-at91/at91sam9_rst.c
new file mode 100644
index 0000000000..8f03576e69
--- /dev/null
+++ b/arch/arm/mach-at91/at91sam9_rst.c
@@ -0,0 +1,72 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2019 Pengutronix, Ahmad Fatoum <a.fatoum@pengutronix.de>
+ */
+
+#include <common.h>
+#include <init.h>
+#include <io.h>
+#include <restart.h>
+#include <linux/clk.h>
+#include <mach/at91_rstc.h>
+
+struct at91sam9x_rst {
+ struct restart_handler restart;
+ void __iomem *base;
+};
+
+static void __noreturn at91sam9x_restart_soc(struct restart_handler *rst)
+{
+ struct at91sam9x_rst *priv = container_of(rst, struct at91sam9x_rst, restart);
+
+ writel(AT91_RSTC_PROCRST
+ | AT91_RSTC_PERRST
+ | AT91_RSTC_EXTRST
+ | AT91_RSTC_KEY,
+ priv->base + AT91_RSTC_CR);
+
+ hang();
+}
+
+static int at91sam9x_rst_probe(struct device_d *dev)
+{
+ struct at91sam9x_rst *priv;
+ struct resource *iores;
+ struct clk *clk;
+
+ iores = dev_request_mem_resource(dev, 0);
+ if (IS_ERR(iores)) {
+ dev_err(dev, "could not get reset memory region\n");
+ return PTR_ERR(iores);
+ }
+
+ priv = xzalloc(sizeof(*priv));
+ priv->base = IOMEM(iores->start);
+
+ clk = clk_get(dev, NULL);
+ if (IS_ERR(clk)) {
+ release_region(iores);
+ free(priv);
+ return PTR_ERR(clk);
+ }
+
+ clk_enable(clk);
+
+ priv->restart.name = "at91sam9x-rst";
+ priv->restart.restart = at91sam9x_restart_soc;
+
+ return restart_handler_register(&priv->restart);
+}
+
+static const __maybe_unused struct of_device_id at91sam9x_rst_dt_ids[] = {
+ { .compatible = "atmel,at91sam9g45-rstc", },
+ { .compatible = "atmel,sama5d3-rstc", },
+ { /* sentinel */ },
+};
+
+static struct driver_d at91sam9x_rst_driver = {
+ .name = "at91sam9x-rst",
+ .of_compatible = DRV_OF_COMPAT(at91sam9x_rst_dt_ids),
+ .probe = at91sam9x_rst_probe,
+};
+device_platform_driver(at91sam9x_rst_driver);
diff --git a/common/block.c b/common/block.c
index 97cf5dc4de..02be80d7cc 100644
--- a/common/block.c
+++ b/common/block.c
@@ -36,7 +36,7 @@ struct chunk {
struct list_head list;
};
-#define BUFSIZE (PAGE_SIZE * 4)
+#define BUFSIZE (PAGE_SIZE * 16)
static int writebuffer_io_len(struct block_device *blk, struct chunk *chunk)
{
@@ -161,6 +161,14 @@ static int block_cache(struct block_device *blk, int block)
dev_dbg(blk->dev, "%s: %d to %d\n", __func__, chunk->block_start,
chunk->num);
+ if (chunk->block_start * BLOCKSIZE(blk) >= blk->discard_start &&
+ chunk->block_start * BLOCKSIZE(blk) + writebuffer_io_len(blk, chunk)
+ <= blk->discard_start + blk->discard_size) {
+ memset(chunk->data, 0, writebuffer_io_len(blk, chunk));
+ list_add(&chunk->list, &blk->buffered_blocks);
+ return 0;
+ }
+
ret = blk->ops->read(blk, chunk->data, chunk->block_start,
writebuffer_io_len(blk, chunk));
if (ret) {
@@ -337,11 +345,23 @@ static int block_op_flush(struct cdev *cdev)
{
struct block_device *blk = cdev->priv;
+ blk->discard_start = blk->discard_size = 0;
+
return writebuffer_flush(blk);
}
static int block_op_close(struct cdev *cdev) __alias(block_op_flush);
+static int block_op_discard_range(struct cdev *cdev, loff_t count, loff_t offset)
+{
+ struct block_device *blk = cdev->priv;
+
+ blk->discard_start = offset;
+ blk->discard_size = count;
+
+ return 0;
+}
+
static struct cdev_operations block_ops = {
.read = block_op_read,
#ifdef CONFIG_BLOCK_WRITE
@@ -349,6 +369,7 @@ static struct cdev_operations block_ops = {
#endif
.close = block_op_close,
.flush = block_op_flush,
+ .discard_range = block_op_discard_range,
};
int blockdevice_register(struct block_device *blk)
@@ -370,7 +391,7 @@ int blockdevice_register(struct block_device *blk)
dev_dbg(blk->dev, "rdbufsize: %d blockbits: %d blkmask: 0x%08x\n",
blk->rdbufsize, blk->blockbits, blk->blkmask);
- for (i = 0; i < 32; i++) {
+ for (i = 0; i < 8; i++) {
struct chunk *chunk = xzalloc(sizeof(*chunk));
chunk->data = dma_alloc(BUFSIZE);
chunk->num = i;
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index d4f411b4ad..2cd58df931 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -87,8 +87,8 @@ static int pcs_set_state(struct pinctrl_device *pdev, struct device_node *np)
for (i = 0; i < rows; i++) {
offset = be32_to_cpup(mux + index++);
- mask = be32_to_cpup(mux + index++);
val = be32_to_cpup(mux + index++);
+ mask = be32_to_cpup(mux + index++);
reg = pcs->read(pcs->base + offset);
reg &= ~mask;
reg |= val;
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 8874775f17..466bbe527b 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -406,6 +406,9 @@ static int usb_device_list_scan(void)
if (ret)
goto out;
}
+
+ /* Avoid hammering the HUB with port scans */
+ mdelay(25);
}
out:
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 0a3aff3cf0..426ee9db0b 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -957,6 +957,8 @@ static int fastboot_handle_sparse(struct f_fastboot *f_fb,
if (ret)
goto out;
} else {
+ discard_range(fd, retlen, pos);
+
pos = lseek(fd, pos, SEEK_SET);
if (pos == -1) {
ret = -errno;
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 4c11e6580c..b84da5516c 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1136,8 +1136,9 @@ fail2:
musb_platform_exit(musb);
fail1:
- dev_err(musb->controller,
- "musb_init_controller failed with status %d\n", status);
+ if (status != -EPROBE_DEFER)
+ dev_err(musb->controller,
+ "musb_init_controller failed with status %d\n", status);
musb_free(musb);
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 3b76b6cc61..d54a663e9d 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -39,7 +39,6 @@
#include <linux/barebox-wrapper.h>
#include "musb_core.h"
-#include "phy-am335x.h"
static __maybe_unused struct of_device_id musb_dsps_dt_ids[];
@@ -217,10 +216,6 @@ static int dsps_musb_init(struct musb *musb)
const struct dsps_musb_wrapper *wrp = glue->wrp;
u32 rev, val, mode;
- musb->xceiv = am335x_get_usb_phy();
- if (IS_ERR(musb->xceiv))
- return PTR_ERR(musb->xceiv);
-
/* Returns zero if e.g. not clocked */
rev = dsps_readl(musb->ctrl_base, wrp->revision);
if (!rev)
@@ -319,11 +314,13 @@ static int dsps_set_mode(void *ctx, enum usb_dr_mode mode)
static int dsps_probe(struct device_d *dev)
{
- struct resource *iores;
+ struct resource *iores[2];
struct musb_hdrc_platform_data *pdata;
struct musb_hdrc_config *config;
struct device_node *dn = dev->device_node;
const struct dsps_musb_wrapper *wrp;
+ struct device_node *phy_node;
+ struct device_d *phy_dev;
struct dsps_glue *glue;
int ret;
@@ -337,6 +334,14 @@ static int dsps_probe(struct device_d *dev)
return -ENODEV;
}
+ phy_node = of_parse_phandle(dn, "phys", 0);
+ if (!phy_node)
+ return -ENODEV;
+
+ phy_dev = of_find_device_by_node(phy_node);
+ if (!phy_dev || !phy_dev->priv)
+ return -EPROBE_DEFER;
+
/* allocate glue */
glue = kzalloc(sizeof(*glue), GFP_KERNEL);
if (!glue) {
@@ -349,17 +354,22 @@ static int dsps_probe(struct device_d *dev)
pdata = &glue->pdata;
- iores = dev_request_mem_resource(dev, 0);
- if (IS_ERR(iores))
- return PTR_ERR(iores);
- glue->musb.mregs = IOMEM(iores->start);
+ iores[0] = dev_request_mem_resource(dev, 0);
+ if (IS_ERR(iores[0])) {
+ ret = PTR_ERR(iores[0]);
+ goto free_glue;
+ }
+ glue->musb.mregs = IOMEM(iores[0]->start);
- iores = dev_request_mem_resource(dev, 1);
- if (IS_ERR(iores))
- return PTR_ERR(iores);
- glue->musb.ctrl_base = IOMEM(iores->start);
+ iores[1] = dev_request_mem_resource(dev, 1);
+ if (IS_ERR(iores[1])) {
+ ret = PTR_ERR(iores[1]);
+ goto release_iores0;
+ }
+ glue->musb.ctrl_base = IOMEM(iores[1]->start);
glue->musb.controller = dev;
+ glue->musb.xceiv = phy_dev->priv;
config = &glue->config;
@@ -377,11 +387,24 @@ static int dsps_probe(struct device_d *dev)
if (pdata->mode == MUSB_PORT_MODE_DUAL_ROLE) {
ret = usb_register_otg_device(dev, dsps_set_mode, glue);
if (ret)
- return ret;
+ goto release_iores1;
return 0;
}
- return musb_init_controller(&glue->musb, pdata);
+ ret = musb_init_controller(&glue->musb, pdata);
+ if (ret)
+ goto release_iores1;
+
+ return 0;
+
+release_iores1:
+ release_region(iores[1]);
+release_iores0:
+ release_region(iores[0]);
+free_glue:
+ free(glue);
+
+ return ret;
}
static const struct dsps_musb_wrapper am33xx_driver_data = {
diff --git a/drivers/usb/musb/phy-am335x-control.c b/drivers/usb/musb/phy-am335x-control.c
index c84525ec7e..41a3689ed3 100644
--- a/drivers/usb/musb/phy-am335x-control.c
+++ b/drivers/usb/musb/phy-am335x-control.c
@@ -109,15 +109,15 @@ struct phy_control *am335x_get_phy_control(struct device_d *dev)
node = of_parse_phandle(dev->device_node, "ti,ctrl_mod", 0);
if (!node)
- return NULL;
+ return ERR_PTR(-ENOENT);
dev = of_find_device_by_node(node);
if (!dev)
- return NULL;
+ return ERR_PTR(-EPROBE_DEFER);
ctrl_usb = dev->priv;
if (!ctrl_usb)
- return NULL;
+ return ERR_PTR(-EPROBE_DEFER);
return &ctrl_usb->phy_ctrl;
}
@@ -141,13 +141,17 @@ static int am335x_control_usb_probe(struct device_d *dev)
ctrl_usb->dev = dev;
iores = dev_request_mem_resource(dev, 0);
- if (IS_ERR(iores))
- return PTR_ERR(iores);
+ if (IS_ERR(iores)) {
+ ret = PTR_ERR(iores);
+ goto free_ctrl;
+ }
ctrl_usb->phy_reg = IOMEM(iores->start);
iores = dev_request_mem_resource(dev, 1);
- if (IS_ERR(iores))
- return PTR_ERR(iores);
+ if (IS_ERR(iores)) {
+ ret = PTR_ERR(iores);
+ goto release_resource;
+ }
ctrl_usb->wkup = IOMEM(iores->start);
spin_lock_init(&ctrl_usb->lock);
@@ -155,6 +159,13 @@ static int am335x_control_usb_probe(struct device_d *dev)
dev->priv = ctrl_usb;
return 0;
+
+release_resource:
+ release_region(iores);
+free_ctrl:
+ free(ctrl_usb);
+
+ return 0;
};
static struct driver_d am335x_control_driver = {
diff --git a/drivers/usb/musb/phy-am335x.c b/drivers/usb/musb/phy-am335x.c
index df31255d89..f2e870d7ee 100644
--- a/drivers/usb/musb/phy-am335x.c
+++ b/drivers/usb/musb/phy-am335x.c
@@ -5,7 +5,6 @@
#include <linux/err.h>
#include "am35x-phy-control.h"
#include "musb_core.h"
-#include "phy-am335x.h"
struct am335x_usbphy {
void __iomem *base;
@@ -14,13 +13,6 @@ struct am335x_usbphy {
struct usb_phy phy;
};
-static struct am335x_usbphy *am_usbphy;
-
-struct usb_phy *am335x_get_usb_phy(void)
-{
- return &am_usbphy->phy;
-}
-
static int am335x_init(struct usb_phy *phy)
{
struct am335x_usbphy *am_usbphy = container_of(phy, struct am335x_usbphy, phy);
@@ -31,6 +23,7 @@ static int am335x_init(struct usb_phy *phy)
static int am335x_phy_probe(struct device_d *dev)
{
+ struct am335x_usbphy *am_usbphy;
struct resource *iores;
int ret;
@@ -44,22 +37,27 @@ static int am335x_phy_probe(struct device_d *dev)
am_usbphy->base = IOMEM(iores->start);
am_usbphy->phy_ctrl = am335x_get_phy_control(dev);
- if (!am_usbphy->phy_ctrl)
- return -ENODEV;
+ if (IS_ERR(am_usbphy->phy_ctrl)) {
+ ret = PTR_ERR(am_usbphy->phy_ctrl);
+ goto err_release;
+ }
am_usbphy->id = of_alias_get_id(dev->device_node, "phy");
if (am_usbphy->id < 0) {
dev_err(dev, "Missing PHY id: %d\n", am_usbphy->id);
- return am_usbphy->id;
+ ret = am_usbphy->id;
+ goto err_release;
}
am_usbphy->phy.init = am335x_init;
- dev->priv = am_usbphy;
+ dev->priv = &am_usbphy->phy;
dev_info(dev, "am_usbphy %p enabled\n", &am_usbphy->phy);
return 0;
+err_release:
+ release_region(iores);
err_free:
free(am_usbphy);
diff --git a/drivers/usb/musb/phy-am335x.h b/drivers/usb/musb/phy-am335x.h
deleted file mode 100644
index 27da2e3b10..0000000000
--- a/drivers/usb/musb/phy-am335x.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _PHY_AM335x_H_
-#define _PHY_AM335x_H_
-
-struct usb_phy *am335x_get_usb_phy(void);
-
-#endif
diff --git a/fs/devfs.c b/fs/devfs.c
index d088c1a66c..e1893d1bd0 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -94,6 +94,26 @@ static int devfs_protect(struct device_d *_dev, FILE *f, size_t count, loff_t of
return cdev->ops->protect(cdev, count, offset + cdev->offset, prot);
}
+static int devfs_discard_range(struct device_d *dev, FILE *f, loff_t count,
+ loff_t offset)
+{
+ struct cdev *cdev = f->priv;
+
+ if (!cdev->ops->discard_range)
+ return -ENOSYS;
+
+ if (cdev->flags & DEVFS_PARTITION_READONLY)
+ return -EPERM;
+
+ if (offset >= cdev->size)
+ return 0;
+
+ if (count + offset > cdev->size)
+ count = cdev->size - offset;
+
+ return cdev->ops->discard_range(cdev, count, offset + cdev->offset);
+}
+
static int devfs_memmap(struct device_d *_dev, FILE *f, void **map, int flags)
{
struct cdev *cdev = f->priv;
@@ -329,6 +349,7 @@ static struct fs_driver_d devfs_driver = {
.truncate = devfs_truncate,
.erase = devfs_erase,
.protect = devfs_protect,
+ .discard_range = devfs_discard_range,
.memmap = devfs_memmap,
.flags = FS_DRIVER_NO_DEV,
.drv = {
diff --git a/fs/fs.c b/fs/fs.c
index 12faaebc27..e00bbcd223 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -497,6 +497,31 @@ int protect(int fd, size_t count, loff_t offset, int prot)
}
EXPORT_SYMBOL(protect);
+int discard_range(int fd, loff_t count, loff_t offset)
+{
+ struct fs_driver_d *fsdrv;
+ FILE *f = fd_to_file(fd);
+ int ret;
+
+ if (IS_ERR(f))
+ return -errno;
+ if (offset >= f->size)
+ return 0;
+ if (count > f->size - offset)
+ count = f->size - offset;
+
+ fsdrv = f->fsdev->driver;
+ if (fsdrv->discard_range)
+ ret = fsdrv->discard_range(&f->fsdev->dev, f, count, offset);
+ else
+ ret = -ENOSYS;
+
+ if (ret)
+ errno = -ret;
+
+ return ret;
+}
+
int protect_file(const char *file, int prot)
{
int fd, ret;
diff --git a/images/Makefile.at91 b/images/Makefile.at91
index f321bdec36..448d71fb98 100644
--- a/images/Makefile.at91
+++ b/images/Makefile.at91
@@ -17,3 +17,7 @@ image-$(CONFIG_MACH_MICROCHIP_KSZ9477_EVB) += barebox-microchip-ksz9477-evb.img
pblb-$(CONFIG_MACH_SAMA5D27_SOM1) += start_sama5d27_som1_ek
FILE_barebox-sama5d27-som1-ek.img = start_sama5d27_som1_ek.pblb
image-$(CONFIG_MACH_SAMA5D27_SOM1) += barebox-sama5d27-som1-ek.img
+
+pblb-$(CONFIG_MACH_SAMA5D27_GIANTBOARD) += start_sama5d27_giantboard
+FILE_barebox-groboards-sama5d27-giantboard.img = start_sama5d27_giantboard.pblb
+image-$(CONFIG_MACH_SAMA5D27_GIANTBOARD) += barebox-groboards-sama5d27-giantboard.img
diff --git a/include/block.h b/include/block.h
index bd87efdc62..a1de266194 100644
--- a/include/block.h
+++ b/include/block.h
@@ -24,6 +24,9 @@ struct block_device {
int rdbufsize;
int blkmask;
+ loff_t discard_start;
+ loff_t discard_size;
+
struct list_head buffered_blocks;
struct list_head idle_blocks;
diff --git a/include/driver.h b/include/driver.h
index 6176e6a05f..fac3953ef4 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -431,6 +431,7 @@ struct cdev_operations {
int (*flush)(struct cdev*);
int (*erase)(struct cdev*, loff_t count, loff_t offset);
int (*protect)(struct cdev*, size_t count, loff_t offset, int prot);
+ int (*discard_range)(struct cdev*, loff_t count, loff_t offset);
int (*memmap)(struct cdev*, void **map, int flags);
int (*truncate)(struct cdev*, size_t size);
};
diff --git a/include/fs.h b/include/fs.h
index 04ec1329e1..5811199c01 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -61,6 +61,8 @@ struct fs_driver_d {
loff_t offset);
int (*protect)(struct device_d *dev, FILE *f, size_t count,
loff_t offset, int prot);
+ int (*discard_range)(struct device_d *dev, FILE *f, loff_t count,
+ loff_t offset);
int (*memmap)(struct device_d *dev, FILE *f, void **map, int flags);
@@ -128,6 +130,7 @@ int umount_by_cdev(struct cdev *cdev);
#define ERASE_SIZE_ALL ((loff_t) - 1)
int erase(int fd, loff_t count, loff_t offset);
int protect(int fd, size_t count, loff_t offset, int prot);
+int discard_range(int fd, loff_t count, loff_t offset);
int protect_file(const char *file, int prot);
void *memmap(int fd, int flags);
diff --git a/lib/libfile.c b/lib/libfile.c
index 5a1817e32a..dbeed12ccd 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -367,6 +367,8 @@ int copy_file(const char *src, const char *dst, int verbose)
goto out;
}
+ discard_range(dstfd, srcstat.st_size, 0);
+
if (verbose) {
if (stat(src, &srcstat) < 0)
srcstat.st_size = 0;