From nobody Thu Nov 28 08:33:32 2024 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 D24CE1D0DCB for ; Wed, 2 Oct 2024 13:58:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727877530; cv=none; b=RK6Q1Bw9cVnxzatYXFCtiLbbxKj4dNljROIUNEG6V2jx3sRZ1+0gDjKNE1B6zcowzBjdFcdYHwwe4HvAU4wglSp/sEGL6hlcpEhnyF54RVSlfc+GUTuYqNJerMpCOX+ngK+EP41INGlzvQhXIXSCHaYQE/GkmyM1A4u0+6xFZFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727877530; c=relaxed/simple; bh=vTwVvG8iZlHzHza+YS67mEwp2zyunt+kNzBDYWtFYWc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kLaegB/TmeXz+mCqquRAic1DmJjBsirg0amuzGTsCBWmx78rz5g2lzXtZvR6QGtanJP84/DAGgY/UvaNeEudsY4fRgpYs5rkApe4TT+Htiya1+kIvSOGLTvVhL0tUoX4QmMBSNkohX1D33+7BEOdXcg8Rcpzas0EsxoYrxO5Hns= 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.53 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-f53.google.com with SMTP id 2adb3069b0e04-5389e24a4d1so6815536e87.3 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=LL4uACt8Q+fVWXy+Edlk9oiN+HU1QUXqgE00aVLv8sojfsXhQSzLqIZX8k7/GqG/Ey hRIaHSJTqwlNvmULVzww3SIMOl9gn1TO8PV5FlQ9KkDoBw2BT1UcYCZZdNBH85hzq4fW jrx0JiOE/8Vz6GNiYDhvd3FTQPQTd/9TWFXp3OxYyYN73X/14eUALxwwlLkeeOXsCtTV MyKy21TShl0HZs3uhoR97mym4TJtNJZYsuTewaHuxzYAofDiblXUQVj2eGUpZAXgRXMn N5zlUYF0QiJrulYTEfAm8WRrtUdidZTtN/NuyIkcNQOy+oi8uVXNwltolUGKaUdUmc8b lEeg== X-Forwarded-Encrypted: i=1; AJvYcCVmiSOCZYEJfY/s14793r+p6fo1smxVWsCX8XIbHPOZ1Bi37yitW1JMelFCEOiC5IPo1qJVkNBnCnsmAIY=@vger.kernel.org X-Gm-Message-State: AOJu0YztXC7abGreMbEbWuHSFXuQ8Gk9wKFjpuzDiIXDTXuaXx27qp33 nOIvikQJ8j7bZSI97dsVcP6m/Emk/VPmqHAn922Kb0AXr0eDGlbWt2pvTADPWL8= 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 29= 0, 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..be25e45175b1322145dca428e84= 5242d8fea2698 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; } =20 -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 =3D v4l2_get_subdevdata(&ov08x->sd); struct i2c_msg msgs; - size_t i, num_regs; + size_t i; int ret; =20 - num_regs =3D last_reg - first_reg + 1; msgs.addr =3D client->addr; msgs.flags =3D 0; msgs.len =3D 2 + num_regs; @@ -1373,6 +1371,31 @@ static int ov08x40_burst_fill_regs(struct ov08x40 *o= v08x, u16 first_reg, return 0; } =20 +static int ov08x40_burst_fill_regs(struct ov08x40 *ov08x, u16 first_reg, + u16 last_reg, u8 val) +{ + struct i2c_client *client =3D v4l2_get_subdevdata(&ov08x->sd); + size_t num_regs, num_write_regs; + int ret; + + num_regs =3D last_reg - first_reg + 1; + num_write_regs =3D num_regs; + + if (client->adapter->quirks && client->adapter->quirks->max_write_len) + num_write_regs =3D client->adapter->quirks->max_write_len - 2; + + while (first_reg < last_reg) { + ret =3D __ov08x40_burst_fill_regs(client, first_reg, last_reg, + num_write_regs, val); + if (ret) + return ret; + + first_reg +=3D 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) --=20 2.46.2 From nobody Thu Nov 28 08:33:32 2024 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (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 1492A1D0E38 for ; Wed, 2 Oct 2024 13:58:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727877531; cv=none; b=FrOsnLUZPe1lzi8f/4JcYS3JYtUx10t1w7+/LnhBl1G3chgs5IVi3UAcm7oGMGhEG3Mi+GRgFKvOWRk3x64LtsQ+eYuxxai1twnt15CCqD5TWvEDvEG/T0XxNBS7R2s/pD0LdybTKSZqBxNO0pYEukWHQrXjeG7HdSLGNummWB0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727877531; 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=ptzQlFstrjgI05p6Mz2j6fMSvlvJa9Jwc2Vdd27igYIMtRG7YGVWKahomr+3mDjIt9HrF7Bz4W8vZxiLye6c9k2oa60M0RQ9HOlEru/BQh1uuhoeVnmkPR6f8eCiuc+cmYUyYBI8nvd2iz4ymN7G/YWVIZ7qBSZ8l/dna6w+MN8= 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.208.179 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-lj1-f179.google.com with SMTP id 38308e7fff4ca-2fabfc06de3so46051221fa.1 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=I4O78BEwwftMErfoBht3OfN1lh0Gs/hisWMNbtKtq+biXBeBqm3GmxIW0LMGpWCTYH 55B/cDEBfDhGuJtAGKYHmrRWO/c0BQEsHSU/LbB2jkAZUw3pPMPEKOWKkO2G1EfXBskc gVQ9CIADuluDbiD5hNNMgMerL/2yk1L+EAKlJTt1SLSL63jCAFX2TYfPFivaKT4BDi0m T7A04tUyh2m9/O2/pFgY0sxdov2/OPM4kTOgoQyilnme+GYpwBkd/TPeloJam9E3CqJJ DNoiFpo6J0w8PIqoXKeXS4XFksi4R81H+76Ahly2nDRJgsmWoftWj4NzAlVj0seVfrIj 7dfw== X-Forwarded-Encrypted: i=1; AJvYcCWZqD2vOa6GrGh95qWP2xam23xBjjJ8FMMwaPp9NU8D19F8OUYRnvo4juLUEV6J9VlxUwQHSznn7wrzh4w=@vger.kernel.org X-Gm-Message-State: AOJu0YwRfyBr0VQELYHJubLm10p1D49jL4VKvPrlnppr0Bg5SiXaZTAC fbPx5ENa/rhccKYLLIV4bRvmDpb9fYTMItZ3nckkIG/2fPUorzsUsvXgOc1CsRI= 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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..74b33a083efbe91db0fa4e7e7bb= 6008a95e4e4d6 --- /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 suppo= rts: + - Automatic black level calibration (ABLC) + - Programmable controls for frame rate, mirror and flip, binning, croppi= ng + 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 =3D <1>; + #size-cells =3D <0>; + + ov08x40: camera@36 { + compatible =3D "ovti,ov08x40"; + reg =3D <0x36>; + + reset-gpios =3D <&tlmm 111 GPIO_ACTIVE_LOW>; + pinctrl-names =3D "default"; + pinctrl-0 =3D <&cam_rgb_defaultt>; + + clocks =3D <&ov08x40_clk>; + + assigned-clocks =3D <&ov08x40_clk>; + assigned-clock-parents =3D <&ov08x40_clk_parent>; + assigned-clock-rates =3D <19200000>; + + avdd-supply =3D <&vreg_l7b_2p8>; + dvdd-supply =3D <&vreg_l7b_1p8>; + dovdd-supply =3D <&vreg_l3m_1p8>; + + port { + ov08x40_ep: endpoint { + remote-endpoint =3D <&csiphy4_ep>; + data-lanes =3D <1 2 3 4>; + link-frequencies =3D /bits/ 64 <400000000>; + }; + }; + }; + }; +... --=20 2.46.2 From nobody Thu Nov 28 08:33:32 2024 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (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 AE8C41D0F5E for ; Wed, 2 Oct 2024 13:58:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727877533; cv=none; b=LKp5kv01lxLUK63ziFy3T52xCH2XoHlEuhKgfIARDIqkv9sBSJ399Pxz74Fdk/pH8FqGQmcGbvr2D2ykC+AR32Wf1swd/ByRUkvGcf8GxfQzgmejCMOzDsPFs1O2mkXwhbBsUm75VbE51I30N36l/+Vf82mEnsXpp32eHPT8kqM= 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.51 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-f51.google.com with SMTP id 4fb4d7f45d1cf-5c89f3f28b6so3404703a12.2 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=fG2eo+5iBZmz6IW1YkOvlFDRMy7Hw31E4HMPx1COwHsdqyY1yaWwCZSG7hLMIPXynO dqDmgl8w/0FxDrT0JEDIAKD9hfW6MWagSKk39iNA3VZ5viJKPN1EZTgTJYucamOZwqCQ C4jGd0ift9IBPtA88ksNvX5VIf8X4g0S6IXtOu/Yi4sV6+HNNevgIF9Ljs+5noPgVIBa vzv1UPrzc3wz8fzs7D0CjBWjdiVCQ2BpisWPg/UWsjdno17Krruc/h8I3jbaZZL9P9rt SeWBFBI5cb7Torg1HuIdYWElg/kAamSkRfq2DL6RUdW6cJWJBcthMOSBFozB9M+s84w3 JftA== X-Forwarded-Encrypted: i=1; AJvYcCXOcpGHuVbx8yRqvpxQtHLmPggjCqE67HBkskfNXhlhpy7fH0eaH+GyD9Az2SRhw3NPKB4tRRsBidpkjPM=@vger.kernel.org X-Gm-Message-State: AOJu0Ywg+0JXl9vuvw+G2qdZklUABMi6pBgPE6UPflaY0dLf/GLsOa4N VYsg8HIwj2WCoIJdEVC8kTvwXBytHkLexY/emGOYTqiKT3qTVsujhelZ2xIM0pE= 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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..3ab8b51df157af78fcccc1aaef7= 3aedb2ae759c9 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[]= =3D { /* 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 =20 /* @@ -2081,21 +2081,21 @@ static int ov08x40_check_hwcfg(struct device *dev) struct fwnode_handle *fwnode =3D dev_fwnode(dev); unsigned int i, j; int ret; - u32 ext_clk; + u32 xvclk_rate; =20 if (!fwnode) return -ENXIO; =20 ret =3D 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; } =20 - if (ext_clk !=3D OV08X40_EXT_CLK) { + if (xvclk_rate !=3D OV08X40_XVCLK) { dev_err(dev, "external clock %d is not supported", - ext_clk); + xvclk_rate); return -EINVAL; } =20 --=20 2.46.2 From nobody Thu Nov 28 08:33:32 2024 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 1B7641D12E4 for ; Wed, 2 Oct 2024 13:58:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727877535; cv=none; b=CiQIpOGY0O0ctcFCxGZ1dUSo3dXKdOJYNDHrhg6J+KmJV/MkT4QF6qGVS7Y5TCekznufgUTcx2UGumIQBWV70DseYDuJWz1a5ntKbYIOVe57Lu0jC388k1M4WSJYnZAofAl/Jha3iXMQR0cr7dmqzns4Y7+IWeMqU9Hml9m19HY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727877535; c=relaxed/simple; bh=LL6t0/fJmZI9eHhzlG/ZhWayuHRs6YWaQKrP0a5lAkU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fmwK3LkFYJAADdjyTDqp/3fffVFyxbZ2fFl8jmp66kjstqb0PTFuqprdgacdy56/YhJBNuIaH+OkWVU7aslWVXfgFehg2Z+g6WXvn+iFKi2goXsn0IE2o2ww0VkQWFLuIb71/VQSeKyIN9RViGhuLgeACA1kLQegd7AUO2pnTjg= 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.175 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-f175.google.com with SMTP id 38308e7fff4ca-2facf48157dso38540801fa.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=M5Uw3vz1jo5zyTi0j3+7ecH6zsM3WGYjZVYn4l3IbE+Ee375S1Qqj0fwkdCqXoZnMP RRBiJ0JQ/Nv0kXsOAFj8eJQI7QPn9J/bfMbB1TzQsx7Q+54deQVtm/WP/fZYGn2p8xLN DSXkI6bX/Z/e87N3X8oUf+P54NTyM+AbbAt2V7xBhxkNPDIH5aMXeA+jkGJ4ywS+ya9l AB6+1IFsxEFTcU6+GOoNugcFKOpOkKuHbw63bhqyVOUbEGprNiFIwlMx7BvxYgISxyxB tvzCjuy4mZaAUe3S4MlCMajxYm8FFSzxBe4PLwlfrKu6xdWH4PsCtxiVSbH6hooK99ve tfhw== X-Forwarded-Encrypted: i=1; AJvYcCUKMCCL3IUhBnc4iIlyHuFTcUbB4lzef+kxFOFn9PxY2LcWuazuSaWD6xKREknj33q3VwjzXyASCjclmjk=@vger.kernel.org X-Gm-Message-State: AOJu0YyCIOJevGh6ef/brsdCSjO81RXE0WAF+Lwj2QX7ZT+gkPUtERGe bq4/uOW0iRSwfYm9oJPxEaJEUsfHQfLysMt4etah5X89QeZ+HGi9BD8RiBjJXio= 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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..821102287580acecd544402254c= fe0fb5c8dc299 100644 --- a/drivers/media/i2c/ov08x40.c +++ b/drivers/media/i2c/ov08x40.c @@ -3,10 +3,13 @@ =20 #include #include +#include #include +#include #include #include #include +#include #include #include #include @@ -1279,6 +1282,12 @@ static const struct ov08x40_mode supported_modes[] = =3D { }, }; =20 +static const char * const ov08x40_supply_names[] =3D { + "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; =20 + 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; =20 @@ -1303,6 +1316,61 @@ struct ov08x40 { =20 #define to_ov08x40(_sd) container_of(_sd, struct ov08x40, sd) =20 +static int ov08x40_power_on(struct device *dev) +{ + struct v4l2_subdev *sd =3D dev_get_drvdata(dev); + struct ov08x40 *ov08x =3D to_ov08x40(sd); + int ret; + + if (is_acpi_node(dev_fwnode(dev))) + return 0; + + ret =3D 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 =3D 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 =3D dev_get_drvdata(dev); + struct ov08x40 *ov08x =3D 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 *ov0= 8x) mutex_destroy(&ov08x->mutex); } =20 -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 =3D { .bus_type =3D V4L2_MBUS_CSI2_DPHY @@ -2086,11 +2154,36 @@ static int ov08x40_check_hwcfg(struct device *dev) if (!fwnode) return -ENXIO; =20 - ret =3D 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 =3D 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 =3D clk_get_rate(ov08x->xvclk); + + ov08x->reset_gpio =3D devm_gpiod_get_optional(dev, "reset", + GPIOD_OUT_LOW); + if (IS_ERR(ov08x->reset_gpio)) + return PTR_ERR(ov08x->reset_gpio); + + for (i =3D 0; i < ARRAY_SIZE(ov08x40_supply_names); i++) + ov08x->supplies[i].supply =3D ov08x40_supply_names[i]; + + ret =3D devm_regulator_bulk_get(dev, + ARRAY_SIZE(ov08x40_supply_names), + ov08x->supplies); + if (ret) + return ret; + } else { + ret =3D fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", + &xvclk_rate); + if (ret) { + dev_err(dev, "can't get clock frequency"); + return ret; + } } =20 if (xvclk_rate !=3D OV08X40_XVCLK) { @@ -2143,32 +2236,37 @@ static int ov08x40_check_hwcfg(struct device *dev) } =20 static int ov08x40_probe(struct i2c_client *client) -{ - struct ov08x40 *ov08x; +{ struct ov08x40 *ov08x; int ret; bool full_power; =20 + ov08x =3D devm_kzalloc(&client->dev, sizeof(*ov08x), GFP_KERNEL); + if (!ov08x) + return -ENOMEM; + /* Check HW config */ - ret =3D ov08x40_check_hwcfg(&client->dev); + ret =3D ov08x40_check_hwcfg(ov08x, &client->dev); if (ret) { dev_err(&client->dev, "failed to check hwcfg: %d", ret); return ret; } =20 - ov08x =3D devm_kzalloc(&client->dev, sizeof(*ov08x), GFP_KERNEL); - if (!ov08x) - return -ENOMEM; - /* Initialize subdev */ v4l2_i2c_subdev_init(&ov08x->sd, client, &ov08x40_subdev_ops); =20 full_power =3D acpi_dev_state_d0(&client->dev); if (full_power) { + ret =3D ov08x40_power_on(&client->dev); + if (ret) { + dev_err(&client->dev, "failed to power on\n"); + return ret; + } + /* Check module identity */ ret =3D ov08x40_identify_module(ov08x); if (ret) { dev_err(&client->dev, "failed to find sensor: %d\n", ret); - return ret; + goto probe_power_off; } } =20 @@ -2210,6 +2308,9 @@ static int ov08x40_probe(struct i2c_client *client) error_handler_free: ov08x40_free_controls(ov08x); =20 +probe_power_off: + ov08x40_power_off(&client->dev); + return ret; } =20 @@ -2224,6 +2325,8 @@ static void ov08x40_remove(struct i2c_client *client) =20 pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); + + ov08x40_power_off(&client->dev); } =20 #ifdef CONFIG_ACPI @@ -2235,10 +2338,17 @@ static const struct acpi_device_id ov08x40_acpi_ids= [] =3D { MODULE_DEVICE_TABLE(acpi, ov08x40_acpi_ids); #endif =20 +static const struct of_device_id ov08x40_of_match[] =3D { + { .compatible =3D "ovti,ov08x40" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, ov08x40_of_match); + static struct i2c_driver ov08x40_i2c_driver =3D { .driver =3D { .name =3D "ov08x40", .acpi_match_table =3D ACPI_PTR(ov08x40_acpi_ids), + .of_match_table =3D ov08x40_of_match, }, .probe =3D ov08x40_probe, .remove =3D ov08x40_remove, --=20 2.46.2