From patchwork Thu Oct 29 05:55:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenyou Yang X-Patchwork-Id: 7516491 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4F461BEEA4 for ; Thu, 29 Oct 2015 06:03:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 338CC2073C for ; Thu, 29 Oct 2015 06:03:30 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 2C1302091F for ; Thu, 29 Oct 2015 06:03:29 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZrgHJ-0004ad-I6; Thu, 29 Oct 2015 06:01:37 +0000 Received: from eusmtp01.atmel.com ([212.144.249.243]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZrgHG-0004WC-EC for linux-arm-kernel@lists.infradead.org; Thu, 29 Oct 2015 06:01:35 +0000 Received: from apsmtp01.atmel.com (10.168.254.30) by eusmtp01.atmel.com (10.161.101.31) with Microsoft SMTP Server id 14.3.235.1; Thu, 29 Oct 2015 07:01:08 +0100 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; Thu, 29 Oct 2015 14:00:34 +0800 From: Wenyou Yang To: Nicolas Ferre , Alexandre Belloni , Jean-Christophe Plagniol-Villard Subject: [RFC PATCH 1/2] ARM: at91: pm: init fast startup trigger signals to PMC Date: Thu, 29 Oct 2015 13:55:46 +0800 Message-ID: <1446098147-32487-2-git-send-email-wenyou.yang@atmel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1446098147-32487-1-git-send-email-wenyou.yang@atmel.com> References: <1446098147-32487-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-20151028_230134_876554_E31C527A X-CRM114-Status: GOOD ( 12.38 ) X-Spam-Score: -4.2 (----) 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: Mark Rutland , Russell King , Pawel Moll , Ian Campbell , Michael Turquette , Stephen Boyd , 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch is to configure the fast startup signals, and which signal is enabled to trigger to the PMC can be configured via the DT property. 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. Signed-off-by: Wenyou Yang --- arch/arm/mach-at91/pm.c | 60 ++++++++++++++++++++++++++++++++++++++++++ include/linux/clk/at91_pmc.h | 32 ++++++++++++++++++++++ 2 files changed, 92 insertions(+) diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index e7ba340..ddf1ed9 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 @@ -411,6 +413,62 @@ static void __init at91_pm_sram_init(void) &at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz); } +static void __init at91_pmc_fast_startup_init(void) +{ + struct device_node *np; + struct regmap *regmap; + u32 regval; + + np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-pmc-fast-startup"); + if (!np) + return; + + regmap = syscon_node_to_regmap(of_get_parent(np)); + if (IS_ERR(regmap)) { + pr_info("AT91: failed to find PMC fast startup\n"); + return; + } + + regval = of_property_read_bool(np, "atmel,fast-startup-wake-up") ? + AT91_PMC_FSTT0 : 0; + regval |= of_property_read_bool(np, "atmel,fast-startup-secumod") ? + AT91_PMC_FSTT1 : 0; + regval |= of_property_read_bool(np, "atmel,fast-startup-piobu0") ? + AT91_PMC_FSTT2 : 0; + regval |= of_property_read_bool(np, "atmel,fast-startup-piobu1") ? + AT91_PMC_FSTT3 : 0; + regval |= of_property_read_bool(np, "atmel,fast-startup-piobu2") ? + AT91_PMC_FSTT4 : 0; + regval |= of_property_read_bool(np, "atmel,fast-startup-piobu3") ? + AT91_PMC_FSTT5 : 0; + regval |= of_property_read_bool(np, "atmel,fast-startup-piobu4") ? + AT91_PMC_FSTT6 : 0; + regval |= of_property_read_bool(np, "atmel,fast-startup-piobu5") ? + AT91_PMC_FSTT7 : 0; + regval |= of_property_read_bool(np, "atmel,fast-startup-piobu6") ? + AT91_PMC_FSTT8 : 0; + regval |= of_property_read_bool(np, "atmel,fast-startup-piobu7") ? + AT91_PMC_FSTT9 : 0; + regval |= of_property_read_bool(np, "atmel,fast-startup-gmac-wol") ? + AT91_PMC_FSTT10 : 0; + regval |= of_property_read_bool(np, "atmel,fast-startup-rtc-alarm") ? + AT91_PMC_RTCAL : 0; + regval |= of_property_read_bool(np, "atmel,fast-startup-usb-resume") ? + AT91_PMC_USBAL : 0; + regval |= of_property_read_bool(np, "atmel,fast-startup-sdmmc-cd") ? + AT91_PMC_SDMMC_CD : 0; + regval |= of_property_read_bool(np, "atmel,fast-startup-rxlp-match") ? + AT91_PMC_RXLP_MCE : 0; + regval |= of_property_read_bool(np, "atmel,fast-startup-acc") ? + AT91_PMC_ACC_CE : 0; + + regmap_write(regmap, AT91_PMC_FSMR, regval); + + regmap_write(regmap, AT91_PMC_FSPR, 0); + + of_node_put(np); +} + static const struct of_device_id atmel_pmc_ids[] = { { .compatible = "atmel,at91rm9200-pmc" }, { .compatible = "atmel,at91sam9260-pmc" }, @@ -439,6 +497,8 @@ static void __init at91_pm_init(void (*pm_idle)(void)) if (pm_idle) arm_pm_idle = pm_idle; + at91_pmc_fast_startup_init(); + at91_pm_sram_init(); if (at91_suspend_sram_fn) diff --git a/include/linux/clk/at91_pmc.h b/include/linux/clk/at91_pmc.h index b80b98b..6c1855b 100644 --- a/include/linux/clk/at91_pmc.h +++ b/include/linux/clk/at91_pmc.h @@ -154,6 +154,38 @@ #define AT91_PMC_CFDEV (1 << 18) /* Clock Failure Detector Event [some SAM9] */ #define AT91_PMC_IMR 0x6c /* Interrupt Mask Register */ +#define AT91_PMC_FSMR 0x70 /* Fast Startup Mode Register */ +#define AT91_PMC_FSTT0 (1 << 0) /* Fast Startup from WKUP Pin Enable */ +#define AT91_PMC_FSTT1 (1 << 1) /* Fast Startup from Security Module Enable */ +#define AT91_PMC_FSTT2 (1 << 2) /* Fast Startup from PIOBU0 Input Enable */ +#define AT91_PMC_FSTT3 (1 << 3) /* Fast Startup from PIOBU1 Input Enable */ +#define AT91_PMC_FSTT4 (1 << 4) /* Fast Startup from PIOBU2 Input Enable */ +#define AT91_PMC_FSTT5 (1 << 5) /* Fast Startup from PIOBU3 Input Enable */ +#define AT91_PMC_FSTT6 (1 << 6) /* Fast Startup from PIOBU4 Input Enable */ +#define AT91_PMC_FSTT7 (1 << 7) /* Fast Startup from PIOBU5 Input Enable */ +#define AT91_PMC_FSTT8 (1 << 8) /* Fast Startup from PIOBU6 Input Enable */ +#define AT91_PMC_FSTT9 (1 << 9) /* Fast Startup from PIOBU7 Input Enable */ +#define AT91_PMC_FSTT10 (1 << 10) /* Fast Startup from GMAC Wake-up On LAN Enable */ +#define AT91_PMC_RTCAL (1 << 17) /* Fast Startup from RTC Alarm Enable */ +#define AT91_PMC_USBAL (1 << 18) /* Fast Startup from USB Resume Enable */ +#define AT91_PMC_SDMMC_CD (1 << 19) /* Fast Startup from SDMMC Card Detect Enable */ +#define AT91_PMC_LPM (1 << 20) /* Low-power Mode */ +#define AT91_PMC_RXLP_MCE (1 << 24) /* Fast Startup from Backup UART Receive Match Condition Enable */ +#define AT91_PMC_ACC_CE (1 << 25) /* Fast Startup from Analog Comparator Controller Comparison Enable*/ + +#define AT91_PMC_FSPR 0x74 /* Fast Startup Polarity Register */ +#define AT91_PMC_FSTP0 (1 << 0) /* WKUP Pin Polarity for Fast Startup */ +#define AT91_PMC_FSTP1 (1 << 1) /* Security Module Polarity for Fast Startup */ +#define AT91_PMC_FSTP2 (1 << 2) /* PIOBU0 Pin Polarity for Fast Startup */ +#define AT91_PMC_FSTP3 (1 << 3) /* PIOBU1 Pin Polarity for Fast Startup */ +#define AT91_PMC_FSTP4 (1 << 4) /* PIOBU2 Pin Polarity for Fast Startup */ +#define AT91_PMC_FSTP5 (1 << 5) /* PIOBU3 Pin Polarity for Fast Startup */ +#define AT91_PMC_FSTP6 (1 << 6) /* PIOBU4 Pin Polarity for Fast Startup */ +#define AT91_PMC_FSTP7 (1 << 7) /* PIOBU5 Pin Polarity for Fast Startup */ +#define AT91_PMC_FSTP8 (1 << 8) /* PIOBU6 Pin Polarity for Fast Startup */ +#define AT91_PMC_FSTP9 (1 << 9) /* PIOBU7 Pin Polarity for Fast Startup */ +#define AT91_PMC_FSTP10 (1 << 10) /* GMAC Wake-up On LAN Polarity for Fast Startup */ + #define AT91_PMC_PLLICPR 0x80 /* PLL Charge Pump Current Register */ #define AT91_PMC_PROT 0xe4 /* Write Protect Mode Register [some SAM9] */