From patchwork Wed Apr 13 12:10:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Hung X-Patchwork-Id: 12811990 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 38343C433EF for ; Wed, 13 Apr 2022 12:49:45 +0000 (UTC) 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:References:In-Reply-To: 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: List-Owner; bh=f1vbkeFp8suIoS9GEoGKbo2wyXEIcjLVtmpQvkREEck=; b=UjNFsv7Rn2lVen ++L2X8wkz03+JT+g6oafpZq+EhRLPuVY1H7eYyYLTazCfVb02xksbYZOxLnBkIsH6onDLRZlFw8n2 U/0kIx+n5yv2DENkeNG7DWSHDlQAXTZAU2J0FSrRHveTwqzdRS9JR5eQsmYOcV4Vi9tP5BydCdHv9 RxnAxq3htyNQ8C0j6Iww/sIZAAsIS2lyni+jHO3yHz3hYUDzZWBsECw+90wafPnYR5PiknazH7fCy ulpSEHxcLJaXZCVTtkYdTsLkpGf+3iwstsT4/rjqS4xc9b1PHkfYHwBvlCqsHirFfNNJnkhBezlOn KEYazFOieJWEEPJCyYSg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1necQF-0014Bd-C2; Wed, 13 Apr 2022 12:48:35 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1necQD-0014AM-2f for linux-arm-kernel@bombadil.infradead.org; Wed, 13 Apr 2022 12:48:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Content-Transfer-Encoding :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=OpVrZh7RW2vZohO4klkow+hjCTZ1CY8lmFXky2NN5qE=; b=b85vlTZGCyqblVfvLRuBZJnKC2 7dYyPw9y57PEHFSaU5AtLad8GU4MkQa5c+dAgCUmyg9CEX3JdEK/BrFBpgDbSKC+UFHBar5ZmWI6A XHKkiFwZNmcrGsx1zDjKzw9IayneGKf/jDiemiCTXCBGK8g9S7+m468BIMqZzGO8EZjm+BvFZ7jAb wNMugUTFbDz4Hhv3G5FykQe5rgF0069tW3sPLtAdf/mT0zl21CCELNLWowMoOq3WMIBPlxFB0UNNU oeEbVW1ozxe6btt5jZ/MhawlPDOHKiGEW054P0zMmrIbQC5n0hqpyiUu6CDfmm++dxkk8pSIOSNZq KYegAeXA==; Received: from twspam01.aspeedtech.com ([211.20.114.71]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1neboa-004dw8-5W for linux-arm-kernel@lists.infradead.org; Wed, 13 Apr 2022 12:09:44 +0000 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 23DBusPS017390; Wed, 13 Apr 2022 19:56:54 +0800 (GMT-8) (envelope-from dylan_hung@aspeedtech.com) Received: from DylanHung-PC.aspeed.com (192.168.2.216) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 13 Apr 2022 20:08:38 +0800 From: Dylan Hung To: , , , , , , , , , , , , , , , CC: Subject: [PATCH v5 2/3] net: mdio: add reset control for Aspeed MDIO Date: Wed, 13 Apr 2022 20:10:36 +0800 Message-ID: <20220413121037.23748-3-dylan_hung@aspeedtech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220413121037.23748-1-dylan_hung@aspeedtech.com> References: <20220413121037.23748-1-dylan_hung@aspeedtech.com> MIME-Version: 1.0 X-Originating-IP: [192.168.2.216] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 23DBusPS017390 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220413_130941_151307_805DCD9F X-CRM114-Status: GOOD ( 13.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add reset assertion/deassertion for Aspeed MDIO. There are 4 MDIO controllers embedded in Aspeed AST2600 SOC and share one reset control register SCU50[3]. To work with old DT blobs which don't have the reset property, devm_reset_control_get_optional_shared is used in this change. Signed-off-by: Dylan Hung Reviewed-by: Philipp Zabel Reviewed-by: Andrew Lunn --- drivers/net/mdio/mdio-aspeed.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/net/mdio/mdio-aspeed.c b/drivers/net/mdio/mdio-aspeed.c index e2273588c75b..1afb58ccc524 100644 --- a/drivers/net/mdio/mdio-aspeed.c +++ b/drivers/net/mdio/mdio-aspeed.c @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -37,6 +38,7 @@ struct aspeed_mdio { void __iomem *base; + struct reset_control *reset; }; static int aspeed_mdio_read(struct mii_bus *bus, int addr, int regnum) @@ -120,6 +122,12 @@ static int aspeed_mdio_probe(struct platform_device *pdev) if (IS_ERR(ctx->base)) return PTR_ERR(ctx->base); + ctx->reset = devm_reset_control_get_optional_shared(&pdev->dev, NULL); + if (IS_ERR(ctx->reset)) + return PTR_ERR(ctx->reset); + + reset_control_deassert(ctx->reset); + bus->name = DRV_NAME; snprintf(bus->id, MII_BUS_ID_SIZE, "%s%d", pdev->name, pdev->id); bus->parent = &pdev->dev; @@ -129,6 +137,7 @@ static int aspeed_mdio_probe(struct platform_device *pdev) rc = of_mdiobus_register(bus, pdev->dev.of_node); if (rc) { dev_err(&pdev->dev, "Cannot register MDIO bus!\n"); + reset_control_assert(ctx->reset); return rc; } @@ -139,7 +148,11 @@ static int aspeed_mdio_probe(struct platform_device *pdev) static int aspeed_mdio_remove(struct platform_device *pdev) { - mdiobus_unregister(platform_get_drvdata(pdev)); + struct mii_bus *bus = (struct mii_bus *)platform_get_drvdata(pdev); + struct aspeed_mdio *ctx = bus->priv; + + reset_control_assert(ctx->reset); + mdiobus_unregister(bus); return 0; }