From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796300663; b=oZ4sJFibm46HOS5RuWmwdEqObaFSeR2Rpsi4HzhTCGUaAGaqPfHyr4cCmbjkBI3UrUZO pbo0nwd8KFeBxQrpkE06PCx1LwP+Tb6+OYkKKUkXuyDNUtSVYiD0aWIfs+GGISvXRiNyQ rRUJM67NWaCS+wwtIPvGfzEj8ab7+HrjgS7+DhVZVPtmw9vItlO4YsMWh79uz6IwlMem2 CZKImlhhYeBeZsVXpo9wrhqspEh8PgdyvFomucYFt/DjsTu9CQwKKM4ylnAYupt5kI/lZ rkBvWo0vYDDovcBpF86EgNn+WKaeECWO5WYDgPgxFb6xlVGYW81+gJDqM+5swB9wTqw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796300663; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=wYVzZWXSB7HC8BJhSVByEsgCN6NmvmnzWuPWsC/KDZ4=; b=SFpOIanSHRLBQlo7FlEk9vUStUsu/zXp/rzC6MBWKHqrLghxTNL3Aqp+iGZay1eFzI6H Q9TtFykbyuWXg4McFjqBvYx2VACnWrZc/9buq9RXnaP3KuOePiv6FbccK7jBnVHsLlUIW Z3/DymhDvnWyy0dG0TdHlR2wPkt/tvDWZwkx8aqipUhSa/Ui15lzU29BbtUA74r9/MSxG 2mlM2snJELF51jf6QPCFs1AKDrjs5mIv3yxq3yWsPl81lSiWIT9vmnmMlhc5oOlTV6FP0 ZpruPq788WWcNOvJG06JCN7I6pC9rmPWBON9ZEK18UPbC25s6NXCPDizGQoQv+tsRGQ== 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=uGtzAGnN; arc=none smtp.remote-ip=209.85.128.44 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 266FA606A333 for ; Thu, 3 Dec 2026 12:24:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 266FA606A333 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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=uGtzAGnN Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4bb5b8ef642so117648995e9.1 for ; Thu, 03 Dec 2026 04:24:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796300661; x=1796905461; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=wYVzZWXSB7HC8BJhSVByEsgCN6NmvmnzWuPWsC/KDZ4=; b=uGtzAGnNDrjDTgBBIpEXVCuAKWIRcJHsGAi+kcoWDxUZA7glyqhwcfiWgq7/XCLexP AfUk0oASov6NstHujvQOyH1H5Nk+A9TsASWaVrDTK5HswDN8PzJ2oEO3NjSxv85gWhL5 zXf++UeHntsA6vgRgc1It0dq7JQhyAlrafeWgR1G1KIW+RhlQN3c/ocyEI9S953oqZDA oMeair1kHK7ouYa4yk6A8b5K/QRrQo6Cg/Z0r8RPbIIARYoPKTNDTCCvzpUyVvHfS4EJ f79kwzTAXcN12wpfXHmiDgQ1RaLeUis/8+pgawbcMAC2NQwDOeNCJFPDU5lFxm+rYO6b JfFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796300661; x=1796905461; h=content-transfer-encoding:mime-version: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=wYVzZWXSB7HC8BJhSVByEsgCN6NmvmnzWuPWsC/KDZ4=; b=UsHZaTqlrJW5RGoj7W2s7EYZ9UkezaYfpG4pHifdGnrLRpyGneoSpAY5SFt5TE5AYd M2+O2VFGlfTKI+zQvQecNM9NiuWWX4+2wkKrLe4HUfRat1dSMZp3UsQBVw+hAi7vptYS p2jMxsjUQFSDHXI/ESRL7jttyCAFG77rRnM3BiFssfTIFpY/W3taeLS2Yc3kIl/r+hzf hhLHJqU0x0gcNdqrIfXOCBqMY6qa1A49ek/9Z8VQVFKb/vuJIpgHsDqeGngIRPw91Amv KT1ctYzGqvev9u5Pr1+TcN71oDzBF9u2buw6JvLRFNW6OfVKsvbggO9nE4ge+42AmVsT wL7g== X-Forwarded-Encrypted: i=1; AL+hErFYVOJFijY/HYHJD1+lJNgCnpauUQ5X5iiFnd00OPt0mGHl5RLO4IJd5rv/7g5QlG9x5jHMEQLKqlU=@vger.kernel.org X-Gm-Message-State: APuU4Z/WcwTmqgWvH04cUci6WkDrl7HN51yerI+Fx3sPPitpVqeYu8DR /oVOnlHwUaVaKSXOfeM+JBejbWiJVR6yiEKKD8HU6vmW8HB+NywX1GQE X-Gm-Gg: AZFdTZfL+pocX01SLV5olvFaHnfZDB3JQuYn6A0pClBm/fPhmsrx5CeMOgcLOZ2WRAe 8HP52FUW7eIZfwidpQsUHrFYOlj6N1PxZSuUWHwJkfCFnYcI8wT1NaAhZkhmUyHaL4yJbhhLjrh XlICHSFgOMTUOYSFOCLK9FclxaW/mSfjY0vWdepTjkS5aYpq7TAMzAaGoMI4ET3GgDxFBLGwa3u /CXAWC/iy1Bt964Do6C1ZbII+8FV0ouPkNjuUQQYKP40BZDmD8IYAUSrLtNMeV7JhHHXJ8R8rs6 5CIekM5Sb7yRH4k8ftyaBu20OPQBWmnhTySWXn2HstaxOw1YRnY1TKYv1IWxK/y4s6bJ8BgiRzI ypBdUkDnmid2cN8HwRu4EX0MLVZwrFReltMu95HOx5LW0InsEItqhEaWos8y/vFha9tMWcEKH4s YEuFoRvjvJeOaN5f0ihA/2vkfx1LrAL/ac/J1KOWqBfQ8I9NcFpk8TwpYTgZsHCCZG8plqzy/MY XnfgFGaofIylhScifM9aE406143m2mafXFS8c9EO4rTtkdk0OHAGt8z7ogzUmLRGY+94owoa7I0 dwEnuSoUO37sOk9aN4S6FEoCpZF80MC99FpWpUeRPH4I1GWRZDKqofHZFU1zT0L8pUAe229ZIln Aco1jtpjcXguBlxSmdFgJHBHNmPA= X-Received: by 2002:a05:600c:3b1a:b0:4a7:8fe8:130c with SMTP id 5b1f17b1804b1-4bb8881d4damr911614195e9.28.1796300661150; Thu, 03 Dec 2026 04:24:21 -0800 (PST) Received: from fedora-tap.advaoptical.com ([82.166.23.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbe005543esm78708555e9.5.2026.12.03.04.24.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 04:24:20 -0800 (PST) From: Sagi Maimon To: netdev@vger.kernel.org Cc: vadim.fedorenko@linux.dev, 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, Sagi Maimon Subject: [PATCH net-next v2] ptp: ocp: add support for the ADVA TimeCard X2 Date: Thu, 3 Dec 2026 14:24:16 +0200 Message-ID: <20261203122416.425770-1-maimon.sagi@gmail.com> X-Mailer: git-send-email 2.47.0 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 Content-Transfer-Encoding: 8bit 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 follows the layout of the card's OSA software instead of the X1's - bit 31 marks the loader and bits 15:0 hold the build - and devlink reports it as 4., the fixed tag 4 marking the new board. 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. ptp_ocp_adva_board_init() also derives the signal and frequency capabilities from signals_nr and freq_in_nr instead of setting them unconditionally, so the X2 advertises neither. 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 4.. 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 --- Notes: v2: - Keep fw_tag static: 4 for the X2, instead of the OSA release byte, so devlink reports 4.. Update the devlink doc to match. (Vadim) - Advertise OCP_CAP_SIGNAL and OCP_CAP_FREQ only when the board has signal generators and frequency inputs; the X2 has neither. (Vadim) - Check sma_op once before the SMA loops in gpio_input_map() and gpio_output_map(), and move the dpll pin registration into ptp_ocp_dpll_pins_register(), which returns early without sma_op. (Vadim) v1: https://lore.kernel.org/netdev/20261130143150.326311-1-maimon.sagi@gmail.com/ Documentation/networking/devlink/ptp_ocp.rst | 30 ++- drivers/ptp/ptp_ocp.c | 250 +++++++++++++++---- 2 files changed, 221 insertions(+), 59 deletions(-) diff --git a/Documentation/networking/devlink/ptp_ocp.rst b/Documentation/networking/devlink/ptp_ocp.rst index f94b759d9cd6..d49740e30c90 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 ``4.``, where ```` is the + build number of the card's OSA software. * - ``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..cd81970a12fc 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,14 +3365,25 @@ 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 = 4; + 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; + bp->fw_cap = OCP_CAP_BASIC; + if (info->signals_nr) + bp->fw_cap |= OCP_CAP_SIGNAL; + if (info->freq_in_nr) + bp->fw_cap |= OCP_CAP_FREQ; ptp_ocp_tod_init(bp); ptp_ocp_nmea_out_init(bp); @@ -3288,10 +3393,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,12 +5288,37 @@ 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; + if (!bp->sma_op) + goto out; + for (i = 0; i < 4; i++) { if (bp->sma[i].mode != SMA_MODE_IN) continue; @@ -5194,6 +5327,7 @@ gpio_input_map(char *buf, struct ptp_ocp *bp, u16 map[][2], u16 bit, return; } } +out: if (!def) def = "----"; strcpy(buf, def); @@ -5206,6 +5340,9 @@ gpio_output_map(char *buf, struct ptp_ocp *bp, u16 map[][2], u16 bit) int i; strcpy(ans, "----"); + if (!bp->sma_op) + return; + for (i = 0; i < 4; i++) { if (bp->sma[i].mode != SMA_MODE_OUT) continue; @@ -5316,21 +5453,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; @@ -5952,12 +6091,48 @@ ptp_ocp_sync_work(struct work_struct *work) queue_delayed_work(system_power_efficient_wq, &bp->sync_work, HZ); } +static int +ptp_ocp_dpll_pins_register(struct ptp_ocp *bp, u64 clkid) +{ + int err, i; + + /* boards without user-accessible SMA connectors have no SMA pins */ + if (!bp->sma_op) + return 0; + + for (i = 0; i < OCP_SMA_NUM; i++) { + bp->sma[i].dpll_pin = dpll_pin_get(clkid, i, THIS_MODULE, + &bp->sma[i].dpll_prop, + &bp->sma[i].tracker); + if (IS_ERR(bp->sma[i].dpll_pin)) { + err = PTR_ERR(bp->sma[i].dpll_pin); + goto out; + } + + err = dpll_pin_register(bp->dpll, bp->sma[i].dpll_pin, + &dpll_pins_ops, &bp->sma[i]); + if (err) { + dpll_pin_put(bp->sma[i].dpll_pin, &bp->sma[i].tracker); + goto out; + } + } + + return 0; +out: + while (i--) { + dpll_pin_unregister(bp->dpll, bp->sma[i].dpll_pin, + &dpll_pins_ops, &bp->sma[i]); + dpll_pin_put(bp->sma[i].dpll_pin, &bp->sma[i].tracker); + } + return err; +} + static int ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct devlink *devlink; struct ptp_ocp *bp; - int err, i; + int err; u64 clkid; devlink = devlink_alloc(&ptp_ocp_devlink_ops, sizeof(*bp), &pdev->dev); @@ -6032,30 +6207,13 @@ 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++) { - bp->sma[i].dpll_pin = dpll_pin_get(clkid, i, THIS_MODULE, - &bp->sma[i].dpll_prop, - &bp->sma[i].tracker); - if (IS_ERR(bp->sma[i].dpll_pin)) { - err = PTR_ERR(bp->sma[i].dpll_pin); - goto out_dpll; - } - - err = dpll_pin_register(bp->dpll, bp->sma[i].dpll_pin, &dpll_pins_ops, - &bp->sma[i]); - if (err) { - dpll_pin_put(bp->sma[i].dpll_pin, &bp->sma[i].tracker); - goto out_dpll; - } - } + err = ptp_ocp_dpll_pins_register(bp, clkid); + if (err) + goto out_dpll; queue_delayed_work(system_power_efficient_wq, &bp->sync_work, HZ); return 0; out_dpll: - while (i--) { - dpll_pin_unregister(bp->dpll, bp->sma[i].dpll_pin, &dpll_pins_ops, &bp->sma[i]); - dpll_pin_put(bp->sma[i].dpll_pin, &bp->sma[i].tracker); - } /* dpll_device_register() takes a second reference and stores bp; only * dpll_device_unregister() drops it. Without this the device stays * visible with a priv pointer into storage devlink_free() will release. base-commit: 3b4d7f44a61b8217ed11c5df95bccfd256c52db3 -- 2.47.0