Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2382434pxb; Sun, 17 Apr 2022 21:03:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIuyy3EowKXwYArHKUHuJwgcsLqD/5CdxlFQSgDCxJLfRYjFvKIqXVSdHzolG8zDYM4Ml3 X-Received: by 2002:a17:906:fd48:b0:6e8:366b:156b with SMTP id wi8-20020a170906fd4800b006e8366b156bmr7272945ejb.317.1650254613109; Sun, 17 Apr 2022 21:03:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650254613; cv=none; d=google.com; s=arc-20160816; b=HO+3e9YI4C+x69tFMgLEq/9CWyGyz3o+DFK6j2yKoVrPzs51UHR4A1ze/YeMYuopTP UrzdnEoOaY9+ebv8yR/xJGSFEj/71CDgg/5sXW9TdxXopfjI3KqSdT4TNVpQqCGuXwD5 jR9WYMWcdD0G+1kuS02bqnPRW+LVBQDz+2lR6jbUwVlYyb6eI7qL0rGM+V9eU0CSmON0 L4vRbsKRy9cPEbfcnp414grdfF+YeXHS+/6L8qsdhKyQd8ErwUIy34Mp/CYsVM4ftyCW iTkxbiTeeHzMBOXgnapEqBRjHMMlgajgR7RgwjSa3IeA7rUldk0YG2UkkY4TlQ7Pe/0S LAaQ== 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=OpVrZh7RW2vZohO4klkow+hjCTZ1CY8lmFXky2NN5qE=; b=bxuSDMADbC6pWl3BOfECIUkYHCcgelyIECX5PIcFuVSzqE4zT/pggaW5EoaPnyHgxq OMcHo0khNrKEsqhBAH7Rb2ya6+YK+dSbhEjjIm1tO4lSU89hX8r6oaJutv2cznHYR3hv lUjVnl3UNgwPpdqslU5Mz1mgwUEBENpPfOCfaSQ2pgiU8d5cMdu+o1QzUkuvQffC97/Z 4Jzb26y6+fOwnbL8grHbceyBhrqvXbwYv8KxpOkcTSOjqP362d56YhwMiULG4nzI5HQh +5hQk8Pptb5f9WLSduTxCC6AW/szwOQLQsODSbb2fvgIXyB9vtV0krrhlHvSX7uOzKGI CFlw== 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 br4-20020a170906d14400b006dfe7bc2fafsi5390017ejb.56.2022.04.17.21.03.08; Sun, 17 Apr 2022 21:03:33 -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 S235646AbiDRBlh (ORCPT + 99 others); Sun, 17 Apr 2022 21:41:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235643AbiDRBlb (ORCPT ); Sun, 17 Apr 2022 21:41:31 -0400 Received: from twspam01.aspeedtech.com (twspam01.aspeedtech.com [211.20.114.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8945618349 for ; Sun, 17 Apr 2022 18:38:54 -0700 (PDT) Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 23I1Qh4I071542; Mon, 18 Apr 2022 09:26:43 +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; Mon, 18 Apr 2022 09:38:41 +0800 From: Dylan Hung To: , , , , , , , , , , , , , , , CC: Subject: [PATCH net-next RESEND v5 2/3] net: mdio: add reset control for Aspeed MDIO Date: Mon, 18 Apr 2022 09:40:58 +0800 Message-ID: <20220418014059.3054-3-dylan_hung@aspeedtech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220418014059.3054-1-dylan_hung@aspeedtech.com> References: <20220418014059.3054-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 23I1Qh4I071542 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 --- 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