Message ID | 20220803112449.37309-1-csokas.bence@prolan.hu (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | fec: Allow changing the PPS channel | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Guessing tree name failed - patch did not apply |
On Wed, Aug 03, 2022 at 01:24:49PM +0200, Csókás Bence wrote: > Makes the PPS channel configurable via the Device Tree (on startup) and sysfs (run-time) > > Signed-off-by: Csókás Bence <csokas.bence@prolan.hu> Please also Cc: the PTP Maintainer for patches which touch PTP code: Richard Cochran <richardcochran@gmail.com> Andrew > --- > drivers/net/ethernet/freescale/fec_main.c | 37 +++++++++++++++++++++++ > drivers/net/ethernet/freescale/fec_ptp.c | 3 -- > 2 files changed, 37 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c > index 2c3266be20e9..7482f26cd2c7 100644 > --- a/drivers/net/ethernet/freescale/fec_main.c > +++ b/drivers/net/ethernet/freescale/fec_main.c > @@ -47,6 +47,7 @@ > #include <linux/bitops.h> > #include <linux/io.h> > #include <linux/irq.h> > +#include <linux/kobject.h> > #include <linux/clk.h> > #include <linux/crc32.h> > #include <linux/platform_device.h> > @@ -3591,6 +3592,36 @@ static int fec_enet_init_stop_mode(struct fec_enet_private *fep, > return ret; > } > > +static ssize_t pps_ch_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) > +{ > + struct device *dev = container_of(kobj, struct device, kobj); > + struct net_device *ndev = to_net_dev(dev); > + struct fec_enet_private *fep = netdev_priv(ndev); > + > + return sprintf(buf, "%d", fep->pps_channel); > +} > + > +static ssize_t pps_ch_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) > +{ > + struct device *dev = container_of(kobj, struct device, kobj); > + struct net_device *ndev = to_net_dev(dev); > + struct fec_enet_private *fep = netdev_priv(ndev); > + int enable = fep->pps_enable; > + struct ptp_clock_request ptp_rq = { .type = PTP_CLK_REQ_PPS }; > + > + if (enable) > + fep->ptp_caps.enable(&fep->ptp_caps, &ptp_rq, 0); > + > + kstrtoint(buf, 0, &fep->pps_channel); > + > + if (enable) > + fep->ptp_caps.enable(&fep->ptp_caps, &ptp_rq, 1); > + > + return count; > +} > + > +struct kobj_attribute pps_ch_attr = __ATTR(pps_channel, 0660, pps_ch_show, pps_ch_store); > + > static int > fec_probe(struct platform_device *pdev) > { > @@ -3687,6 +3718,9 @@ fec_probe(struct platform_device *pdev) > fep->phy_interface = interface; > } > > + if (of_property_read_u32(np, "fsl,pps-channel", &fep->pps_channel)) > + fep->pps_channel = 0; > + > fep->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); > if (IS_ERR(fep->clk_ipg)) { > ret = PTR_ERR(fep->clk_ipg); > @@ -3799,6 +3833,9 @@ fec_probe(struct platform_device *pdev) > if (ret) > goto failed_register; > > + if (sysfs_create_file(&ndev->dev.kobj, &pps_ch_attr.attr)) > + pr_err("Cannot create pps_channel sysfs file\n"); > + > device_init_wakeup(&ndev->dev, fep->wol_flag & > FEC_WOL_HAS_MAGIC_PACKET); > > diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c > index 69dfed4de4ef..a5077eff305b 100644 > --- a/drivers/net/ethernet/freescale/fec_ptp.c > +++ b/drivers/net/ethernet/freescale/fec_ptp.c > @@ -86,8 +86,6 @@ > #define FEC_CC_MULT (1 << 31) > #define FEC_COUNTER_PERIOD (1 << 31) > #define PPS_OUPUT_RELOAD_PERIOD NSEC_PER_SEC > -#define FEC_CHANNLE_0 0 > -#define DEFAULT_PPS_CHANNEL FEC_CHANNLE_0 > > /** > * fec_ptp_enable_pps > @@ -112,7 +110,6 @@ static int fec_ptp_enable_pps(struct fec_enet_private *fep, uint enable) > if (fep->pps_enable == enable) > return 0; > > - fep->pps_channel = DEFAULT_PPS_CHANNEL; > fep->reload_period = PPS_OUPUT_RELOAD_PERIOD; > > spin_lock_irqsave(&fep->tmreg_lock, flags); > -- > 2.25.1 >
On Wed, 3 Aug 2022 13:24:49 +0200 Csókás Bence wrote:
> Makes the PPS channel configurable via the Device Tree (on startup) and sysfs (run-time)
# Form letter - net-next is closed
We have already sent the networking pull request for 6.0
and therefore net-next is closed for new drivers, features,
code refactoring and optimizations. We are currently accepting
bug fixes only.
Please repost when net-next reopens after 6.0-rc1 is cut.
RFC patches sent for review only are obviously welcome at any time.
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 2c3266be20e9..7482f26cd2c7 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -47,6 +47,7 @@ #include <linux/bitops.h> #include <linux/io.h> #include <linux/irq.h> +#include <linux/kobject.h> #include <linux/clk.h> #include <linux/crc32.h> #include <linux/platform_device.h> @@ -3591,6 +3592,36 @@ static int fec_enet_init_stop_mode(struct fec_enet_private *fep, return ret; } +static ssize_t pps_ch_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) +{ + struct device *dev = container_of(kobj, struct device, kobj); + struct net_device *ndev = to_net_dev(dev); + struct fec_enet_private *fep = netdev_priv(ndev); + + return sprintf(buf, "%d", fep->pps_channel); +} + +static ssize_t pps_ch_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) +{ + struct device *dev = container_of(kobj, struct device, kobj); + struct net_device *ndev = to_net_dev(dev); + struct fec_enet_private *fep = netdev_priv(ndev); + int enable = fep->pps_enable; + struct ptp_clock_request ptp_rq = { .type = PTP_CLK_REQ_PPS }; + + if (enable) + fep->ptp_caps.enable(&fep->ptp_caps, &ptp_rq, 0); + + kstrtoint(buf, 0, &fep->pps_channel); + + if (enable) + fep->ptp_caps.enable(&fep->ptp_caps, &ptp_rq, 1); + + return count; +} + +struct kobj_attribute pps_ch_attr = __ATTR(pps_channel, 0660, pps_ch_show, pps_ch_store); + static int fec_probe(struct platform_device *pdev) { @@ -3687,6 +3718,9 @@ fec_probe(struct platform_device *pdev) fep->phy_interface = interface; } + if (of_property_read_u32(np, "fsl,pps-channel", &fep->pps_channel)) + fep->pps_channel = 0; + fep->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); if (IS_ERR(fep->clk_ipg)) { ret = PTR_ERR(fep->clk_ipg); @@ -3799,6 +3833,9 @@ fec_probe(struct platform_device *pdev) if (ret) goto failed_register; + if (sysfs_create_file(&ndev->dev.kobj, &pps_ch_attr.attr)) + pr_err("Cannot create pps_channel sysfs file\n"); + device_init_wakeup(&ndev->dev, fep->wol_flag & FEC_WOL_HAS_MAGIC_PACKET); diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c index 69dfed4de4ef..a5077eff305b 100644 --- a/drivers/net/ethernet/freescale/fec_ptp.c +++ b/drivers/net/ethernet/freescale/fec_ptp.c @@ -86,8 +86,6 @@ #define FEC_CC_MULT (1 << 31) #define FEC_COUNTER_PERIOD (1 << 31) #define PPS_OUPUT_RELOAD_PERIOD NSEC_PER_SEC -#define FEC_CHANNLE_0 0 -#define DEFAULT_PPS_CHANNEL FEC_CHANNLE_0 /** * fec_ptp_enable_pps @@ -112,7 +110,6 @@ static int fec_ptp_enable_pps(struct fec_enet_private *fep, uint enable) if (fep->pps_enable == enable) return 0; - fep->pps_channel = DEFAULT_PPS_CHANNEL; fep->reload_period = PPS_OUPUT_RELOAD_PERIOD; spin_lock_irqsave(&fep->tmreg_lock, flags);
Makes the PPS channel configurable via the Device Tree (on startup) and sysfs (run-time) Signed-off-by: Csókás Bence <csokas.bence@prolan.hu> --- drivers/net/ethernet/freescale/fec_main.c | 37 +++++++++++++++++++++++ drivers/net/ethernet/freescale/fec_ptp.c | 3 -- 2 files changed, 37 insertions(+), 3 deletions(-)