net: mscc: ocelot: move ocelot ptp clock code out of ocelot.c
The Ocelot PTP clock driver had been embedded into ocelot.c driver. It had supported basic gettime64/settime64/adjtime/adjfine functions by now which were used by both Ocelot switch and Felix switch. This patch is to move current ptp clock code out of ocelot.c driver maintaining as a single ocelot_ptp.c. For futher new features implementation, the common code could be put in ocelot_ptp.c and the switch specific code should be in specific switch driver. The interrupt implementation in SoC is different between Ocelot and Felix. Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
59211053f0
commit
2b49d128b3
@@ -7,6 +7,7 @@
|
||||
#include <soc/mscc/ocelot_sys.h>
|
||||
#include <soc/mscc/ocelot_dev.h>
|
||||
#include <soc/mscc/ocelot_ana.h>
|
||||
#include <soc/mscc/ocelot_ptp.h>
|
||||
#include <soc/mscc/ocelot.h>
|
||||
#include <linux/packing.h>
|
||||
#include <linux/module.h>
|
||||
@@ -494,6 +495,21 @@ static int felix_init_structs(struct felix *felix, int num_phys_ports)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct ptp_clock_info ocelot_ptp_clock_info = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "felix ptp",
|
||||
.max_adj = 0x7fffffff,
|
||||
.n_alarm = 0,
|
||||
.n_ext_ts = 0,
|
||||
.n_per_out = 0,
|
||||
.n_pins = 0,
|
||||
.pps = 0,
|
||||
.gettime64 = ocelot_ptp_gettime64,
|
||||
.settime64 = ocelot_ptp_settime64,
|
||||
.adjtime = ocelot_ptp_adjtime,
|
||||
.adjfine = ocelot_ptp_adjfine,
|
||||
};
|
||||
|
||||
/* Hardware initialization done here so that we can allocate structures with
|
||||
* devm without fear of dsa_register_switch returning -EPROBE_DEFER and causing
|
||||
* us to allocate structures twice (leak memory) and map PCI memory twice
|
||||
@@ -510,6 +526,14 @@ static int felix_setup(struct dsa_switch *ds)
|
||||
return err;
|
||||
|
||||
ocelot_init(ocelot);
|
||||
if (ocelot->ptp) {
|
||||
err = ocelot_init_timestamp(ocelot, &ocelot_ptp_clock_info);
|
||||
if (err) {
|
||||
dev_err(ocelot->dev,
|
||||
"Timestamp initialization failed\n");
|
||||
ocelot->ptp = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (port = 0; port < ds->num_ports; port++) {
|
||||
ocelot_init_port(ocelot, port);
|
||||
@@ -548,6 +572,7 @@ static void felix_teardown(struct dsa_switch *ds)
|
||||
if (felix->info->mdio_bus_free)
|
||||
felix->info->mdio_bus_free(ocelot);
|
||||
|
||||
ocelot_deinit_timestamp(ocelot);
|
||||
/* stop workqueue thread */
|
||||
ocelot_deinit(ocelot);
|
||||
}
|
||||
|
Reference in New Issue
Block a user