From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.231 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796298329; b=aVTDm1CLzLcq8pB6ASHXqQ74kfNxo6kNR2qMDYSlI631tCPoR56N7bBkwIwStVWsB5nX g6bfNdLujodXgn/u/26rtrBJbmCtg2whOqlh0NchsNiRsmFKyGWnUqBIwkqziM1rFXTf5 gigMAHe3Vl4QAxWsOjNMrwwO7eegCn8AJVdcqMZ94ESOmqoXbOPqYKAgM9SWxZDGaFc7J kWAFfgLwH3wd0KyRpgfb0w1CZolchc6f5WEnO5yFx+CFy3iPyfIciHH0kl6zT98U5SHTS wLdXbcsqOiJXJuTK1ZMTcBmmTBHhppgrYnc2SRAkR++dvCrGUc4S+Epe3ljn4CYCJhQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796298329; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=P1ehCqsfvp/LtddSRQmMYKp2YpHiABDoFWiHsnrqbDM=; b=ve0NcRO/UMYgwpjCbe4/9M3vvzlDqowM0Am+5WcxI36uQrAl4N+FQYxozas5a9OwcW2Z SQHt9L6iNlkoLNKMY+9TZdCZLmK+4z7mnwKJJpkS6J+EMcNzgDhMCEidtSwOQjFaqFDxv RLP09lBLke8ukpnnJRqr2R2NXUZbU0U6N2Gm9qxLq63PEviAh/J1Wo8Gg3KltX2Z4TySk FXAaH6b0aNeEJ9H1QVHq2yL2CtpJhIoJqNIWXXBHojp3C5bkgb0lGgYTRdvPYRsxalMpg MSosLjl9gY7TgkcU9KLWc3JyPtGmJB1pE3yBNJ6VdnBX74oJ4gKvQ0vvs3l2x8IwMow== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=ShvmoiFk; arc=none smtp.remote-ip=91.218.175.231 Received: from mta0.migadu.com (out-231.mta0.migadu.com [91.218.175.231]) (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 92C26606A330 for ; Thu, 3 Dec 2026 11:45:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 92C26606A330 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=ShvmoiFk X-Envelope-To: linux-doc@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=wh5PKeBvufOxq/U0xBLwvD0l/BMr+P+Eu08kAOmmlP0=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796298326; v=1; x=1796903126; b=ShvmoiFkin4ysvX8IzK2BgowdkSu0MjxYpy+4HzhTyOrfBFXST5Zp4ymApuBA/WNuZHXTMeN hbbooBJPgLTYyq2byg+kk+LH6oI7uusxzoDBcGf2YHo2szZmyxahXFRla4y+Dla0V4FIMWFsENf LbxCvkeJqGAWOAPtD6OK9dU0= X-Envelope-To: linux-doc@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 9ef596c5f6093539; Thu, 03 Dec 2026 11:45:23 +0000 X-Mizu-Trace-ID: 9ef596c5f6093539 X-Migadu-Flow: FLOW_OUT Message-ID: <096aeb5e-951a-4e66-a664-520c70b67b93@linux.dev> Date: Thu, 3 Dec 2026 11:45:21 +0000 X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next] ptp: ocp: add support for the ADVA TimeCard X2 To: Sagi Maimon , netdev@vger.kernel.org Cc: richardcochran@gmail.com, jiri@resnulli.us, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, willemb@google.com, corbet@lwn.net, skhan@linuxfoundation.org, rdunlap@infradead.org, linux-doc@vger.kernel.org References: <20261130143150.326311-1-maimon.sagi@gmail.com> Content-Language: en-US From: Vadim Fedorenko In-Reply-To: <20261130143150.326311-1-maimon.sagi@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 30/11/2026 14:31, Sagi Maimon wrote: > The ADVA TimeCard X2 (PCI ID ad5a:0420) keeps the PPS timestamper, the > NMEA serial port, the I2C controller with the board EEPROMs and the TAP > CPLD of the X1. It has no signal generators or frequency counters, its > firmware rather than the host keeps the clock's time of day on GNSS, its > FPGA image is not updated from the host, and its two SMA connectors are > internal to the card, out of the user's reach. > > Add a resource table for it on top of ptp_ocp_adva_board_init(), with: > > - no TOD block, since the firmware sets the time of day; > - no SMA op, since there are no connectors to configure; > - no SPI flash, since there is no FPGA image to write; > - a reduced attribute group: serial number, GNSS sync and CPLD status; > - has_cpld set, so the CPLD is identified and can be flashed through > devlink as on the X1. > - osa_version set: the image version register carries the release > and build of the card's OSA software instead of the X1 layout - > bit 31 marks the loader, bits 23:16 hold the release and bits 15:0 > the build - and devlink reports it as .. > > Every board so far has a TOD block, SMA connectors and an FPGA flash, so > allow all three to be absent. ptp_ocp_tod_init() dereferenced bp->tod > unconditionally; it now returns early when there is no TOD block. When > sma_op is unset, ptp_ocp_adva_board_init() sets up no PTP pins and no > SMA state, probe registers the dpll device without pins, and the debugfs > summary neither prints SMA lines nor names an SMA as a signal source. > When there is no SPI flash, a devlink flash update without a component > fails with -EOPNOTSUPP, rather than letting ptp_ocp_find_flash() walk > the children of an invalid pointer derived from the NULL spi_flash. The > CPLD component is unaffected, and all other boards have all three and > are unaffected. > > Update the devlink documentation to match: the CPLD versions and the > fw.cpld component now apply to the X2 as well, a flash update without > a component is not supported there, and the fw version is the OSA > software release and build. > > The card also carries an AXI Ethernet MAC, which is added separately. > > Tested on an ADVA TimeCard X2 with FPGA image 136.1089: the card > probes, devlink reports the board, firmware and CPLD versions, read > from the EEPROMs and the CPLD, and phc2sys tracks its PTP clock. > > Assisted-by: LLM sparse > Signed-off-by: Sagi Maimon > --- > Documentation/networking/devlink/ptp_ocp.rst | 30 +-- > drivers/ptp/ptp_ocp.c | 182 ++++++++++++++++--- > 2 files changed, 172 insertions(+), 40 deletions(-) > > diff --git a/Documentation/networking/devlink/ptp_ocp.rst b/Documentation/networking/devlink/ptp_ocp.rst > index f94b759d9cd6..36c4104662cf 100644 > --- a/Documentation/networking/devlink/ptp_ocp.rst > +++ b/Documentation/networking/devlink/ptp_ocp.rst > @@ -21,15 +21,17 @@ The ``ptp_ocp`` driver reports the following versions > * - ``fw`` > - running > - Version of the firmware running on the card. Reported as ``loader`` > - instead when the card is running the firmware loader. > + instead when the card is running the firmware loader. On ADVA > + TimeCard X2 boards it is the release and build of the card's OSA > + software, as ``.``. > * - ``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 > + Only present on ADVA TimeCard X1 and X2 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 > @@ -54,17 +56,19 @@ 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. The card runs the new image after its next reset. Not > + supported on ADVA TimeCard X2 boards, whose FPGA image is not > + updated from the host; the request fails with ``EOPNOTSUPP``. > * - ``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. > + - The configuration flash of the TAP CPLD on ADVA TimeCard X1 and X2 > + 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 > diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c > index decc56892059..f88939a3e932 100644 > --- a/drivers/ptp/ptp_ocp.c > +++ b/drivers/ptp/ptp_ocp.c > @@ -41,6 +41,7 @@ > #define PCI_VENDOR_ID_ADVA 0xad5a > #define PCI_DEVICE_ID_ADVA_TIMECARD 0x0400 > #define PCI_DEVICE_ID_ADVA_TIMECARD_X1 0x0410 > +#define PCI_DEVICE_ID_ADVA_TIMECARD_X2 0x0420 > > static struct class timecard_class = { > .name = "timecard", > @@ -81,7 +82,7 @@ struct ptp_ocp_servo_conf { > /* > * Combined servo + board-variant parameters for ADVA boards. > * Embedded in the resource table .extra so a single ptp_ocp_adva_board_init() > - * can handle both ADVA and ADVA-X1 without per-variant init functions. > + * can handle ADVA, ADVA-X1 and ADVA-X2 without per-variant init functions. > */ > struct ptp_ocp_adva_info { > struct ptp_ocp_servo_conf servo; > @@ -92,6 +93,8 @@ struct ptp_ocp_adva_info { > const struct ocp_attr_group *attr_groups; > /* x1: TAP CPLD present */ > bool has_cpld; > + /* x2: image version in the OSA software format */ > + bool osa_version; > }; > > #define OCP_CTRL_ENABLE BIT(0) > @@ -170,7 +173,7 @@ struct gpio_reg { > u32 gpio1; > u32 __pad0; > u32 gpio2; > - /* adva_x1: I2C bus ownership register; reserved on other variants */ > + /* adva_x1/x2: I2C bus ownership register; reserved on other variants */ > u32 i2c_bus_ctrl; > }; > > @@ -499,6 +502,7 @@ static const struct ocp_attr_group art_timecard_groups[]; > static const struct ocp_attr_group adva_timecard_groups[]; > > static const struct ocp_attr_group adva_timecard_x1_groups[]; > +static const struct ocp_attr_group adva_timecard_x2_groups[]; > > struct ptp_ocp_eeprom_map { > u16 off; > @@ -1319,12 +1323,91 @@ static struct ocp_resource ocp_adva_x1_resource[] = { > { } > }; > > +static struct ocp_resource ocp_adva_x2_resource[] = { > + { > + OCP_MEM_RESOURCE(reg), > + .offset = 0x01000000, .size = 0x10000, > + }, > + { > + OCP_MEM_RESOURCE(pps_to_clk), > + .offset = 0x01040000, .size = 0x10000, > + }, > + { > + /* > + * PPS timestamper. X2 exposes no external timestampers, but > + * this block is what raises the per-second interrupt behind > + * PTP_ENABLE_PPS, so /dev/ppsN stays silent without it. > + */ > + OCP_EXT_RESOURCE(pps), > + .offset = 0x010C0000, .size = 0x10000, .irq_vec = 0, > + .extra = &(struct ptp_ocp_ext_info) { > + .index = 5, > + .irq_fcn = ptp_ocp_ts_irq, > + .enable = ptp_ocp_ts_enable, > + }, > + }, > + { > + OCP_MEM_RESOURCE(image), > + .offset = 0x00020000, .size = 0x1000, > + }, > + { > + /* > + * The gpio_reg block. X2 has no SMA routing to configure, but > + * the window's i2c_bus_ctrl word carries the MicroBlaze I2C > + * bus-ownership handshake that CPLD access needs; see > + * adva_x1_bus_claim(). The X2 FPGA places it at 0x70000 > + * rather than at 0x130000 as on the other ADVA boards. > + */ > + OCP_MEM_RESOURCE(pps_select), > + .offset = 0x00070000, .size = 0x1000, > + }, > + { > + OCP_SERIAL_RESOURCE(port[PORT_NMEA]), > + .offset = 0x00190000 + 0x1000, .irq_vec = 10, > + }, > + { > + OCP_I2C_RESOURCE(i2c_ctrl), > + .offset = 0x00150000, .size = 0x10000, .irq_vec = 7, > + .extra = &(struct ptp_ocp_i2c_info) { > + .name = "xiic-i2c", > + .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" }, > + }, > + }, > + }, > + }, > + { > + .setup = ptp_ocp_adva_board_init, > + .extra = &(struct ptp_ocp_adva_info) { > + .servo = { > + .servo_offset_p = 0xc000, > + .servo_offset_i = 0x1000, > + .servo_drift_p = 0, > + .servo_drift_i = 0, > + }, > + .signals_nr = 0, > + .freq_in_nr = 0, > + .attr_groups = adva_timecard_x2_groups, > + .has_cpld = true, > + .osa_version = true, > + }, > + }, > + { } > +}; > + > 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_DATA(OROLIA, ARTCARD, &ocp_art_resource) }, > { PCI_DEVICE_DATA(ADVA, TIMECARD, &ocp_adva_resource) }, > { PCI_DEVICE_DATA(ADVA, TIMECARD_X1, &ocp_adva_x1_resource) }, > + { PCI_DEVICE_DATA(ADVA, TIMECARD_X2, &ocp_adva_x2_resource) }, > { } > }; > MODULE_DEVICE_TABLE(pci, ptp_ocp_pcidev_id); > @@ -1933,6 +2016,12 @@ ptp_ocp_tod_init(struct ptp_ocp *bp) > { > u32 ctrl, reg; > > + /* The X2 maps no TOD block: its firmware keeps the clock's time of > + * day on GNSS. > + */ > + if (!bp->tod) > + return; > + > ctrl = ioread32(&bp->tod->ctrl); > ctrl |= TOD_CTRL_PROTOCOL | TOD_CTRL_ENABLE; > ctrl &= ~(TOD_CTRL_DISABLE_FMT_A | TOD_CTRL_DISABLE_FMT_B); > @@ -2189,6 +2278,11 @@ ptp_ocp_devlink_flash_update(struct devlink *devlink, > return err; > } > > + if (!bp->spi_flash) { > + NL_SET_ERR_MSG_MOD(extack, "FPGA image update not supported"); > + return -EOPNOTSUPP; > + } > + > dev = ptp_ocp_find_flash(bp); > if (!dev) { > dev_err(&bp->pdev->dev, "Can't find Flash SPI adapter\n"); > @@ -3271,13 +3365,20 @@ ptp_ocp_adva_board_init(struct ptp_ocp *bp, struct ocp_resource *r) > bp->freq_in_nr = info->freq_in_nr; > > version = ioread32(&bp->image->version); > - /* if lower 16 bits are empty, this is the fw loader. */ > - if ((version & 0xffff) == 0) { > - version = version >> 16; > - bp->fw_loader = true; > + if (info->osa_version) { > + /* OSA: bit 31 loader, bits 23:16 release, bits 15:0 build */ > + bp->fw_loader = !!(version & BIT(31)); > + bp->fw_tag = (version >> 16) & 0xff; originally, the idea was to use fw_tag as non-iterleaving manufacturing release version. with this change you make it variable and possibly clashing with previous versions. please, keep it static, either 3 or 4 as it's a new board. > + bp->fw_version = version & 0xffff; > + } else { > + /* if lower 16 bits are empty, this is the fw loader. */ > + if ((version & 0xffff) == 0) { > + version = version >> 16; > + bp->fw_loader = true; > + } > + bp->fw_tag = 3; > + bp->fw_version = version & 0xffff; > } > - bp->fw_tag = 3; > - bp->fw_version = version & 0xffff; > bp->fw_cap = OCP_CAP_BASIC | OCP_CAP_SIGNAL | OCP_CAP_FREQ; you have to change capabilities as well as new board doesn't have signal generators (OCP_CAP_SIGNAL) > > ptp_ocp_tod_init(bp); > @@ -3288,10 +3389,13 @@ ptp_ocp_adva_board_init(struct ptp_ocp *bp, struct ocp_resource *r) > if (err) > return err; > > - err = ptp_ocp_set_pins(bp); > - if (err) > - return err; > - ptp_ocp_sma_init(bp); > + /* boards without user-accessible SMA connectors have no sma_op */ > + if (bp->sma_op) { > + err = ptp_ocp_set_pins(bp); > + if (err) > + return err; > + ptp_ocp_sma_init(bp); > + } > > bp->has_cpld = info->has_cpld; > > @@ -5180,13 +5284,35 @@ static const struct ocp_attr_group adva_timecard_x1_groups[] = { > { }, > }; > > +/* > + * X2 exposes the basic identity attributes plus the TAP CPLD status. It > + * has no user-accessible SMA connectors, signal generators or frequency > + * inputs, so none of the SMA, signal or freq groups apply. > + */ > +static struct attribute *adva_timecard_x2_attrs[] = { > + &dev_attr_serialnum.attr, > + &dev_attr_gnss_sync.attr, > + &dev_attr_cpld_status.attr, > + NULL, > +}; > + > +static const struct attribute_group adva_timecard_x2_group = { > + .attrs = adva_timecard_x2_attrs, > +}; > + > +static const struct ocp_attr_group adva_timecard_x2_groups[] = { > + { .cap = OCP_CAP_BASIC, .group = &adva_timecard_x2_group }, > + { .cap = OCP_CAP_BASIC, .group = &ptp_ocp_timecard_tty_group }, > + { }, > +}; > + > static void > gpio_input_map(char *buf, struct ptp_ocp *bp, u16 map[][2], u16 bit, > const char *def) > { > int i; > > - for (i = 0; i < 4; i++) { > + for (i = 0; bp->sma_op && i < 4; i++) { I would prefer early exit based on sma_op pointer rather than useless iterations > if (bp->sma[i].mode != SMA_MODE_IN) > continue; > if (map[i][0] & (1 << bit)) { > @@ -5206,7 +5332,7 @@ gpio_output_map(char *buf, struct ptp_ocp *bp, u16 map[][2], u16 bit) > int i; > > strcpy(ans, "----"); > - for (i = 0; i < 4; i++) { > + for (i = 0; bp->sma_op && i < 4; i++) { > if (bp->sma[i].mode != SMA_MODE_OUT) > continue; > if (map[i][1] & (1 << bit)) > @@ -5316,21 +5442,23 @@ ptp_ocp_summary_show(struct seq_file *s, void *data) > sma_val[1][1] = reg >> 16; > } > > - sma1_show(dev, NULL, buf); > - seq_printf(s, " sma1: %04x,%04x %s", > - sma_val[0][0], sma_val[0][1], buf); > + if (bp->sma_op) { > + sma1_show(dev, NULL, buf); > + seq_printf(s, " sma1: %04x,%04x %s", > + sma_val[0][0], sma_val[0][1], buf); > > - sma2_show(dev, NULL, buf); > - seq_printf(s, " sma2: %04x,%04x %s", > - sma_val[1][0], sma_val[1][1], buf); > + sma2_show(dev, NULL, buf); > + seq_printf(s, " sma2: %04x,%04x %s", > + sma_val[1][0], sma_val[1][1], buf); > > - sma3_show(dev, NULL, buf); > - seq_printf(s, " sma3: %04x,%04x %s", > - sma_val[2][0], sma_val[2][1], buf); > + sma3_show(dev, NULL, buf); > + seq_printf(s, " sma3: %04x,%04x %s", > + sma_val[2][0], sma_val[2][1], buf); > > - sma4_show(dev, NULL, buf); > - seq_printf(s, " sma4: %04x,%04x %s", > - sma_val[3][0], sma_val[3][1], buf); > + sma4_show(dev, NULL, buf); > + seq_printf(s, " sma4: %04x,%04x %s", > + sma_val[3][0], sma_val[3][1], buf); > + } > > if (bp->ts0) { > ts_reg = bp->ts0->mem; > @@ -6032,7 +6160,7 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id) > if (err) > goto out_dpll_put; > > - for (i = 0; i < OCP_SMA_NUM; i++) { > + for (i = 0; bp->sma_op && i < OCP_SMA_NUM; i++) { here as well > bp->sma[i].dpll_pin = dpll_pin_get(clkid, i, THIS_MODULE, > &bp->sma[i].dpll_prop, > &bp->sma[i].tracker); > > base-commit: 02e8a63b4685a4321c60d562edabecc097f4a0d9 --- pw-bot: cr