From 99848b5edf766797274abf01c141377782f52966 Mon Sep 17 00:00:00 2001 From: Asgeir Stavik Hustad Date: Wed, 4 Sep 2024 01:11:32 +0200 Subject: [PATCH] same70b: Add support for SMC for SAME70- and SAMV71-series Add smc definition in same70.dtsi Add atmel,smc-bus-width to atmel,sam-smc dts bindings. Update driver to select bus width from DT Signed-off-by: Asgeir Stavik Hustad --- drivers/memc/memc_sam_smc.c | 6 +++++- dts/arm/atmel/same70.dtsi | 9 +++++++++ dts/bindings/memory-controllers/atmel,sam-smc.yaml | 14 ++++++++++++++ west.yml | 2 +- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/memc/memc_sam_smc.c b/drivers/memc/memc_sam_smc.c index b54f18f55bbc9b..825e4abb9d0357 100644 --- a/drivers/memc/memc_sam_smc.c +++ b/drivers/memc/memc_sam_smc.c @@ -75,10 +75,14 @@ static int memc_smc_init(const struct device *dev) SMC_CYCLE_NWE_CYCLE(DT_PROP_BY_IDX(node_id, atmel_smc_cycle_timing, 0)) \ | SMC_CYCLE_NRD_CYCLE(DT_PROP_BY_IDX(node_id, atmel_smc_cycle_timing, 1)) +#define BUS_WIDTH(node_id) COND_CODE_1(DT_ENUM_IDX(node_id, atmel_smc_bus_width), \ + (SMC_MODE_DBW_16_BIT), (0)) + #define BANK_CONFIG(node_id) \ { \ .cs = DT_REG_ADDR(node_id), \ - .mode = COND_CODE_1(DT_ENUM_IDX(node_id, atmel_smc_write_mode), \ + .mode = BUS_WIDTH(node_id) \ + | COND_CODE_1(DT_ENUM_IDX(node_id, atmel_smc_write_mode), \ (SMC_MODE_WRITE_MODE), (0)) \ | COND_CODE_1(DT_ENUM_IDX(node_id, atmel_smc_read_mode), \ (SMC_MODE_READ_MODE), (0)), \ diff --git a/dts/arm/atmel/same70.dtsi b/dts/arm/atmel/same70.dtsi index fa954af21f5ca6..d82422dd0537de 100644 --- a/dts/arm/atmel/same70.dtsi +++ b/dts/arm/atmel/same70.dtsi @@ -476,6 +476,15 @@ alarms-count = <1>; status = "disabled"; }; + + smc: smc@40080000 { + compatible = "atmel,sam-smc"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x40080000 0x4000>; + clocks = <&pmc PMC_TYPE_PERIPHERAL 9>; + status = "disabled"; + }; }; }; diff --git a/dts/bindings/memory-controllers/atmel,sam-smc.yaml b/dts/bindings/memory-controllers/atmel,sam-smc.yaml index 57e646bd73a536..ab74d4bad3cadc 100644 --- a/dts/bindings/memory-controllers/atmel,sam-smc.yaml +++ b/dts/bindings/memory-controllers/atmel,sam-smc.yaml @@ -148,3 +148,17 @@ child-binding: is encoded in 9 bits where the two highest bits are multiplied with an offset of 256. Effective value for each element: 256 x cycle[8:7] + cycle[6:0] + + atmel,smc-bus-width: + type: int + default: 8 + description: | + Bus Width configuration for the Static Memory Controller that + is wired to the external device. + SMC on SAMx7 supports 8/16-bit bus width, on SAM4 + only 8-bit data buses are supported. + + The default value is 8-bit data buses. + enum: + - 8 + - 16 diff --git a/west.yml b/west.yml index 9454f2e57adc82..857ec81f9ab493 100644 --- a/west.yml +++ b/west.yml @@ -152,7 +152,7 @@ manifest: groups: - hal - name: hal_atmel - revision: 56d60ebc909ad065bf6554cee73487969857614b + revision: pull/41/head path: modules/hal/atmel groups: - hal