From nobody Thu Nov 28 21:43:49 2024 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (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 037DE13B5B3 for ; Thu, 26 Sep 2024 15:46:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727365607; cv=none; b=bgjGbTHmOTxgfLqXd0Iu9xtsBfPn9T+L00IjQbofhg4wwMmExKjdkdxgYQMjEHDd1wM943R0lQaCsKpl9FXj804CBdPiQD4EuyVAgfZXfzqCjUQ4qiLMGKkvJPzeOX6JIc00P35IeG3BXuKfSOKJGoEcV/XCsdibvsqFBc4C5UA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727365607; c=relaxed/simple; bh=vTwVvG8iZlHzHza+YS67mEwp2zyunt+kNzBDYWtFYWc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nx8pqDrTO/7WWOzXJoUpzJr9deyrAI10IzAnQcwAghXE0RPj/5KKcMljEBD8MAruASaX4aH14ERwUsoPMvo0qW1XzCZFT1fzEhT2nh/y9+kJpEKIJP+AedLQ+AhhSyAOIDQWvtjl1DJh3wlUfw6QHY1bWDy23J59fm4A9Y1pylA= 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=Tr62/Wsx; arc=none smtp.client-ip=209.85.167.48 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="Tr62/Wsx" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-5389917ef34so1252022e87.2 for ; Thu, 26 Sep 2024 08:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727365604; x=1727970404; 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=Tr62/WsxrIbtWYD/PpbNOfunNtorLYB6HgXtx2kPaQxdlYMzuxlJmBP3XcvDaC1CIM /OWmD0XeYGUp6L8PmaFwoxHQFEM/h49p85/eD1vTkksURqcBs4HZetRz4RltopSKKGJD N4N6tL2DB8NEK7884Qw2dQleH8eRaFepbcjbxgXtbhgimSBJE5/RDGhM1N72xpkJrPHT 4rscA1UetElZ3RzCSt2lWGA4Tbze9gXOEtQ4SGOYj0O4u/nycIW+3RokiniMa9+5vm8M K1yD/PXBzCmbSjXbwRWV2tDNG0E1zNNu3n1zBVX/ZHBb7yDLe0pWsz1mBB6fxncgXDr6 sMuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727365604; x=1727970404; 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=JAiAOXwX75mHEtbHCdCScqZ/Jzn0EofRDEnNgcebytQ+B+OsTs9ZXAarrZBeTp/vLy RQisJYS6TBcLcGlv+PxmisWBYcfTRWK9rgTXLj3ABtXLqRiVZXxrLWsqSCk8tJIt5M+M yGUmw0E35Ci0ArWSV9ACIWvLU4hgAgJIwZMPYLW7XXx/1c2TAXTIAuBsjH14LLFjHDwB XfT3/iF4RTnGSO0YpTdjWc1/GlqE9uWdCKz10p4C278ICNDUXPxI5doVd2Tne7MO5FYL TihZ6LQggpOb/8I+/qGMJTZwjM47XYVHhEmG1HYVpV5LWEENhBHDEn1WLMgi0mCbvBYW BiNQ== X-Forwarded-Encrypted: i=1; AJvYcCVcDT/bo6dI3hM+IQsQV/nSIiv9op5ICS3vCG0OlrZaDdK3VWzcJ8aiMeiUJZueiVrmouAS16iqMDOlRiY=@vger.kernel.org X-Gm-Message-State: AOJu0Yz37aHpJ5hwaX7V9mki+C63i/hHzo0+M3A4hy6s8XnwpLHavfWQ uKTHXMyyTvtlq8dHkg+4MJBnMoAtqR6yNR4Zi11+oo+ergnE87l7HBTtGz0aSgU= X-Google-Smtp-Source: AGHT+IHC0UquaOxuhN7DmBE/LSdM/gTJCcl8evA7sxTCF52bwGR80T7zNwFTy8yz3npSXKHM2xzLNQ== X-Received: by 2002:a05:6512:b21:b0:536:54df:bff2 with SMTP id 2adb3069b0e04-5389fc6ce3fmr15586e87.54.1727365603983; Thu, 26 Sep 2024 08:46:43 -0700 (PDT) Received: from [127.0.0.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c882405166sm75744a12.9.2024.09.26.08.46.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 08:46:43 -0700 (PDT) From: Bryan O'Donoghue Date: Thu, 26 Sep 2024 16:46:37 +0100 Subject: [PATCH 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: <20240926-b4-master-24-11-25-ov08x40-v1-1-e4d5fbd3b58a@linaro.org> References: <20240926-b4-master-24-11-25-ov08x40-v1-0-e4d5fbd3b58a@linaro.org> In-Reply-To: <20240926-b4-master-24-11-25-ov08x40-v1-0-e4d5fbd3b58a@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/ZANAwAIASJxO7Ohjcg6AcsmYgBm9YHg4K/kfdpbJQr+sw9ORWikEEUVqPmwUlJR2 bTlEW+ogzKJAjMEAAEIAB0WIQTmk/sqq6Nt4Rerb7QicTuzoY3IOgUCZvWB4AAKCRAicTuzoY3I Ohl/D/0Qb6kIU3vP5HUUG7aJUfyxpNFzA1wXaBuDcXnB/unRTeG6IpZ3IWeEFNgO/tti+ReF2Nm crX5bRwXLxSEJ6DO5eKhUL/PbDyq80O0q4LXjfzTbgOb/56biZxFvo73Kp9gcfm8fT1S6SC25pS CZ6fLP82MCppTds4iRoAuif/8zfvqRVjEMEoxYz/gwlPFN42n2PDUx74eLJMrV22sP6JkEVYlfD qdlbPMU1ziiDTFehsG7vCXXC9Z5TWGSO/U/cBbK6eZSRcD8bUfBLy27NhbmZgHIR/L/IyKBWoP9 vB0KaQmcJGEWXTNfrMdz0yeL/h5Wtup/MzJYFIKwWmpvWsRAywElmabLlCXwjohKfvNlp6KqceX H8LREqgmliNbLF1EoggBJgzDCs2SM/G7zEqoCkQI8s87xeizWkPkqUlyMPmkBdXXcHGQdNP45Y8 GUc2F4jUSTvdahmtXUzaiozGGGHCKQ7YgkNsk9YnJpoZckdo0F7Ta0oak3ETxMTOaWQZ1QshOYT g+9oXzKhpS/0o2m5BwJBfE/EmwBzSR8BuSacZxH80brKjK7iozHMcssJj3AUKUELU9vfirLteoY wV4cfEHsygpEby6S0aUn1DVBnyosYcZJoWIas6gtdnFdQp1aaN3Ut3HkxQAACOhG6Yqx44uV+0u ObvNwXiyV425BvA== 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 21:43:49 2024 Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (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 1BBAD156864 for ; Thu, 26 Sep 2024 15:46:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727365608; cv=none; b=fqRmhB1jhS57jXI+QL/wwYElDuI3H5IQv4ks5cZ04qFs+8Uh12PEkASpax2bPYDixrdidMubdnANdbVetaTuqJCFVMqu+lPiyRLCjjfRr1ZQ8I1rCQaXvTTwH+q7M8078Ymbr4I1x0YcVsAYEozNZ7xAIFVNuNQiDwJaRJp0arw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727365608; c=relaxed/simple; bh=4FVzIy8QpHWKlC0SqUgcgLp+icF+nOSWpVflVXxObqE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Z70LONJutoEJOu7JTV6gHMk3scmOBWnOdnrl24ati79npdo7ImakE0TOc1+Az2md0bE/CblRrn2t1RBKwIDbmcdmzTwM7Gh+1BC6Py8eLIwYlRRRcxgMcSNJ+W9PuOFXQvZfDnb/U8d9tfBr0fU/iyXpU7vsu1uq+KeKDNKe/Ns= 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=yTYzrfYo; arc=none smtp.client-ip=209.85.208.176 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="yTYzrfYo" Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2f75aa08a96so12678721fa.1 for ; Thu, 26 Sep 2024 08:46:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727365605; x=1727970405; 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=/CRYCZo7FKJ+FINfaWBLgAHFnlJxKNwCO23rsvgAsb8=; b=yTYzrfYonnQkXsE/GJDbH6VRIiW+y5bXcJ7DLhrAeyUsaDekD0xpUcGgOjHwJBCXBw 2rJZWqbLX/9uNGPwynfjwX+HTdrt6Ui7iIfO4HPUfmKofr0Ed0JnHCE0sVB3YZmGZTY0 PA9JTWqpuEHR06uBbo3QR1EVNyHINFGhO0Ar8k1BRJ7NXBsns8FpOG818aUz0Bq8FRh1 s5xp0AwSKd7EWSevGmNsJQqtLBl3qZi7v9ixFGUW2HexELq1lwp1dWyL3oIHY/qP8Dbd N+/owlhpfSo7zq7Q1d7VFhC2ulekQVrPjWDn5uHaH8Gcuwtu6KL8q8LrOp8KhF9k3eIE etJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727365605; x=1727970405; 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=/CRYCZo7FKJ+FINfaWBLgAHFnlJxKNwCO23rsvgAsb8=; b=laFFln/xl8ALeuCSQ9IWUn451oTCPDeObMvbxxKClWVbd2xQkTCNhzF5AOblD59LDH OqMPon+xoz2tatQIpjVNEdBI28WQbGOQrj9dJ2smfKIUXcmtADoxN7IDTXXlt+/+jpt8 jcv50Ke2ynPKdv+4k70kw8g22/aFZ2KjXK159pz6EM6dQE9xJbi5sD3kCW3omJRpuvKU pEF2fXqyI2ZFEW29q+fdAkhIqwSCPfG922c6HaP0dFJ7vpuCKmc4LG6ZdxoW2buAwvsP LsTl3azb3SBKS6I5bMFlYpLX4zzGgCcpoMGpz4oHEaOjA3/dG9jXFdfm1cvCiDSzI9vq JwVw== X-Forwarded-Encrypted: i=1; AJvYcCXztycV69x751Nl4VR3i6VKM1Bma3GVYIU5Humofl+iLYlew9uOqhhWXBzLXB7VaWtOpZVDFyAkSKwoiH8=@vger.kernel.org X-Gm-Message-State: AOJu0Yxj8QuJWrfQcn+yUltpfHHYHAhx+zVTHt9bye44QZAkH6V6WDaS hkfmF3oxfHovqyeETawSAvQsxPPcGoqFL9SiQ66YGDluOEjcGNq/iVlXnCgdRu0= X-Google-Smtp-Source: AGHT+IG0+T+XsEWCeNbh8UesCqshRA43B0vDrHxEbWCEUBLE+cU7D5O3LGoP1fl3F3hZCwU/kUDNnw== X-Received: by 2002:a2e:be8e:0:b0:2f7:4fac:f69f with SMTP id 38308e7fff4ca-2f9d3e44c83mr886931fa.12.1727365604966; Thu, 26 Sep 2024 08:46:44 -0700 (PDT) Received: from [127.0.0.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c882405166sm75744a12.9.2024.09.26.08.46.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 08:46:44 -0700 (PDT) From: Bryan O'Donoghue Date: Thu, 26 Sep 2024 16:46:38 +0100 Subject: [PATCH 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: <20240926-b4-master-24-11-25-ov08x40-v1-2-e4d5fbd3b58a@linaro.org> References: <20240926-b4-master-24-11-25-ov08x40-v1-0-e4d5fbd3b58a@linaro.org> In-Reply-To: <20240926-b4-master-24-11-25-ov08x40-v1-0-e4d5fbd3b58a@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=3921; i=bryan.odonoghue@linaro.org; h=from:subject:message-id; bh=4FVzIy8QpHWKlC0SqUgcgLp+icF+nOSWpVflVXxObqE=; b=owEBbQKS/ZANAwAIASJxO7Ohjcg6AcsmYgBm9YHg0e33Npz0wAHU2EHzLqBUUh68Lfwy9S8Sb wG5ma8OUBiJAjMEAAEIAB0WIQTmk/sqq6Nt4Rerb7QicTuzoY3IOgUCZvWB4AAKCRAicTuzoY3I OkadD/4u/RdZ7/cqJNC7HnAOc861nIxfZbXUWt+EDABqjYLKi8dob46cLlxxLg6n4fJT/6miVAj onoLk6gOyd6/Aci9hwxzu8pqX2SoKrFSR3QcRc+Ebu7GkBf2SfkiA+n6mfFiakPC78P/MSCkWSg bBhrfKld98uKRlEeRiIos2yA2Xop0xcTiRt/x7rSoiksA0iA8aTXcjUivYRRUYD92w9FAG269DC frc47BL3pF0boRRtHjAJGTz7m/p7kJvWnuDPHls1uZK5AHr5b6dG+rbL5qYDEHV+dRQ0tNkWJ/f W3llpz4vkpuzUadplpjrNmY7NyK7y1B7A8WBzHcvPKzt1K6YYjwzO8ELIIge2qX5iPOcMNY1XWI p+zcTWlMmsf+ShV8nAFYQqafbQ/iYy1k7Ehz+vj+r1SzHGQs2kBdyLIYhL4dem+qWE/GUuHnN6I cGUENwCj9KWowyGY8mfaVZ1qw3lBkg0QT07+NoM3OTxPh+ptrefsmak+Ntfn7/4vSuEuvCE9IaU amlt1bU0A1b2yeU138+mVRa5Cct7sOvoCjML+znYvODPjhysATvf1b8NJPCmXgdNGPBsBm0cKLB kCzBJMyeMcsfA5jkbx82IIhxz1yURDZymDDswuwrN0Jqv91fx5X91GxlWHFmU+Ug2mh9pmbYkXW /EQmywBpVOg/sDQ== 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. Signed-off-by: Bryan O'Donoghue --- .../bindings/media/i2c/ovti,ov08x40.yaml | 130 +++++++++++++++++= ++++ 1 file changed, 130 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..250785f062d0146e8615d8f3e77= 00aebbd40b1dc --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/ovti,ov08x40.yaml @@ -0,0 +1,130 @@ +# 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 + + clock-names: + description: + Input clock for the sensor. + items: + - const: xvclk + + clock-frequency: + description: + Frequency of the xvclk clock in Hertz. + + 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 + - clock-names + - clock-frequency + - dovdd-supply + - avdd-supply + - dvdd-supply + - reset-gpios + - 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>; + clock-names =3D "xvclk"; + clock-frequency =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 21:43:49 2024 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (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 B192B157490 for ; Thu, 26 Sep 2024 15:46:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727365609; cv=none; b=eMdFx5GnDyQgo1vPr549JXrFcIA1uoNOyoC+Fmu4EyVnL3aX01YwljOrQG9i9jgbiaSWc405974MXTXvxbCS/6l4J7DvgbVQw86/zztVtT+0RGGRLFS9mVM+qoKTyB7oTPQXTYGp00ObHzg3O9BZRUeCeam1Al2SV6qSe95IlNk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727365609; c=relaxed/simple; bh=9n+eZBcj4PM7sK6+NFZGx6o8ZubV08SdnN4bV1+Fg3I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ECTIBpidZ7zTiY6qqHX3Hhw5zMadNwDJikmt/vCwlXoYQk3wRpKfpKYk04mTMdhowFfN2obM6kgg9CKZ2E0pjSEh4f7PTs6kNWVqQHGLPux8H1D9rkEr1ahSprrHiHdYaKQmcm1V7lnNm1XsUAHO66HPYHRpjma9NafnMdwokEY= 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=cR3y26/s; arc=none smtp.client-ip=209.85.208.49 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="cR3y26/s" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-5c876ed9c93so1188510a12.2 for ; Thu, 26 Sep 2024 08:46:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727365606; x=1727970406; 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=X31HSTlCzdVM5leNrm8kaJCkvfeV2FA5CwiaPcRFfvM=; b=cR3y26/siPso9htbfSuKjSL4TAzVfwur+0FoIEkPmcr7vY8udMb4q4FgUcGQqk3vQw BsIAb73rRvsBfM3pFXr+LhC2wI3IdqO9xcEjWKRmQO3sdJ2ZuF7Y1tT2M73JG7UwwafP vnOpSjzLlZzsF/q1DwnElGoiEEbQP5rd0bWBZzO9gW7ip/nuPxbGeKXTWdQYMQ78G8A7 vh17qBsRN7T88Y2EOfGy7MnxTHOKmcbNNzSJ5KDLOyYza232gMcEFypcH1lYEEpQaBC5 qmA7h3BaT0XXDzOpNMlVdVBXNmB3kYXSmyFILidw0OuEBo0sKKzBoJ6x9tvNRcYnNH/r j99g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727365606; x=1727970406; 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=X31HSTlCzdVM5leNrm8kaJCkvfeV2FA5CwiaPcRFfvM=; b=gYwHO1G3vmMP/vab0Gw3yupiwuUARaouOsv5g0VaG2Z6uJCXM51o2Mbu4MVAsLnM3X Ij5VTFp/gIQYxLK1Di6XAjvKwr9JGf+FxuNnnps4gM5krYOgBJFcC152DzQRi5Ub49Qu c8n2zEJdBcG3sF6pwmg955G27q/p+1/YMB+NR61PI9rq9mM5Gd5Jf+x5BbKP15D0o7Mf ukj5OyVHIE90UPEXk+zqo7XYRuhCfYpuNPWxDV3V6L6OygXhuX+b10hEaXaik7UJPzbB R4D1QgVwOdiovfM0X3pJLoQSQSqPUg3z/f7hYs7yekfdWRtIlylwDrO3lA1WVtws5jcR lH5Q== X-Forwarded-Encrypted: i=1; AJvYcCWQtEe27MDQpCCMOy0X9U3pC/9eIEl8aUd5rwLEQNqCuC5Okdg2sH0Pg2TpOez+A3vckMUwe3Kg4AlbjMw=@vger.kernel.org X-Gm-Message-State: AOJu0YwHV63MmMF5VbLN5sYw4jUh6VIQ4IBEol0rcnUhuoKzeMA2x9g2 GlAEJF4QN6YpSRcUee5wv/Fp2dn28NwNyjzSz6tEr5BM8A90QeZcNSxqnisAEKI= X-Google-Smtp-Source: AGHT+IEaBURJfwJKJ3uznZce7fPj92s1+tbcBYO5hFCdQG0lP3re4+t6lCfulzAoLnpHioLQIeypkg== X-Received: by 2002:a05:6402:4402:b0:5c4:2343:1227 with SMTP id 4fb4d7f45d1cf-5c8824ef51dmr162016a12.5.1727365605957; Thu, 26 Sep 2024 08:46:45 -0700 (PDT) Received: from [127.0.0.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c882405166sm75744a12.9.2024.09.26.08.46.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 08:46:45 -0700 (PDT) From: Bryan O'Donoghue Date: Thu, 26 Sep 2024 16:46:39 +0100 Subject: [PATCH 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: <20240926-b4-master-24-11-25-ov08x40-v1-3-e4d5fbd3b58a@linaro.org> References: <20240926-b4-master-24-11-25-ov08x40-v1-0-e4d5fbd3b58a@linaro.org> In-Reply-To: <20240926-b4-master-24-11-25-ov08x40-v1-0-e4d5fbd3b58a@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=1651; i=bryan.odonoghue@linaro.org; h=from:subject:message-id; bh=9n+eZBcj4PM7sK6+NFZGx6o8ZubV08SdnN4bV1+Fg3I=; b=owEBbQKS/ZANAwAIASJxO7Ohjcg6AcsmYgBm9YHhelecfaMhp+gW2199dsN/wC6Ur4mnO75hN NXFJ2kEuVCJAjMEAAEIAB0WIQTmk/sqq6Nt4Rerb7QicTuzoY3IOgUCZvWB4QAKCRAicTuzoY3I OuLZEACh+orTS42ln+5XegAqChpJoiwuhwYX+HkUOOMHmyYav76OoYVkpHhs+1/k48HWKN1IvbS UgDe0EyTFhiyH6a/uA9iV5GPY7tyMHOGbNfw6GHWaGtJGsW+eag4tSZgJfRJNZYZ2NMuCNGo52o pv0K+URCZfksevR6sOF3IiTF957DWnQ4E5UffAWKmtRef7BQ10/DlLnq/3Axi1fF+QUdX3E4ws6 8sg/Wc51VJ5ZKUNnQREYyOncc+XcvUVRNvS+82IRVmws4BVQ4b9s6xfp7r9GQs7wMwSyM4mUmCP KLKfFJwsiJVd02KrTOBFRqsWuhm+eGALpu9k4/XEJ94KvSfYYQGKoRLLGoEyzIDf2JBLxvqpemT 0GGn5INirPAN30iPfnnTl2mudkJwci9rYzQ+SFM/190fVtPUGEDfOClVaRI5iY+oTeebRZ6awlU xmH/7GRfu3E8YadJvBOH7N2hN+dU4KJI7VjRPJNg+vlD98TE4Po2L9Pt9Wm3EG3dwbCwrHa84Qt mkPRvtIgENCLwWcoi4KY/ZSantTuULvrlBUrXj7czlZlUosbYDpIVTgPLmYk3/bQmT5jm4DcYOh lGtueek1YqzrXaqTNv0R4SbBIlmOJF5xufTXHvkUntU5qAKmgbwVYEhQeTVs1qVQvtV+4vfnFHQ qyuwbEB2a66yP0w== 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 as preparation for adding DT support where the name of the clock in DT will be "xvclk". 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 21:43:49 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 0B3A1158DCC for ; Thu, 26 Sep 2024 15:46:48 +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=1727365611; cv=none; b=bI3t/Ujy9i8Y/s1VnaZpuzgxZtjsJYf8OTeQwNQ1SwIVHn7mGKMq3fFgzsDGFzpg+XKEovtbCfE1d80Z2qfdxbEoNPzFn/HAblNinQ0UtYMFROttEUGHLJJoH2BHTYG0rsQHyTL/WNwRMKzDVsLpvJaCqVGjNAI3gRnW/Y2E3VI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727365611; c=relaxed/simple; bh=hN9nY+XO5LtlmRfoeHlDSRP5jauzJNqdIys8SDwpCh8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BvomNoQCr+rpjZLf7GI2Q5qJi5Gl5hiTr6LlEOvl8qaRXAPOZ3sd8grNtAdvBaTuF5AOdWCNEBe2xQ2Dwf9JbGxN+7EKuUtnqIWaWpglNgXUzrHm0sDMUyJyq/ogyFvFAqOa4msy+Bkuo6tYVzxotj+a1NYVBKwiyRNCPndZAGw= 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=UpbGAjl4; 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="UpbGAjl4" Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2f75b13c2a8so13167681fa.3 for ; Thu, 26 Sep 2024 08:46:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727365607; x=1727970407; 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=/6iOEHBavDXZv+5TUc6CX9qNRyXsARZk7ltgBWtHLzk=; b=UpbGAjl44MX16siuz189l2ZJZNaaGPMxT8CNoCyispcTdXzzF3756XerC7zhOLgX7I bLU9DJcElzjCG5MWSh8wEOvQHiL018fPQ7N9QRkeBcqc9HijaZ74hqo/5pRliw/wLFCf 8f/NePoW/JnUKmsrmE5HzjynuMnjFOF13Jp/5HK0kVNwc+QxuvYm3h9kSVjsNid9kKH0 6UjnD9sxJeHFVgc76In3rcKiE9iN0fEj8caufHcjmv5KOySds1eT3FP+3Lrl4OkqKnki uHYGhEYccbyUxdH+UuHFpaLBTQ+JZqDXJpYwuUyNTlofCJS1Rrbh9h+rVZ8lx4vImF1s 6veQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727365607; x=1727970407; 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=/6iOEHBavDXZv+5TUc6CX9qNRyXsARZk7ltgBWtHLzk=; b=hilZkYOPg5QNQJvOonsymc8e7olSMw/B8Y1oQ90tiXrzaZ5F8D24BS0OndvpMZLtHy uAa5pzo5NvRxL+jX090EV2wewaUprLhhKEXd/wL8XvPCB46X3zcGw7YwkFLxe8VvNNgg VjaBhMgx3vI1E7IwYYG8u0oV9UWTZCyOm8CU9l+CV0gdIHEzvm8OcLBViu+kMq5Y8onl 97VLSMN6k+SkNdhkcgFHP5WkAVY3eV2KgE3N6itN3TzWMMBRpCWgu4vQLZgG8zR+75pp /BsIU4J4cBh9LGOZLaxPT7hUtfgSiKeA6rfD7UzASIEKjwuMUWgL+8Mr8kWh7MF71wka Hl6g== X-Forwarded-Encrypted: i=1; AJvYcCWm3Ef+uS5fkL0KwV+hZg48pSzkIfh9hNmriWA/kj6j5mQ/MU4+WteXWfwCutufrKAxdO7VnlcMwQzzxGg=@vger.kernel.org X-Gm-Message-State: AOJu0Yxi4hoqrCt0JIiLMMnemkgWakddw2Nhenkv3oWS+SGtdw9t9lgW C6M6/Nlfqi6wU10AtPnjmCIJVTuFPwhSqAw1dJn7JT6IEZK9bfco050bATFe072Se2SFgEW3fry sa38= X-Google-Smtp-Source: AGHT+IHdgeSXa45u5y9ZzGSWTYrTnjjBxy62mASnauaIT1zo42jL8IDegwXdw4/dS3sHfWkCuYrF/A== X-Received: by 2002:a2e:4a0a:0:b0:2f9:c0be:3b14 with SMTP id 38308e7fff4ca-2f9d4198afbmr446111fa.42.1727365607045; Thu, 26 Sep 2024 08:46:47 -0700 (PDT) Received: from [127.0.0.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c882405166sm75744a12.9.2024.09.26.08.46.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 08:46:46 -0700 (PDT) From: Bryan O'Donoghue Date: Thu, 26 Sep 2024 16:46:40 +0100 Subject: [PATCH 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: <20240926-b4-master-24-11-25-ov08x40-v1-4-e4d5fbd3b58a@linaro.org> References: <20240926-b4-master-24-11-25-ov08x40-v1-0-e4d5fbd3b58a@linaro.org> In-Reply-To: <20240926-b4-master-24-11-25-ov08x40-v1-0-e4d5fbd3b58a@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=6908; i=bryan.odonoghue@linaro.org; h=from:subject:message-id; bh=hN9nY+XO5LtlmRfoeHlDSRP5jauzJNqdIys8SDwpCh8=; b=owEBbQKS/ZANAwAIASJxO7Ohjcg6AcsmYgBm9YHhO6JO2EG17aLieP8wWpbxTnUs7hM0lfg+v MT//8mekzeJAjMEAAEIAB0WIQTmk/sqq6Nt4Rerb7QicTuzoY3IOgUCZvWB4QAKCRAicTuzoY3I OnjVD/46onL+Bo654zVCWSOXL4wyz2BLGbp8rKtbs15MFsfaj48iu8FSTv8qg4fvZ5iSFpex08f gjKEv+VCBRq742MpE6OL5HQ9CzUkxvpBB/X33FBSC1K5/xLunnIxqF9jKlg17AZ3xpPT57o1jpx H4nPwOTXMohVJW9EhJEUxkQycyLMxT5a6ffDLxHGTisvBCRh1zYrWXf08rJrkoQazYQVvsLhNS/ WHAvyWZxsxZI9HEqX1Ab6DJsU0ytkFmUQ8T9dA/LS1GWHw+caeWKRbgl0Jn0XccM+WSJGTE6gdk MLLJFr3HBFuoqTRte4orJmhk8esmUqleHHYW2bF92rgdlD+7BkfCEo/M4vvEJCCPZZStH6MNe11 Err4J9grs9GLV/+uQSKiwmpsKoE7uKYK6z2rSEKJ3tdN4Qj6Fvl8KPxcwOrjQleneoUro+/TpsW Z03s/HxxiZFa4Sx5s6ybF6lBvTiA5+p92r9swxALe8FBnnvOTmHjM4Sm0AI+ZTdVDU7giYQUx1K 0VXFLNq6Wca6Z06u2j/Vp8XMnNWDp4hqiL45BygcQw7BIJvNGMQrX9k5xroeNtuuxt2wBdb7vyv OYqES1wAarXU41xBFht2wdhEbxe2YyOkm+TPCv/+QZguA91/3DWGdMBjn4eSmqhZbwUsaMphyBf VjlSbfzeT0I+tww== 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 | 129 ++++++++++++++++++++++++++++++++++++++++= ---- 1 file changed, 120 insertions(+), 9 deletions(-) diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c index 3ab8b51df157af78fcccc1aaef73aedb2ae759c9..7e1f473a6661c2beb890ac81b72= ba4782f29b076 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 @@ -2093,6 +2161,32 @@ static int ov08x40_check_hwcfg(struct device *dev) return ret; } =20 + if (!is_acpi_node(fwnode)) { + ov08x->xvclk =3D devm_clk_get(dev, "xvclk"); + if (IS_ERR(ov08x->xvclk)) { + dev_err(dev, "could not get xvclk clock (%pe)\n", + ov08x->xvclk); + return PTR_ERR(ov08x->xvclk); + } + + clk_set_rate(ov08x->xvclk, xvclk_rate); + 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; + } + if (xvclk_rate !=3D OV08X40_XVCLK) { dev_err(dev, "external clock %d is not supported", xvclk_rate); @@ -2143,32 +2237,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 +2309,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 +2326,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 +2339,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