Skip to content

Commit b96c7b4

Browse files
committed
Merge branch 'dsa-microchip-checking'
Rakesh Sankaranarayanan says: ==================== net: dsa: microchip: ksz_pwrite status check for lan937x and irq and error checking updates for ksz series This patch series include following changes, - Add KSZ9563 inside ksz_switch_chips. As per current structure, KSZ9893 is reused inside ksz_switch_chips structure, but since there is a mismatch in number of irq's, new member added for KSZ9563 and sku detected based on Global Chip ID 4 Register. Compatible string from device tree mapped to KSZ9563 for spi and i2c mode probes. - Assign device interrupt during i2c probe operation. - Add error checking for ksz_pwrite inside lan937x_change_mtu. After v6.0, ksz_pwrite updated to have return type int instead of void, and lan937x_change_mtu still uses ksz_pwrite without status verification. - Add port_nirq as 3 for KSZ8563 switch family. - Use dev_err_probe() instead of dev_err() to have more standardized error formatting and logging. v1 -> v2: - Removed regmap validation patch from the series, planning to take up in future after checking for any better approach and studying the actual need for this change. - Resolved error reported in ksz8863_smi.c file. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 380f9ac + 9b18331 commit b96c7b4

7 files changed

Lines changed: 56 additions & 21 deletions

File tree

drivers/net/dsa/microchip/ksz8863_smi.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,10 @@ static int ksz8863_smi_probe(struct mdio_device *mdiodev)
152152
&regmap_smi[i], dev,
153153
&rc);
154154
if (IS_ERR(dev->regmap[i])) {
155-
ret = PTR_ERR(dev->regmap[i]);
156-
dev_err(&mdiodev->dev,
157-
"Failed to initialize regmap%i: %d\n",
158-
ksz8863_regmap_config[i].val_bits, ret);
159-
return ret;
155+
return dev_err_probe(&mdiodev->dev,
156+
PTR_ERR(dev->regmap[i]),
157+
"Failed to initialize regmap%i\n",
158+
ksz8863_regmap_config[i].val_bits);
160159
}
161160
}
162161

drivers/net/dsa/microchip/ksz9477.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ int ksz9477_reset_switch(struct ksz_device *dev)
195195

196196
/* KSZ9893 compatible chips do not support refclk configuration */
197197
if (dev->chip_id == KSZ9893_CHIP_ID ||
198-
dev->chip_id == KSZ8563_CHIP_ID)
198+
dev->chip_id == KSZ8563_CHIP_ID ||
199+
dev->chip_id == KSZ9563_CHIP_ID)
199200
return 0;
200201

201202
data8 = SW_ENABLE_REFCLKO;

drivers/net/dsa/microchip/ksz9477_i2c.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ static int ksz9477_i2c_probe(struct i2c_client *i2c,
3030
rc.lock_arg = &dev->regmap_mutex;
3131
dev->regmap[i] = devm_regmap_init_i2c(i2c, &rc);
3232
if (IS_ERR(dev->regmap[i])) {
33-
ret = PTR_ERR(dev->regmap[i]);
34-
dev_err(&i2c->dev,
35-
"Failed to initialize regmap%i: %d\n",
36-
ksz9477_regmap_config[i].val_bits, ret);
37-
return ret;
33+
return dev_err_probe(&i2c->dev, PTR_ERR(dev->regmap[i]),
34+
"Failed to initialize regmap%i\n",
35+
ksz9477_regmap_config[i].val_bits);
3836
}
3937
}
4038

4139
if (i2c->dev.platform_data)
4240
dev->pdata = i2c->dev.platform_data;
4341

42+
dev->irq = i2c->irq;
43+
4444
ret = ksz_switch_register(dev);
4545

