Skip to content

Commit 0db0561

Browse files
committed
Merge branch 'Felix-DSA-driver-cleanup-build-Seville-separately'
Vladimir Oltean says: ==================== Felix DSA driver cleanup: build Seville separately When introducing the Seville switch support to the Felix driver, some technical debt was created. Since both VSC9959 and VSC9953 are embedded switches (one on an arm64 SoC and the other on a powerpc SoC), there is no use case for having the code for both be present in the same module. This was necessary at the time due to the common SERDES PCS code that they were using, but that has been since refactored into drivers/net/pcs/pcs-lynx.c. This makes the Seville driver stop uselessly depending upon PCI and FSL_ENETC_MDIO, which were only dependencies of Felix in fact. Some whitespace/tab conversions are also present in this series as part of the cleanup process. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 42ccf1c + d60bc62 commit 0db0561

8 files changed

Lines changed: 102 additions & 98 deletions

File tree

‎drivers/net/dsa/ocelot/Kconfig‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ config NET_DSA_MSCC_FELIX
1010
select FSL_ENETC_MDIO
1111
select PCS_LYNX
1212
help
13-
This driver supports network switches from the Vitesse /
14-
Microsemi / Microchip Ocelot family of switching cores that are
15-
connected to their host CPU via Ethernet.
16-
The following switches are supported:
17-
- VSC9959 (Felix): embedded as a PCIe function of the NXP LS1028A
18-
ENETC integrated endpoint.
19-
- VSC9953 (Seville): embedded as a platform device on the
20-
NXP T1040 SoC.
13+
This driver supports the VSC9959 (Felix) switch, which is embedded as
14+
a PCIe function of the NXP LS1028A ENETC RCiEP.
15+
16+
config NET_DSA_MSCC_SEVILLE
17+
tristate "Ocelot / Seville Ethernet switch support"
18+
depends on NET_DSA
19+
depends on NET_VENDOR_MICROSEMI
20+
depends on HAS_IOMEM
21+
select MSCC_OCELOT_SWITCH_LIB
22+
select NET_DSA_TAG_OCELOT
23+
select PCS_LYNX
24+
help
25+
This driver supports the VSC9953 (Seville) switch, which is embedded
26+
as a platform device on the NXP T1040 SoC.

‎drivers/net/dsa/ocelot/Makefile‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22
obj-$(CONFIG_NET_DSA_MSCC_FELIX) += mscc_felix.o
3+
obj-$(CONFIG_NET_DSA_MSCC_SEVILLE) += mscc_seville.o
34

45
mscc_felix-objs := \
56
felix.o \
6-
felix_vsc9959.o \
7+
felix_vsc9959.o
8+
9+
mscc_seville-objs := \
10+
felix.o \
711
seville_vsc9953.o

‎drivers/net/dsa/ocelot/felix.c‎

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -538,23 +538,6 @@ static int felix_init_structs(struct felix *felix, int num_phys_ports)
538538
return 0;
539539
}
540540

