From: Li Jun Date: Thu, 29 Jan 2015 02:26:52 +0000 (+0800) Subject: MLK-10174-1 arm: imx: gpc: export an interface to keep mega fast power X-Git-Tag: C0P2-H0.0--20200415~4511 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=b4c25ff8063a65e188475fa38ad799015f30febb;p=linux.git MLK-10174-1 arm: imx: gpc: export an interface to keep mega fast power Add an interface for GPC used by drivers to keep mega fast mix domain power. Signed-off-by: Li Jun (cherry picked from commit f40b0d57803b26a889d12cb70f128801ef75055a) --- diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h index 4a46191677b8..4719b3fd0a25 100644 --- a/arch/arm/mach-imx/common.h +++ b/arch/arm/mach-imx/common.h @@ -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); diff --git a/arch/arm/mach-imx/gpc.c b/arch/arm/mach-imx/gpc.c index 2a420d6414cc..a854416916d0 100644 --- a/arch/arm/mach-imx/gpc.c +++ b/arch/arm/mach-imx/gpc.c @@ -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 index 000000000000..2cffa4be22aa --- /dev/null +++ b/include/linux/imx_gpc.h @@ -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__ */