mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next v13 0/2] ptp: ocp: add TAP CPLD support for ADVA TimeCard X1
@ 2026-09-08 12:23 Sagi Maimon
  2026-09-08 12:23 ` [PATCH net-next v13 1/2] ptp: ocp: add TAP CPLD access " Sagi Maimon
  2026-09-08 12:23 ` [PATCH net-next v13 2/2] ptp: ocp: add TAP CPLD firmware upload " Sagi Maimon
  0 siblings, 2 replies; 7+ messages in thread
From: Sagi Maimon @ 2026-09-08 12:23 UTC (permalink / raw)
  To: netdev
  Cc: vadim.fedorenko, richardcochran, kuba, andrew+netdev, davem,
	edumazet, pabeni, linux-kernel, Sagi Maimon

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.

v12: https://lore.kernel.org/netdev/20260902044232.21188-1-maimon.sagi@gmail.com/T/#u

Changes since v12 - all from the automated review of v12:

 - The CPLD device ID is no longer read from ptp_ocp_devlink_info_get().
   DEVLINK_CMD_INFO_GET carries no GENL_ADMIN_PERM, and that read claims
   the i2c adapter and drives the on-card mux for up to two seconds,
   which any user could have repeated to keep the EEPROM, nvmem and at24
   paths off the controller.  The same operation is root-only through
   cpld_status.  The driver now reads the ID once from its own worker,
   as soon as the i2c adapter has registered, and info_get() reports the
   cached value.  Patch 1.
 - As a result info_get() can no longer fail because of the CPLD: it
   skips cpld.id when the value is not available.  Returning an error
   there made devlink discard the whole reply, and -ENODEV was reachable
   on any card where the i2c adapter never bound, which also aborted
   'devlink dev info' for every other instance on the host.  Patch 1.
 - cpld.id is now reported before the EEPROM data rather than after its
   early return, so it no longer depends on the EEPROM having been read.
   Patch 1.
 - adva_x1_bus_claim() re-checks that the adapter it just took a
   reference to is still this card's: i2c_del_adapter() frees the idr
   slot before the bus notifier clears the cached number, so the number
   could already have been recycled.  Patch 1.
 - The probe error paths unregister devlink before ptp_ocp_detach(),
   which destroys cpld_lock and releases the i2c controller.  Patch 1.
 - I2C_M_DMA_SAFE is no longer set.  No adapter that can bind here does
   DMA, and the read half of the scratch buffer is an interior pointer
   that does not satisfy the flag's alignment contract; the core is left
   free to bounce.  Patch 1.
 - The firmware-upload callbacks map errnos onto the documented
   fw_upload_err categories: -ENODEV and a failed transfer are no longer
   reported as a timeout, and a CPLD FAILED status is no longer reported
   as one either.  Patch 2.
 - adva_cpld_prepare() checks for a cancellation on entry, as its own
   comment promised, instead of cycling the CPLD into configuration mode
   for an upload that was already aborted.  Patch 2.
 - Added Documentation/networking/devlink/ptp_ocp.rst describing the
   driver-specific cpld.id version, with the index and MAINTAINERS
   entries.  Patch 1.
 - Comments in patch 1 no longer describe the firmware-upload path that
   only patch 2 adds, and the lines that exceeded 80 columns are wrapped.

Three points from that review are deliberately not addressed here,
because changing them needs a full programming cycle on the card to
validate and I would rather not fold untested changes into a respin:

 - poll_complete() samples DONE before REFRESH only, and does not check
   the sysCONFIG error field the way drivers/fpga/lattice-sysconfig.c
   does.
 - adva_x1_mblaze_release() does not wait for the firmware to route the
   controller back before the adapter lock is dropped.
 - A cancel arriving between cleanup() and fw_upload_prog_complete()
   stays set and aborts the next upload.

Tested on an ADVA TimeCard X1: the driver loads with the i2c adapter
registering after probe, cpld.id and cpld_status read back correctly,
and the wire byte sequences are unchanged from v12, which programmed the
part successfully.

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 +
 Documentation/networking/devlink/index.rst   |   1 +
 Documentation/networking/devlink/ptp_ocp.rst |  35 +
 MAINTAINERS                                  |   1 +
 drivers/ptp/Kconfig                          |   2 +
 drivers/ptp/ptp_ocp.c                        | 761 ++++++++++++++++++-
 6 files changed, 818 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/networking/devlink/ptp_ocp.rst


base-commit: c29b37ed7a4d9856ed758a82282456d69cee2ed1
-- 
2.47.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-09-11 23:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-08 12:23 [PATCH net-next v13 0/2] ptp: ocp: add TAP CPLD support for ADVA TimeCard X1 Sagi Maimon
2026-09-08 12:23 ` [PATCH net-next v13 1/2] ptp: ocp: add TAP CPLD access " Sagi Maimon
2026-09-10 15:23   ` netdev-bot+sashiko
2026-09-11 23:52   ` Jakub Kicinski
2026-09-08 12:23 ` [PATCH net-next v13 2/2] ptp: ocp: add TAP CPLD firmware upload " Sagi Maimon
2026-09-10 15:23   ` netdev-bot+sashiko
2026-09-11 23:51   ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®