From patchwork Wed Apr 23 09:25:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chander Kashyap X-Patchwork-Id: 4039771 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3C2459F319 for ; Wed, 23 Apr 2014 09:29:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 63452201DE for ; Wed, 23 Apr 2014 09:29:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 86E702018E for ; Wed, 23 Apr 2014 09:29:07 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WctSK-00013O-U1; Wed, 23 Apr 2014 09:27:04 +0000 Received: from mail-pb0-f46.google.com ([209.85.160.46]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WctS3-0000d5-UM for linux-arm-kernel@lists.infradead.org; Wed, 23 Apr 2014 09:26:48 +0000 Received: by mail-pb0-f46.google.com with SMTP id rq2so599483pbb.33 for ; Wed, 23 Apr 2014 02:26:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KgLJEDdIEkmytuXhpkLjRX16WVhXabUHASp6S6c8YuM=; b=bCroQ5OEcuFNTe0Zr2OOVucn80R3L/wRO85bCLjab3VlvFuMp3TTqVo89jlUL3PO4x sgptxLBdMh0JKfbYPDoKl8wU59fWECjUq5i3t3oEJ00R+dQSncaBCboqVwIj6aE98cY6 TudwBrSWIw5Oqx978oqnpBcWbEpSY0ry3qBk9iOL0IaR+YTT0FYyAubhpA5IyT3D44QQ DasNEkfM4HjER61AOcMf29anBVcTVuGy/PLizzvdLiSCIa1Q0jSI+AhYon4qh6IkBcyd UEV5k7ec1vUDQDjWyEzqwLhWXT/ylD886LoE/wLH/x0Qrl8loLxiLeXUN7EyOUXz1MF0 1bgA== X-Gm-Message-State: ALoCoQkP7LWhLXdRCdPauZueiP51aG5+HndkUJ6rQ/AHio7BZCivxAEAcc8nsKepEzY220xXoJoX X-Received: by 10.68.233.99 with SMTP id tv3mr10731912pbc.163.1398245187183; Wed, 23 Apr 2014 02:26:27 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPSA id vg1sm1119481pbc.44.2014.04.23.02.26.23 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Apr 2014 02:26:26 -0700 (PDT) From: Chander Kashyap To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [Patch v2 4/4] mcpm: exynos: populate suspend and powered_up callbacks Date: Wed, 23 Apr 2014 14:55:54 +0530 Message-Id: <1398245154-18771-5-git-send-email-chander.kashyap@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1398245154-18771-1-git-send-email-chander.kashyap@linaro.org> References: <1398080958-21677-5-git-send-email-chander.kashyap@linaro.org> <1398245154-18771-1-git-send-email-chander.kashyap@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140423_022647_997709_3B1C63C3 X-CRM114-Status: GOOD ( 12.85 ) X-Spam-Score: -0.7 (/) Cc: Chander Kashyap , kgene.kim@samsung.com, daniel.lezcano@linaro.org, rjw@rjwysocki.net, Chander Kashyap , lorenzo.pieralisi@arm.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to support cpuidle through mcpm, suspend and powered-up callbacks are required in mcpm platform code. Hence populate the same callbacks. Signed-off-by: Chander Kashyap Signed-off-by: Chander Kashyap --- changes in v2: 1. Fixed typo: enynos_pmu_cpunr to exynos_pmu_cpunr arch/arm/mach-exynos/mcpm-exynos.c | 53 ++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/arch/arm/mach-exynos/mcpm-exynos.c b/arch/arm/mach-exynos/mcpm-exynos.c index 6c74c82..d53f597 100644 --- a/arch/arm/mach-exynos/mcpm-exynos.c +++ b/arch/arm/mach-exynos/mcpm-exynos.c @@ -272,10 +272,63 @@ static int exynos_power_down_finish(unsigned int cpu, unsigned int cluster) return 0; /* success: the CPU is halted */ } +static void enable_coherency(void) +{ + unsigned long v, u; + + asm volatile( + "mrc p15, 0, %0, c1, c0, 1\n" + "orr %0, %0, %2\n" + "ldr %1, [%3]\n" + "and %1, %1, #0\n" + "orr %0, %0, %1\n" + "mcr p15, 0, %0, c1, c0, 1\n" + : "=&r" (v), "=&r" (u) + : "Ir" (0x40), "Ir" (S5P_INFORM0) + : "cc"); +} + +void exynos_powered_up(void) +{ + unsigned int mpidr, cpu, cluster; + + mpidr = read_cpuid_mpidr(); + cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0); + cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1); + + arch_spin_lock(&exynos_mcpm_lock); + if (cpu_use_count[cpu][cluster] == 0) + cpu_use_count[cpu][cluster] = 1; + arch_spin_unlock(&exynos_mcpm_lock); +} + +static void exynos_suspend(u64 residency) +{ + unsigned int mpidr, cpunr; + + mpidr = read_cpuid_mpidr(); + cpunr = exynos_pmu_cpunr(mpidr); + + __raw_writel(virt_to_phys(mcpm_entry_point), REG_ENTRY_ADDR); + + exynos_power_down(); + + /* + * Execution reaches here only if cpu did not power down. + * Hence roll back the changes done in exynos_power_down function. + */ + __raw_writel(EXYNOS_CORE_LOCAL_PWR_EN, + EXYNOS_ARM_CORE_CONFIGURATION(cpunr)); + set_cr(get_cr() | CR_C); + enable_coherency(); +} + 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, + .suspend = exynos_suspend, + .powered_up = exynos_powered_up, }; static void __init exynos_mcpm_usage_count_init(void)