From: lorenzo.pieralisi@arm.com (Lorenzo Pieralisi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 5/6] arm: exynos: Add MCPM call-back functions
Date: Wed, 30 Apr 2014 15:59:11 +0100 [thread overview]
Message-ID: <20140430145911.GA32671@e102568-lin.cambridge.arm.com> (raw)
In-Reply-To: <1398528348-21214-6-git-send-email-a.kesavan@samsung.com>
On Sat, Apr 26, 2014 at 05:05:47PM +0100, Abhilash Kesavan wrote:
[...]
> + if (last_man && __mcpm_outbound_enter_critical(cpu, cluster)) {
> + arch_spin_unlock(&exynos_mcpm_lock);
> +
I missed it on first review, but you do need to disable L2 prefetching
on A15 here as we do in TC2 (tc2_pm.c), this power down procedure is not
compliant otherwise.
Thanks,
Lorenzo
> + /* Flush all cache levels for this cluster. */
> + exynos_v7_exit_coherency_flush(all);
> +
> + /*
> + * Disable cluster-level coherency by masking
> + * incoming snoops and DVM messages:
> + */
> + cci_disable_port_by_cpu(mpidr);
> +
> + __mcpm_outbound_leave_critical(cluster, CLUSTER_DOWN);
> + } else {
> + arch_spin_unlock(&exynos_mcpm_lock);
> +
> + /* Disable and flush the local CPU cache. */
> + exynos_v7_exit_coherency_flush(louis);
> + }
> +
> + __mcpm_cpu_down(cpu, cluster);
> +
> + /* Now we are prepared for power-down, do it: */
> + if (!skip_wfi)
> + wfi();
> +
> + /* Not dead at this point? Let our caller cope. */
> +}
> +
> +static int exynos_power_down_finish(unsigned int cpu, unsigned int cluster)
> +{
> + unsigned int tries = 100;
> + unsigned int cpunr = cpu + (cluster * EXYNOS5420_CPUS_PER_CLUSTER);
> +
> + pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster);
> + BUG_ON(cpu >= EXYNOS5420_CPUS_PER_CLUSTER ||
> + cluster >= EXYNOS5420_NR_CLUSTERS);
> +
> + /* Wait for the core state to be OFF */
> + while (tries--) {
> + if (ACCESS_ONCE(cpu_use_count[cpu][cluster]) == 0) {
> + if ((exynos_cpu_power_state(cpunr) == 0))
> + return 0; /* success: the CPU is halted */
> + }
> +
> + /* Otherwise, wait and retry: */
> + msleep(1);
> + }
> +
> + return -ETIMEDOUT; /* timeout */
> +}
> +
> +static const struct mcpm_platform_ops exynos_power_ops = {
> + .power_up = exynos_power_up,
> + .power_down = exynos_power_down,
> + .power_down_finish = exynos_power_down_finish,
> +};
> +
> +static void __init exynos_mcpm_usage_count_init(void)
> +{
> + unsigned int mpidr, cpu, cluster;
> +
> + mpidr = read_cpuid_mpidr();
> + cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
> + cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
> +
> + pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster);
> + BUG_ON(cpu >= EXYNOS5420_CPUS_PER_CLUSTER ||
> + cluster >= EXYNOS5420_NR_CLUSTERS);
> +
> + cpu_use_count[cpu][cluster] = 1;
> +}
> +
> +/*
> + * Enable cluster-level coherency, in preparation for turning on the MMU.
> + */
> +static void __naked exynos_pm_power_up_setup(unsigned int affinity_level)
> +{
> + asm volatile ("\n"
> + "cmp r0, #1\n"
> + "bxne lr\n"
> + "b cci_enable_port_for_self");
> +}
> +
> +static int __init exynos_mcpm_init(void)
> +{
> + int ret = 0;
> +
> + if (!soc_is_exynos5420())
> + return -ENODEV;
> +
> + if (!cci_probed())
> + return -ENODEV;
> +
> + /*
> + * To increase the stability of KFC reset we need to program
> + * the PMU SPARE3 register
> + */
> + __raw_writel(EXYNOS5420_SWRESET_KFC_SEL, S5P_PMU_SPARE3);
> +
> + exynos_mcpm_usage_count_init();
> +
> + ret = mcpm_platform_register(&exynos_power_ops);
> + if (!ret)
> + ret = mcpm_sync_init(exynos_pm_power_up_setup);
> + if (ret)
> + return ret;
> +
> + mcpm_smp_set_ops();
> +
> + pr_info("Exynos MCPM support installed\n");
> +
> + /*
> + * Future entries into the kernel can now go
> + * through the cluster entry vectors.
> + */
> + __raw_writel(virt_to_phys(mcpm_entry_point),
> + REG_ENTRY_ADDR);
> +
> + return ret;
> +}
> +
> +early_initcall(exynos_mcpm_init);
> diff --git a/arch/arm/mach-exynos/regs-pmu.h b/arch/arm/mach-exynos/regs-pmu.h
> index 6685ebf..f44d318 100644
> --- a/arch/arm/mach-exynos/regs-pmu.h
> +++ b/arch/arm/mach-exynos/regs-pmu.h
> @@ -38,6 +38,7 @@
> #define S5P_INFORM5 S5P_PMUREG(0x0814)
> #define S5P_INFORM6 S5P_PMUREG(0x0818)
> #define S5P_INFORM7 S5P_PMUREG(0x081C)
> +#define S5P_PMU_SPARE3 S5P_PMUREG(0x090C)
>
> #define S5P_ARM_CORE0_LOWPWR S5P_PMUREG(0x1000)
> #define S5P_DIS_IRQ_CORE0 S5P_PMUREG(0x1004)
> @@ -325,4 +326,6 @@
>
> #define EXYNOS5_OPTION_USE_RETENTION (1 << 4)
>
> +#define EXYNOS5420_SWRESET_KFC_SEL 0x3
> +
> #endif /* __ASM_ARCH_REGS_PMU_H */
> --
> 1.8.3.2
>
>
next prev parent reply other threads:[~2014-04-30 14:59 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-26 16:05 [PATCH v3 0/6] MCPM backend for Exynos5420 Abhilash Kesavan
2014-04-26 16:05 ` [PATCH v3 1/6] ARM: EXYNOS: Add generic cpu power control functions for all exynos based SoCs Abhilash Kesavan
2014-04-26 16:05 ` [PATCH v3 2/6] ARM: EXYNOS: use generic exynos cpu power control functions Abhilash Kesavan
2014-05-02 15:25 ` [PATCH v4 2/5] " Abhilash Kesavan
2014-04-26 16:05 ` [PATCH v3 3/6] arm: exynos: Add generic cluster " Abhilash Kesavan
2014-05-02 15:25 ` [PATCH v4 3/5] " Abhilash Kesavan
2014-04-26 16:05 ` [PATCH v3 4/6] ARM: dts: exynos5420: add CCI node Abhilash Kesavan
2014-05-02 15:25 ` [PATCH v4 4/5] " Abhilash Kesavan
2014-04-26 16:05 ` [PATCH v3 5/6] arm: exynos: Add MCPM call-back functions Abhilash Kesavan
2014-04-28 17:44 ` Lorenzo Pieralisi
2014-04-29 3:32 ` Abhilash Kesavan
2014-04-29 18:49 ` Nicolas Pitre
2014-04-30 3:01 ` Abhilash Kesavan
2014-04-30 10:24 ` Dave Martin
2014-04-30 14:43 ` Nicolas Pitre
2014-05-01 9:39 ` Abhilash Kesavan
2014-04-30 14:59 ` Lorenzo Pieralisi [this message]
2014-05-01 9:39 ` Abhilash Kesavan
2014-05-02 15:25 ` [PATCH v4 5/5] " Abhilash Kesavan
2014-05-02 18:16 ` Nicolas Pitre
2014-05-02 18:23 ` Andrew Bresticker
2014-05-02 18:37 ` Nicolas Pitre
2014-05-05 16:26 ` Abhilash Kesavan
2014-05-05 16:25 ` Abhilash Kesavan
2014-04-26 16:05 ` [PATCH v3 6/6] arm: exynos: Add /dev/bL_status user interface on Exynos5420 Abhilash Kesavan
2014-04-28 11:25 ` Daniel Lezcano
2014-04-28 12:49 ` Abhilash Kesavan
2014-04-30 14:49 ` Nicolas Pitre
2014-05-01 9:39 ` Abhilash Kesavan
2014-05-02 15:24 ` [PATCH v4 0/5] MCPM backend for Exynos5420 Abhilash Kesavan
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=20140430145911.GA32671@e102568-lin.cambridge.arm.com \
--to=lorenzo.pieralisi@arm.com \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).