🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #17379

[PATCH net-next v3 3/3] ptp: ocp: support the WiWi revision 02 Time Card

#17379
From: Ahmad Byagowi
Date: Mon, 16 Nov 2026 18:20
562 lines
32488 bytes
Match WiWi 2163:1008, subsystem 10ee:0007, without a class filter.
Resolve WiWi devices against the static PCI table so a dynamic ID
cannot substitute an unrelated resource layout. NetTimeLogic uses the PCI
Revision ID for incompatible interface changes. Revision 02 identifies
the LitePCIe/MSI-X interface; the Xilinx subsystem ID and FPGA build
number do not identify the register interface. Reject unknown revisions
and check BAR0 and the MSI-X layout before accessing FPGA registers.
Do not probe a CoreList or require exact versions of individual cores.

Report the full 32-bit image ID as the running firmware build. Derive
signal and frequency capabilities from the supported revision, not the
legacy FB build-number thresholds. This ID does not identify the boot
slot. Retain legacy version reporting on other cards.

WiWi shares the peripheral resource table used by the existing Celestica
entry (18d4:1008), not its PCI addressing and interrupt scheme.
For WiWi only, translate peripheral offsets by 0x02000000 and interrupt
inputs by 32. Use aligned 32-bit UART I/O and typed XIIC platform
data, sharing the EEPROM list but not casting another controller's data.
Do not expose an unvalidated second GNSS UART or PPS output source.
Keep the external SMA PPS2 input. The PCI revision identifies the host
interface, not optional board wiring. Use hardware selector values for
WiWi DPLL routing; preserve the existing behavior on other boards.

Enable the three UART and XIIC inputs during probe. Reject attempts to
arm a timestamper or generator with -EAGAIN until the timing gate write
has been flushed. This avoids relying on FPGA replay of a pulse caused
by a userspace request made while the gate was closed.

Do not register the WiWi SPI flash controller or enable its interrupt.
This prevents the driver from exposing raw MTD access to the golden
image. Reject devlink flash as well. The update format and controller
support are not validated; read access via MTD is intentionally lost.

Thomas Schaub of NetTimeLogic described the production register layout
and interrupt gate on 10 November 2026 and the PCI revision convention
on 11 November.

An earlier driver on revision 02, build 0x0000800f, registered 64 MSI-X
vectors, the PHC and three UARTs; both at24 devices bound and the PHC
advanced. That run did not test this revision's flash policy, GNSS2
routing policy or interrupt-readiness guard. No PPS lock, UTC accuracy
or replay of masked events is claimed.

Tool-origin disclosure: Codex assisted with the driver changes, tests
and changelog using the hardware evidence, revision rule and netdev review.

Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
---
 Documentation/networking/devlink/ptp_ocp.rst |  47 +++-
 drivers/ptp/ptp_ocp.c                        | 242 +++++++++++++++++--
 2 files changed, 270 insertions(+), 19 deletions(-)

diff --git a/Documentation/networking/devlink/ptp_ocp.rst b/Documentation/networking/devlink/ptp_ocp.rst
index f94b759d9..f7e228570 100644
--- a/Documentation/networking/devlink/ptp_ocp.rst
+++ b/Documentation/networking/devlink/ptp_ocp.rst
@@ -20,8 +20,10 @@ The ``ptp_ocp`` driver reports the following versions
      - Description
    * - ``fw``
      - running
-     - Version of the firmware running on the card.  Reported as ``loader``
-       instead when the card is running the firmware loader.
+     - Version of the firmware running on the card. Where the driver can
+       distinguish a firmware loader, it reports ``loader`` instead.
+       WiWi reports the raw build ID as ``fw``; it does not identify the
+       boot slot or distinguish a fallback boot.
    * - ``board.id``
      - fixed
      - Board identifier, read from the on-card EEPROM.
@@ -54,7 +56,8 @@ selected with the component name.
      - 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.
+       exposes. Not supported on WiWi. 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
@@ -73,3 +76,41 @@ with the standard devlink status notifications.
 Example::
 
     $ devlink dev flash pci/0000:02:00.0 file adva-cpld.bin component fw.cpld
