From patchwork Thu Sep 26 15:46:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 13813481 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D15C13B5B4 for ; Thu, 26 Sep 2024 15:46:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727365608; cv=none; b=WzrC8BQT85yM0aEv6PYMVFcUPeTrwddp18NjGAaJ/Iw86uHANynJhxAK3Gd58thpSEjD16iNbJUk0rls+3iglxpSTfu2f/kA9xAr+npLAcsjAGEPRfoCUkEX6S+U8twPVoJ3fIv5yBJVeCBemnHuHB2JSBpBat8eSMP+Oyi0wec= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727365608; c=relaxed/simple; bh=vTwVvG8iZlHzHza+YS67mEwp2zyunt+kNzBDYWtFYWc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qcQGlGlGDTndNXOCgX+Dv8oFXSvy++aTr+HMLPgPK0m3DddkU3Xwf4xI3/dOzaCfyo4dgfs35W89992uOZZBigMZLP+UH8xmDY008AcOnxJMvefsVwLyHQoWSGuY45qIFBfTIFB2hLxePTQKUVcPdDs8MhzOrwnL86BzZYpTVfo= 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.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Tr62/Wsx" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-5389917ef34so1252027e87.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=nxbSfPvHhXluZUQ+xtVKRln52+J0BCb8W23ZNF/lDZb6jhqNkgbHWqRl9BfkW3UNxW p9n1PWWGhFh0qa3hzgVUs9rvVE0d7CCqH/dDdY6f21acxT1y2rBwcnMIql0RLr3FT8xl fi1g+/N1XDnjSHTZcaYXD9kechZEqrirTR6i5uGchO0jwSKAaXVsjuhZk47lL8ehBfy9 f8Z1kaceCMt8SZfV+ERsvezstNxedh/g4ueLToJFJ4wxQ9uVtnCAzPmBBH6D4LlyPf4H JTjlpajVJrm3ZvPRDf0A2ab8wOcgqf2zr8jTr2BoPsGOGNis09CYIz8/woFPZbM7MiZT DoeA== X-Gm-Message-State: AOJu0YzZ8sHJgz7jwpg1JY/3aagzcM0n3DU3lE4LgFEI3+ejoCBifSqk daxI/m2icc2qsBYd/XPZvC/c1tR2KhqAvWDgjotAS6bJXzAfYyd17cryvozbaKJ0hj8c/O2e9+a 4OmY= 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-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 290, write) [ 38.781454] ov08x40 2-0036: Failed regs transferred: -95 [ 38.787076] ov08x40 2-0036: ov08x40_start_streaming failed to set regs Fix the error by breaking up the write sequence into the advertised maximum write size of the quirks field if the quirks field is populated. Fixes: 8f667d202384 ("media: ov08x40: Reduce start streaming time") Cc: stable@vger.kernel.org # v6.9+ Tested-by: Bryan O'Donoghue # x1e80100-crd Signed-off-by: Bryan O'Donoghue --- drivers/media/i2c/ov08x40.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c index 48df077522ad0bb2b5f64a6def8844c02af6a193..be25e45175b1322145dca428e845242d8fea2698 100644 --- a/drivers/media/i2c/ov08x40.c +++ b/drivers/media/i2c/ov08x40.c @@ -1339,15 +1339,13 @@ static int ov08x40_read_reg(struct ov08x40 *ov08x, return 0; } -static int ov08x40_burst_fill_regs(struct ov08x40 *ov08x, u16 first_reg, - u16 last_reg, u8 val) +static int __ov08x40_burst_fill_regs(struct i2c_client *client, u16 first_reg, + u16 last_reg, size_t num_regs, u8 val) { - struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd); struct i2c_msg msgs; - size_t i, num_regs; + size_t i; int ret; - num_regs = last_reg - first_reg + 1; msgs.addr = client->addr; msgs.flags = 0; msgs.len = 2 + num_regs; @@ -1373,6 +1371,31 @@ static int ov08x40_burst_fill_regs(struct ov08x40 *ov08x, u16 first_reg, return 0; } +static int ov08x40_burst_fill_regs(struct ov08x40 *ov08x, u16 first_reg, + u16 last_reg, u8 val) +{ + struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd); + size_t num_regs, num_write_regs; + int ret; + + num_regs = last_reg - first_reg + 1; + num_write_regs = num_regs; + + if (client->adapter->quirks && client->adapter->quirks->max_write_len) + num_write_regs = client->adapter->quirks->max_write_len - 2; + + while (first_reg < last_reg) { + ret = __ov08x40_burst_fill_regs(client, first_reg, last_reg, + num_write_regs, val); + if (ret) + return ret; + + first_reg += num_write_regs; + } + + return 0; +} + /* Write registers up to 4 at a time */ static int ov08x40_write_reg(struct ov08x40 *ov08x, u16 reg, u32 len, u32 __val) From patchwork Thu Sep 26 15:46:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 13813482 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 7290D156F41 for ; Thu, 26 Sep 2024 15:46:47 +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=1727365609; cv=none; b=G2WtDzGxFBBYvvmpLRSxLDpbbcbmu4MzM7S0fUskRRVlTGcbri+se22KPnZZmLWXRnDvVHcHwz/pqa2jkmLcIsMTa2wgEML+ckUVmkciXy75bN7/j8us9AZxWzRdwwFt0YAXbKBZKS79HnZl7GqXiXxgyj9VUtABM15Ba/SYvWI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727365609; c=relaxed/simple; bh=4FVzIy8QpHWKlC0SqUgcgLp+icF+nOSWpVflVXxObqE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nVCY8rlBTvYEG/AXt5feY7gLU9oGmkkAFU4DIDb11/HlzaaCUD8ZXEARX4ODFNUDOAbRNZUFr1GsJ1IvkaocK4G6zrAplALYXU3vIiDt2sTeYnbkaTTRcF/OAgAH9lshTwc1OzJ3toTW15oobNe48uH2OAioncjt7J37NMtw/YU= 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.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="yTYzrfYo" Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2f74b6e1810so10581921fa.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=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=GsoqB7GJbviT1/C+02FV3JTUB7lxNLBrNIviVyL2VBl4nNeyzi9TCOG+Qi5wik5OAd 2ZSIMxQaZpiLSJNMkcH+ncQJY+w6IZERDttXwmMAenlYPjPTMfIDm/ipAKEqdNTgAF1S mSH76w05WfdXNl7TrHLg+n6H/0PCbcNjCZU4G1QaQfiYj3HWFkGgSi/MBenqclgGn5yR wB08UTjodTGQARayu62sGkd8u08ordW9QlO5rQZpYSIP4uqUnAFetv7/7DSlod8EnGF4 ST0V2gb31KtKFO9jDFUXhlIdlsXBP6eupkgDXLy7CbfHgm6sXx9WfDfe5QUaxsGJgx4m W7qg== X-Gm-Message-State: AOJu0YwdrcLLAbyAC6D4RsawVv9AIAnh79jz0VfwJuGDzL1s4s8AvE+N M0bHrC++cLlqUA92Fdxxci2Y/8w50Xx/juUQ5yoBTnxeqxCz0n5+G3A6TE/pfiojj8eTGG73Jqt eesQ= 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-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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..250785f062d0146e8615d8f3e7700aebbd40b1dc --- /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 supports. + - Automatic black level calibration (ABLC) + - Programmable controls for frame rate, mirror and flip, binning, cropping + and windowing + - Output formats 10-bit 4C RGB RAW, 10-bit Bayer RAW + - 4-lane MIPI D-PHY TX @ 1 Gbps per lane + - 2-lane MPIP D-PHY TX @ 2 Gbps per lane + - Dynamic defect pixel cancellation + - Standard SCCB command interface + +properties: + compatible: + const: ovti,ov08x40 + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + 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 = <1>; + #size-cells = <0>; + + ov08x40: camera@36 { + compatible = "ovti,ov08x40"; + reg = <0x36>; + + reset-gpios = <&tlmm 111 GPIO_ACTIVE_LOW>; + pinctrl-names = "default"; + pinctrl-0 = <&cam_rgb_defaultt>; + + clocks = <&ov08x40_clk>; + clock-names = "xvclk"; + clock-frequency = <19200000>; + + avdd-supply = <&vreg_l7b_2p8>; + dvdd-supply = <&vreg_l7b_1p8>; + dovdd-supply = <&vreg_l3m_1p8>; + + port { + ov08x40_ep: endpoint { + remote-endpoint = <&csiphy4_ep>; + data-lanes = <1 2 3 4>; + link-frequencies = /bits/ 64 <400000000>; + }; + }; + }; + }; +... From patchwork Thu Sep 26 15:46:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 13813483 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.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 E8B54157E6B for ; Thu, 26 Sep 2024 15:46:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727365609; cv=none; b=olC5Jwmi2mmhhe8MFWmckVOy4/icCE4cHzst2UhcryDsre+gL0LO5jN7+y0F2Unt+N/cASUQbAZnPL2yUhu4dJtK2+w6ZyWXKuqlUyGrvm/NpKitCkRu4/MOJgxfPoInaPi31egBOHE97ithhCqshiPr+iV75Q40iL3ddBwIpAk= 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.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="cR3y26/s" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-5c876ed9c93so1188514a12.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=Szq88YZseejT7xxk/PkyPuFFdF9yrV6LEUgdp6raQFRXtfFjdU+NVFJdjob20u1YVa dbOhaZ0/RRx0wMxMF/436jCiAK2Jf2a20+f6K4Yibn66tC65DH48XYoX8HSKhlX/zUX/ uzOwVFYxUFTSVB4i6qvInhdxk0XIap6A1m2bnkiMWh36xP9v2+f9RMrRzivKnJXBvf2a 0Guz+zkkY7/oYZH06E9lGnVdaUEiMrTlmIrHh/Oz2ZclIo9qEJKKZdJGsBmJ3DGXd1Zd iR+JtDnZcTTjZ+aEvcrxZsG9MraX0AGgez45viXgIGcR7IFi40XCh+4h2+AQHKkLr0rx D/pA== X-Gm-Message-State: AOJu0YxbHHQyQwq2M+p6/CnEvw2WzWs1ef7mcq2W+SkPHYwVOIM+pDc1 HOQs8H2wckr+rovpWjvvmbiRwo4jmA9Vveqa2FY9IkBUN1cyvAa1rM9US40rjGlnuGsZ/5ML4LP UrJk= 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-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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..3ab8b51df157af78fcccc1aaef73aedb2ae759c9 100644 --- a/drivers/media/i2c/ov08x40.c +++ b/drivers/media/i2c/ov08x40.c @@ -1215,7 +1215,7 @@ static const char * const ov08x40_test_pattern_menu[] = { /* Configurations for supported link frequencies */ #define OV08X40_LINK_FREQ_400MHZ 400000000ULL #define OV08X40_SCLK_96MHZ 96000000ULL -#define OV08X40_EXT_CLK 19200000 +#define OV08X40_XVCLK 19200000 #define OV08X40_DATA_LANES 4 /* @@ -2081,21 +2081,21 @@ static int ov08x40_check_hwcfg(struct device *dev) struct fwnode_handle *fwnode = dev_fwnode(dev); unsigned int i, j; int ret; - u32 ext_clk; + u32 xvclk_rate; if (!fwnode) return -ENXIO; ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", - &ext_clk); + &xvclk_rate); if (ret) { dev_err(dev, "can't get clock frequency"); return ret; } - if (ext_clk != OV08X40_EXT_CLK) { + if (xvclk_rate != OV08X40_XVCLK) { dev_err(dev, "external clock %d is not supported", - ext_clk); + xvclk_rate); return -EINVAL; } From patchwork Thu Sep 26 15:46:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 13813484 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 35F3C15A4B0 for ; Thu, 26 Sep 2024 15:46:49 +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=1727365611; cv=none; b=Fgvf0qhdady/Ub0yiwUa9v2bn09K3ArosOnDEbRipii64sgJdpi+k0m+/BgWxsBju31rzOaIB6WyGqcAD240yojp1LDVQlHbdzF1ptgc/FBKwgwKSE8HVv+eTQH5WJLmBH5aYEfX/6H+TQ1v0Zu9K6KS803pGbeza/fyLZ2Yzvs= 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.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="UpbGAjl4" Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2f75c56f16aso15508681fa.0 for ; Thu, 26 Sep 2024 08:46:49 -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=Ho6yxCbzfPhgIXwkuVKlLxwXV3GbpdhZ6frQhWUumVkquZQePOsORe9lMl/dyGXjXA lGkAl9T+McqsuC9Q9cHsxUrbUaxptq1z0Nz022IKDf9iX1ZpfGYEBA2E5Rvfsovi7iIn bPxeJAySfWLNECsau3OptC2Mm250Fg1XKTxO/IwX/dlE1aAFNyrsSIxCHaLZcsvu63Vr 2dRaHsAMi56z85mmvtqIG2P4PputoM5gxkiMLGNqkyVHrhZrVlUfR28ciNpr/Vn0aYy4 edH3d8sgjC+ewGY2iwFHm/S75/l5zYnryPfCtaQ7nX3lyZbwCk1jfoQVV5jNpyhQ4od/ m1yQ== X-Gm-Message-State: AOJu0YyAL+DphPBhvb0+W3tJlPUrgNK51rMlqAtvwYUo7Sv383IT5BNW ko5yxyklpWqFB3i1PjiN90ap3CDAfbx8k/VS8qxc74qZaPHs0c75qld6GNOU4ilG0kOiIM5DIR/ Y1T4= 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-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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..7e1f473a6661c2beb890ac81b72ba4782f29b076 100644 --- a/drivers/media/i2c/ov08x40.c +++ b/drivers/media/i2c/ov08x40.c @@ -3,10 +3,13 @@ #include #include +#include #include +#include #include #include #include +#include #include #include #include @@ -1279,6 +1282,12 @@ static const struct ov08x40_mode supported_modes[] = { }, }; +static const char * const ov08x40_supply_names[] = { + "dovdd", /* Digital I/O power */ + "avdd", /* Analog power */ + "dvdd", /* Digital core power */ +}; + struct ov08x40 { struct v4l2_subdev sd; struct media_pad pad; @@ -1291,6 +1300,10 @@ struct ov08x40 { struct v4l2_ctrl *hblank; struct v4l2_ctrl *exposure; + struct clk *xvclk; + struct gpio_desc *reset_gpio; + struct regulator_bulk_data supplies[ARRAY_SIZE(ov08x40_supply_names)]; + /* Current mode */ const struct ov08x40_mode *cur_mode; @@ -1303,6 +1316,61 @@ struct ov08x40 { #define to_ov08x40(_sd) container_of(_sd, struct ov08x40, sd) +static int ov08x40_power_on(struct device *dev) +{ + struct v4l2_subdev *sd = dev_get_drvdata(dev); + struct ov08x40 *ov08x = to_ov08x40(sd); + int ret; + + if (is_acpi_node(dev_fwnode(dev))) + return 0; + + ret = clk_prepare_enable(ov08x->xvclk); + if (ret < 0) { + dev_err(dev, "failed to enable xvclk\n"); + return ret; + } + + if (ov08x->reset_gpio) { + gpiod_set_value_cansleep(ov08x->reset_gpio, 1); + usleep_range(1000, 2000); + } + + ret = regulator_bulk_enable(ARRAY_SIZE(ov08x40_supply_names), + ov08x->supplies); + if (ret < 0) { + dev_err(dev, "failed to enable regulators\n"); + goto disable_clk; + } + + gpiod_set_value_cansleep(ov08x->reset_gpio, 0); + usleep_range(1500, 1800); + + return 0; + +disable_clk: + gpiod_set_value_cansleep(ov08x->reset_gpio, 1); + clk_disable_unprepare(ov08x->xvclk); + + return ret; +} + +static int ov08x40_power_off(struct device *dev) +{ + struct v4l2_subdev *sd = dev_get_drvdata(dev); + struct ov08x40 *ov08x = to_ov08x40(sd); + + if (is_acpi_node(dev_fwnode(dev))) + return 0; + + gpiod_set_value_cansleep(ov08x->reset_gpio, 1); + regulator_bulk_disable(ARRAY_SIZE(ov08x40_supply_names), + ov08x->supplies); + clk_disable_unprepare(ov08x->xvclk); + + return 0; +} + /* Read registers up to 4 at a time */ static int ov08x40_read_reg(struct ov08x40 *ov08x, u16 reg, u32 len, u32 *val) @@ -2072,7 +2140,7 @@ static void ov08x40_free_controls(struct ov08x40 *ov08x) mutex_destroy(&ov08x->mutex); } -static int ov08x40_check_hwcfg(struct device *dev) +static int ov08x40_check_hwcfg(struct ov08x40 *ov08x, struct device *dev) { struct v4l2_fwnode_endpoint bus_cfg = { .bus_type = V4L2_MBUS_CSI2_DPHY @@ -2093,6 +2161,32 @@ static int ov08x40_check_hwcfg(struct device *dev) return ret; } + if (!is_acpi_node(fwnode)) { + ov08x->xvclk = 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 = clk_get_rate(ov08x->xvclk); + + ov08x->reset_gpio = devm_gpiod_get_optional(dev, "reset", + GPIOD_OUT_LOW); + if (IS_ERR(ov08x->reset_gpio)) + return PTR_ERR(ov08x->reset_gpio); + + for (i = 0; i < ARRAY_SIZE(ov08x40_supply_names); i++) + ov08x->supplies[i].supply = ov08x40_supply_names[i]; + + ret = devm_regulator_bulk_get(dev, + ARRAY_SIZE(ov08x40_supply_names), + ov08x->supplies); + if (ret) + return ret; + } + if (xvclk_rate != 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) } static int ov08x40_probe(struct i2c_client *client) -{ - struct ov08x40 *ov08x; +{ struct ov08x40 *ov08x; int ret; bool full_power; + ov08x = devm_kzalloc(&client->dev, sizeof(*ov08x), GFP_KERNEL); + if (!ov08x) + return -ENOMEM; + /* Check HW config */ - ret = ov08x40_check_hwcfg(&client->dev); + ret = ov08x40_check_hwcfg(ov08x, &client->dev); if (ret) { dev_err(&client->dev, "failed to check hwcfg: %d", ret); return ret; } - ov08x = devm_kzalloc(&client->dev, sizeof(*ov08x), GFP_KERNEL); - if (!ov08x) - return -ENOMEM; - /* Initialize subdev */ v4l2_i2c_subdev_init(&ov08x->sd, client, &ov08x40_subdev_ops); full_power = acpi_dev_state_d0(&client->dev); if (full_power) { + ret = ov08x40_power_on(&client->dev); + if (ret) { + dev_err(&client->dev, "failed to power on\n"); + return ret; + } + /* Check module identity */ ret = ov08x40_identify_module(ov08x); if (ret) { dev_err(&client->dev, "failed to find sensor: %d\n", ret); - return ret; + goto probe_power_off; } } @@ -2210,6 +2309,9 @@ static int ov08x40_probe(struct i2c_client *client) error_handler_free: ov08x40_free_controls(ov08x); +probe_power_off: + ov08x40_power_off(&client->dev); + return ret; } @@ -2224,6 +2326,8 @@ static void ov08x40_remove(struct i2c_client *client) pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); + + ov08x40_power_off(&client->dev); } #ifdef CONFIG_ACPI @@ -2235,10 +2339,17 @@ static const struct acpi_device_id ov08x40_acpi_ids[] = { MODULE_DEVICE_TABLE(acpi, ov08x40_acpi_ids); #endif +static const struct of_device_id ov08x40_of_match[] = { + { .compatible = "ovti,ov08x40" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, ov08x40_of_match); + static struct i2c_driver ov08x40_i2c_driver = { .driver = { .name = "ov08x40", .acpi_match_table = ACPI_PTR(ov08x40_acpi_ids), + .of_match_table = ov08x40_of_match, }, .probe = ov08x40_probe, .remove = ov08x40_remove,