Re: [PATCH net-next v2] ptp: add Alibaba CIPU PTP clock driver

From: Wen Gu
Date: Mon Jun 30 2025 - 05:05:21 EST




On 2025/6/27 15:46, Andrew Lunn wrote:
+#define DRV_VER_MAJOR 1
+#define DRV_VER_MINOR 3
+#define DRV_VER_SUBMINOR 0

+#define LINUX_UPSTREAM 0x1F

+static int ptp_cipu_set_drv_version(struct ptp_cipu_ctx *ptp_ctx)
+{
+ struct ptp_cipu_regs *regs = &ptp_ctx->regs;
+ int version, patchlevel, sublevel;
+ u32 env_ver, drv_ver;
+ int rc;
+
+ if (sscanf(utsname()->release, "%u.%u.%u",
+ &version, &patchlevel, &sublevel) != 3)
+ return -EINVAL;
+ sublevel = sublevel < 0xFF ? sublevel : 0xFF;
+
+ env_ver = (LINUX_UPSTREAM << 27) | (version << 16) |
+ (patchlevel << 8) | sublevel;
+
+ rc = cipu_iowrite32_and_check(ptp_ctx->reg_addr +
+ PTP_CIPU_REG(env_ver),
+ env_ver, &regs->env_ver);
+ if (rc)
+ return rc;
+
+ drv_ver = (DRV_TYPE << 24) | (DRV_VER_MAJOR << 16) |
+ (DRV_VER_MINOR << 8) | DRV_VER_SUBMINOR;
+
+ return cipu_iowrite32_and_check(ptp_ctx->reg_addr +
+ PTP_CIPU_REG(drv_ver), drv_ver,
+ &regs->drv_ver);
+}

Please could you explain what this is doing.

Andrew

Sure.

This provides informations to cloud ptp device, so that device
can decide whether to allow the initialization to continue.

It is expected to avoid loading a version that is found to have
serious defects after it is released.

Thanks,