541-
static struct ptp_clock_info ocelot_ptp_clock_info = {
542-
.owner = THIS_MODULE,
543-
.name = "felix ptp",
544-
.max_adj = 0x7fffffff,
545-
.n_alarm = 0,
546-
.n_ext_ts = 0,
547-
.n_per_out = OCELOT_PTP_PINS_NUM,
548-
.n_pins = OCELOT_PTP_PINS_NUM,
549-
.pps = 0,
550-
.gettime64 = ocelot_ptp_gettime64,
551-
.settime64 = ocelot_ptp_settime64,
552-
.adjtime = ocelot_ptp_adjtime,
553-
.adjfine = ocelot_ptp_adjfine,
554-
.verify = ocelot_ptp_verify,
555-
.enable = ocelot_ptp_enable,
556-
};
557-
558541
/* Hardware initialization done here so that we can allocate structures with
559542
* devm without fear of dsa_register_switch returning -EPROBE_DEFER and causing
560543
* us to allocate structures twice (leak memory) and map PCI memory twice
@@ -573,7 +556,7 @@ static int felix_setup(struct dsa_switch *ds)
573556

574557
ocelot_init(ocelot);
575558
if (ocelot->ptp) {
576-
err = ocelot_init_timestamp(ocelot, &ocelot_ptp_clock_info);
559+
err = ocelot_init_timestamp(ocelot, felix->info->ptp_caps);
577560
if (err) {
578561
dev_err(ocelot->dev,
579562
"Timestamp initialization failed\n");
@@ -797,31 +780,5 @@ const struct dsa_switch_ops felix_switch_ops = {
797780
.cls_flower_add = felix_cls_flower_add,
798781
.cls_flower_del = felix_cls_flower_del,
799782
.cls_flower_stats = felix_cls_flower_stats,
800-
.port_setup_tc = felix_port_setup_tc,
783+
.port_setup_tc = felix_port_setup_tc,
801784
};
802-
803-
static int __init felix_init(void)
804-
{
805-
int err;
806-
807-
err = pci_register_driver(&felix_vsc9959_pci_driver);
808-
if (err)
809-
return err;
810-
811-
err = platform_driver_register(&seville_vsc9953_driver);
812-
if (err)
813-
return err;
814-
815-
return 0;
816-
}
817-
module_init(felix_init);
818-
819-
static void __exit felix_exit(void)
820-
{
821-
pci_unregister_driver(&felix_vsc9959_pci_driver);
822-
platform_driver_unregister(&seville_vsc9953_driver);
823-
}
824-
module_exit(felix_exit);
825-
826-
MODULE_DESCRIPTION("Felix Switch driver");
827-
MODULE_LICENSE("GPL v2");

‎drivers/net/dsa/ocelot/felix.h‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ struct felix_info {
2020
const struct ocelot_stat_layout *stats_layout;
2121
unsigned int num_stats;
2222
int num_ports;
23-
int num_tx_queues;
23+
int num_tx_queues;
2424
struct vcap_field *vcap_is2_keys;
2525
struct vcap_field *vcap_is2_actions;
2626
const struct vcap_props *vcap;
2727
int switch_pci_bar;
2828
int imdio_pci_bar;
29+
const struct ptp_clock_info *ptp_caps;
2930
int (*mdio_bus_alloc)(struct ocelot *ocelot);
3031
void (*mdio_bus_free)(struct ocelot *ocelot);
3132
void (*phylink_validate)(struct ocelot *ocelot, int port,
@@ -41,8 +42,6 @@ struct felix_info {
4142
};
4243

4344
extern const struct dsa_switch_ops felix_switch_ops;
44-
extern struct pci_driver felix_vsc9959_pci_driver;
45-
extern struct platform_driver seville_vsc9953_driver;
4645

4746
/* DSA glue / front-end for struct ocelot */
4847
struct felix {
@@ -55,6 +54,4 @@ struct felix {
5554
resource_size_t imdio_base;
5655
};
5756

58-
void vsc9959_mdio_bus_free(struct ocelot *ocelot);
59-
6057
#endif

‎drivers/net/dsa/ocelot/felix_vsc9959.c‎

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -296,15 +296,15 @@ static const u32 vsc9959_sys_regmap[] = {
296296
};
297297

298298
static const u32 vsc9959_ptp_regmap[] = {
299-
REG(PTP_PIN_CFG, 0x000000),
300-
REG(PTP_PIN_TOD_SEC_MSB, 0x000004),
301-
REG(PTP_PIN_TOD_SEC_LSB, 0x000008),
302-
REG(PTP_PIN_TOD_NSEC, 0x00000c),
303-
REG(PTP_PIN_WF_HIGH_PERIOD, 0x000014),
304-
REG(PTP_PIN_WF_LOW_PERIOD, 0x000018),
305-
REG(PTP_CFG_MISC, 0x0000a0),
306-
REG(PTP_CLK_CFG_ADJ_CFG, 0x0000a4),
307-
REG(PTP_CLK_CFG_ADJ_FREQ, 0x0000a8),
299+
REG(PTP_PIN_CFG, 0x000000),
300+
REG(PTP_PIN_TOD_SEC_MSB, 0x000004),
301+
REG(PTP_PIN_TOD_SEC_LSB, 0x000008),
302+
REG(PTP_PIN_TOD_NSEC, 0x00000c),
303+
REG(PTP_PIN_WF_HIGH_PERIOD, 0x000014),
304+
REG(PTP_PIN_WF_LOW_PERIOD, 0x000018),
305+
REG(PTP_CFG_MISC, 0x0000a0),
306+
REG(PTP_CLK_CFG_ADJ_CFG, 0x0000a4),
307+
REG(PTP_CLK_CFG_ADJ_FREQ, 0x0000a8),
308308
};
309309

310310
static const u32 vsc9959_gcb_regmap[] = {
@@ -719,6 +719,23 @@ static const struct vcap_props vsc9959_vcap_props[] = {
719719
},
720720
};
721721

722+
static const struct ptp_clock_info vsc9959_ptp_caps = {
723+
.owner = THIS_MODULE,
724+
.name = "felix ptp",
725+
.max_adj = 0x7fffffff,
726+
.n_alarm = 0,
727+
.n_ext_ts = 0,
728+
.n_per_out = OCELOT_PTP_PINS_NUM,
729+
.n_pins = OCELOT_PTP_PINS_NUM,
730+
.pps = 0,
731+
.gettime64 = ocelot_ptp_gettime64,
732+
.settime64 = ocelot_ptp_settime64,
733+
.adjtime = ocelot_ptp_adjtime,
734+
.adjfine = ocelot_ptp_adjfine,
735+
.verify = ocelot_ptp_verify,
736+
.enable = ocelot_ptp_enable,
737+
};
738+
722739
#define VSC9959_INIT_TIMEOUT 50000
723740
#define VSC9959_GCB_RST_SLEEP 100
724741
#define VSC9959_SYS_RAMINIT_SLEEP 80
@@ -727,7 +744,7 @@ static int vsc9959_gcb_soft_rst_status(struct ocelot *ocelot)
727744
{
728745
int val;
729746

730-
regmap_field_read(ocelot->regfields[GCB_SOFT_RST_SWC_RST], &val);
747+
ocelot_field_read(ocelot, GCB_SOFT_RST_SWC_RST, &val);
731748

732749
return val;
733750
}
@@ -737,12 +754,15 @@ static int vsc9959_sys_ram_init_status(struct ocelot *ocelot)
737754
return ocelot_read(ocelot, SYS_RAM_INIT);
738755
}
739756

