From patchwork Mon Jun 19 09:23:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 109861 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2876417vqr; Mon, 19 Jun 2023 02:42:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ76PONmeP7rznFKCJakzxRQqA4TFypw77rDk2/pqVNowbXpSx5uZRTC5PJS1mMTcrCvHfBG X-Received: by 2002:a54:4585:0:b0:394:4642:7148 with SMTP id z5-20020a544585000000b0039446427148mr9968465oib.48.1687167734824; Mon, 19 Jun 2023 02:42:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687167734; cv=none; d=google.com; s=arc-20160816; b=Wz78Wliw7jcsNE7/FMHEwJkNx+gudbdJC3qs+6YAsBEdBDh2NKmUh/j5kMqo8I8u69 TL/bn5aueiyfiVXr+PvEEfxj/Tflx5UqLkVpwCWkIIP2d34JI50MHkhE+gvaB8jyCKyw kG3Gx1LX/DrpdUE2w+n6aRbv5dXmgqsShit0XBkT4gk0IK2AHV+0ZAFDtN6tJOSstUGc uNYWtJD222aI3eq+KNdmt84tlTG8g5adRvf2CA3V0fj0KFRWR7D4F9uqcOCN73dNmruS SziPyWBDjqqeBboV3TaRrjxk8McCC+AvGZPZQJzljmao/FldVTT+yXfXzeDuxD14dSbq 2IYQ== 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=ePekGJ8XieE9NixEVRESpLaa1JhvD/weUEjagHex2MA=; b=ngMA/NpCpYkBo1pVX0FDrswpMO9EBX9Gq9XlewLRFQZ1CCG+yYQo/iK+pEbJEZn4ok YhNiwagIn3lZcMnfyf7kaI7c8mqnuvDiSJO3SrMaAR962T6/KOl3ZngsRyyXjhznKRrl hIyVGN7VfpPF3dTbrzgY0q7mX/AuUjv3uBMD44pNl85hmXNDIsbEUBGolBtFD0CvaoWf mokeipXevEXnIN3G4A/ysgF3GcscZPhtPanoHrMFrQHnJ/yI52Y7bjY2+co/vp2Jpvri Lq5Yo5MaC6PhtZArYnUOYMpcGAOOfUxrBMNmTc9Z5jq+kxcnST2nmPHt7ZLdrjuUe3kf mFDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20221208.gappssmtp.com header.s=20221208 header.b=stXeyAKF; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rm13-20020a17090b3ecd00b0025e8dc583cfsi7737267pjb.123.2023.06.19.02.41.59; Mon, 19 Jun 2023 02:42:14 -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=stXeyAKF; 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 S231500AbjFSJZ0 (ORCPT + 99 others); Mon, 19 Jun 2023 05:25:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231376AbjFSJY1 (ORCPT ); Mon, 19 Jun 2023 05:24:27 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 782EDB4 for ; Mon, 19 Jun 2023 02:24:25 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3f8d1eb535eso27296625e9.3 for ; Mon, 19 Jun 2023 02:24:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20221208.gappssmtp.com; s=20221208; t=1687166664; x=1689758664; 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=ePekGJ8XieE9NixEVRESpLaa1JhvD/weUEjagHex2MA=; b=stXeyAKFiBma9MHM5czXcrssZRC1jErp8AXW2Fa8I2556gbnr9ZR3eAm7LWOkt9U/J yDg1VDJ1jLiK1sHFJM7IN9YEToCipDXUUoeVD87J25vlIPosjONHyv7awdWlH0488U3g /okd2MFXSWmg+CD44rJvSFCylpjUoIzjCdWH5eXuyZm3yXnnN4Hmi7e+Bgoy8htaDRPl KMVq59xLm8pPOr1zcnH+S/WEssULK3T1SoJfubLXdxqJrjhhffoJi2NiVJYpJCYZXQul GpinTFwqcwT/89/3sdLeJQOkzTVNFdZ859QRai9ckSu9WQoJQyIX75eP5pqcTZ3UAaZV 3sYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687166664; x=1689758664; 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=ePekGJ8XieE9NixEVRESpLaa1JhvD/weUEjagHex2MA=; b=ZTUi7okbylpC0pyIQvjJ/oqoX2BfyjsBa9VNAHpGMjbQrjmsINsp27LEpovLVk1beI jC5X8c8eTA9QwW36W34g0ZRXWz1Ma+L4b3D9mDSHSIuN4E8YaCBc5dJdFI1YlhjdaQsD r+NNqtSsr/Vetv7/nJU8qAfVu1Ue4rt+cOLNkonSfItrbr8yogWm2HneIchFlZWYB4iu euRLCz1+cklW7Om3Q4YJ60CrlWUNeQWPZ6muIT2PrzjVrk2hgt7HLm+u1qnxEHx1HMps caF7n3dJUp35B9wBd/XZW7t+3fDzVmzyEqjkSNx2y7JHGLPDm2fee4Iiank1fb+qd27I VOww== X-Gm-Message-State: AC+VfDw3xeQ247z9nE0vkbDD2gOk7bxieIMUZvMG8ynWeNp0CGiyHYWj pxtq+nAu+dFsFjSNq2R1VBmLDQ== X-Received: by 2002:a7b:c014:0:b0:3f8:f1db:d206 with SMTP id c20-20020a7bc014000000b003f8f1dbd206mr6380789wmb.25.1687166664061; Mon, 19 Jun 2023 02:24:24 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:d9e8:ddbf:7391:a0b0]) by smtp.gmail.com with ESMTPSA id q9-20020a7bce89000000b003f7cb42fa20sm10045229wmj.42.2023.06.19.02.24.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 02:24:23 -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 , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Andrew Halaney Cc: netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Bartosz Golaszewski Subject: [RESEND PATCH v2 10/14] net: stmmac: dwmac-qcom-ethqos: prepare the driver for more PHY modes Date: Mon, 19 Jun 2023 11:23:58 +0200 Message-Id: <20230619092402.195578-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230619092402.195578-1-brgl@bgdev.pl> References: <20230619092402.195578-1-brgl@bgdev.pl> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769123594889710951?= X-GMAIL-MSGID: =?utf-8?q?1769123594889710951?= 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 Reviewed-by: Andrew Halaney --- .../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 a739e1d5c046..0ececc951528 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -92,11 +92,13 @@ 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 link_clk_rate; struct clk *link_clk; struct phy *serdes_phy; unsigned int speed; + int phy_mode; const struct ethqos_emac_por *por; unsigned int num_por; @@ -331,13 +333,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; @@ -483,7 +483,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; @@ -559,6 +559,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; @@ -650,6 +655,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)) {