All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Lemon <jonathan.lemon@gmail.com>
To: Richard Cochran <richardcochran@gmail.com>
Cc: f.fainelli@gmail.com, bcm-kernel-feedback-list@broadcom.com,
	andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk,
	netdev@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH net-next v1 1/4] net: phy: broadcom: Add PTP support for some Broadcom PHYs.
Date: Mon, 25 Apr 2022 16:55:40 -0700	[thread overview]
Message-ID: <20220425235540.vuacu26xb6bzpxob@bsd-mbp.dhcp.thefacebook.com> (raw)
In-Reply-To: <20220425013800.GC4472@hoboy.vegasvil.org>

On Sun, Apr 24, 2022 at 06:38:00PM -0700, Richard Cochran wrote:
> 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.  :(

We could just have a chip-specific version of this function.  The
recovered timestamp is passed back in a structure, so the rest of the
code would be unchanged.
-- 
Jonathan    (no, not volunteering to do this...)

  reply	other threads:[~2022-04-25 23:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-24  2:23 [PATCH net-next v1 0/4] Broadcom PTP PHY support Jonathan Lemon
2022-04-24  2:23 ` [PATCH net-next v1 1/4] net: phy: broadcom: Add PTP support for some Broadcom PHYs Jonathan Lemon
2022-04-24 23:27   ` Florian Fainelli
2022-04-25 23:53     ` Jonathan Lemon
2022-04-25  1:19   ` Richard Cochran
2022-04-25 23:30     ` Jonathan Lemon
2022-04-26  2:49       ` Richard Cochran
2022-04-26  3:02         ` Richard Cochran
2022-04-25  1:38   ` Richard Cochran
2022-04-25 23:55     ` Jonathan Lemon [this message]
2022-04-26  2:53       ` Richard Cochran
2022-04-26 18:02         ` Florian Fainelli
2022-04-25  3:12   ` Richard Cochran
2022-04-25 23:47     ` Jonathan Lemon
2022-04-27 14:40   ` Richard Cochran
2022-04-28  5:02     ` Jonathan Lemon
2022-04-24  2:23 ` [PATCH net-next v1 2/4] net: phy: broadcom: Add Broadcom PTP hooks to bcm-phy-lib Jonathan Lemon
2022-04-24 23:35   ` Florian Fainelli
2022-04-24  2:23 ` [PATCH net-next v1 3/4] net: phy: broadcom: Hook up the PTP PHY functions Jonathan Lemon
2022-04-24 23:29   ` Florian Fainelli
2022-04-24  2:23 ` [PATCH net-next v1 4/4] net: phy: Kconfig: Add broadcom PTP PHY library Jonathan Lemon
2022-04-24 23:29   ` Florian Fainelli
2022-04-25  1:01 ` [PATCH net-next v1 0/4] Broadcom PTP PHY support Richard Cochran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220425235540.vuacu26xb6bzpxob@bsd-mbp.dhcp.thefacebook.com \
    --to=jonathan.lemon@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=kernel-team@fb.com \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.