mbox series

[net-next,0/5] net: lan966x: Add support for PTP programmable pins

Message ID 20220424145824.2931449-1-horatiu.vultur@microchip.com
Headers show
Series net: lan966x: Add support for PTP programmable pins | expand

Message

Horatiu Vultur April 24, 2022, 2:58 p.m. UTC
Lan966x has 8 PTP programmable pins. The last pin is hardcoded to be used
by PHC0 and all the rest are shareable between the PHCs. The PTP pins can
implement both extts and perout functions.

Horatiu Vultur (5):
  dt-bindings: net: lan966x: Extend with the ptp external interrupt.
  net: lan966x: Change the PTP pin used to read/write the PHC.
  net: lan966x: Add registers used to configure the PTP pin
  net: lan966x: Add support for PTP_PF_PEROUT
  net: lan966x: Add support for PTP_PF_EXTTS

 .../net/microchip,lan966x-switch.yaml         |   2 +
 .../ethernet/microchip/lan966x/lan966x_main.c |  17 ++
 .../ethernet/microchip/lan966x/lan966x_main.h |   4 +
 .../ethernet/microchip/lan966x/lan966x_ptp.c  | 276 +++++++++++++++++-
 .../ethernet/microchip/lan966x/lan966x_regs.h |  40 +++
 5 files changed, 338 insertions(+), 1 deletion(-)

Comments

Richard Cochran April 24, 2022, 3:09 p.m. UTC | #1
On Sun, Apr 24, 2022 at 04:58:24PM +0200, Horatiu Vultur wrote:

> @@ -321,6 +321,63 @@ irqreturn_t lan966x_ptp_irq_handler(int irq, void *args)
>  	return IRQ_HANDLED;
>  }
>  
> +irqreturn_t lan966x_ptp_ext_irq_handler(int irq, void *args)
> +{
> +	struct lan966x *lan966x = args;
> +	struct lan966x_phc *phc;
> +	unsigned long flags;
> +	u64 time = 0;
> +	time64_t s;
> +	int pin, i;
> +	s64 ns;
> +
> +	if (!(lan_rd(lan966x, PTP_PIN_INTR)))
> +		return IRQ_NONE;
> +
> +	/* Go through all domains and see which pin generated the interrupt */
> +	for (i = 0; i < LAN966X_PHC_COUNT; ++i) {
> +		struct ptp_clock_event ptp_event = {0};
> +
> +		phc = &lan966x->phc[i];
> +		pin = ptp_find_pin(phc->clock, PTP_PF_EXTTS, 0);

Not safe to call ptp_find_pin() from ISR.  See comment in include/linux/ptp_clock_kernel.h

Thanks,
Richard
Horatiu Vultur April 25, 2022, 8:31 p.m. UTC | #2
The 04/24/2022 08:09, Richard Cochran wrote:

Hi Richard,

> 
> On Sun, Apr 24, 2022 at 04:58:24PM +0200, Horatiu Vultur wrote:
> 
> > @@ -321,6 +321,63 @@ irqreturn_t lan966x_ptp_irq_handler(int irq, void *args)
> >       return IRQ_HANDLED;
> >  }
> >
> > +irqreturn_t lan966x_ptp_ext_irq_handler(int irq, void *args)
> > +{
> > +     struct lan966x *lan966x = args;
> > +     struct lan966x_phc *phc;
> > +     unsigned long flags;
> > +     u64 time = 0;
> > +     time64_t s;
> > +     int pin, i;
> > +     s64 ns;
> > +
> > +     if (!(lan_rd(lan966x, PTP_PIN_INTR)))
> > +             return IRQ_NONE;
> > +
> > +     /* Go through all domains and see which pin generated the interrupt */
> > +     for (i = 0; i < LAN966X_PHC_COUNT; ++i) {
> > +             struct ptp_clock_event ptp_event = {0};
> > +
> > +             phc = &lan966x->phc[i];
> > +             pin = ptp_find_pin(phc->clock, PTP_PF_EXTTS, 0);
> 
> Not safe to call ptp_find_pin() from ISR.  See comment in include/linux/ptp_clock_kernel.h

Good catch.
From what I can see, I should be able to use ptp_find_pin_unlocked.

> 
> Thanks,
> Richard