+
+WiWi production firmware
+========================
+
+WiWi Time Cards with PCI ID ``2163:1008`` and subsystem ID ``10ee:0007``
+use the PCI Revision ID to identify the register interface. The driver
+supports revision ``02`` (LitePCIe/MSI-X) and rejects unknown revisions
+before accessing FPGA registers. Incompatible interface changes require
+a new revision. The driver also checks the BAR and MSI-X layout before
+initializing the card.
+
+The image ID at BAR0 offset ``0x02020000`` identifies a firmware build,
+not the register interface. The running ``fw`` version in devlink reports
+the full image ID, for example ``0x0000800f``. Compatible builds need not
+have the same image ID or individual core versions. PCIe access to the
+CoreList is not required.
+
+WiWi reuses the peripheral layout described by the driver's shared
+resource table. Its PCI interface is distinct from that of the existing
+Celestica entry (``18d4:1008``). Only the WiWi match adds ``0x02000000``
+to peripheral offsets and requires aligned 32-bit MMIO. Interrupt input
+``n`` uses MSI-X vector ``n + 32``. The per-input enable mask is at BAR0
+offset ``0x1800``. Until the timing gate is open, attempts to arm a
+timestamp, PPS or signal generator return ``-EAGAIN`` and can be retried.
+The driver exposes neither a second GNSS serial port nor a GNSS2 SMA
+output source on this board. Neither is a supported capability inferred
+from revision 02. This does not disable the external SMA PPS2 input.
+The separate EEPROM and RGB I2C inputs (17 and 18) have no handlers in
+this driver and stay masked; these are distinct from its I2C input 7.
+
+The driver does not register the WiWi SPI flash controller, so there is
+no raw MTD device for this flash, even for reads. Its IRQ remains masked.
+WiWi firmware updates through ``devlink dev flash`` are also rejected.
+The WiWi image has a different flash header from the Celestica image.
+The golden image at flash offset zero boots the update image via MultiBoot
+with watchdog fallback. The vendor's programming path requires a modified
+``spi-xilinx`` driver. Successful clock registration does not establish
+GNSS synchronization or valid UTC.
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index decc56892..df40dac98 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -35,6 +35,22 @@
 #define PCI_VENDOR_ID_CELESTICA			0x18d4
 #define PCI_DEVICE_ID_CELESTICA_TIMECARD	0x1008
 
+#define PCI_VENDOR_ID_WIWI			0x2163
+#define PCI_DEVICE_ID_WIWI_TIMECARD		0x1008
+
+/* WiWi rev 02 translates shared peripheral offsets and interrupt inputs. */
+#define OCP_WIWI_MMIO_OFFSET			0x02000000
+#define OCP_WIWI_IRQ_OFFSET			32
+#define OCP_WIWI_MSI_ENABLE			0x1800
+/* Upper 32 bits: the three UARTs and XIIC can interrupt during probe. */
+#define OCP_WIWI_PERIPHERAL_IRQS	(BIT(3) | BIT(5) | BIT(7) | BIT(10))
+/* PPS/TS0/TS1, TS2, GEN1-4 and TS3/TS4. */
+#define OCP_WIWI_TIMING_IRQS			(GENMASK(2, 0) | BIT(6) | \
+						 GENMASK(16, 11))
+/* Do not unmask unused inputs, including the flash controller (9). */
+#define OCP_WIWI_IRQS				(OCP_WIWI_PERIPHERAL_IRQS | \
+						 OCP_WIWI_TIMING_IRQS)
+
 #define PCI_VENDOR_ID_OROLIA			0x1ad7
 #define PCI_DEVICE_ID_OROLIA_ARTCARD		0xa000
 
