From patchwork Wed Oct 2 13:58:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 832628 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (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 DA81A1D0DCE for ; Wed, 2 Oct 2024 13:58:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727877532; cv=none; b=epxQS+AZpgh/6gFbstrW0BDIogp75KJEy4Byb+YrPkkYJEf6OpjDtniGqmZm8qBWcN4zfUoSzET3Tex5n+dSb1syM05m2MgZ4g47C/ob+vkmn1QxrPp8ARcXGy1YE3zJctbXtuDcBCs7EjqlGWwqeEu8ROeU8bbgg9b1aAbSe6o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727877532; c=relaxed/simple; bh=vTwVvG8iZlHzHza+YS67mEwp2zyunt+kNzBDYWtFYWc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XiJyO0zAUSV8wbTqYIShquw9idvFz2P50ehwl0HAoYYqOStxdp3rrViuLR4Cks62vL6pWKNtzbilGMd0XwAkU/0NUJtKzYBhDYQ+ldOsu6Ce93otQLB1bh9bOA88ePyWVTuq+2RCcdFK4OENmLNX1+5dxUiSbreSlbW13p0Dpug= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=oERhoMRU; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="oERhoMRU" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-53994aadb66so3710997e87.2 for ; Wed, 02 Oct 2024 06:58:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727877527; x=1728482327; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=E7nKjwcfTxwC0PwN6GrPgJAgBaaTNk6QSx4URpDS/gc=; b=oERhoMRUNxjEaPh+A1eUzygiomkUAcQkBs/hl4Q8jCBsDhWVkvq86L3FZ1sCyRYEeE 8WjMT3P0ZNuCbV9c8m3uwqavc9Yqvcao/A1BlKssJ7ew41ZUaqyi9RD0DEXs8ZYLV42X kvdHIZgFc9zuNQb3TTu86GdPm2fwXaFPssnUwerjpSL9PnqNHjOg+ETDGWi6zs9RhcZJ Nv3wH7OHOFsXoo8DGhBT96vqXe2TCHgCBJ66El4+H3QynUd4WxwLORmoAUFxMdHtCnq/ 3UzEdoLLZrRKQ7MBZVqHTPtgm+WztVG40fks5Dm1b3sobOtkmiAnnqa+keiSQbYkPFL6 65gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727877527; x=1728482327; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E7nKjwcfTxwC0PwN6GrPgJAgBaaTNk6QSx4URpDS/gc=; b=EmzyapcJbZ1nDFZzQJwD4wi5jO/MM4Re3+TD35TxyJVbU6SLhskSw6snJhPzQExBDA oyMW/ig+Fv6lnYU1dY8hLN01hl1tVuNp2gL3mYIdBQZDseeo7PgmeGOOqpxtiL9BLAZD fDuTg18N1XEhYFv6Cv62HmEz+uMq4Mt26Eaqi9MJs3W0xmfGHeQ+Kxq/XKonYliMQJJh Ju3ulLPI3Y2P7n1qJ9TJ5V/Z+k7qX9VhKMTP9JK/9XGhWbc+wfc9lqSoKUyNU8weDszG +9Y3OKK4WZUkbEmCGpvsHhlrepO8Ts3ZX7Y89ADEVF5RRnlb3ovM/AyXv15t0E0sQKyQ 1X1g== X-Gm-Message-State: AOJu0Yzs9JR5Gp+reUG76MaovwnrMQYGbpo+c8ScZNMcTlBfM3r27sIq TfxmCusY7bUOE6sMthKsudbd+JzuCiOJ7C91g6TybdwaNlgVhoYD+c0RY11WSvk= X-Google-Smtp-Source: AGHT+IHw9KJJ4jKUtIw0HbXWpy5zod4qe3AGMUGvrOu/5zZkhX4Sj/h2kA+sotMO5YI0x7xXSCBSOA== X-Received: by 2002:a05:6512:10d6:b0:535:6aa9:9868 with SMTP id 2adb3069b0e04-539a06637cdmr1877282e87.19.1727877526868; Wed, 02 Oct 2024 06:58:46 -0700 (PDT) Received: from [127.0.0.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c882405b19sm7577346a12.11.2024.10.02.06.58.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 06:58:46 -0700 (PDT) From: Bryan O'Donoghue Date: Wed, 02 Oct 2024 14:58:43 +0100 Subject: [PATCH v3 1/4] media: ov08x40: Fix burst write sequence Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241002-b4-master-24-11-25-ov08x40-v3-1-483bcdcf8886@linaro.org> References: <20241002-b4-master-24-11-25-ov08x40-v3-0-483bcdcf8886@linaro.org> In-Reply-To: <20241002-b4-master-24-11-25-ov08x40-v3-0-483bcdcf8886@linaro.org> To: Sakari Ailus , Jason Chen , Mauro Carvalho Chehab , Sergey Senozhatsky , Hans Verkuil , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Bryan O'Donoghue , stable@vger.kernel.org X-Mailer: b4 0.15-dev-dedf8 It is necessary to account for I2C quirks in the burst mode path of this driver. Not all I2C controllers can accept arbitrarily long writes and this is represented in the quirks field of the adapter structure. Prior to this patch the following error message is seen on a Qualcomm X1E80100 CRD. [ 38.773524] i2c i2c-2: adapter quirk: msg too long (addr 0x0036, size 290, write) [ 38.781454] ov08x40 2-0036: Failed regs transferred: -95 [ 38.787076] ov08x40 2-0036: ov08x40_start_streaming failed to set regs Fix the error by breaking up the write sequence into the advertised maximum write size of the quirks field if the quirks field is populated. Fixes: 8f667d202384 ("media: ov08x40: Reduce start streaming time") Cc: stable@vger.kernel.org # v6.9+ Tested-by: Bryan O'Donoghue # x1e80100-crd Signed-off-by: Bryan O'Donoghue --- drivers/media/i2c/ov08x40.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c index 48df077522ad0bb2b5f64a6def8844c02af6a193..be25e45175b1322145dca428e845242d8fea2698 100644 --- a/drivers/media/i2c/ov08x40.c +++ b/drivers/media/i2c/ov08x40.c @@ -1339,15 +1339,13 @@ static int ov08x40_read_reg(struct ov08x40 *ov08x, return 0; } -static int ov08x40_burst_fill_regs(struct ov08x40 *ov08x, u16 first_reg, - u16 last_reg, u8 val) +static int __ov08x40_burst_fill_regs(struct i2c_client *client, u16 first_reg, + u16 last_reg, size_t num_regs, u8 val) { - struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd); struct i2c_msg msgs; - size_t i, num_regs; + size_t i; int ret; - num_regs = last_reg - first_reg + 1; msgs.addr = client->addr; msgs.flags = 0; msgs.len = 2 + num_regs; @@ -1373,6 +1371,31 @@ static int ov08x40_burst_fill_regs(struct ov08x40 *ov08x, u16 first_reg, return 0; } +static int ov08x40_burst_fill_regs(struct ov08x40 *ov08x, u16 first_reg, + u16 last_reg, u8 val) +{ + struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd); + size_t num_regs, num_write_regs; + int ret; + + num_regs = last_reg - first_reg + 1; + num_write_regs = num_regs; + + if (client->adapter->quirks && client->adapter->quirks->max_write_len) + num_write_regs = client->adapter->quirks->max_write_len - 2; + + while (first_reg < last_reg) { + ret = __ov08x40_burst_fill_regs(client, first_reg, last_reg, + num_write_regs, val); + if (ret) + return ret; + + first_reg += num_write_regs; + } + + return 0; +} + /* Write registers up to 4 at a time */ static int ov08x40_write_reg(struct ov08x40 *ov08x, u16 reg, u32 len, u32 __val) From patchwork Wed Oct 2 13:58:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 832302 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (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 1904D1D0E39 for ; Wed, 2 Oct 2024 13:58:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727877532; cv=none; b=tVbDJIkdg5Oyu56UEbkOpxEqxl92h9JGYxL1+JMiaAqMDSqEhSbPnoqo6sX2rf/lrl0K5S7QIkgR5oPm7ZnOa/C8Ib8eaHJ3D7ZA7QuL0IA+az8q9+YdVFBteLY+dc9JsZ/vKpv6d09PBdpSLEOEzAFcfQn1NoArRH9r/OIzmrs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727877532; c=relaxed/simple; bh=fIo5orNyLLEFPtJb5oz4IDtLey/l+6Bpn6HZ72/3cCA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Kn4d3miUtyMu7Hb8RMvJGWfftg47LfhIPWXSxJdAjB7k73lBSUCqKoxhC2o8onfRNL4Y/DbF+qkGA7YWMAVwa208bcMbE/8J0l4zzaFSvSS/LE/g8vs6DvPXzagOtN0RPNGhsNe6BAfeH0JNjEHOY2JMqC2nim299BpeEaX8RpA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=PpymQSe5; arc=none smtp.client-ip=209.85.167.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PpymQSe5" Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-5398d171fa2so4535360e87.0 for ; Wed, 02 Oct 2024 06:58:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727877528; x=1728482328; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Z+tYln/WYLGMsq4JdI9qtiUzKuDrsrfKpk26EEW8Tg8=; b=PpymQSe5ePQMCuq3W0SBo+zRdg8Q3QfV4NjFYZQfk9a/b8d62JSkcBZwM44HWiXfpj +GJC7jY3KocuMxCqG7UE8+E4jiW1d85zG5XQsRuKti6+X4K4tIdbWRo8uZ4Yy0F2XcgP 5fI1hsMfrukVOYt2NkRsMAm7q6bf/Jr26LAbb8+ChvtMoS/yFmg/tqxgDwOFQVbsyLrv +7nhNA+YOiXDCWwj2qaGq4Qc3e6vWYM8nRYrzoekzLJ2oKMSSSorGagoyYIoXWoNpy00 93tVbSZoqZ385ZmBK5nyNliRhkf3yzaZJELbOlXPjtljrE/NKYCLjaTbqt0O9zq+yu13 w9RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727877528; x=1728482328; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z+tYln/WYLGMsq4JdI9qtiUzKuDrsrfKpk26EEW8Tg8=; b=MAkDGwn/AboCK+SinFslumB5hbVBexu7xW4TDU71w2CndDXV2KitIaz/tLwW4wXML9 YEvpz7e8NzSr0+L3oxxwY8MreSbEyHyB/ps+q+kDQyLZq/LtNTNEEBkij/8J3X0O87C4 VgwhDkkifRJHbKKuR8Tjy8qt55NU7Qt6LcQ7EuNoaY5d/7yVbH3PpW5qhgnd4ES7iFmt 1W/4oAr8CogmDQ23mjdE5Svk4GZP+On440s8VDOG5MZRFtijO5XZq7eOY1PJfrrUzp8l SHd7Ta9CJd/W3a4C2H6mVyl9HEG52Ou2GSgZ+MuerecWb1FKXGXEAdmpzsReNZ7S2fAN dxIA== X-Gm-Message-State: AOJu0Yxo26d0l1QzsHMQEFKRtRq3Ayu4LDrDCYGuukTdRpvwYdBmdnJm U0sRneWiFYsyTxpYYErDDCFZoucQ3i83XZ+2sJhkwyvmlGx5jw2w7exfBJb3nVk= X-Google-Smtp-Source: AGHT+IFCgyh8+Qb5va2P+FCDk6hJ8gP0zOs45xyIB7dsI22CUb5NA/DAJZ9Nc26i9yRNcfg3mK9j3Q== X-Received: by 2002:a05:6512:b12:b0:539:921a:44af with SMTP id 2adb3069b0e04-539a07a134fmr1752530e87.48.1727877528068; Wed, 02 Oct 2024 06:58:48 -0700 (PDT) Received: from [127.0.0.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c882405b19sm7577346a12.11.2024.10.02.06.58.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 06:58:47 -0700 (PDT) From: Bryan O'Donoghue Date: Wed, 02 Oct 2024 14:58:44 +0100 Subject: [PATCH v3 2/4] media: dt-bindings: Add OmniVision OV08X40 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241002-b4-master-24-11-25-ov08x40-v3-2-483bcdcf8886@linaro.org> References: <20241002-b4-master-24-11-25-ov08x40-v3-0-483bcdcf8886@linaro.org> In-Reply-To: <20241002-b4-master-24-11-25-ov08x40-v3-0-483bcdcf8886@linaro.org> To: Sakari Ailus , Jason Chen , Mauro Carvalho Chehab , Sergey Senozhatsky , Hans Verkuil , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Bryan O'Donoghue X-Mailer: b4 0.15-dev-dedf8 Add bindings for the already upstream OV08X40 to enable usage of this sensor on DTS based systems. Signed-off-by: Bryan O'Donoghue --- .../bindings/media/i2c/ovti,ov08x40.yaml | 116 +++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/Documentation/devicetree/bindings/media/i2c/ovti,ov08x40.yaml b/Documentation/devicetree/bindings/media/i2c/ovti,ov08x40.yaml new file mode 100644 index 0000000000000000000000000000000000000000..74b33a083efbe91db0fa4e7e7bb6008a95e4e4d6 --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/ovti,ov08x40.yaml @@ -0,0 +1,116 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright (c) 2024 Linaro Ltd. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/i2c/ovti,ov08x40.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Omnivision OV08X40 CMOS Sensor + +maintainers: + - Bryan O'Donoghue + +description: | + The Omnivision OV08X40 is a 9.2 megapixel, CMOS image sensor which supports: + - Automatic black level calibration (ABLC) + - Programmable controls for frame rate, mirror and flip, binning, cropping + and windowing + - Output formats 10-bit 4C RGB RAW, 10-bit Bayer RAW + - 4-lane MIPI D-PHY TX @ 1 Gbps per lane + - 2-lane MPIP D-PHY TX @ 2 Gbps per lane + - Dynamic defect pixel cancellation + - Standard SCCB command interface + +properties: + compatible: + const: ovti,ov08x40 + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + avdd-supply: + description: Analogue circuit voltage supply. + + dovdd-supply: + description: I/O circuit voltage supply. + + dvdd-supply: + description: Digital circuit voltage supply. + + reset-gpios: + description: Active low GPIO connected to XSHUTDOWN pad of the sensor. + + port: + $ref: /schemas/graph.yaml#/$defs/port-base + additionalProperties: false + + properties: + endpoint: + $ref: /schemas/media/video-interfaces.yaml# + unevaluatedProperties: false + + properties: + data-lanes: + oneOf: + - items: + - const: 1 + - const: 2 + - items: + - const: 1 + - const: 2 + - const: 3 + - const: 4 + + link-frequencies: true + + required: + - data-lanes + - link-frequencies + +required: + - compatible + - reg + - clocks + - port + +additionalProperties: false + +examples: + - | + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + ov08x40: camera@36 { + compatible = "ovti,ov08x40"; + reg = <0x36>; + + reset-gpios = <&tlmm 111 GPIO_ACTIVE_LOW>; + pinctrl-names = "default"; + pinctrl-0 = <&cam_rgb_defaultt>; + + clocks = <&ov08x40_clk>; + + assigned-clocks = <&ov08x40_clk>; + assigned-clock-parents = <&ov08x40_clk_parent>; + assigned-clock-rates = <19200000>; + + avdd-supply = <&vreg_l7b_2p8>; + dvdd-supply = <&vreg_l7b_1p8>; + dovdd-supply = <&vreg_l3m_1p8>; + + port { + ov08x40_ep: endpoint { + remote-endpoint = <&csiphy4_ep>; + data-lanes = <1 2 3 4>; + link-frequencies = /bits/ 64 <400000000>; + }; + }; + }; + }; +... From patchwork Wed Oct 2 13:58:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 832301 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (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 A84501D0E28 for ; Wed, 2 Oct 2024 13:58:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727877533; cv=none; b=BMhz9u7LuAu6a+px8F76jcWjpaPwqSztBUQ7oQfdjNWFI3ez/W2H4+14jgt4JqwhZ+jvtGPYcIC3h9zTAxye+LwJiiFDjFtoT0XwHl/QBqiNCdDFdLBJyLV69vIUMrbAzIUAqZVYU8JiCstZA50nFcL2OE3bRggZqvz2jvb4ff4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727877533; c=relaxed/simple; bh=KuJYhS6BLwFHq2M3BsUApExs70W98G5/TG0tISRMP7Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FwzqEkOxMCGQieshLe8M2L5cWtYG0SWDbYSYNB0ULelmpk5ByeSlPuTvVoU8OzOXip6xf3nthSYnWvZ/fCg6doHVbZ8SYoosnmTzMUGM7eNC7jCoGpuIP1Y/QvdnFw3dn7gOBb/EaanSi+YXDhCa8/c2cp/TB8RBbYZgUAbSyw8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=mxvXlTqx; arc=none smtp.client-ip=209.85.208.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mxvXlTqx" Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-5c896b9b4e0so5111298a12.3 for ; Wed, 02 Oct 2024 06:58:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727877530; x=1728482330; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=wDWnOefZjmiIEjMknhotah0eI13dQMdxoD4kz7zvhSU=; b=mxvXlTqx6hxsoqFOhWczaXX5hDbN+NoWGm2Szw1we5jsd3oyLWxEFSoUGqUHma2DxK FVWWrRctDJE62zij6U2WWy1wa4lh+JtvXz3I3AmJbrMVKpQttUBK8mE2AAUG4I/9bvdj rfCoOtf9B3LB+PTZ8l4OsGNo5ywAeYfG+t0YPJBBq53NlBIdUL2LYlniZAGLbtgAMXHs K5Bx/CyeHnlL0WhH1ym4vO62BU4BHY2KnxvX6T5F2L7Bta+7XKF1xI1EofgBYsnLn3bY npFFuvz0C/JX9SGGoe7ZO5G27kl4n14k8vh6R1rKLkMPHIhm4f6u34+5yV4wbjztanEu GHZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727877530; x=1728482330; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wDWnOefZjmiIEjMknhotah0eI13dQMdxoD4kz7zvhSU=; b=C+5JgZ24OT8uH60aaT90Aogq+RM6iDqIm1lkAW3Fzro8zgYQmwQ496Pk5EvljCPLO7 3VA15+KxwfuIL5g44vnvFefDO2fq1HhPQhBTkcqhjHOZWteJiHpG59whzLs7oaO8SBKX dJeE8LGM2U5ZxFfrqPV8mwHHDjRM9scItdP1BcEhK8pfZN6qbdsByhWG+FuzZ7jBxD1C q7KlIxfn7ON9upvaxwT5WHHx09loXoGuxxO0mp2vDHoymPvAlvvVzwH4sY4qwsfGbKXX ce8GNA9WN1lOJvrsBwQBk6vkVBoqt0GzmFgejHN8AGOdfUfWt/UBC2VYCEug2d7+6y9F P4zg== X-Gm-Message-State: AOJu0YwLsIdUIRrpljduYfHtwMxoFkvIWp7oSSmwoOzbB7ntf9ie1v69 LTKhPCmKKE38vX/kRADx71j+vyc0puns97CGkr9HcboMaQxzz/QM/9TRbqP26E8= X-Google-Smtp-Source: AGHT+IGHtKriEtbcWdY7fhEQr2/c7bU25UcFhWZRnYm/e1VoJ+qT/dbOLfn2MvOA0mIj5hp60Zt8hw== X-Received: by 2002:a05:6402:2789:b0:5c8:8322:b154 with SMTP id 4fb4d7f45d1cf-5c8b192cfc4mr2497340a12.16.1727877530035; Wed, 02 Oct 2024 06:58:50 -0700 (PDT) Received: from [127.0.0.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c882405b19sm7577346a12.11.2024.10.02.06.58.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 06:58:48 -0700 (PDT) From: Bryan O'Donoghue Date: Wed, 02 Oct 2024 14:58:45 +0100 Subject: [PATCH v3 3/4] media: ov08x40: Rename ext_clk to xvclk Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241002-b4-master-24-11-25-ov08x40-v3-3-483bcdcf8886@linaro.org> References: <20241002-b4-master-24-11-25-ov08x40-v3-0-483bcdcf8886@linaro.org> In-Reply-To: <20241002-b4-master-24-11-25-ov08x40-v3-0-483bcdcf8886@linaro.org> To: Sakari Ailus , Jason Chen , Mauro Carvalho Chehab , Sergey Senozhatsky , Hans Verkuil , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Bryan O'Donoghue X-Mailer: b4 0.15-dev-dedf8 The data-sheet and documentation for this part uses the name xvclk not ext_clk for the input reference clock. Rename the variables and defines in this driver to align with the data-sheet name. Signed-off-by: Bryan O'Donoghue --- drivers/media/i2c/ov08x40.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c index be25e45175b1322145dca428e845242d8fea2698..3ab8b51df157af78fcccc1aaef73aedb2ae759c9 100644 --- a/drivers/media/i2c/ov08x40.c +++ b/drivers/media/i2c/ov08x40.c @@ -1215,7 +1215,7 @@ static const char * const ov08x40_test_pattern_menu[] = { /* Configurations for supported link frequencies */ #define OV08X40_LINK_FREQ_400MHZ 400000000ULL #define OV08X40_SCLK_96MHZ 96000000ULL -#define OV08X40_EXT_CLK 19200000 +#define OV08X40_XVCLK 19200000 #define OV08X40_DATA_LANES 4 /* @@ -2081,21 +2081,21 @@ static int ov08x40_check_hwcfg(struct device *dev) struct fwnode_handle *fwnode = dev_fwnode(dev); unsigned int i, j; int ret; - u32 ext_clk; + u32 xvclk_rate; if (!fwnode) return -ENXIO; ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", - &ext_clk); + &xvclk_rate); if (ret) { dev_err(dev, "can't get clock frequency"); return ret; } - if (ext_clk != OV08X40_EXT_CLK) { + if (xvclk_rate != OV08X40_XVCLK) { dev_err(dev, "external clock %d is not supported", - ext_clk); + xvclk_rate); return -EINVAL; } From patchwork Wed Oct 2 13:58:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 832627 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (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 25FC21D12E7 for ; Wed, 2 Oct 2024 13:58:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727877536; cv=none; b=GJULrT1HwdwwJFoUwO8L2XrRRB7viCa5r+iflhR7wJxIJqoFGgS3Osm2PCQShceyKpJbRgBmmRUvpxp/E5BM8PKzfXYUYzqtnlWRrkripeBAAHBsLBipQ5Y5zw3gjsgokk8LOowsqGSW+NCXDKvPswOR0TORam4lbK48pT15fe4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727877536; c=relaxed/simple; bh=LL6t0/fJmZI9eHhzlG/ZhWayuHRs6YWaQKrP0a5lAkU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=f18rBxsodd7oztPFQtiWHDZMgpldJzqv6/KTNT9TsQKWCEnCJF9T0k29fROgPpr0AzN5eWz6mAvTwW7Dt4CaIDf0iUOZrbDQKoW73hqYTSpJ1AV5naxlOg8o+W2u5vluok+RGwYG/oJE7pJxFTexTq77T+oCoxWfaMWcRKdL6qk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=q9neev35; arc=none smtp.client-ip=209.85.208.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="q9neev35" Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2facf48157dso38540821fa.2 for ; Wed, 02 Oct 2024 06:58:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727877531; x=1728482331; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=F1exe6gHY7SXzDJNE6ebEB1h7PVHhMSJMUSH5bL4x90=; b=q9neev35gUoWdoL6rxVsrxM6V192/iC7jaRkg2d+vgsFLCMHD5meVpaQ5sFUz0/xqV hTw1Mp0/Dg1qwvOuHEU6LCmUn5P8qOLx6146YVpc7Maxlb2ZUrEH+jqusS0wfVV6fdG8 h0/7Nf7Iv8IvaNN1WUdW+TER4X4G7Zwnc+rf+stnrMqMgiHOBh65l9hFuktlIx+6fhwJ Oj5439/wsPOaD64oLcaSSDi+ypPFQFGFdVkdv+wazYXj1lpFeLXQRtp1B1g49KANxDOQ JMzOEq403oVnoYTARL99kGocDXK9wNAssiIwhwWqsfLgpb+MZ5tuGly5HYQsa9bcF4+0 Hl5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727877531; x=1728482331; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F1exe6gHY7SXzDJNE6ebEB1h7PVHhMSJMUSH5bL4x90=; b=jKOXMsCB6UezukmVc+gTxSXpK6KCF1kD3Jv5RjUn9j8EdAXrOFGvRVYl9JWjpFiwAG S3wcdssFE8NMvl+x/zW6nCdVJ80G9JdZqbTFaga3tH9dajZs2/yO91gK6k+pv1yOe8aY z0wHak2Ql2G+QRwTujryY4qZfJPusIC5pg/wxhZp0/p7OL/ugo/YDW/xSp6FVJdBZjWv 0FdnhWK1qcCh+8z75mWIuJl5cZ2CvaaxxI53rgggUIEaTu9I6TMubqldYr6X1PgzVmbY aVqzgbbMFWOejhu0yjPgwARvkSoevEUIwnI1lS3dWUJmd3XJur3VxvUK+XWppptLkycF hbFA== X-Gm-Message-State: AOJu0YyVWydFNbmDt40OOIYoyb+adl+d2PbHzsAL4Tm1dru7D7X5I9qX pehOEiu7n2d/w0XXFt3bwimPb11bqMRDsK6kFEQSKtERjUB8pD50fgu+1cz7Hlw= X-Google-Smtp-Source: AGHT+IFSaP/RvQU7G5tWbAclrgJaV7UMCMpdQF/+pCyV5GAOTHhtXOi+9GpNetCjRB/brf/Hu/+65Q== X-Received: by 2002:a2e:9215:0:b0:2f3:f358:8657 with SMTP id 38308e7fff4ca-2fae10a6b58mr17865921fa.44.1727877531147; Wed, 02 Oct 2024 06:58:51 -0700 (PDT) Received: from [127.0.0.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c882405b19sm7577346a12.11.2024.10.02.06.58.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 06:58:50 -0700 (PDT) From: Bryan O'Donoghue Date: Wed, 02 Oct 2024 14:58:46 +0100 Subject: [PATCH v3 4/4] media: ov08x40: Add OF probe support Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241002-b4-master-24-11-25-ov08x40-v3-4-483bcdcf8886@linaro.org> References: <20241002-b4-master-24-11-25-ov08x40-v3-0-483bcdcf8886@linaro.org> In-Reply-To: <20241002-b4-master-24-11-25-ov08x40-v3-0-483bcdcf8886@linaro.org> To: Sakari Ailus , Jason Chen , Mauro Carvalho Chehab , Sergey Senozhatsky , Hans Verkuil , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Bryan O'Donoghue X-Mailer: b4 0.15-dev-dedf8 The ACPI version of this driver "just works" on dts based systems with a few extensions to facilitate. - Add support for DT based probing - Add support for taking the part out of reset via a GPIO reset pin - Add in regulator bulk on/off logic for the power rails. Once done this sensor works nicely on a Qualcomm X1E80100 CRD. Tested-by: Bryan O'Donoghue # x1e80100-crd Signed-off-by: Bryan O'Donoghue --- drivers/media/i2c/ov08x40.c | 138 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 124 insertions(+), 14 deletions(-) diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c index 3ab8b51df157af78fcccc1aaef73aedb2ae759c9..821102287580acecd544402254cfe0fb5c8dc299 100644 --- a/drivers/media/i2c/ov08x40.c +++ b/drivers/media/i2c/ov08x40.c @@ -3,10 +3,13 @@ #include #include +#include #include +#include #include #include #include +#include #include #include #include @@ -1279,6 +1282,12 @@ static const struct ov08x40_mode supported_modes[] = { }, }; +static const char * const ov08x40_supply_names[] = { + "dovdd", /* Digital I/O power */ + "avdd", /* Analog power */ + "dvdd", /* Digital core power */ +}; + struct ov08x40 { struct v4l2_subdev sd; struct media_pad pad; @@ -1291,6 +1300,10 @@ struct ov08x40 { struct v4l2_ctrl *hblank; struct v4l2_ctrl *exposure; + struct clk *xvclk; + struct gpio_desc *reset_gpio; + struct regulator_bulk_data supplies[ARRAY_SIZE(ov08x40_supply_names)]; + /* Current mode */ const struct ov08x40_mode *cur_mode; @@ -1303,6 +1316,61 @@ struct ov08x40 { #define to_ov08x40(_sd) container_of(_sd, struct ov08x40, sd) +static int ov08x40_power_on(struct device *dev) +{ + struct v4l2_subdev *sd = dev_get_drvdata(dev); + struct ov08x40 *ov08x = to_ov08x40(sd); + int ret; + + if (is_acpi_node(dev_fwnode(dev))) + return 0; + + ret = clk_prepare_enable(ov08x->xvclk); + if (ret < 0) { + dev_err(dev, "failed to enable xvclk\n"); + return ret; + } + + if (ov08x->reset_gpio) { + gpiod_set_value_cansleep(ov08x->reset_gpio, 1); + usleep_range(1000, 2000); + } + + ret = regulator_bulk_enable(ARRAY_SIZE(ov08x40_supply_names), + ov08x->supplies); + if (ret < 0) { + dev_err(dev, "failed to enable regulators\n"); + goto disable_clk; + } + + gpiod_set_value_cansleep(ov08x->reset_gpio, 0); + usleep_range(1500, 1800); + + return 0; + +disable_clk: + gpiod_set_value_cansleep(ov08x->reset_gpio, 1); + clk_disable_unprepare(ov08x->xvclk); + + return ret; +} + +static int ov08x40_power_off(struct device *dev) +{ + struct v4l2_subdev *sd = dev_get_drvdata(dev); + struct ov08x40 *ov08x = to_ov08x40(sd); + + if (is_acpi_node(dev_fwnode(dev))) + return 0; + + gpiod_set_value_cansleep(ov08x->reset_gpio, 1); + regulator_bulk_disable(ARRAY_SIZE(ov08x40_supply_names), + ov08x->supplies); + clk_disable_unprepare(ov08x->xvclk); + + return 0; +} + /* Read registers up to 4 at a time */ static int ov08x40_read_reg(struct ov08x40 *ov08x, u16 reg, u32 len, u32 *val) @@ -2072,7 +2140,7 @@ static void ov08x40_free_controls(struct ov08x40 *ov08x) mutex_destroy(&ov08x->mutex); } -static int ov08x40_check_hwcfg(struct device *dev) +static int ov08x40_check_hwcfg(struct ov08x40 *ov08x, struct device *dev) { struct v4l2_fwnode_endpoint bus_cfg = { .bus_type = V4L2_MBUS_CSI2_DPHY @@ -2086,11 +2154,36 @@ static int ov08x40_check_hwcfg(struct device *dev) if (!fwnode) return -ENXIO; - ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", - &xvclk_rate); - if (ret) { - dev_err(dev, "can't get clock frequency"); - return ret; + if (!is_acpi_node(fwnode)) { + ov08x->xvclk = devm_clk_get(dev, NULL); + if (IS_ERR(ov08x->xvclk)) { + dev_err(dev, "could not get xvclk clock (%pe)\n", + ov08x->xvclk); + return PTR_ERR(ov08x->xvclk); + } + + xvclk_rate = clk_get_rate(ov08x->xvclk); + + ov08x->reset_gpio = devm_gpiod_get_optional(dev, "reset", + GPIOD_OUT_LOW); + if (IS_ERR(ov08x->reset_gpio)) + return PTR_ERR(ov08x->reset_gpio); + + for (i = 0; i < ARRAY_SIZE(ov08x40_supply_names); i++) + ov08x->supplies[i].supply = ov08x40_supply_names[i]; + + ret = devm_regulator_bulk_get(dev, + ARRAY_SIZE(ov08x40_supply_names), + ov08x->supplies); + if (ret) + return ret; + } else { + ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", + &xvclk_rate); + if (ret) { + dev_err(dev, "can't get clock frequency"); + return ret; + } } if (xvclk_rate != OV08X40_XVCLK) { @@ -2143,32 +2236,37 @@ static int ov08x40_check_hwcfg(struct device *dev) } static int ov08x40_probe(struct i2c_client *client) -{ - struct ov08x40 *ov08x; +{ struct ov08x40 *ov08x; int ret; bool full_power; + ov08x = devm_kzalloc(&client->dev, sizeof(*ov08x), GFP_KERNEL); + if (!ov08x) + return -ENOMEM; + /* Check HW config */ - ret = ov08x40_check_hwcfg(&client->dev); + ret = ov08x40_check_hwcfg(ov08x, &client->dev); if (ret) { dev_err(&client->dev, "failed to check hwcfg: %d", ret); return ret; } - ov08x = devm_kzalloc(&client->dev, sizeof(*ov08x), GFP_KERNEL); - if (!ov08x) - return -ENOMEM; - /* Initialize subdev */ v4l2_i2c_subdev_init(&ov08x->sd, client, &ov08x40_subdev_ops); full_power = acpi_dev_state_d0(&client->dev); if (full_power) { + ret = ov08x40_power_on(&client->dev); + if (ret) { + dev_err(&client->dev, "failed to power on\n"); + return ret; + } + /* Check module identity */ ret = ov08x40_identify_module(ov08x); if (ret) { dev_err(&client->dev, "failed to find sensor: %d\n", ret); - return ret; + goto probe_power_off; } } @@ -2210,6 +2308,9 @@ static int ov08x40_probe(struct i2c_client *client) error_handler_free: ov08x40_free_controls(ov08x); +probe_power_off: + ov08x40_power_off(&client->dev); + return ret; } @@ -2224,6 +2325,8 @@ static void ov08x40_remove(struct i2c_client *client) pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); + + ov08x40_power_off(&client->dev); } #ifdef CONFIG_ACPI @@ -2235,10 +2338,17 @@ static const struct acpi_device_id ov08x40_acpi_ids[] = { MODULE_DEVICE_TABLE(acpi, ov08x40_acpi_ids); #endif +static const struct of_device_id ov08x40_of_match[] = { + { .compatible = "ovti,ov08x40" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, ov08x40_of_match); + static struct i2c_driver ov08x40_i2c_driver = { .driver = { .name = "ov08x40", .acpi_match_table = ACPI_PTR(ov08x40_acpi_ids), + .of_match_table = ov08x40_of_match, }, .probe = ov08x40_probe, .remove = ov08x40_remove,