From patchwork Sat Jan 1 18:27:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 529515 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7272C433EF for ; Sat, 1 Jan 2022 18:28:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232632AbiAAS2Q (ORCPT ); Sat, 1 Jan 2022 13:28:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230259AbiAAS2Q (ORCPT ); Sat, 1 Jan 2022 13:28:16 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8145C06173E; Sat, 1 Jan 2022 10:28:15 -0800 (PST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 03632DA1; Sat, 1 Jan 2022 19:28:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1641061693; bh=8HNqwyQBZrSAUREx3ZKUMsJ6GEjIA4WkM1zBeIzYArs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sP0ZDeUQJtjhrMnlIhh1VEW/XVwVhRbk8gZSYGdp9lFiLwuLDQXq1QErd+YRwp/Vf XIIGY4rudBIqZy/+akbsoThOtr0BPFiOSaz/dQKleErg/99uWckFSpWjpI5s1R+wTE KWTJmny6+MbZbpdCAjbH2D61jmmRmATeqrWAFKrY= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Kieran Bingham , =?utf-8?q?Niklas_S=C3=B6d?= =?utf-8?q?erlund?= , Thomas Nizan , Rob Herring , devicetree@vger.kernel.org, Mark Brown , Liam Girdwood Subject: [PATCH v2 01/11] dt-bindings: media: i2c: max9286: Add support for per-port supplies Date: Sat, 1 Jan 2022 20:27:56 +0200 Message-Id: <20220101182806.19311-2-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> References: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Power supplies for the ports can be controlled per port depending on the hardware design. Support per-port supplies in the DT bindings, mutually exclusive with the global supply. Signed-off-by: Laurent Pinchart Reviewed-by: Rob Herring --- Changes since v1: - Simplify mutual exclusion condition --- .../bindings/media/i2c/maxim,max9286.yaml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max9286.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max9286.yaml index 02f656e78700..c20557b52e45 100644 --- a/Documentation/devicetree/bindings/media/i2c/maxim,max9286.yaml +++ b/Documentation/devicetree/bindings/media/i2c/maxim,max9286.yaml @@ -39,7 +39,7 @@ properties: maxItems: 1 poc-supply: - description: Regulator providing Power over Coax to the cameras + description: Regulator providing Power over Coax to all the ports enable-gpios: description: GPIO connected to the \#PWDN pin with inverted polarity @@ -160,6 +160,10 @@ properties: additionalProperties: false +patternProperties: + "^port[0-3]-poc-supply$": + description: Regulator providing Power over Coax for a particular port + required: - compatible - reg @@ -167,6 +171,14 @@ required: - i2c-mux - gpio-controller +allOf: + - if: + required: + - poc-supply + then: + patternProperties: + "^port[0-3]-poc-supply$": false + additionalProperties: false examples: From patchwork Sat Jan 1 18:27:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 529595 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D91EC2BA80 for ; Sat, 1 Jan 2022 18:28:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232654AbiAAS2T (ORCPT ); Sat, 1 Jan 2022 13:28:19 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:41358 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232633AbiAAS2R (ORCPT ); Sat, 1 Jan 2022 13:28:17 -0500 Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F3858FC9; Sat, 1 Jan 2022 19:28:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1641061694; bh=o0tyhyzYWH47JWnsREc9KPEBXdX+IXo7x/GMJj2UNwM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OdYgFPK1TJ0AVjgZWEX31ERmVx1Vko9YqUHhhLupLJohGsLlTM0uu48xSpOrMlXjF fojKRCNUYmymJr+DIfLlf0KA3AFLplwN/nBxRy5WKon3kBLkjNvjKDom3r2nA7g6sU KWRJuo3IYfP3beeY3gS4yLJ9FKVTmXHrppJwZOx0= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Kieran Bingham , =?utf-8?q?Niklas_S=C3=B6d?= =?utf-8?q?erlund?= , Thomas Nizan , Rob Herring , devicetree@vger.kernel.org Subject: [PATCH v2 02/11] dt-bindings: media: i2c: max9286: Add property to select I2C speed Date: Sat, 1 Jan 2022 20:27:57 +0200 Message-Id: <20220101182806.19311-3-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> References: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The I2C speed on the remote side (the I2C master bus of the connected serializers) is configurable, and doesn't need to match the speed of the local bus (the slave bus of the MAX9286). All remote buses must use the same speed, and the MAX9286 needs to be programmed accordingly. Add a new DT property to select the speed to make it configurable. Signed-off-by: Laurent Pinchart --- .../devicetree/bindings/media/i2c/maxim,max9286.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max9286.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max9286.yaml index c20557b52e45..5d3e99027a79 100644 --- a/Documentation/devicetree/bindings/media/i2c/maxim,max9286.yaml +++ b/Documentation/devicetree/bindings/media/i2c/maxim,max9286.yaml @@ -50,6 +50,13 @@ properties: '#gpio-cells': const: 2 + maxim,i2c-clock-frequency: + enum: [ 8470, 28300, 84700, 105000, 173000, 339000, 533000, 837000 ] + default: 105000 + description: | + The I2C clock frequency for the remote I2C buses. The value must match + the configuration of the remote serializers. + maxim,reverse-channel-microvolt: minimum: 30000 maximum: 200000 From patchwork Sat Jan 1 18:27:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 529514 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A67EC433FE for ; Sat, 1 Jan 2022 18:28:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232645AbiAAS2S (ORCPT ); Sat, 1 Jan 2022 13:28:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232637AbiAAS2R (ORCPT ); Sat, 1 Jan 2022 13:28:17 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44094C061574; Sat, 1 Jan 2022 10:28:17 -0800 (PST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D772D1207; Sat, 1 Jan 2022 19:28:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1641061695; bh=7w127SGh0OEk4TSPY7jvDZ8OZMBkHZHIdByroOfok58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FpaHGhTmi83UGIdhEnndE7CXL5RSLpVO8YP9jHB55z1U7xGccpcXKPrcf3CUJ3lID Zhqzc9X1HZ8IA6d65MwSZ7ynouKLicF3ETOrMWK/aSL90t/v7NRFAUqm27yRhXyjdQ 3HA3fRw9llw2RHdhW7heCADQnQgMh0CeB4Dr3+ZE= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Kieran Bingham , =?utf-8?q?Niklas_S=C3=B6d?= =?utf-8?q?erlund?= , Thomas Nizan , Rob Herring , devicetree@vger.kernel.org Subject: [PATCH v2 03/11] dt-bindings: media: i2c: max9286: Add property to select bus width Date: Sat, 1 Jan 2022 20:27:58 +0200 Message-Id: <20220101182806.19311-4-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> References: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The GMSL serial data bus width is normally selected by the BWS pin, but it can also be configured by software. Add a DT property that allows overriding the value of the BWS-selected bus width to support systems whose BWS pin doesn't result in the correct value. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- .../devicetree/bindings/media/i2c/maxim,max9286.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max9286.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max9286.yaml index 5d3e99027a79..123e98cdb7b6 100644 --- a/Documentation/devicetree/bindings/media/i2c/maxim,max9286.yaml +++ b/Documentation/devicetree/bindings/media/i2c/maxim,max9286.yaml @@ -50,6 +50,13 @@ properties: '#gpio-cells': const: 2 + maxim,bus-width: + enum: [ 24, 27, 32 ] + description: | + The GMSL serial data bus width. This setting is normally controlled by + the BWS pin, but may be overridden with this property. The value must + match the configuration of the remote serializers. + maxim,i2c-clock-frequency: enum: [ 8470, 28300, 84700, 105000, 173000, 339000, 533000, 837000 ] default: 105000 From patchwork Sat Jan 1 18:27:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 529512 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5031C433EF for ; Sat, 1 Jan 2022 18:28:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232660AbiAAS2T (ORCPT ); Sat, 1 Jan 2022 13:28:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232650AbiAAS2T (ORCPT ); Sat, 1 Jan 2022 13:28:19 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BED8AC061574; Sat, 1 Jan 2022 10:28:18 -0800 (PST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B133E1540; Sat, 1 Jan 2022 19:28:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1641061696; bh=bQYUIcZSpusmxSxGxJjRaukEsY0BUnBNolRA68fd2TQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mSzo2EF0+BU8STmhKcQLVE2rC7/VsGDdH4is3EbgwMezZRNDx47i329GWSz7xbFsV gQfiS920ozZa7cH7+lQbis3UF1+UO0+MWOzOOE02RMITtLarJORliGcozY/FReqvZc BtwURHmisrboVhhG3f8at+R6cuHJfIlqwumrwTj8= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Kieran Bingham , =?utf-8?q?Niklas_S=C3=B6d?= =?utf-8?q?erlund?= , Thomas Nizan , Mark Brown , Liam Girdwood Subject: [PATCH v2 04/11] media: i2c: max9286: Add support for port regulators Date: Sat, 1 Jan 2022 20:27:59 +0200 Message-Id: <20220101182806.19311-5-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> References: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Thomas Nizan Allow users to use one PoC regulator per port, instead of a global regulator. The properties '^port[0-3]-poc-supply$' in the DT node are used to indicate the regulators for individual ports. Signed-off-by: Thomas Nizan Signed-off-by: Laurent Pinchart --- Changes since v1: - Use to_index() - Use dev_err_probe() - Fix error path in probe() - Use devm_regulator_get_optional() instead of devm_regulator_get_exclusive() --- drivers/media/i2c/max9286.c | 107 +++++++++++++++++++++++++++++++----- 1 file changed, 94 insertions(+), 13 deletions(-) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index eb2b8e42335b..15c80034e3a4 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -138,6 +138,7 @@ struct max9286_source { struct v4l2_subdev *sd; struct fwnode_handle *fwnode; + struct regulator *regulator; }; struct max9286_asd { @@ -1071,6 +1072,49 @@ static int max9286_register_gpio(struct max9286_priv *priv) return ret; } +static int max9286_poc_power_on(struct max9286_priv *priv) +{ + struct max9286_source *source; + unsigned int enabled = 0; + int ret; + + /* Enable the global regulator if available. */ + if (priv->regulator) + return regulator_enable(priv->regulator); + + /* Otherwise use the per-port regulators. */ + for_each_source(priv, source) { + ret = regulator_enable(source->regulator); + if (ret < 0) + goto error; + + enabled |= BIT(to_index(priv, source)); + } + + return 0; + +error: + for_each_source(priv, source) { + if (enabled & BIT(to_index(priv, source))) + regulator_disable(source->regulator); + } + + return ret; +} + +static void max9286_poc_power_off(struct max9286_priv *priv) +{ + struct max9286_source *source; + + if (priv->regulator) { + regulator_disable(priv->regulator); + return; + } + + for_each_source(priv, source) + regulator_disable(source->regulator); +} + static int max9286_init(struct device *dev) { struct max9286_priv *priv; @@ -1081,9 +1125,9 @@ static int max9286_init(struct device *dev) priv = i2c_get_clientdata(client); /* Enable the bus power. */ - ret = regulator_enable(priv->regulator); + ret = max9286_poc_power_on(priv); if (ret < 0) { - dev_err(&client->dev, "Unable to turn PoC on\n"); + dev_err(dev, "Unable to turn PoC on\n"); return ret; } @@ -1117,7 +1161,7 @@ static int max9286_init(struct device *dev) err_v4l2_register: max9286_v4l2_unregister(priv); err_regulator: - regulator_disable(priv->regulator); + max9286_poc_power_off(priv); return ret; } @@ -1248,6 +1292,47 @@ static int max9286_parse_dt(struct max9286_priv *priv) return 0; } +static int max9286_get_poc_supplies(struct max9286_priv *priv) +{ + struct device *dev = &priv->client->dev; + struct max9286_source *source; + int ret; + + /* Start by getting the global regulator. */ + priv->regulator = devm_regulator_get_optional(dev, "poc"); + if (!IS_ERR(priv->regulator)) + return 0; + + if (PTR_ERR(priv->regulator) != -ENODEV) { + if (PTR_ERR(priv->regulator) != -EPROBE_DEFER) + dev_err(dev, "Unable to get PoC regulator: %ld\n", + PTR_ERR(priv->regulator)); + return PTR_ERR(priv->regulator); + } + + /* If there's no global regulator, get per-port regulators. */ + dev_dbg(dev, + "No global PoC regulator, looking for per-port regulators\n"); + priv->regulator = NULL; + + for_each_source(priv, source) { + unsigned int index = to_index(priv, source); + char name[10]; + + snprintf(name, sizeof(name), "port%u-poc", index); + source->regulator = devm_regulator_get(dev, name); + if (IS_ERR(source->regulator)) { + ret = PTR_ERR(source->regulator); + dev_err_probe(dev, ret, + "Unable to get port %u PoC regulator\n", + index); + return ret; + } + } + + return 0; +} + static int max9286_probe(struct i2c_client *client) { struct max9286_priv *priv; @@ -1292,17 +1377,13 @@ static int max9286_probe(struct i2c_client *client) if (ret) goto err_powerdown; - priv->regulator = devm_regulator_get(&client->dev, "poc"); - if (IS_ERR(priv->regulator)) { - ret = PTR_ERR(priv->regulator); - dev_err_probe(&client->dev, ret, - "Unable to get PoC regulator\n"); - goto err_powerdown; - } - ret = max9286_parse_dt(priv); if (ret) - goto err_powerdown; + goto err_cleanup_dt; + + ret = max9286_get_poc_supplies(priv); + if (ret) + goto err_cleanup_dt; ret = max9286_init(&client->dev); if (ret < 0) @@ -1326,7 +1407,7 @@ static int max9286_remove(struct i2c_client *client) max9286_v4l2_unregister(priv); - regulator_disable(priv->regulator); + max9286_poc_power_off(priv); gpiod_set_value_cansleep(priv->gpiod_pwdn, 0); From patchwork Sat Jan 1 18:28:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 529513 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D5BFC46467 for ; Sat, 1 Jan 2022 18:28:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232657AbiAAS2T (ORCPT ); Sat, 1 Jan 2022 13:28:19 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:41358 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232644AbiAAS2S (ORCPT ); Sat, 1 Jan 2022 13:28:18 -0500 Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8BAF31C05; Sat, 1 Jan 2022 19:28:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1641061697; bh=sOpCj9w9HvlAvFT8NODOVxRC+SFPiWORlRc+hiWvmM0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BK993IaH5gyuXDZk01ZNoiedE4lf5d5M6N+J0zIAM46IGeUKRFisZT9gi9NT6geJO wDewub9jesJwxVIvCrqlDgTh+T5vt0H16mlY8bdorBE76U11ql7tan4KOvRtmMEqG0 R2IZ+WwJbiPyTEprCBz0VMyafz4zM/5qFdFfKm1Y= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Kieran Bingham , =?utf-8?q?Niklas_S=C3=B6d?= =?utf-8?q?erlund?= , Thomas Nizan Subject: [PATCH v2 05/11] media: i2c: max9286: Support manual framesync operation Date: Sat, 1 Jan 2022 20:28:00 +0200 Message-Id: <20220101182806.19311-6-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> References: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The MAX9286 can generate a framesync signal to synchronize the cameras, using an internal timer. Support this mode of operation and configure it through the .s_frameinterval() operation. If the frame interval is not 0, framesync is switched to manual mode with the specified interval, otherwise automatic mode is used. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- Changes since v1: - Use pixel rate to calculate frame sync counter --- drivers/media/i2c/max9286.c | 84 +++++++++++++++++++++++++++++++++---- 1 file changed, 75 insertions(+), 9 deletions(-) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index 15c80034e3a4..75374034724f 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -170,9 +170,11 @@ struct max9286_priv { u32 rev_chan_mv; struct v4l2_ctrl_handler ctrls; - struct v4l2_ctrl *pixelrate; + struct v4l2_ctrl *pixelrate_ctrl; + unsigned int pixelrate; struct v4l2_mbus_framefmt fmt[MAX9286_N_SINKS]; + struct v4l2_fract interval; /* Protects controls and fmt structures */ struct mutex mutex; @@ -473,6 +475,40 @@ static int max9286_check_config_link(struct max9286_priv *priv, return 0; } +static void max9286_set_fsync_period(struct max9286_priv *priv) +{ + u32 fsync; + + if (!priv->interval.numerator || !priv->interval.denominator) { + /* + * Special case, a null interval enables automatic FRAMESYNC + * mode. FRAMESYNC is taken from the slowest link. + */ + max9286_write(priv, 0x01, MAX9286_FSYNCMODE_INT_HIZ | + MAX9286_FSYNCMETH_AUTO); + return; + } + + /* + * Manual FRAMESYNC + * + * The FRAMESYNC generator is configured with a period expressed as a + * number of PCLK periods. + */ + fsync = div_u64((u64)priv->pixelrate * priv->interval.numerator, + priv->interval.denominator); + + dev_dbg(&priv->client->dev, "fsync period %u (pclk %u)\n", fsync, + priv->pixelrate); + + max9286_write(priv, 0x01, MAX9286_FSYNCMODE_INT_OUT | + MAX9286_FSYNCMETH_MANUAL); + + max9286_write(priv, 0x06, (fsync >> 0) & 0xff); + max9286_write(priv, 0x07, (fsync >> 8) & 0xff); + max9286_write(priv, 0x08, (fsync >> 16) & 0xff); +} + /* ----------------------------------------------------------------------------- * V4L2 Subdev */ @@ -511,11 +547,13 @@ static int max9286_set_pixelrate(struct max9286_priv *priv) return -EINVAL; } + priv->pixelrate = pixelrate; + /* * The CSI-2 transmitter pixel rate is the single source rate multiplied * by the number of available sources. */ - return v4l2_ctrl_s_ctrl_int64(priv->pixelrate, + return v4l2_ctrl_s_ctrl_int64(priv->pixelrate_ctrl, pixelrate * priv->nsources); } @@ -655,6 +693,8 @@ static int max9286_s_stream(struct v4l2_subdev *sd, int enable) int ret; if (enable) { + max9286_set_fsync_period(priv); + /* * The frame sync between cameras is transmitted across the * reverse channel as GPIO. We must open all channels while @@ -714,6 +754,32 @@ static int max9286_s_stream(struct v4l2_subdev *sd, int enable) return 0; } +static int max9286_g_frame_interval(struct v4l2_subdev *sd, + struct v4l2_subdev_frame_interval *interval) +{ + struct max9286_priv *priv = sd_to_max9286(sd); + + if (interval->pad != MAX9286_SRC_PAD) + return -EINVAL; + + interval->interval = priv->interval; + + return 0; +} + +static int max9286_s_frame_interval(struct v4l2_subdev *sd, + struct v4l2_subdev_frame_interval *interval) +{ + struct max9286_priv *priv = sd_to_max9286(sd); + + if (interval->pad != MAX9286_SRC_PAD) + return -EINVAL; + + priv->interval = interval->interval; + + return 0; +} + static int max9286_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_mbus_code_enum *code) @@ -805,6 +871,8 @@ static int max9286_get_fmt(struct v4l2_subdev *sd, static const struct v4l2_subdev_video_ops max9286_video_ops = { .s_stream = max9286_s_stream, + .g_frame_interval = max9286_g_frame_interval, + .s_frame_interval = max9286_s_frame_interval, }; static const struct v4l2_subdev_pad_ops max9286_pad_ops = { @@ -885,10 +953,10 @@ static int max9286_v4l2_register(struct max9286_priv *priv) priv->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; v4l2_ctrl_handler_init(&priv->ctrls, 1); - priv->pixelrate = v4l2_ctrl_new_std(&priv->ctrls, - &max9286_ctrl_ops, - V4L2_CID_PIXEL_RATE, - 1, INT_MAX, 1, 50000000); + priv->pixelrate_ctrl = v4l2_ctrl_new_std(&priv->ctrls, + &max9286_ctrl_ops, + V4L2_CID_PIXEL_RATE, + 1, INT_MAX, 1, 50000000); priv->sd.ctrl_handler = &priv->ctrls; ret = priv->ctrls.error; @@ -997,9 +1065,7 @@ static int max9286_setup(struct max9286_priv *priv) MAX9286_CSILANECNT(priv->csi2_data_lanes) | MAX9286_DATATYPE_YUV422_8BIT); - /* Automatic: FRAMESYNC taken from the slowest Link. */ - max9286_write(priv, 0x01, MAX9286_FSYNCMODE_INT_HIZ | - MAX9286_FSYNCMETH_AUTO); + max9286_set_fsync_period(priv); /* Enable HS/VS encoding, use D14/15 for HS/VS, invert VS. */ max9286_write(priv, 0x0c, MAX9286_HVEN | MAX9286_INVVS | From patchwork Sat Jan 1 18:28:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 529594 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D16DC433F5 for ; Sat, 1 Jan 2022 18:28:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232661AbiAAS2U (ORCPT ); Sat, 1 Jan 2022 13:28:20 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:41358 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232656AbiAAS2T (ORCPT ); Sat, 1 Jan 2022 13:28:19 -0500 Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4CA911C1C; Sat, 1 Jan 2022 19:28:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1641061697; bh=NzGbThJbHkTNGb9Y2RvNhqGx9XtHQ2R8epxt9n2Crvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oOFk0/XjblFZivuHYLiJarWeR6LaItasEz79EgpuFsWaO6RGwxw6himFuA41DXpls QbI0i2VQclLX1ZHm0GhMWMkW00rUQG2U1DuibeP6opLDQQwvtJklYkyANWR9tJ0lDy 5ifOyfiphUJEKtebT3IbjOnnljdeOmQA/IM5Gpko= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Kieran Bingham , =?utf-8?q?Niklas_S=C3=B6d?= =?utf-8?q?erlund?= , Thomas Nizan Subject: [PATCH v2 06/11] media: i2c: max9286: Rename MAX9286_DATATYPE_RAW11 to RAW12 Date: Sat, 1 Jan 2022 20:28:01 +0200 Message-Id: <20220101182806.19311-7-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> References: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The MAX9286_DATATYPE_RAW11 value is used to configure the MAX9286 for 11-bit or 12-bit input data. While 11-bit data is supported on the GMSL side, CSI-2 doesn't have a RAW11 format. 11-bit data is transferred over CSI-2 as RAW12. Rename the macro accordingly to avoid confusion. Signed-off-by: Laurent Pinchart --- drivers/media/i2c/max9286.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index 75374034724f..576d9c6fac14 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -71,7 +71,7 @@ #define MAX9286_DATATYPE_USER_YUV_12BIT (10 << 0) #define MAX9286_DATATYPE_USER_24BIT (9 << 0) #define MAX9286_DATATYPE_RAW14 (8 << 0) -#define MAX9286_DATATYPE_RAW11 (7 << 0) +#define MAX9286_DATATYPE_RAW12 (7 << 0) #define MAX9286_DATATYPE_RAW10 (6 << 0) #define MAX9286_DATATYPE_RAW8 (5 << 0) #define MAX9286_DATATYPE_YUV422_10BIT (4 << 0) From patchwork Sat Jan 1 18:28:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 529511 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BD44C43219 for ; Sat, 1 Jan 2022 18:28:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232672AbiAAS2V (ORCPT ); Sat, 1 Jan 2022 13:28:21 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:41396 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232658AbiAAS2U (ORCPT ); Sat, 1 Jan 2022 13:28:20 -0500 Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0A96E1C5E; Sat, 1 Jan 2022 19:28:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1641061698; bh=trtYcqAKlXV6jQdXdc/doblYIyAt6w0iUvs0fkACAZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lwxlRbUmgctokRwYK/Wvos0KSZslN/O147EgeXfKr/T28EIpw9mbzASq3LIeBa4ft L3duPkM/pHmOE9VC0A5zi/qum9P60Yj+4kf82EjJVCQ+Bp5YyN8mfpElt1EHusdkyP Izu/KNG359ypshu+MHtNBgRUAwzl5B2hy1gzcK5I= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Kieran Bingham , =?utf-8?q?Niklas_S=C3=B6d?= =?utf-8?q?erlund?= , Thomas Nizan Subject: [PATCH v2 07/11] media: i2c: max9286: Support 12-bit raw bayer formats Date: Sat, 1 Jan 2022 20:28:02 +0200 Message-Id: <20220101182806.19311-8-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> References: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add support for 12-bit raw bayer formats to the driver, configuring the GMSL format accordingly. Signed-off-by: Laurent Pinchart --- drivers/media/i2c/max9286.c | 128 ++++++++++++++++++++++++++---------- 1 file changed, 95 insertions(+), 33 deletions(-) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index 576d9c6fac14..24c2bf4fda53 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -135,6 +135,11 @@ #define MAX9286_N_PADS 5 #define MAX9286_SRC_PAD 4 +struct max9286_format_info { + u32 code; + u8 datatype; +}; + struct max9286_source { struct v4l2_subdev *sd; struct fwnode_handle *fwnode; @@ -214,6 +219,34 @@ static inline struct max9286_priv *sd_to_max9286(struct v4l2_subdev *sd) return container_of(sd, struct max9286_priv, sd); } +static const struct max9286_format_info max9286_formats[] = { + { + .code = MEDIA_BUS_FMT_UYVY8_1X16, + .datatype = MAX9286_DATATYPE_YUV422_8BIT, + }, { + .code = MEDIA_BUS_FMT_VYUY8_1X16, + .datatype = MAX9286_DATATYPE_YUV422_8BIT, + }, { + .code = MEDIA_BUS_FMT_YUYV8_1X16, + .datatype = MAX9286_DATATYPE_YUV422_8BIT, + }, { + .code = MEDIA_BUS_FMT_YVYU8_1X16, + .datatype = MAX9286_DATATYPE_YUV422_8BIT, + }, { + .code = MEDIA_BUS_FMT_SBGGR12_1X12, + .datatype = MAX9286_DATATYPE_RAW12, + }, { + .code = MEDIA_BUS_FMT_SGBRG12_1X12, + .datatype = MAX9286_DATATYPE_RAW12, + }, { + .code = MEDIA_BUS_FMT_SGRBG12_1X12, + .datatype = MAX9286_DATATYPE_RAW12, + }, { + .code = MEDIA_BUS_FMT_SRGGB12_1X12, + .datatype = MAX9286_DATATYPE_RAW12, + }, +}; + /* ----------------------------------------------------------------------------- * I2C IO */ @@ -475,6 +508,38 @@ static int max9286_check_config_link(struct max9286_priv *priv, return 0; } +static void max9286_set_video_format(struct max9286_priv *priv, + const struct v4l2_mbus_framefmt *format) +{ + const struct max9286_format_info *info = NULL; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(max9286_formats); ++i) { + if (max9286_formats[i].code == format->code) { + info = &max9286_formats[i]; + break; + } + } + + if (WARN_ON(!info)) + return; + + /* + * Video format setup: + * Disable CSI output, VC is set according to Link number. + */ + max9286_write(priv, 0x15, MAX9286_VCTYPE | MAX9286_0X15_RESV); + + /* Enable CSI-2 Lane D0-D3 only, DBL mode. */ + max9286_write(priv, 0x12, MAX9286_CSIDBL | MAX9286_DBL | + MAX9286_CSILANECNT(priv->csi2_data_lanes) | + info->datatype); + + /* Enable HS/VS encoding, use D14/15 for HS/VS, invert VS. */ + max9286_write(priv, 0x0c, MAX9286_HVEN | MAX9286_INVVS | + MAX9286_HVSRC_D14); +} + static void max9286_set_fsync_period(struct max9286_priv *priv) { u32 fsync; @@ -693,6 +758,15 @@ static int max9286_s_stream(struct v4l2_subdev *sd, int enable) int ret; if (enable) { + const struct v4l2_mbus_framefmt *format; + + /* + * Get the format from the first used sink pad, as all sink + * formats must be identical. + */ + format = &priv->fmt[__ffs(priv->bound_sources)]; + + max9286_set_video_format(priv, format); max9286_set_fsync_period(priv); /* @@ -813,22 +887,20 @@ static int max9286_set_fmt(struct v4l2_subdev *sd, { struct max9286_priv *priv = sd_to_max9286(sd); struct v4l2_mbus_framefmt *cfg_fmt; + unsigned int i; if (format->pad == MAX9286_SRC_PAD) return -EINVAL; - /* Refuse non YUV422 formats as we hardcode DT to 8 bit YUV422 */ - switch (format->format.code) { - case MEDIA_BUS_FMT_UYVY8_1X16: - case MEDIA_BUS_FMT_VYUY8_1X16: - case MEDIA_BUS_FMT_YUYV8_1X16: - case MEDIA_BUS_FMT_YVYU8_1X16: - break; - default: - format->format.code = MEDIA_BUS_FMT_UYVY8_1X16; - break; + /* Validate the format. */ + for (i = 0; i < ARRAY_SIZE(max9286_formats); ++i) { + if (max9286_formats[i].code == format->format.code) + break; } + if (i == ARRAY_SIZE(max9286_formats)) + format->format.code = max9286_formats[i].code; + cfg_fmt = max9286_get_pad_format(priv, sd_state, format->pad, format->which); if (!cfg_fmt) @@ -886,16 +958,20 @@ static const struct v4l2_subdev_ops max9286_subdev_ops = { .pad = &max9286_pad_ops, }; +static const struct v4l2_mbus_framefmt max9286_default_format = { + .width = 1280, + .height = 800, + .code = MEDIA_BUS_FMT_UYVY8_1X16, + .colorspace = V4L2_COLORSPACE_SRGB, + .field = V4L2_FIELD_NONE, + .ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT, + .quantization = V4L2_QUANTIZATION_DEFAULT, + .xfer_func = V4L2_XFER_FUNC_DEFAULT, +}; + static void max9286_init_format(struct v4l2_mbus_framefmt *fmt) { - fmt->width = 1280; - fmt->height = 800; - fmt->code = MEDIA_BUS_FMT_UYVY8_1X16; - fmt->colorspace = V4L2_COLORSPACE_SRGB; - fmt->field = V4L2_FIELD_NONE; - fmt->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; - fmt->quantization = V4L2_QUANTIZATION_DEFAULT; - fmt->xfer_func = V4L2_XFER_FUNC_DEFAULT; + *fmt = max9286_default_format; } static int max9286_open(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh) @@ -1054,23 +1130,9 @@ static int max9286_setup(struct max9286_priv *priv) max9286_write(priv, 0x0b, link_order[priv->route_mask]); max9286_write(priv, 0x69, (0xf & ~priv->route_mask)); - /* - * Video format setup: - * Disable CSI output, VC is set according to Link number. - */ - max9286_write(priv, 0x15, MAX9286_VCTYPE | MAX9286_0X15_RESV); - - /* Enable CSI-2 Lane D0-D3 only, DBL mode, YUV422 8-bit. */ - max9286_write(priv, 0x12, MAX9286_CSIDBL | MAX9286_DBL | - MAX9286_CSILANECNT(priv->csi2_data_lanes) | - MAX9286_DATATYPE_YUV422_8BIT); - + max9286_set_video_format(priv, &max9286_default_format); max9286_set_fsync_period(priv); - /* Enable HS/VS encoding, use D14/15 for HS/VS, invert VS. */ - max9286_write(priv, 0x0c, MAX9286_HVEN | MAX9286_INVVS | - MAX9286_HVSRC_D14); - /* * The overlap window seems to provide additional validation by tracking * the delay between vsync and frame sync, generating an error if the From patchwork Sat Jan 1 18:28:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 529593 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73B0BC35268 for ; Sat, 1 Jan 2022 18:28:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232676AbiAAS2V (ORCPT ); Sat, 1 Jan 2022 13:28:21 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:41358 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232644AbiAAS2U (ORCPT ); Sat, 1 Jan 2022 13:28:20 -0500 Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B86E41C2A; Sat, 1 Jan 2022 19:28:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1641061699; bh=JY2EI5SBxo1VKLIWuKjo2aA/oopc8B5/4cdYuD3mU24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PKHks2BfGo5mYm2FR+fqLDL7jvVx+r8m+VKCbWdnd39C82ko8tVVRMJoIlS2HIdht a8T8he/FPQ9TZKk4TzxDJ/oFV4SejeCkk9/2GQW8vJj7nFQJoBvlURGfItFYBZskgk lsH61min2v4cJjEvOTRolxh9ONPBOuqJbYUWMJ9w= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Kieran Bingham , =?utf-8?q?Niklas_S=C3=B6d?= =?utf-8?q?erlund?= , Thomas Nizan Subject: [PATCH v2 08/11] media: i2c: max9286: Define macros for all bits of register 0x15 Date: Sat, 1 Jan 2022 20:28:03 +0200 Message-Id: <20220101182806.19311-9-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> References: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Macros are easier to read than numerical values. Signed-off-by: Laurent Pinchart --- drivers/media/i2c/max9286.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index 24c2bf4fda53..4b69bd036ca6 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -80,10 +80,13 @@ #define MAX9286_DATATYPE_RGB565 (1 << 0) #define MAX9286_DATATYPE_RGB888 (0 << 0) /* Register 0x15 */ +#define MAX9286_CSI_IMAGE_TYP BIT(7) #define MAX9286_VC(n) ((n) << 5) #define MAX9286_VCTYPE BIT(4) #define MAX9286_CSIOUTEN BIT(3) -#define MAX9286_0X15_RESV (3 << 0) +#define MAX9286_SWP_ENDIAN BIT(2) +#define MAX9286_EN_CCBSYB_CLK_STR BIT(1) +#define MAX9286_EN_GPI_CCBSYB BIT(0) /* Register 0x1b */ #define MAX9286_SWITCHIN(n) (1 << ((n) + 4)) #define MAX9286_ENEQ(n) (1 << (n)) @@ -525,10 +528,12 @@ static void max9286_set_video_format(struct max9286_priv *priv, return; /* - * Video format setup: - * Disable CSI output, VC is set according to Link number. + * Video format setup: disable CSI output, set VC according to Link + * number, enable I2C clock stretching when CCBSY is low, enable CCBSY + * in external GPI-to-GPO mode. */ - max9286_write(priv, 0x15, MAX9286_VCTYPE | MAX9286_0X15_RESV); + max9286_write(priv, 0x15, MAX9286_VCTYPE | MAX9286_EN_CCBSYB_CLK_STR | + MAX9286_EN_GPI_CCBSYB); /* Enable CSI-2 Lane D0-D3 only, DBL mode. */ max9286_write(priv, 0x12, MAX9286_CSIDBL | MAX9286_DBL | @@ -810,13 +815,17 @@ static int max9286_s_stream(struct v4l2_subdev *sd, int enable) } /* - * Enable CSI output, VC set according to link number. - * Bit 7 must be set (chip manual says it's 0 and reserved). + * Configure the CSI-2 output to line interleaved mode (W x (N + * x H), as opposed to the (N x W) x H mode that outputs the + * images stitched side-by-side) and enable it. */ - max9286_write(priv, 0x15, 0x80 | MAX9286_VCTYPE | - MAX9286_CSIOUTEN | MAX9286_0X15_RESV); + max9286_write(priv, 0x15, MAX9286_CSI_IMAGE_TYP | MAX9286_VCTYPE | + MAX9286_CSIOUTEN | MAX9286_EN_CCBSYB_CLK_STR | + MAX9286_EN_GPI_CCBSYB); } else { - max9286_write(priv, 0x15, MAX9286_VCTYPE | MAX9286_0X15_RESV); + max9286_write(priv, 0x15, MAX9286_VCTYPE | + MAX9286_EN_CCBSYB_CLK_STR | + MAX9286_EN_GPI_CCBSYB); /* Stop all cameras. */ for_each_source(priv, source) From patchwork Sat Jan 1 18:28:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 529592 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E5EFC4321E for ; Sat, 1 Jan 2022 18:28:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232664AbiAAS2W (ORCPT ); Sat, 1 Jan 2022 13:28:22 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:41396 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232662AbiAAS2V (ORCPT ); Sat, 1 Jan 2022 13:28:21 -0500 Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 733671C05; Sat, 1 Jan 2022 19:28:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1641061700; bh=IjEZByg+EYOjp53P6k2Hf4M2XaAnkA1LCq9LArT6bac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dINaZ6xqNw9FJZ2LW9C3wBM9BZOLkcVygwCK09qm2+Mzz79RtcSmg6bH3VtM99D7I I9ZCDo+VQQyvCUWal4+BLLxgdcR0Lz0MAgc16gfqEw1zeki4PSSvQ4jVMHDANxpzks UGavg515ASneek2d/j7vMcbeUN0KKyNHd95ExdJE= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Kieran Bingham , =?utf-8?q?Niklas_S=C3=B6d?= =?utf-8?q?erlund?= , Thomas Nizan Subject: [PATCH v2 09/11] media: i2c: max9286: Configure remote I2C speed from device tree Date: Sat, 1 Jan 2022 20:28:04 +0200 Message-Id: <20220101182806.19311-10-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> References: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Read the maxim,i2c-clock-frequency DT property that specifies the speed of the remote I2C bus, and configure the MAX9286 accordingly. The remote serializers must all have a matching configuration. Signed-off-by: Laurent Pinchart --- drivers/media/i2c/max9286.c | 56 +++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index 4b69bd036ca6..d88a4d8e63ab 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -143,6 +143,11 @@ struct max9286_format_info { u8 datatype; }; +struct max9286_i2c_speed { + u32 rate; + u8 mstbt; +}; + struct max9286_source { struct v4l2_subdev *sd; struct fwnode_handle *fwnode; @@ -176,6 +181,7 @@ struct max9286_priv { /* The initial reverse control channel amplitude. */ u32 init_rev_chan_mv; u32 rev_chan_mv; + u8 i2c_mstbt; struct v4l2_ctrl_handler ctrls; struct v4l2_ctrl *pixelrate_ctrl; @@ -250,6 +256,17 @@ static const struct max9286_format_info max9286_formats[] = { }, }; +static const struct max9286_i2c_speed max9286_i2c_speeds[] = { + { .rate = 8470, .mstbt = MAX9286_I2CMSTBT_8KBPS }, + { .rate = 28300, .mstbt = MAX9286_I2CMSTBT_28KBPS }, + { .rate = 84700, .mstbt = MAX9286_I2CMSTBT_84KBPS }, + { .rate = 105000, .mstbt = MAX9286_I2CMSTBT_105KBPS }, + { .rate = 173000, .mstbt = MAX9286_I2CMSTBT_173KBPS }, + { .rate = 339000, .mstbt = MAX9286_I2CMSTBT_339KBPS }, + { .rate = 533000, .mstbt = MAX9286_I2CMSTBT_533KBPS }, + { .rate = 837000, .mstbt = MAX9286_I2CMSTBT_837KBPS }, +}; + /* ----------------------------------------------------------------------------- * I2C IO */ @@ -370,7 +387,7 @@ static int max9286_i2c_mux_init(struct max9286_priv *priv) static void max9286_configure_i2c(struct max9286_priv *priv, bool localack) { u8 config = MAX9286_I2CSLVSH_469NS_234NS | MAX9286_I2CSLVTO_1024US | - MAX9286_I2CMSTBT_105KBPS; + priv->i2c_mstbt; if (localack) config |= MAX9286_I2CLOCACK; @@ -1320,6 +1337,8 @@ static int max9286_parse_dt(struct max9286_priv *priv) struct device_node *node = NULL; unsigned int i2c_mux_mask = 0; u32 reverse_channel_microvolt; + u32 i2c_clk_freq = 105000; + unsigned int i; /* Balance the of_node_put() performed by of_find_node_by_name(). */ of_node_get(dev->of_node); @@ -1410,6 +1429,23 @@ static int max9286_parse_dt(struct max9286_priv *priv) } of_node_put(node); + of_property_read_u32(dev->of_node, "maxim,i2c-clock-frequency", + &i2c_clk_freq); + for (i = 0; i < ARRAY_SIZE(max9286_i2c_speeds); ++i) { + const struct max9286_i2c_speed *speed = &max9286_i2c_speeds[i]; + + if (speed->rate == i2c_clk_freq) { + priv->i2c_mstbt = speed->mstbt; + break; + } + } + + if (i == ARRAY_SIZE(max9286_i2c_speeds)) { + dev_err(dev, "Invalid %s value %u\n", + "maxim,i2c-clock-frequency", i2c_clk_freq); + return -EINVAL; + } + /* * Parse the initial value of the reverse channel amplitude from * the firmware interface and convert it to millivolts. @@ -1484,10 +1520,16 @@ static int max9286_probe(struct i2c_client *client) priv->client = client; i2c_set_clientdata(client, priv); + ret = max9286_parse_dt(priv); + if (ret) + goto err_cleanup_dt; + priv->gpiod_pwdn = devm_gpiod_get_optional(&client->dev, "enable", GPIOD_OUT_HIGH); - if (IS_ERR(priv->gpiod_pwdn)) - return PTR_ERR(priv->gpiod_pwdn); + if (IS_ERR(priv->gpiod_pwdn)) { + ret = PTR_ERR(priv->gpiod_pwdn); + goto err_cleanup_dt; + } gpiod_set_consumer_name(priv->gpiod_pwdn, "max9286-pwdn"); gpiod_set_value_cansleep(priv->gpiod_pwdn, 1); @@ -1514,10 +1556,6 @@ static int max9286_probe(struct i2c_client *client) if (ret) goto err_powerdown; - ret = max9286_parse_dt(priv); - if (ret) - goto err_cleanup_dt; - ret = max9286_get_poc_supplies(priv); if (ret) goto err_cleanup_dt; @@ -1528,10 +1566,10 @@ static int max9286_probe(struct i2c_client *client) return 0; -err_cleanup_dt: - max9286_cleanup_dt(priv); err_powerdown: gpiod_set_value_cansleep(priv->gpiod_pwdn, 0); +err_cleanup_dt: + max9286_cleanup_dt(priv); return ret; } From patchwork Sat Jan 1 18:28:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 529510 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D325C4167D for ; Sat, 1 Jan 2022 18:28:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232681AbiAAS2X (ORCPT ); Sat, 1 Jan 2022 13:28:23 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:41358 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232673AbiAAS2V (ORCPT ); Sat, 1 Jan 2022 13:28:21 -0500 Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 45BD923CD; Sat, 1 Jan 2022 19:28:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1641061700; bh=dnGR1bEHDZqk4iWfFd2fMzIUpx2RL/NdzunIMoofj0Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RNcwjfYLqJrKn93pPTdDtnujmNOrLf5l+qS856tBHqQQLWnEfNB4BzA8P1l5wtGcA mJrDENPAjhGedTHEA0ibYQRswyGN8bD+9gZxPI2zrwgBWngqeL7GVVu+VwU+3C1DPs 0Uhk6jFx8qdcZSxkbPJcJ5i3pPn5w6OP1CWo1gF4= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Kieran Bingham , =?utf-8?q?Niklas_S=C3=B6d?= =?utf-8?q?erlund?= , Thomas Nizan Subject: [PATCH v2 10/11] media: i2c: max9286: Configure bus width from device tree Date: Sat, 1 Jan 2022 20:28:05 +0200 Message-Id: <20220101182806.19311-11-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> References: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The GMSL serial data bus width is normally selected through the BWS pin. On some systems, the pin may not be wired to the correct value. Support overriding the bus width by software, using the value specified in the device tree. Signed-off-by: Laurent Pinchart --- drivers/media/i2c/max9286.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index d88a4d8e63ab..07ebb01640a1 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -90,6 +90,11 @@ /* Register 0x1b */ #define MAX9286_SWITCHIN(n) (1 << ((n) + 4)) #define MAX9286_ENEQ(n) (1 << (n)) +/* Register 0x1c */ +#define MAX9286_HIGHIMM(n) BIT((n) + 4) +#define MAX9286_I2CSEL BIT(2) +#define MAX9286_HIBW BIT(1) +#define MAX9286_BWS BIT(0) /* Register 0x27 */ #define MAX9286_LOCKED BIT(7) /* Register 0x31 */ @@ -182,6 +187,7 @@ struct max9286_priv { u32 init_rev_chan_mv; u32 rev_chan_mv; u8 i2c_mstbt; + u32 bus_width; struct v4l2_ctrl_handler ctrls; struct v4l2_ctrl *pixelrate_ctrl; @@ -1159,6 +1165,23 @@ static int max9286_setup(struct max9286_priv *priv) max9286_set_video_format(priv, &max9286_default_format); max9286_set_fsync_period(priv); + if (priv->bus_width) { + int val; + + val = max9286_read(priv, 0x1c); + if (val < 0) + return val; + + val &= ~(MAX9286_HIBW | MAX9286_BWS); + + if (priv->bus_width == 27) + val |= MAX9286_HIBW; + else if (priv->bus_width == 32) + val |= MAX9286_BWS; + + max9286_write(priv, 0x1c, val); + } + /* * The overlap window seems to provide additional validation by tracking * the delay between vsync and frame sync, generating an error if the @@ -1429,6 +1452,19 @@ static int max9286_parse_dt(struct max9286_priv *priv) } of_node_put(node); + of_property_read_u32(dev->of_node, "maxim,bus-width", &priv->bus_width); + switch (priv->bus_width) { + case 0: + case 24: + case 27: + case 32: + break; + default: + dev_err(dev, "Invalid %s value %u\n", "maxim,bus-width", + priv->bus_width); + return -EINVAL; + } + of_property_read_u32(dev->of_node, "maxim,i2c-clock-frequency", &i2c_clk_freq); for (i = 0; i < ARRAY_SIZE(max9286_i2c_speeds); ++i) { From patchwork Sat Jan 1 18:28:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 529591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEB24C4332F for ; Sat, 1 Jan 2022 18:28:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232677AbiAAS2Y (ORCPT ); Sat, 1 Jan 2022 13:28:24 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:41396 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232663AbiAAS2W (ORCPT ); Sat, 1 Jan 2022 13:28:22 -0500 Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 083041C5E; Sat, 1 Jan 2022 19:28:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1641061701; bh=cC05pikczMfCTTejBalLAeTBNCIgo7s5Ewq7sBic6co=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RlMDieVDtUBbeIj/ElXRXtut9fZhpj1eBDyS8t1afgEQUkZXqK0OAmBk3Qiwa/Ar+ bcn/yoEsMnlN3UdWFfD6H6XUiLWHh4dfFGP5fzba/Zlmq6kR+QD6nJAlwE++AFHT4j IAzChoTwBJdgSV9zHc2Sok7xkBWdueljuj5SFbSQ= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Kieran Bingham , =?utf-8?q?Niklas_S=C3=B6d?= =?utf-8?q?erlund?= , Thomas Nizan Subject: [PATCH v2 11/11] media: i2c: max9286: Select HS as data enable signal Date: Sat, 1 Jan 2022 20:28:06 +0200 Message-Id: <20220101182806.19311-12-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> References: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org GMSL can transport three synchronization signals: VSync, HSync and Data Enable. The MAX9286 can select either HS or DE as a line valid signal. Not all serializers (and transmission formats) support the DE signal. The MAX9271, used by the RDACM20 and RDACM21 cameras, doesn't document DE support. Nonetheless, the max9286 driver selects the DE signal as line valid in register 0x0c (by not setting the DESEL bit). It's not clear why this works. As HS is a more common line valid qualifier, set the DESEL bit by default. This is needed to support the onsemi MARS cameras. If a camera requires usage of the DE signal in the future, this will need to be made configurable. Signed-off-by: Laurent Pinchart Tested-by: Jacopo Mondi Reviewed-by: Jacopo Mondi --- drivers/media/i2c/max9286.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index 07ebb01640a1..446fc238d642 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -563,9 +563,12 @@ static void max9286_set_video_format(struct max9286_priv *priv, MAX9286_CSILANECNT(priv->csi2_data_lanes) | info->datatype); - /* Enable HS/VS encoding, use D14/15 for HS/VS, invert VS. */ - max9286_write(priv, 0x0c, MAX9286_HVEN | MAX9286_INVVS | - MAX9286_HVSRC_D14); + /* + * Enable HS/VS encoding, use HS as line valid source, use D14/15 for + * HS/VS, invert VS. + */ + max9286_write(priv, 0x0c, MAX9286_HVEN | MAX9286_DESEL | + MAX9286_INVVS | MAX9286_HVSRC_D14); } static void max9286_set_fsync_period(struct max9286_priv *priv) From patchwork Sat Jan 1 23:26:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 529508 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED849C433F5 for ; Sat, 1 Jan 2022 23:26:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232770AbiAAX0q (ORCPT ); Sat, 1 Jan 2022 18:26:46 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:42772 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232731AbiAAX0p (ORCPT ); Sat, 1 Jan 2022 18:26:45 -0500 Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C6B4ECC; Sun, 2 Jan 2022 00:26:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1641079604; bh=JhDsZtKrxBpxD0eT0NwG04iESg/HP1kho30u6fGWlO4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RVoMZSafmdIpATu8VmLDzEWRkvly8/6Lrfnt0Sc1AI0rYgihypZ6EYa8jOJ8SZ9e+ KomMa43nIaqUwcOsRJCTYTTbOL4M6jAn0/Yvje/6NNouGUzRknXpMV4OJspE1ZtqhU miTxLOPmaXOKepR2ckPX8/vUPynqJu12hpqgjokw= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Kieran Bingham , =?utf-8?q?Niklas_?= =?utf-8?q?S=C3=B6derlund?= , Thomas Nizan Subject: [PATCH v2 12/11] media: i2c: max9286: Print power-up GMSL link configuration Date: Sun, 2 Jan 2022 01:26:37 +0200 Message-Id: <20220101232637.32104-1-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> References: <20220101182806.19311-1-laurent.pinchart+renesas@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The power-up GMSL link configuration is controlled by the HIM and BWS pins, whose state is reflected in register 0x1c. Print the detected power-up config in a debug message to help debugging. Signed-off-by: Laurent Pinchart --- drivers/media/i2c/max9286.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index 446fc238d642..f7cbfdde436e 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -1147,6 +1147,7 @@ static int max9286_setup(struct max9286_priv *priv) (2 << 6) | (1 << 4) | (0 << 2) | (3 << 0), /* 210x */ (3 << 6) | (2 << 4) | (1 << 2) | (0 << 0), /* 3210 */ }; + int cfg; /* * Set the I2C bus speed. @@ -1168,21 +1169,23 @@ static int max9286_setup(struct max9286_priv *priv) max9286_set_video_format(priv, &max9286_default_format); max9286_set_fsync_period(priv); + cfg = max9286_read(priv, 0x1c); + if (cfg < 0) + return cfg; + + dev_dbg(&priv->client->dev, "power-up config: %s immunity, %u-bit bus\n", + cfg & MAX9286_HIGHIMM(0) ? "high" : "legacy", + cfg & MAX9286_BWS ? 32 : cfg & MAX9286_HIBW ? 27 : 24); + if (priv->bus_width) { - int val; - - val = max9286_read(priv, 0x1c); - if (val < 0) - return val; - - val &= ~(MAX9286_HIBW | MAX9286_BWS); + cfg &= ~(MAX9286_HIBW | MAX9286_BWS); if (priv->bus_width == 27) - val |= MAX9286_HIBW; + cfg |= MAX9286_HIBW; else if (priv->bus_width == 32) - val |= MAX9286_BWS; + cfg |= MAX9286_BWS; - max9286_write(priv, 0x1c, val); + max9286_write(priv, 0x1c, cfg); } /*