Skip to content

Commit

Permalink
Merge tag 'at91-soc-6.14' of https://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/git/at91/linux into soc/arm

Microchip AT91 SoC updates for v6.14

This update includes:
- support for the SAMA7D65 SoC
- support for automatic mode in the backup unit power switch, eliminating
  the need for software intervention when entering low power mode
- a fix to release a device node reference in the failure path of the
  SoC driver initialization

* tag 'at91-soc-6.14' of https://git.kernel.org/pub/scm/linux/kernel/git/at91/linux:
  ARM: at91: add new SoC sama7d65
  ARM: at91: pm: change BU Power Switch to automatic mode
  soc: atmel: fix device_node release in atmel_soc_device_init()

Link: https://lore.kernel.org/r/20250107081424.758980-3-claudiu.beznea@tuxon.dev
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
  • Loading branch information
Arnd Bergmann committed Jan 17, 2025
2 parents afc6713 + 452d18c commit 2fd7a3f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
11 changes: 11 additions & 0 deletions arch/arm/mach-at91/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ config SOC_SAMA5D4
help
Select this if you are using one of Microchip's SAMA5D4 family SoC.

config SOC_SAMA7D65
bool "SAMA7D65 family"
depends on ARCH_MULTI_V7
select HAVE_AT91_GENERATED_CLK
select HAVE_AT91_SAM9X60_PLL
select HAVE_AT91_USB_CLK
select HAVE_AT91_UTMI
select SOC_SAMA7
help
Select this if you are using one of Microchip's SAMA7D65 family SoC.

config SOC_SAMA7G5
bool "SAMA7G5 family"
depends on ARCH_MULTI_V7
Expand Down
31 changes: 20 additions & 11 deletions arch/arm/mach-at91/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,21 @@ static int at91_suspend_finish(unsigned long val)
return 0;
}

static void at91_pm_switch_ba_to_vbat(void)
/**
* at91_pm_switch_ba_to_auto() - Configure Backup Unit Power Switch
* to automatic/hardware mode.
*
* The Backup Unit Power Switch can be managed either by software or hardware.
* Enabling hardware mode allows the automatic transition of power between
* VDDANA (or VDDIN33) and VDDBU (or VBAT, respectively), based on the
* availability of these power sources.
*
* If the Backup Unit Power Switch is already in automatic mode, no action is
* required. If it is in software-controlled mode, it is switched to automatic
* mode to enhance safety and eliminate the need for toggling between power
* sources.
*/
static void at91_pm_switch_ba_to_auto(void)
{
unsigned int offset = offsetof(struct at91_pm_sfrbu_regs, pswbu);
unsigned int val;
Expand All @@ -609,24 +623,19 @@ static void at91_pm_switch_ba_to_vbat(void)

val = readl(soc_pm.data.sfrbu + offset);

/* Already on VBAT. */
if (!(val & soc_pm.sfrbu_regs.pswbu.state))
/* Already on auto/hardware. */
if (!(val & soc_pm.sfrbu_regs.pswbu.ctrl))
return;

val &= ~soc_pm.sfrbu_regs.pswbu.softsw;
val |= soc_pm.sfrbu_regs.pswbu.key | soc_pm.sfrbu_regs.pswbu.ctrl;
val &= ~soc_pm.sfrbu_regs.pswbu.ctrl;
val |= soc_pm.sfrbu_regs.pswbu.key;
writel(val, soc_pm.data.sfrbu + offset);

/* Wait for update. */
val = readl(soc_pm.data.sfrbu + offset);
while (val & soc_pm.sfrbu_regs.pswbu.state)
val = readl(soc_pm.data.sfrbu + offset);
}

static void at91_pm_suspend(suspend_state_t state)
{
if (soc_pm.data.mode == AT91_PM_BACKUP) {
at91_pm_switch_ba_to_vbat();
at91_pm_switch_ba_to_auto();

cpu_suspend(0, at91_suspend_finish);

Expand Down
2 changes: 1 addition & 1 deletion drivers/soc/atmel/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ static const struct of_device_id at91_soc_allowed_list[] __initconst = {

static int __init atmel_soc_device_init(void)
{
struct device_node *np = of_find_node_by_path("/");
struct device_node *np __free(device_node) = of_find_node_by_path("/");

if (!of_match_node(at91_soc_allowed_list, np))
return 0;
Expand Down

0 comments on commit 2fd7a3f

Please sign in to comment.