@@ -405,6 +421,10 @@ struct ptp_ocp {
 	struct delayed_work	sync_work;
 	int			id;
 	int			n_irqs;
+	bool			wiwi;
+	bool			wiwi_timing_ready;
+	u32			wiwi_image_id;
+	void __iomem		*wiwi_msi;
 	struct ptp_ocp_serial_port	port[__PORT_COUNT];
 	bool			fw_loader;
 	u8			fw_tag;
@@ -578,6 +598,22 @@ static struct ptp_ocp_eeprom_map art_eeprom_map[] = {
  * 15: Orolia TS4
  */
 
+static struct i2c_board_info ocp_fb_i2c_devices[] = {
+	{ I2C_BOARD_INFO("24c02", 0x50) },
+	{ I2C_BOARD_INFO("24mac402", 0x58), .platform_data = "mac" },
+};
+
+static struct ptp_ocp_i2c_info ocp_wiwi_i2c = {
+	.name = "xiic-i2c",
+	.fixed_rate = 50000000,
+	.data_size = sizeof(struct xiic_i2c_platform_data),
+	.data = &(struct xiic_i2c_platform_data) {
+		.num_devices = ARRAY_SIZE(ocp_fb_i2c_devices),
+		.devices = ocp_fb_i2c_devices,
+		.force_32bit_access = true,
+	},
+};
+
 static struct ocp_resource ocp_fb_resource[] = {
 	{
 		OCP_MEM_RESOURCE(reg),
@@ -730,12 +766,8 @@ static struct ocp_resource ocp_fb_resource[] = {
 			.fixed_rate = 50000000,
 			.data_size = sizeof(struct xiic_i2c_platform_data),
 			.data = &(struct xiic_i2c_platform_data) {
-				.num_devices = 2,
-				.devices = (struct i2c_board_info[]) {
-					{ I2C_BOARD_INFO("24c02", 0x50) },
-					{ I2C_BOARD_INFO("24mac402", 0x58),
-					  .platform_data = "mac" },
-				},
+				.num_devices = ARRAY_SIZE(ocp_fb_i2c_devices),
+				.devices = ocp_fb_i2c_devices,
 			},
 		},
 	},
@@ -1322,6 +1354,11 @@ static struct ocp_resource ocp_adva_x1_resource[] = {
 static const struct pci_device_id ptp_ocp_pcidev_id[] = {
 	{ PCI_DEVICE_DATA(META, TIMECARD, &ocp_fb_resource) },
 	{ PCI_DEVICE_DATA(CELESTICA, TIMECARD, &ocp_fb_resource) },
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_WIWI, PCI_DEVICE_ID_WIWI_TIMECARD,
+			       PCI_VENDOR_ID_XILINX, 0x0007),
+		.driver_data = (kernel_ulong_t)ocp_fb_resource,
+	},
 	{ PCI_DEVICE_DATA(OROLIA, ARTCARD, &ocp_art_resource) },
 	{ PCI_DEVICE_DATA(ADVA, TIMECARD, &ocp_adva_resource) },
 	{ PCI_DEVICE_DATA(ADVA, TIMECARD_X1, &ocp_adva_x1_resource) },
@@ -1384,6 +1421,23 @@ static const struct ocp_selector ptp_ocp_sma_out[] = {
 	{ }
 };
 
+/* No validated second receiver on the supported WiWi board. */
+static const struct ocp_selector ptp_ocp_wiwi_sma_out[] = {
+	{ .name = "10Mhz", .value = 0x0000, .frequency = 10000000 },
+	{ .name = "PHC",   .value = 0x0001, .frequency = 1 },
+	{ .name = "MAC",   .value = 0x0002, .frequency = 1 },
+	{ .name = "GNSS1", .value = 0x0004, .frequency = 1 },
+	{ .name = "IRIG",  .value = 0x0010, .frequency = 10000 },
+	{ .name = "DCF",   .value = 0x0020, .frequency = 77000 },
+	{ .name = "GEN1",  .value = 0x0040 },
+	{ .name = "GEN2",  .value = 0x0080 },
+	{ .name = "GEN3",  .value = 0x0100 },
+	{ .name = "GEN4",  .value = 0x0200 },
+	{ .name = "GND",   .value = 0x2000 },
+	{ .name = "VCC",   .value = 0x4000 },
+	{ }
+};
+
 static const struct ocp_selector ptp_ocp_art_sma_in[] = {
 	{ .name = "PPS1",	.value = 0x0001,  .frequency = 1 },
 	{ .name = "10Mhz",	.value = 0x0008,  .frequency = 1000000 },
@@ -2174,6 +2228,12 @@ ptp_ocp_devlink_flash_update(struct devlink *devlink,
 	const char *msg;
 	int err;
 
+	if (bp->wiwi) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "WiWi flash updates are not supported");
+		return -EOPNOTSUPP;
+	}
+
 	if (params->component) {
 		if (!bp->has_cpld ||
 		    strcmp(params->component, ADVA_CPLD_COMPONENT)) {
@@ -2220,7 +2280,10 @@ ptp_ocp_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req,
 	u32 id;
 
 	fw_image = bp->fw_loader ? "loader" : "fw";
-	sprintf(buf, "%d.%d", bp->fw_tag, bp->fw_version);
+	if (bp->wiwi)
+		snprintf(buf, sizeof(buf), "0x%08x", bp->wiwi_image_id);
+	else
+		sprintf(buf, "%d.%d", bp->fw_tag, bp->fw_version);
 	err = devlink_info_version_running_put(req, fw_image, buf);
 	if (err)
 		return err;
@@ -2470,6 +2533,12 @@ ptp_ocp_signal_from_perout(struct ptp_ocp *bp, int gen,
 	return ptp_ocp_signal_set(bp, gen, &s);
 }
 
+static bool ptp_ocp_timing_ready(struct ptp_ocp *bp)
+{
+	/* Pair with probe's publication after the gate readback. */
+	return !bp->wiwi || smp_load_acquire(&bp->wiwi_timing_ready);
+}
+
 static int
 ptp_ocp_signal_enable(void *priv, u32 req, bool enable)
 {
@@ -2479,6 +2548,9 @@ ptp_ocp_signal_enable(void *priv, u32 req, bool enable)
 	struct timespec64 ts;
 	int gen;
 
+	if (enable && !ptp_ocp_timing_ready(bp))
+		return -EAGAIN;
+
 	gen = ext->info->index - 1;
 
 	iowrite32(0, &reg->intr_mask);
@@ -2552,6 +2624,9 @@ ptp_ocp_ts_enable(void *priv, u32 req, bool enable)
 	struct ts_reg __iomem *reg = ext->mem;
 	struct ptp_ocp *bp = ext->bp;
 
+	if (enable && !ptp_ocp_timing_ready(bp))
+		return -EAGAIN;
+
 	if (ext == bp->pps) {
 		u32 old_map = bp->pps_req_map;
 
@@ -2641,7 +2716,7 @@ ptp_ocp_serial_line(struct ptp_ocp *bp, struct ocp_resource *r)
 	 */
 	memset(&uart, 0, sizeof(uart));
 	uart.port.dev = &pdev->dev;
-	uart.port.iotype = UPIO_MEM;
+	uart.port.iotype = bp->wiwi ? UPIO_MEM32 : UPIO_MEM;
 	uart.port.regshift = 2;
 	uart.port.mapbase = pci_resource_start(pdev, 0) + r->offset;
 	uart.port.irq = pci_irq_vector(pdev, r->irq_vec);
@@ -2944,6 +3019,14 @@ static const struct ocp_sma_op ocp_fb_sma_op = {
 	.set_output	= ptp_ocp_sma_fb_set_output,
 };
 
+static const struct ocp_sma_op ocp_wiwi_sma_op = {
+	.tbl		= { ptp_ocp_sma_in, ptp_ocp_wiwi_sma_out },
+	.init		= ptp_ocp_sma_fb_init,
+	.get		= ptp_ocp_sma_fb_get,
+	.set_inputs	= ptp_ocp_sma_fb_set_inputs,
+	.set_output	= ptp_ocp_sma_fb_set_output,
+};
+
 static int
 ptp_ocp_sma_adva_set_output(struct ptp_ocp *bp, int sma_nr, u32 val)
 {
@@ -3037,6 +3120,13 @@ ptp_ocp_fb_set_version(struct ptp_ocp *bp)
 
 	version = ioread32(&bp->image->version);
 
+	if (bp->wiwi) {
+		/* Revision 02 defines capabilities; report the build ID. */
+		bp->wiwi_image_id = version;
+		bp->fw_cap = OCP_CAP_BASIC | OCP_CAP_SIGNAL | OCP_CAP_FREQ;
+		return;
+	}
+
 	/* if lower 16 bits are empty, this is the fw loader. */
 	if ((version & 0xffff) == 0) {
 		version = version >> 16;
@@ -3069,8 +3159,7 @@ ptp_ocp_fb_board_init(struct ptp_ocp *bp, struct ocp_resource *r)
 
 	bp->flash_start = 1024 * 4096;
 	bp->eeprom_map = fb_eeprom_map;
-	bp->fw_version = ioread32(&bp->image->version);
-	bp->sma_op = &ocp_fb_sma_op;
+	bp->sma_op = bp->wiwi ? &ocp_wiwi_sma_op : &ocp_fb_sma_op;
 	bp->signals_nr = 4;
 	bp->freq_in_nr = 4;
 
@@ -3110,7 +3199,30 @@ ptp_ocp_register_resources(struct ptp_ocp *bp, kernel_ulong_t driver_data)
 	int err = 0;
 
 	table = (struct ocp_resource *)driver_data;
-	for (r = table; r->setup; r++) {
+	for (; table->setup; table++) {
+		struct ocp_resource translated = *table;
+
+		r = table;
+		if (bp->wiwi) {
+			/* Do not expose the flash through raw MTD, either. */
+			if (r->setup == ptp_ocp_register_spi)
+				continue;
+			/* The supported board has no validated GNSS2 port. */
+			if (r->setup == ptp_ocp_register_serial &&
+			    r->bp_offset == offsetof(struct ptp_ocp,
+						    port[PORT_GNSS2]))
+				continue;
+			/* Leave the shared resource table unchanged. */
+			if (translated.offset)
+				translated.offset += OCP_WIWI_MMIO_OFFSET;
+			if (r->setup == ptp_ocp_register_i2c)
+				translated.extra = &ocp_wiwi_i2c;
+			if (r->setup == ptp_ocp_register_ext ||
+			    r->setup == ptp_ocp_register_serial ||
+			    r->setup == ptp_ocp_register_i2c)
+				translated.irq_vec += OCP_WIWI_IRQ_OFFSET;
+			r = &translated;
+		}
 		if (!ptp_ocp_allow_irq(bp, r))
 			continue;
 		err = r->setup(bp, r);
@@ -3394,6 +3506,8 @@ ptp_ocp_sma_show(struct ptp_ocp *bp, int sma_nr, char *buf,
 		return ptp_ocp_show_inputs(tbl[0], val, buf, default_in_val);
 	}
 
+	if (bp->wiwi && !ptp_ocp_select_name_from_val(tbl[1], val))
+		return sysfs_emit(buf, "OUT: unavailable\n");
 	return ptp_ocp_show_output(tbl[1], val, buf, default_out_val);
 }
 
@@ -5455,7 +5569,7 @@ ptp_ocp_summary_show(struct seq_file *s, void *data)
 	}
 	seq_printf(s, "MAC PPS1 src: %s\n", mac_src);
 
-	gpio_input_map(buf, bp, sma_val, 1, "GNSS2");
+	gpio_input_map(buf, bp, sma_val, 1, bp->wiwi ? NULL : "GNSS2");
 	seq_printf(s, "MAC PPS2 src: %s\n", buf);
 
 	/* assumes automatic switchover/selection */
@@ -5787,6 +5901,12 @@ ptp_ocp_detach(struct ptp_ocp *bp)
 	platform_device_unregister(bp->i2c_ctrl);
 	if (bp->i2c_clk)
 		clk_hw_unregister_fixed_rate(bp->i2c_clk);
+	/* Keep child interrupts available until the children are gone. */
+	if (bp->wiwi_msi) {
+		iowrite32(0, bp->wiwi_msi);
+		iowrite32(0, bp->wiwi_msi + 4);
+		ioread32(bp->wiwi_msi);
+	}
 	if (bp->n_irqs)
 		pci_free_irq_vectors(bp->pdev);
 	mutex_destroy(&bp->cpld_lock);
@@ -5881,9 +6001,14 @@ static int ptp_ocp_dpll_frequency_set(const struct dpll_pin *pin,
 		return -EOPNOTSUPP;
 
 	tbl = bp->sma_op->tbl[sma->mode];
-	for (i = 0; tbl[i].name; i++)
-		if (tbl[i].frequency == frequency)
-			return ptp_ocp_sma_store_val(bp, i, sma->mode, sma_nr + 1);
+	for (i = 0; tbl[i].name; i++) {
+		if (tbl[i].frequency == frequency) {
+			int val = bp->wiwi ? tbl[i].value : i;
+
+			return ptp_ocp_sma_store_val(bp, val, sma->mode,
+						     sma_nr + 1);
+		}
+	}
 	return -EINVAL;
 }
 
@@ -5901,6 +6026,8 @@ static int ptp_ocp_dpll_frequency_get(const struct dpll_pin *pin,
 	int i;
 
 	val = bp->sma_op->get(bp, sma_nr + 1);
+	if (bp->wiwi)
+		val &= SMA_SELECT_MASK;
 	tbl = bp->sma_op->tbl[sma->mode];
 	for (i = 0; tbl[i].name; i++)
 		if (val == tbl[i].value) {
@@ -5952,6 +6079,49 @@ ptp_ocp_sync_work(struct work_struct *work)
 	queue_delayed_work(system_power_efficient_wq, &bp->sync_work, HZ);
 }
 
+/* The PCI revision identifies the register interface, not the FPGA build. */
+static int ptp_ocp_wiwi_validate(struct pci_dev *pdev)
+{
+	u32 table, pba;
+	int cap;
+
+	if (pdev->revision != 0x02)
+		return dev_err_probe(&pdev->dev, -ENODEV,
+				     "Unsupported WiWi PCI revision 0x%02x\n",
+				     pdev->revision);
+
+	cap = pci_find_capability(pdev, PCI_CAP_ID_MSIX);
+	if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM) ||
+	    pci_resource_len(pdev, 0) != 0x04000000 || !cap ||
+	    pci_msix_vec_count(pdev) != 64 ||
+	    pci_read_config_dword(pdev, cap + PCI_MSIX_TABLE, &table) ||
+	    pci_read_config_dword(pdev, cap + PCI_MSIX_PBA, &pba) ||
+	    table != 0x2000 || pba != 0x1808)
+		return dev_err_probe(&pdev->dev, -ENODEV,
+				     "Unsupported WiWi PCI layout\n");
+
+	return 0;
+}
+
+static int ptp_ocp_wiwi_irq_init(struct ptp_ocp *bp)
+{
+	void __iomem *msi;
+
+	msi = __ptp_ocp_get_mem(bp, pci_resource_start(bp->pdev, 0) +
+			      OCP_WIWI_MSI_ENABLE, 8);
+	if (IS_ERR(msi))
+		return PTR_ERR(msi);
+	bp->wiwi_msi = msi;
+
+	/* LiteX stores bits 63:32 before bits 31:0, as little-endian words. */
+	iowrite32(0, msi);
+	iowrite32(0, msi + 4);
+	if (ioread32(msi) || ioread32(msi + 4))
+		return -EIO;
+
+	return 0;
+}
+
 static int
 ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
@@ -5960,6 +6130,13 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	int err, i;
 	u64 clkid;
 
+	/* Dynamic IDs must not override the WiWi board's resource table. */
+	if (pdev->vendor == PCI_VENDOR_ID_WIWI) {
+		id = pci_match_id(ptp_ocp_pcidev_id, pdev);
+		if (!id)
+			return -ENODEV;
+	}
+
 	devlink = devlink_alloc(&ptp_ocp_devlink_ops, sizeof(*bp), &pdev->dev);
 	if (!devlink) {
 		dev_err(&pdev->dev, "devlink_alloc failed\n");
@@ -5973,6 +6150,13 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	}
 
 	bp = devlink_priv(devlink);
+	bp->wiwi = id->vendor == PCI_VENDOR_ID_WIWI;
+	if (bp->wiwi) {
+		/* Validate before IRQ setup, bus mastering or FPGA writes. */
+		err = ptp_ocp_wiwi_validate(pdev);
+		if (err)
+			goto out_disable;
+	}
 	err = ptp_ocp_device_init(bp, pdev);
 	if (err)
 		goto out_disable;
@@ -5988,18 +6172,33 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	INIT_DELAYED_WORK(&bp->sync_work, ptp_ocp_sync_work);
 
+	if (bp->wiwi) {
+		err = ptp_ocp_wiwi_irq_init(bp);
+		if (err)
+			goto out;
+	}
+
 	/* compat mode.
 	 * Older FPGA firmware only returns 2 irq's.
 	 * allow this - if not all of the IRQ's are returned, skip the
 	 * extra devices and just register the clock.
 	 */
-	err = pci_alloc_irq_vectors(pdev, 1, 17, PCI_IRQ_MSI | PCI_IRQ_MSIX);
+	if (bp->wiwi)
+		err = pci_alloc_irq_vectors(pdev, 49, 64, PCI_IRQ_MSIX);
+	else
+		err = pci_alloc_irq_vectors(pdev, 1, 17,
+					    PCI_IRQ_MSI | PCI_IRQ_MSIX);
 	if (err < 0) {
 		dev_err(&pdev->dev, "alloc_irq_vectors err: %d\n", err);
 		goto out;
 	}
 	bp->n_irqs = err;
 	pci_set_master(pdev);
+	/* Only the UART and XIIC inputs may interrupt during probe. */
+	if (bp->wiwi_msi) {
+		iowrite32(OCP_WIWI_PERIPHERAL_IRQS, bp->wiwi_msi);
+		ioread32(bp->wiwi_msi);
+	}
 
 	err = ptp_ocp_register_resources(bp, id->driver_data);
 	if (err)
@@ -6048,6 +6247,17 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 			goto out_dpll;
 		}
 	}
+	/* All handlers and the PHC are ready for timestamp interrupts. */
+	if (bp->wiwi_msi) {
+		iowrite32(OCP_WIWI_IRQS, bp->wiwi_msi);
+		if (ioread32(bp->wiwi_msi) != OCP_WIWI_IRQS) {
+			err = dev_err_probe(&pdev->dev, -EIO,
+					    "WiWi interrupt gate did not open\n");
+			goto out_dpll;
+		}
+		/* Publish readiness to the timestamp and generator enablers. */
+		smp_store_release(&bp->wiwi_timing_ready, true);
+	}
 	queue_delayed_work(system_power_efficient_wq, &bp->sync_work, HZ);
 
 	return 0;
Technical Details
Message-ID: <20261116-wiwi-v3-87afa10a8-3-ahmadexp@gmail.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364616-linux-kernel-netdev=dewy.ru
References: <20261116-wiwi-v3-87afa10a8-0-ahmadexp@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364616-linux-kernel-netdev=dewy.ru
From: ahmadexp@gmail.com (Ahmad Byagowi)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v3 3/3] ptp: ocp: support the WiWi revision 02 Time Card
Date: Mon, 16 Nov 2026 10:20:55 -0800
Organization: Usenet Network
Message-ID: <20261116-wiwi-v3-87afa10a8-3-ahmadexp@gmail.com>
References: <20261116-wiwi-v3-87afa10a8-0-ahmadexp@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2135006"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:IpQkGcJwkF/LrhbVQP59b3bUK5E= sha256:JB0HEOifRzxbV5UHPrukyuqpAJMnTV6KTbHqmzVl27U=
	sha1:B10wyQ+CdoKsmlouI6DXCxMWMy8= sha256:zb4yNhReRx2NPmFn5WkmPyJNWKF8KS6of3tQbQcck2w=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 1A282114D23; Mon, 16 Nov 2026 21:21:18 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id oDf-BOkB-1OC;
	Mon, 16 Nov 2026 21:21:14 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-364616-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id C2180114D1F; Mon, 16 Nov 2026 21:21:05 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 5903529B4C; Mon, 16 Nov 2026 18:21:04 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794853263;
	b=p4YfsUIMcEMPs17ZibM6/j/h1cZ/fi/fTwacqu70clKwPkU1TDi6teV+0/c2jvTzpnxO
	 Tp1AumGwPFtGLTlngCE+fJvsUSUOQUmAHkVji/l8MW8+kjz9Aspk7TGhtL1Mj9VmFgjJs
	 ZEZNjwxaxf2vN48pzWNbUbeLNS5SKBJ6lcr1m+0c7uPGTbIfCAeyi/qWvTyXRgIM7qk0S
	 TyD9ejN92p/PKGIOm0BoHGwubzUkLL787jevFgA1enkB/gq7DlDl5ufoqCaB4ufHesou7
	 c+1bnGMU4RNnaBVYadRqENYFaIduvcHTBSv+XqmTIWP06+GK38IfUr4Eu1A0o+X9oCw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794853263;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
	 References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=Y8vKeC4ApgPKvtb5f83QUWlYjNGKfo0MCQ1lCHmqkXo=;
	b=kujxifz7E0dD1dDjWxcxR2WBtUCfLNXN1MLjMxWY2RK9q/tYYOuyr3GR3J7O0xDDirSJ
	 1YQpcPQXePTdaj6WQPhY8OimvTUg+yUJcl/38TcikJj53wtrmpcqNMw0Z0J5nimg1Y8Jt
	 uicHzQgdmKypbzrmvSvYuFeByTlLiczamDXh/BSKsDcALrhewmpJrClNmPdzJjj6J3Acn
	 zeDzpIod9OuIE18mg44TjUodLKxTdEv1M8wukcUyQowBHAbW6qBzKGsFLLY2NxvK0nb/o
	 b/h7cZLF2b6uZCszwX9ruae8hYhdqnXQu6RCDo8Di6O/8P5i2ZbXph+Y12HiXeALyWA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=V8fzeRKe;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 8714D606A881;
	Mon, 16 Nov 2026 18:21:03 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=V8fzeRKe
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.48
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794853262;
	b=2lLYTwtS4Wx7chIUsc649cngAc+iiW6VsCvC4AAoqPPpXYz0Acquyzs7axnJyFLg6IIm
	 MY1q2LodY00PQNTOenfe1b+zKtQj+XX+MbjnNRnWIgKJau9td66+uEOkUU6YYta9rHrQn
	 vHeBNzgak9wTvyxYnmbzs24t8UTnBS0jeeQaHzhaWO+HOm/tRj4jJJUVxlw/u/FhkMOQw
	 UMWJgxML3nHcPqQSYdDx0AtCzcikAXf1tIWjCnvVAbc/JSjbkVpWigGZGN358ktFSA1nl
	 AJcbFY/ldHkxg3m4dnMJ6RZ/IMVSBM/WX2NF7oZ4pu8c34cIXmKdLuMcRYTR4Mxkf9g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794853262;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding;
	bh=Y8vKeC4ApgPKvtb5f83QUWlYjNGKfo0MCQ1lCHmqkXo=;
	b=ZVuGLsBlfuhEr5uf7howy4VuFYdqIX06OsvcjfUapc5mF+I1HZN49caBuO1AhDzRD7sq
	 cSQnOa2LTwsAAT7FzjsK4pBCecLjRU4Gmvg/Ph1WG2U1Z6TrsYMJ37VZfiRDYmBQWSCB3
	 qmVYCBIhFZPPCI1QGWq87IYh0oy1Ob1UZvDbIMrxAB8MclPD/DHevIAOYUtw0au6u/oBW
	 H9iig3MepUA3fo0Isfm/7QdizxPA2DGQ9CMNSCxLDD8SJdOvjDniByj8QSPQH+kCxz2Sr
	 zwRuqLbPT+Pa9i/SgrlfW9Itl5EfvLuEXGqirhLB+WQ7Vfzf8FWpSAxUpF1VpItbbqg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=V8fzeRKe;
	arc=none smtp.remote-ip=209.85.216.48
X-Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CE3A606A31C
	for <netdev@vger.kernel.org>; Mon, 16 Nov 2026 18:21:01 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0CE3A606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-3ada4c06b7bso2003633a91.2
        for <netdev@vger.kernel.org>; Mon, 16 Nov 2026 10:21:01 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1794853261; x=1795458061; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=Y8vKeC4ApgPKvtb5f83QUWlYjNGKfo0MCQ1lCHmqkXo=;
        b=V8fzeRKe0oGo4rCimiTi77vYt3tRjLJfLRD0yqtNjjKqHb46isoCWjVaN3hPDdRBdK
         uX+tem2ioLtwU3pS59aB9cBxZMFG9p6O0HTDNvRVUBVKVOq4SvyyS/UnFO5cETI1PBg5
         WrB1DUYRCTuDzXUPW9NtfKoMcxFZcTwzjcyonec4i1lV9mQ7mUoLkqku3UBkhBzQEBtu
         km1VkK6tN+UnVPsNwGsb4xpREqD8hXCk8+qMs32/4Xmu/30CzcSwOd1e7kN3WN7r0kbs
         xwgxR7P090HtmF5hr1Pw1b+zCu+I8sbmVzld0EPIM4Wz5VbFghXxGaHDHMi6eUFgW2Zi
         IWHQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1794853261; x=1795458061;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
         :to:cc:subject:date:message-id:reply-to:content-type;
        bh=Y8vKeC4ApgPKvtb5f83QUWlYjNGKfo0MCQ1lCHmqkXo=;
        b=BjUyZqwrWKJSWf6cNnW0JrU3wPZ8eRHDyhasMA5kAB7NB9z2U0Set5j7LcKjpHTGX4
         FXc6gqQ1CaiYi93CdEM0r5IWREuSHCQti+YUkG06ltwLPdz2SI7J5ixHR0VAD/tyFzn/
         b4Gj8ChxvSiygkQfekbuMWB2rNHkr9Bi3U/M/iK/IrAYNYnybNmoTyYX1WHoNs1yyXL2
         LIlYmq4tnWcy/As/R3aB0QpLNlRKsW5B7kI3cfGvdw6FdvBZuy78edZCIdOQW72+n9xZ
         i/pEw339W5lZ+p3SJ5iVql5ITmeHouTtWOL8CT0Fn0ZE7o8qP8mVwnU6LZsL+hnKPTJ1
         QdmA==
X-Gm-Message-State: APuU4Z9PUqyqdCmZmmNF5VIfENJHl7mmVK/S3phsRkHoH20brV9gbCGN
	NissodQfNMiXykGJDIirL4j9JKZpuso213Bqyr3iGcFi0pPUovscl62p98RvPWDB
X-Gm-Gg: AZFdTZfPicA5bavH+yLwE/2xADTLFhkPN47KJtZ7Az7txO65k7AWXzq/roeMFuqywbP
	S/dupPk2GWrWcb6XB7hZ18q8/4TRf/gmTYxoTxmIihCBHXP/MVN3jpwPNGjmvAgSAYMVLLYI9UF
	Z3c/ysiaXd7wHS5sUhDnkBsbRz8VtGd/A6+Q6LuAJ4ADKfcpPYI6VDePeQ2XLt17YH0qhgOOtrE
	ZBMZLuyefdZquMMqmxt3PMf/EHT2w/PmkjVzK159eQkOc7aOwRHc63rybphoQYp+i5sUbccl11W
	9GfBtGfhKTXB2EWtl6KJQ3dPUBsZdtBnIiG3WhfmWco92gMqHOpLLU1k+XhKwx3y01qOpdipnU6
	JrsmE8YH7p15VJVrGzHTbGfezaH6cM/DMixzXZapI7v0H7wNwYMj2LXxNRn5ezoRxlYaKqA4QIl
	sJtk5OJSCezODIaJyFr4ZeaPQnjjUkJkvmT/2eF/DBKEiCk9hqPdm05VKU4R/397PLG7Nj/Ea6P
	9eCDI5wE5GXfQx6Th6O7s0qgmsv6+sW4OunMFX7q71w6klnwZ+bOBLeRHCLFknXKx+P1DYjNPLh
	v2tqfmDawqBEaNULA+ktaWFYw9dPOSGk0tU1DwkqcZNmeZhnDshjoZpDhheHRIZ80PhKVWM/sMX
	gvWCtmeWjVtXRiOBqZyfK91TgebFuNL3DXnwdpD+sTbr9cVFnw4lKWCeR13E=
X-Received: by 2002:a17:90b:548d:b0:3ac:7c52:faeb with SMTP id 98e67ed59e1d1-3b1b0b836femr11432251a91.41.1794853261056;
        Mon, 16 Nov 2026 10:21:01 -0800 (PST)
X-Received: from localhost.localdomain ([12.162.234.74])
        by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b1b1e9ef15sm10002360a91.0.2026.11.16.10.20.57
        (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
        Mon, 16 Nov 2026 10:20:58 -0800 (PST)
X-Cc: andrew+netdev@lunn.ch,
	corbet@lwn.net,
	davem@davemloft.net,
	edumazet@kernel.org,
	horms@kernel.org,
	jiri@resnulli.us,
	kuba@kernel.org,
	linux-doc@vger.kernel.org,
	linux-i2c@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	pabeni@redhat.com,
	rdunlap@infradead.org,
	richardcochran@gmail.com,
	skhan@linuxfoundation.org
X-Mailer: git-send-email 2.54.0
X-In-Reply-To: <20261116-wiwi-v3-87afa10a8-0-ahmadexp@gmail.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list