From patchwork Tue Oct 26 09:37:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 12584325 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DA2DC433F5 for ; Tue, 26 Oct 2021 09:37:31 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 E9DF360551 for ; Tue, 26 Oct 2021 09:37:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E9DF360551 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=fgs4dkzLIoZWYUg9gujS2eVEDpLjwAxU1018ApAEYfE=; b=Z1xhS5JmRkz3Ro uFq63abWiqdnq5oWphajj0drOn7fNkvcRzEg901d3VT+3vVqKH8BsYKQ1eRT433k9gA/JB8H18MPT BiMQ9OkLfE0bJxrqlpVlyX0g6CO4NXRuiSwJYomxawsSJ3nD9gwxpWToJCe2qKBf8a98yHZW473hx 0BaEs6t0u8PeVUFCtPekgY43zFogfn2ZWcyNfeMoKnFlb13xH6oR7ZuVF1JItUOOhetdSqpv8IDRd goXcetLd/MYlwdt0oGbA2KznHX3Xnqws6S3iFjduKIT8HKwUttMnAePKCfZsPMaobGJjK3q7HfRnC JRb8bno3zc4+7uT7gzpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfIte-001Jj3-37; Tue, 26 Oct 2021 09:37:30 +0000 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfIta-001Jg3-Ij for linux-phy@lists.infradead.org; Tue, 26 Oct 2021 09:37:28 +0000 Received: by mail-lf1-x12e.google.com with SMTP id j2so2976462lfg.3 for ; Tue, 26 Oct 2021 02:37:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vKFWLSRl10tgQ1BAA/camWrcHhGVWkCvOyqQZ1aZWm4=; b=ZXK1k4pBYcr5jb/Oai+oGIp59SN838ETCgJhW3Y5443AzH2W7qh+r6OEzbV1mpp0Fl c17lqXzoULzIrV6mvN+acqvEmicr+fsnSErFYlK6f402aE0ptRyjibv5CXx7COz6YZHA 0XL5vnsIkF2RehilDw4qzvObqhafZZdgC5SaiNjfeIHA0OpCsUWxJ7l/lqesuZCGLWei tS6vHm/FfL1u+v+aLrFNyCgtdiIFFUOErn5utAhXLSiV9P+n42ppsFqvdzSKf8vpH7Ye r6v4QBMPp0ilh87yLy7MCNLXz3LmhPQ/01bOpcHNMN3Wkfdt/wBEAUAnwsY+WVz4aQaH qTeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vKFWLSRl10tgQ1BAA/camWrcHhGVWkCvOyqQZ1aZWm4=; b=u/ITM1YILG8FnnnXqbLgu15nwAPCu4RkgAq7CqvT+930ON1sHlOv3+OTpkexcxY9po bIn07TAMj6OAM6r5TCpReMYCgHX9w7XEyweNHzG2qe52fimxBqaNm3EEUqGzUKUTgBWX awJUWeUWGBazmeX05Ivj7jrgp6XWkti3HuoIrs6yD28AxrABwKij7+R3BxqijHYJHr5V 8HZc73p1/2v2396GfMM4f90KjO4rzAxA8B/2x1GTPNntPQO4xhTnbktSker3M963szDj sO7baOyQmQwBRagPo4Zv4y9Tvf6Q/JyT80pINuQP9xJ94WJMPTCBDiHLGzP/qzk3zQ4a vVtw== X-Gm-Message-State: AOAM530j8l2LG++SgKnBV+1aaoXjLljSPGbwGb3iTtq3wL2Vi6nxF/Np DXV7E37bZ4n8G3pA2UStUSb+jiSZfxk= X-Google-Smtp-Source: ABdhPJxhtvBSZIiI+yxopG7DgTgfVaLQi15+YGbGH/tCbj/A+fNOqUTIW8/Y54zRFNqjF0L7oiz4gA== X-Received: by 2002:a05:6512:4016:: with SMTP id br22mr14257700lfb.132.1635241043910; Tue, 26 Oct 2021 02:37:23 -0700 (PDT) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id o9sm600438lfk.292.2021.10.26.02.37.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 02:37:23 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Kishon Vijay Abraham I , Vinod Koul Cc: Florian Fainelli , Chunfeng Yun , linux-phy@lists.infradead.org, devicetree@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH RESEND] phy: bcm-ns-usb2: support updated DT binding with PHY reg space Date: Tue, 26 Oct 2021 11:37:16 +0200 Message-Id: <20211026093716.5567-1-zajec5@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211026_023726_669197_1F54FFEE X-CRM114-Status: GOOD ( 18.32 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org From: Rafał Miłecki Updated DT binding maps just a PHY's register space instead of the whole DMU block. Accessing a common CRU reg is handled using syscon & regmap. The old binding has been deprecated and remains supported as a fallback method. Signed-off-by: Rafał Miłecki --- This patch has been previously sent in a patchset touching two subsystems: PHY and MFD. For that reason probably it has been missed. This adds support for binding added in the commit 55b9b741712d ("dt-bindings: phy: brcm,ns-usb2-phy: bind just a PHY block") (can be found in linux-phy.git). --- drivers/phy/broadcom/phy-bcm-ns-usb2.c | 52 +++++++++++++++++++++----- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/drivers/phy/broadcom/phy-bcm-ns-usb2.c b/drivers/phy/broadcom/phy-bcm-ns-usb2.c index 4b015b8a71c3..98d32729a45d 100644 --- a/drivers/phy/broadcom/phy-bcm-ns-usb2.c +++ b/drivers/phy/broadcom/phy-bcm-ns-usb2.c @@ -9,17 +9,23 @@ #include #include #include +#include #include #include #include #include #include +#include #include struct bcm_ns_usb2 { struct device *dev; struct clk *ref_clk; struct phy *phy; + struct regmap *clkset; + void __iomem *base; + + /* Deprecated binding */ void __iomem *dmu; }; @@ -27,7 +33,6 @@ static int bcm_ns_usb2_phy_init(struct phy *phy) { struct bcm_ns_usb2 *usb2 = phy_get_drvdata(phy); struct device *dev = usb2->dev; - void __iomem *dmu = usb2->dmu; u32 ref_clk_rate, usb2ctl, usb_pll_ndiv, usb_pll_pdiv; int err = 0; @@ -44,7 +49,10 @@ static int bcm_ns_usb2_phy_init(struct phy *phy) goto err_clk_off; } - usb2ctl = readl(dmu + BCMA_DMU_CRU_USB2_CONTROL); + if (usb2->base) + usb2ctl = readl(usb2->base); + else + usb2ctl = readl(usb2->dmu + BCMA_DMU_CRU_USB2_CONTROL); if (usb2ctl & BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_PDIV_MASK) { usb_pll_pdiv = usb2ctl; @@ -58,15 +66,24 @@ static int bcm_ns_usb2_phy_init(struct phy *phy) usb_pll_ndiv = (1920000000 * usb_pll_pdiv) / ref_clk_rate; /* Unlock DMU PLL settings with some magic value */ - writel(0x0000ea68, dmu + BCMA_DMU_CRU_CLKSET_KEY); + if (usb2->clkset) + regmap_write(usb2->clkset, 0, 0x0000ea68); + else + writel(0x0000ea68, usb2->dmu + BCMA_DMU_CRU_CLKSET_KEY); /* Write USB 2.0 PLL control setting */ usb2ctl &= ~BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_NDIV_MASK; usb2ctl |= usb_pll_ndiv << BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_NDIV_SHIFT; - writel(usb2ctl, dmu + BCMA_DMU_CRU_USB2_CONTROL); + if (usb2->base) + writel(usb2ctl, usb2->base); + else + writel(usb2ctl, usb2->dmu + BCMA_DMU_CRU_USB2_CONTROL); /* Lock DMU PLL settings */ - writel(0x00000000, dmu + BCMA_DMU_CRU_CLKSET_KEY); + if (usb2->clkset) + regmap_write(usb2->clkset, 0, 0x00000000); + else + writel(0x00000000, usb2->dmu + BCMA_DMU_CRU_CLKSET_KEY); err_clk_off: clk_disable_unprepare(usb2->ref_clk); @@ -90,10 +107,27 @@ static int bcm_ns_usb2_probe(struct platform_device *pdev) return -ENOMEM; usb2->dev = dev; - usb2->dmu = devm_platform_ioremap_resource_byname(pdev, "dmu"); - if (IS_ERR(usb2->dmu)) { - dev_err(dev, "Failed to map DMU regs\n"); - return PTR_ERR(usb2->dmu); + if (of_find_property(dev->of_node, "brcm,syscon-clkset", NULL)) { + usb2->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(usb2->base)) { + dev_err(dev, "Failed to map control reg\n"); + return PTR_ERR(usb2->base); + } + + usb2->clkset = syscon_regmap_lookup_by_phandle(dev->of_node, + "brcm,syscon-clkset"); + if (IS_ERR(usb2->clkset)) { + dev_err(dev, "Failed to lookup clkset regmap\n"); + return PTR_ERR(usb2->clkset); + } + } else { + usb2->dmu = devm_platform_ioremap_resource_byname(pdev, "dmu"); + if (IS_ERR(usb2->dmu)) { + dev_err(dev, "Failed to map DMU regs\n"); + return PTR_ERR(usb2->dmu); + } + + dev_warn(dev, "using deprecated DT binding\n"); } usb2->ref_clk = devm_clk_get(dev, "phy-ref-clk");