Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp261438pxb; Thu, 7 Apr 2022 05:05:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwq/hgDxWnPuzcEXK/9UxbUQ6E/njgKULfm61/Xvjgf5Pwlx/VlyZrHZhSgKLz4g4SHotR3 X-Received: by 2002:a17:907:8a15:b0:6e8:a80:aaae with SMTP id sc21-20020a1709078a1500b006e80a80aaaemr13299727ejc.637.1649333106586; Thu, 07 Apr 2022 05:05:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649333106; cv=none; d=google.com; s=arc-20160816; b=i2KWz++lw6BLi3ZrqHCoKfJIdqfRl0AW+8QosBaC4hdh8SVrqtHmG4ksxwbziDeW+C IxlFXswNAi0Bd6dhs01X5UO0PFf4TpwZi0X9mIGXbD3WpYsxH+dLfEg3uuNXszbSl2CO uMzVOCaQHzeYU4fJGwlDbYia6M6J3fAUcg+LWk270E7gpi8y4sWK6anuXrVRwMs1/Wi0 GjFCiQ+xqg/yUn3vW2HDLa2Z0Tgo1Y7RelbgwLbPS6GNlLN2T6cw3gpkp5QPAYTmRmQo kM1qPdUDluDwFJQRGk+kCH/sXSVQz+Q6bOkX546NAhWcPjTWbtKaZRDmqu1QE+tOk/cF yq9Q== 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=E5b1LWB1DiHexXJ3Ck/uNOgi43Y6N1+zDCfUn5DS+PI=; b=vWYk6cbLxYYfcgbxd0OOrRK+eL3mPV5nNMHnvN/JNPYCSgsYr8NbP4jj5irJrLFgHK xkWF6RpVyzuA2uSXOgbMe0n2RYzIQJQL6m6kQlpzO46PqT7i1+ypWQUi2Q4bIgbofi3L zCq8j3EG7/Qp/RyG7XU4OGzaZWNIyiMQ9yK9oDSla7Ltx/hOcHbOpg69mJXFVHsD7TYp WSpEyivW7UbxiVZ48Ns6Qfr6q1Zu4BnalAlm6LDr+OYMcl34qFok30ko4BxEGI91FZ60 RsM1vIrtwLpbRAaqA2JY3BUDEFWXbh7tUjTf8lmddsTMS/NtLB0eN4GnWYChzDXZ9SRi LqMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p4-20020a17090635c400b006e7f5ad72d5si8411002ejb.580.2022.04.07.05.04.39; Thu, 07 Apr 2022 05:05:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239349AbiDGIAD (ORCPT + 99 others); Thu, 7 Apr 2022 04:00:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242483AbiDGH77 (ORCPT ); Thu, 7 Apr 2022 03:59:59 -0400 Received: from twspam01.aspeedtech.com (twspam01.aspeedtech.com [211.20.114.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69BBF111DCA; Thu, 7 Apr 2022 00:57:59 -0700 (PDT) Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 2377ieII045434; Thu, 7 Apr 2022 15:44:40 +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; Thu, 7 Apr 2022 15:56:00 +0800 From: Dylan Hung To: , , , , , , , , , , , , , , CC: Subject: [PATCH RESEND v3 2/3] net: mdio: add reset control for Aspeed MDIO Date: Thu, 7 Apr 2022 15:57:33 +0800 Message-ID: <20220407075734.19644-3-dylan_hung@aspeedtech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220407075734.19644-1-dylan_hung@aspeedtech.com> References: <20220407075734.19644-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 2377ieII045434 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 --- 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; } -- 2.25.1