Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5272879rwd; Mon, 12 Jun 2023 02:34:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6zX/ymLuSnqH+sBnI0fY5yIdcQauyifmhYWNqxPF+HYAx7nodnYNA1JX86fFnGULCQBIFJ X-Received: by 2002:a17:90a:19d7:b0:258:de1b:9dcc with SMTP id 23-20020a17090a19d700b00258de1b9dccmr10555187pjj.9.1686562466648; Mon, 12 Jun 2023 02:34:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686562466; cv=none; d=google.com; s=arc-20160816; b=mCGiiUJmZBXjFAKCwaIvm9kyYNzo3t9ZKO1jyOLb/N8/QWGl/yr8yH2/RCr5c9zOry T7klKMPfrqICLGKV6rbxBH0Gq1TLpEddB7JucXxNtLnCaCP44kTjt6nCADDKkporm/k1 GvdLscrXA0PndSv4bjkG2aC/u7APiKcXK4Htio7QwNNa2pi6QJkN+ZcCbKVXJJxs/XZl FmuVuswAUMtBx5Ig3nYfqM+fOamRBxi3Cv/RPnfjxgjOXBujNJ06Tl4g792INp83DZqg f/SAbS3VVSXvo6W9UVLnsBY133kLiu0iy98xM7hlnk/Obx6BUuEHJCJEPEsTl/PNMzPQ 4QKQ== 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 :dkim-signature; bh=WtiGUP9ra+nN5+GqOB+XAIPugwOoW0PwoEeYaWXDQls=; b=QZ8q8zYCkJk9PBPCEOnKlNhv05YL1LKLVmk5LaD8LrtWf+EkeMmiPDFO7EYOHApdow Uizw32sxQg6tOy3bTd9VDciy6NmPVLe3tJGLEEkiR176UsBKvmCmhQkvHNrV0syIjpl4 oxxbXInfrK2TdLzlRUTHlS3xK98mMGtDVku1B/mhsrPiL/rknFDFyXwhgK9WvNGN9wW/ G1f0jMEmMgeqbtGpnqYLhIFhyMKEWXFkKFcgGX6IzBr3PNQHsVBOvZjN9pXkHEv3djJf SGJ21dJ+7APRFPCyDhiYFCQmogNhJstJMjVV9WGFneQZ3L+HGia/OmRDsKTGJTXviPYR wTkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20221208.gappssmtp.com header.s=20221208 header.b=ewW4ilPW; 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 e6-20020a170902cf4600b001aad291018fsi6665943plg.350.2023.06.12.02.34.11; Mon, 12 Jun 2023 02:34:26 -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; dkim=pass header.i=@bgdev-pl.20221208.gappssmtp.com header.s=20221208 header.b=ewW4ilPW; 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 S233108AbjFLJcE (ORCPT + 99 others); Mon, 12 Jun 2023 05:32:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232955AbjFLJaV (ORCPT ); Mon, 12 Jun 2023 05:30:21 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B0104EC2 for ; Mon, 12 Jun 2023 02:24:51 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3f6dfc4e01fso41423125e9.0 for ; Mon, 12 Jun 2023 02:24:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20221208.gappssmtp.com; s=20221208; t=1686561889; x=1689153889; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WtiGUP9ra+nN5+GqOB+XAIPugwOoW0PwoEeYaWXDQls=; b=ewW4ilPWNv7194ancCa8h4Y2nB9YHWmOOTZiAPChRO1LOfZRRdXY/Q3X6OjGm5QyED tzZCF5qaleZ00eF4KQLSjPLPk0TNPsnKTOsx1fxBzPooOeCLgmEZO5nQjr7l6tFLgkGG 1LOt8o7G8ubTSO0VPXoauA3uLBTwM2nytfqbwwophk78EeKKzwtErTWeIxU2wLFl7y2j KwWADOmvCOeU5Rm1K6AjUUnsQsZ/qLncaNkUlaE3uC/dgn61R0oY2Htjc0phFZVhW6va P1mlE2HiQxyKUAfTNmtu+HrwE7ov3+pP2vTpYOFzD2ppmg7FNeZ+c8ipUBfuQsficczr 85+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686561889; x=1689153889; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WtiGUP9ra+nN5+GqOB+XAIPugwOoW0PwoEeYaWXDQls=; b=fpDaWPnF4fKaD8uAxmerm7+SWSyqplCpbxN3sRXdAZz5XejkGwbcCRLhCSM0vW656R Kik3KWCfQAaQRIvE4UuLySoKGTdvkcMa7fv+Kj2OSNOUfL6EN+Q1McUP1XDt5Yyk14Vg j09hHAFtRMghMz2K0Uy6o99CGpWG5FiyxepCAQStU/9G80KGbo4aHa3Si+UmGh2SGyt1 v3SstQjg9sONihLEQ08VDzH9u/WdYrKGFuYjGi7HOwT2GEXi0k5zV+ofOHxH8gHy5QqE S6SbX7xe63G2oBvDuNC5WkYb1HZY0kwMjebRZfM5ZuTz9iYVlNQvf1UjjzfbIbVGET+M QmgA== X-Gm-Message-State: AC+VfDyVXI9F12V5YrqsKNxDA+dP8WMMMrfGUE9Q63VSc93MlBGfM4Yp VNq4QDFg9W+i1cvV6Jsc1FNH8Q== X-Received: by 2002:a05:600c:2204:b0:3f7:35a9:dfdf with SMTP id z4-20020a05600c220400b003f735a9dfdfmr6517067wml.24.1686561889654; Mon, 12 Jun 2023 02:24:49 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:a222:bbe9:c688:33ae]) by smtp.gmail.com with ESMTPSA id p14-20020a7bcc8e000000b003f727764b10sm10892044wma.4.2023.06.12.02.24.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 02:24:48 -0700 (PDT) From: Bartosz Golaszewski To: Vinod Koul , Bhupesh Sharma , Andy Gross , Bjorn Andersson , Konrad Dybcio , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kishon Vijay Abraham I , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu Cc: netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Bartosz Golaszewski Subject: [PATCH 16/26] net: stmmac: dwmac-qcom-ethqos: prepare the driver for more PHY modes Date: Mon, 12 Jun 2023 11:23:45 +0200 Message-Id: <20230612092355.87937-17-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230612092355.87937-1-brgl@bgdev.pl> References: <20230612092355.87937-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, 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 From: Bartosz Golaszewski In preparation for supporting SGMII, let's make the code a bit more generic. Add a new callback for MAC configuration so that we can assign a different variant of it in the future. Signed-off-by: Bartosz Golaszewski --- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index 21f329d2f7eb..2f96f2c11278 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -92,12 +92,14 @@ struct ethqos_emac_driver_data { struct qcom_ethqos { struct platform_device *pdev; void __iomem *rgmii_base; + int (*configure_func)(struct qcom_ethqos *ethqos); unsigned int rgmii_clk_rate; struct clk *rgmii_clk; struct clk *phyaux_clk; struct phy *serdes_phy; unsigned int speed; + int phy_mode; const struct ethqos_emac_por *por; unsigned int num_por; @@ -332,13 +334,11 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos) { struct device *dev = ðqos->pdev->dev; int phase_shift; - int phy_mode; int loopback; /* Determine if the PHY adds a 2 ns TX delay or the MAC handles it */ - phy_mode = device_get_phy_mode(dev); - if (phy_mode == PHY_INTERFACE_MODE_RGMII_ID || - phy_mode == PHY_INTERFACE_MODE_RGMII_TXID) + if (ethqos->phy_mode == PHY_INTERFACE_MODE_RGMII_ID || + ethqos->phy_mode == PHY_INTERFACE_MODE_RGMII_TXID) phase_shift = 0; else phase_shift = RGMII_CONFIG2_TX_CLK_PHASE_SHIFT_EN; @@ -485,7 +485,7 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos) return 0; } -static int ethqos_configure(struct qcom_ethqos *ethqos) +static int ethqos_configure_rgmii(struct qcom_ethqos *ethqos) { struct device *dev = ðqos->pdev->dev; volatile unsigned int dll_lock; @@ -561,6 +561,11 @@ static int ethqos_configure(struct qcom_ethqos *ethqos) return 0; } +static int ethqos_configure(struct qcom_ethqos *ethqos) +{ + return ethqos->configure_func(ethqos); +} + static void ethqos_fix_mac_speed(void *priv, unsigned int speed) { struct qcom_ethqos *ethqos = priv; @@ -660,6 +665,22 @@ static int qcom_ethqos_probe(struct platform_device *pdev) goto out_config_dt; } + ethqos->phy_mode = device_get_phy_mode(dev); + switch (ethqos->phy_mode) { + case PHY_INTERFACE_MODE_RGMII: + case PHY_INTERFACE_MODE_RGMII_ID: + case PHY_INTERFACE_MODE_RGMII_RXID: + case PHY_INTERFACE_MODE_RGMII_TXID: + ethqos->configure_func = ethqos_configure_rgmii; + break; + case -ENODEV: + ret = -ENODEV; + goto out_config_dt; + default: + ret = -EINVAL; + goto out_config_dt; + } + ethqos->pdev = pdev; ethqos->rgmii_base = devm_platform_ioremap_resource_byname(pdev, "rgmii"); if (IS_ERR(ethqos->rgmii_base)) { -- 2.39.2