aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/layerscape/patches-4.9/806-flextimer-support-layerscape.patch
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/layerscape/patches-4.9/806-flextimer-support-layerscape.patch')
-rw-r--r--target/linux/layerscape/patches-4.9/806-flextimer-support-layerscape.patch109
1 files changed, 99 insertions, 10 deletions
diff --git a/target/linux/layerscape/patches-4.9/806-flextimer-support-layerscape.patch b/target/linux/layerscape/patches-4.9/806-flextimer-support-layerscape.patch
index 711fde77de..4f7fe70a8d 100644
--- a/target/linux/layerscape/patches-4.9/806-flextimer-support-layerscape.patch
+++ b/target/linux/layerscape/patches-4.9/806-flextimer-support-layerscape.patch
@@ -1,4 +1,4 @@
-From a5b3155b532289af793c26251cb087b4a24d5c15 Mon Sep 17 00:00:00 2001
+From 76cd2ef6b69b67c09480a3248f7b910897f0bb2f Mon Sep 17 00:00:00 2001
From: Yangbo Lu <yangbo.lu@nxp.com>
Date: Mon, 25 Sep 2017 12:13:12 +0800
Subject: [PATCH] flextimer: support layerscape
@@ -10,13 +10,15 @@ Signed-off-by: Meng Yi <meng.yi@nxp.com>
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
---
drivers/clocksource/fsl_ftm_timer.c | 8 +-
- drivers/soc/fsl/layerscape/ftm_alarm.c | 286 +++++++++++++++++++++++++++++++++
- 2 files changed, 290 insertions(+), 4 deletions(-)
+ drivers/soc/fsl/layerscape/ftm_alarm.c | 367 +++++++++++++++++++++++++++++++++
+ 2 files changed, 371 insertions(+), 4 deletions(-)
create mode 100644 drivers/soc/fsl/layerscape/ftm_alarm.c
+diff --git a/drivers/clocksource/fsl_ftm_timer.c b/drivers/clocksource/fsl_ftm_timer.c
+index 738515b8..770bbbca 100644
--- a/drivers/clocksource/fsl_ftm_timer.c
+++ b/drivers/clocksource/fsl_ftm_timer.c
-@@ -83,11 +83,11 @@ static inline void ftm_counter_disable(v
+@@ -83,11 +83,11 @@ static inline void ftm_counter_disable(void __iomem *base)
static inline void ftm_irq_acknowledge(void __iomem *base)
{
@@ -32,9 +34,12 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
}
static inline void ftm_irq_enable(void __iomem *base)
+diff --git a/drivers/soc/fsl/layerscape/ftm_alarm.c b/drivers/soc/fsl/layerscape/ftm_alarm.c
+new file mode 100644
+index 00000000..49865b0b
--- /dev/null
+++ b/drivers/soc/fsl/layerscape/ftm_alarm.c
-@@ -0,0 +1,286 @@
+@@ -0,0 +1,367 @@
+/*
+ * Freescale FlexTimer Module (FTM) Alarm driver.
+ *
@@ -53,6 +58,10 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+#include <linux/platform_device.h>
++#include <linux/of.h>
++#include <linux/of_device.h>
++#include <linux/libata.h>
++#include <linux/module.h>
+
+#define FTM_SC 0x00
+#define FTM_SC_CLK_SHIFT 3
@@ -77,6 +86,57 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
+static u32 alarm_freq;
+static bool big_endian;
+
++enum pmu_endian_type {
++ BIG_ENDIAN,
++ LITTLE_ENDIAN,
++};
++
++struct rcpm_cfg {
++ enum pmu_endian_type big_endian; /* Big/Little endian of PMU module */
++ u32 flextimer_set_bit; /* FlexTimer1 is not powerdown during device LPM20 */
++};
++
++static struct rcpm_cfg ls1012a_rcpm_cfg = {
++ .big_endian = BIG_ENDIAN,
++ .flextimer_set_bit = 0x20000,
++};
++
++static struct rcpm_cfg ls1021a_rcpm_cfg = {
++ .big_endian = BIG_ENDIAN,
++ .flextimer_set_bit = 0x20000,
++};
++
++static struct rcpm_cfg ls1043a_rcpm_cfg = {
++ .big_endian = BIG_ENDIAN,
++ .flextimer_set_bit = 0x20000,
++};
++
++static struct rcpm_cfg ls1046a_rcpm_cfg = {
++ .big_endian = BIG_ENDIAN,
++ .flextimer_set_bit = 0x20000,
++};
++
++static struct rcpm_cfg ls1088a_rcpm_cfg = {
++ .big_endian = LITTLE_ENDIAN,
++ .flextimer_set_bit = 0x4000,
++};
++
++static struct rcpm_cfg ls208xa_rcpm_cfg = {
++ .big_endian = LITTLE_ENDIAN,
++ .flextimer_set_bit = 0x4000,
++};
++
++static const struct of_device_id ippdexpcr_of_match[] = {
++ { .compatible = "fsl,ls1012a-ftm", .data = &ls1012a_rcpm_cfg},
++ { .compatible = "fsl,ls1021a-ftm", .data = &ls1021a_rcpm_cfg},
++ { .compatible = "fsl,ls1043a-ftm", .data = &ls1043a_rcpm_cfg},
++ { .compatible = "fsl,ls1046a-ftm", .data = &ls1046a_rcpm_cfg},
++ { .compatible = "fsl,ls1088a-ftm", .data = &ls1088a_rcpm_cfg},
++ { .compatible = "fsl,ls208xa-ftm", .data = &ls208xa_rcpm_cfg},
++ {},
++};
++MODULE_DEVICE_TABLE(of, ippdexpcr_of_match);
++
+static inline u32 ftm_readl(void __iomem *addr)
+{
+ if (big_endian)
@@ -251,7 +311,10 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
+ struct resource *r;
+ int irq;
+ int ret;
-+ u32 ippdexpcr;
++ struct rcpm_cfg *rcpm_cfg;
++ u32 ippdexpcr, flextimer;
++ const struct of_device_id *of_id;
++ enum pmu_endian_type endian;
+
+ r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!r)
@@ -261,14 +324,32 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
+ if (IS_ERR(ftm1_base))
+ return PTR_ERR(ftm1_base);
+
++ of_id = of_match_node(ippdexpcr_of_match, np);
++ if (!of_id)
++ return -ENODEV;
++
++ rcpm_cfg = devm_kzalloc(&pdev->dev, sizeof(*rcpm_cfg), GFP_KERNEL);
++ if (!rcpm_cfg)
++ return -ENOMEM;
++
++ rcpm_cfg = (struct rcpm_cfg*)of_id->data;
++ endian = rcpm_cfg->big_endian;
++ flextimer = rcpm_cfg->flextimer_set_bit;
++
+ r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "FlexTimer1");
+ if (r) {
+ rcpm_ftm_addr = devm_ioremap_resource(&pdev->dev, r);
+ if (IS_ERR(rcpm_ftm_addr))
+ return PTR_ERR(rcpm_ftm_addr);
-+ ippdexpcr = ioread32be(rcpm_ftm_addr);
-+ ippdexpcr |= 0x20000;
-+ iowrite32be(ippdexpcr, rcpm_ftm_addr);
++ if (endian == BIG_ENDIAN)
++ ippdexpcr = ioread32be(rcpm_ftm_addr);
++ else
++ ippdexpcr = ioread32(rcpm_ftm_addr);
++ ippdexpcr |= flextimer;
++ if (endian == BIG_ENDIAN)
++ iowrite32be(ippdexpcr, rcpm_ftm_addr);
++ else
++ iowrite32(ippdexpcr, rcpm_ftm_addr);
+ }
+
+ irq = irq_of_parse_and_map(np, 0);
@@ -302,7 +383,12 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
+}
+
+static const struct of_device_id ftm_alarm_match[] = {
-+ { .compatible = "fsl,ftm-alarm", },
++ { .compatible = "fsl,ls1012a-ftm", },
++ { .compatible = "fsl,ls1021a-ftm", },
++ { .compatible = "fsl,ls1043a-ftm", },
++ { .compatible = "fsl,ls1046a-ftm", },
++ { .compatible = "fsl,ls1088a-ftm", },
++ { .compatible = "fsl,ls208xa-ftm", },
+ { .compatible = "fsl,ftm-timer", },
+ { },
+};
@@ -321,3 +407,6 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
+ return platform_driver_register(&ftm_alarm_driver);
+}
+device_initcall(ftm_alarm_init);
+--
+2.14.1
+