[RFC] ARM: at91: sama5d3: Migrate to MFD-based SMC driver

Ahmad Fatoum a.fatoum at pengutronix.de
Fri Nov 6 04:20:07 PST 2026


Hi Alexander,

On 7/18/25 7:07 PM, Ahmad Fatoum wrote:
> On 14.07.25 22:00, Alexander Shiyan wrote:
>> Hi Ahmad, any news on this?
> 
> Sorry, haven't come around to yet, but will try to soon.

Soon was a lie, I am sorry about that.

This works fine, I took the liberty of resending your patch:
https://lore.barebox.org/barebox/20261106111352.3535034-1-a.fatoum@pengutronix.de/T/#mbaea85a775fa0f09ebc6cc2eb8d2bc521bbc2f7d

Cheers,
Ahmad

> 
>>
>> вт, 24 июн. 2025 г. в 12:15, Alexander Shiyan <eagle.alexander923 at gmail.com>:
>>>
>>> This replaces the low-level SMC driver implementation with the
>>> MFD-based driver for SAMA5D3 platforms.
>>>
>>> Signed-off-by: Alexander Shiyan <eagle.alexander923 at gmail.com>
>>> ---
>>>  arch/arm/boards/sama5d3_xplained/board.c | 46 ------------------------
>>>  arch/arm/mach-at91/Kconfig               |  1 -
>>>  arch/arm/mach-at91/sam9_smc.c            |  5 +--
>>>  3 files changed, 1 insertion(+), 51 deletions(-)
>>>
>>> diff --git a/arch/arm/boards/sama5d3_xplained/board.c b/arch/arm/boards/sama5d3_xplained/board.c
>>> index 4d908e6b9f..3ee3f2166e 100644
>>> --- a/arch/arm/boards/sama5d3_xplained/board.c
>>> +++ b/arch/arm/boards/sama5d3_xplained/board.c
>>> @@ -3,60 +3,14 @@
>>>  #include <common.h>
>>>  #include <init.h>
>>>  #include <envfs.h>
>>> -#include <mach/at91/at91sam9_smc.h>
>>> -#include <mach/at91/hardware.h>
>>> -#include <linux/clk.h>
>>> -
>>> -static struct sam9_smc_config sama5d3_xplained_nand_smc_config = {
>>> -       .ncs_read_setup         = 1,
>>> -       .nrd_setup              = 2,
>>> -       .ncs_write_setup        = 1,
>>> -       .nwe_setup              = 2,
>>> -
>>> -       .ncs_read_pulse         = 5,
>>> -       .nrd_pulse              = 3,
>>> -       .ncs_write_pulse        = 5,
>>> -       .nwe_pulse              = 3,
>>> -
>>> -       .read_cycle             = 8,
>>> -       .write_cycle            = 8,
>>> -
>>> -       .mode                   = AT91_SMC_READMODE | AT91_SMC_WRITEMODE |
>>> -                                 AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
>>> -       .tdf_cycles             = 3,
>>> -
>>> -       .tclr                   = 3,
>>> -       .tadl                   = 10,
>>> -       .tar                    = 3,
>>> -       .ocms                   = 0,
>>> -       .trr                    = 4,
>>> -       .twb                    = 5,
>>> -       .rbnsel                 = 3,
>>> -       .nfsel                  = 1
>>> -};
>>>
>>>  static int sama5d3_xplained_probe(struct device *dev)
>>>  {
>>> -       struct clk *clk;
>>> -
>>>         barebox_set_hostname("sama5d3_xplained");
>>>
>>>         if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT_GENERIC))
>>>                 defaultenv_append_directory(defaultenv_sama5d3_xplained);
>>>
>>> -       add_generic_device("at91sam9-smc", DEVICE_ID_SINGLE, NULL,
>>> -                          SAMA5D3_BASE_HSMC + 0x600, 0xa0,
>>> -                          IORESOURCE_MEM, NULL);
>>> -
>>> -       clk = clk_lookup("hsmc_clk");
>>> -       if (IS_ERR(clk))
>>> -               dev_warn(dev, "couldn't get hsmc_clk: %pe\n", clk);
>>> -
>>> -       clk_enable(clk);
>>> -
>>> -       /* configure chip-select 3 (NAND) */
>>> -       sama5_smc_configure(0, 3, &sama5d3_xplained_nand_smc_config);
>>> -
>>>         return 0;
>>>  }
>>>
>>> diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
>>> index db79ad2d26..22ab99d9c8 100644
>>> --- a/arch/arm/mach-at91/Kconfig
>>> +++ b/arch/arm/mach-at91/Kconfig
>>> @@ -107,7 +107,6 @@ config SOC_SAMA5D2
>>>  config SOC_SAMA5D3
>>>         bool
>>>         select SOC_SAMA5
>>> -       select AT91SAM9_SMC
>>>         select CLOCKSOURCE_ATMEL_PIT
>>>         select HAVE_AT91_SMD
>>>         select HAVE_AT91_USB_CLK
>>> diff --git a/arch/arm/mach-at91/sam9_smc.c b/arch/arm/mach-at91/sam9_smc.c
>>> index 6c9e169a8e..66b30694ce 100644
>>> --- a/arch/arm/mach-at91/sam9_smc.c
>>> +++ b/arch/arm/mach-at91/sam9_smc.c
>>> @@ -14,8 +14,7 @@
>>>
>>>  #define AT91_SAM9_SMC_CS_STRIDE                0x10
>>>  #define AT91_SAMA5_SMC_CS_STRIDE       0x14
>>> -#define AT91_SMC_CS_STRIDE     ((at91_soc_initdata.type == AT91_SOC_SAMA5D3 \
>>> -                                || at91_soc_initdata.type == AT91_SOC_SAMA5D4) \
>>> +#define AT91_SMC_CS_STRIDE     ((at91_soc_initdata.type == AT91_SOC_SAMA5D4) \
>>>                                  ? AT91_SAMA5_SMC_CS_STRIDE : AT91_SAM9_SMC_CS_STRIDE)
>>>  #define AT91_SMC_CS(id, n)     (smc_base_addr[id] + ((n) * AT91_SMC_CS_STRIDE))
>>>
>>> @@ -27,7 +26,6 @@ static void sam9_smc_cs_write_mode(void __iomem *base,
>>>         void __iomem *mode_reg;
>>>
>>>         switch (at91_soc_initdata.type) {
>>> -       case AT91_SOC_SAMA5D3:
>>>         case AT91_SOC_SAMA5D4:
>>>                 mode_reg = base + AT91_SAMA5_SMC_MODE;
>>>                 break;
>>> @@ -101,7 +99,6 @@ static void sam9_smc_cs_read_mode(void __iomem *base,
>>>         void __iomem *mode_reg;
>>>
>>>         switch (at91_soc_initdata.type) {
>>> -       case AT91_SOC_SAMA5D3:
>>>         case AT91_SOC_SAMA5D4:
>>>                 mode_reg = base + AT91_SAMA5_SMC_MODE;
>>>                 break;
>>> --
>>> 2.39.1
>>>
>>
> 
> 

-- 
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 |




More information about the barebox mailing list