[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250128102558.22459-3-swathi.ks@samsung.com>
Date: Tue, 28 Jan 2025 15:55:56 +0530
From: Swathi K S <swathi.ks@...sung.com>
To: krzk@...nel.org, robh@...nel.org, davem@...emloft.net,
edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
conor+dt@...nel.org, richardcochran@...il.com, mcoquelin.stm32@...il.com,
andrew@...n.ch, alim.akhtar@...sung.com, linux-fsd@...la.com
Cc: netdev@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org, linux-samsung-soc@...r.kernel.org,
alexandre.torgue@...s.st.com, peppe.cavallaro@...com, joabreu@...opsys.com,
swathi.ks@...sung.com, rcsekar@...sung.com, ssiddha@...la.com,
jayati.sahu@...sung.com, pankaj.dubey@...sung.com, ravi.patel@...sung.com,
gost.dev@...sung.com
Subject: [PATCH v5 2/4] net: stmmac: dwc-qos: Add FSD EQoS support
The FSD SoC contains two instance of the Synopsys DWC ethernet QOS IP core.
The binding that it uses is slightly different from existing ones because
of the integration (clocks, resets).
Signed-off-by: Chandrasekar R <rcsekar@...sung.com>
Signed-off-by: Suresh Siddha <ssiddha@...la.com>
Signed-off-by: Swathi K S <swathi.ks@...sung.com>
---
.../stmicro/stmmac/dwmac-dwc-qos-eth.c | 74 +++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
index bd4eb187f8c6..81a7038bcdf4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
@@ -20,6 +20,7 @@
#include <linux/platform_device.h>
#include <linux/reset.h>
#include <linux/stmmac.h>
+#include <linux/regmap.h>
#include "stmmac_platform.h"
#include "dwmac4.h"
@@ -37,6 +38,12 @@ struct tegra_eqos {
struct gpio_desc *reset;
};
+struct fsd_eqos_plat_data {
+ struct clk_bulk_data *clks;
+ int num_clks;
+ struct device *dev;
+};
+
static int dwc_eth_dwmac_config_dt(struct platform_device *pdev,
struct plat_stmmacenet_data *plat_dat)
{
@@ -260,6 +267,67 @@ static int tegra_eqos_init(struct platform_device *pdev, void *priv)
return 0;
}
+static int fsd_clks_endisable(void *priv, bool enabled)
+{
+ struct fsd_eqos_plat_data *plat = priv;
+
+ if (enabled) {
+ return clk_bulk_prepare_enable(plat->num_clks, plat->clks);
+ } else {
+ clk_bulk_disable_unprepare(plat->num_clks, plat->clks);
+ return 0;
+ }
+}
+
+static int fsd_eqos_probe(struct platform_device *pdev,
+ struct plat_stmmacenet_data *data,
+ struct stmmac_resources *res)
+{
+ struct fsd_eqos_plat_data *priv_plat;
+ struct clk *rx1 = NULL;
+ struct clk *rx2 = NULL;
+ int ret = 0;
+
+ priv_plat = devm_kzalloc(&pdev->dev, sizeof(*priv_plat), GFP_KERNEL);
+ if (!priv_plat)
+ return -ENOMEM;
+
+ priv_plat->dev = &pdev->dev;
+
+ ret = devm_clk_bulk_get_all(&pdev->dev, &priv_plat->clks);
+ if (ret < 0)
+ return dev_err_probe(&pdev->dev, ret, "No clocks available\n");
+
+ priv_plat->num_clks = ret;
+
+ data->bsp_priv = priv_plat;
+ data->clks_config = fsd_clks_endisable;
+
+ for (int i = 0; i < priv_plat->num_clks; i++) {
+ if (strcmp(priv_plat->clks[i].id, "eqos_rxclk_mux") == 0)
+ rx1 = priv_plat->clks[i].clk;
+ else if (strcmp(priv_plat->clks[i].id, "eqos_phyrxclk") == 0)
+ rx2 = priv_plat->clks[i].clk;
+ }
+
+ /* Eth0 RX clock doesn't support MUX */
+ if (rx1)
+ clk_set_parent(rx1, rx2);
+
+ ret = fsd_clks_endisable(priv_plat, true);
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret, "Failed to enable FSD clock\n");
+
+ return 0;
+}
+
+static void fsd_eqos_remove(struct platform_device *pdev)
+{
+ struct fsd_eqos_plat_data *priv_plat = get_stmmac_bsp_priv(&pdev->dev);
+
+ fsd_clks_endisable(priv_plat, false);
+}
+
static int tegra_eqos_probe(struct platform_device *pdev,
struct plat_stmmacenet_data *data,
struct stmmac_resources *res)
@@ -406,6 +474,11 @@ static const struct dwc_eth_dwmac_data tegra_eqos_data = {
.remove = tegra_eqos_remove,
};
+static const struct dwc_eth_dwmac_data fsd_eqos_data = {
+ .probe = fsd_eqos_probe,
+ .remove = fsd_eqos_remove,
+};
+
static int dwc_eth_dwmac_probe(struct platform_device *pdev)
{
const struct dwc_eth_dwmac_data *data;
@@ -468,6 +541,7 @@ static void dwc_eth_dwmac_remove(struct platform_device *pdev)
static const struct of_device_id dwc_eth_dwmac_match[] = {
{ .compatible = "snps,dwc-qos-ethernet-4.10", .data = &dwc_qos_data },
{ .compatible = "nvidia,tegra186-eqos", .data = &tegra_eqos_data },
+ { .compatible = "tesla,fsd-ethqos", .data = &fsd_eqos_data },
{ }
};
MODULE_DEVICE_TABLE(of, dwc_eth_dwmac_match);
--
2.17.1
Powered by blists - more mailing lists