From patchwork Fri Apr 15 11:59:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 12814822 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 14602C4332F for ; Fri, 15 Apr 2022 12:00:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344543AbiDOMDV (ORCPT ); Fri, 15 Apr 2022 08:03:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353065AbiDOMDN (ORCPT ); Fri, 15 Apr 2022 08:03:13 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 145CD48E6A for ; Fri, 15 Apr 2022 04:59:59 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id x3so4821624wmj.5 for ; Fri, 15 Apr 2022 04:59:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uyhcCx6yj8rjxb6a42YESztMokSP0tWlkBSMt8gW5Ow=; b=tdnhFnBX6qS2mTFAwfjMwaXKe4UZ3lRuPcgDGDVexws0JgIGdxWDmWkZiuBI3C4ibI dCpea726QjZh3DQSLEMBH9F5MlkdRRaYPTnyNKduv3UwKHzze4jc1FOwleDwrvP2Iutb ejLHGejj5fGwk+jLmV19Z45X+ETbw6LLkR+m+mV1M58ScRkac0yyVGyNEWcOiRo3QiCy zeU6E0PiqId7M0hPjx1ls5lk768SkqSD82R4kKvGbxdZayef8tFZApx3G+3K3Dx6H76J +00MegbyeSmm4UqrB3GdpobylmX9rg+m1LmKGp03Mvdu8sfq+j5A0p9ODshv4GHp88XU 0WAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uyhcCx6yj8rjxb6a42YESztMokSP0tWlkBSMt8gW5Ow=; b=PagxLoK2wyCATgImoNMncD3nLBrnPqGhSHpWnUMqeTrp8i/X/XYqxxI1yPMJZQ20V+ xI8cQn/gHzH7KmOuukP6PyyVAdQCGXF0Z+ePu9lOnhSo+e4WwzQYk+w19fhjdGyc6uPk QIBN2bC+D91m3BH5Ddb6C3YLHdym0DzxaxGGPtcPI2wMnN4iL8xE2gWn4oF6dggzjpuP gqLD5jYDUEKFkF1pckrc4QbR8XBtpVyqyKkxEMjpO23vPWaRoJ+rQScPPzYM58mwqB+U 1MXxctgOnTnCrywy5vF8mu06fOiabOt25Dj7W7BEiUpC7qEPh+FoZBIqIkV3I55brvzk FrSQ== X-Gm-Message-State: AOAM532KAtlN3prb2GcOFXMPKjfyx/W8AK7HdmlN2BkHkOVWJhbczCBa 668AZ67I7+lVGWyvN8FmJmscog== X-Google-Smtp-Source: ABdhPJzG7CULNtuZz0PT2UdSsywjt2yheHKLf8RXO8Sojc1D4/EAWNozAB179tMXPw4/DVVaUyCvfg== X-Received: by 2002:a7b:c844:0:b0:37b:b986:7726 with SMTP id c4-20020a7bc844000000b0037bb9867726mr3228116wml.160.1650023998511; Fri, 15 Apr 2022 04:59:58 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id bg8-20020a05600c3c8800b0038e4c5967besm5328568wmb.3.2022.04.15.04.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 04:59:58 -0700 (PDT) From: Bryan O'Donoghue To: sakari.ailus@iki.fi, jacopo@jmondi.org, paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, mchehab@kernel.org, linux-media@vger.kernel.org, devicetree@vger.kernel.org Cc: robert.foss@linaro.org, hfink@snap.com, jgrahsl@snap.com, dmitry.baryshkov@linaro.org, vladimir.zapolskiy@linaro.org, bryan.odonoghue@linaro.org, stable@vger.kernel.org Subject: [PATCH v5 1/4] media: i2c: imx412: Fix reset GPIO polarity Date: Fri, 15 Apr 2022 12:59:51 +0100 Message-Id: <20220415115954.1649217-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220415115954.1649217-1-bryan.odonoghue@linaro.org> References: <20220415115954.1649217-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The imx412/imx577 sensor has a reset line that is active low not active high. Currently the logic for this is inverted. The right way to define the reset line is to declare it active low in the DTS and invert the logic currently contained in the driver. The DTS should represent the hardware does i.e. reset is active low. So: + reset-gpios = <&tlmm 78 GPIO_ACTIVE_LOW>; not: - reset-gpios = <&tlmm 78 GPIO_ACTIVE_HIGH>; I was a bit reticent about changing this logic since I thought it might negatively impact @intel.com users. Googling a bit though I believe this sensor is used on "Keem Bay" which is clearly a DTS based system and is not upstream yet. Fixes: 9214e86c0cc1 ("media: i2c: Add imx412 camera sensor driver") Cc: stable@vger.kernel.org Signed-off-by: Bryan O'Donoghue Reviewed-by: Daniele Alessandrelli --- drivers/media/i2c/imx412.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/imx412.c b/drivers/media/i2c/imx412.c index be3f6ea55559..e6be6b4250f5 100644 --- a/drivers/media/i2c/imx412.c +++ b/drivers/media/i2c/imx412.c @@ -1011,7 +1011,7 @@ static int imx412_power_on(struct device *dev) struct imx412 *imx412 = to_imx412(sd); int ret; - gpiod_set_value_cansleep(imx412->reset_gpio, 1); + gpiod_set_value_cansleep(imx412->reset_gpio, 0); ret = clk_prepare_enable(imx412->inclk); if (ret) { @@ -1024,7 +1024,7 @@ static int imx412_power_on(struct device *dev) return 0; error_reset: - gpiod_set_value_cansleep(imx412->reset_gpio, 0); + gpiod_set_value_cansleep(imx412->reset_gpio, 1); return ret; } @@ -1040,7 +1040,7 @@ static int imx412_power_off(struct device *dev) struct v4l2_subdev *sd = dev_get_drvdata(dev); struct imx412 *imx412 = to_imx412(sd); - gpiod_set_value_cansleep(imx412->reset_gpio, 0); + gpiod_set_value_cansleep(imx412->reset_gpio, 1); clk_disable_unprepare(imx412->inclk); From patchwork Fri Apr 15 11:59:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 12814823 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 6B260C4167D for ; Fri, 15 Apr 2022 12:00:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235553AbiDOMDV (ORCPT ); Fri, 15 Apr 2022 08:03:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353064AbiDOMDN (ORCPT ); Fri, 15 Apr 2022 08:03:13 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D7FE40A2A for ; Fri, 15 Apr 2022 05:00:01 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id v64-20020a1cac43000000b0038cfd1b3a6dso7612389wme.5 for ; Fri, 15 Apr 2022 05:00:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0qzwRG5yOP0zfZHRBmajTxytV7avLAvdnBn43hNrQG8=; b=bmT5CUWzbuCvNyaDXWWpRe8mRTnF0rCEC9NCcl19TWWu/9zu60I6VLNBeuNiD6GZGk qp/v6Cj5l9K8JBM1fmJ9Yn5R/nza2h2W7XujLh367lsvQNBHgSZzxvwXNna8TXVtwq4v 0gpMRHlo/sT+uktp5qjV7JWlWbhIc2NdO3ZRtRyddogOJWgF39/lbu7RbeeKT+DyLaVD JwwI6/YkWmv8jmQzQZG0qaAu8Rs2kPRVReHnqU4t0WraM/vot3Dx5ZKIz+VFXD05a6Qx 4nG41aMVxeN3Btr44n3j9+5Okt3vZi7qJbqYRy5RxMyVErB1WCloeLtJPmpKUrZgKsOB Bfgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0qzwRG5yOP0zfZHRBmajTxytV7avLAvdnBn43hNrQG8=; b=oUP5QbjDGNnMtI+zgoKpNqBpqlAfeKBeYxA8Fy9aAtFloCRRWXWrPCEdMHKDY3fJEx EwtS8kQMW2PUjuLoXLQti9lcG/qv+dEymzR8Y5J1auNJm3NdNlPN60+ykYl9ewKCv7Vx 28r5X+/kQbJcSxnaQged0Jp46F63xeRJhWy59B7kO1cXdeAlnf6X6fwqSiAW4ojuRIS5 KLZIwKcXBzCHssxsUg0PPu5iYldpb7WaoGlV1cOarNFrQhvdSizBTuCUcBqmLc7dcDXz 5SRFx3UiZVlj647Wo958id+3gNWXRPQZ5s3ntqNea9eCaOx+ORyfRRdLr8wFhwl2zUwI 4xIg== X-Gm-Message-State: AOAM530ROdx+yVOYopjS6DViQQGDTE5leIq61ssnukXbuMyFS26YyCpM qLy5Jj2moII/QTKpeFX+f5075g== X-Google-Smtp-Source: ABdhPJwfyRlomaFcVJEIpG3tdSZCmtGrVkln0decCB5296QertvgjohHN7nbwkWSBmkQE9bZMDvvWQ== X-Received: by 2002:a1c:4e03:0:b0:38e:d730:11eb with SMTP id g3-20020a1c4e03000000b0038ed73011ebmr3143904wmh.191.1650023999647; Fri, 15 Apr 2022 04:59:59 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id bg8-20020a05600c3c8800b0038e4c5967besm5328568wmb.3.2022.04.15.04.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 04:59:59 -0700 (PDT) From: Bryan O'Donoghue To: sakari.ailus@iki.fi, jacopo@jmondi.org, paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, mchehab@kernel.org, linux-media@vger.kernel.org, devicetree@vger.kernel.org Cc: robert.foss@linaro.org, hfink@snap.com, jgrahsl@snap.com, dmitry.baryshkov@linaro.org, vladimir.zapolskiy@linaro.org, bryan.odonoghue@linaro.org, stable@vger.kernel.org Subject: [PATCH v5 2/4] media: i2c: imx412: Fix power_off ordering Date: Fri, 15 Apr 2022 12:59:52 +0100 Message-Id: <20220415115954.1649217-3-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220415115954.1649217-1-bryan.odonoghue@linaro.org> References: <20220415115954.1649217-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The enable path does - gpio - clock The disable path does - gpio - clock Fix the order on the power-off path so that power-off and power-on have the same ordering for clock and gpio. Fixes: 9214e86c0cc1 ("media: i2c: Add imx412 camera sensor driver") Cc: stable@vger.kernel.org Signed-off-by: Bryan O'Donoghue Reviewed-by: Daniele Alessandrelli --- drivers/media/i2c/imx412.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/imx412.c b/drivers/media/i2c/imx412.c index e6be6b4250f5..84279a680873 100644 --- a/drivers/media/i2c/imx412.c +++ b/drivers/media/i2c/imx412.c @@ -1040,10 +1040,10 @@ static int imx412_power_off(struct device *dev) struct v4l2_subdev *sd = dev_get_drvdata(dev); struct imx412 *imx412 = to_imx412(sd); - gpiod_set_value_cansleep(imx412->reset_gpio, 1); - clk_disable_unprepare(imx412->inclk); + gpiod_set_value_cansleep(imx412->reset_gpio, 1); + return 0; } From patchwork Fri Apr 15 11:59:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 12814824 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 3C3FBC4167B for ; Fri, 15 Apr 2022 12:00:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242045AbiDOMDW (ORCPT ); Fri, 15 Apr 2022 08:03:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353072AbiDOMDO (ORCPT ); Fri, 15 Apr 2022 08:03:14 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60EEF60076 for ; Fri, 15 Apr 2022 05:00:02 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id r13so10404932wrr.9 for ; Fri, 15 Apr 2022 05:00:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k3gcIDeCZ4FNN7UJi4DooXXT3wAgGZnORf6hg3bDQ7g=; b=Lp2ckp7jsSJgJIE1mesO4GV9GwVxlgCvy9tC/qMN00qmoHDUayeE6iXjaFd4PL1H4o kCpAG0Zyiq/eEGQwq9NqhMgKFkkZi33EZjqsc0ZHrhkNcVHbYQ1XbfKJl9kKukuoP6PR KLCNWyxwwUocGZzhfVTn0+eWLfmLI8d7I2vQGwJpWVUk/DoeYst+tkvknbZdUFMXf7e8 DY5HdqhUwq8QucJ/23DQh02talPeXSNAKnEcZ3RbpSebLXKY/s8Xf+HFpegTaYQLNiiu 6d3aoogsP3rc922yZE/vDYowN7cS1S0rgevYxbk7vK4DqGEKHyx2Blyn0ZlZfOdV8ouO JXlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k3gcIDeCZ4FNN7UJi4DooXXT3wAgGZnORf6hg3bDQ7g=; b=scPvQKp9lNOjYutGMTjz20rluHvqz4rh1GbwVfcVVXoVmp92a2EV0b+Ye3IRwQulKv xg7nNX/0oREbarvh2KOxml5jhy73koFstk3Y1uZZNQoaVsS8O8YwdWywjdnG34nG96n5 z6sLH6zlgoZoTNn4He1hSLPzY3DkGH38UdI35i4nMlVIWyhfv1oCKpJ+48djSUihj6m+ IldOHAiaxpFVAlF0lIV8Ym4Tov/Lj2ROAyAVSKrmG79Ul44RjNNaFiHwwXwGiIwFEADA oRPocevOeac/2UXgVfQCE9DtERGQcXWfYWaQZt6ELCwqD8HdHPEBMUlpEXVzBpepKVQP qbLQ== X-Gm-Message-State: AOAM5328y0YlIWMWaTHT381kOlAAMVqRtAeW9Yh8Mpn7V+drNZrkrvBD SDUN9v7jAGIGi/aOin96CRBt0EBn1Rt/5A== X-Google-Smtp-Source: ABdhPJxY9aZUe5GtuIDCyEMp5X7G9YR6Qb5XWS264VnZgqy7LkUR00Z1Aju4y/jjt17zDp27fY9Jng== X-Received: by 2002:a5d:5846:0:b0:204:1a79:f1ab with SMTP id i6-20020a5d5846000000b002041a79f1abmr5285022wrf.520.1650024000953; Fri, 15 Apr 2022 05:00:00 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id bg8-20020a05600c3c8800b0038e4c5967besm5328568wmb.3.2022.04.15.04.59.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 05:00:00 -0700 (PDT) From: Bryan O'Donoghue To: sakari.ailus@iki.fi, jacopo@jmondi.org, paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, mchehab@kernel.org, linux-media@vger.kernel.org, devicetree@vger.kernel.org Cc: robert.foss@linaro.org, hfink@snap.com, jgrahsl@snap.com, dmitry.baryshkov@linaro.org, vladimir.zapolskiy@linaro.org, bryan.odonoghue@linaro.org, Rob Herring , Krzysztof Kozlowski , Krzysztof Kozlowski Subject: [PATCH v5 3/4] media: dt-bindings: imx412: Add regulator descriptions Date: Fri, 15 Apr 2022 12:59:53 +0100 Message-Id: <20220415115954.1649217-4-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220415115954.1649217-1-bryan.odonoghue@linaro.org> References: <20220415115954.1649217-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The imx412 like many I2C camera sensors has three voltage rails which depending on platform may be necessary to switch power onto directly. Add in as optional rails so as not to break anything for existing users. Cc: Rob Herring Cc: Krzysztof Kozlowski Acked-by: Krzysztof Kozlowski Signed-off-by: Bryan O'Donoghue --- .../devicetree/bindings/media/i2c/sony,imx412.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/devicetree/bindings/media/i2c/sony,imx412.yaml b/Documentation/devicetree/bindings/media/i2c/sony,imx412.yaml index afcf70947f7e..26d1807d0bb6 100644 --- a/Documentation/devicetree/bindings/media/i2c/sony,imx412.yaml +++ b/Documentation/devicetree/bindings/media/i2c/sony,imx412.yaml @@ -32,6 +32,15 @@ properties: description: Clock frequency 6MHz, 12MHz, 18MHz, 24MHz or 27MHz maxItems: 1 + dovdd-supply: + description: Interface power supply. + + avdd-supply: + description: Analog power supply. + + dvdd-supply: + description: Digital power supply. + reset-gpios: description: Reference to the GPIO connected to the XCLR pin, if any. maxItems: 1 From patchwork Fri Apr 15 11:59:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 12814825 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 99778C4332F for ; Fri, 15 Apr 2022 12:00:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351076AbiDOMDX (ORCPT ); Fri, 15 Apr 2022 08:03:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353084AbiDOMDO (ORCPT ); Fri, 15 Apr 2022 08:03:14 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFEC66AA74 for ; Fri, 15 Apr 2022 05:00:03 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id m14so10431116wrb.6 for ; Fri, 15 Apr 2022 05:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=d1y641nRGtjN50xjMNw5/o57jqZADQ8uigdFPEkJTyU=; b=gymdzLmCMoEPCVTZMbYMa+Yc3PkIVZg2v+9QxYPYaBgIWr2uhGjeotsMXVo0ja1kWu kjwdhjc7tFhfE5IpC9Rtw3rLNRqz86f0GSdLXvhXjJ5d7QgnPLNBEv1OvqyPezFr5SPJ 9EWNFSi6uyHmdxaloiVggwcF3mM/Ta/ikHNiemO45TC8FGCs2/lJyLgJrSQTgvbhjfsK IQQwgbfo2dXFnDbs/M2x7bf140VtGAUSToqcRrvWRC2FE+M0xhFNjt6uYyTTIuBQcOYD aaNNwTVuwLfcLO9K/n2OD+nvI7plEc/6pcvQxK0gFTPKgegJH8ZqNDr5ygvVM4PL/BC+ xSSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d1y641nRGtjN50xjMNw5/o57jqZADQ8uigdFPEkJTyU=; b=wO+t8UC64uI1VTz4JKajVtT0lyykTd9lDBd4G5Ias1WnUZCyyEDL2QRXglcdb+Eh6O 4MxKtn7KP8YU/oHPWqxRedUBXLXJh50dunbKieB7Hd8VPnIyuE+ZC9ByUxbKbYfJXMkb BEAAM/pbOQ1HQuOoJKuqDiT/jDBcs1nypVwjx/AewV7KaZrpsHWyb8YZfd3/b97olS/b g2jKbZ+mcXLehLm6pV7fJVyP5nwdzjoUxS1O2KV3AHUTLn4DIgZucdnDuQIc2SgLPmW6 t86/xFTT3BLmQLLVVOw/mBwoHZeT5Hfq92JkWpNQkmlC8fnQqNjZ39byCntXIvuCqk3O UHMw== X-Gm-Message-State: AOAM530fg44s1sh3c1kj1BD144f3fyJEpn/87eI8m9kU12F2dGZMbIWL iYIIPdiVoJIC8LUXj+OESpvkbA== X-Google-Smtp-Source: ABdhPJyH6Ovh1R3/6pCX22brV+JOSgbCvt1cq88CdvUGW7aioz3V9VJIJO98IwqosBm8jbVa4CEe3w== X-Received: by 2002:adf:f54a:0:b0:207:a746:e7 with SMTP id j10-20020adff54a000000b00207a74600e7mr5650813wrp.82.1650024002354; Fri, 15 Apr 2022 05:00:02 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id bg8-20020a05600c3c8800b0038e4c5967besm5328568wmb.3.2022.04.15.05.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 05:00:01 -0700 (PDT) From: Bryan O'Donoghue To: sakari.ailus@iki.fi, jacopo@jmondi.org, paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, mchehab@kernel.org, linux-media@vger.kernel.org, devicetree@vger.kernel.org Cc: robert.foss@linaro.org, hfink@snap.com, jgrahsl@snap.com, dmitry.baryshkov@linaro.org, vladimir.zapolskiy@linaro.org, bryan.odonoghue@linaro.org Subject: [PATCH v5 4/4] media: i2c: imx412: Add bulk regulator support Date: Fri, 15 Apr 2022 12:59:54 +0100 Message-Id: <20220415115954.1649217-5-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220415115954.1649217-1-bryan.odonoghue@linaro.org> References: <20220415115954.1649217-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Depending on the platform we may need to enable and disable three separate regulators for the imx412. - DOVDD Digital I/O power - AVDD Analog power - DVDD Digital core power The addition of these regulators shouldn't affect existing users using fixed-on/firmware-controlled regulators. Signed-off-by: Bryan O'Donoghue Reviewed-by: Jacopo Mondi Acked-by: Daniele Alessandrelli --- drivers/media/i2c/imx412.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/media/i2c/imx412.c b/drivers/media/i2c/imx412.c index 84279a680873..1795a6180d60 100644 --- a/drivers/media/i2c/imx412.c +++ b/drivers/media/i2c/imx412.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -101,6 +102,12 @@ struct imx412_mode { struct imx412_reg_list reg_list; }; +static const char * const imx412_supply_names[] = { + "dovdd", /* Digital I/O power */ + "avdd", /* Analog power */ + "dvdd", /* Digital core power */ +}; + /** * struct imx412 - imx412 sensor device structure * @dev: Pointer to generic device @@ -128,6 +135,7 @@ struct imx412 { struct media_pad pad; struct gpio_desc *reset_gpio; struct clk *inclk; + struct regulator_bulk_data supplies[ARRAY_SIZE(imx412_supply_names)]; struct v4l2_ctrl_handler ctrl_handler; struct v4l2_ctrl *link_freq_ctrl; struct v4l2_ctrl *pclk_ctrl; @@ -946,6 +954,16 @@ static int imx412_parse_hw_config(struct imx412 *imx412) return -EINVAL; } + /* Get optional DT defined regulators */ + for (i = 0; i < ARRAY_SIZE(imx412_supply_names); i++) + imx412->supplies[i].supply = imx412_supply_names[i]; + + ret = devm_regulator_bulk_get(imx412->dev, + ARRAY_SIZE(imx412_supply_names), + imx412->supplies); + if (ret) + return ret; + ep = fwnode_graph_get_next_endpoint(fwnode, NULL); if (!ep) return -ENXIO; @@ -1011,6 +1029,13 @@ static int imx412_power_on(struct device *dev) struct imx412 *imx412 = to_imx412(sd); int ret; + ret = regulator_bulk_enable(ARRAY_SIZE(imx412_supply_names), + imx412->supplies); + if (ret < 0) { + dev_err(dev, "failed to enable regulators\n"); + return ret; + } + gpiod_set_value_cansleep(imx412->reset_gpio, 0); ret = clk_prepare_enable(imx412->inclk); @@ -1025,6 +1050,8 @@ static int imx412_power_on(struct device *dev) error_reset: gpiod_set_value_cansleep(imx412->reset_gpio, 1); + regulator_bulk_disable(ARRAY_SIZE(imx412_supply_names), + imx412->supplies); return ret; } @@ -1044,6 +1071,9 @@ static int imx412_power_off(struct device *dev) gpiod_set_value_cansleep(imx412->reset_gpio, 1); + regulator_bulk_disable(ARRAY_SIZE(imx412_supply_names), + imx412->supplies); + return 0; }