mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-25 05:34:00 +08:00
99c6bcf46d
More multiplatform enablement for ARM platforms. The ones converted in this branch are: - bcm2835 - cns3xxx - sirf - nomadik - msx - spear - tegra - ux500 We're getting close to having most of them converted! One of the larger platforms remaining is Samsung Exynos, and there are a bunch of supporting patches in this merge window for it. There was a patch in this branch to a early version of multiplatform conversion, but it ended up being reverted due to need of more bake time. The revert commit is part of the branch since it would have required rebasing multiple dependent branches and they were stable by then. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAABAgAGBQJRgg99AAoJEIwa5zzehBx3n78P/j0w/8v+F4dM29ba5M/tqbFI e3wpeFykZ/HJH+FFIEYfIablpfHsLB0LEMh0dZmwHESFC6eR0RfGL2jOkpfcH9Ne 7B/JIFN4l1iwqqKCXf+QbYL6e8YFxlJkg6BIB4KhNgliQoO/ASP/8EbcgROYuxmN KPVdw9laUCCvb5Ogh2NWVAkBHhVGAEiqK20r4TQz8alI8RUmMleWM3o+wLBWVhOO d3gtYSfuFSbrJfbpKSdycLizoV/NekdOC1A9Ov9YuOdw8DzNbrThCRQtu0tIUgxN JjfnGlEJLsJS9SESfr8SYWxTuhe/lB2dGqjQPvRtl2HGBhbtTlnWfQ0k2ZHdeJuD J50SLrGA2gN9E5PlHJXjYk8uhhGIq8bNTJ//CtDkfKTq1D7PuHVEpEctsaz3BBbM U+x9zP2v4FB+yrZu8w+gkQY/wDgHsxj08mT6BK0+l8ePdyQV22CvwmM5XlJFI03x 5J0nLYiYfef+ZN9rGgVrQbn+yv+IEkE4DmeiscjeVJE5LVdVrDpYGfx7UA7V0UA7 i3KRVpNKuy1v7GJDnKlEBPkmB+vgXTRXUPDVCuC4n0Hi5PYj4es1gY6AoXGF90wm vtKxGr/2XDLP7Ro+m0OXMttSgQShnmbrbOngfkWcFwUmG7cB3SSUUOGKM+2LNnXM MJTqVhPjkZ2GYBi/J6S/ =4hSo -----END PGP SIGNATURE----- Merge tag 'multiplatform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc Pull ARM SoC multiplatform updates from Olof Johansson: "More multiplatform enablement for ARM platforms. The ones converted in this branch are: - bcm2835 - cns3xxx - sirf - nomadik - msx - spear - tegra - ux500 We're getting close to having most of them converted! One of the larger platforms remaining is Samsung Exynos, and there are a bunch of supporting patches in this merge window for it. There was a patch in this branch to a early version of multiplatform conversion, but it ended up being reverted due to need of more bake time. The revert commit is part of the branch since it would have required rebasing multiple dependent branches and they were stable by then" * tag 'multiplatform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (70 commits) mmc: sdhci-s3c: Fix operation on non-single image Samsung platforms clocksource: nomadik-mtu: fix up clocksource/timer Revert "ARM: exynos: enable multiplatform support" ARM: SPEAr13xx: Fix typo "ARCH_HAVE_CPUFREQ" ARM: exynos: enable multiplatform support rtc: s3c: make header file local mtd: onenand/samsung: make regs-onenand.h file local thermal/exynos: remove unnecessary header inclusions mmc: sdhci-s3c: remove platform dependencies ARM: samsung: move mfc device definition to s5p-dev-mfc.c ARM: exynos: move debug-macro.S to include/debug/ ARM: exynos: prepare for sparse IRQ ARM: exynos: introduce EXYNOS_ATAGS symbol ARM: tegra: build assembly files with -march=armv7-a ARM: Push selects for TWD/SCU into machine entries ARM: ux500: build hotplug.o for ARMv7-a ARM: ux500: move to multiplatform ARM: ux500: make remaining headers local ARM: ux500: make irqs.h local to platform ARM: ux500: get rid of <mach/[hardware|db8500-regs].h> ...
125 lines
3.1 KiB
C
125 lines
3.1 KiB
C
/*
|
|
* Copyright (c) 2012 Linaro : Daniel Lezcano <daniel.lezcano@linaro.org> (IBM)
|
|
*
|
|
* Based on the work of Rickard Andersson <rickard.andersson@stericsson.com>
|
|
* and Jonas Aaberg <jonas.aberg@stericsson.com>.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/cpuidle.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/atomic.h>
|
|
#include <linux/smp.h>
|
|
#include <linux/mfd/dbx500-prcmu.h>
|
|
#include <linux/platform_data/arm-ux500-pm.h>
|
|
|
|
#include <asm/cpuidle.h>
|
|
#include <asm/proc-fns.h>
|
|
|
|
#include "db8500-regs.h"
|
|
|
|
static atomic_t master = ATOMIC_INIT(0);
|
|
static DEFINE_SPINLOCK(master_lock);
|
|
|
|
static inline int ux500_enter_idle(struct cpuidle_device *dev,
|
|
struct cpuidle_driver *drv, int index)
|
|
{
|
|
int this_cpu = smp_processor_id();
|
|
bool recouple = false;
|
|
|
|
if (atomic_inc_return(&master) == num_online_cpus()) {
|
|
|
|
/* With this lock, we prevent the other cpu to exit and enter
|
|
* this function again and become the master */
|
|
if (!spin_trylock(&master_lock))
|
|
goto wfi;
|
|
|
|
/* decouple the gic from the A9 cores */
|
|
if (prcmu_gic_decouple()) {
|
|
spin_unlock(&master_lock);
|
|
goto out;
|
|
}
|
|
|
|
/* If an error occur, we will have to recouple the gic
|
|
* manually */
|
|
recouple = true;
|
|
|
|
/* At this state, as the gic is decoupled, if the other
|
|
* cpu is in WFI, we have the guarantee it won't be wake
|
|
* up, so we can safely go to retention */
|
|
if (!prcmu_is_cpu_in_wfi(this_cpu ? 0 : 1))
|
|
goto out;
|
|
|
|
/* The prcmu will be in charge of watching the interrupts
|
|
* and wake up the cpus */
|
|
if (prcmu_copy_gic_settings())
|
|
goto out;
|
|
|
|
/* Check in the meantime an interrupt did
|
|
* not occur on the gic ... */
|
|
if (prcmu_gic_pending_irq())
|
|
goto out;
|
|
|
|
/* ... and the prcmu */
|
|
if (prcmu_pending_irq())
|
|
goto out;
|
|
|
|
/* Go to the retention state, the prcmu will wait for the
|
|
* cpu to go WFI and this is what happens after exiting this
|
|
* 'master' critical section */
|
|
if (prcmu_set_power_state(PRCMU_AP_IDLE, true, true))
|
|
goto out;
|
|
|
|
/* When we switch to retention, the prcmu is in charge
|
|
* of recoupling the gic automatically */
|
|
recouple = false;
|
|
|
|
spin_unlock(&master_lock);
|
|
}
|
|
wfi:
|
|
cpu_do_idle();
|
|
out:
|
|
atomic_dec(&master);
|
|
|
|
if (recouple) {
|
|
prcmu_gic_recouple();
|
|
spin_unlock(&master_lock);
|
|
}
|
|
|
|
return index;
|
|
}
|
|
|
|
static struct cpuidle_driver ux500_idle_driver = {
|
|
.name = "ux500_idle",
|
|
.owner = THIS_MODULE,
|
|
.states = {
|
|
ARM_CPUIDLE_WFI_STATE,
|
|
{
|
|
.enter = ux500_enter_idle,
|
|
.exit_latency = 70,
|
|
.target_residency = 260,
|
|
.flags = CPUIDLE_FLAG_TIME_VALID |
|
|
CPUIDLE_FLAG_TIMER_STOP,
|
|
.name = "ApIdle",
|
|
.desc = "ARM Retention",
|
|
},
|
|
},
|
|
.safe_state_index = 0,
|
|
.state_count = 2,
|
|
};
|
|
|
|
int __init ux500_idle_init(void)
|
|
{
|
|
/* Configure wake up reasons */
|
|
prcmu_enable_wakeups(PRCMU_WAKEUP(ARM) | PRCMU_WAKEUP(RTC) |
|
|
PRCMU_WAKEUP(ABB));
|
|
|
|
return cpuidle_register(&ux500_idle_driver, NULL);
|
|
}
|
|
|
|
device_initcall(ux500_idle_init);
|