Re: [PATCH 6/6] ptp_ocelot: support 4 programmable pins

From: Richard Cochran
Date: Tue Mar 24 2020 - 09:07:38 EST


On Fri, Mar 20, 2020 at 06:37:26PM +0800, Yangbo Lu wrote:
> +static int ocelot_ptp_enable(struct ptp_clock_info *ptp,
> + struct ptp_clock_request *rq, int on)
> +{
> + struct ocelot *ocelot = container_of(ptp, struct ocelot, ptp_info);
> + enum ocelot_ptp_pins ptp_pin;
> + struct timespec64 ts;
> + unsigned long flags;
> + int pin = -1;
> + u32 val;
> + s64 ns;
> +
> + switch (rq->type) {
> + case PTP_CLK_REQ_PEROUT:
> + /* Reject requests with unsupported flags */
> + if (rq->perout.flags)
> + return -EOPNOTSUPP;
> +
> + /*
> + * TODO: support disabling function
> + * When ptp_disable_pinfunc() is to disable function,
> + * it has already held pincfg_mux.
> + * However ptp_find_pin() in .enable() called also needs
> + * to hold pincfg_mux.
> + * This causes dead lock. So, just return for function
> + * disabling, and this needs fix-up.

What dead lock?

When enable(PTP_CLK_REQ_PEROUT, on=0) is called, you don't need to
call ptp_disable_pinfunc(). Just stop the periodic waveform
generator. The assignment of function to pin remains unchanged.

> + */
> + if (!on)
> + break;
> +
> + pin = ptp_find_pin(ocelot->ptp_clock, PTP_PF_PEROUT,
> + rq->perout.index);
> + if (pin == 0)
> + ptp_pin = PTP_PIN_0;
> + else if (pin == 1)
> + ptp_pin = PTP_PIN_1;
> + else if (pin == 2)
> + ptp_pin = PTP_PIN_2;
> + else if (pin == 3)
> + ptp_pin = PTP_PIN_3;
> + else
> + return -EINVAL;

Return -EBUSY here instead.

Thanks,
Richard