* [PATCH 1/5] Revert "mtd: nand: drop DT support in legacy driver"
2023-09-26 18:38 [PATCH 0/5] ARM: at91: add first DT support for Calao usb/tny boards Ahmad Fatoum
@ 2023-09-26 18:38 ` Ahmad Fatoum
2023-09-26 18:38 ` [PATCH 2/5] ARM: at91: add SDRAMC driver for memory detection Ahmad Fatoum
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-09-26 18:38 UTC (permalink / raw)
To: barebox; +Cc: wsa, Ahmad Fatoum
DT support was removed with the rationale that all DT-enabled platforms
are supported by the new driver ported from Linux. The new driver
however refuses to work the AT91SAM9263. Until that's figured it,
restore DT support in the legacy driver.
This reverts commit 1fd8336bb0fe46856d2881121dd61bf560910448.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/mtd/nand/Kconfig | 8 ++-
drivers/mtd/nand/atmel/legacy.c | 104 +++++++++++++++++++++++++++++++-
2 files changed, 109 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 87926d88d2c6..19f4322f65a1 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -114,10 +114,14 @@ config NAND_ATMEL
depends on ARCH_AT91 || (OFDEVICE && COMPILE_TEST)
config NAND_ATMEL_LEGACY
- def_bool !AT91_MULTI_BOARDS
+ def_bool !AT91_MULTI_BOARDS || SOC_AT91SAM9
depends on NAND_ATMEL
help
- Select legacy non-device tree enabled driver.
+ Select legacy driver for non-DT-enabled platforms
+ and for the deprecated non-EBI binding.
+
+ The deprecated binding is currently the only one
+ support for AT91SAM9.
config NAND_ATMEL_PMECC
bool
diff --git a/drivers/mtd/nand/atmel/legacy.c b/drivers/mtd/nand/atmel/legacy.c
index cf402549b857..cee9e49be021 100644
--- a/drivers/mtd/nand/atmel/legacy.c
+++ b/drivers/mtd/nand/atmel/legacy.c
@@ -23,6 +23,10 @@
#include <init.h>
#include <gpio.h>
+#include <of.h>
+#include <of_gpio.h>
+#include <of_mtd.h>
+
#include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h>
#include <linux/mtd/nand.h>
@@ -1105,6 +1109,92 @@ static void atmel_nand_hwctl(struct nand_chip *nand_chip, int mode)
{
}
+static int atmel_nand_of_init(struct atmel_nand_host *host, struct device_node *np)
+{
+ u32 val;
+ u32 offset[2];
+ int ecc_mode;
+ struct atmel_nand_data *board = host->board;
+ enum of_gpio_flags flags = 0;
+
+ if (!IS_ENABLED(CONFIG_OFDEVICE))
+ return -ENOSYS;
+
+ if (of_property_read_u32(np, "atmel,nand-addr-offset", &val) == 0) {
+ if (val >= 32) {
+ dev_err(host->dev, "invalid addr-offset %u\n", val);
+ return -EINVAL;
+ }
+ board->ale = val;
+ }
+
+ if (of_property_read_u32(np, "atmel,nand-cmd-offset", &val) == 0) {
+ if (val >= 32) {
+ dev_err(host->dev, "invalid cmd-offset %u\n", val);
+ return -EINVAL;
+ }
+ board->cle = val;
+ }
+
+ ecc_mode = of_get_nand_ecc_mode(np);
+
+ board->ecc_mode = ecc_mode < 0 ? NAND_ECC_SOFT : ecc_mode;
+
+ board->on_flash_bbt = of_get_nand_on_flash_bbt(np);
+
+ if (of_get_nand_bus_width(np) == 16)
+ board->bus_width_16 = 1;
+
+ board->rdy_pin = of_get_gpio_flags(np, 0, &flags);
+ board->enable_pin = of_get_gpio(np, 1);
+ board->det_pin = of_get_gpio(np, 2);
+
+ board->has_pmecc = of_property_read_bool(np, "atmel,has-pmecc");
+
+ if (!(board->ecc_mode == NAND_ECC_HW) || !board->has_pmecc)
+ return 0; /* Not using PMECC */
+
+ /* use PMECC, get correction capability, sector size and lookup
+ * table offset.
+ * If correction bits and sector size are not specified, then
+ * find
+ * them from NAND ONFI parameters.
+ */
+ if (of_property_read_u32(np, "atmel,pmecc-cap", &val) == 0) {
+ if ((val != 2) && (val != 4) && (val != 8) && (val != 12) && (val != 24)) {
+ dev_err(host->dev, "Unsupported PMECC correction capability: %d"
+ " should be 2, 4, 8, 12 or 24\n", val);
+ return -EINVAL;
+ }
+
+ board->pmecc_corr_cap = (u8)val;
+ }
+
+ if (of_property_read_u32(np, "atmel,pmecc-sector-size", &val) == 0) {
+ if ((val != 512) && (val != 1024)) {
+ dev_err(host->dev, "Unsupported PMECC sector size: %d"
+ " should be 512 or 1024 bytes\n", val);
+ return -EINVAL;
+ }
+
+ board->pmecc_sector_size = (u16)val;
+ }
+
+ if (of_property_read_u32_array(np, "atmel,pmecc-lookup-table-offset", offset, 2) != 0) {
+ dev_err(host->dev, "Cannot get PMECC lookup table offset\n");
+ return -EINVAL;
+ }
+
+ if (!offset[0] && !offset[1]) {
+ dev_err(host->dev, "Invalid PMECC lookup table offset\n");
+ return -EINVAL;
+ }
+
+ board->pmecc_lookup_table_offset = (board->pmecc_sector_size == 512) ? offset[0] : offset[1];
+
+ return 0;
+}
+
static int atmel_hw_nand_init_params(struct device *dev,
struct atmel_nand_host *host)
{
@@ -1191,7 +1281,13 @@ static int __init atmel_nand_probe(struct device *dev)
host->board = pdata;
host->dev = dev;
- memcpy(host->board, dev->platform_data, sizeof(struct atmel_nand_data));
+ if (dev->of_node) {
+ res = atmel_nand_of_init(host, dev->of_node);
+ if (res)
+ goto err_no_card;
+ } else {
+ memcpy(host->board, dev->platform_data, sizeof(struct atmel_nand_data));
+ }
nand_chip->priv = host; /* link the private data structures */
mtd->dev.parent = dev;
@@ -1327,9 +1423,15 @@ static int __init atmel_nand_probe(struct device *dev)
return res;
}
+static struct of_device_id atmel_nand_dt_ids[] = {
+ { .compatible = "atmel,at91rm9200-nand" },
+ { /* sentinel */ }
+};
+
static struct driver atmel_nand_driver = {
.name = "atmel_nand",
.probe = atmel_nand_probe,
+ .of_compatible = DRV_OF_COMPAT(atmel_nand_dt_ids),
};
device_platform_driver(atmel_nand_driver);
--
2.39.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/5] ARM: at91: add SDRAMC driver for memory detection
2023-09-26 18:38 [PATCH 0/5] ARM: at91: add first DT support for Calao usb/tny boards Ahmad Fatoum
2023-09-26 18:38 ` [PATCH 1/5] Revert "mtd: nand: drop DT support in legacy driver" Ahmad Fatoum
@ 2023-09-26 18:38 ` Ahmad Fatoum
2023-09-26 18:38 ` [PATCH 3/5] ARM: at91: at91sam9_rst: add DT support for at91sam9260 Ahmad Fatoum
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-09-26 18:38 UTC (permalink / raw)
To: barebox; +Cc: wsa, Ahmad Fatoum
We already have support to read back memory size from the SDRAM
controller on older AT91 processor via the at91_get_sdram_size()
function, but that's mostly called from board code.
Add a proper driver that can probe the SDRAM device in the DT to
dynamically detect the memory without hardcoding.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/mach-at91/Kconfig | 3 ++
arch/arm/mach-at91/Makefile | 1 +
arch/arm/mach-at91/sdramc.c | 47 +++++++++++++++++++++++++++++
include/mach/at91/at91sam9_sdramc.h | 4 +++
4 files changed, 55 insertions(+)
create mode 100644 arch/arm/mach-at91/sdramc.c
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index d2499747252d..1197e06670c7 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -42,6 +42,9 @@ config HAVE_AT91_I2S_MUX_CLK
config HAVE_AT91_SAM9X60_PLL
bool
+config HAVE_AT91_SDRAMC
+ bool
+
config HAVE_AT91_DDRAMC
bool
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 301e0b761b26..777dc6d1aa3c 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_BOOTM) += bootm-barebox.o
obj-y += at91sam9_reset.o
obj-y += at91sam9g45_reset.o
obj-pbl-$(CONFIG_HAVE_AT91_DDRAMC) += ddramc.o
+obj-pbl-$(CONFIG_HAVE_AT91_SDRAMC) += sdramc.o
pbl-$(CONFIG_AT91_MCI_PBL) += xload-mmc.o
pbl-$(CONFIG_AT91_MCI_PBL) += at91sam9_xload_mmc.o
diff --git a/arch/arm/mach-at91/sdramc.c b/arch/arm/mach-at91/sdramc.c
new file mode 100644
index 000000000000..655f24ecd9ad
--- /dev/null
+++ b/arch/arm/mach-at91/sdramc.c
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2020 Ahmad Fatoum <a.fatoum@pengutronix.de>
+ */
+
+#include <common.h>
+#include <init.h>
+#include <mach/at91/hardware.h>
+#include <asm/barebox-arm.h>
+#include <mach/at91/at91sam9_sdramc.h>
+#include <asm/memory.h>
+#include <pbl.h>
+#include <io.h>
+
+void __noreturn at91sam9260_barebox_entry(void *boarddata)
+{
+ barebox_arm_entry(AT91_CHIPSELECT_1,
+ at91_get_sdram_size(IOMEM(AT91SAM9260_BASE_SDRAMC)),
+ boarddata);
+}
+
+static int at91_sdramc_probe(struct device *dev)
+{
+ struct resource *iores;
+ void __iomem *base;
+
+ iores = dev_request_mem_resource(dev, 0);
+ if (IS_ERR(iores))
+ return PTR_ERR(iores);
+ base = IOMEM(iores->start);
+
+ return arm_add_mem_device("ram0", AT91_CHIPSELECT_1,
+ at91_get_sdram_size(base));
+}
+
+static struct of_device_id at91_sdramc_dt_ids[] = {
+ { .compatible = "atmel,at91sam9260-sdramc" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, at91_sdramc_dt_ids);
+
+static struct driver at91_sdramc_driver = {
+ .name = "at91sam9260-sdramc",
+ .probe = at91_sdramc_probe,
+ .of_compatible = at91_sdramc_dt_ids,
+};
+mem_platform_driver(at91_sdramc_driver);
diff --git a/include/mach/at91/at91sam9_sdramc.h b/include/mach/at91/at91sam9_sdramc.h
index a4c88b24d4a0..2ba73cd2f2dc 100644
--- a/include/mach/at91/at91sam9_sdramc.h
+++ b/include/mach/at91/at91sam9_sdramc.h
@@ -13,6 +13,8 @@
#ifndef AT91SAM9_SDRAMC_H
#define AT91SAM9_SDRAMC_H
+#include <linux/compiler.h>
+
/* SDRAM Controller (SDRAMC) registers */
#define AT91_SDRAMC_MR 0x00 /* SDRAM Controller Mode Register */
#define AT91_SDRAMC_MODE (0xf << 0) /* Command Mode */
@@ -268,5 +270,7 @@ static inline bool at91sam9263_is_low_power_sdram(int bank)
}
}
+void __noreturn at91sam9260_barebox_entry(void *boarddata);
+
#endif
#endif
--
2.39.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/5] ARM: at91: at91sam9_rst: add DT support for at91sam9260
2023-09-26 18:38 [PATCH 0/5] ARM: at91: add first DT support for Calao usb/tny boards Ahmad Fatoum
2023-09-26 18:38 ` [PATCH 1/5] Revert "mtd: nand: drop DT support in legacy driver" Ahmad Fatoum
2023-09-26 18:38 ` [PATCH 2/5] ARM: at91: add SDRAMC driver for memory detection Ahmad Fatoum
@ 2023-09-26 18:38 ` Ahmad Fatoum
2023-09-26 18:38 ` [PATCH 4/5] ARM: at91: sam9260: don't build non-DT device support when unneeded Ahmad Fatoum
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-09-26 18:38 UTC (permalink / raw)
To: barebox; +Cc: wsa, Ahmad Fatoum
AT91SAM9260 needs a special reset sequence that we already implement
at91sam9_reset(). Make it easily available to DT-enabled boards by
adding it to the at91sam9_rst driver used for newer SoCs.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/mach-at91/at91sam9_rst.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-at91/at91sam9_rst.c b/arch/arm/mach-at91/at91sam9_rst.c
index db7411a053d6..d2c008e3439a 100644
--- a/arch/arm/mach-at91/at91sam9_rst.c
+++ b/arch/arm/mach-at91/at91sam9_rst.c
@@ -10,6 +10,7 @@
#include <linux/bitfield.h>
#include <linux/clk.h>
#include <mach/at91/at91_rstc.h>
+#include <mach/at91/at91sam9260.h>
#include <reset_source.h>
struct at91sam9x_rst {
@@ -56,6 +57,16 @@ static void __noreturn at91sam9x_restart_soc(struct restart_handler *rst)
hang();
}
+void __noreturn at91sam9_reset(void __iomem *sdram, void __iomem *rstc_cr);
+
+static void __noreturn at91sam9260_restart_soc(struct restart_handler *rst)
+{
+ struct at91sam9x_rst *priv = container_of(rst, struct at91sam9x_rst, restart);
+
+ at91sam9_reset(IOMEM(AT91SAM9260_BASE_SDRAMC),
+ IOMEM(priv->base + AT91_RSTC_CR));
+}
+
static int at91sam9x_rst_probe(struct device *dev)
{
struct at91sam9x_rst *priv;
@@ -83,14 +94,15 @@ static int at91sam9x_rst_probe(struct device *dev)
at91sam9x_set_reset_reason(dev, priv->base);
priv->restart.name = "at91sam9x-rst";
- priv->restart.restart = at91sam9x_restart_soc;
+ priv->restart.restart = device_get_match_data(dev);
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", },
+ { .compatible = "atmel,at91sam9260-rstc", at91sam9260_restart_soc },
+ { .compatible = "atmel,at91sam9g45-rstc", at91sam9x_restart_soc },
+ { .compatible = "atmel,sama5d3-rstc", at91sam9x_restart_soc },
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, at91sam9x_rst_dt_ids);
--
2.39.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 4/5] ARM: at91: sam9260: don't build non-DT device support when unneeded
2023-09-26 18:38 [PATCH 0/5] ARM: at91: add first DT support for Calao usb/tny boards Ahmad Fatoum
` (2 preceding siblings ...)
2023-09-26 18:38 ` [PATCH 3/5] ARM: at91: at91sam9_rst: add DT support for at91sam9260 Ahmad Fatoum
@ 2023-09-26 18:38 ` Ahmad Fatoum
2023-09-26 18:38 ` [PATCH 5/5] ARM: at91: add first DT support for Calao usb/tny boards Ahmad Fatoum
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-09-26 18:38 UTC (permalink / raw)
To: barebox; +Cc: wsa, Ahmad Fatoum
The _device.c files create helper functions for creating devices for
legacy boards that do not support CONFIG_AT91_MULTI_BOARDS.
We are adding DT support for 9260, so guard the file behind a
!CONFIG_AT91_MULTI_BOARDS check.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/mach-at91/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 777dc6d1aa3c..c4532959556e 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -25,10 +25,10 @@ obj-$(CONFIG_HAVE_AT91SAM9_RST) += at91sam9_rst.o
# CPU-specific support
obj-$(CONFIG_SOC_AT91RM9200) += at91rm9200.o at91rm9200_time.o at91rm9200_devices.o
-obj-$(CONFIG_SOC_AT91SAM9260) += at91sam9260.o at91sam9260_devices.o
obj-$(CONFIG_SOC_AT91SAM9261) += at91sam9261.o at91sam9261_devices.o
obj-$(CONFIG_SOC_AT91SAM9G10) += at91sam9261.o at91sam9261_devices.o
ifeq ($(CONFIG_AT91_MULTI_BOARDS),)
+obj-$(CONFIG_SOC_AT91SAM9260) += at91sam9260.o at91sam9260_devices.o
obj-$(CONFIG_SOC_AT91SAM9263) += at91sam9263.o at91sam9263_devices.o
obj-$(CONFIG_SOC_SAMA5D3) += sama5d3.o sama5d3_devices.o
obj-$(CONFIG_SOC_SAMA5D4) += sama5d4.o sama5d4_devices.o
--
2.39.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 5/5] ARM: at91: add first DT support for Calao usb/tny boards
2023-09-26 18:38 [PATCH 0/5] ARM: at91: add first DT support for Calao usb/tny boards Ahmad Fatoum
` (3 preceding siblings ...)
2023-09-26 18:38 ` [PATCH 4/5] ARM: at91: sam9260: don't build non-DT device support when unneeded Ahmad Fatoum
@ 2023-09-26 18:38 ` Ahmad Fatoum
2023-09-26 21:21 ` OFFLIST Re: [PATCH 0/5] " Wolfram Sang
2023-10-04 8:25 ` Sascha Hauer
6 siblings, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-09-26 18:38 UTC (permalink / raw)
To: barebox; +Cc: wsa, Ahmad Fatoum
We have a lot of defconfigs for ARM9 AT91 boards, that we want to get
rid off after migrating the boards to at91_multi_defconfig.
Thanks to a temporarily donated Calao USB-A9G20 by Wolfram, we start by
switching the Calao boards to DT.
This is not yet a complete replacement:
- We use the legacy NAND driver instead of the newly backported driver
that Linux uses with the hardware, presumably without issues
- OHCI hangs during probe, so it's disabled for now
- A barebox with comparative functionality to the non-DT version
exceeds the 256K partition size
These can be resolved separately though, so add here first DT support.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/boards/Makefile | 1 +
arch/arm/boards/calao/Makefile | 4 +++
arch/arm/boards/calao/board.c | 13 ++++++++
arch/arm/boards/calao/lowlevel.c | 30 +++++++++++++++++
arch/arm/configs/at91_multi_defconfig | 4 +--
arch/arm/dts/Makefile | 3 ++
arch/arm/dts/at91sam9260.dtsi | 33 ++++++++++++++++++
arch/arm/dts/at91sam9g20.dtsi | 2 ++
arch/arm/dts/calao_nand.dtsi | 48 +++++++++++++++++++++++++++
arch/arm/dts/tny_a9260.dts | 4 +++
arch/arm/dts/tny_a9g20.dts | 4 +++
arch/arm/dts/usb_a9260.dts | 4 +++
arch/arm/dts/usb_a9g20.dts | 4 +++
arch/arm/mach-at91/Kconfig | 10 ++++++
images/Makefile.at91 | 9 +++++
include/mach/at91/at91sam9260.h | 1 +
include/mach/at91/at91sam9g45.h | 1 +
17 files changed, 173 insertions(+), 2 deletions(-)
create mode 100644 arch/arm/boards/calao/Makefile
create mode 100644 arch/arm/boards/calao/board.c
create mode 100644 arch/arm/boards/calao/lowlevel.c
create mode 100644 arch/arm/dts/at91sam9260.dtsi
create mode 100644 arch/arm/dts/at91sam9g20.dtsi
create mode 100644 arch/arm/dts/calao_nand.dtsi
create mode 100644 arch/arm/dts/tny_a9260.dts
create mode 100644 arch/arm/dts/tny_a9g20.dts
create mode 100644 arch/arm/dts/usb_a9260.dts
create mode 100644 arch/arm/dts/usb_a9g20.dts
diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
index c285ed7aee2d..bdac1e69ee60 100644
--- a/arch/arm/boards/Makefile
+++ b/arch/arm/boards/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_MACH_AT91SAM9N12EK) += at91sam9n12ek/
obj-$(CONFIG_MACH_AT91SAM9X5EK) += at91sam9x5ek/
obj-$(CONFIG_MACH_BEAGLE) += beagle/
obj-$(CONFIG_MACH_BEAGLEBONE) += beaglebone/
+obj-$(CONFIG_MACH_CALAO) += calao/
obj-$(CONFIG_MACH_CANON_A1100) += canon-a1100/
obj-$(CONFIG_MACH_CM_FX6) += cm-fx6/
obj-$(CONFIG_MACH_NITROGEN6) += boundarydevices-nitrogen6/
diff --git a/arch/arm/boards/calao/Makefile b/arch/arm/boards/calao/Makefile
new file mode 100644
index 000000000000..da63d2625f7a
--- /dev/null
+++ b/arch/arm/boards/calao/Makefile
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+obj-y += board.o
+lwl-y += lowlevel.o
diff --git a/arch/arm/boards/calao/board.c b/arch/arm/boards/calao/board.c
new file mode 100644
index 000000000000..cc369c4cf1c1
--- /dev/null
+++ b/arch/arm/boards/calao/board.c
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <deep-probe.h>
+#include <of.h>
+
+static const struct of_device_id calao_of_match[] = {
+ { .compatible = "calao,tny-a9260" },
+ { .compatible = "calao,tny-a9g20" },
+ { .compatible = "calao,usb-a9260" },
+ { .compatible = "calao,usb-a9g20" },
+ { /* sentinel */ },
+};
+BAREBOX_DEEP_PROBE_ENABLE(calao_of_match);
diff --git a/arch/arm/boards/calao/lowlevel.c b/arch/arm/boards/calao/lowlevel.c
new file mode 100644
index 000000000000..2a081a97a4e3
--- /dev/null
+++ b/arch/arm/boards/calao/lowlevel.c
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <common.h>
+#include <init.h>
+#include <debug_ll.h>
+#include <asm/reloc.h>
+#include <mach/at91/barebox-arm.h>
+#include <mach/at91/at91sam9_sdramc.h>
+#include <mach/at91/at91sam9260.h>
+#include <mach/at91/hardware.h>
+
+static void dbgu_init(void)
+{
+ /* pinmux/clocks/uart already configured by first stage */
+ putc_ll('>');
+}
+
+#define CALAO_ENTRY_2ND(entrypoint, dtbname) \
+AT91_ENTRY_FUNCTION(entrypoint, r0, r1, r2) { \
+ extern char __dtb_z_##dtbname##_start[]; \
+ arm_cpu_lowlevel_init(); \
+ arm_setup_stack(AT91SAM9260_SRAM_END); \
+ dbgu_init(); \
+ at91sam9260_barebox_entry(runtime_address(__dtb_z_##dtbname##_start)); \
+}
+
+CALAO_ENTRY_2ND(start_tny_a9260, tny_a9260);
+CALAO_ENTRY_2ND(start_tny_a9g20, tny_a9g20);
+CALAO_ENTRY_2ND(start_usb_a9260, usb_a9260);
+CALAO_ENTRY_2ND(start_usb_a9g20, usb_a9g20);
diff --git a/arch/arm/configs/at91_multi_defconfig b/arch/arm/configs/at91_multi_defconfig
index de47af3bd0a6..e24bb36c2890 100644
--- a/arch/arm/configs/at91_multi_defconfig
+++ b/arch/arm/configs/at91_multi_defconfig
@@ -1,5 +1,6 @@
CONFIG_ARCH_AT91=y
CONFIG_AT91_MULTI_BOARDS=y
+CONFIG_MACH_CALAO=y
CONFIG_MACH_SKOV_ARM9CPU=y
CONFIG_MACH_AT91SAM9263EK=y
CONFIG_MACH_AT91SAM9X5EK=y
@@ -98,6 +99,7 @@ CONFIG_I2C=y
CONFIG_I2C_AT91=y
CONFIG_MTD=y
CONFIG_NAND=y
+CONFIG_MTD_NAND_ECC_SOFT=y
CONFIG_NAND_ATMEL=y
CONFIG_MTD_UBI=y
CONFIG_MTD_UBI_FASTMAP=y
@@ -117,7 +119,6 @@ CONFIG_MCI_MMC_BOOT_PARTITIONS=y
CONFIG_MCI_MMC_GPP_PARTITIONS=y
CONFIG_MCI_ATMEL_SDHCI=y
CONFIG_MFD_ATMEL_FLEXCOM=y
-CONFIG_STATE_DRV=y
CONFIG_LED=y
CONFIG_LED_GPIO=y
CONFIG_LED_GPIO_OF=y
@@ -141,6 +142,5 @@ CONFIG_FS_EXT4=y
CONFIG_FS_TFTP=y
CONFIG_FS_NFS=y
CONFIG_FS_FAT=y
-CONFIG_FS_FAT_LFN=y
CONFIG_FS_UBIFS=y
CONFIG_FS_UBIFS_COMPRESSION_LZO=y
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 97fbb8115341..e9512a30c812 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -194,6 +194,9 @@ lwl-$(CONFIG_MACH_ZII_VF610_DEV) += \
vf610-zii-spb4.dtb.o \
vf610-zii-ssmb-dtu.dtb.o
lwl-$(CONFIG_MACH_AC_SXB) += ac-sxb.dtb.o
+lwl-$(CONFIG_MACH_CALAO) += \
+ tny_a9260.dtb.o tny_a9g20.dtb.o \
+ usb_a9260.dtb.o usb_a9g20.dtb.o
lwl-$(CONFIG_MACH_AT91SAM9263EK_DT) += at91sam9263ek.dtb.o
lwl-$(CONFIG_MACH_SAMA5D3_XPLAINED) += at91-sama5d3_xplained.dtb.o
lwl-$(CONFIG_MACH_MICROCHIP_KSZ9477_EVB) += at91-microchip-ksz9477-evb.dtb.o
diff --git a/arch/arm/dts/at91sam9260.dtsi b/arch/arm/dts/at91sam9260.dtsi
new file mode 100644
index 000000000000..828ab6646e85
--- /dev/null
+++ b/arch/arm/dts/at91sam9260.dtsi
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+&ebi {
+ status = "disabled";
+};
+
+&nand_controller {
+ status = "disabled";
+};
+
+&{/ahb/apb} {
+ nand0: nand@40000000 {
+ compatible = "atmel,at91rm9200-nand";
+ #address-cells = <1>;
+ #size-cells = <1>;
+ reg = <0x40000000 0x10000000
+ 0xffffe800 0x200
+ >;
+ atmel,nand-addr-offset = <21>;
+ atmel,nand-cmd-offset = <22>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_nand_cs &pinctrl_nand_rb>;
+ gpios = <&pioC 13 GPIO_ACTIVE_HIGH
+ &pioC 14 GPIO_ACTIVE_HIGH
+ 0
+ >;
+ status = "disabled";
+ };
+};
+
+&usb0 { /* currently hangs with DT-enabled driver */
+ status = "disabled";
+};
diff --git a/arch/arm/dts/at91sam9g20.dtsi b/arch/arm/dts/at91sam9g20.dtsi
new file mode 100644
index 000000000000..b8301a8ce7de
--- /dev/null
+++ b/arch/arm/dts/at91sam9g20.dtsi
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include "at91sam9260.dtsi"
diff --git a/arch/arm/dts/calao_nand.dtsi b/arch/arm/dts/calao_nand.dtsi
new file mode 100644
index 000000000000..e42d6cdc8c01
--- /dev/null
+++ b/arch/arm/dts/calao_nand.dtsi
@@ -0,0 +1,48 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+&nand0 {
+ nand-bus-width = <8>;
+ nand-ecc-mode = "soft";
+ nand-on-flash-bbt;
+ status = "okay";
+
+ at91bootstrap@0 {
+ label = "at91bootstrap";
+ reg = <0x0 0x20000>;
+ };
+
+ barebox@20000 {
+ label = "barebox";
+ reg = <0x20000 0x40000>;
+ };
+
+ bareboxenv@60000 {
+ label = "bareboxenv";
+ reg = <0x60000 0x20000>;
+ };
+
+ bareboxenv2@80000 {
+ label = "bareboxenv2";
+ reg = <0x80000 0x20000>;
+ };
+
+ oftree@80000 {
+ label = "oftree";
+ reg = <0xa0000 0x20000>;
+ };
+
+ kernel@a0000 {
+ label = "kernel";
+ reg = <0xc0000 0x400000>;
+ };
+
+ rootfs@4a0000 {
+ label = "rootfs";
+ reg = <0x4c0000 0x7800000>;
+ };
+
+ data@7ca0000 {
+ label = "data";
+ reg = <0x7cc0000 0x8340000>;
+ };
+};
diff --git a/arch/arm/dts/tny_a9260.dts b/arch/arm/dts/tny_a9260.dts
new file mode 100644
index 000000000000..2c4df66f7a75
--- /dev/null
+++ b/arch/arm/dts/tny_a9260.dts
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include <arm/microchip/tny_a9260.dts>
+#include "at91sam9260.dtsi"
+#include "calao_nand.dtsi"
diff --git a/arch/arm/dts/tny_a9g20.dts b/arch/arm/dts/tny_a9g20.dts
new file mode 100644
index 000000000000..654a988c44c3
--- /dev/null
+++ b/arch/arm/dts/tny_a9g20.dts
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include <arm/microchip/tny_a9g20.dts>
+#include "at91sam9g20.dtsi"
+#include "calao_nand.dtsi"
diff --git a/arch/arm/dts/usb_a9260.dts b/arch/arm/dts/usb_a9260.dts
new file mode 100644
index 000000000000..9eb2db3ff8ce
--- /dev/null
+++ b/arch/arm/dts/usb_a9260.dts
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include <arm/microchip/usb_a9260.dts>
+#include "at91sam9260.dtsi"
+#include "calao_nand.dtsi"
diff --git a/arch/arm/dts/usb_a9g20.dts b/arch/arm/dts/usb_a9g20.dts
new file mode 100644
index 000000000000..a8ed22b7c407
--- /dev/null
+++ b/arch/arm/dts/usb_a9g20.dts
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include <arm/microchip/usb_a9g20.dts>
+#include "at91sam9g20.dtsi"
+#include "calao_nand.dtsi"
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 1197e06670c7..94e8e525a2f0 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -571,6 +571,16 @@ config AT91_MULTI_BOARDS
if AT91_MULTI_BOARDS
+config MACH_CALAO
+ bool "CALAO DT-enabled boards (TNY/USB-A9260/A9G20)"
+ select SOC_AT91SAM9260
+ select OFDEVICE
+ select COMMON_CLK_OF_PROVIDER
+ select HAVE_AT91_SDRAMC
+ help
+ Select this if you are using a device tree enabled board
+ from Calao Systems: TNY-A9260, TNY-A9G20, USB-A9260 or USB-A9G20.
+
config MACH_SKOV_ARM9CPU
bool "SKOV ARM9 CPU"
select SOC_AT91SAM9263
diff --git a/images/Makefile.at91 b/images/Makefile.at91
index 36f725940639..523dc5f499f0 100644
--- a/images/Makefile.at91
+++ b/images/Makefile.at91
@@ -160,3 +160,12 @@ image-$(CONFIG_MACH_USB_A9263) += barebox-usb-a9263-128m.img
pblb-$(CONFIG_MACH_USB_A9G20) += start_usb_a9g20
FILE_barebox-usb-a9g20.img = start_usb_a9g20.pblb
image-$(CONFIG_MACH_USB_A9G20) += barebox-usb-a9g20.img
+
+pblb-$(CONFIG_MACH_CALAO) += start_tny_a9260 start_tny_a9g20 \
+ start_usb_a9260 start_usb_a9g20
+FILE_barebox-tny-a9260.img = start_tny_a9260.pblb
+FILE_barebox-tny-a9g20.img = start_tny_a9g20.pblb
+FILE_barebox-usb-a9260.img = start_usb_a9260.pblb
+FILE_barebox-usb-a9g20.img = start_usb_a9g20.pblb
+image-$(CONFIG_MACH_CALAO) += barebox-tny-a9260.img barebox-tny-a9g20.img \
+ barebox-usb-a9260.img barebox-usb-a9g20.img
diff --git a/include/mach/at91/at91sam9260.h b/include/mach/at91/at91sam9260.h
index 1375872ce230..764af3a20316 100644
--- a/include/mach/at91/at91sam9260.h
+++ b/include/mach/at91/at91sam9260.h
@@ -100,6 +100,7 @@
#define AT91SAM9260_SRAM1_SIZE SZ_4K /* Internal SRAM 1 size (4Kb) */
#define AT91SAM9260_SRAM_BASE 0x002FF000 /* Internal SRAM base address */
#define AT91SAM9260_SRAM_SIZE SZ_8K /* Internal SRAM size (8Kb) */
+#define AT91SAM9260_SRAM_END (AT91SAM9260_SRAM_BASE + AT91SAM9260_SRAM_SIZE)
#define AT91SAM9260_UHP_BASE 0x00500000 /* USB Host controller */
diff --git a/include/mach/at91/at91sam9g45.h b/include/mach/at91/at91sam9g45.h
index d7596930d2e9..630cee2b87af 100644
--- a/include/mach/at91/at91sam9g45.h
+++ b/include/mach/at91/at91sam9g45.h
@@ -107,6 +107,7 @@
*/
#define AT91SAM9G45_SRAM_BASE 0x00300000 /* Internal SRAM base address */
#define AT91SAM9G45_SRAM_SIZE SZ_64K /* Internal SRAM size (64Kb) */
+#define AT91SAM9G45_SRAM_END (AT91SAM9G45_SRAM_BASE + AT91SAM9G45_SRAM_SIZE)
#define AT91SAM9G45_ROM_BASE 0x00400000 /* Internal ROM base address */
#define AT91SAM9G45_ROM_SIZE SZ_64K /* Internal ROM size (64Kb) */
--
2.39.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* OFFLIST Re: [PATCH 0/5] ARM: at91: add first DT support for Calao usb/tny boards
2023-09-26 18:38 [PATCH 0/5] ARM: at91: add first DT support for Calao usb/tny boards Ahmad Fatoum
` (4 preceding siblings ...)
2023-09-26 18:38 ` [PATCH 5/5] ARM: at91: add first DT support for Calao usb/tny boards Ahmad Fatoum
@ 2023-09-26 21:21 ` Wolfram Sang
2023-10-04 8:25 ` Sascha Hauer
6 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2023-09-26 21:21 UTC (permalink / raw)
To: R; +Cc: barebox
[-- Attachment #1: Type: text/plain, Size: 483 bytes --]
Hi!
> This is not yet a complete replacement:
>
> - We use the legacy NAND driver instead of the newly backported driver
> that Linux uses with the hardware, presumably without issues
>
> - OHCI hangs during probe, so it's disabled for now
>
> - A barebox with comparative functionality to the non-DT version
> exceeds the 256K partition size
Aber brauchst Du das Gerät dann nicht noch etwas für diese Sachen?
Grüße nach Paris,
Wolfram
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/5] ARM: at91: add first DT support for Calao usb/tny boards
2023-09-26 18:38 [PATCH 0/5] ARM: at91: add first DT support for Calao usb/tny boards Ahmad Fatoum
` (5 preceding siblings ...)
2023-09-26 21:21 ` OFFLIST Re: [PATCH 0/5] " Wolfram Sang
@ 2023-10-04 8:25 ` Sascha Hauer
6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2023-10-04 8:25 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox, wsa
On Tue, Sep 26, 2023 at 08:38:30PM +0200, Ahmad Fatoum wrote:
> We have a lot of defconfigs for ARM9 AT91 boards, that we want to get
> rid off after migrating the boards to at91_multi_defconfig.
>
> Thanks to a temporarily donated Calao USB-A9G20 by Wolfram, we start by
> switching the Calao boards to DT.
>
> This is not yet a complete replacement:
>
> - We use the legacy NAND driver instead of the newly backported driver
> that Linux uses with the hardware, presumably without issues
>
> - OHCI hangs during probe, so it's disabled for now
>
> - A barebox with comparative functionality to the non-DT version
> exceeds the 256K partition size
>
> These can be resolved separately though, so add here first DT support.
>
> Ahmad Fatoum (5):
> Revert "mtd: nand: drop DT support in legacy driver"
> ARM: at91: add SDRAMC driver for memory detection
> ARM: at91: at91sam9_rst: add DT support for at91sam9260
> ARM: at91: sam9260: don't build non-DT device support when unneeded
> ARM: at91: add first DT support for Calao usb/tny boards
Applied, thanks
Sascha
>
> arch/arm/boards/Makefile | 1 +
> arch/arm/boards/calao/Makefile | 4 +
> arch/arm/boards/calao/board.c | 13 ++++
> arch/arm/boards/calao/lowlevel.c | 30 ++++++++
> arch/arm/configs/at91_multi_defconfig | 4 +-
> arch/arm/dts/Makefile | 3 +
> arch/arm/dts/at91sam9260.dtsi | 33 ++++++++
> arch/arm/dts/at91sam9g20.dtsi | 2 +
> arch/arm/dts/calao_nand.dtsi | 48 ++++++++++++
> arch/arm/dts/tny_a9260.dts | 4 +
> arch/arm/dts/tny_a9g20.dts | 4 +
> arch/arm/dts/usb_a9260.dts | 4 +
> arch/arm/dts/usb_a9g20.dts | 4 +
> arch/arm/mach-at91/Kconfig | 13 ++++
> arch/arm/mach-at91/Makefile | 3 +-
> arch/arm/mach-at91/at91sam9_rst.c | 18 ++++-
> arch/arm/mach-at91/sdramc.c | 47 ++++++++++++
> drivers/mtd/nand/Kconfig | 8 +-
> drivers/mtd/nand/atmel/legacy.c | 104 +++++++++++++++++++++++++-
> images/Makefile.at91 | 9 +++
> include/mach/at91/at91sam9260.h | 1 +
> include/mach/at91/at91sam9_sdramc.h | 4 +
> include/mach/at91/at91sam9g45.h | 1 +
> 23 files changed, 353 insertions(+), 9 deletions(-)
> create mode 100644 arch/arm/boards/calao/Makefile
> create mode 100644 arch/arm/boards/calao/board.c
> create mode 100644 arch/arm/boards/calao/lowlevel.c
> create mode 100644 arch/arm/dts/at91sam9260.dtsi
> create mode 100644 arch/arm/dts/at91sam9g20.dtsi
> create mode 100644 arch/arm/dts/calao_nand.dtsi
> create mode 100644 arch/arm/dts/tny_a9260.dts
> create mode 100644 arch/arm/dts/tny_a9g20.dts
> create mode 100644 arch/arm/dts/usb_a9260.dts
> create mode 100644 arch/arm/dts/usb_a9g20.dts
> create mode 100644 arch/arm/mach-at91/sdramc.c
>
> --
> 2.39.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 8+ messages in thread