From patchwork Mon Aug 8 10:05:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenyou Yang X-Patchwork-Id: 9267683 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7A624607D6 for ; Mon, 8 Aug 2016 10:20:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A5E526E8A for ; Mon, 8 Aug 2016 10:20:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5ECA627DCE; Mon, 8 Aug 2016 10:20:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B88C526E8A for ; Mon, 8 Aug 2016 10:20:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bWheZ-0007Nn-ML; Mon, 08 Aug 2016 10:19:27 +0000 Received: from eusmtp01.atmel.com ([212.144.249.243]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bWheO-000736-Mu for linux-arm-kernel@lists.infradead.org; Mon, 08 Aug 2016 10:19:23 +0000 Received: from apsmtp01.atmel.com (10.168.254.30) by eusmtp01.atmel.com (10.145.145.31) with Microsoft SMTP Server id 14.3.235.1; Mon, 8 Aug 2016 12:18:53 +0200 Received: from shaarm01.corp.atmel.com (10.168.254.13) by apsmtp01.corp.atmel.com (10.168.254.30) with Microsoft SMTP Server id 14.3.235.1; Mon, 8 Aug 2016 18:26:15 +0800 From: Wenyou Yang To: Nicolas Ferre , Alexandre Belloni , Russell King Subject: [PATCH v6 4/6] ARM: at91: pm: Configure PMC fast startup signals Date: Mon, 8 Aug 2016 18:05:03 +0800 Message-ID: <1470650705-31418-5-git-send-email-wenyou.yang@atmel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1470650705-31418-1-git-send-email-wenyou.yang@atmel.com> References: <1470650705-31418-1-git-send-email-wenyou.yang@atmel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160808_031917_586995_371630E1 X-CRM114-Status: GOOD ( 13.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Pawel Moll , Ian Campbell , Mark Brown , linux-kernel@vger.kernel.org, Wenyou Yang , Rob Herring , Kumar Gala , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- Changes in v6: None Changes in v5: - to improve the scalability, rework the DT expression part, use the child nodes to describe the wake-up input and its active level. Changes in v4: None Changes in v3: - use 0 and 1, not string, to define the trigger active polarity. Changes in v2: - shorten the pmc-fast-startup property's name. - use the value property, instead of bool property for high or low triggered. arch/arm/mach-at91/pm.c | 65 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/clk/at91_pmc.h | 14 ++++++++++ 2 files changed, 79 insertions(+) diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index dad412f..e451d34 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include #include @@ -459,6 +461,68 @@ static void __init at91_pm_init(void (*pm_idle)(void)) pr_info("AT91: PM not supported, due to no SRAM allocated\n"); } +static int __init at91_pmc_fast_startup_init(void) +{ + struct device_node *np, *cnp; + struct regmap *regmap; + u32 input, input_mask; + u32 mode = 0, polarity = 0; + + np = of_find_compatible_node(NULL, NULL, + "atmel,sama5d2-pmc-fast-startup"); + if (!np) + return -ENODEV; + + regmap = syscon_node_to_regmap(of_get_parent(np)); + if (IS_ERR(regmap)) { + pr_info("AT91: failed to find PMC fast startup node\n"); + return PTR_ERR(regmap); + } + + for_each_child_of_node(np, cnp) { + if (of_property_read_u32(cnp, "reg", &input)) { + pr_warn("AT91: reg property is missing for %s\n", + cnp->full_name); + continue; + } + + input_mask = 1 << input; + if (!(input_mask & AT91_PMC_FS_INPUT_MASK)) { + pr_warn("AT91: wake-up input %d out of range\n", input); + continue; + } + mode |= input_mask; + + if (of_property_read_bool(cnp, "atmel,wakeup-active-high")) + polarity |= input_mask; + } + + if (of_property_read_bool(np, "atmel,wakeup-rtc-timer")) + mode |= AT91_PMC_RTCAL; + + if (of_property_read_bool(np, "atmel,wakeup-usb-resume")) + mode |= AT91_PMC_USBAL; + + if (of_property_read_bool(np, "atmel,wakeup-sdmmc-cd")) + mode |= AT91_PMC_SDMMC_CD; + + if (of_property_read_bool(np, "atmel,wakeup-rxlp-match")) + mode |= AT91_PMC_RXLP_MCE; + + if (of_property_read_bool(np, "atmel,wakeup-acc-comparison")) + mode |= AT91_PMC_ACC_CE; + + pr_debug("AT91: mode = 0x%x, ploarity = 0%x\n", mode, polarity); + + regmap_write(regmap, AT91_PMC_FSMR, mode); + + regmap_write(regmap, AT91_PMC_FSPR, polarity); + + of_node_put(np); + + return 0; +} + void __init at91rm9200_pm_init(void) { at91_dt_ramc(); @@ -511,4 +575,5 @@ void __init sama5d2_pm_init(void) sama5_pm_init(); at91_pm_data.ulp_mode = ULP1_MODE; + at91_pmc_fast_startup_init(); } diff --git a/include/linux/clk/at91_pmc.h b/include/linux/clk/at91_pmc.h index cec6cc3..08a55f2 100644 --- a/include/linux/clk/at91_pmc.h +++ b/include/linux/clk/at91_pmc.h @@ -157,6 +157,20 @@ #define AT91_PMC_GCKRDY (1 << 24) /* Generated Clocks */ #define AT91_PMC_IMR 0x6c /* Interrupt Mask Register */ +#define AT91_PMC_FSMR 0x70 /* Fast Startup Mode Register */ +#define AT91_PMC_FSTT(n) (0x1 << n) +#define AT91_PMC_RTCAL BIT(17) /* RTC Alarm Enable */ +#define AT91_PMC_USBAL BIT(18) /* USB Resume Enable */ +#define AT91_PMC_SDMMC_CD BIT(19) /* SDMMC Card Detect Enable */ +#define AT91_PMC_LPM BIT(20) /* Low-power Mode */ +#define AT91_PMC_RXLP_MCE BIT(24) /* Backup UART Receive Enable */ +#define AT91_PMC_ACC_CE BIT(25) /* ACC Enable */ + +#define AT91_PMC_FSPR 0x74 /* Fast Startup Polarity Reg */ +#define AT91_PMC_FSTP(n) (0x1 << n) + +#define AT91_PMC_FS_INPUT_MASK 0x7ff + #define AT91_PMC_PLLICPR 0x80 /* PLL Charge Pump Current Register */ #define AT91_PMC_PROT 0xe4 /* Write Protect Mode Register [some SAM9] */