From patchwork Mon Dec 16 21:00:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Apitzsch_via_B4_Relay?= X-Patchwork-Id: 851321 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B56AF1EBA19; Mon, 16 Dec 2024 21:01:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734382892; cv=none; b=hcWOdB9ULR6U33bSTZh5MWtYH99eCdxX3BPirnOgllnVe+IFlylyFtTEowb+fmGufT8bXaUPEK0XzPn4N3ARFBdD76yTLeTmlLa8N8rCD6HgXTwR+1Dzb1b1z1MYRnofOEptOO2F/j+2Xt4a29pcYhR7ZtJCo3sJespK9QiW8U8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734382892; c=relaxed/simple; bh=zUcTVek0znxSPbGSAUj0TIEoAk4rhiWgGrxX0KX4CK0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QVvuwRDO16UVwNTh+tSmiZ2jSHaWl9Jfo4BDIj7qk6R68BFRc95T0vOBr8si+Vgij7yzHnaGwSfmaXvN/z0uxB2vV2snHLUad4TgXR4LY3ktSzeoH08ldqFemH//jCbs1yAYAePzfHAb4r7hNRj6cdezLcJV+NDBcpg0NzozxqE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oz3Tepj/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oz3Tepj/" Received: by smtp.kernel.org (Postfix) with ESMTPS id 7D468C4CEF1; Mon, 16 Dec 2024 21:01:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734382892; bh=zUcTVek0znxSPbGSAUj0TIEoAk4rhiWgGrxX0KX4CK0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=oz3Tepj/f5xam1Er+HDkB/OtyPI6sZITa9QNqPsqXHmvHkgAjxJRhL+Ywl11wk022 cO47ht28NSzHdbG1krWajmUvFo4++WiaO+ZWW8OAOVYMpysURwM6s6hK610WgxwvRC AOk5Wq5eO33EGV4acjcagfKN3MfJ7lM+PMe4m+0NuH7nom7ttoLiIOiYP7pFM4LEzA 7AArpZ+UpnbonUT7Oito1Eq0ZOp0TEazKacx7th9AyNKweSDif77jN6NLesikX++C5 YzC7hvUcMGSabL8r7aapdaYzteE9YIIGIOTa7s07b/Xr3lSxxnWMXKi9mVwIjEEzE9 1q8qhEIEKRN/w== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75121E77183; Mon, 16 Dec 2024 21:01:32 +0000 (UTC) From: =?utf-8?q?Andr=C3=A9_Apitzsch_via_B4_Relay?= Date: Mon, 16 Dec 2024 22:00:56 +0100 Subject: [PATCH v4 10/13] media: i2c: imx214: Verify chip ID Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241216-imx214-v4-10-8cbda160fbce@apitzsch.eu> References: <20241216-imx214-v4-0-8cbda160fbce@apitzsch.eu> In-Reply-To: <20241216-imx214-v4-0-8cbda160fbce@apitzsch.eu> To: Ricardo Ribalda , Sakari Ailus , Mauro Carvalho Chehab Cc: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Dave Stevenson , Vincent Knecht , =?utf-8?q?Andr=C3=A9_Apitzsch?= , Ricardo Ribalda X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734382889; l=1922; i=git@apitzsch.eu; s=20240325; h=from:subject:message-id; bh=e05L2XjG/AT6ZJ+4C5UbrPra4xl1PlWuC53URulnVtQ=; b=yho3ZiU6xmOIuCWyqYaBGSngomt1RZ1HrqaLTBw4AIULLMo8YM4aRfX11PaxEsTYRBWdgUtkr FRB0gDMVZaaDSyZuUo2uk4FkGaKkcK4s/75GigWfvseMZ0YjNWLpTms X-Developer-Key: i=git@apitzsch.eu; a=ed25519; pk=wxovcZRfvNYBMcTw4QFFtNEP4qv39gnBfnfyImXZxiU= X-Endpoint-Received: by B4 Relay for git@apitzsch.eu/20240325 with auth_id=142 X-Original-From: =?utf-8?q?Andr=C3=A9_Apitzsch?= Reply-To: git@apitzsch.eu From: André Apitzsch Check the chip ID and stop probing if it is no imx214 sensor. Acked-by: Ricardo Ribalda Signed-off-by: André Apitzsch --- drivers/media/i2c/imx214.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c index 91d0e892f9ac30a86cd0e1848e4b0d9befea2932..4779439974add96b0fcf5089ae40d8d3126d0ffa 100644 --- a/drivers/media/i2c/imx214.c +++ b/drivers/media/i2c/imx214.c @@ -20,6 +20,10 @@ #include #include +/* Chip ID */ +#define IMX214_REG_CHIP_ID CCI_REG16(0x0016) +#define IMX214_CHIP_ID 0x0214 + #define IMX214_REG_MODE_SELECT CCI_REG8(0x0100) #define IMX214_MODE_STANDBY 0x00 #define IMX214_MODE_STREAMING 0x01 @@ -1098,6 +1102,27 @@ static int imx214_get_regulators(struct device *dev, struct imx214 *imx214) imx214->supplies); } +/* Verify chip ID */ +static int imx214_identify_module(struct imx214 *imx214) +{ + struct i2c_client *client = v4l2_get_subdevdata(&imx214->sd); + int ret; + u64 val; + + ret = cci_read(imx214->regmap, IMX214_REG_CHIP_ID, &val, NULL); + if (ret) + return dev_err_probe(&client->dev, ret, + "failed to read chip id %x\n", + IMX214_CHIP_ID); + + if (val != IMX214_CHIP_ID) + return dev_err_probe(&client->dev, -EIO, + "chip id mismatch: %x!=%llx\n", + IMX214_CHIP_ID, val); + + return 0; +} + static int imx214_parse_fwnode(struct device *dev) { struct fwnode_handle *endpoint; @@ -1191,6 +1216,10 @@ static int imx214_probe(struct i2c_client *client) */ imx214_power_on(imx214->dev); + ret = imx214_identify_module(imx214); + if (ret) + goto error_power_off; + pm_runtime_set_active(imx214->dev); pm_runtime_enable(imx214->dev); pm_runtime_idle(imx214->dev);