Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4377048ioa; Wed, 27 Apr 2022 02:23:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4BXOfKjQC2+sk98KB5wegnzE3EBSehY89QbDPDyI5/lcP0BP2cXR4duqtDGsATS7E3tYA X-Received: by 2002:a17:902:8f86:b0:15b:4dfa:ba7b with SMTP id z6-20020a1709028f8600b0015b4dfaba7bmr27655182plo.43.1651051420457; Wed, 27 Apr 2022 02:23:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651051420; cv=none; d=google.com; s=arc-20160816; b=qsK8VRz1Yl4Jo23AhvDgACkYUJk9NpL6Vo2JJl7vxkOXSaLjSakLn+x+UGbOiNn3PY jbgmQFFsJBK+P/1dGMIBwGTxlPY9jiSpQ2Cnf/19qFKehhH9x28RAD7TliQuMNQKFP8M jQPqhfFfJIlK+mPx3tiZ7fPOdE48biX8RmTpOWeY956iyNqoLIX2dyHOHh59k4FbCZ5E FVT2xCkZd8KjOGjGldXM1L9X+QuqXYCPQRR/ldeVJai6sDsDWThb07hctXZewVKl3RUc VNxQVP8YGDGwgSIGcMwa0zee0x7l4CJHzqMNF19HCkD+z86Mhu1nEUF6UKaEQn5HH0nQ 1eCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=4DPKSYI6qSPBf0vFEdHy5vtXaCV8PVdGjATHijdnq5g=; b=qVrUDygl/0qGosGzgLvkDWBBIiB/sHM5JBQz9Kl8a09deOjBBv5tAATyf0+FxUmkPO q7R+oFVkn2YbMBsCexQb3o15wfWchUOSN8wFIK/Rxaa+PO3zNBBIvapm9cPWuj1ul0JN 9emmPPImBqn5psgcQMKbJfXAJOGgUTm2PEEpxiYLjTwqXoOdGV7J4mOui5IpatPMoYxF 3f0kD+Cu4M2q9cGDHIBc/jap2lTBWrxUz9zaMJPrt/kdK23C8Tl31kM8y5AmWNfedU3u YbcKR3+3CLROdTePiGlYHk9bENtdnAqEQuiobkrXx0FXVyXfinM7gvxPtEx+k5Y8iT56 UZdg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id m5-20020a170902f64500b00158e5bfcc7dsi1127584plg.136.2022.04.27.02.23.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 02:23:40 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1612838A3; Wed, 27 Apr 2022 02:09:40 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357603AbiD0D6e (ORCPT + 99 others); Tue, 26 Apr 2022 23:58:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357597AbiD0D60 (ORCPT ); Tue, 26 Apr 2022 23:58:26 -0400 Received: from twspam01.aspeedtech.com (twspam01.aspeedtech.com [211.20.114.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75C6869CE1 for ; Tue, 26 Apr 2022 20:55:15 -0700 (PDT) Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 23R3gTLg032328; Wed, 27 Apr 2022 11:42:29 +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, 27 Apr 2022 11:54:59 +0800 From: Dylan Hung To: , , , , , , , , , , , , , , , CC: Subject: [PATCH net-next v6 2/3] net: mdio: add reset control for Aspeed MDIO Date: Wed, 27 Apr 2022 11:55:00 +0800 Message-ID: <20220427035501.17500-3-dylan_hung@aspeedtech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220427035501.17500-1-dylan_hung@aspeedtech.com> References: <20220427035501.17500-1-dylan_hung@aspeedtech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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 23R3gTLg032328 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 Reviewed-by: Andrew Jeffery --- 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 7aa49827196f..944d005d2bd1 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 @@ -41,6 +42,7 @@ struct aspeed_mdio { void __iomem *base; + struct reset_control *reset; }; static int aspeed_mdio_op(struct mii_bus *bus, u8 st, u8 op, u8 phyad, u8 regad, @@ -174,6 +176,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; @@ -184,6 +192,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; } @@ -194,7 +203,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; } -- 2.25.1