netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sagi Maimon <maimon.sagi@gmail.com>
To: netdev@vger.kernel.org
Cc: vadim.fedorenko@linux.dev, richardcochran@gmail.com,
	kuba@kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net,
	edumazet@google.com, pabeni@redhat.com,
	linux-kernel@vger.kernel.org, Sagi Maimon <maimon.sagi@gmail.com>
Subject: [PATCH net-next v11 0/2] ptp: ocp: add TAP CPLD support for ADVA TimeCard X1
Date: Tue, 11 Aug 2026 16:57:18 +0300	[thread overview]
Message-ID: <20260811135720.109580-1-maimon.sagi@gmail.com> (raw)

The ADVA TimeCard X1 (PCI device 0x0410) carries a Lattice MachXO3 CPLD
on the TMC I2C bus.  This series adds access to it and an update path
through the kernel firmware-upload subsystem.

The card has two I2C controllers.  Linux registers only the one at
0x00150000, normally routed to the config EEPROMs; the one at 0x00120000
belongs to the on-card MicroBlaze and is routed to the TMC or M.2 bus as
its firmware selects.  A request/grant handshake re-routes the host
controller onto the TMC bus, where the PCA9548 and the CPLD behind its
channel 0 live.  Everything here is built on that handshake.

Patch 1 adds the arbitration and the read-only interfaces on top of it.
Patch 2 adds the flashing, as requested in review.

v10:    https://lore.kernel.org/all/20260805083154.3821-1-maimon.sagi@gmail.com/
Review: https://lore.kernel.org/all/20260810230735.955188-2-kuba@kernel.org/

One review point did not become a code change, so to answer it here: the
CPLD paths leaving the PCA9548 with all channels deselected is harmless.
The mux sits on the TMC bus, which the EEPROM paths never see - by the
time the grant is dropped and the host controller is back on the EEPROM
segment, the mux is not reachable from that adapter at all.  Deselect-all
is also the PCA9548 power-on state, so the MicroBlaze finds it exactly as
it would after a cold boot.  v11 documents this above the CPLD helpers
rather than leaving it to be re-derived.

Changes since v10:

 - Split into two patches, separating the firmware flashing from the
   bus access and the read-only interfaces (Jakub).
 - Report the Lattice device ID as the fixed devlink version "cpld.id"
   and drop the cpld_device_id sysfs attribute (Jakub).  The value is
   cached, so the bus arbitration is paid once per card.
 - Hold the i2c core adapter lock across the whole grant window and use
   __i2c_transfer(); while the host controller is routed onto the TMC
   bus the EEPROMs are not behind that adapter at all, so an unarbitrated
   transfer from ptp_ocp_read_eeprom(), the nvmem attributes or the at24
   sysfs files would be issued onto the wrong bus.
 - Register the firmware-upload node per card as adva-cpld.N; the fixed
   name made the second X1 board in a host fail with -EEXIST.
 - Unregister the upload first on detach, so an in-flight programming
   cycle is cancelled and flushed while the I2C controller is still up.
 - Restrict cpld_status to 0400 and take cpld_lock interruptibly, so a
   reader cannot sit unkillable for the length of an upload or stall
   device removal.
 - Fix adva_x1_cpld_wait_ready(): it polled floor(max_ms / 100) times and
   never re-read after the last sleep, so the 100 ms per-page budget
   allowed exactly one poll.  Use read_poll_timeout() with a wall-clock
   deadline that also accounts for the I2C transactions.
 - Cancellation: keep a request that arrives before prepare() runs,
   annotate the flag with READ_ONCE/WRITE_ONCE, honour it inside the long
   waits, and report it as CANCELED rather than HW_ERROR.
 - Set cpld_in_config_mode before EN_CFG_TP and clear it once REFRESH is
   accepted, so DIS_CFG is neither skipped after a failed wait nor sent
   to a device that already rebooted.
 - Retry the post-REFRESH mux reselect; its return was discarded, so a
   NAK failed an update whose image was already running.
 - Drop I2C_M_NOSTART: two messages in one transfer already give the
   repeated-START read the ISC protocol needs, and the flag asks for the
   opposite on adapters that honour it.
 - Withdraw the MicroBlaze request when the grant times out, and drop the
   -EBUSY check that only ever read back its own write.
 - select FW_LOADER and FW_UPLOAD; without them the documented update
   path does not exist.
 - Correct the IDCODE to 0x612bc043 and the part to LCMXO3LF-2100.
 - Add lockdep_assert_held() to the callbacks and context annotations for
   the lock handed from prepare() to cleanup().

Sagi Maimon (2):
  ptp: ocp: add TAP CPLD access for ADVA TimeCard X1
  ptp: ocp: add TAP CPLD firmware upload for ADVA TimeCard X1

 Documentation/ABI/testing/sysfs-timecard |  24 +
 drivers/ptp/Kconfig                      |   2 +
 drivers/ptp/ptp_ocp.c                    | 655 ++++++++++++++++++++++-
 3 files changed, 677 insertions(+), 4 deletions(-)

-- 
2.47.0


             reply	other threads:[~2026-08-11 13:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-11 13:57 Sagi Maimon [this message]
2026-08-11 13:57 ` [PATCH net-next v11 1/2] ptp: ocp: add TAP CPLD access for ADVA TimeCard X1 Sagi Maimon
2026-08-11 13:57 ` [PATCH net-next v11 2/2] ptp: ocp: add TAP CPLD firmware upload " Sagi Maimon

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=20260811135720.109580-1-maimon.sagi@gmail.com \
    --to=maimon.sagi@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=vadim.fedorenko@linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).