From patchwork Fri Feb 5 13:52:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Saenz Julienne X-Patchwork-Id: 12070179 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C1E9C433DB for ; Fri, 5 Feb 2021 13:55:18 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E56B964DF6 for ; Fri, 5 Feb 2021 13:55:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E56B964DF6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=leici1ueQSbk3ulf3JkduuU2NgUJ5Ivm0KTbMgW6/I4=; b=wSoHhjJb3Ctfw9NI+V794/U0I NEq7o0qJ7SXOEQR+g/eVbSNeQNEiP+K/hg66m5G6v0YUdIrVxote83A1lKfwTT6Zk7cSsgDBPO7Gw Z9n/Way4P1+ao4mpgydt4TKJsOzKTn/4qsi1B8GOs09hZHiAhczZ4Am5Km/5fDJTsFOSI0l2ZUm/+ xG1vo/+EL9bqaZjCNUH/3V872NguoTK8GagrYkFM0AkL/RsYsAwjBDpyb1RLQ4SMtJ77Zh9mLSFH4 gqMLTearSgQuC/VsfGRnosodglZcOYhvOi4h/shauxMgyvIdmQsYiD8sKJ8QtJIsn3mNL/n0Kaes/ nu7wYE4oQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l81YV-00046R-DE; Fri, 05 Feb 2021 13:53:51 +0000 Received: from mx2.suse.de ([195.135.220.15]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l81Xh-0003oo-Ke; Fri, 05 Feb 2021 13:53:06 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 62858ACBA; Fri, 5 Feb 2021 13:53:00 +0000 (UTC) From: Nicolas Saenz Julienne To: f.fainelli@gmail.com, Saenz Julienne , bcm-kernel-feedback-list@broadcom.com, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Lee Jones , Ray Jui , Scott Branden Subject: [RFC/PATCH 04/11] mfd: bcm2835-pm: Add support for BCM2711 Date: Fri, 5 Feb 2021 14:52:40 +0100 Message-Id: <20210205135249.2924-5-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210205135249.2924-1-nsaenzjulienne@suse.de> References: <20210205135249.2924-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210205_085301_965147_60F1864F X-CRM114-Status: GOOD ( 23.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, phil@raspberrypi.com, wahrenst@gmx.net Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In BCM2711 the new ARGON ASB took over V3D. The old ASB is still present with the ISP and H264 bits, and V3D is in the same place in the new ASB as the old one. As per the devicetree bindings, BCM2711 will provide both the old and new ASB registers, so get both of them and pass them into 'bcm2835-power,' which will take care of selecting which one to use accordingly. We're being extra careful when dealing with older firmware. We can't assume all V3D users will use the new "brcm,bcm2711-pm" compatible string, so use the fact that a 3rd resource is present in firmware as a hint we're running on BCM2711. Signed-off-by: Nicolas Saenz Julienne --- drivers/mfd/bcm2835-pm.c | 55 ++++++++++++++++++++++++++-------- include/linux/mfd/bcm2835-pm.h | 1 + 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c index 42fe67f1538e..98c6943d3cd0 100644 --- a/drivers/mfd/bcm2835-pm.c +++ b/drivers/mfd/bcm2835-pm.c @@ -6,6 +6,7 @@ * the WDT and power drivers. */ +#include #include #include #include @@ -17,6 +18,9 @@ #include #include +#define BCM2835 BIT(1) +#define BCM2711 BIT(2) + static const struct mfd_cell bcm2835_pm_devs[] = { { .name = "bcm2835-wdt" }, }; @@ -30,6 +34,7 @@ static int bcm2835_pm_probe(struct platform_device *pdev) struct resource *res; struct device *dev = &pdev->dev; struct bcm2835_pm *pm; + bool is_bcm2711; int ret; pm = devm_kzalloc(dev, sizeof(*pm), GFP_KERNEL); @@ -38,6 +43,7 @@ static int bcm2835_pm_probe(struct platform_device *pdev) platform_set_drvdata(pdev, pm); pm->dev = dev; + is_bcm2711 = (uintptr_t)device_get_match_data(&pdev->dev) & BCM2711; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); pm->base = devm_ioremap_resource(dev, res); @@ -50,30 +56,53 @@ static int bcm2835_pm_probe(struct platform_device *pdev) if (ret) return ret; - /* We'll use the presence of the AXI ASB regs in the - * bcm2835-pm binding as the key for whether we can reference - * the full PM register range and support power domains. + /* To support old firmware, check if a third resource was defined and + * use that as a hint that we're on bcm2711. */ + res = platform_get_resource(pdev, IORESOURCE_MEM, 2); + if (res) { + pm->arsan_asb = devm_ioremap_resource(dev, res); + if (IS_ERR(pm->arsan_asb)) { + dev_err(dev, "Failed to map Arsan ASB: %ld\n", + PTR_ERR(pm->arsan_asb)); + return PTR_ERR(pm->arsan_asb); + } + + if (!is_bcm2711) { + dev_warn(dev, "Using an outdated DT, please update it\n"); + is_bcm2711 = true; + } + } + + if (is_bcm2711 && !pm->arsan_asb) { + dev_err(dev, "Arsan ASB resource missing\n"); + return -EINVAL; + } + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); if (res) { pm->asb = devm_ioremap_resource(dev, res); - if (IS_ERR(pm->asb)) + if (IS_ERR(pm->asb)) { + dev_err(dev, "Failed to map ASB: %ld\n", PTR_ERR(pm->asb)); return PTR_ERR(pm->asb); - - ret = devm_mfd_add_devices(dev, -1, - bcm2835_power_devs, - ARRAY_SIZE(bcm2835_power_devs), - NULL, 0, NULL); - if (ret) - return ret; + } } + /* We'll use the presence of the ASB regs in the bcm2835-pm binding as + * the key for whether we can reference the full PM register range and + * support power domains. + */ + if (pm->asb) + return devm_mfd_add_devices(dev, -1, bcm2835_power_devs, + ARRAY_SIZE(bcm2835_power_devs), + NULL, 0, NULL); return 0; } static const struct of_device_id bcm2835_pm_of_match[] = { - { .compatible = "brcm,bcm2835-pm-wdt", }, - { .compatible = "brcm,bcm2835-pm", }, + { .compatible = "brcm,bcm2835-pm-wdt", .data = (void *)BCM2835}, + { .compatible = "brcm,bcm2835-pm", .data = (void *)BCM2835}, + { .compatible = "brcm,bcm2711-pm", .data = (void *)BCM2711}, {}, }; MODULE_DEVICE_TABLE(of, bcm2835_pm_of_match); diff --git a/include/linux/mfd/bcm2835-pm.h b/include/linux/mfd/bcm2835-pm.h index ed37dc40e82a..536e3c85347c 100644 --- a/include/linux/mfd/bcm2835-pm.h +++ b/include/linux/mfd/bcm2835-pm.h @@ -9,6 +9,7 @@ struct bcm2835_pm { struct device *dev; void __iomem *base; void __iomem *asb; + void __iomem *arsan_asb; }; #endif /* BCM2835_MFD_PM_H */