From patchwork Mon Jun 12 09:23:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 106385 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2466919vqr; Mon, 12 Jun 2023 02:50:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5MWXjJl92NM52TWFrZKVFJMCMl66/duJqfh/taLrSQtkFmzWUUyWgW2BgRE3hm1uZXODJZ X-Received: by 2002:a05:6a20:8f07:b0:10d:1213:432a with SMTP id b7-20020a056a208f0700b0010d1213432amr10630404pzk.33.1686563405051; Mon, 12 Jun 2023 02:50:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686563405; cv=none; d=google.com; s=arc-20160816; b=mZavByuB2kMTXgmXvHh9h+vc3ouQwyURaRTtoOdPkm8igOb8GHcP3JdPW9NQZDtmKz qd4SFPtHYp2AYJkTCZH69GO9sJKfiT3c8gnGtuuyD7EbdwADRrncbsQfGQ3eEp4vCjRa oSC/dc5BaHrH12FChsq7bklNr3X1tVYpcjsh7E85J4FnmLOpGKaFBa1ZFhz4OzYFN6bo RIQ4rq6Q+RpvornLKkIkXlIUMxqdJnJTwQiBe2T2krnB3/pWFyjXVw6EVCmhJl3lBsig LqEH2wUe1UYWofDp02I2DMkdTxWm8YiKN+U84ApYtA1qQLxcVnZYObkQeGAaqhiTC7v8 +3kw== 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=Gu6Hj8PYw+w5Smr4EMXMmc+WADcALPo6VlL++XAkFkQ=; b=ehEOGR6FVHi3VHFrLZ8sFJqXWbwrixq8y7qHzKHlnTAf087IkjF3JoBQH59Yh8ALN/ ZN/1hp0yo9680T1X3iWCeAYqyA9Smd9gpaiGGYtdj7Dfw8S4S+aRvZIqJEQmYEppSzYd suZ0/NvVy8K60IpMoq35QJhOQq92Bjh4vvoivZ49b/YxNQYXcrB5u79zWblmuRL+lZ7+ SwsPyvigR6GS5qhq9qSNOd+bFTLsEhGQgvmxtuU0ADythDftm6vfNGTSp15naYgjIhbk jyYwFlbQZ7E8RJyuAMS3ylmJ7ObzeHCWevLW8r89UitnMuL9bs4HZcf3gs3TBWzEDtIU MAsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20221208.gappssmtp.com header.s=20221208 header.b=KgztPCwz; 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 k16-20020aa79990000000b0064d62222c46si6644943pfh.121.2023.06.12.02.49.53; Mon, 12 Jun 2023 02:50:05 -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=KgztPCwz; 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 S235065AbjFLJcQ (ORCPT + 99 others); Mon, 12 Jun 2023 05:32:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234786AbjFLJac (ORCPT ); Mon, 12 Jun 2023 05:30:32 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D38B04EC5 for ; Mon, 12 Jun 2023 02:24:52 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-4f64fb05a8aso4792336e87.0 for ; Mon, 12 Jun 2023 02:24:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20221208.gappssmtp.com; s=20221208; t=1686561891; x=1689153891; 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=Gu6Hj8PYw+w5Smr4EMXMmc+WADcALPo6VlL++XAkFkQ=; b=KgztPCwzL7tQDDy797REtkk6bu9zfPBV1CItjq2k4V9QtMfVqe7RQDCXQ+XLPJ+Tnu as8pYDlZiiycSsvjx0FeTP5FWiqBhfePAPUFcTmRWIbqULZz4GzxMxSYa6wh8l/ZdnX8 19eJideh6H6lNdJyPVL8ku4IHc43sCPTWCXZwSYq9N9lKCdNc1tcn/DsRUUbRH4jkopC 4m3O+6XeduNEMSUdeIrKAAqOR2554WPPuGg8oI5fw2O+aNCrNLvyIgTVYq+T3am/k4Ak GtUlY9r08SUm7vHfrQ4KlyXcElHqGru24EzP2b4Dg5v4sIQkXWI9ZdASbzNYVUtZhgM6 Y07g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686561891; x=1689153891; 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=Gu6Hj8PYw+w5Smr4EMXMmc+WADcALPo6VlL++XAkFkQ=; b=QQuUDLE6nuRFk36J7txZ/esZ9JvwbxEkM9HujbkvSL4/TNBVizT+7ccB2aetnhHUcO CiPyCALy/rJ1TPyu1YID45BMBxU2v1fsWdzQRLQnT42dIbyui13l50Myj7fM8gxiqCGp 5ZDMC0bze567+ZY6ns1Z4EqHSCa7QOqW5CG+2bIK9mxtI7BNDg+BYXWKkpd+NN4UL+1N xWqR7GBWWZN/62erdy6L6vF0EccrhtCQjVVrcNpkQyRncE+ev7zyOfRhDPnM+yvXBa8I Fz1jClDgZ4KX6FsjGw5mBsWsB2V2EamuxNfmBCq3PxLWtE5FDw9DXYowxGSFr9lFe26S XRcw== X-Gm-Message-State: AC+VfDw11ebUr66DakQ4VrmaFl5mj3daJb6uE3IFrhYmnz6S+Q5MY8bn ZTEH6D/6BdB8wg0r1XoU36m2iA== X-Received: by 2002:ac2:5b11:0:b0:4f3:b32d:f739 with SMTP id v17-20020ac25b11000000b004f3b32df739mr4457643lfn.19.1686561891077; Mon, 12 Jun 2023 02:24:51 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 02:24:50 -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 17/26] net: stmmac: dwmac-qcom-ethqos: add support for SGMII Date: Mon, 12 Jun 2023 11:23:46 +0200 Message-Id: <20230612092355.87937-18-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 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?1768489909144369341?= X-GMAIL-MSGID: =?utf-8?q?1768489909144369341?= From: Bartosz Golaszewski On sa8775p the MAC is connected to the external PHY over SGMII so add support for it to the driver. Signed-off-by: Bartosz Golaszewski --- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index 2f96f2c11278..247e3888cca0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -76,6 +76,10 @@ #define RGMII_CONFIG2_DATA_DIVIDE_CLK_SEL BIT(6) #define RGMII_CONFIG2_TX_CLK_PHASE_SHIFT_EN BIT(5) +/* MAC_CTRL_REG bits */ +#define ETHQOS_MAC_CTRL_SPEED_MODE BIT(14) +#define ETHQOS_MAC_CTRL_PORT_SEL BIT(15) + struct ethqos_emac_por { unsigned int offset; unsigned int value; @@ -92,6 +96,7 @@ struct ethqos_emac_driver_data { struct qcom_ethqos { struct platform_device *pdev; void __iomem *rgmii_base; + void __iomem *mac_base; int (*configure_func)(struct qcom_ethqos *ethqos); unsigned int rgmii_clk_rate; @@ -561,6 +566,33 @@ static int ethqos_configure_rgmii(struct qcom_ethqos *ethqos) return 0; } +static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos) +{ + int val; + + val = readl(ethqos->mac_base + MAC_CTRL_REG); + + switch (ethqos->speed) { + case SPEED_1000: + val &= ~ETHQOS_MAC_CTRL_PORT_SEL; + rgmii_updatel(ethqos, RGMII_CONFIG2_RGMII_CLK_SEL_CFG, + RGMII_CONFIG2_RGMII_CLK_SEL_CFG, + RGMII_IO_MACRO_CONFIG2); + break; + case SPEED_100: + val |= ETHQOS_MAC_CTRL_PORT_SEL | ETHQOS_MAC_CTRL_SPEED_MODE; + break; + case SPEED_10: + val |= ETHQOS_MAC_CTRL_PORT_SEL; + val &= ~ETHQOS_MAC_CTRL_SPEED_MODE; + break; + } + + writel(val, ethqos->mac_base + MAC_CTRL_REG); + + return val; +} + static int ethqos_configure(struct qcom_ethqos *ethqos) { return ethqos->configure_func(ethqos); @@ -673,6 +705,9 @@ static int qcom_ethqos_probe(struct platform_device *pdev) case PHY_INTERFACE_MODE_RGMII_TXID: ethqos->configure_func = ethqos_configure_rgmii; break; + case PHY_INTERFACE_MODE_SGMII: + ethqos->configure_func = ethqos_configure_sgmii; + break; case -ENODEV: ret = -ENODEV; goto out_config_dt; @@ -688,6 +723,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev) goto out_config_dt; } + ethqos->mac_base = stmmac_res.addr; + data = of_device_get_match_data(dev); ethqos->por = data->por; ethqos->num_por = data->num_por;