Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp761245pxb; Tue, 12 Apr 2022 12:45:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypc49CNJO+k17n8pag68anoD3jZY6s4WBpbSLxh9m0h7OC5ccGvKPxmU0PgkED2Q9VIF4i X-Received: by 2002:a63:2cd4:0:b0:39d:8636:3808 with SMTP id s203-20020a632cd4000000b0039d86363808mr5648959pgs.290.1649792741992; Tue, 12 Apr 2022 12:45:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649792741; cv=none; d=google.com; s=arc-20160816; b=eQwCMESXLmYgp3VYmk+FJcvdWPv+ImBU68SgOKPkCTt+WXD1cGT5iQoaIgn1KeJFPU XOQkFM2qzhP1npVhTK3wuB738VEY+cyAek5/H/ILXKhyeogDjdSH8oWSTv62ZOH/ZOaM EGKHL3SUhSqpHm0B84I+xbe1XJNwJn+6MIKMLKbY43ryjMcO2MsTNtofXFhChEZ4QxGc xn0+4xveZKs28ZX86zvU7g+9sW65avXsvxXLgEuWHq6biHquy+7FHndUp8HwGeF7/qex 8jHQCMnOpf22NwOeOL81/rlWWv8nOZeNFE89rmCYjCsFrqkNIPiMFrLLbQQif/JPfGEV 3OmQ== 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=rHaZq3R7Q3NT0lt4/1EesuWqQsnvaGryAuEmmbTWXMkj8IqFGAiAl4Ds00H44enfUc ejY793ZqO4NvejbFyWrFXlPRn3trlljGoZMI9QnNKNCsJtvA6q5lXu1MIujXw7CmeeoM 79tYagkhP6+JBhuAeOeqepeozlryu26207W5DVGxVdbcumv7I7o+kmVrWLfaAAqKi2uS 2H3mX1A22X4LNKdF/2q4lAk7aCpjFXuvmuzWfSLkKfGCQ9i5dBqMlYSyErNtQxIfCt+M t6NbzQGNdDrdx3zF8ANSuQ4bBxEI8SD+iquKIiy+GgYqRo0hEYgA0yKbyZcnoh+aDIN2 +PKg== 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 e17-20020a056a00163100b0050571d2dff2si11344016pfc.306.2022.04.12.12.45.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 12:45:41 -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 C00FC67D37; Tue, 12 Apr 2022 12:43:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241318AbiDLHgu (ORCPT + 99 others); Tue, 12 Apr 2022 03:36:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352191AbiDLHNh (ORCPT ); Tue, 12 Apr 2022 03:13:37 -0400 Received: from twspam01.aspeedtech.com (twspam01.aspeedtech.com [211.20.114.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F435140E7 for ; Mon, 11 Apr 2022 23:54:26 -0700 (PDT) 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 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 23C6gdUM026334 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]. 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