From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8360395ACA for ; Mon, 20 Jul 2026 16:38:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784565519; cv=none; b=ZHr/nBLWaSYsbdQvHCQ3XsCdByxtvSt/BWxBJouctYuxN3NQwZ+hBDK9ARGxVTPese13kBX1I7w7Z7S7sjN6IrYZH26rXw5OiGVzeLSAy5R3JjNAtI7Y/KpzukOaEnctiie/USpV09gp0CcmpI/pe+gQ9+O9hhoI4N/4xmAx/GU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784565519; c=relaxed/simple; bh=8Fm3vEh+1dWQI8swqJhCYbgEM+cB8Zzx1PqOZJ4zxcs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OqELZuD4wO1tk6hlgsQSVazR3vaq0KWYEFWxbyhGr8PKo/9fsDJZznSKnUM0zACYOLGPGV8yDIFY7p2FPeZgCKPGae2W5mbGEWLr0ok4pvmpDOsEExYWhfh89JStTQb1ghx9z4+0p6Fw5gDkOHhDm6qK5XRAv6k/oMYpkLf+AjI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=awUgsM9T; arc=none smtp.client-ip=209.85.128.47 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.b="awUgsM9T" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4954a2e73a9so20207495e9.3 for ; Mon, 20 Jul 2026 09:38:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784565515; x=1785170315; 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=tpd1FFeABygMAE3RBVlHC8AOP8gSRlvHTu7ypo6aoKs=; b=awUgsM9Tp68B3xdqujmAURZzTARdEm+kuEFSDAQOy71H/UEgbuLSv5yTe665iRZv7H He7LO/wcdcAXI/HUktgban8tynshHkN4O7d/BBaVpUuq5lQebW/Y8skV7PSQVdGKo4hn G0QFpdIBV2+sQpjHQ/s6MxPigrsBFG/Z0uxBunUetS16E27LuzYVtjWkdpJhc8JIigBM OFUYMtPtONjB7VKgXhISu7tUyMBdZ76XT3dVZjfgYyyxUhZS8UkJgvQRD9kQW4TwFqPS 3xegh16q2SWazK8PnKU61R9T6FUTDzHZyxnK2eDHmOaM2HXodO3WCfRwmC/SGFchIrk9 6AUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784565515; x=1785170315; 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=tpd1FFeABygMAE3RBVlHC8AOP8gSRlvHTu7ypo6aoKs=; b=OsSzKR35FhHW3aHkTp6ldOrjduWnRctEz1j2Kjc/EPEaVz9+m41Amj01XHz18B0AUu lO9YRXeqo9d09SIjs1luPO29/gFbFx7Sbuoe5SRfM8Fr0mwp9iXbRPa8tRL421vUehsX JNdntI5/ysvB/Ch7me8aNLKn8u8XY94+7icS5JS8Spz152H0wz6h8oy/E0YCoAXK0doK eLT9LHKvb+N9S2h9N4y9yDBfIv0IXZP4R4YguQ8/Qd6QV6lBHSsXTggTGDJ2to6w5Xug Kgnfrl++N8VvMtaF89kzgqZql/ueY15IMJf/kxDIEzbLbQHMC5mj/4uKt6CXJbc3zQIJ v3jQ== X-Forwarded-Encrypted: i=1; AHgh+Rp9hjkYVL6aw4oaDWDdokBkePbOS7DLK1u1dTvAMqYCtpll1P/JSOhC6viNLQkqs32z6OSl14E+5dc55aE=@vger.kernel.org X-Gm-Message-State: AOJu0YzUy/FTzWfzt4o8xNBWwV6ZB6kpHfRqMis8AUlF+C6nxYLj/vlF O464zKty48+Re4ZgdM5mhoxK1YSvsDYuvJ6SCUgWWb2lsxZ88Qv3cbLF X-Gm-Gg: AfdE7cnvouWqTbNswLNCSjldS66YM05dkW3d6esuX02xSSfERP9hOd/J/wXJEiOpmeF PLVx2gSvAOoEiHAb/mvIuaYz+kxNQV5NYAk6U0EK2z/dPfQGlqSBb1z5tLcP9mS6wc9204ONlrk t3ytPuEiHsYCbKKiPWd91HAXLQjcpGPOurtEKJsqDgu/2aviGEZgUFiGLas/HmRcFWiZ/+ra2Hd YoyntiTe+fISIthdf2cC0SSoIDpVhSQ4OaAP9e1gozPqKBQn5gxAdL6wF/JqYbsRu2qxQd8/0UE qFqxNJ1f/or0fvOSeNU5kH7wr5NpPxjEr0xdb63LqU2qEKsCXU8e4le22S73WbsHUy0BHZWGuPC qui8xWDUqF/Lf3Z4wH7dk15wdgw+3lrVFsiTiJLahz+gnRmHcy95Hu4r2fp1bt1gO2w0ml14mu7 UHzXUU3RYoq2CfiY163tnEW7Tluzw= X-Received: by 2002:a05:600c:e558:20b0:495:5cda:52ec with SMTP id 5b1f17b1804b1-4955cda5441mr50515775e9.16.1784565515124; Mon, 20 Jul 2026 09:38:35 -0700 (PDT) Received: from localhost.localdomain ([2001:b07:5d3a:fe75:4352:bba7:6d7f:5f92]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49565373608sm2105325e9.6.2026.07.20.09.38.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:38:34 -0700 (PDT) From: Fernando Rimoli To: Sakari Ailus , Daniel Scally , linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , Arsalan Naeem , Jakob Berg Jespersen , linux-kernel@vger.kernel.org, Fernando Rimoli Subject: [PATCH v3 3/4] media: i2c: ov5693: Gate the MIPI clock lane for non-continuous clock Date: Mon, 20 Jul 2026 18:38:18 +0200 Message-ID: <20260720163819.104130-4-fernandorimoli11@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260720163819.104130-1-fernandorimoli11@gmail.com> References: <20260717132021.18034-1-fernandorimoli11@gmail.com> <20260720163819.104130-1-fernandorimoli11@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The ov5693 never programs MIPI_CTRL00 (0x4800), leaving it at its 0x00 power-on default (free-running MIPI clock). The IPU3 CSI-2 receiver tolerates this, but the IPU6 receiver (e.g. on Microsoft Surface Pro 8/9 and Surface Go 4) fails to lock onto the link, so the sensor streams but capture times out with "stream stop time out" and no frames arrive. Parse the "clock-noncontinuous" endpoint property (which sets the V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK flag) and, when it is present, gate the clock lane while idle (bit 5) and keep the bus in LP11 (bit 2) at stream on, matching the approach ov5647 already uses for the same register. When the flag is absent the register is left at its reset default, so IPU3 and other users are unaffected. Gating the clock lane was determined to be necessary and sufficient by sweeping the register at runtime on a Surface Pro 9 (IPU6): every value with bit 5 set streams (300/300 frames, steady 28 fps), every value with bit 5 clear fails with the CSI-2 timeout; register read-back confirmed the power-on default is 0x00. Bit 2 (bus idle in LP11) is set as well, matching ov5640's value. Note that unlike ov5647 the line-sync bit (bit 4) is deliberately not set: adding it collapses the IPU6 stream to a couple of frames, so this value differs from ov5647's - the IPU6 D-PHY behaves differently, consistent with these settings being PHY-specific. The "clock-noncontinuous" property is supplied by the ipu-bridge for the affected IPU6 variants in a subsequent patch. Link: https://github.com/linux-surface/linux-surface/pull/2171 Co-developed-by: Arsalan Naeem Signed-off-by: Arsalan Naeem Signed-off-by: Fernando Rimoli Tested-by: Jakob Berg Jespersen --- drivers/media/i2c/ov5693.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/media/i2c/ov5693.c b/drivers/media/i2c/ov5693.c index 02236f3db..5468e89d6 100644 --- a/drivers/media/i2c/ov5693.c +++ b/drivers/media/i2c/ov5693.c @@ -35,6 +35,14 @@ #define OV5693_STOP_STREAMING 0x00 #define OV5693_SW_RESET 0x01 +/* MIPI transmitter control */ +#define OV5693_MIPI_CTRL00_REG CCI_REG8(0x4800) +/* bit 5: gate the clock lane when idle; bit 2: keep the bus in LP11 when idle */ +#define OV5693_MIPI_CTRL00_CLOCK_LANE_GATE BIT(5) +#define OV5693_MIPI_CTRL00_BUS_IDLE BIT(2) +#define OV5693_MIPI_CTRL00_NCONT_CLOCK (OV5693_MIPI_CTRL00_CLOCK_LANE_GATE | \ + OV5693_MIPI_CTRL00_BUS_IDLE) + #define OV5693_REG_CHIP_ID CCI_REG16(0x300a) /* Yes, this is right. The datasheet for the OV5693 gives its ID as 0x5690 */ #define OV5693_CHIP_ID 0x5690 @@ -144,6 +152,9 @@ struct ov5693_device { struct regulator_bulk_data supplies[OV5693_NUM_SUPPLIES]; struct clk *xvclk; + /* Gate the MIPI clock lane when idle (CSI-2 non-continuous clock) */ + bool clock_ncont; + struct ov5693_mode { struct v4l2_rect crop; struct v4l2_mbus_framefmt format; @@ -611,6 +622,19 @@ static int ov5693_enable_streaming(struct ov5693_device *ov5693, bool enable) { int ret = 0; + /* + * When the CSI-2 link is configured for a non-continuous clock, gate + * the MIPI clock lane while idle (bit 5) and keep the bus in LP11 + * (bit 2). The power-on default of MIPI_CTRL00 is 0x00 (free-running + * clock): the IPU3 CSI-2 receiver tolerates that, but the IPU6 one + * fails to lock onto the link and capture times out. Only touch the + * register when the endpoint requests a non-continuous clock, leaving + * the reset default in place otherwise. + */ + if (enable && ov5693->clock_ncont) + cci_write(ov5693->regmap, OV5693_MIPI_CTRL00_REG, + OV5693_MIPI_CTRL00_NCONT_CLOCK, &ret); + cci_write(ov5693->regmap, OV5693_SW_STREAM_REG, enable ? OV5693_START_STREAMING : OV5693_STOP_STREAMING, &ret); @@ -1259,6 +1283,9 @@ static int ov5693_check_hwcfg(struct ov5693_device *ov5693) goto out_free_bus_cfg; } + ov5693->clock_ncont = bus_cfg.bus.mipi_csi2.flags & + V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK; + out_free_bus_cfg: v4l2_fwnode_endpoint_free(&bus_cfg); -- 2.43.0