From patchwork Tue Apr 12 06:56:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Hung X-Patchwork-Id: 12810223 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 6A4EAC433EF for ; Tue, 12 Apr 2022 07:57:22 +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=B64TOrfvYlI7oczjexB3/7vGzbBVTBUJbnLGemHZ5Ag=; b=vn6gmC1d0cwC8N 50wNNuxvMgMZ/xOFCGXXjRpKBO7xyxLrzNlRsPqAECfOzxDq/obK4GHdbkD/kj0PJFrkg5st+jWiy 7O6hHlhHe4jgr9act5pOnwW/SHjJKAd/THg35RwOYL9L7gb40mUeXlmmvCUcUF+POEFuxeiUsqCgK JqODloH/tlR9kfRcCNvnG10Y8t3O7MUXcs433Ck+HNytTmK7zhYITFqDdgjo34+Q8wnPqf9PpkDk0 nTAPHzgs54rcLSV4J88nHO7lRQ6+0eHI99rbwOTlA7jSnakJFqlX4hSiWzOpZ+zif9/AJuHfVCHac rMcirmWmgZ6xNBji8Tjw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1neBNc-00CN17-Em; Tue, 12 Apr 2022 07:56:04 +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 1neBGM-00CJRi-9X for linux-arm-kernel@bombadil.infradead.org; Tue, 12 Apr 2022 07:48:34 +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=E5b1LWB1DiHexXJ3Ck/uNOgi43Y6N1+zDCfUn5DS+PI=; b=h9aVl/nYBmxv7kMrwEp6MNZCSs uLrlUOBLX3dbQoN9vUch8yWat+bpCiDFXDZG1FLzajS6sBs2u0R67vWl+hLW5jImcht/pvS9bU6jO qZQtDdfC7NLVvKBggYoPPeoeCHvkMl2Uvi0VVovTTPxilyeHIdXmOZDDHGRrHecEYRjBYNKKf/43o 45Y6prGUU3yn+bwBbX2QXbP35WZoXREgP0y6LcaTAu1hvchaxGWZJwioFTB7hAnDivfD87P4AKB1X VEo/N65UOAd28u2Uzp17kJPH8AKwy9W7whIDKJKP9CJkg6bxj5tQqvnRZaDuo8iLpBi+MgiQIXW6I 1f5/l4gg==; Received: from twspam01.aspeedtech.com ([211.20.114.71]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1neAQw-004Euz-Id for linux-arm-kernel@lists.infradead.org; Tue, 12 Apr 2022 06:55:31 +0000 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 23C6gdUM026334; Tue, 12 Apr 2022 14:42:39 +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; Tue, 12 Apr 2022 14:54:19 +0800 From: Dylan Hung To: , , , , , , , , , , , , , , , CC: Subject: [PATCH v4 2/3] net: mdio: add reset control for Aspeed MDIO Date: Tue, 12 Apr 2022 14:56:10 +0800 Message-ID: <20220412065611.8930-3-dylan_hung@aspeedtech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220412065611.8930-1-dylan_hung@aspeedtech.com> References: <20220412065611.8930-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 23C6gdUM026334 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220412_075527_987502_C751656D X-CRM114-Status: GOOD ( 13.62 ) 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; }