Skip to content

Commit 6ed3472

Browse files
triha2workkuba-moo
authored andcommitted
net: dsa: microchip: Do not execute PTP driver code for unsupported switches
The PTP driver code only works for certain KSZ switches like KSZ9477, KSZ9567, LAN937X and their varieties. This code is enabled by kernel configuration CONFIG_NET_DSA_MICROCHIP_KSZ_PTP. As the DSA driver is common to work with all KSZ switches this PTP code is not appropriate for other unsupported switches. The ptp_capable indication is added to the chip data structure to signal whether to execute those code. Signed-off-by: Tristram Ha <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 3272040 commit 6ed3472

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

drivers/net/dsa/microchip/ksz_common.c

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
13391339
.supports_rgmii = {false, false, true},
13401340
.internal_phy = {true, true, false},
13411341
.gbit_capable = {false, false, true},
1342+
.ptp_capable = true,
13421343
.wr_table = &ksz8563_register_set,
13431344
.rd_table = &ksz8563_register_set,
13441345
},
@@ -1550,6 +1551,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
15501551
.internal_phy = {true, true, true, true,
15511552
true, false, false},
15521553
.gbit_capable = {true, true, true, true, true, true, true},
1554+
.ptp_capable = true,
15531555
.wr_table = &ksz9477_register_set,
15541556
.rd_table = &ksz9477_register_set,
15551557
},
@@ -1677,6 +1679,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
16771679
.supports_rgmii = {false, false, true},
16781680
.internal_phy = {true, true, false},
16791681
.gbit_capable = {true, true, true},
1682+
.ptp_capable = true,
16801683
},
16811684

16821685
[KSZ8567] = {
@@ -1712,6 +1715,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
17121715
true, false, false},
17131716
.gbit_capable = {false, false, false, false, false,
17141717
true, true},
1718+
.ptp_capable = true,
17151719
},
17161720

17171721
[KSZ9567] = {
@@ -1744,6 +1748,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
17441748
.internal_phy = {true, true, true, true,
17451749
true, false, false},
17461750
.gbit_capable = {true, true, true, true, true, true, true},
1751+
.ptp_capable = true,
17471752
},
17481753

17491754
[LAN9370] = {
@@ -1773,6 +1778,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
17731778
.supports_rmii = {false, false, false, false, true},
17741779
.supports_rgmii = {false, false, false, false, true},
17751780
.internal_phy = {true, true, true, true, false},
1781+
.ptp_capable = true,
17761782
},
17771783

17781784
[LAN9371] = {
@@ -1802,6 +1808,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
18021808
.supports_rmii = {false, false, false, false, true, true},
18031809
.supports_rgmii = {false, false, false, false, true, true},
18041810
.internal_phy = {true, true, true, true, false, false},
1811+
.ptp_capable = true,
18051812
},
18061813

18071814
[LAN9372] = {
@@ -1835,6 +1842,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
18351842
true, true, false, false},
18361843
.internal_phy = {true, true, true, true,
18371844
false, false, true, true},
1845+
.ptp_capable = true,
18381846
},
18391847

18401848
[LAN9373] = {
@@ -1868,6 +1876,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
18681876
true, true, false, false},
18691877
.internal_phy = {true, true, true, false,
18701878
false, false, true, true},
1879+
.ptp_capable = true,
18711880
},
18721881

18731882
[LAN9374] = {
@@ -1901,6 +1910,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
19011910
true, true, false, false},
19021911
.internal_phy = {true, true, true, true,
19031912
false, false, true, true},
1913+
.ptp_capable = true,
19041914
},
19051915

19061916
[LAN9646] = {
@@ -2809,16 +2819,21 @@ static int ksz_setup(struct dsa_switch *ds)
28092819
if (ret)
28102820
goto out_girq;
28112821

2812-
ret = ksz_ptp_irq_setup(ds, dp->index);
2813-
if (ret)
2814-
goto out_pirq;
2822+
if (dev->info->ptp_capable) {
2823+
ret = ksz_ptp_irq_setup(ds, dp->index);
2824+
if (ret)
2825+
goto out_pirq;
2826+
}
28152827
}
28162828
}
28172829

2818-
ret = ksz_ptp_clock_register(ds);
2819-
if (ret) {
2820-
dev_err(dev->dev, "Failed to register PTP clock: %d\n", ret);
2821-
goto out_ptpirq;
2830+
if (dev->info->ptp_capable) {
2831+
ret = ksz_ptp_clock_register(ds);
2832+
if (ret) {
2833+
dev_err(dev->dev, "Failed to register PTP clock: %d\n",
2834+
ret);
2835+
goto out_ptpirq;
2836+
}
28222837
}
28232838

28242839
ret = ksz_mdio_register(dev);
@@ -2838,9 +2853,10 @@ static int ksz_setup(struct dsa_switch *ds)
28382853
return 0;
28392854

28402855
out_ptp_clock_unregister:
2841-
ksz_ptp_clock_unregister(ds);
2856+
if (dev->info->ptp_capable)
2857+
ksz_ptp_clock_unregister(ds);
28422858
out_ptpirq:
2843-
if (dev->irq > 0)
2859+
if (dev->irq > 0 && dev->info->ptp_capable)
28442860
dsa_switch_for_each_user_port(dp, dev->ds)
28452861
ksz_ptp_irq_free(ds, dp->index);
28462862
out_pirq:
@@ -2859,11 +2875,13 @@ static void ksz_teardown(struct dsa_switch *ds)
28592875
struct ksz_device *dev = ds->priv;
28602876
struct dsa_port *dp;
28612877

2862-
ksz_ptp_clock_unregister(ds);
2878+
if (dev->info->ptp_capable)
2879+
ksz_ptp_clock_unregister(ds);
28632880

28642881
if (dev->irq > 0) {
28652882
dsa_switch_for_each_user_port(dp, dev->ds) {
2866-
ksz_ptp_irq_free(ds, dp->index);
2883+
if (dev->info->ptp_capable)
2884+
ksz_ptp_irq_free(ds, dp->index);
28672885

28682886
ksz_irq_free(&dev->ports[dp->index].pirq);
28692887
}

drivers/net/dsa/microchip/ksz_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ struct ksz_chip_data {
9292
bool supports_rgmii[KSZ_MAX_NUM_PORTS];
9393
bool internal_phy[KSZ_MAX_NUM_PORTS];
9494
bool gbit_capable[KSZ_MAX_NUM_PORTS];
95+
bool ptp_capable;
9596
const struct regmap_access_table *wr_table;
9697
const struct regmap_access_table *rd_table;
9798
};

0 commit comments

Comments
 (0)