Merge branch 'ptp-ocp-add-tap-cpld-support-for-adva-timecard-x1'

Sagi Maimon says:

====================
ptp: ocp: add TAP CPLD support for ADVA TimeCard X1

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 devlink flash.

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.

Patches 1 and 2 are pre-existing probe-error-path bugs that were buried
in the feature commit in v13; they are split out with Fixes: tags.  Patch
1 is also a prerequisite: patch 3 adds a mutex that ptp_ocp_detach()
destroys, so devlink has to be unregistered first.  Patch 3 adds the bus
arbitration and the read-only interfaces, patch 4 the flashing.
====================

Link: https://patch.msgid.link/20260916153242.157171-1-sagi.maimon@adtran.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Jakub Kicinski 2026-09-21 16:13:34 -07:00
commit 05092b5433
5 changed files with 1039 additions and 6 deletions

View File

@ -11,6 +11,35 @@ Contact: Jonathan Lemon <jonathan.lemon@gmail.com>
Description: This directory contains the attributes of the Nth timecard
registered.
What: /sys/class/timecard/ocpN/cpld_status
Date: July 2026
Contact: Sagi Maimon <maimon.sagi@gmail.com>
Description: (RO, root only) The flags set in the status register of the
TAP CPLD, space separated, or an empty line when none is
set. Only present on ADVA x1 TAP boards (PCI ID
0xad5a:0x0410).
========== ================================================
done the configuration flash holds a valid image and
it is active
busy an internal operation is in progress
failed the last ISC operation failed
========== ================================================
For example "busy" while an operation runs, or "busy failed"
if a failure is latched while another one is in progress.
A read arbitrates for the shared I2C bus and reprograms the
on-card mux, so it is restricted to root. The Lattice device
ID of the CPLD is read by the driver shortly after probe,
and again after a successful CPLD update, and reported from
that cached value as the fixed "cpld.id" version by
devlink dev info.
New CPLD firmware is programmed with devlink dev flash,
selecting the "fw.cpld" component; see
Documentation/networking/devlink/ptp_ocp.rst.
What: /sys/class/timecard/ocpN/available_clock_sources
Date: September 2021
Contact: Jonathan Lemon <jonathan.lemon@gmail.com>

View File

@ -99,6 +99,7 @@ parameters, info versions, and other features it supports.
nfp
octeontx2
prestera
ptp_ocp
qed
sfc
stmmac

View File

@ -0,0 +1,75 @@
.. SPDX-License-Identifier: GPL-2.0
========================
ptp_ocp devlink support
========================
This document describes the devlink features implemented by the ``ptp_ocp``
device driver: the info versions it reports and its flash update support.
Info versions
=============
The ``ptp_ocp`` driver reports the following versions
.. list-table:: devlink info versions implemented
:widths: 5 5 90
* - Name
- Type
- Description
* - ``fw``
- running
- Version of the firmware running on the card. Reported as ``loader``
instead when the card is running the firmware loader.
* - ``board.id``
- fixed
- Board identifier, read from the on-card EEPROM.
* - ``cpld.id``
- fixed
- Lattice device ID (IDCODE) of the TAP CPLD, formatted as ``0x%08x``.
Only present on ADVA TimeCard X1 boards, which are the only ones
carrying that CPLD. Reading it claims the shared I2C bus and
reprograms the on-card mux, so the driver does that from its own
worker and reports the cached value here; the version is omitted
until that read has succeeded. The read is made once per binding
and again after a successful CPLD update.
* - ``fw.cpld``
- running
- USERCODE of the image programmed into the TAP CPLD, formatted as
``0x%08x``. Read together with ``cpld.id`` and reported the same
way. This is the component name to pass to ``devlink dev flash``
to update the CPLD.
Flash update
============
The driver implements ``devlink dev flash`` for two separate targets,
selected with the component name.
.. list-table:: Flash components
:widths: 20 80
* - Component
- Description
* - (none)
- The card's own flash, written through the SPI controller the driver
exposes. The card runs the new image after its next reset.
* - ``fw.cpld``
- The configuration flash of the TAP CPLD on ADVA TimeCard X1 boards,
programmed over I2C with the MachXO3 in-system programming commands
and activated with a REFRESH, so the new image runs immediately.
The image is the raw configuration bitstream. The only check the
driver makes is that its length is a non-zero multiple of the
16-byte page size, so a container such as ``.jed`` has to be
converted first rather than passed through - one whose length
happens to be a multiple of 16 would be programmed as if it were
a bitstream.
Programming the CPLD claims the shared I2C bus for the whole cycle, so
reads of the card's EEPROM block until it completes. Progress is reported
with the standard devlink status notifications.
Example::
$ devlink dev flash pci/0000:02:00.0 file adva-cpld.bin component fw.cpld

View File

@ -20490,6 +20490,7 @@ OPENCOMPUTE PTP CLOCK DRIVER
M: Vadim Fedorenko <vadim.fedorenko@linux.dev>
L: netdev@vger.kernel.org
S: Maintained
F: Documentation/networking/devlink/ptp_ocp.rst
F: drivers/ptp/ptp_ocp.c
OPENCORES I2C BUS DRIVER

File diff suppressed because it is too large Load Diff