From nobody Thu Nov 28 01:21:52 2024 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (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 3D80713EFF3 for ; Sat, 5 Oct 2024 10:31:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728124273; cv=none; b=rdS3ayH4MYr8llJm/IiFEE6ZkxF2AxXaaLSWNs/2zHDFHuU1q8p67/lVMyG6qlyaoqCrebRiR5AsS9gk/+rgUE5W9mcC04c1T6zs4aC3wDrxhkdHPEwCFBQK3J+u5GD6J1+IMjcmwf+ZnvvhAioRAVayySXnSbZJhsvsVDvWxlc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728124273; c=relaxed/simple; bh=vTwVvG8iZlHzHza+YS67mEwp2zyunt+kNzBDYWtFYWc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QSXt8kSI4MMwDL4MwiwxQdYzehTsz/5ZzKQeW2P2qHjkO4eDzrjQQwpJBrvTr1fsR4qD0NK9MgHNeO4tpQ4VDHmpIcIAjcAEGwcSOGcWBYV8S+FquYl59/ChDx9qyAwBBdO+I8qaZHGVQrw1dPaJqCqfe9MXHzaXE4TiQ1IIM+I= 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=mnpatQ9G; arc=none smtp.client-ip=209.85.208.52 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="mnpatQ9G" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-5c42f406e29so3656284a12.2 for ; Sat, 05 Oct 2024 03:31:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728124269; x=1728729069; 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=mnpatQ9GEEEMayWewFkEs5Jrn6hI6nlA/jNRwo4KPX1V6Zi1cchTK2DhbBeYgwV6Jc tnKgq3V2QTK0j1jljiXdcsJNFPSR3JwppcwgVT4s42dk/IMLtn/wfsGYj3u6ndPBhzId Kkg6fPnfpqQ8hBPzJTX3plE5wXfj/sbcvKREM4AxxejfRh7+X3kVpJyx+9jhUxjmQv+N 3Rxl5rvN6XWiy2Q85Ld0zUbLeXXa+3cb9AR/iNJPoTebVL4qiLdqwug6eImtLxFoHxHC 0y1rh2yt7bmQ2FGWxUMt5wtPjTGWnLkEY7G3OVHWmDC//cpKcJ5ZBVlo+oH7OvQosOjU xMgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728124269; x=1728729069; 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=gyikl9XvbstheaqPLL20lfaPYbzojot3d0Hrx54/4UfU2hwZ3Fw1cTjwLrQDVm76fj W/dbJAxOHCsNRpQF9WoUSUFomkwDXoVvjUU42TZqFuKIbRfINbkntydPfNKtR5zm4pCu TOtInXhjIPPnlsfB+c4Lu4qEA4D2gwGIvXlkZiaqzYK9pykiR6eu/fhtp2RqkRZwgz2a R9b+cPejdJdRyDdRhGz4S3fKpX97RxQRPvtVUmLPXa32SGtVMPgohOH8fNqkS2PywDLX Lywwa6EPrGYo54Y8Uy3UE7d7P0NRqZuRfBIVwODuZQO6i54J10K+5Qj3CHUy61SiqwaQ NgsA== X-Forwarded-Encrypted: i=1; AJvYcCXjICSBB8KaK17Ut0eUyBSITgwop9/igSKostpMAdNxEtzATk9lRIt0oOu7PWC5jNq/731Q/9KJYb9wFGQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxVUPELBs8TCYD8TQiPNRc7nrAhf/6S4ig4RDJgXItj65hLSJZi WeHHRdaI0RnAP7j6eS4NmWMdTx6W5ox5aQs+GjE/ki6AR0WBt7pe2n7m7aVg7v8= X-Google-Smtp-Source: AGHT+IGMw6qNSWut4ShGQ2E89T3alI/rY9/tMRu5/jv2l5XfRLkJFb4c9fLiEXAjApPQ+ggWZtlBlA== X-Received: by 2002:a17:907:25c3:b0:a80:f6a0:9c3c with SMTP id a640c23a62f3a-a991ba979famr577085366b.0.1728124269473; Sat, 05 Oct 2024 03:31:09 -0700 (PDT) Received: from [127.0.0.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a992e7856bfsm116315566b.138.2024.10.05.03.31.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 03:31:09 -0700 (PDT) From: Bryan O'Donoghue Date: Sat, 05 Oct 2024 11:31:03 +0100 Subject: [PATCH v5 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: <20241005-b4-master-24-11-25-ov08x40-v5-1-5f1eb2e11036@linaro.org> References: <20241005-b4-master-24-11-25-ov08x40-v5-0-5f1eb2e11036@linaro.org> In-Reply-To: <20241005-b4-master-24-11-25-ov08x40-v5-0-5f1eb2e11036@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 X-Developer-Signature: v=1; a=openpgp-sha256; l=2802; i=bryan.odonoghue@linaro.org; h=from:subject:message-id; bh=vTwVvG8iZlHzHza+YS67mEwp2zyunt+kNzBDYWtFYWc=; b=owEBbQKS/ZANAwAIASJxO7Ohjcg6AcsmYgBnARVpPvMthR5vaCpvzYZx2Ib+Iducs9nYCFnN1 kMDZUqdG+KJAjMEAAEIAB0WIQTmk/sqq6Nt4Rerb7QicTuzoY3IOgUCZwEVaQAKCRAicTuzoY3I Ohj/D/49VOqkWw6B83cchu7024YSwZ9ifrGHWKGj5dPQ/pm5R19PW26WsWa9rD4GKbaz8Yc+ZZw qoIiRg+ezt6zLVHtRjS6xIM9k8tlZYGEyNoKtyqJGO54XJdkNiJc6P8cEcStc7YGOne9VV0/bFL FSx2wzfl1K4qmeiSn+sS2jV46Kbv/tjCXPQwgeEpv70mnkeQ0EA4AYOTrlVBmmNaSHMPrPW4DVE xIhnrV3xpK/kqwuAXSKdQGG0nFL+iAGMp3B0205d/l/PHqhuTFBGn14Zzm/pTmqfxOdCw763PWY o1YLwipqSyEcV/wtg7Abr6cIUeAu+2q09nasK2hla/bUdgNWoEnyXx/Vc+/7TwTZvd3e2K5ACys sJZlgUdlXQLDpZO5VeZC8xUEIew9i6d7nEm0SkwEMgsGKwS0VgyVHgOgDTo4PcGyyggx6ESl5ni IusIKJlYVKqpR3JYlRvmrDaLMSNUKQRGJhx0Jg5Jycrg3ZZSxe3YB+eor5oh3r9Ekf6xWoY5IcO xvA/5zvwRKDbWYUORrqVy2idpiPdK6T3huVpvn2lJshU+3qybWkyTg/vIFclJb673AL+AcD54+8 Dovy2QRQMtreUzbPnbf8ehZ7B7crZjvGFlHONpM8G/Xzb/876xaePKi+dhDpflmHfkKrFoLpUSn TN06H04H50FCceA== X-Developer-Key: i=bryan.odonoghue@linaro.org; a=openpgp; fpr=E693FB2AABA36DE117AB6FB422713BB3A18DC83A 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 01:21:52 2024 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.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 D6EE61494AC for ; Sat, 5 Oct 2024 10:31:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728124275; cv=none; b=YR2U+ACZNXllY2KBIE6/6HYVMwn+SeB1NmZKO57jvUo6QwwUENsKxqa2U60tgp+3vY6/tG2X1Aj6zCMd6dt7zzVzGmLGrYUQTYUvRqIbYe78YWXI+YlYxponcWVpngOf6QXyG0EF99009J/ITqSnNDyBplQMvg42boraBhlqfyc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728124275; c=relaxed/simple; bh=mYuK773IRT+YGybwbHjM35dYaPg0a7sBAF8PXfbece8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ld3PsKd0kkyX+Kbe0JcbM/Wt/eYOsrgseMnZfNjCiLfFl4rwBkwzgSKSGNXa8yRPVC7SbplsjyblTwPTHz0z9lxTwRg9X/zNHUokRJszUZHmcUfhwDGUe/IMWk6rcmkVPB6IQuHYJa2Iam2XJbq7kstRKN4k30TGPyMmNH3p2qs= 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=wnibTZxp; arc=none smtp.client-ip=209.85.218.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="wnibTZxp" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a9939f20ca0so63719766b.1 for ; Sat, 05 Oct 2024 03:31:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728124271; x=1728729071; 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=HwzWgYqivhHj7+dnzlG3c8h9sTHdrV9evRLKyR/6z8s=; b=wnibTZxpNRHdCTy6d5LflvJ1BSFOsbKXF+I1oUV/GUoYEiaBvkvxUFGi73Rgb3R42A 5QwzgpLqIPpmYO+Y0VDACO1Shy9ufBHOepxqe0uEWUpjOtAMTnXMdcAY26PL8HtyTXII 7JCFir0maxZz1QaVFjCPPVD4WUSEYtYBnMBlKiSlYI7YCA0brL1/8J6a4FV82HkPygDv pYW4+esBmRSCCtEUPVwEKJyDze07cje7S+juMxm04LPfYWJvXrYds10zYViir9g37F/y Utxpor1fc3NLKyaRQgYAqb8ReVk4hG2Al5DavS8EGPZBS/L1BUkdsGAwgHsu9Uvid4oG uKXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728124271; x=1728729071; 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=HwzWgYqivhHj7+dnzlG3c8h9sTHdrV9evRLKyR/6z8s=; b=ozCDRsSTD2Fn+WpAYufzi49ye1oIqPdJBm3lb1IRlgMnLYLDWr3f20q6k/T42VrFdH 3M/g4gjhI7uUrZinyGIQat5f8G5h2XAqKgUvJJmN3nsFq9ZoJ/FgZ7PfWqDoyTbinKm4 7rN5NtJR4qLcx2f0frl62nOUDzUL6xqC0fIe74PQOjrsmtOcxlHePUmLxL4Zb811Otcq JdP3PltTB/QMm8QKK+rlQi+mgRCHqbjCioWttIkohrNxxaGpTRc1JovqeW5JTTYeCREy pGOZXHEi4FdOZnIvj1bVqkErBpkbd+2dp/kGdhRmYdyeHqOG9AaJeFFRgB1R0/FKWk0D koFA== X-Forwarded-Encrypted: i=1; AJvYcCWxZbNeBy1mAe8GoAc1QmVkDFrmKPMEvX/JBLpgICOGba3Ifa88nAuUmwE21A1bH3it7bS8QQ6T2oEXwAw=@vger.kernel.org X-Gm-Message-State: AOJu0YzDHvXuMmvtN5wfVjUHlYtld5OGJ0GAOoDWfXUYMwZZUMYLk5r+ rL7hxRIZIRXQY6f8bpSAQQf1Mop7qoPgUvWCga5i+5EHpGpHyjLI2Zr5dI+YhPk= X-Google-Smtp-Source: AGHT+IEOPMtL4BVfUFgMWZuRnFGsRtNqb/uP3ixzcZgVM2LYwmah3ZToT5wqwMDj8CDUs2Vq8HgMQg== X-Received: by 2002:a17:907:3f04:b0:a8a:8d81:97ac with SMTP id a640c23a62f3a-a991bce418emr642020966b.4.1728124271181; Sat, 05 Oct 2024 03:31:11 -0700 (PDT) Received: from [127.0.0.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a992e7856bfsm116315566b.138.2024.10.05.03.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 03:31:10 -0700 (PDT) From: Bryan O'Donoghue Date: Sat, 05 Oct 2024 11:31:04 +0100 Subject: [PATCH v5 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: <20241005-b4-master-24-11-25-ov08x40-v5-2-5f1eb2e11036@linaro.org> References: <20241005-b4-master-24-11-25-ov08x40-v5-0-5f1eb2e11036@linaro.org> In-Reply-To: <20241005-b4-master-24-11-25-ov08x40-v5-0-5f1eb2e11036@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 , Krzysztof Kozlowski X-Mailer: b4 0.15-dev-dedf8 X-Developer-Signature: v=1; a=openpgp-sha256; l=3716; i=bryan.odonoghue@linaro.org; h=from:subject:message-id; bh=mYuK773IRT+YGybwbHjM35dYaPg0a7sBAF8PXfbece8=; b=owEBbQKS/ZANAwAIASJxO7Ohjcg6AcsmYgBnARVpRfAm2zMkwC9vLk5NPBOv36YYy3xgdQzhd FR7OjAR2zWJAjMEAAEIAB0WIQTmk/sqq6Nt4Rerb7QicTuzoY3IOgUCZwEVaQAKCRAicTuzoY3I OgEzD/9OGf0LkAtJLwcxh0LsUp7S2uA5/4Nf653XkuGpLS+BWoCutUixaaTZpITXOzA+vWSc4Ud wAqbU0Dyh8o9a0cqoT3G6NMI6iMA9+e6o0lsG9QHH4qXvpjKjBMe6PG9u9Mb2Z+YTgUHCeIBAFQ 0fCYGS3Q/6Bvi8gZ1dlAkHc/CwJ2V2Ek6aswF60qRe1jATzWHdHFIKTH4PnQTNX5OcJCMiDtA83 8jzenjk3uHeopuOtkp05A99IEaKpWUkV6qvP7jQEgWEjCRFouYKWX4UG9xSCdWqRQvomAwN0slS TVXGd7Z35BioXpMLjqUrvAbIU4w8v5gJWtDpnDR+YMCOZi6mHIpnycczNU0pxZy7+cCJhq/C85X vomoSwAwdF4SeBZPXVTjRHx9qwIRRXYVdGxZaxTKFYqC429wTxmynAuy4hFZ3S4A/hh3QA/veNk 0t3jwKyc8qjN4dNWwXlSrXjP1chU/aCHodh4O7I8xM6YnFLgDjNOl5yfVgf2umMcSxHL8I34tzf ESXZEUDsAZvVKwYqUZR0hcsOI5u6wmftQyFPULVIcY23EHapxNWrvs8Cj66gldbCtv9U246RSTN vX3NwI0rJk+/evjWNfwOdLBza44sqbVYpXdZ9Xdz14r53X93ngO58SWKTgAoQFbEyeVPy3LeBFp HfLvsEku8kGI6yQ== X-Developer-Key: i=bryan.odonoghue@linaro.org; a=openpgp; fpr=E693FB2AABA36DE117AB6FB422713BB3A18DC83A Add bindings for the already upstream OV08X40 to enable usage of this sensor on DTS based systems. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Bryan O'Donoghue --- .../bindings/media/i2c/ovti,ov08x40.yaml | 114 +++++++++++++++++= ++++ 1 file changed, 114 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..51f29033e1d94b1822fcfd90a6e= ee4bacd677c18 --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/ovti,ov08x40.yaml @@ -0,0 +1,114 @@ +# 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 + + 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 01:21:52 2024 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.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 BE75914A0B5 for ; Sat, 5 Oct 2024 10:31:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728124275; cv=none; b=ARZBItxIzQlj2cuLZ7vFo9NNAXzq5OQJvOUg5iwbkHwoLpWBRLFw8LgzHlDFLdIz5V4+aUdGZNI+GlhZ/M7rg+InR2+gjHdr5fJFFYM8zhHTvKpdphU+Qs7vPAG0Fuf3r51B4yMQzgUFQGlRemm5xgFXNs2tNHu+1XCmKU5JA1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728124275; c=relaxed/simple; bh=KuJYhS6BLwFHq2M3BsUApExs70W98G5/TG0tISRMP7Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=B/hp5vft+tTlrPPwaz/USdQ3XvkBMuYgw97tmCUdLo4CYlxO0WJAqoEpzHeZyD9zvwsFwHDzBmOQ93tlNd9PdIdHwGSyreF5N/uRBwbl52wUw+nkpM7ItVGTneNROLAqDLwSwuNZpDDJX7MLaCnEDQn/ytXimRI7nq/T5wSlIWA= 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=XKnMFfsi; arc=none smtp.client-ip=209.85.128.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="XKnMFfsi" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-42cb57f8b41so37315305e9.0 for ; Sat, 05 Oct 2024 03:31:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728124272; x=1728729072; 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=XKnMFfsiTHJjgIdseT6Kn5dvPFbvqggbHyJftH7ZvxhXGplPDShhe+XHWLjnnyYxyz IZmMwHvssoiJLsrlI5/sviWLLrXUJwUX4FNbAMVxxQcd8Sq35HDqStZ73j2+LelQJDQM LavjZP+vjwimN+JJXvkrQmVMBEcIgNjA75IP1S98azEfdBPtZTYN1BaimRgj6rySbNYW wlo0pH1LyAfndEZkXCpU7AJlwRw0Vlp9rUykGTy6KWBBjuMpMCi9D6rcSonvAs/IkHxD 8zGdwjQOU0sMGnsRQq3qWrG/adZsWYXRYzyHeIy3GMRAdPSgPdiURTgZllYZDFGxqSsH QhGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728124272; x=1728729072; 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=JSQ+zRk8ImpS2nBXVXKVjUWyO1l5pput86Fu6+uMs+CRCZoKVx7qW5S3ppRCEhp9Vq tnolsDScyZTCzhaCwXA20NUdkSo1DqaEyLut8+Pw89TSTaLRUOQ3rBrjXdL1czIsA8TL bwuHElqvIXN0xxmi9YpRxGHNbG+WOT8UOq8odoRdF6KLuM6d8oBgGz3+Kttys5OpFd7r 4dnK8mK3pOBVKbbB8k1sGwMygbZWo6ck50KtFg5q8iLOb3vwRjjzRFqVIVqM8DN84Zso 2snd9xFLaLqdzYZBzmTWz6PcRGQ+TCatCHczUR8Aj4Vr7km/PDwKcKcttsy8lDiph1Q+ WEkA== X-Forwarded-Encrypted: i=1; AJvYcCX3qLJSacA7557+mNVu7zMxHW9frGgzvS6VPQyVnwDgQW2/anE3q6PNlvHNdhU0l11bxeqHOE7IhkHvbLc=@vger.kernel.org X-Gm-Message-State: AOJu0YzRz3UcmNXAUVCWhHOMTl0oxv4B/Y6+OOyt0KsjV9nlV6PBw2l+ /oYIS+oouUGrIZvmVUIc0eHL//9xbAay2KjQQsHFeIBUJ5wbD/AnN2bZlxLJf+A= X-Google-Smtp-Source: AGHT+IFTJaGLuVeiz/URrKiFMl/ObSaOX7rTRCjs+ik5O7L2vVG+w8UUYNMwtTMYka30+t859f4IYw== X-Received: by 2002:a05:600c:293:b0:42c:b802:47bc with SMTP id 5b1f17b1804b1-42f8db3e896mr4351935e9.34.1728124272164; Sat, 05 Oct 2024 03:31:12 -0700 (PDT) Received: from [127.0.0.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a992e7856bfsm116315566b.138.2024.10.05.03.31.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 03:31:11 -0700 (PDT) From: Bryan O'Donoghue Date: Sat, 05 Oct 2024 11:31:05 +0100 Subject: [PATCH v5 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: <20241005-b4-master-24-11-25-ov08x40-v5-3-5f1eb2e11036@linaro.org> References: <20241005-b4-master-24-11-25-ov08x40-v5-0-5f1eb2e11036@linaro.org> In-Reply-To: <20241005-b4-master-24-11-25-ov08x40-v5-0-5f1eb2e11036@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 X-Developer-Signature: v=1; a=openpgp-sha256; l=1588; i=bryan.odonoghue@linaro.org; h=from:subject:message-id; bh=KuJYhS6BLwFHq2M3BsUApExs70W98G5/TG0tISRMP7Q=; b=owEBbQKS/ZANAwAIASJxO7Ohjcg6AcsmYgBnARVp5Gj1nry9lNTa8Pb3pZfveRm/Y1XwWca4P l80hK1hq7+JAjMEAAEIAB0WIQTmk/sqq6Nt4Rerb7QicTuzoY3IOgUCZwEVaQAKCRAicTuzoY3I OhsREACsz83KNPTLwh6GOaVyVHVFSyU+OW6Ws4BItgxBfGhIxAygKNKYlFt3ZakuK90k9s6f82V co152IJh6OfHhgGnAxcBA01TU+IrYnC2b4eUkLryXSq+jk/XRZdbWI2xsWTIJBNm2gUcbTjQtiZ rjX0a/GfjD0vv+TUZyX/JrnH13oO31GesrqdLtaBSh5dbHl2yudou3//+rqGil1xL8tMbhsMKY5 8jpoJI6MmQiGYm98UIn36eBeBE6lBnPF6J80UVfBs0ce96Zrg8ZWmhM1w86XRKKZYJwThgKUXFN Khl8ifOzXpBirKsMCrJxNVJS0uh/cKkgjRVF/5uM5+XXV08m07G32apN+xvCxMAK67LAoFCuxSA 8W9X394by5pTS0n1Ty82AqI4U+xKHrhp4H0xkaL1LilkPuTulq2WQsz906ziUmoXTA8V4C60Jf2 cngUSoN3oVDh6tVx7v390/7LYACheVZgV+gx0mMsjVYGf61WLRBPs+tc+/xYo7gqvqRSfzxFzWg Ifc0vURWgRuHdtYQP3esDXcobsI1v6qNd5GE+y1MLV0b036exW0TuzvtW3xZkUWkEsX+2n3Uw2n PQqQUdMLO5Mh7nSwZxseZI+goV3+KeaP8dGBuzaiYyYxyOOrtzhNM4dlMrLCZiPY1PEg2HiQYOu uzotZ/poXcPbEUA== X-Developer-Key: i=bryan.odonoghue@linaro.org; a=openpgp; fpr=E693FB2AABA36DE117AB6FB422713BB3A18DC83A 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 01:21:52 2024 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.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 DFFFC14B94F for ; Sat, 5 Oct 2024 10:31:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728124276; cv=none; b=gCmQsMZtFPdUoy0l0eEJ9oD6iIWxDFJc5VNET0CHZ9sflbxXU0QDC3zZDSast/euALcgFk1yCbFpRguBF6TRHMG7MFVW8rx8eKLNgiBpwM7qSTQPCFbqz2sgUcb10gMFhxLMqdoTdL0+CQD391vCT30reVvQpn27K16qduxVtcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728124276; c=relaxed/simple; bh=MZdA/sRLAsmvUPZP3TphhP3dJzkLom00eAxDcabblxk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dMH+6Jb0dMemfRROmM5k8isNpYI/0CKXMsMxGCXL2IMGKdIxTGnNPUcpoFwtRgjOPeQ9E7kJXkUo+XSdItWjuuz0+Iflsqyyqq+ArheqmH7Ne4brDd7baqjxKNjELvcB7AsV/3Ws+pGcnFVdxIDiCSMwaSyvE0R8qyIJa8J7oFk= 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=ensFfRQa; arc=none smtp.client-ip=209.85.218.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="ensFfRQa" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a8d446adf6eso467307466b.2 for ; Sat, 05 Oct 2024 03:31:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728124273; x=1728729073; 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=pseR3SnwJF/ltwSCthgN9v3QXyD9/cz3sKkOTqoReDs=; b=ensFfRQa3eqA32dNxca6TT/6FIAnSIpIS9vBe7YwVSFb9Po2PUZ1kYIvkrwCsy3gDu ZSBIv2ky6rSV/fobclDah8S1f82MbND5I8VPxlJpVGt1OqDkx6UWNlgnmAua7OQLJam7 6yDiIreYhL57xtE06sOhpplXISQD0OIQg7l/sfGtBCj6ctS5fy3PNYVXzSCaEH9C2of6 NSgIqlF9yBXfCum2tvT+YyynVF3J7iRRWAx/wPi1WvaUvohMlodvKsAB4u24UI94pF6F tmbgeUmeRbrLZs8moZHxLQ90SpTpU7XRQeYRFN5Vpg8rFz/DgCeQ4NTCnExbBYeurSFY YE5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728124273; x=1728729073; 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=pseR3SnwJF/ltwSCthgN9v3QXyD9/cz3sKkOTqoReDs=; b=a2L2dSqZ8+ALea8pp4bb3a8BiPrQ8DWbjuV4vASKDVxLt4j5gebdTJLGgu/1VDHr/f maCxPaeswoIKacDbAkPZjgZ0hrmJGZzMPTZit1awKiko/LjefkwQEdGomdooHXRFp1Tq k6ffe20MmsDXRCAGwKnB/9EGErhuNv+9mBhiF2v0c8dmkyUl6E8HAKvHAC/lRlk3gLUN GFbPiTsf8qYlyeyFRUpKQl+oJW/RSYHx3N2iQs1eEjYUYbHwez5KR6qQ8hHLp+I6DJtU AR8mVDHCNaq+ff3k8lKgOoCB6ZJwia/aNBfkUM7kPcl6P0g3cuRJigWW8zxQYjaMnnbt X1Lw== X-Forwarded-Encrypted: i=1; AJvYcCUxJX24w8eG4HvjcTS3FCYEi09YxSGDS0NhUVVxuEYTbtyvNmDmgDc+M8Qlf9giuBM1Uw1ky+Yu3UfL14A=@vger.kernel.org X-Gm-Message-State: AOJu0YyAoHUcykcQFMtd//vmPME11Db0STNVOWDyyb4MrgweveTH8V0R GKJvlr9DtC+P1/CDi4CkaESlAwcnOCRZqKhqKzlrl0P/4diW2aDfgNZUofGD8Kg= X-Google-Smtp-Source: AGHT+IGnpJbRkaeEp++fKU34EvopNpr/tyBn+AeOlnfao3/er+hs2WZEx+AXO2rdZ+yVQjSYpLNcaA== X-Received: by 2002:a17:907:36c4:b0:a8d:1303:2283 with SMTP id a640c23a62f3a-a991bd7a123mr567894066b.30.1728124273102; Sat, 05 Oct 2024 03:31:13 -0700 (PDT) Received: from [127.0.0.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a992e7856bfsm116315566b.138.2024.10.05.03.31.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 03:31:12 -0700 (PDT) From: Bryan O'Donoghue Date: Sat, 05 Oct 2024 11:31:06 +0100 Subject: [PATCH v5 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: <20241005-b4-master-24-11-25-ov08x40-v5-4-5f1eb2e11036@linaro.org> References: <20241005-b4-master-24-11-25-ov08x40-v5-0-5f1eb2e11036@linaro.org> In-Reply-To: <20241005-b4-master-24-11-25-ov08x40-v5-0-5f1eb2e11036@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 X-Developer-Signature: v=1; a=openpgp-sha256; l=7427; i=bryan.odonoghue@linaro.org; h=from:subject:message-id; bh=MZdA/sRLAsmvUPZP3TphhP3dJzkLom00eAxDcabblxk=; b=owEBbQKS/ZANAwAIASJxO7Ohjcg6AcsmYgBnARVqi35DN6gUi+5keNREXE36RVNzvmSK5VLjs 2TziUE2nCOJAjMEAAEIAB0WIQTmk/sqq6Nt4Rerb7QicTuzoY3IOgUCZwEVagAKCRAicTuzoY3I OkdrD/4jdS4d6RhXojZ416uinCFqyvFUj5cpzuo4DlDXoY/1Nz6azwXPh95o1T1PkVuFGgoSCOs YSQWGGnw9G9o48NdyDr/xzI0h1d4EoSL6LjhxMGtlF6IJv/rabmp/F1xNR3yK1grurvlwLQbmtK /jwkYznAN2F7XDmvcPbnsPXxojP5loPJI/mNl9tpJujm+OEimW15qfikNXZD/9JFBJPNBEaHbTG goBm7fgleoveZZjkV1Y/3csyg6+rergqZ3Vm96mxnaXMR/Eo/qtalOOm/L/WGtjXqyZNW+FL2q8 akyJqfada7b0VrAuZjhjVzUQg+4+ENcoLdinozxfTdU1J7CPTPYCaWbRDVNE3Qby/fbD7kYM/j1 kfDNAS4fRG9WiV/bNFR+y341m2i/pO3M6Dfq1aUo1yYdAdhLESTrERrTQhI4IDa6Usxk5qEvnD/ eHrDxJHlFeTaNi8sjyDJb3moKNZPMM8P1X/vEUMEYv18q2Rp8L3UnH6MWpQnJHsl+YO/NP7KDta phphJ2FP5Hg2xSe0R+hqUhdq2/1KjwvF4UmrflSqa4NW8Fdpodv4pm07lvnI2UkIoELDIi+h3Jk YlR+EbZEYxMRrTKqNofm600ZrpyaazuWo6wfaCcgyYxNU8IhUcM6B6LNrKdxg4bypOAHIQAM6oh N2899CZzi1+AL/w== X-Developer-Key: i=bryan.odonoghue@linaro.org; a=openpgp; fpr=E693FB2AABA36DE117AB6FB422713BB3A18DC83A 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 | 140 +++++++++++++++++++++++++++++++++++++++-= ---- 1 file changed, 125 insertions(+), 15 deletions(-) diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c index 3ab8b51df157af78fcccc1aaef73aedb2ae759c9..ff17e09a1f96175d598c395bcae= 0cdf01d68a79f 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 @@ -2177,7 +2275,7 @@ static int ov08x40_probe(struct i2c_client *client) =20 ret =3D ov08x40_init_controls(ov08x); if (ret) - return ret; + goto probe_power_off; =20 /* Initialize subdev */ ov08x->sd.internal_ops =3D &ov08x40_internal_ops; @@ -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