Skip to content

Commit 4ea17f5

Browse files
LorenzoBianconigregkh
authored andcommitted
net: airoha: Add airoha_eth_soc_data struct
[ Upstream commit 5863b4e ] Introduce airoha_eth_soc_data struct to contain differences between various SoC. Move XSI reset names in airoha_eth_soc_data. This is a preliminary patch to enable AN7583 ethernet controller support in airoha-eth driver. Co-developed-by: Christian Marangi <ansuelsmth@gmail.com> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Link: https://patch.msgid.link/20251017-an7583-eth-support-v3-4-f28319666667@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com> Stable-dep-of: 02f7296 ("net: airoha: Fix FE_PSE_BUF_SET configuration if PPE2 is available") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ae1b40d commit 4ea17f5

2 files changed

Lines changed: 48 additions & 11 deletions

File tree

drivers/net/ethernet/airoha/airoha_eth.c

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,8 +1406,7 @@ static int airoha_hw_init(struct platform_device *pdev,
14061406
int err, i;
14071407

14081408
/* disable xsi */
1409-
err = reset_control_bulk_assert(ARRAY_SIZE(eth->xsi_rsts),
1410-
eth->xsi_rsts);
1409+
err = reset_control_bulk_assert(eth->soc->num_xsi_rsts, eth->xsi_rsts);
14111410
if (err)
14121411
return err;
14131412

@@ -2943,6 +2942,7 @@ static int airoha_register_gdm_devices(struct airoha_eth *eth)
29432942

29442943
static int airoha_probe(struct platform_device *pdev)
29452944
{
2945+
struct reset_control_bulk_data *xsi_rsts;
29462946
struct device_node *np;
29472947
struct airoha_eth *eth;
29482948
int i, err;
@@ -2951,6 +2951,10 @@ static int airoha_probe(struct platform_device *pdev)
29512951
if (!eth)
29522952
return -ENOMEM;
29532953

2954+
eth->soc = of_device_get_match_data(&pdev->dev);
2955+
if (!eth->soc)
2956+
return -EINVAL;
2957+
29542958
eth->dev = &pdev->dev;
29552959

29562960
err = dma_set_mask_and_coherent(eth->dev, DMA_BIT_MASK(32));
@@ -2975,13 +2979,18 @@ static int airoha_probe(struct platform_device *pdev)
29752979
return err;
29762980
}
29772981

2978-
eth->xsi_rsts[0].id = "xsi-mac";
2979-
eth->xsi_rsts[1].id = "hsi0-mac";
2980-
eth->xsi_rsts[2].id = "hsi1-mac";
2981-
eth->xsi_rsts[3].id = "hsi-mac";
2982-
eth->xsi_rsts[4].id = "xfp-mac";
2982+
xsi_rsts = devm_kzalloc(eth->dev,
2983+
eth->soc->num_xsi_rsts * sizeof(*xsi_rsts),
2984+
GFP_KERNEL);
2985+
if (err)
2986+
return err;
2987+
2988+
eth->xsi_rsts = xsi_rsts;
2989+
for (i = 0; i < eth->soc->num_xsi_rsts; i++)
2990+
eth->xsi_rsts[i].id = eth->soc->xsi_rsts_names[i];
2991+
29832992
err = devm_reset_control_bulk_get_exclusive(eth->dev,
2984-
ARRAY_SIZE(eth->xsi_rsts),
2993+
eth->soc->num_xsi_rsts,
29852994
eth->xsi_rsts);
29862995
if (err) {
29872996
dev_err(eth->dev, "failed to get bulk xsi reset lines\n");
@@ -3074,8 +3083,23 @@ static void airoha_remove(struct platform_device *pdev)
30743083
platform_set_drvdata(pdev, NULL);
30753084
}
30763085

3086+
static const char * const en7581_xsi_rsts_names[] = {
3087+
"xsi-mac",
3088+
"hsi0-mac",
3089+
"hsi1-mac",
3090+
"hsi-mac",
3091+
"xfp-mac",
3092+
};
3093+
3094+
static const struct airoha_eth_soc_data en7581_soc_data = {
3095+
.version = 0x7581,
3096+
.xsi_rsts_names = en7581_xsi_rsts_names,
3097+
.num_xsi_rsts = ARRAY_SIZE(en7581_xsi_rsts_names),
3098+
.num_ppe = 2,
3099+
};
3100+
30773101
static const struct of_device_id of_airoha_match[] = {
3078-
{ .compatible = "airoha,en7581-eth" },
3102+
{ .compatible = "airoha,en7581-eth", .data = &en7581_soc_data },
30793103
{ /* sentinel */ }
30803104
};
30813105
MODULE_DEVICE_TABLE(of, of_airoha_match);

drivers/net/ethernet/airoha/airoha_eth.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#define AIROHA_MAX_NUM_IRQ_BANKS 4
2222
#define AIROHA_MAX_DSA_PORTS 7
2323
#define AIROHA_MAX_NUM_RSTS 3
24-
#define AIROHA_MAX_NUM_XSI_RSTS 5
2524
#define AIROHA_MAX_MTU 9216
2625
#define AIROHA_MAX_PACKET_SIZE 2048
2726
#define AIROHA_NUM_QOS_CHANNELS 4
@@ -556,9 +555,18 @@ struct airoha_ppe {
556555
struct dentry *debugfs_dir;
557556
};
558557

558+
struct airoha_eth_soc_data {
559+
u16 version;
560+
const char * const *xsi_rsts_names;
561+
int num_xsi_rsts;
562+
int num_ppe;
563+
};
564+
559565
struct airoha_eth {
560566
struct device *dev;
561567

568+
const struct airoha_eth_soc_data *soc;
569+
562570
unsigned long state;
563571
void __iomem *fe_regs;
564572

@@ -568,7 +576,7 @@ struct airoha_eth {
568576
struct rhashtable flow_table;
569577

570578
struct reset_control_bulk_data rsts[AIROHA_MAX_NUM_RSTS];
571-
struct reset_control_bulk_data xsi_rsts[AIROHA_MAX_NUM_XSI_RSTS];
579+
struct reset_control_bulk_data *xsi_rsts;
572580

573581
struct net_device *napi_dev;
574582

@@ -611,6 +619,11 @@ static inline bool airhoa_is_lan_gdm_port(struct airoha_gdm_port *port)
611619
return port->id == 1;
612620
}
613621

622+
static inline bool airoha_is_7581(struct airoha_eth *eth)
623+
{
624+
return eth->soc->version == 0x7581;
625+
}
626+
614627
bool airoha_is_valid_gdm_port(struct airoha_eth *eth,
615628
struct airoha_gdm_port *port);
616629

0 commit comments

Comments
 (0)