MLK-10174-1 arm: imx: gpc: export an interface to keep mega fast power
authorLi Jun <jun.li@freescale.com>
Thu, 29 Jan 2015 02:26:52 +0000 (10:26 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:48:03 +0000 (14:48 -0500)
Add an interface for GPC used by drivers to keep mega fast mix domain
power.

Signed-off-by: Li Jun <jun.li@freescale.com>
(cherry picked from commit f40b0d57803b26a889d12cb70f128801ef75055a)

arch/arm/mach-imx/common.h
arch/arm/mach-imx/gpc.c
include/linux/imx_gpc.h [new file with mode: 0644]

index 4a46191..4719b3f 100644 (file)
@@ -103,6 +103,8 @@ void imx_gpcv2_pre_suspend(bool arm_power_off);
 void imx_gpcv2_post_resume(void);
 void imx_gpcv2_set_core1_pdn_pup_by_software(bool pdn);
 unsigned int imx_gpcv2_is_mf_mix_off(void);
+int imx_gpc_mf_power_on(unsigned int irq, unsigned int on);
+int imx_gpcv2_mf_power_on(unsigned int irq, unsigned int on);
 void __init imx_gpcv2_check_dt(void);
 void imx_gpcv2_set_lpm_mode(enum mxc_cpu_pwr_mode mode);
 void imx_gpcv2_set_cpu_power_gate_in_idle(bool pdn);
index 2a420d6..a854416 100644 (file)
@@ -57,6 +57,7 @@ static u32 gpc_wake_irqs[IMR_NUM];
 static u32 gpc_saved_imrs[IMR_NUM];
 static u32 gpc_mf_irqs[IMR_NUM];
 static u32 gpc_mf_request_on[IMR_NUM];
+static DEFINE_SPINLOCK(gpc_lock);
 
 unsigned int imx_gpc_is_mf_mix_off(void)
 {
@@ -267,6 +268,33 @@ static const struct irq_domain_ops imx_gpc_domain_ops = {
        .free           = irq_domain_free_irqs_common,
 };
 
+int imx_gpc_mf_power_on(unsigned int irq, unsigned int on)
+{
+       struct irq_desc *d = irq_to_desc(irq);
+       unsigned int idx = d->irq_data.hwirq / 32;
+       unsigned long flags;
+       u32 mask;
+
+       mask = 1 << (d->irq_data.hwirq % 32);
+       spin_lock_irqsave(&gpc_lock, flags);
+       gpc_mf_request_on[idx] = on ? gpc_mf_request_on[idx] | mask :
+                                 gpc_mf_request_on[idx] & ~mask;
+       spin_unlock_irqrestore(&gpc_lock, flags);
+
+       return 0;
+}
+
+int imx_gpc_mf_request_on(unsigned int irq, unsigned int on)
+{
+       if (cpu_is_imx6sx() || cpu_is_imx6ul())
+               return imx_gpc_mf_power_on(irq, on);
+       else if (cpu_is_imx7d())
+               return imx_gpcv2_mf_power_on(irq, on);
+       else
+               return 0;
+}
+EXPORT_SYMBOL_GPL(imx_gpc_mf_request_on);
+
 static int __init imx_gpc_init(struct device_node *node,
                               struct device_node *parent)
 {
diff --git a/include/linux/imx_gpc.h b/include/linux/imx_gpc.h
new file mode 100644 (file)
index 0000000..2cffa4b
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2015 Freescale Semiconductor, Inc.
+ */
+
+/*
+ * The code contained herein is licensed under the GNU Lesser General
+ * Public License.  You may obtain a copy of the GNU Lesser General
+ * Public License Version 2.1 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/lgpl-license.html
+ * http://www.gnu.org/copyleft/lgpl.html
+ */
+
+/*
+ * @file linux/imx_gpc.h
+ *
+ * @brief Global header file for imx GPC
+ *
+ * @ingroup GPC
+ */
+#ifndef __LINUX_IMX_GPC_H__
+#define __LINUX_IMX_GPC_H__
+
+int imx_gpc_mf_request_on(unsigned int irq, unsigned int on);
+#endif /* __LINUX_IMX_GPC_H__ */