757+
/* CORE_ENA is in SYS:SYSTEM:RESET_CFG
758+
* RAM_INIT is in SYS:RAM_CTRL:RAM_INIT
759+
*/
740760
static int vsc9959_reset(struct ocelot *ocelot)
741761
{
742762
int val, err;
743763

744764
/* soft-reset the switch core */
745-
regmap_field_write(ocelot->regfields[GCB_SOFT_RST_SWC_RST], 1);
765+
ocelot_field_write(ocelot, GCB_SOFT_RST_SWC_RST, 1);
746766

747767
err = readx_poll_timeout(vsc9959_gcb_soft_rst_status, ocelot, val, !val,
748768
VSC9959_GCB_RST_SLEEP, VSC9959_INIT_TIMEOUT);
@@ -762,7 +782,7 @@ static int vsc9959_reset(struct ocelot *ocelot)
762782
}
763783

764784
/* enable switch core */
765-
regmap_field_write(ocelot->regfields[SYS_RESET_CFG_CORE_ENA], 1);
785+
ocelot_field_write(ocelot, SYS_RESET_CFG_CORE_ENA, 1);
766786

767787
return 0;
768788
}
@@ -933,7 +953,7 @@ static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot)
933953
return 0;
934954
}
935955

936-
void vsc9959_mdio_bus_free(struct ocelot *ocelot)
956+
static void vsc9959_mdio_bus_free(struct ocelot *ocelot)
937957
{
938958
struct felix *felix = ocelot_to_felix(ocelot);
939959
int port;
@@ -1166,12 +1186,13 @@ static const struct felix_info felix_info_vsc9959 = {
11661186
.num_tx_queues = FELIX_NUM_TC,
11671187
.switch_pci_bar = 4,
11681188
.imdio_pci_bar = 0,
1189+
.ptp_caps = &vsc9959_ptp_caps,
11691190
.mdio_bus_alloc = vsc9959_mdio_bus_alloc,
11701191
.mdio_bus_free = vsc9959_mdio_bus_free,
11711192
.phylink_validate = vsc9959_phylink_validate,
11721193
.prevalidate_phy_mode = vsc9959_prevalidate_phy_mode,
1173-
.port_setup_tc = vsc9959_port_setup_tc,
1174-
.port_sched_speed_set = vsc9959_sched_speed_set,
1194+
.port_setup_tc = vsc9959_port_setup_tc,
1195+
.port_sched_speed_set = vsc9959_sched_speed_set,
11751196
.xmit_template_populate = vsc9959_xmit_template_populate,
11761197
};
11771198

@@ -1307,9 +1328,13 @@ static struct pci_device_id felix_ids[] = {
13071328
};
13081329
MODULE_DEVICE_TABLE(pci, felix_ids);
13091330

1310-
struct pci_driver felix_vsc9959_pci_driver = {
1331+
static struct pci_driver felix_vsc9959_pci_driver = {
13111332
.name = "mscc_felix",
13121333
.id_table = felix_ids,
13131334
.probe = felix_pci_probe,
13141335
.remove = felix_pci_remove,
13151336
};
1337+
module_pci_driver(felix_vsc9959_pci_driver);
1338+
1339+
MODULE_DESCRIPTION("Felix Switch driver");
1340+
MODULE_LICENSE("GPL v2");

‎drivers/net/dsa/ocelot/seville_vsc9953.c‎

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,12 @@
1616
#define VSC9953_VCAP_IS2_ENTRY_WIDTH 376
1717
#define VSC9953_VCAP_PORT_CNT 10
1818

19-
#define MSCC_MIIM_REG_STATUS 0x0
20-
#define MSCC_MIIM_STATUS_STAT_BUSY BIT(3)
21-
#define MSCC_MIIM_REG_CMD 0x8
22-
#define MSCC_MIIM_CMD_OPR_WRITE BIT(1)
23-
#define MSCC_MIIM_CMD_OPR_READ BIT(2)
24-
#define MSCC_MIIM_CMD_WRDATA_SHIFT 4
25-
#define MSCC_MIIM_CMD_REGAD_SHIFT 20
26-
#define MSCC_MIIM_CMD_PHYAD_SHIFT 25
27-
#define MSCC_MIIM_CMD_VLD BIT(31)
28-
#define MSCC_MIIM_REG_DATA 0xC
29-
#define MSCC_MIIM_DATA_ERROR (BIT(16) | BIT(17))
30-
31-
#define MSCC_PHY_REG_PHY_CFG 0x0
32-
#define PHY_CFG_PHY_ENA (BIT(0) | BIT(1) | BIT(2) | BIT(3))
33-
#define PHY_CFG_PHY_COMMON_RESET BIT(4)
34-
#define PHY_CFG_PHY_RESET (BIT(5) | BIT(6) | BIT(7) | BIT(8))
35-
#define MSCC_PHY_REG_PHY_STATUS 0x4
19+
#define MSCC_MIIM_CMD_OPR_WRITE BIT(1)
20+
#define MSCC_MIIM_CMD_OPR_READ BIT(2)
21+
#define MSCC_MIIM_CMD_WRDATA_SHIFT 4
22+
#define MSCC_MIIM_CMD_REGAD_SHIFT 20
23+
#define MSCC_MIIM_CMD_PHYAD_SHIFT 25
24+
#define MSCC_MIIM_CMD_VLD BIT(31)
3625

3726
static const u32 vsc9953_ana_regmap[] = {
3827
REG(ANA_ADVLEARN, 0x00b500),
@@ -820,6 +809,10 @@ static int vsc9953_mdio_read(struct mii_bus *bus, int phy_id, int regnum)
820809
return err;
821810
}
822811

812+
/* CORE_ENA is in SYS:SYSTEM:RESET_CFG
813+
* MEM_INIT is in SYS:SYSTEM:RESET_CFG
814+
* MEM_ENA is in SYS:SYSTEM:RESET_CFG
815+
*/
823816
static int vsc9953_reset(struct ocelot *ocelot)
824817
{
825818
int val, err;
@@ -835,8 +828,8 @@ static int vsc9953_reset(struct ocelot *ocelot)
835828
}
836829

837830
/* initialize switch mem ~40us */
838-
ocelot_field_write(ocelot, SYS_RESET_CFG_MEM_INIT, 1);
839831
ocelot_field_write(ocelot, SYS_RESET_CFG_MEM_ENA, 1);
832+
ocelot_field_write(ocelot, SYS_RESET_CFG_MEM_INIT, 1);
840833

841834
err = readx_poll_timeout(vsc9953_sys_ram_init_status, ocelot, val, !val,
842835
VSC9953_SYS_RAMINIT_SLEEP,
@@ -847,7 +840,6 @@ static int vsc9953_reset(struct ocelot *ocelot)
847840
}
848841

849842
/* enable switch core */
850-
ocelot_field_write(ocelot, SYS_RESET_CFG_MEM_ENA, 1);
851843
ocelot_field_write(ocelot, SYS_RESET_CFG_CORE_ENA, 1);
852844

853845
return 0;
@@ -989,6 +981,23 @@ static int vsc9953_mdio_bus_alloc(struct ocelot *ocelot)
989981
return 0;
990982
}
991983

984+
static void vsc9953_mdio_bus_free(struct ocelot *ocelot)
985+
{
986+
struct felix *felix = ocelot_to_felix(ocelot);
987+
int port;
988+
989+
for (port = 0; port < ocelot->num_phys_ports; port++) {
990+
struct lynx_pcs *pcs = felix->pcs[port];
991+
992+
if (!pcs)
993+
continue;
994+
995+
mdio_device_free(pcs->mdio);
996+
lynx_pcs_destroy(pcs);
997+
}
998+
mdiobus_unregister(felix->imdio);
999+
}
1000+
9921001
static void vsc9953_xmit_template_populate(struct ocelot *ocelot, int port)
9931002
{
9941003
struct ocelot_port *ocelot_port = ocelot->ports[port];
@@ -1022,7 +1031,7 @@ static const struct felix_info seville_info_vsc9953 = {
10221031
.num_mact_rows = 2048,
10231032
.num_ports = 10,
10241033
.mdio_bus_alloc = vsc9953_mdio_bus_alloc,
1025-
.mdio_bus_free = vsc9959_mdio_bus_free,
1034+
.mdio_bus_free = vsc9953_mdio_bus_free,
10261035
.phylink_validate = vsc9953_phylink_validate,
10271036
.prevalidate_phy_mode = vsc9953_prevalidate_phy_mode,
10281037
.xmit_template_populate = vsc9953_xmit_template_populate,
@@ -1101,11 +1110,15 @@ static const struct of_device_id seville_of_match[] = {
11011110
};
11021111
MODULE_DEVICE_TABLE(of, seville_of_match);
11031112

1104-
struct platform_driver seville_vsc9953_driver = {
1113+
static struct platform_driver seville_vsc9953_driver = {
11051114
.probe = seville_probe,
11061115
.remove = seville_remove,
11071116
.driver = {
11081117
.name = "mscc_seville",
11091118
.of_match_table = of_match_ptr(seville_of_match),
11101119
},
11111120
};
1121+
module_platform_driver(seville_vsc9953_driver);
1122+
1123+
MODULE_DESCRIPTION("Seville Switch driver");
1124+
MODULE_LICENSE("GPL v2");

‎drivers/net/ethernet/mscc/ocelot_ptp.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ int ocelot_ptp_enable(struct ptp_clock_info *ptp,
300300
}
301301
EXPORT_SYMBOL(ocelot_ptp_enable);
302302

303-
int ocelot_init_timestamp(struct ocelot *ocelot, struct ptp_clock_info *info)
303+
int ocelot_init_timestamp(struct ocelot *ocelot,
304+
const struct ptp_clock_info *info)
304305
{
305306
struct ptp_clock *ptp_clock;
306307
int i;

‎include/soc/mscc/ocelot_ptp.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ int ocelot_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin,
5353
enum ptp_pin_function func, unsigned int chan);
5454
int ocelot_ptp_enable(struct ptp_clock_info *ptp,
5555
struct ptp_clock_request *rq, int on);
56-
int ocelot_init_timestamp(struct ocelot *ocelot, struct ptp_clock_info *info);
56+
int ocelot_init_timestamp(struct ocelot *ocelot,
57+
const struct ptp_clock_info *info);
5758
int ocelot_deinit_timestamp(struct ocelot *ocelot);
5859
#endif

0 commit comments

Comments
 (0)