From patchwork Wed Jan 26 10:14:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 12724890 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A460FC28CF5 for ; Wed, 26 Jan 2022 10:14:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239724AbiAZKOw (ORCPT ); Wed, 26 Jan 2022 05:14:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232102AbiAZKOv (ORCPT ); Wed, 26 Jan 2022 05:14:51 -0500 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 AAE3DC06161C for ; Wed, 26 Jan 2022 02:14:50 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id o12so18640641lfg.12 for ; Wed, 26 Jan 2022 02:14:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=oT7VXAYr1RlKcC98jWVV1AYCja1UpLRPiR4q3wejxVA=; b=NvRuai8lXax1U7sBNU4VPS/k14T3EaNJRElshLx90nevrt12JEU4w7LNjtgaGeHU/U 7If6Ltrt2sE4Umo+ltVazzcWnstLrrUR6Qk3X0glvqP9W3nJdDvZUjD6H1FBM/bHh+CR 0tGbiigcM7H9yKqJFxQlapVNQgiL9RBGzcW69ZoHx0EHAIFZxvJfbb1t1wFEz38pm6JI qRLKHLYs0Nt3xKcs27kEXlm1bJeWeM5ZVj4bIveXRIIkLnpQjaGTa/cL489ujko/V8gi ANQmeKzNzp31vXxfxzcssYFcSsFaXiht+4wIBAZde9Yqovz5jF6A1lPFYfP8tVpv3MzU fQJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=oT7VXAYr1RlKcC98jWVV1AYCja1UpLRPiR4q3wejxVA=; b=XqNlcuphygvOBIjgKO8j7tPB+JuuCn9bchaHWK0gf5YyIPR48x1Q0s541NTJNNIguR gkm/sqyH3Ru9CfJn6KuR4H9M6AG3QAGf1XYCiW02pSVa+1u4/X2ywrnozGxx0X1goM+U SrX5r8cll3A0TfF3SqGSecZ4DH5hzZIYq13vnVO5i4SE2csfp4AfGxYl7Mx7Q6ivErzl HsuzX9CbkZc/Lyi3KV2LeZZAidat5aqq2NedL0va0Gg1hQ4Wer/RteU4VkmJXjCNSfCd yzUBv0JnEq/jEEX4N4Z2pqqF65Hjg8ruSYhzhjzkH1qohJXhboVQ1LgEiXvtHiQv0qM3 mh8A== X-Gm-Message-State: AOAM532vRryduBJHGtDS5Kj9fQ66fisMJvnBrNjcModwiMAlYtzYlg7x 6RsKLHLY0xNEAyIL7X0fFRyzag== X-Google-Smtp-Source: ABdhPJyfKp3pZx4gkqPihioKFMszACC2nq5auF0qwUCkwVvR4ZEvusm7VaGL+LurbX6E5VROm45fjw== X-Received: by 2002:ac2:596a:: with SMTP id h10mr14507077lfp.528.1643192089053; Wed, 26 Jan 2022 02:14:49 -0800 (PST) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id h13sm1351906lfv.100.2022.01.26.02.14.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jan 2022 02:14:48 -0800 (PST) From: Tobias Waldekranz To: davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, Madalin Bucur , Rob Herring , Shaohui Xie , Scott Wood , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/5] dt-bindings: net: xgmac_mdio: Remove unsupported "bus-frequency" Date: Wed, 26 Jan 2022 11:14:28 +0100 Message-Id: <20220126101432.822818-2-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220126101432.822818-1-tobias@waldekranz.com> References: <20220126101432.822818-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This property has never been supported by the driver. The kernel has settled on "clock-frequency" as the standard name for this binding, so once that is supported we will document that instead. Fixes: 7f93c9d90f4d ("power/fsl: add MDIO dt binding for FMan") Signed-off-by: Tobias Waldekranz Reviewed-by: Andrew Lunn --- Documentation/devicetree/bindings/net/fsl-fman.txt | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Documentation/devicetree/bindings/net/fsl-fman.txt b/Documentation/devicetree/bindings/net/fsl-fman.txt index 020337f3c05f..cd5288fb4318 100644 --- a/Documentation/devicetree/bindings/net/fsl-fman.txt +++ b/Documentation/devicetree/bindings/net/fsl-fman.txt @@ -388,15 +388,6 @@ PROPERTIES Value type: Definition: A standard property. -- bus-frequency - Usage: optional - Value type: - Definition: Specifies the external MDIO bus clock speed to - be used, if different from the standard 2.5 MHz. - This may be due to the standard speed being unsupported (e.g. - due to a hardware problem), or to advertise that all relevant - components in the system support a faster speed. - - interrupts Usage: required for external MDIO Value type: From patchwork Wed Jan 26 10:14:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 12724891 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 208C1C63682 for ; Wed, 26 Jan 2022 10:14:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239742AbiAZKOy (ORCPT ); Wed, 26 Jan 2022 05:14:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239732AbiAZKOw (ORCPT ); Wed, 26 Jan 2022 05:14:52 -0500 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EAAAC061744 for ; Wed, 26 Jan 2022 02:14:52 -0800 (PST) Received: by mail-lf1-x133.google.com with SMTP id p27so62125004lfa.1 for ; Wed, 26 Jan 2022 02:14:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=/mvM51A5cZB1/LP8bxdtukBhEKxdmFmIE0WYJdIBCJA=; b=mvIP15AWvQg1ZCiSg0C3i/x1fq4RgGtsbSqHGugR8AvKBMBhnyQpIvYdTa0Q1lSPf9 4rI0oX+gyII5WDvROn/rYgWLGUEkOOeVq+2PN9wQ1m3SQWOXPkYqFU1VTMstSvYYveCj H2yYU0GNO/jwjQRZg5P9ux025ZhnUCBYVTIsdRWKVdc+j9dwPfsIGx/Y6ClttcDRVsMu ShkjLCwfwlDESlOcUrMr4QmsUFqYcJCRJcD1UbnXBwrD5KYNfZup3CxAEgEZ+u375Mjl gtS1T6Bfu43yUZAXYZ+jVMxGjPIJOIvURAGvzRg4KfqzK76meuahOnSz7vUWritSnzDd yp3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=/mvM51A5cZB1/LP8bxdtukBhEKxdmFmIE0WYJdIBCJA=; b=l9fO+TvYV72xMT+FW62vHHbiGI/+ofw61/hN8S1n256JmGG6pONj47GyqWb5j1e+1B TEJ0R5JmsATnxiVyuHcNETtAw3jXeyXCKpKIutCQ9Tcd0dE64umTIo8Ord3fHSp+6lXX hWi9ZZUR0N+T8TWbMc56VIjk9SEZt4WOmrITTuXwz5AfHDIsPbPHEv7rSRu/dIDi8UTR biEfaYK+m0Ewl7y09rkHDQnHsIqH8Ir4J/1564NF5cIWEChlrGNtn9cPKhgMSrJs+lMY pzgyCPY/2HPQs2Uwghx6sOWWVs2qXCqyCShLMm8Q4stNB/q4rMrRWsnkR3V3ujetutxI 606g== X-Gm-Message-State: AOAM532ivnfEPnO9qMq+6QLMoMLhYK4UwPeayvNOcUQ2CrB5M2/lUPiO Zhe4BBQb00dmllBgcaeRz9lCbA== X-Google-Smtp-Source: ABdhPJyvELxIdfcM95tWre+Zw7gqfURABlf0U53dRmWPEok32iFeh0sYdUrHcb/83tLAAdRaV6JSXw== X-Received: by 2002:a05:6512:3406:: with SMTP id i6mr19581169lfr.637.1643192090820; Wed, 26 Jan 2022 02:14:50 -0800 (PST) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id h13sm1351906lfv.100.2022.01.26.02.14.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jan 2022 02:14:50 -0800 (PST) From: Tobias Waldekranz To: davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, Andrew Lunn , Marcin Wojtas , Calvin Johnson , Markus Koch , linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/5] net/fsl: xgmac_mdio: Use managed device resources Date: Wed, 26 Jan 2022 11:14:29 +0100 Message-Id: <20220126101432.822818-3-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220126101432.822818-1-tobias@waldekranz.com> References: <20220126101432.822818-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org All of the resources used by this driver has managed interfaces, so use them. Heed the warning in the comment before platform_get_resource and use a bare devm_ioremap to allow for non-exclusive access to the IO memory. Signed-off-by: Tobias Waldekranz Reviewed-by: Andrew Lunn --- drivers/net/ethernet/freescale/xgmac_mdio.c | 35 ++++----------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c index 266e562bd67a..40442d64a247 100644 --- a/drivers/net/ethernet/freescale/xgmac_mdio.c +++ b/drivers/net/ethernet/freescale/xgmac_mdio.c @@ -273,7 +273,7 @@ static int xgmac_mdio_probe(struct platform_device *pdev) return -EINVAL; } - bus = mdiobus_alloc_size(sizeof(struct mdio_fsl_priv)); + bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(struct mdio_fsl_priv)); if (!bus) return -ENOMEM; @@ -284,13 +284,11 @@ static int xgmac_mdio_probe(struct platform_device *pdev) bus->probe_capabilities = MDIOBUS_C22_C45; snprintf(bus->id, MII_BUS_ID_SIZE, "%pa", &res->start); - /* Set the PHY base address */ priv = bus->priv; - priv->mdio_base = ioremap(res->start, resource_size(res)); - if (!priv->mdio_base) { - ret = -ENOMEM; - goto err_ioremap; - } + priv->mdio_base = devm_ioremap(&pdev->dev, res->start, + resource_size(res)); + if (IS_ERR(priv->mdio_base)) + return PTR_ERR(priv->mdio_base); /* For both ACPI and DT cases, endianness of MDIO controller * needs to be specified using "little-endian" property. @@ -312,31 +310,11 @@ static int xgmac_mdio_probe(struct platform_device *pdev) ret = -EINVAL; if (ret) { dev_err(&pdev->dev, "cannot register MDIO bus\n"); - goto err_registration; + return ret; } platform_set_drvdata(pdev, bus); - return 0; - -err_registration: - iounmap(priv->mdio_base); - -err_ioremap: - mdiobus_free(bus); - - return ret; -} - -static int xgmac_mdio_remove(struct platform_device *pdev) -{ - struct mii_bus *bus = platform_get_drvdata(pdev); - struct mdio_fsl_priv *priv = bus->priv; - - mdiobus_unregister(bus); - iounmap(priv->mdio_base); - mdiobus_free(bus); - return 0; } @@ -364,7 +342,6 @@ static struct platform_driver xgmac_mdio_driver = { .acpi_match_table = xgmac_acpi_match, }, .probe = xgmac_mdio_probe, - .remove = xgmac_mdio_remove, }; module_platform_driver(xgmac_mdio_driver); From patchwork Wed Jan 26 10:14:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 12724892 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36C5FC63686 for ; Wed, 26 Jan 2022 10:14:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239749AbiAZKO4 (ORCPT ); Wed, 26 Jan 2022 05:14:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239743AbiAZKOy (ORCPT ); Wed, 26 Jan 2022 05:14:54 -0500 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 38865C061747 for ; Wed, 26 Jan 2022 02:14:54 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id z19so25380593lfq.13 for ; Wed, 26 Jan 2022 02:14:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=qqxkmTuDL0v9WH77bm0OjP2Xt3xkG3hMYP9qpSlEMQo=; b=kWB3pDyb6GK7cB9NC0EGJqCO++IYq7Ux9l7gTi9HBrbqNcOXW374l/CfIfwBhdGMyO R7gb2yLbmQ/7/7TsX3Nvg5M0hStCx24nC3lUBoNhxi7hqAb7PxTX8y10YhDaXMlq6okp 49EATEyHJPhRJl9LrA2pCABm4pXyTyC8GCHnZ6W1WjCfE9qsXSAG8/629WB8wxEDMD4q c5UEHofas4N4Qic/PFWspRZITQljlIbh7kgyJACe2+9WSeud2hOCpNDqM6clctZK0HqE B3zr14qW2/HoqCfoxbKloJhuwDGkM55BT98n6TYMrH7WKdBS227SFKpR6yaZ7Hgo3S4H B9VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=qqxkmTuDL0v9WH77bm0OjP2Xt3xkG3hMYP9qpSlEMQo=; b=YtvwB4m1kAhrFA3BMc29NWuXMH/iMGLRuR/OK2ESsZPY5dEjwRZWBGInAtewOrh7BG Uv3DkwinGa+sO0HwzM7BaAEiEl4hbB9pIVXF2raaGa23uhYaSybrTl1O+zXen/OxdTOX vdPqXFHu6hLrVuj7eV9KGJcMZSfv0v0NbZNg1w3CK1rv8M+tDl8t/4MZu7zoC1E18uuQ S7bL4u+UuxXWAzk0VDX8oK+ZgM+QQhuSl2SrU0q0jlwxpDRzP4EyuqjGL3h1NCaYAR04 Q/lUeP+khM48UkHefhwOAHjOufWaeKiYBlB4Zl4+ogUePtAC8nOPeD9kuQdp76un+lyv SHBQ== X-Gm-Message-State: AOAM530d1W+sXNvFz53B8sJeaqmiLjSuHuN3p3yFmTXplki7+TZ/vibq 9bMS0oU/KjisHgCS1b3XkChf0g== X-Google-Smtp-Source: ABdhPJw1Sm+RU38Ee1daea/JwTDtshnGfEbZdRpC2dQ6WKLjwdjbEONVXnXgFxZI3rHD0jS0MNhz8A== X-Received: by 2002:a05:6512:1519:: with SMTP id bq25mr10006379lfb.326.1643192092592; Wed, 26 Jan 2022 02:14:52 -0800 (PST) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id h13sm1351906lfv.100.2022.01.26.02.14.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jan 2022 02:14:52 -0800 (PST) From: Tobias Waldekranz To: davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, Marcin Wojtas , Andrew Lunn , Markus Koch , Calvin Johnson , linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/5] net/fsl: xgmac_mdio: Support preamble suppression Date: Wed, 26 Jan 2022 11:14:30 +0100 Message-Id: <20220126101432.822818-4-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220126101432.822818-1-tobias@waldekranz.com> References: <20220126101432.822818-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Support the standard "suppress-preamble" attribute to disable preamble generation. Signed-off-by: Tobias Waldekranz Reviewed-by: Andrew Lunn --- drivers/net/ethernet/freescale/xgmac_mdio.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c index 40442d64a247..18bf2370d45a 100644 --- a/drivers/net/ethernet/freescale/xgmac_mdio.c +++ b/drivers/net/ethernet/freescale/xgmac_mdio.c @@ -39,6 +39,7 @@ struct tgec_mdio_controller { #define MDIO_STAT_CLKDIV(x) (((x>>1) & 0xff) << 8) #define MDIO_STAT_BSY BIT(0) #define MDIO_STAT_RD_ER BIT(1) +#define MDIO_STAT_PRE_DIS BIT(5) #define MDIO_CTL_DEV_ADDR(x) (x & 0x1f) #define MDIO_CTL_PORT_ADDR(x) ((x & 0x1f) << 5) #define MDIO_CTL_PRE_DIS BIT(10) @@ -254,6 +255,21 @@ static int xgmac_mdio_read(struct mii_bus *bus, int phy_id, int regnum) return ret; } +static void xgmac_mdio_set_suppress_preamble(struct mii_bus *bus) +{ + struct mdio_fsl_priv *priv = (struct mdio_fsl_priv *)bus->priv; + struct tgec_mdio_controller __iomem *regs = priv->mdio_base; + struct device *dev = bus->parent; + u32 mdio_stat; + + if (!device_property_read_bool(dev, "suppress-preamble")) + return; + + mdio_stat = xgmac_read32(®s->mdio_stat, priv->is_little_endian); + mdio_stat |= MDIO_STAT_PRE_DIS; + xgmac_write32(mdio_stat, ®s->mdio_stat, priv->is_little_endian); +} + static int xgmac_mdio_probe(struct platform_device *pdev) { struct fwnode_handle *fwnode; @@ -301,6 +317,8 @@ static int xgmac_mdio_probe(struct platform_device *pdev) priv->has_a011043 = device_property_read_bool(&pdev->dev, "fsl,erratum-a011043"); + xgmac_mdio_set_suppress_preamble(bus); + fwnode = pdev->dev.fwnode; if (is_of_node(fwnode)) ret = of_mdiobus_register(bus, to_of_node(fwnode)); From patchwork Wed Jan 26 10:14:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 12724893 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 103CFC2BA4C for ; Wed, 26 Jan 2022 10:15:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239758AbiAZKPC (ORCPT ); Wed, 26 Jan 2022 05:15:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239743AbiAZKO4 (ORCPT ); Wed, 26 Jan 2022 05:14:56 -0500 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A0D2C061744 for ; Wed, 26 Jan 2022 02:14:56 -0800 (PST) Received: by mail-lf1-x136.google.com with SMTP id z4so6894495lft.3 for ; Wed, 26 Jan 2022 02:14:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=USujqVpdZsW/z2MKg24tG7SlZmyGeevlaGFebRua/vY=; b=b7gK/BdRk280w03vgWCel/KJX7+Dvu/EYaj2bq+tscRGg0ofFIyo3nBt3p39xGT0B6 MPmLq5MbPYcOX1M9eOhokTTwsOrRntnqzo/RqnmRnYKWA7fuaATI08NoMVCtvdsWRV6h 3Mwc79weYJXRVoGUcgWx90Y1AEVCJAhXroAtSUFSfUKnWeKaNUMFgoYn5mL28bsde39K jS4LkINHWxYv5DhJa4mp82f/Qe/I0cmffe9k19aZWA2ZaKLGgfxnzKbM929Ts/vPScyC g1Squ0IGF1aLdZbT4RLdQJdUdGdrBfWLz6vahTx/lyFxDfwN3zk5LTbJXNs1Tq2foDyg XKUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=USujqVpdZsW/z2MKg24tG7SlZmyGeevlaGFebRua/vY=; b=GdpfJdJcSOOxl1Q0riyfUqk+iJF/4C1/doQUId/5Qm5b5YzSRSkKaMDyjVtRmrUu3p /2so6eKDDHimZ7Duiu2WTxBiUe/yRO7wHV6HY8bn3+3OgMdcWFaRhZUccFeCJVkG19r6 REDVOosqkRCmOutA43w8cwRgWgpU3nrW3C4pS616jTiRXbg0wcQ6L/R0w1hygprr7ErP gcL4c9E9JJVK9InEnTddJa2FJlMsOkvoGhbhJ4flZEfhrY+p+aEMRqcQmxcWmUBSqmH8 Ou/BOH5/5LLDFFZCMoVJbZCs8ZWODnALiV2JFrz7ZB36PQwOiFfUp7+2dccl83CsrGGz FOaA== X-Gm-Message-State: AOAM530CJqqxvtjuXaHtc8k6dUoLgvFv4iCdli7xKaGUvUksmdQEITUN h830xPp9kJwVa89lI1topAFFxw== X-Google-Smtp-Source: ABdhPJxAK4WzXolZalsQAmdWpvIAX6/9bQpBndcyHYEapRU5xriuKXtvrDvnZjU4j/ySkLHcOvgubw== X-Received: by 2002:a05:6512:2247:: with SMTP id i7mr9650934lfu.295.1643192094394; Wed, 26 Jan 2022 02:14:54 -0800 (PST) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id h13sm1351906lfv.100.2022.01.26.02.14.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jan 2022 02:14:53 -0800 (PST) From: Tobias Waldekranz To: davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, Marcin Wojtas , Andrew Lunn , Calvin Johnson , Markus Koch , linux-kernel@vger.kernel.org Subject: [PATCH net-next 4/5] net/fsl: xgmac_mdio: Support setting the MDC frequency Date: Wed, 26 Jan 2022 11:14:31 +0100 Message-Id: <20220126101432.822818-5-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220126101432.822818-1-tobias@waldekranz.com> References: <20220126101432.822818-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Support the standard "clock-frequency" attribute to set the generated MDC frequency. If not specified, the driver will leave the divisor bits untouched. Signed-off-by: Tobias Waldekranz --- drivers/net/ethernet/freescale/xgmac_mdio.c | 35 ++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c index 18bf2370d45a..2199f8f4ff68 100644 --- a/drivers/net/ethernet/freescale/xgmac_mdio.c +++ b/drivers/net/ethernet/freescale/xgmac_mdio.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -36,7 +37,7 @@ struct tgec_mdio_controller { } __packed; #define MDIO_STAT_ENC BIT(6) -#define MDIO_STAT_CLKDIV(x) (((x>>1) & 0xff) << 8) +#define MDIO_STAT_CLKDIV(x) (((x) & 0x1ff) << 7) #define MDIO_STAT_BSY BIT(0) #define MDIO_STAT_RD_ER BIT(1) #define MDIO_STAT_PRE_DIS BIT(5) @@ -51,6 +52,8 @@ struct tgec_mdio_controller { struct mdio_fsl_priv { struct tgec_mdio_controller __iomem *mdio_base; + struct clk *enet_clk; + u32 mdc_freq; bool is_little_endian; bool has_a009885; bool has_a011043; @@ -255,6 +258,34 @@ static int xgmac_mdio_read(struct mii_bus *bus, int phy_id, int regnum) return ret; } +static void xgmac_mdio_set_mdc_freq(struct mii_bus *bus) +{ + struct mdio_fsl_priv *priv = (struct mdio_fsl_priv *)bus->priv; + struct tgec_mdio_controller __iomem *regs = priv->mdio_base; + struct device *dev = bus->parent; + u32 mdio_stat, div; + + if (device_property_read_u32(dev, "clock-frequency", &priv->mdc_freq)) + return; + + priv->enet_clk = devm_clk_get(dev, NULL); + if (IS_ERR(priv->enet_clk)) { + dev_err(dev, "Input clock unknown, not changing MDC frequency"); + return; + } + + div = ((clk_get_rate(priv->enet_clk) / priv->mdc_freq) - 1) / 2; + if (div < 5 || div > 0x1ff) { + dev_err(dev, "Requested MDC frequecy is out of range, ignoring"); + return; + } + + mdio_stat = xgmac_read32(®s->mdio_stat, priv->is_little_endian); + mdio_stat &= ~MDIO_STAT_CLKDIV(0x1ff); + mdio_stat |= MDIO_STAT_CLKDIV(div); + xgmac_write32(mdio_stat, ®s->mdio_stat, priv->is_little_endian); +} + static void xgmac_mdio_set_suppress_preamble(struct mii_bus *bus) { struct mdio_fsl_priv *priv = (struct mdio_fsl_priv *)bus->priv; @@ -319,6 +350,8 @@ static int xgmac_mdio_probe(struct platform_device *pdev) xgmac_mdio_set_suppress_preamble(bus); + xgmac_mdio_set_mdc_freq(bus); + fwnode = pdev->dev.fwnode; if (is_of_node(fwnode)) ret = of_mdiobus_register(bus, to_of_node(fwnode)); From patchwork Wed Jan 26 10:14:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 12724894 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46456C63682 for ; Wed, 26 Jan 2022 10:15:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239766AbiAZKPD (ORCPT ); Wed, 26 Jan 2022 05:15:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239768AbiAZKO5 (ORCPT ); Wed, 26 Jan 2022 05:14:57 -0500 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EF3FC061749 for ; Wed, 26 Jan 2022 02:14:57 -0800 (PST) Received: by mail-lj1-x22f.google.com with SMTP id b14so13917311ljb.0 for ; Wed, 26 Jan 2022 02:14:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=yYyA7Dvhv5JH05dt+/m//IIi7iqHJvsuMpECJGKlvh4=; b=ilxqhKe48DT0NtXyXNY+cwIN9bMKeCydVgQ28UFvs4WAPnILVev774zeZ453kQKnQr U6qarLtWu3Hp311kAdhqG000rePikNFW3iXtbXPS3culI+90BrtYfSZbkn+zw6dA1Ik6 FKRm5ntMIhmw2JZ1qnHJGh+KpQfTNPQ7B3QS+CLf6/uH4asCKMntcZIgDnObRYySOqaN pcnTTgqTkvTOiRYORuB7fBsbqBEa8sxC2CrIbbw26lZqNzxEyPN8FqlfW0epXJPoHLzH zBIt0MG8FuCM4t0WrMj8hgeDcbDVQZLDe7RqBx2TUfocu0usIgfUuTXcxZbG4BALBI1n dAIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=yYyA7Dvhv5JH05dt+/m//IIi7iqHJvsuMpECJGKlvh4=; b=zIfZWgAokhlAkdi2kUpr/PTcOO5mA5w3+zb+1GEG/obiB4VSg9WDj+em+5wNqog75o XYulzLt1ik9GLFLbD613Bid+YNtfdP5CTAli/ZQDsqkWbcys3uV2gF5K6FU3MBAQhZAz F+ux+fOqq5UtTcnKJLhRqt7tUDUe7acka1mAfCV51mTIWoQp1GcM8GF1aTAJVT8cSfKm a0S4ILNBKaQBRKgGnp8Jb4hEZ8tZPGki91FmMh+p9L5IOFGb8xxCHk+7Cz8niTVrvq77 iDlA7LeHWmZhij8Og23PLf6aZ/LR6AB48WirS1WmDd2XUbRU7qwwDEn8X7rKXh0LTauI o9Vg== X-Gm-Message-State: AOAM532rXZsp1/huMhGED17uRZ23qTnegKXW9EFtZprkp/DO5IuVd60r +kal1wCNb+vGMflyKQV/Lomy5zwKXi3QLg== X-Google-Smtp-Source: ABdhPJzgbNmJSZlbIDHCg+cktCi1VJ/8rcgjfp4OaMvn8WwhJ5KejctOC6lXhpjNgE3oISrMv4IIjg== X-Received: by 2002:a2e:9609:: with SMTP id v9mr17890283ljh.306.1643192095350; Wed, 26 Jan 2022 02:14:55 -0800 (PST) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id h13sm1351906lfv.100.2022.01.26.02.14.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jan 2022 02:14:54 -0800 (PST) From: Tobias Waldekranz To: davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, Madalin Bucur , Rob Herring , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 5/5] dt-bindings: net: xgmac_mdio: Add "clock-frequency" and "suppress-preamble" Date: Wed, 26 Jan 2022 11:14:32 +0100 Message-Id: <20220126101432.822818-6-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220126101432.822818-1-tobias@waldekranz.com> References: <20220126101432.822818-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The driver now supports the standard "clock-frequency" and "suppress-preamble" properties, do document them in the binding description. Signed-off-by: Tobias Waldekranz Reviewed-by: Andrew Lunn --- .../devicetree/bindings/net/fsl-fman.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Documentation/devicetree/bindings/net/fsl-fman.txt b/Documentation/devicetree/bindings/net/fsl-fman.txt index cd5288fb4318..801efc7d6818 100644 --- a/Documentation/devicetree/bindings/net/fsl-fman.txt +++ b/Documentation/devicetree/bindings/net/fsl-fman.txt @@ -388,6 +388,25 @@ PROPERTIES Value type: Definition: A standard property. +- clocks + Usage: optional + Value type: + Definition: A reference to the input clock of the controller + from which the MDC frequency is derived. + +- clock-frequency + Usage: optional + Value type: + Definition: Specifies the external MDC frequency, in Hertz, to + be used. Requires that the input clock is specified in the + "clocks" property. See also: mdio.yaml. + +- suppress-preamble + Usage: optional + Value type: + Definition: Disable generation of preamble bits. See also: + mdio.yaml. + - interrupts Usage: required for external MDIO Value type: