Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2256301pxp; Mon, 21 Mar 2022 15:07:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnpvAq3pE5vSvZLghnP3jgzSWAyw2l8ij6E6YA7CkXyfdkbqBGDJcD5bk3wjy/jUQwkKn/ X-Received: by 2002:a17:902:d506:b0:154:377b:a38c with SMTP id b6-20020a170902d50600b00154377ba38cmr11796606plg.100.1647900449247; Mon, 21 Mar 2022 15:07:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647900449; cv=none; d=google.com; s=arc-20160816; b=i3LIHCvLbc+9dyuzPHRAqYYXHI+qms925SW7Cc+cuS8CP/fqwVM+LnXak8Z8d0Raqb 86YaTx3rkcSF3E2bnk9cOqf5tsfasMk1eSwmH8VtnPCnIxSWGZYZx+yWGD0tqIvPCrFd YkCB6GS1/II49VNWydY6QO7UO2ReIFls5PNtsMHfpslYsy7lRCZbuW6gnCNPb8Rz9YG9 dTx0Zw1XM/FTmVX3ph8ilPeTeqBLE7lvBEK0ZyksBWTTuod7Sn2zY9oo4AgvTyL2NIDi dvFYX0kCLOTF8ceOx+M7Ajl555Q6TfIaeR6yb/ItKBlfSsfrR3SA4d6ivYGkID20GxFk QuNA== 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=LuMbXbBelITZsR2Q2ibGaS+q4loqRrKNhNdOA2zt0n0=; b=Pp0/Zju4IFttYvEFR3bBxDc5a8XCfQAGpXiqv8NW0NVGCFksN5+3KTOKnyj5Sia138 5miXvVtyM6F7huBE/kqr1Pog4iP9Z9sxAPpSGlzHsV9BLCf2CgX+lD1Io2rIMFWaLZ8B 1SrF+98Cy3gR0POa2EPWAK+YURTGQw9XrnqIxqDtscVMu8lNUpV1Vloop+2dVnKJnmx5 RFKt5umzFegakpgV6A0fsbYKJrNJNO5OyG1MrcaauJ3f99exSyScDTNoK8wTtamPGV8K msLXzLcPJrcT31zK7K0aP3M+rurRr/6LFNb6AnyaaPk50/bf1ijiHYCXWcZdActkjucS rLow== 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:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j4-20020a170902c08400b001544015be4bsi7146900pld.355.2022.03.21.15.07.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:07:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 1A7344BFED; Mon, 21 Mar 2022 14:29:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346066AbiCUJ6O (ORCPT + 99 others); Mon, 21 Mar 2022 05:58:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346109AbiCUJ6A (ORCPT ); Mon, 21 Mar 2022 05:58:00 -0400 Received: from twspam01.aspeedtech.com (twspam01.aspeedtech.com [211.20.114.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35576137F41 for ; Mon, 21 Mar 2022 02:56:34 -0700 (PDT) Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 22L9jwJu079099; Mon, 21 Mar 2022 17:45:58 +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, 21 Mar 2022 17:56:23 +0800 From: Dylan Hung To: , , , , , , , , , , , , , , CC: , Subject: [PATCH v2 2/3] net: mdio: add reset control for Aspeed MDIO Date: Mon, 21 Mar 2022 17:56:47 +0800 Message-ID: <20220321095648.4760-3-dylan_hung@aspeedtech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220321095648.4760-1-dylan_hung@aspeedtech.com> References: <20220321095648.4760-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 22L9jwJu079099 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,T_SCC_BODY_TEXT_LINE 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]. So devm_reset_control_get_shared is used in this change. Signed-off-by: Dylan Hung Cc: stable@vger.kernel.org --- 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..5bda48d7071d 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_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