1 From 5af2b2dc4d6ba0ff7696e79f18e5b2bf862194eb Mon Sep 17 00:00:00 2001
2 From: Lorenzo Bianconi <lorenzo@kernel.org>
3 Date: Tue, 7 Mar 2023 15:55:24 +0000
4 Subject: [PATCH 2/7] net: ethernet: mtk_eth_soc: move MAX_DEVS in mtk_soc_data
6 This is a preliminary patch to add MT7988 SoC support since it runs 3
9 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
10 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
12 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 34 +++++++++++++++++++--
13 drivers/net/ethernet/mediatek/mtk_eth_soc.h | 11 +++----
14 2 files changed, 36 insertions(+), 9 deletions(-)
16 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
17 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
18 @@ -3972,7 +3972,10 @@ static void mtk_sgmii_destroy(struct mtk
22 - for (i = 0; i < MTK_MAX_DEVS; i++)
23 + if (!eth->sgmii_pcs)
26 + for (i = 0; i < eth->soc->num_devs; i++)
27 mtk_pcs_lynxi_destroy(eth->sgmii_pcs[i]);
30 @@ -4425,7 +4428,12 @@ static int mtk_sgmii_init(struct mtk_eth
34 - for (i = 0; i < MTK_MAX_DEVS; i++) {
35 + eth->sgmii_pcs = devm_kzalloc(eth->dev,
36 + sizeof(*eth->sgmii_pcs) *
40 + for (i = 0; i < eth->soc->num_devs; i++) {
41 np = of_parse_phandle(eth->dev->of_node, "mediatek,sgmiisys", i);
44 @@ -4470,6 +4478,18 @@ static int mtk_probe(struct platform_dev
45 if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
46 eth->ip_align = NET_IP_ALIGN;
48 + eth->netdev = devm_kzalloc(eth->dev,
49 + sizeof(*eth->netdev) * eth->soc->num_devs,
54 + eth->mac = devm_kzalloc(eth->dev,
55 + sizeof(*eth->mac) * eth->soc->num_devs,
60 spin_lock_init(ð->page_lock);
61 spin_lock_init(ð->tx_irq_lock);
62 spin_lock_init(ð->rx_irq_lock);
63 @@ -4655,7 +4675,7 @@ static int mtk_probe(struct platform_dev
67 - for (i = 0; i < MTK_MAX_DEVS; i++) {
68 + for (i = 0; i < eth->soc->num_devs; i++) {
72 @@ -4732,6 +4752,7 @@ static const struct mtk_soc_data mt2701_
73 .hw_features = MTK_HW_FEATURES,
74 .required_clks = MT7623_CLKS_BITMAP,
75 .required_pctl = true,
78 .txd_size = sizeof(struct mtk_tx_dma),
79 .rxd_size = sizeof(struct mtk_rx_dma),
80 @@ -4750,6 +4771,7 @@ static const struct mtk_soc_data mt7621_
81 .required_pctl = false,
85 .foe_entry_size = sizeof(struct mtk_foe_entry) - 16,
87 .txd_size = sizeof(struct mtk_tx_dma),
88 @@ -4771,6 +4793,7 @@ static const struct mtk_soc_data mt7622_
91 .has_accounting = true,
93 .foe_entry_size = sizeof(struct mtk_foe_entry) - 16,
95 .txd_size = sizeof(struct mtk_tx_dma),
96 @@ -4790,6 +4813,7 @@ static const struct mtk_soc_data mt7623_
97 .required_pctl = true,
101 .foe_entry_size = sizeof(struct mtk_foe_entry) - 16,
103 .txd_size = sizeof(struct mtk_tx_dma),
104 @@ -4809,6 +4833,7 @@ static const struct mtk_soc_data mt7629_
105 .required_clks = MT7629_CLKS_BITMAP,
106 .required_pctl = false,
107 .has_accounting = true,
110 .txd_size = sizeof(struct mtk_tx_dma),
111 .rxd_size = sizeof(struct mtk_rx_dma),
112 @@ -4830,6 +4855,7 @@ static const struct mtk_soc_data mt7981_
114 .foe_entry_size = sizeof(struct mtk_foe_entry),
115 .has_accounting = true,
118 .txd_size = sizeof(struct mtk_tx_dma_v2),
119 .rxd_size = sizeof(struct mtk_rx_dma_v2),
120 @@ -4849,6 +4875,7 @@ static const struct mtk_soc_data mt7986_
121 .required_pctl = false,
122 .offload_version = 2,
125 .foe_entry_size = sizeof(struct mtk_foe_entry),
126 .has_accounting = true,
128 @@ -4867,6 +4894,7 @@ static const struct mtk_soc_data rt5350_
129 .hw_features = MTK_HW_FEATURES_MT7628,
130 .required_clks = MT7628_CLKS_BITMAP,
131 .required_pctl = false,
134 .txd_size = sizeof(struct mtk_tx_dma),
135 .rxd_size = sizeof(struct mtk_rx_dma),
136 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
137 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
138 @@ -1018,6 +1018,7 @@ struct mtk_reg_map {
139 * @required_pctl A bool value to show whether the SoC requires
140 * the extra setup for those pins used by GMAC.
141 * @hash_offset Flow table hash offset.
142 + * @num_devs SoC number of macs.
143 * @foe_entry_size Foe table entry size.
144 * @has_accounting Bool indicating support for accounting of
146 @@ -1036,6 +1037,7 @@ struct mtk_soc_data {
152 netdev_features_t hw_features;
154 @@ -1051,9 +1053,6 @@ struct mtk_soc_data {
156 #define MTK_DMA_MONITOR_TIMEOUT msecs_to_jiffies(1000)
158 -/* currently no SoC has more than 2 macs */
159 -#define MTK_MAX_DEVS 2
161 /* struct mtk_eth - This is the main datasructure for holding the state
163 * @dev: The device pointer
164 @@ -1108,14 +1107,14 @@ struct mtk_eth {
165 spinlock_t tx_irq_lock;
166 spinlock_t rx_irq_lock;
167 struct net_device dummy_dev;
168 - struct net_device *netdev[MTK_MAX_DEVS];
169 - struct mtk_mac *mac[MTK_MAX_DEVS];
170 + struct net_device **netdev;
171 + struct mtk_mac **mac;
174 unsigned long sysclk;
175 struct regmap *ethsys;
176 struct regmap *infra;
177 - struct phylink_pcs *sgmii_pcs[MTK_MAX_DEVS];
178 + struct phylink_pcs **sgmii_pcs;
181 refcount_t dma_refcnt;