From patchwork Sun Apr 27 13:29:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King X-Patchwork-Id: 4071611 Return-Path: X-Original-To: patchwork-linux-pm@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 B18329F169 for ; Sun, 27 Apr 2014 13:29:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C959420256 for ; Sun, 27 Apr 2014 13:29:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2A45B20266 for ; Sun, 27 Apr 2014 13:29:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752252AbaD0N3T (ORCPT ); Sun, 27 Apr 2014 09:29:19 -0400 Received: from gw-1.arm.linux.org.uk ([78.32.30.217]:53704 "EHLO pandora.arm.linux.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753188AbaD0N3P (ORCPT ); Sun, 27 Apr 2014 09:29:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=pandora; h=Date:Sender:Message-Id:Subject:Cc:To:From:References:In-Reply-To; bh=go7Nn32CBHW9/AMQ7/GAvt7cA7fOqHR5ybbaK+5RewQ=; b=Zno8xl90Gk86gpI0gYjVQqgFH7xtt/eGx8AojiFkLwZD7qVhWmc0AKe2Z+Z8tn+hVlLPWq35Q5XfxxtKP4DlbO3i4rGCQQX+KcyeWrE9l6GB7d8jvxvGSXzM51e1NLNIYhffzt7pit5LMRkcyHUHIYEY5L0zurNnkMDkonl6oDw=; Received: from e0022681537dd.dyn.arm.linux.org.uk ([2002:4e20:1eda:1:222:68ff:fe15:37dd]:50944 helo=rmk-PC.arm.linux.org.uk) by pandora.arm.linux.org.uk with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1WeP8p-0005ir-KN; Sun, 27 Apr 2014 14:29:11 +0100 Received: from rmk by rmk-PC.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1WeP8p-0000Uw-7m; Sun, 27 Apr 2014 14:29:11 +0100 In-Reply-To: <20140427132312.GC26756@n2100.arm.linux.org.uk> References: <20140427132312.GC26756@n2100.arm.linux.org.uk> From: Russell King To: linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Cc: devicetree@vger.kernel.org, linux-pm@vger.kernel.org, Mark Rutland , Pawel Moll , "Rafael J. Wysocki" , Rob Herring Subject: [PATCH 5/5] ARM: dove: add non-DT PMU support Message-Id: Date: Sun, 27 Apr 2014 14:29:11 +0100 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 Since Dove has non-DT support still, this patch adds the static data to the PMU driver in order to initialise PMU domains. Signed-off-by: Russell King --- arch/arm/mach-dove/pmu.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-dove/pmu.c b/arch/arm/mach-dove/pmu.c index 0b3201fa2d5c..9832044dbab9 100644 --- a/arch/arm/mach-dove/pmu.c +++ b/arch/arm/mach-dove/pmu.c @@ -226,6 +226,20 @@ static void __pmu_domain_register(struct pmu_domain *domain) pm_genpd_init(&domain->base, NULL, !(val & domain->pwr_mask)); } +static void pmu_domain_register(struct pmu_data *pmu, + const struct pmu_domain *pmu_dom) +{ + struct pmu_domain *domain; + + domain = kmemdup(pmu_dom, sizeof(*domain), GFP_KERNEL); + if (!domain) + return; + + domain->pmu = pmu; + + __pmu_domain_register(domain); +} + static void pmu_add_genpd_of(struct device *dev) { struct device_node *node; @@ -241,6 +255,15 @@ static void pmu_add_genpd_of(struct device *dev) } } +static void pmu_add_genpd_name(const char *name, struct device *dev) +{ + while (1) { + if (pm_genpd_name_add_device(name, dev) != -EAGAIN) + break; + cond_resched(); + } +} + static void pmu_remove_genpd(struct device *dev) { struct generic_pm_domain *genpd = dev_to_genpd(dev); @@ -256,11 +279,19 @@ static int pmu_platform_call(struct notifier_block *nb, unsigned long event, void *data) { struct device *dev = data; + const char *name = NULL; + + if (strcmp(dev_name(dev), "ap510-vmeta.0") == 0) + name = "vpu"; + else if (strcmp(dev_name(dev), "galcore.0") == 0) + name = "gpu"; switch (event) { case BUS_NOTIFY_ADD_DEVICE: if (dev->of_node) pmu_add_genpd_of(dev); + else if (name) + pmu_add_genpd_name(name, dev); break; case BUS_NOTIFY_DEL_DEVICE: @@ -363,6 +394,49 @@ static int __init dove_init_pmu_irq(struct pmu_data *pmu, int irq) return 0; } +static struct pmu_data pmu_data = { + .lock = __SPIN_LOCK_UNLOCKED(&pmu.lock), + .pmc_base = DOVE_PMU_VIRT_BASE, + .pmu_base = DOVE_PMU_VIRT_BASE + 0x8000, +}; + +static struct pmu_domain vpu_domain = { + .pwr_mask = PMU_PWR_DOWN_VPU, + .rst_mask = PMU_SW_RST_VIDEO_MASK, + .iso_mask = PMU_ISO_VPU, + .base = { + .name = "vpu", + }, +}; + +static struct pmu_domain gpu_domain = { + .pwr_mask = PMU_PWR_DOWN_GPU, + .rst_mask = PMU_SW_RST_GPU_MASK, + .iso_mask = PMU_ISO_GPU, + .base = { + .name = "gpu", + }, +}; + +static int __init dove_pmu_init_legacy(void) +{ + struct pmu_data *pmu = &pmu_data; + int ret, parent_irq; + + pmu_reset_init(pmu); + pmu_domain_register(pmu, &vpu_domain); + pmu_domain_register(pmu, &gpu_domain); + pm_genpd_poweroff_unused(); + + ret = dove_init_pmu_irq(pmu, IRQ_DOVE_PMU); + if (ret) + pr_err("dove_init_pmu_irq() failed: %d\n", ret); + + bus_register_notifier(&platform_bus_type, &platform_nb); + + return 0; +} + /* * pmu { * compatible = "marvell,pmu"; @@ -390,7 +464,7 @@ int __init dove_init_pmu(void) /* Lookup the PMU node */ np_pmu = of_find_compatible_node(NULL, NULL, "marvell,pmu"); if (!np_pmu) - return 0; + return dove_pmu_init_legacy(); pmu = kzalloc(sizeof(*pmu), GFP_KERNEL); if (!pmu)