[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220425013800.GC4472@hoboy.vegasvil.org>
Date: Sun, 24 Apr 2022 18:38:00 -0700
From: Richard Cochran <richardcochran@...il.com>
To: Jonathan Lemon <jonathan.lemon@...il.com>
Cc: f.fainelli@...il.com, bcm-kernel-feedback-list@...adcom.com,
andrew@...n.ch, hkallweit1@...il.com, linux@...linux.org.uk,
netdev@...r.kernel.org, kernel-team@...com
Subject: Re: [PATCH net-next v1 1/4] net: phy: broadcom: Add PTP support for
some Broadcom PHYs.
On Sat, Apr 23, 2022 at 07:23:53PM -0700, Jonathan Lemon wrote:
> +static bool bcm_ptp_get_tstamp(struct bcm_ptp_private *priv,
> + struct bcm_ptp_capture *capts)
> +{
> + struct phy_device *phydev = priv->phydev;
> + u16 ts[4], reg;
> + u32 sec, nsec;
> +
> + mutex_lock(&priv->mutex);
> +
> + reg = bcm_phy_read_exp(phydev, INTR_STATUS);
> + if ((reg & INTC_SOP) == 0) {
> + mutex_unlock(&priv->mutex);
> + return false;
> + }
> +
> + bcm_phy_write_exp(phydev, TS_READ_CTRL, TS_READ_START);
> +
> + ts[0] = bcm_phy_read_exp(phydev, TS_REG_0);
> + ts[1] = bcm_phy_read_exp(phydev, TS_REG_1);
> + ts[2] = bcm_phy_read_exp(phydev, TS_REG_2);
> + ts[3] = bcm_phy_read_exp(phydev, TS_REG_3);
> +
> + /* not in be32 format for some reason */
> + capts->seq_id = bcm_phy_read_exp(priv->phydev, TS_INFO_0);
> +
> + reg = bcm_phy_read_exp(phydev, TS_INFO_1);
> + capts->msgtype = reg >> 12;
> + capts->tx_dir = !!(reg & BIT(11));
Okay, so now I am sad. The 541xx has:
TIMESTAMP_INFO_1 0xA8C bit 0 DIR, bits 1-2 msg_type, etc
TIMESTAMP_INFO_2 0xA8D sequence ID
It is the same info, but randomly shuffled among the two registers in
a different way.
So much for supporting multiple devices with a common code base. :(
> + bcm_phy_write_exp(phydev, TS_READ_CTRL, TS_READ_END);
> + bcm_phy_write_exp(phydev, TS_READ_CTRL, 0);
> +
> + mutex_unlock(&priv->mutex);
> +
> + sec = (ts[3] << 16) | ts[2];
> + nsec = (ts[1] << 16) | ts[0];
> + capts->hwtstamp = ktime_set(sec, nsec);
> +
> + return true;
> +}
Thanks,
Richard
Powered by blists - more mailing lists