4646
/* Main DSA driver may not be started yet. */
@@ -101,7 +101,7 @@ static const struct of_device_id ksz9477_dt_ids[] = {
101101
},
102102
{
103103
.compatible = "microchip,ksz9563",
104-
.data = &ksz_switch_chips[KSZ9893]
104+
.data = &ksz_switch_chips[KSZ9563]
105105
},
106106
{
107107
.compatible = "microchip,ksz8563",

drivers/net/dsa/microchip/ksz_common.c

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
10391039
.num_statics = 16,
10401040
.cpu_ports = 0x07, /* can be configured as cpu port */
10411041
.port_cnt = 3, /* total port count */
1042+
.port_nirqs = 3,
10421043
.ops = &ksz9477_dev_ops,
10431044
.mib_names = ksz9477_mib_names,
10441045
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
@@ -1282,6 +1283,31 @@ const struct ksz_chip_data ksz_switch_chips[] = {
12821283
.gbit_capable = {true, true, true},
12831284
},
12841285

1286+
[KSZ9563] = {
1287+
.chip_id = KSZ9563_CHIP_ID,
1288+
.dev_name = "KSZ9563",
1289+
.num_vlans = 4096,
1290+
.num_alus = 4096,
1291+
.num_statics = 16,
1292+
.cpu_ports = 0x07, /* can be configured as cpu port */
1293+
.port_cnt = 3, /* total port count */
1294+
.port_nirqs = 3,
1295+
.ops = &ksz9477_dev_ops,
1296+
.mib_names = ksz9477_mib_names,
1297+
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
1298+
.reg_mib_cnt = MIB_COUNTER_NUM,
1299+
.regs = ksz9477_regs,
1300+
.masks = ksz9477_masks,
1301+
.shifts = ksz9477_shifts,
1302+
.xmii_ctrl0 = ksz9477_xmii_ctrl0,
1303+
.xmii_ctrl1 = ksz8795_xmii_ctrl1, /* Same as ksz8795 */
1304+
.supports_mii = {false, false, true},
1305+
.supports_rmii = {false, false, true},
1306+
.supports_rgmii = {false, false, true},
1307+
.internal_phy = {true, true, false},
1308+
.gbit_capable = {true, true, true},
1309+
},
1310+
12851311
[KSZ9567] = {
12861312
.chip_id = KSZ9567_CHIP_ID,
12871313
.dev_name = "KSZ9567",
@@ -2389,7 +2415,8 @@ static enum dsa_tag_protocol ksz_get_tag_protocol(struct dsa_switch *ds,
23892415

23902416
if (dev->chip_id == KSZ8830_CHIP_ID ||
23912417
dev->chip_id == KSZ8563_CHIP_ID ||
2392-
dev->chip_id == KSZ9893_CHIP_ID)
2418+
dev->chip_id == KSZ9893_CHIP_ID ||
2419+
dev->chip_id == KSZ9563_CHIP_ID)
23932420
proto = DSA_TAG_PROTO_KSZ9893;
23942421

23952422
if (dev->chip_id == KSZ9477_CHIP_ID ||
@@ -2509,7 +2536,8 @@ static void ksz_set_xmii(struct ksz_device *dev, int port,
25092536
data8 |= bitval[P_RGMII_SEL];
25102537
/* On KSZ9893, disable RGMII in-band status support */
25112538
if (dev->chip_id == KSZ9893_CHIP_ID ||
2512-
dev->chip_id == KSZ8563_CHIP_ID)
2539+
dev->chip_id == KSZ8563_CHIP_ID ||
2540+
dev->chip_id == KSZ9563_CHIP_ID)
25132541
data8 &= ~P_MII_MAC_MODE;
25142542
break;
25152543
default:
@@ -2782,6 +2810,8 @@ static int ksz_switch_detect(struct ksz_device *dev)
27822810

27832811
if (id4 == SKU_ID_KSZ8563)
27842812
dev->chip_id = KSZ8563_CHIP_ID;
2813+
else if (id4 == SKU_ID_KSZ9563)
2814+
dev->chip_id = KSZ9563_CHIP_ID;
27852815
else
27862816
dev->chip_id = KSZ9893_CHIP_ID;
27872817

drivers/net/dsa/microchip/ksz_common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ enum ksz_model {
154154
KSZ9896,
155155
KSZ9897,
156156
KSZ9893,
157+
KSZ9563,
157158
KSZ9567,
158159
LAN9370,
159160
LAN9371,
@@ -172,6 +173,7 @@ enum ksz_chip_id {
172173
KSZ9896_CHIP_ID = 0x00989600,
173174
KSZ9897_CHIP_ID = 0x00989700,
174175
KSZ9893_CHIP_ID = 0x00989300,
176+
KSZ9563_CHIP_ID = 0x00956300,
175177
KSZ9567_CHIP_ID = 0x00956700,
176178
LAN9370_CHIP_ID = 0x00937000,
177179
LAN9371_CHIP_ID = 0x00937100,
@@ -551,6 +553,7 @@ static inline int is_lan937x(struct ksz_device *dev)
551553
/* KSZ9893, KSZ9563, KSZ8563 specific register */
552554
#define REG_CHIP_ID4 0x0f
553555
#define SKU_ID_KSZ8563 0x3c
556+
#define SKU_ID_KSZ9563 0x1c
554557

555558
/* Driver set switch broadcast storm protection at 10% rate. */
556559
#define BROADCAST_STORM_PROT_RATE 10

drivers/net/dsa/microchip/ksz_spi.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,9 @@ static int ksz_spi_probe(struct spi_device *spi)
7171
dev->regmap[i] = devm_regmap_init_spi(spi, &rc);
7272

7373
if (IS_ERR(dev->regmap[i])) {
74-
ret = PTR_ERR(dev->regmap[i]);
75-
dev_err(&spi->dev,
76-
"Failed to initialize regmap%i: %d\n",
77-
regmap_config[i].val_bits, ret);
78-
return ret;
74+
return dev_err_probe(&spi->dev, PTR_ERR(dev->regmap[i]),
75+
"Failed to initialize regmap%i\n",
76+
regmap_config[i].val_bits);
7977
}
8078
}
8179

@@ -163,7 +161,7 @@ static const struct of_device_id ksz_dt_ids[] = {
163161
},
164162
{
165163
.compatible = "microchip,ksz9563",
166-
.data = &ksz_switch_chips[KSZ9893]
164+
.data = &ksz_switch_chips[KSZ9563]
167165
},
168166
{
169167
.compatible = "microchip,ksz8563",

drivers/net/dsa/microchip/lan937x_main.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,11 @@ int lan937x_change_mtu(struct ksz_device *dev, int port, int new_mtu)
242242
}
243243

244244
/* Write the frame size in PORT_MAX_FR_SIZE register */
245-
ksz_pwrite16(dev, port, PORT_MAX_FR_SIZE, new_mtu);
245+
ret = ksz_pwrite16(dev, port, PORT_MAX_FR_SIZE, new_mtu);
246+
if (ret) {
247+
dev_err(ds->dev, "failed to update mtu for port %d\n", port);
248+
return ret;
249+
}
246250

247251
return 0;
248252
}

0 commit comments

Comments
 (0)