[PATCH net-next v11 0/2] ptp: ocp: add TAP CPLD support for ADVA TimeCard X1
Sagi Maimon <[email protected]>
| Newsgroups | org.kernel.vger.netdev,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
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/[email protected]/ Review: https://lore.kernel.org/all/[email protected]/ 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