mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wenyou Yang <wenyou.yang@atmel.com>
To: Nicolas Ferre <nicolas.ferre@atmel.com>,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>,
	Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Russell King <linux@arm.linux.org.uk>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Michael Turquette <mturquette@baylibre.com>,
	"Rob Herring" <robh+dt@kernel.org>,
	Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	"Kumar Gala" <galak@codeaurora.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <linux-clk@vger.kernel.org>,
	Wenyou Yang <wenyou.yang@atmel.com>
Subject: [RFC PATCH 1/2] ARM: at91: pm: init fast startup trigger signals to PMC
Date: Thu, 29 Oct 2015 13:55:46 +0800	[thread overview]
Message-ID: <1446098147-32487-2-git-send-email-wenyou.yang@atmel.com> (raw)
In-Reply-To: <1446098147-32487-1-git-send-email-wenyou.yang@atmel.com>

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 <wenyou.yang@atmel.com>
---

 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 <linux/platform_device.h>
 #include <linux/io.h>
 #include <linux/clk/at91_pmc.h>
+#include <linux/mfd/syscon.h>
+#include <linux/regmap.h>
 
 #include <asm/irq.h>
 #include <linux/atomic.h>
@@ -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] */
-- 
1.7.9.5


  reply	other threads:[~2015-10-29  6:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-29  5:55 [RFC PATCH 0/2] ARM: at91/pm: init fast startup signal to the PMC Wenyou Yang
2015-10-29  5:55 ` Wenyou Yang [this message]
2015-10-29  5:55 ` [RFC PATCH 2/2] ARM: at91/dt: sama5d2_xplained: add pmc_fast_restart node Wenyou Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1446098147-32487-2-git-send-email-wenyou.yang@atmel.com \
    --to=wenyou.yang@atmel.com \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=mturquette@baylibre.com \
    --cc=nicolas.ferre@atmel.com \
    --cc=pawel.moll@arm.com \
    --cc=plagnioj@jcrosoft.com \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®