From patchwork Wed Sep 23 15:21:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 11795129 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E976F112E for ; Wed, 23 Sep 2020 15:22:02 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B54BF221E7 for ; Wed, 23 Sep 2020 15:22:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="DICBs42o"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="1qswdop5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B54BF221E7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:To:From:Reply-To:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=wzzru50syqE6yTUhOCmzNvZZak0voUwswrh/PKuBARk=; b=DICBs42ovQxfzw4MFCCw9JFnWE K0+VbsC9gYlhhrTBbtOW27CRwnojPhaXOrFEVX9xE1Mf5LOTXkYyz7m2Mo6s2CZYUAnKwSvaDLAzm rqvMYCuzLoyn1TyG55Srmrf+fc84Pjzw0lmQgYQ6zM8rgaVQZuDY1XzfZL6Ikvh9ApJ0tErkAnL+r G+loUq8Hw4589TYdrcBhKjjvF55vBHiP9qdlJoRW66OEhQBxkBzoEvTLMrqc9+dTPGOv2EpVSmQ0E S0shSPC7d2ncZ++jEb/vQF2DP7JTRnXoifHJHnjM2EkMbDlWSGA+jFJt9iPP51Dwoa9MVIUSuu3m3 Wdp7qqXQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kL6aY-0000qZ-N3; Wed, 23 Sep 2020 15:21:46 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kL6aW-0000pH-Da for linux-arm-kernel@lists.infradead.org; Wed, 23 Sep 2020 15:21:45 +0000 Received: from localhost.localdomain (unknown [194.230.155.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 39ABB21D7D; Wed, 23 Sep 2020 15:21:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600874503; bh=wvbsKJYoqgNub9wPTqt3MqH7+f/uGfjF05Ctdg6ef8Q=; h=From:To:Subject:Date:From; b=1qswdop5ZbIH3YNuChOfZZPkymeF2rhoCevYoVbzSwnacV5eZZSDwGTp0Bmq8Ys+g NSdjT6dz22C6D3flVrn/cuUk69cn2N7zJyM8WhgRqS9JLgv87RbFH/Uno56gwWDec4 ub3na5zpBE8uRfZuRQOqqczKsRmW38g5C7ylkPBI= From: Krzysztof Kozlowski To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Krzysztof Kozlowski , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 1/4] dt-bindings: media: imx258: add bindings for IMX258 sensor Date: Wed, 23 Sep 2020 17:21:26 +0200 Message-Id: <20200923152129.21736-1-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200923_112144_680668_63EA006D X-CRM114-Status: GOOD ( 18.30 ) X-Spam-Score: -6.4 (------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-6.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [198.145.29.99 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -1.2 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add bindings for the IMX258 camera sensor. The bindings, just like the driver, are quite limited, e.g. do not support regulator supplies. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Rob Herring --- Changes since v3: 1. Document also two lane setup. Changes since v2: 1. Remove clock-frequency, add reset GPIOs, add supplies. 2. Use additionalProperties. Changes since v1: 1. None --- .../devicetree/bindings/media/i2c/imx258.yaml | 100 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 101 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/imx258.yaml diff --git a/Documentation/devicetree/bindings/media/i2c/imx258.yaml b/Documentation/devicetree/bindings/media/i2c/imx258.yaml new file mode 100644 index 000000000000..520e75c7b451 --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/imx258.yaml @@ -0,0 +1,100 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/i2c/imx258.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sony IMX258 13 Mpixel CMOS Digital Image Sensor + +maintainers: + - Krzysztof Kozlowski + +description: |- + IMX258 is a diagonal 5.867mm (Type 1/3.06) 13 Mega-pixel CMOS active pixel + type stacked image sensor with a square pixel array of size 4208 x 3120. It + is programmable through I2C interface. Image data is sent through MIPI + CSI-2. + +properties: + compatible: + const: sony,imx258 + + clocks: + description: + Clock frequency from 6 to 27 MHz. + maxItems: 1 + + reg: + maxItems: 1 + + reset-gpios: + description: |- + Reference to the GPIO connected to the XCLR pin, if any. + + vana-supply: + description: + Analog voltage (VANA) supply, 2.7 V + + vdig-supply: + description: + Digital I/O voltage (VDIG) supply, 1.2 V + + vif-supply: + description: + Interface voltage (VIF) supply, 1.8 V + + # See ../video-interfaces.txt for more details + port: + type: object + properties: + endpoint: + type: object + properties: + data-lanes: + oneOf: + - items: + - const: 1 + - const: 2 + - const: 3 + - const: 4 + - items: + - const: 1 + - const: 2 + + link-frequencies: + allOf: + - $ref: /schemas/types.yaml#/definitions/uint64-array + description: + Allowed data bus frequencies. + + required: + - data-lanes + - link-frequencies + +required: + - compatible + - reg + - port + +additionalProperties: false + +examples: + - | + i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + sensor@6c { + compatible = "sony,imx258"; + reg = <0x6c>; + clocks = <&imx258_clk>; + + port { + endpoint { + remote-endpoint = <&csi1_ep>; + data-lanes = <1 2 3 4>; + link-frequencies = /bits/ 64 <320000000>; + }; + }; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 5b9621ca2b31..68f30a283a2c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16262,6 +16262,7 @@ M: Sakari Ailus L: linux-media@vger.kernel.org S: Maintained T: git git://linuxtv.org/media_tree.git +F: Documentation/devicetree/bindings/media/i2c/imx258.yaml F: drivers/media/i2c/imx258.c SONY IMX274 SENSOR DRIVER From patchwork Wed Sep 23 15:21:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 11795131 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D5AAB6CB for ; Wed, 23 Sep 2020 15:22:04 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9886E221E7 for ; Wed, 23 Sep 2020 15:22:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="0XdkobyZ"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="jdFSqzea" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9886E221E7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qZdmWQhwfQMlCGuQhp8L9qs03aZT3GBO7TXlzpFYko8=; b=0XdkobyZuw6MFwqiuO8UJZaDy4 Pk4G4UxFyulasV+2zsSGPqglXIr/Hhqr8iFy2YD6vmyrJZ6NUBserfF1UfwArtXFY+L18UYuu5i89 woWuBCzvrbUu5vxxqZNP3zHDCufvZNSZNbWlSGB3gQcg8Q6YiGHrAvyIj8OHm+VNoq4AGj49/gUlT FI/ZH5j4t6gl0E/Bv+5vMDJ+LWdF5pvvtdB/lWU7n30YwD599czo92VkTa9FQPpy4ACwsdaTxLgXm +g86Kmbbs81lUefLVpO7TRxbXjEvyfLrmSjSHoMpEJpXRgMwM8JOfz6KkV8okah7mfVCJt675zdpM z8dmx1bA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kL6ag-0000tq-1D; Wed, 23 Sep 2020 15:21:54 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kL6ad-0000su-NH for linux-arm-kernel@lists.infradead.org; Wed, 23 Sep 2020 15:21:52 +0000 Received: from localhost.localdomain (unknown [194.230.155.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C013B2220D; Wed, 23 Sep 2020 15:21:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600874511; bh=YFzPYTGbhS/cXqU9/JrjDc2rIbUUmhePYBf0XdnbY5c=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jdFSqzeaWobiZMLn/+cvSwMakiL7KnX32BZ+wR8JppfqHnUFznHunmVWEirUe7Pki 8xXWp3T6PPzBayhIL3uqO2rvT5MdPR2F9XKBjI2VQt0UBnH0czAdJd3Ljf/ureAEuH UErCL/cjIU2hOaJgewkWihe6AQTiLxvVXBee1QEg= From: Krzysztof Kozlowski To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Krzysztof Kozlowski , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 2/4] media: i2c: imx258: add support for binding via device tree Date: Wed, 23 Sep 2020 17:21:27 +0200 Message-Id: <20200923152129.21736-2-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200923152129.21736-1-krzk@kernel.org> References: <20200923152129.21736-1-krzk@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200923_112151_831257_78F28925 X-CRM114-Status: GOOD ( 15.58 ) X-Spam-Score: -6.4 (------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-6.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [198.145.29.99 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -1.2 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The IMX258 can be used also on embedded designs using device tree so allow the sensor to bind to a device tree node. Signed-off-by: Krzysztof Kozlowski --- Changes since v1: 1. None --- drivers/media/i2c/imx258.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c index ccb55fd1d506..ed79bfb4c991 100644 --- a/drivers/media/i2c/imx258.c +++ b/drivers/media/i2c/imx258.c @@ -1291,11 +1291,18 @@ static const struct acpi_device_id imx258_acpi_ids[] = { MODULE_DEVICE_TABLE(acpi, imx258_acpi_ids); #endif +static const struct of_device_id imx258_dt_ids[] = { + { .compatible = "sony,imx258" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, imx258_dt_ids); + static struct i2c_driver imx258_i2c_driver = { .driver = { .name = "imx258", .pm = &imx258_pm_ops, .acpi_match_table = ACPI_PTR(imx258_acpi_ids), + .of_match_table = imx258_dt_ids, }, .probe_new = imx258_probe, .remove = imx258_remove, From patchwork Wed Sep 23 15:21:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 11795135 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B2B166CB for ; Wed, 23 Sep 2020 15:22:13 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 747DD21D7D for ; Wed, 23 Sep 2020 15:22:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="UuGteZLb"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="sUCUIUoU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 747DD21D7D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9CMFaQ9Ngdz/8wpZvvr1LuYMbMJpjhyO4fCDkNSs9fM=; b=UuGteZLb8IpE/zF4fRkHzrQ19p QdB5bl33UVSgG/rovd4PJ23fziawydUT37NSMNz9oo892RNLG5WfnfnapZ/PJsYBv173d+kd7DGsF eYPD9zMSbXuadVHfu55thGItk/bIFkBrTNVCI+iueJNMunrcDqm2xSzuCYl+qdrZk1E88sFer2/Fe B3suzz1e2Kjj4a3gxuBf0nou24C9m8uUqJWU27orPXEOzJf+s9GjE5155K7obt5+ldRXz6axoprqw kCQ7+2nx4paAZzPrdgI/8byk1FCGCcNXSERtB6zkrmgEhG4D3bqK+sOvn50N/p6gWFYkmqIDovYf2 lTJOPj8A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kL6an-0000vz-Va; Wed, 23 Sep 2020 15:22:02 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kL6ai-0000uO-Qj for linux-arm-kernel@lists.infradead.org; Wed, 23 Sep 2020 15:21:58 +0000 Received: from localhost.localdomain (unknown [194.230.155.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A2C31221E7; Wed, 23 Sep 2020 15:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600874516; bh=+tyuJ8q5tjs0jpFIPnpAR8bb5kiLEh5MWM0XHwgZgz0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=sUCUIUoUUR9CrF6o2sXj2S9Tqz0z+l8tXQnNuiXIROgOWFhTBxOz7rsEcDBSJOevC 00WjyLhmw9x7dboS2T/3gaI8ExtLKsCxCKCnqSJV0FzhJSi2n3QzScek8DXfgIzuhu 7qQ72iMlLyMWV6ZafCcBdrq+USeQLLqHzE2N+V9o= From: Krzysztof Kozlowski To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Krzysztof Kozlowski , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 3/4] media: i2c: imx258: simplify getting state container Date: Wed, 23 Sep 2020 17:21:28 +0200 Message-Id: <20200923152129.21736-3-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200923152129.21736-1-krzk@kernel.org> References: <20200923152129.21736-1-krzk@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200923_112156_946994_DDD77508 X-CRM114-Status: GOOD ( 15.08 ) X-Spam-Score: -6.4 (------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-6.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [198.145.29.99 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -1.2 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The pointer to 'struct v4l2_subdev' is stored in drvdata via v4l2_i2c_subdev_init() so there is no point of a dance like: struct i2c_client *client = to_i2c_client(struct device *dev) struct v4l2_subdev *sd = i2c_get_clientdata(client); This allows to remove local variable 'client' and few pointer dereferences. Signed-off-by: Krzysztof Kozlowski --- Changes since v3: 1. None Changes since v2: 1. New patch --- drivers/media/i2c/imx258.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c index ed79bfb4c991..ae183b0dbba9 100644 --- a/drivers/media/i2c/imx258.c +++ b/drivers/media/i2c/imx258.c @@ -1018,8 +1018,7 @@ static int imx258_set_stream(struct v4l2_subdev *sd, int enable) static int __maybe_unused imx258_suspend(struct device *dev) { - struct i2c_client *client = to_i2c_client(dev); - struct v4l2_subdev *sd = i2c_get_clientdata(client); + struct v4l2_subdev *sd = dev_get_drvdata(dev); struct imx258 *imx258 = to_imx258(sd); if (imx258->streaming) @@ -1030,8 +1029,7 @@ static int __maybe_unused imx258_suspend(struct device *dev) static int __maybe_unused imx258_resume(struct device *dev) { - struct i2c_client *client = to_i2c_client(dev); - struct v4l2_subdev *sd = i2c_get_clientdata(client); + struct v4l2_subdev *sd = dev_get_drvdata(dev); struct imx258 *imx258 = to_imx258(sd); int ret; From patchwork Wed Sep 23 15:21:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 11795137 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7CFB112E for ; Wed, 23 Sep 2020 15:22:20 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A39C621D7D for ; Wed, 23 Sep 2020 15:22:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="b6bCzJIr"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="puPPJBBj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A39C621D7D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NlSi6gHdb0XaGh8Q5uKAqkPCq2NJjmiVo1XK76JerkA=; b=b6bCzJIrIw3He8DRNQULiv9+ul TYxlc0VcB5Jghu9lR2VI7FMEto8U6wzyWPE8pDc5c+20BWqVqIIgrzvwxtseSz3a7JMvhPpoC/qIW mNZjuoPXnl36eaJyU23Etq+N2EUAgfnBWPvdYSYLPk4aGnuef5WnsUxYintFuDiixLv2SFfOnT/rc HKmJu27/D2drre2piFfGkMhyLeEQJHtg65bTWzc3eKpJIY50NbM5YG8Q5CeSVgeZMRO+fdRB6jw1c TaQVLBYlXLIPb2HIodkHce7Z/mhUC66DpvBXrxem6LuvJ78fgrPH+Onarf3hiEr6HKGydZAyOFQIH gj/1Ai1w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kL6au-0000yL-Ub; Wed, 23 Sep 2020 15:22:08 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kL6ao-0000wR-Rp for linux-arm-kernel@lists.infradead.org; Wed, 23 Sep 2020 15:22:04 +0000 Received: from localhost.localdomain (unknown [194.230.155.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4AE3021D7D; Wed, 23 Sep 2020 15:21:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600874522; bh=tH7mX2uiDbk528V//LDqIJ+cbqxHanIdBiyIEHFK1RI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=puPPJBBj9n7wgb77YhUNAoCQeBAPQvpu54QNBSNwZcR5EznlCkROqhTYqS+OQGXGK 1LFrXTI7Ljbp9xVEvnsNfR+1T+VeutZUM303oqGE2ZLapjX32jF8oY3Zw9iM37Ewza DPCo1Q8+2Cr7CGidaKauX3/qOAo6II5bJH4pQ0R8= From: Krzysztof Kozlowski To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Krzysztof Kozlowski , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 4/4] media: i2c: imx258: get clock from device properties and enable it via runtime PM Date: Wed, 23 Sep 2020 17:21:29 +0200 Message-Id: <20200923152129.21736-4-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200923152129.21736-1-krzk@kernel.org> References: <20200923152129.21736-1-krzk@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200923_112203_063949_6B0F2FAD X-CRM114-Status: GOOD ( 25.03 ) X-Spam-Score: -6.4 (------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-6.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [198.145.29.99 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -1.2 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The IMX258 sensor driver checked in device properties for a clock-frequency property which actually does not mean that the clock is really running such frequency or is it even enabled. Get the provided clock and check it frequency. If none is provided, fall back to old property. Enable the clock when accessing the IMX258 registers and when streaming starts with runtime PM. Signed-off-by: Krzysztof Kozlowski --- Changes since v3: 1. None Changes since v2: 1. Do not try to set drvdata, wrap lines. 2. Use dev_dbg. Changes since v1: 1. Use runtime PM for clock toggling --- drivers/media/i2c/imx258.c | 71 +++++++++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 9 deletions(-) diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c index ae183b0dbba9..7bedbfe5c4d6 100644 --- a/drivers/media/i2c/imx258.c +++ b/drivers/media/i2c/imx258.c @@ -2,6 +2,7 @@ // Copyright (C) 2018 Intel Corporation #include +#include #include #include #include @@ -68,6 +69,9 @@ #define REG_CONFIG_MIRROR_FLIP 0x03 #define REG_CONFIG_FLIP_TEST_PATTERN 0x02 +/* Input clock frequency in Hz */ +#define IMX258_INPUT_CLOCK_FREQ 19200000 + struct imx258_reg { u16 address; u8 val; @@ -610,6 +614,8 @@ struct imx258 { /* Streaming on/off */ bool streaming; + + struct clk *clk; }; static inline struct imx258 *to_imx258(struct v4l2_subdev *_sd) @@ -972,6 +978,29 @@ static int imx258_stop_streaming(struct imx258 *imx258) return 0; } +static int imx258_power_on(struct device *dev) +{ + struct v4l2_subdev *sd = dev_get_drvdata(dev); + struct imx258 *imx258 = to_imx258(sd); + int ret; + + ret = clk_prepare_enable(imx258->clk); + if (ret) + dev_err(dev, "failed to enable clock\n"); + + return ret; +} + +static int imx258_power_off(struct device *dev) +{ + struct v4l2_subdev *sd = dev_get_drvdata(dev); + struct imx258 *imx258 = to_imx258(sd); + + clk_disable_unprepare(imx258->clk); + + return 0; +} + static int imx258_set_stream(struct v4l2_subdev *sd, int enable) { struct imx258 *imx258 = to_imx258(sd); @@ -1199,9 +1228,28 @@ static int imx258_probe(struct i2c_client *client) int ret; u32 val = 0; - device_property_read_u32(&client->dev, "clock-frequency", &val); - if (val != 19200000) - return -EINVAL; + imx258 = devm_kzalloc(&client->dev, sizeof(*imx258), GFP_KERNEL); + if (!imx258) + return -ENOMEM; + + imx258->clk = devm_clk_get_optional(&client->dev, NULL); + if (!imx258->clk) { + dev_dbg(&client->dev, + "no clock provided, using clock-frequency property\n"); + + device_property_read_u32(&client->dev, "clock-frequency", &val); + if (val != IMX258_INPUT_CLOCK_FREQ) + return -EINVAL; + } else if (IS_ERR(imx258->clk)) { + return dev_err_probe(&client->dev, PTR_ERR(imx258->clk), + "error getting clock\n"); + } else { + if (clk_get_rate(imx258->clk) != IMX258_INPUT_CLOCK_FREQ) { + dev_err(&client->dev, + "input clock frequency not supported\n"); + return -EINVAL; + } + } /* * Check that the device is mounted upside down. The driver only @@ -1211,24 +1259,25 @@ static int imx258_probe(struct i2c_client *client) if (ret || val != 180) return -EINVAL; - imx258 = devm_kzalloc(&client->dev, sizeof(*imx258), GFP_KERNEL); - if (!imx258) - return -ENOMEM; - /* Initialize subdev */ v4l2_i2c_subdev_init(&imx258->sd, client, &imx258_subdev_ops); + /* Will be powered off via pm_runtime_idle */ + ret = imx258_power_on(&client->dev); + if (ret) + return ret; + /* Check module identity */ ret = imx258_identify_module(imx258); if (ret) - return ret; + goto error_identify; /* Set default mode to max resolution */ imx258->cur_mode = &supported_modes[0]; ret = imx258_init_controls(imx258); if (ret) - return ret; + goto error_identify; /* Initialize subdev */ imx258->sd.internal_ops = &imx258_internal_ops; @@ -1258,6 +1307,9 @@ static int imx258_probe(struct i2c_client *client) error_handler_free: imx258_free_controls(imx258); +error_identify: + imx258_power_off(&client->dev); + return ret; } @@ -1278,6 +1330,7 @@ static int imx258_remove(struct i2c_client *client) static const struct dev_pm_ops imx258_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(imx258_suspend, imx258_resume) + SET_RUNTIME_PM_OPS(imx258_power_off, imx258_power_on, NULL) }; #ifdef CONFIG_ACPI