From nobody Thu Nov 28 11:42:41 2024 Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (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 E8D1D19DF53 for ; Tue, 1 Oct 2024 13:15:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727788559; cv=none; b=hbbK+HpMLOZzPK8aXBJJyFJzjQWUlwNedxD70/8q9YwH3ZskqAI9VawBJcaq90R/dxBuO0Klx50mwDcjQKWDXV7Fy0IFP7s0JLdXlGwYCw9esmNB0DmxTYZH4SHIIgG8xSVu7KAywlVLPT5OaGXyINSTNU3XSeXXOlnDW+Eer/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727788559; c=relaxed/simple; bh=vTwVvG8iZlHzHza+YS67mEwp2zyunt+kNzBDYWtFYWc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iNPkna+AgBmVR8WLtV1A81OGIXXaMBjLY/9TzmnpmPK+rNQJ6wfl+E5uSwt11XXqViHlCzEzgl0CkgBIXQLMkCG7VhJWmVD1JyXlTKY4HRHpSqk+orn2qWQgUDOP/AZZxd1wdghSecN4kEcqLa8e3Hod2yaAwY2/Pt/9OLGBO1A= 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=EzZJuVWq; arc=none smtp.client-ip=209.85.208.170 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="EzZJuVWq" Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2fad100dd9fso27887771fa.3 for ; Tue, 01 Oct 2024 06:15:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727788555; x=1728393355; 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=EzZJuVWqe4dq4DSLEYafF1RDbQ37B8sYfE6VIFtY0ohWA2rjHysQraV9dT6lhN8s2n /VnDr/bpZ1KrsfO3+zNTQ3c25wGgnoCLlOgMlzPEcIzz8SYZ16b9OPl8HZKghlq50opV rUezgJdvDF7rAlC1+qY4sIh9EuC7BW/OgM/jCasHcSbjQCvaD9OyOkZWPyoP9fIfIqxI y+s3pBOryA9Hqunvh5wt+8VuNVtPix+A5CMWCMSQrnuvKd8docvJIdJBR7x2SXH+FHWY PXruVoTERxOIINowsrmctxlMbHnxA3+nh/wCEdqyvdXu9sxgh2Biop1AnGJk4oi2+CAd k1eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727788555; x=1728393355; 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=TL+335g7g5N/xeOCVC91N705c5boRLr+Yl508SfZKW3RAZyaEGbOzPY3wY9DYpI4lo qWBfeg08peu2//zdofDXV7oNpUCNmyI9zbk/yMxwHFfhMEjjH0tQXWYUrSzQ0TzRYyqG Kug98tFo5D8kDZOkJQ/Q8qCUYeUv7arzN2IBin6qHiOt24e0FXZjGqAuRnz9I3Kd5cME L+ctjjkJsDAwh8vagh0XfFSYl/7JxLVkda4n8CuJqZhIYPXHyZwLCcT5/o5lUX2tHunp LjyruBYz23zo/2KFL7m02272NnU5NYOuweu/iGaQ1zxwXEFNQacJuFtaW+rgysgnhDhJ 5OUw== X-Forwarded-Encrypted: i=1; AJvYcCVljJFWIdNZymfOAK14PJEaU6g7W+MgcFiWs/NfNfEu7W26DGpsFF0NHq6N+IlQgyEfEb0pgs9VHy2CnLM=@vger.kernel.org X-Gm-Message-State: AOJu0Yx4eUzYAxj7ebio3qn+9TqDrMWch4ie8xeOY2AwgfYpNPoNfYut /yw6oCxRx1gorIvmJjE6opLX0AeWjxvww+vCEbVVTmgWlihp/AHhGmJMmk8Odqg= X-Google-Smtp-Source: AGHT+IGnYlidwKx74FpXp9lnAfLCOvamYKKTjUzv/lAopPuJt0yTpxQDXRhkk1HEkGvbsHnREX5bKg== X-Received: by 2002:a05:651c:54d:b0:2ef:2905:f36d with SMTP id 38308e7fff4ca-2f9d3e4966dmr118969421fa.16.1727788554878; Tue, 01 Oct 2024 06:15:54 -0700 (PDT) Received: from [127.0.0.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c88248abf5sm6170875a12.77.2024.10.01.06.15.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 06:15:54 -0700 (PDT) From: Bryan O'Donoghue Date: Tue, 01 Oct 2024 14:15:49 +0100 Subject: [PATCH v2 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: <20241001-b4-master-24-11-25-ov08x40-v2-1-e478976b20c1@linaro.org> References: <20241001-b4-master-24-11-25-ov08x40-v2-0-e478976b20c1@linaro.org> In-Reply-To: <20241001-b4-master-24-11-25-ov08x40-v2-0-e478976b20c1@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/ZANAwAIASJxO7Ohjcg6AcsmYgBm+/YH9ifjoLl/q8cwHxx2jKcu3VxWfPPCtvJZo /m1Al51PXiJAjMEAAEIAB0WIQTmk/sqq6Nt4Rerb7QicTuzoY3IOgUCZvv2BwAKCRAicTuzoY3I OgtSD/9f5tponllpWndL3ew/MCurWWz4cP041CVQGSjiHOQLs4LBamTk9/p9sKU4bS/o4gjHUHg agBB5f9rog4wQrb6BFR167obvnUf4XWKFTuRBVxpvi+oIBqDITmlhL0BciQPDFGH5Gy/o93WiWO hV4kdU7APdnnB1xyYwPgZWdMfUOHBcw3P3MzGzpfyck6qn0cMg8GTDTbCfBot5vuQVW80vBgtU4 FUWE5Y48bxjGayg9r8UDprRN3byOoZfT3JfCfXcv7ONWqwxJfh7dlXS9OQ2/lRBPMulFifZAU+t lzU1pBGeGFTfh6G4oN9LkI95RyvIv5Yq+uIYwKR6IzIoYJsmU0S1kDUQxf5hm4k1Tk91P4Us4f2 SbO43XBmBJm1Jq7PySQES2XrXUaokra+Y7z5X1NAzhdqpzDOCm49V8blv1s85WoOc4moMuvFJ8c x+m3JlIPyByA1RXvVKwETAlyZxqrD1Ive4nbO9EJytCFY1Onq1bfOxFcO+rLZwADw3en4SHphAO f0a5rQVhjPAN4/0Bj4cR8g+qthITvOQSmL/eySByJfbUapjMNv16pylo44ttjKndKV3Q6+7m02z 5B/cc+hfV/0kJglbUK55B5fy4e/biOlSWjfPlbHG4uyL4LtvX+FRZCIF0gnd0V5qadSIje0YsJX v8tM3xQHeUNLcXg== 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 11:42:41 2024 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (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 5211B1C331A for ; Tue, 1 Oct 2024 13:15:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727788560; cv=none; b=ssrLiBQrFdWUJ69Bf70VBDLy1F6Br7a3K8KD/4lPaX7Z7jdZlnAB8qbO553/T6gZPBwa/nqDOxijjNc7UeA6m1TSn6/qACLxbPaxtwODvejZWuQ0U4o0A7lL2bZRU2ICKxFygvrzf+lyeuoIokQF9KX8+nPy782z27412oizj9w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727788560; c=relaxed/simple; bh=Lqdd3Iex9Ieycc9m4bbhq0l+g+TliLP6Lt7etgxesno=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MJGBAxuwk1T19k/n6GnqO96zxieHCedf++9sIRwcF7g/Jxh22zQSb/PX2d1NFqey6Ka3CRHreBXCjl1GCE8vRMfEZY4N8CXTYdaPS2ZWaOBR71K5NemeQbfwAlDC+d79H5uuLuojylHMZjCBMUdkRuQxbYu3qpUWvSpU8V8YA/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=rRyYp68M; arc=none smtp.client-ip=209.85.167.45 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="rRyYp68M" Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-5399675e14cso2549116e87.3 for ; Tue, 01 Oct 2024 06:15:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727788556; x=1728393356; 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=OlXAikEDwAtjOIbwMBno+zyl47bykwn2jCgyJZs+uR8=; b=rRyYp68M75u/4bHH8YZdY61UMh8BI9UJiMC7ws8CpspEQj10MvGI65bwxEYhYllhvA KgN0VRa7eTK5OuYEqMQXrhjME6PKVQdMbd3qwnp2CQ9oGGLzlWTvPMiVWbyD26sWYuiy NSwf0OW0nrVgrpvpoPpBqqzYuzdLMKKE06AiTP0Ieu+61mePbQ0+DbGRjEkHBIRiAhJn ruCiXxtVL3SkRlaChcn4bq1fvuek67PqR+txaSVY8USnQE/ktfrZDASr0bXEZZtJrYqE GOrQcmEm5cleDVonQqnu9AAxD4Tutyo3N3g7bERbTfol6UjuHk3oByATseCV9jybfhjQ 8Imw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727788556; x=1728393356; 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=OlXAikEDwAtjOIbwMBno+zyl47bykwn2jCgyJZs+uR8=; b=vlJG51Q37ipR7OKw3JAOvx9Sr+XjHFJn7Dmnvx+qPkk1dwI2h0nbOGi81cO6V6YRoi ceXp82UqKQ9sncD4Isrp+vC4Vu/HNlJgLSvPZhl6boSu3Iqow8iIRdGJAAQZ1pDBbzfL xDTmqxgo/R+/tmgRwwwb10Mut6NzZUCQFYq21mwPvrTAmmT/M9Oy3dxWPHHUfoVaFGLF Uz33JFpt3kLuqG47oApcuXW13po7Jro0YN3wv8iOgzm8oaKh+a4QfUIG+2Bx+mb/CDFg ICuFm03QzvtxQa+9STy2TjoIGcKkIH/CQfAmyBACu0QsWPcxTKey+10Z7fpR9F4Blz5N uEuA== X-Forwarded-Encrypted: i=1; AJvYcCUr0TNF11irhBs0RObT0Jdi3THbzb8vX5wBELxU2pOTV64tCT1f7QV+YnHJgA2L3eQ/3phRpHmu8IDRe0s=@vger.kernel.org X-Gm-Message-State: AOJu0YyQ/FeWeu+IFAFq9tO7vQNMK5N9Y6JMSEAn5w7mxRlHp8pDOKj6 dZp0bvoojqrkC1TABQgeNBD3wBip/LXcbTh6L4L4XDjVPQdv0TgPXfQoKhFpijE= X-Google-Smtp-Source: AGHT+IHNo9CACCWv9p7CK3KBj/Iiahgfbdnox0jvdyvCrXh8Zhk6yeMmUeyRPHsmRWzsVYK0FMwxHA== X-Received: by 2002:a05:6512:b21:b0:536:54df:bff2 with SMTP id 2adb3069b0e04-5389fc6ce3fmr8500110e87.54.1727788556018; Tue, 01 Oct 2024 06:15:56 -0700 (PDT) Received: from [127.0.0.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c88248abf5sm6170875a12.77.2024.10.01.06.15.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 06:15:55 -0700 (PDT) From: Bryan O'Donoghue Date: Tue, 01 Oct 2024 14:15:50 +0100 Subject: [PATCH v2 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: <20241001-b4-master-24-11-25-ov08x40-v2-2-e478976b20c1@linaro.org> References: <20241001-b4-master-24-11-25-ov08x40-v2-0-e478976b20c1@linaro.org> In-Reply-To: <20241001-b4-master-24-11-25-ov08x40-v2-0-e478976b20c1@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=3777; i=bryan.odonoghue@linaro.org; h=from:subject:message-id; bh=Lqdd3Iex9Ieycc9m4bbhq0l+g+TliLP6Lt7etgxesno=; b=owEBbQKS/ZANAwAIASJxO7Ohjcg6AcsmYgBm+/YH6qhGt1OnCw8VR4lfYovDxEKyANfFBA6g+ dywFMkGSTyJAjMEAAEIAB0WIQTmk/sqq6Nt4Rerb7QicTuzoY3IOgUCZvv2BwAKCRAicTuzoY3I OrukEACIOwTCc0LpzFRqm+9/Zk+l2pvjzV+EOLMeex4UhL5hZMH+E0CFUHmZRKVO+5fc2mnqOvX Mu7FabWbBFD/UM2EKBKFOOl6NGSNqmbityXYBuvsmRhEWdjLHLcT3kwA29sanK8ICEOfH53IfV6 Yc1FO2B2U+27/CnWU7a4rU4eTe1GVq6oAUGBgRav8qw0eruL8XrCWJn7pkF9Zt0hUW6Yc5TFHlx YFVHI65QRM5LTPH2dIbCua02n6xrK7D5SefwPjZF0RrSrkhE7cGTiXR+ISk4GOYZZaWKoErIzd4 JIETyDgar7v1DwF8UFshz9z62L1zQxyavdMpuGQLa9a2kKCmxTwepwW2meSQuWxX/c/GiK92CWC Cos6ud5SRL3XCNPdfD21MiU5zgT8Q8bX9x/Uh/NQqcTNoNPufcEUPcRRETekDMk1JF2zNVtGVLO 5H0KT4ywTnFgSYdSRx9YShIggwSRMuRxOFkdFMf3XVJPfyHQtzjxSDLugjWiS3Pu1yWV/RmKATS EdyLo/wislwX7T84N2ffLa+4p077Jq1iPkcNxN/RFL6sZI+LN5FRCDQXu0zgCD0OYnYEc1Ja3QV hMczJBD+l9RdlqljumAkxGO95N7ygsALcaI9rYhJAPSQPFU00mpy/DDyLkX5Aujuw84TYeeDE1T FvyZmVmTKHoqdBQ== 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 DT based systems. Signed-off-by: Bryan O'Donoghue --- .../bindings/media/i2c/ovti,ov08x40.yaml | 120 +++++++++++++++++= ++++ 1 file changed, 120 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..bc499e4b5d48ed57250dec33a91= c92552f137cf9 --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/ovti,ov08x40.yaml @@ -0,0 +1,120 @@ +# 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 + + assigned-clocks: true + assigned-clock-parents: true + assigned-clock-rates: true + + 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 <&ov9282_clk>; + assigned-clock-parents =3D <&ov9282_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 11:42:41 2024 Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 DDCDA1C5795 for ; Tue, 1 Oct 2024 13:16:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727788564; cv=none; b=WWzd2S3FJKmyxKdn7QB4SUyKQHq24yrfb3lPl4eg+LsgBKOz+8+4v7fZKebxafoyGRl7syq6zEG5ABRByabYya4VS/U+rRZack+Dh7IF7haOWwGwpa3KShOMQ1L6vDDBRLo3P/CqDr8h9gQOoiEBwvTMkVGqTy0P0GM9kivUkd4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727788564; c=relaxed/simple; bh=KuJYhS6BLwFHq2M3BsUApExs70W98G5/TG0tISRMP7Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Y8M8OmMyd5leHR/dNoOwLIdRnrFelHuAG+39AZgGWsNs55fNobMyQOgbQILqxfbodoMUEgUU4Gb/UyhcmaHiCXyjDuyqWHgz+v5am7dL3+94vB1m+pb4GRCRh1DSYHUFfHNsywLJwYLY0XEedBdar+nV1GXJW4eKct8VbcIPpXI= 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=FEr/GEjE; arc=none smtp.client-ip=209.85.208.182 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="FEr/GEjE" Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2fad784e304so13705481fa.2 for ; Tue, 01 Oct 2024 06:16:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727788561; x=1728393361; 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=FEr/GEjEdMWP65mZYx+q4PRPbWv5eAueMd679Z3kBe4KS1MW5aPE4yOA0liMEjU3Iv /sWy5JFgXPST44bwG5hCSLq7kfdYwzeE/5hEL38l94Mx8tRMkBn3Oe5oEtfPLis8UeCh A34wf5u7IuKTMhG8KST9smHhe6A7F7WdZztENbpZjLD9Eamr7atRasIk1OZYF2hI6WCH bpyLgMo4CYU36VUWm1I+reXrJProONX17AfKPLxm0rmUcgCCptLe40CBbjV1OfWk8wZV GXuWR35pJfKGYlASAHKEJsQ9nOItLsehgld5gpiS0CoykjceGd0/eVxFJHWQ4iNXyabb lSXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727788561; x=1728393361; 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=m+sYQ+IvxgPbf21AypIi3y7tn573q23UEm7R7enreth7gO88wUWzWXFI1IrNmDXDSH nHXUNUjyOsCO4xqnxrw32fM0AOkpc+zSrpc65l4ckbtXCGgJwZq/V0itxz60WOO0Fde3 SNcbhgST9WsEpUoaCSUpykApFsyQosScMJfAZUTTw7cFRnRLXkYyvowwN38d7XonFOnM h9ahj5X51BEekc1KcvE75Lth8XcwSVYOwCiYVXJ8EaaogPMJbR7Lr4U4gZDFEtwJEijo +Y8hkwPtJt7FjdW9Xv9waUcNl5E08khvL36ftcccr4TjL7ddbe89ApJEqWZ8lDJHD6q/ apyA== X-Forwarded-Encrypted: i=1; AJvYcCW8XHXepeS0zD9E6aNtkAc1eulAAPdkLVrUweFdmvJChZrOeoickn6mIWK4dXMHMiywHSbdvDE2xfDBZlM=@vger.kernel.org X-Gm-Message-State: AOJu0Yy/8CVbOf85CNDRsuqPNgn5Pmg7FgNitf4G1SQKHRxsMWqCdLJp XUyXBxud8MwpakGUB0ccNsuUCXUN4Y41cSwnmg2JztQB+Sp5162Cf0ADeZKvo/Q= X-Google-Smtp-Source: AGHT+IG/fw6UTWNuX/m2S/JOjvVxWHJbYxhho/MAY4qRlXDPE1784ETsLkH4i6A5S/ZYtCGWLlilpQ== X-Received: by 2002:a05:6512:684:b0:539:986e:cd68 with SMTP id 2adb3069b0e04-539986ecf7amr2697367e87.60.1727788560923; Tue, 01 Oct 2024 06:16:00 -0700 (PDT) Received: from [127.0.0.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c88248abf5sm6170875a12.77.2024.10.01.06.15.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 06:16:00 -0700 (PDT) From: Bryan O'Donoghue Date: Tue, 01 Oct 2024 14:15:51 +0100 Subject: [PATCH v2 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: <20241001-b4-master-24-11-25-ov08x40-v2-3-e478976b20c1@linaro.org> References: <20241001-b4-master-24-11-25-ov08x40-v2-0-e478976b20c1@linaro.org> In-Reply-To: <20241001-b4-master-24-11-25-ov08x40-v2-0-e478976b20c1@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/ZANAwAIASJxO7Ohjcg6AcsmYgBm+/YHmai8wAoApJZH2dpa4ZHi0kOROlr8nU3Oi /MdUv5CmV+JAjMEAAEIAB0WIQTmk/sqq6Nt4Rerb7QicTuzoY3IOgUCZvv2BwAKCRAicTuzoY3I OvjeD/9iyuEkpcja5ZKuhS1H0/8uvYdamUVhZAhK6XO9vrMG7B+G2bwVNB/keDeUGbLmimmvkso 1+rLtcLjherL0DBIlskWFIEs/kqZQ6lsUr2xbUyBhxqkqNWqIK2GMbcnarrOUoRXvA4KYlHDxJf HIrRoyfVPqKEi8Rcl4CnqBuwdqS8c8HdPBgidfDeM+QrNkpjrIgorQGYBESqW1PVeJeKox567dy xRo3zfT69SgeCkF3aSiyvnVuP2oQwEOBIvSgoYo+uJB6kWUA6VuJbOdiLwIlx1d1xOd5Aw4/TA1 /HXybETQ5lTzZRJI5TIl1o10or1BNC0+GnXPcKNoAulabegS01NqFAmELszNDJsvP/ALmswwnGf Z6rTmAtDqf+iaI0VAH/aZaC3EIBx95Vl1OyBG8kN6UGJ1tWI3rcIMczULQGj3MT2sp24+g7K1tf ep7Y3ASveW9+ooNwf5byqy6pDjtvMsfVzE4sFgIjmOm+94sN3w1H8k7UvCKiCGgSI/qfIGgMXAG dUUFWnM38lycNwDCHpKQ0S88xzwVT0GCQTilvxT1C0Ypqv+s9BKyCVzR8Q/am8ipiIkF/DmqNLw i1kSGlbawRqYqjtR6p99MIIuZiUr7oAVUGYnv0no9ZDB75LCUaabITz+im6luWJMpIpnRcOatde 6T3RGL8FxIpLd+g== 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 11:42:41 2024 Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (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 2AE0D1C57A7 for ; Tue, 1 Oct 2024 13:16:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727788566; cv=none; b=r1DtagKFkpFoqor5zk4Vog1gqqLGM/R7kd+czkQpFXv3gVE5ETDY+qyFJZoO+LQRuJo3amOqndZA7S+MC4qpzpOrUDKaqWmQNSRAaz9tm7SMKrWL7nqzpkipjOhYhmoF+sx22YT6a4ojg5xqB0HEBpGh+sCtfrfLCHX5iF0Hyz8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727788566; c=relaxed/simple; bh=LL6t0/fJmZI9eHhzlG/ZhWayuHRs6YWaQKrP0a5lAkU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KCBnGV9fDT0fOntHAXETmbpt+GURfwk4Fp13cyGO9j2YCHHpA4E5+QE6cN0pQZfYWpO1yyZoQiAqS7ihk5O/SGx162EBTm2hC5bXEq3e5pudOMoagVD5CxziZDWBqIXAypdASjpTYOrxWUca3gr0aTXicolAv/QWpTTHTqoZIak= 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=t92aafPO; arc=none smtp.client-ip=209.85.208.171 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="t92aafPO" Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2fac6b3c220so29262001fa.2 for ; Tue, 01 Oct 2024 06:16:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727788562; x=1728393362; 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=t92aafPO8lXXO4JTCAZCb9BAj6ZGgVJ4kLfUv1URtW/vkvycDnzF99VJ6JXvTDXuS+ uOmR6Fe8d2VtcU4W3FdCzHrYghuaDKr8j417yS/nd3Z7f+pHGARKTHYN0xokbAJgQy3h 5MVojq40UDG3Lyjl+8Wv3zffa544sJ0mJ+uYul0aO4STuWY7wM9+WEm+TplVTIo/7+k/ NkdWzBdvbU1W3lcVcnXduPbx09gPxH8KZPjTlilFztAU+9ZkMw7jfQAp7v9ivCnuYCIk MHxKIaxYO8uLya9OPbpk/lOOa3Z0mcTseQwdNFKB8f72Q/a6a7fPlODZX9kwQuP+TeE4 0sdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727788562; x=1728393362; 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=pTda0UjCL531uZai/BUsmUtjp+ygAlBWWAvRyZeWi56B6upJKKg/zKVJ9IFZy1Y185 IN6NPOKZGH3p7Ww3sxCQ7rF91opoFo9tfOYpFTNZDJmjI/GnOXT0gKP/qyDAi3JsIS3y /1NwAd6oMpNHadAOyZpQD5YSo/VIaK0dgKqLTEdhKdOAn4nQTA3vPcwtF9HJPSCqWgLP S/clDQekou4yw4Jjj9b22PNMVp6lT4gpT99+/fpQZdC0dPaA3D2tqS44dvzfaG0n4PUS 0eicmnhGymYk2gm1M3YvSNJDebdKMZJk1pa6ndTMK4ReHhSndFjxKnAyONpM3oLq7ypQ kifg== X-Forwarded-Encrypted: i=1; AJvYcCUhXichUa+nDFRKbtHseIHBC0qEdrvg35TrVjgpnkJeQAfrRKeVVIVK2RL9/uJnU8yar0yNx0BbVzVids0=@vger.kernel.org X-Gm-Message-State: AOJu0YxgA+4LDen3N+vCnel+N4k15vbp25m/5tCddFObwOHkgcsdlAlr tMjZU835UlysQ12LmrMQZ3ndt5DElQzKydjTWrBNvVzANi5TcdWOEtXt+LAmElk= X-Google-Smtp-Source: AGHT+IFSxbUgwp5T17L4lfEcoZQa3j03UrqKT6wM0D3H8uIMQWJVbmmi8XefknZ5MF5QWzyA0y4HnA== X-Received: by 2002:a2e:be24:0:b0:2fa:d4ef:f234 with SMTP id 38308e7fff4ca-2fad4eff502mr40485041fa.1.1727788562110; Tue, 01 Oct 2024 06:16:02 -0700 (PDT) Received: from [127.0.0.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c88248abf5sm6170875a12.77.2024.10.01.06.16.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 06:16:01 -0700 (PDT) From: Bryan O'Donoghue Date: Tue, 01 Oct 2024 14:15:52 +0100 Subject: [PATCH v2 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: <20241001-b4-master-24-11-25-ov08x40-v2-4-e478976b20c1@linaro.org> References: <20241001-b4-master-24-11-25-ov08x40-v2-0-e478976b20c1@linaro.org> In-Reply-To: <20241001-b4-master-24-11-25-ov08x40-v2-0-e478976b20c1@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=7175; i=bryan.odonoghue@linaro.org; h=from:subject:message-id; bh=LL6t0/fJmZI9eHhzlG/ZhWayuHRs6YWaQKrP0a5lAkU=; b=owEBbQKS/ZANAwAIASJxO7Ohjcg6AcsmYgBm+/YIZ0w1u6sevaDtTjqQmx7Q16jGK5DFZBZuS yCUJLddqVWJAjMEAAEIAB0WIQTmk/sqq6Nt4Rerb7QicTuzoY3IOgUCZvv2CAAKCRAicTuzoY3I Ouj5EACf19CU1PV2xw0MW/aNL/RLtrzd0vVfTlp8YuyWIQis4lTrI0+uNccandpCK2TWv+12VwN B2F9ZLcwr4JptwMuz6494Jx/bRic7pHBA2FOEXJN1k9NDomcKmhWw80z2YuEbH6eNSq0ldGRL7l 7lhf/qjwUlKlsgJ7Mq0yYBUAnEOxQzZxQ53a1NnqigU0917Od+Y2H3qbDaYzPx/z6mNyy8/jSed pi3TdY69Uw8dPQLokOggPZP6HrZ8FiJTQ2NV+dhXb6Bys8XzWR0cJVwpivNqoeCrdiuxbhkVef8 /RR7MveRh0REEaP1uh/ZyAuV7T6chHTAIlfjjKbhNUbYuorQEtQoZhgO71AjZ5AR2SKqFD3wSzL JTZFc4rCDz8GLSmn0qQr02NkD5ePne/B8RqXB9+KfOK4xwDL09SLDVpRX4vTokOPNeT/OUNId87 sOmoOjKDshRfNdivDdCC0FkQdy+uhwLOnUzpvfaTWZQ27v1ijjBgIvFhrSa2kN7Fw/yf+M2Yt6A 84qmoiwg179ykuZHA8EL0gEDTrWamwcfxn0lYi2u4aBMiPTmWo5Vvn4o2f2MLCUqywYZFX6YQIp ScsvTLUK7qXLT/3Rp6BE6/+Ij9qw+J8GcX+SZHWUHBYpeRpCcmj++u0/xv34fuo3CHjoC0COVoK 9zKGTFX0jdTHszQ== 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 | 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