Skip to content

Commit d3737f9

Browse files
wenyouyaclaudiubeznea
authored andcommitted
ARM: at91: pm: Configure PMC fast startup signals
The fast startup signal is used as wake up sources for ULP1 mode. As soon as a fast startup signal is asserted, the embedded 12 MHz RC oscillator restarts automatically. This patch is to configure the fast startup signals, which signal is enabled to trigger the PMC to wake up the system from ULP1 mode should be configured via the DT. Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com> [claudiu.beznea@microchip.com: align with 4.14 changes] Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
1 parent c9b34b7 commit d3737f9

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

arch/arm/mach-at91/pm.c

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include <linux/suspend.h>
2020

2121
#include <linux/clk/at91_pmc.h>
22+
#include <linux/mfd/syscon.h>
23+
#include <linux/regmap.h>
2224

2325
#include <asm/cacheflush.h>
2426
#include <asm/fncpy.h>
@@ -607,6 +609,68 @@ static void __init at91_pm_init(void (*pm_idle)(void))
607609
}
608610
}
609611

612+
static int __init at91_pmc_fast_startup_init(void)
613+
{
614+
struct device_node *np, *cnp;
615+
struct regmap *regmap;
616+
u32 input, input_mask;
617+
u32 mode = 0, polarity = 0;
618+
619+
np = of_find_compatible_node(NULL, NULL,
620+
"atmel,sama5d2-pmc-fast-startup");
621+
if (!np)
622+
return -ENODEV;
623+
624+
regmap = syscon_node_to_regmap(of_get_parent(np));
625+
if (IS_ERR(regmap)) {
626+
pr_info("AT91: failed to find PMC fast startup node\n");
627+
return PTR_ERR(regmap);
628+
}
629+
630+
for_each_child_of_node(np, cnp) {
631+
if (of_property_read_u32(cnp, "reg", &input)) {
632+
pr_warn("AT91: reg property is missing for %s\n",
633+
cnp->full_name);
634+
continue;
635+
}
636+
637+
input_mask = 1 << input;
638+
if (!(input_mask & AT91_PMC_FS_INPUT_MASK)) {
639+
pr_warn("AT91: wake-up input %d out of range\n", input);
640+
continue;
641+
}
642+
mode |= input_mask;
643+
644+
if (of_property_read_bool(cnp, "atmel,wakeup-active-high"))
645+
polarity |= input_mask;
646+
}
647+
648+
if (of_property_read_bool(np, "atmel,wakeup-rtc-timer"))
649+
mode |= AT91_PMC_RTCAL;
650+
651+
if (of_property_read_bool(np, "atmel,wakeup-usb-resume"))
652+
mode |= AT91_PMC_USBAL;
653+
654+
if (of_property_read_bool(np, "atmel,wakeup-sdmmc-cd"))
655+
mode |= AT91_PMC_SDMMC_CD;
656+
657+
if (of_property_read_bool(np, "atmel,wakeup-rxlp-match"))
658+
mode |= AT91_PMC_RXLP_MCE;
659+
660+
if (of_property_read_bool(np, "atmel,wakeup-acc-comparison"))
661+
mode |= AT91_PMC_ACC_CE;
662+
663+
pr_debug("AT91: mode = 0x%x, ploarity = 0%x\n", mode, polarity);
664+
665+
regmap_write(regmap, AT91_PMC_FSMR, mode);
666+
667+
regmap_write(regmap, AT91_PMC_FSPR, polarity);
668+
669+
of_node_put(np);
670+
671+
return 0;
672+
}
673+
610674
void __init at91rm9200_pm_init(void)
611675
{
612676
if (!IS_ENABLED(CONFIG_SOC_AT91RM9200))
@@ -647,6 +711,7 @@ void __init sama5d2_pm_init(void)
647711

648712
at91_pm_backup_init();
649713
sama5_pm_init();
714+
at91_pmc_fast_startup_init();
650715
}
651716

652717
static int __init at91_pm_modes_select(char *str)

include/linux/clk/at91_pmc.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,20 @@
157157
#define AT91_PMC_GCKRDY (1 << 24) /* Generated Clocks */
158158
#define AT91_PMC_IMR 0x6c /* Interrupt Mask Register */
159159

160+
#define AT91_PMC_FSMR 0x70 /* Fast Startup Mode Register */
161+
#define AT91_PMC_FSTT(n) (0x1 << n)
162+
#define AT91_PMC_RTCAL BIT(17) /* RTC Alarm Enable */
163+
#define AT91_PMC_USBAL BIT(18) /* USB Resume Enable */
164+
#define AT91_PMC_SDMMC_CD BIT(19) /* SDMMC Card Detect Enable */
165+
#define AT91_PMC_LPM BIT(20) /* Low-power Mode */
166+
#define AT91_PMC_RXLP_MCE BIT(24) /* Backup UART Receive Enable */
167+
#define AT91_PMC_ACC_CE BIT(25) /* ACC Enable */
168+
169+
#define AT91_PMC_FSPR 0x74 /* Fast Startup Polarity Reg */
170+
#define AT91_PMC_FSTP(n) (0x1 << n)
171+
172+
#define AT91_PMC_FS_INPUT_MASK 0x7ff
173+
160174
#define AT91_PMC_PLLICPR 0x80 /* PLL Charge Pump Current Register */
161175

162176
#define AT91_PMC_PROT 0xe4 /* Write Protect Mode Register [some SAM9] */

0 commit comments

Comments
 (0)