Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1007944ybz; Wed, 29 Apr 2020 13:19:58 -0700 (PDT) X-Google-Smtp-Source: APiQypKRupuLk6fa5w8jKMd4dcAuOJSyi/zHV+Z9y44BNuuPQSeBo11U38uBhp6b4Xd4yTU4Yk/y X-Received: by 2002:a17:906:3492:: with SMTP id g18mr4156697ejb.112.1588191598332; Wed, 29 Apr 2020 13:19:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588191598; cv=none; d=google.com; s=arc-20160816; b=p7VR8Ic6YP/+kS0VzelgdIzcrp6klMVhVZL1dTIQi0UA4/XBY0It2UlD+UpPpBMLor 6wzji3rNiXQpXD1CCFvGFGIwNwkuJU2CZ2/wZDX+78AhtDNcjZH5wDItT6QvFRkG1VeU kNSBpjTeTaZzQ/rNz9Ari2GL5VTHhMozRYhnWbwY2hbKt42N034/YGrWYqkHdIsa9OfY qVMj+QpndOmCQmDz4U8i43Inetg/AT9TGFwrTLvtoNX/nC+Hi7GacJVWQ3+qy2ZDaALx a68WhxTpXEZ3NsiMv2o+6hTJYm+/51tEJsHmOBI6cWMXjmO5mA1MJzND23+LBTRFWsK5 QaKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1zoQa+ThGA1a5k62C+YVRReIRqRAT+ZWYkJ8mwLP5jA=; b=bCg8BDhAFYyjH4EQbRhLEV4FodvxRT6rn5y+9Tjv1FPYcmYnamurFjIAc5RFRRkdl3 kQ5T/C3ZafyLxqGXZJwq99je8pMlhmp8k0dTuMArnVKMYcECnLsy2MdGeBRpWebMtrkD f9aqfVbL4x5inFO0CBh+jOrySO1wYBGBgCYNi64yZELUhkiVXkUr8/2Hq+IeU+yqc8Qg FiUnqlcF5A39gYIOcMiYk1jvK416hSqqmkV78xcqff2NrKTMmpgShKaBs6UvOHmFlYeG UGIQ4e0Yhp4gN4GJKkaLDg9a8vBmuYogDZM8924d9zQ2nIhTE4+b6O+eOvRHsgyCNlaG EkjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@googlemail.com header.s=20161025 header.b=HO0Mhip1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y8si4145320edv.143.2020.04.29.13.19.34; Wed, 29 Apr 2020 13:19:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@googlemail.com header.s=20161025 header.b=HO0Mhip1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727901AbgD2URx (ORCPT + 99 others); Wed, 29 Apr 2020 16:17:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727124AbgD2URW (ORCPT ); Wed, 29 Apr 2020 16:17:22 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C78CAC03C1AE; Wed, 29 Apr 2020 13:17:21 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id s10so4151967wrr.0; Wed, 29 Apr 2020 13:17:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1zoQa+ThGA1a5k62C+YVRReIRqRAT+ZWYkJ8mwLP5jA=; b=HO0Mhip1lp0c90pKkg5HF+2Xi8ipoLoZCjBymL/hCZEdtEOUvuhAyu2Emi+oh14tz0 treSzae4lgi7uEJjpqdN8NcvelrsiR4b2Xoto0beyyaagymmYETL4HDgy7DgnF/tpzRp fW+jNCw5vh1mXIdvzcbSAqBq5y/3lqESvMrnxe9WCWl9OrKmsNjyVv7bE176w2OvP+Ao jsnuPqlWWzFyi2l8n3BzieNBlqqOM8IuuDmtVTtwwh/qR6Ya2+ieBJRlC9hCsBYQrHcS eDTudmAAD1UARmX0Vc64TqggXt8GPIDtrTENM1eNjQOs6uE05Xl/RD90zMwzpeiYCubt Zu6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1zoQa+ThGA1a5k62C+YVRReIRqRAT+ZWYkJ8mwLP5jA=; b=o8/rr1dqbtkovkYajxSPsbPTGygj5wZm74V6nqpOEPxIfA48cj61iGzxBvMYbdjF33 wbgACZKaTPvHWgVGLl3a4co+TUorq6BTfKkWEt0TSjYzkUil4va961ZWFKuWsbZbJdgh +QSs1boDihY4iLphyI4iUcO16Amf2qAGVR8HwVz/FJMuWZCfvzlCbmfmg7mmMTXDJ/x2 LDsC3NTN7CCW6aAlXhQtXSXsnAt0M1B0FazrqmgJjsKjhV8E3SWtFxjRmcUz5nEqewTL NwPybBsl/nWEVcYOG3gvqm+wCZjpl0GxJVtxJrsZmEy7BpD0XXfwEpeAncu9u+m14LMg 8ShA== X-Gm-Message-State: AGi0PuaEJBJUkX3Di/anUrUeRU7wOlbdHpXiRXIxltpKhTGmoRo8FIuu QYzy2YVhI/Vp00OIVKkVjqQ= X-Received: by 2002:a5d:4b0a:: with SMTP id v10mr19723880wrq.342.1588191440393; Wed, 29 Apr 2020 13:17:20 -0700 (PDT) Received: from localhost.localdomain (p200300F137142E00428D5CFFFEB99DB8.dip0.t-ipconnect.de. [2003:f1:3714:2e00:428d:5cff:feb9:9db8]) by smtp.googlemail.com with ESMTPSA id q143sm9923623wme.31.2020.04.29.13.17.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2020 13:17:19 -0700 (PDT) From: Martin Blumenstingl To: robh+dt@kernel.org, andrew@lunn.ch, f.fainelli@gmail.com, linux-amlogic@lists.infradead.org, devicetree@vger.kernel.org Cc: jianxin.pan@amlogic.com, davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Martin Blumenstingl Subject: [PATCH RFC v2 07/11] net: stmmac: dwmac-meson8b: Make the clock enabling code re-usable Date: Wed, 29 Apr 2020 22:16:40 +0200 Message-Id: <20200429201644.1144546-8-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200429201644.1144546-1-martin.blumenstingl@googlemail.com> References: <20200429201644.1144546-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The timing adjustment clock will need similar logic as the RGMII clock: It has to be enabled in the driver conditionally and when the driver is unloaded it should be disabled again. Extract the existing code for the RGMII clock into a new function so it can be re-used. Signed-off-by: Martin Blumenstingl --- .../ethernet/stmicro/stmmac/dwmac-meson8b.c | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c index 41f3ef6bea66..d31f79c455de 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c @@ -266,6 +266,22 @@ static int meson_axg_set_phy_mode(struct meson8b_dwmac *dwmac) return 0; } +static int meson8b_devm_clk_prepare_enable(struct meson8b_dwmac *dwmac, + struct clk *clk) +{ + int ret; + + ret = clk_prepare_enable(clk); + if (ret) + return ret; + + devm_add_action_or_reset(dwmac->dev, + (void(*)(void *))clk_disable_unprepare, + dwmac->rgmii_tx_clk); + + return 0; +} + static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac) { int ret; @@ -299,16 +315,13 @@ static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac) return ret; } - ret = clk_prepare_enable(dwmac->rgmii_tx_clk); + ret = meson8b_devm_clk_prepare_enable(dwmac, + dwmac->rgmii_tx_clk); if (ret) { dev_err(dwmac->dev, "failed to enable the RGMII TX clock\n"); return ret; } - - devm_add_action_or_reset(dwmac->dev, - (void(*)(void *))clk_disable_unprepare, - dwmac->rgmii_tx_clk); break; case PHY_INTERFACE_MODE_RMII: -- 2.26.2