Skip to content

Commit 38389aa

Browse files
grygoriySdavem330
authored andcommitted
net: ethernet: ti: am65-cpsw-nuss: enable am65x sr2.0 support
The AM65x SR2.0 MCU CPSW has fixed errata i2027 "CPSW: CPSW Does Not Support CPPI Receive Checksum (Host to Ethernet) Offload Feature". This errata also fixed for J271E SoC. Use SOC bus data for K3 SoC identification and apply i2027 errata w/a only for the AM65x SR1.0 SoC. Signed-off-by: Grygorii Strashko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3d0fda9 commit 38389aa

File tree

2 files changed

+41
-8
lines changed

2 files changed

+41
-8
lines changed

drivers/net/ethernet/ti/am65-cpsw-nuss.c

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/pm_runtime.h>
2424
#include <linux/regmap.h>
2525
#include <linux/mfd/syscon.h>
26+
#include <linux/sys_soc.h>
2627
#include <linux/dma/ti-cppi5.h>
2728
#include <linux/dma/k3-udma-glue.h>
2829

@@ -148,10 +149,11 @@ static void am65_cpsw_nuss_get_ver(struct am65_cpsw_common *common)
148149
common->nuss_ver = readl(common->ss_base);
149150
common->cpsw_ver = readl(common->cpsw_base);
150151
dev_info(common->dev,
151-
"initializing am65 cpsw nuss version 0x%08X, cpsw version 0x%08X Ports: %u\n",
152+
"initializing am65 cpsw nuss version 0x%08X, cpsw version 0x%08X Ports: %u quirks:%08x\n",
152153
common->nuss_ver,
153154
common->cpsw_ver,
154-
common->port_num + 1);
155+
common->port_num + 1,
156+
common->pdata.quirks);
155157
}
156158

157159
void am65_cpsw_nuss_adjust_link(struct net_device *ndev)
@@ -1877,7 +1879,7 @@ static int am65_cpsw_nuss_init_ndev_2g(struct am65_cpsw_common *common)
18771879
port->ndev->ethtool_ops = &am65_cpsw_ethtool_ops_slave;
18781880

18791881
/* Disable TX checksum offload by default due to HW bug */
1880-
if (common->pdata->quirks & AM65_CPSW_QUIRK_I2027_NO_TX_CSUM)
1882+
if (common->pdata.quirks & AM65_CPSW_QUIRK_I2027_NO_TX_CSUM)
18811883
port->ndev->features &= ~NETIF_F_HW_CSUM;
18821884

18831885
ndev_priv->stats = netdev_alloc_pcpu_stats(struct am65_cpsw_ndev_stats);
@@ -1981,21 +1983,50 @@ static void am65_cpsw_nuss_cleanup_ndev(struct am65_cpsw_common *common)
19811983
}
19821984
}
19831985

1986+
struct am65_cpsw_soc_pdata {
1987+
u32 quirks_dis;
1988+
};
1989+
1990+
static const struct am65_cpsw_soc_pdata am65x_soc_sr2_0 = {
1991+
.quirks_dis = AM65_CPSW_QUIRK_I2027_NO_TX_CSUM,
1992+
};
1993+
1994+
static const struct soc_device_attribute am65_cpsw_socinfo[] = {
1995+
{ .family = "AM65X",
1996+
.revision = "SR2.0",
1997+
.data = &am65x_soc_sr2_0
1998+
},
1999+
{/* sentinel */}
2000+
};
2001+
19842002
static const struct am65_cpsw_pdata am65x_sr1_0 = {
19852003
.quirks = AM65_CPSW_QUIRK_I2027_NO_TX_CSUM,
19862004
};
19872005

1988-
static const struct am65_cpsw_pdata j721e_sr1_0 = {
2006+
static const struct am65_cpsw_pdata j721e_pdata = {
19892007
.quirks = 0,
19902008
};
19912009

19922010
static const struct of_device_id am65_cpsw_nuss_of_mtable[] = {
1993-
{ .compatible = "ti,am654-cpsw-nuss", .data = &am65x_sr1_0 },
1994-
{ .compatible = "ti,j721e-cpsw-nuss", .data = &j721e_sr1_0 },
2011+
{ .compatible = "ti,am654-cpsw-nuss", .data = &am65x_sr1_0},
2012+
{ .compatible = "ti,j721e-cpsw-nuss", .data = &j721e_pdata},
19952013
{ /* sentinel */ },
19962014
};
19972015
MODULE_DEVICE_TABLE(of, am65_cpsw_nuss_of_mtable);
19982016

2017+
static void am65_cpsw_nuss_apply_socinfo(struct am65_cpsw_common *common)
2018+
{
2019+
const struct soc_device_attribute *soc;
2020+
2021+
soc = soc_device_match(am65_cpsw_socinfo);
2022+
if (soc && soc->data) {
2023+
const struct am65_cpsw_soc_pdata *socdata = soc->data;
2024+
2025+
/* disable quirks */
2026+
common->pdata.quirks &= ~socdata->quirks_dis;
2027+
}
2028+
}
2029+
19992030
static int am65_cpsw_nuss_probe(struct platform_device *pdev)
20002031
{
20012032
struct cpsw_ale_params ale_params = { 0 };
@@ -2014,7 +2045,9 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
20142045
of_id = of_match_device(am65_cpsw_nuss_of_mtable, dev);
20152046
if (!of_id)
20162047
return -EINVAL;
2017-
common->pdata = of_id->data;
2048+
common->pdata = *(const struct am65_cpsw_pdata *)of_id->data;
2049+
2050+
am65_cpsw_nuss_apply_socinfo(common);
20182051

20192052
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cpsw_nuss");
20202053
common->ss_base = devm_ioremap_resource(&pdev->dev, res);

drivers/net/ethernet/ti/am65-cpsw-nuss.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct am65_cpsw_pdata {
8282
struct am65_cpsw_common {
8383
struct device *dev;
8484
struct device *mdio_dev;
85-
const struct am65_cpsw_pdata *pdata;
85+
struct am65_cpsw_pdata pdata;
8686

8787
void __iomem *ss_base;
8888
void __iomem *cpsw_base;

0 commit comments

Comments
 (0)