From patchwork Sun Apr 10 16:35: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: 559560 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 6BD80C4332F for ; Sun, 10 Apr 2022 16:36:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243615AbiDJQiN (ORCPT ); Sun, 10 Apr 2022 12:38:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243609AbiDJQiK (ORCPT ); Sun, 10 Apr 2022 12:38:10 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCDCE3AA58 for ; Sun, 10 Apr 2022 09:35:58 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id i20so6586270wrb.13 for ; Sun, 10 Apr 2022 09:35:58 -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=nz+8z7lU6Hjr3OWaRn2W5qjAwAOaEVnr0lrLZw293X4=; b=iODvnRmO4vn/UJ4raGboPDiwjqUfs4FOwiNJcTEynxUz7cOOU0tewKaLpNyVbrxtY/ HkMJTPxZsfayBJ+Vroio2FHH6T610hIo7nNla+qQLFEiymZ9Vh7ZIuoe46tYFD7rcI3s UE84Hr0KkSknV2pDTBq1vhS3NhkLf2hosUbRxwQJMXd9REaoQzBQYUvKrGmA7c4o07R9 FsP6qcW8dmRXBJItMFPGxwCfeg5Evkxzp2Sa/etLvk1p5FxPNWIlXJOOzZT6usMRJOro yjKo6DGVFqmKURgjKNIP7FrinMJKwyULeMadXAlKSppuC9/1hpS4UI8mfJnbJyjaTYh0 p7ZQ== 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=nz+8z7lU6Hjr3OWaRn2W5qjAwAOaEVnr0lrLZw293X4=; b=XdgdfvvNElIE0N7EkcCg08ySJVzOigFlAlDOWmVMUAHCq2uCaI63QbaGYZJoB2UeDx nn3RYasWJCYw2rLRmkSTpt2k4361oizXXTxUO1w2S04IL1oJ4hirrN7w+tIY+8eNQZT5 blqnIQgitfYbNFgc2fHEn6qrnn07hMy+9zQjejf/8jakJDQfNW5rHty/tIsUp5ui9F0B Z21rBdg4AT64dMDWSMu8q7mmoFbblVn5rTA2iL3CgvxXShpgGATBraZz2tjADdbwlwYa LF+UJjBXdKlX2IhVGk8b5cLBGRSpvY/gQcRawafzAcFrCx06oVcKdsOzC9Mo+xv9Ll69 C+Pw== X-Gm-Message-State: AOAM531ZN6Hf85FtUr1kc/+SPF2PfEa3keRoJFFl/hGY0LXUPeZexOm7 FP6+sINio4xM14KHYL82DsnBbA== X-Google-Smtp-Source: ABdhPJxffhH5nYuHtCQM7ScuPlYkKa1+NdI6Q2qKi+xi2jN7etWrShcktef9bZJo1kXSmqzqkRfVBg== X-Received: by 2002:a5d:4d02:0:b0:207:a6e8:ef4a with SMTP id z2-20020a5d4d02000000b00207a6e8ef4amr743903wrt.245.1649608557379; Sun, 10 Apr 2022 09:35:57 -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 a7-20020adffb87000000b00207982c7f4dsm6500126wrr.67.2022.04.10.09.35.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Apr 2022 09:35:56 -0700 (PDT) From: Bryan O'Donoghue To: 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 Subject: [RESEND PATCH 1/2] media: dt-bindings: imx412: Add regulator descriptions Date: Sun, 10 Apr 2022 17:35:52 +0100 Message-Id: <20220410163553.3501938-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220410163553.3501938-1-bryan.odonoghue@linaro.org> References: <20220410163553.3501938-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 Signed-off-by: Bryan O'Donoghue Acked-by: Krzysztof Kozlowski --- .../devicetree/bindings/media/i2c/sony,imx412.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/devicetree/bindings/media/i2c/sony,imx412.yaml b/Documentation/devicetree/bindings/media/i2c/sony,imx412.yaml index afcf70947f7e..16869a91ec9a 100644 --- a/Documentation/devicetree/bindings/media/i2c/sony,imx412.yaml +++ b/Documentation/devicetree/bindings/media/i2c/sony,imx412.yaml @@ -32,6 +32,18 @@ properties: description: Clock frequency 6MHz, 12MHz, 18MHz, 24MHz or 27MHz maxItems: 1 + dovdd-supply: + description: + Definition of the regulator used as interface power supply. + + avdd-supply: + description: + Definition of the regulator used as analog power supply. + + dvdd-supply: + description: + Definition of the regulator used as digital power supply. + reset-gpios: description: Reference to the GPIO connected to the XCLR pin, if any. maxItems: 1 From patchwork Sun Apr 10 16:31:09 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: 559561 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 2EF35C433EF for ; Sun, 10 Apr 2022 16:31:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240658AbiDJQd3 (ORCPT ); Sun, 10 Apr 2022 12:33:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240648AbiDJQd1 (ORCPT ); Sun, 10 Apr 2022 12:33:27 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EF61DEF8 for ; Sun, 10 Apr 2022 09:31:16 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id u17-20020a05600c211100b0038eaf4cdaaeso1962574wml.1 for ; Sun, 10 Apr 2022 09:31:16 -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=N+Sd3XQqKZuKjlUjPG3x4ncDDe97DiTcIqhqg+djNQQ=; b=Q7ocK6N0ggpuHGZsHmzBa/+PGDmMECjwx7kMe1uFNFageuCax9ty6xIb1PFQvfOfoB QeR5GXymp9iIMdo7wXpI1OBofgXcp3zVUH3WJ64rv64o6IKBJnYzh6BQ8nkOiuW6GwIn DJ4FdLkFGx2JiBGlzBNJBDt51ndoLW5m1jC9Hkhu6TSy2xe3TCsVBLoxzD6s+imAOp28 b5+dsY9lSHgLpZSX22gLdXXBDrT63PBEv5FT/MP9fiTaQ6jzCppgrzn+2RCQC53Vq1xR jlJB2lM8NXb3F/vkgOm5+QVMUOQ4pzNzRccf59Rc6JZyN2gW1OdC33l84ULH0iziewqx 4NiA== 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=N+Sd3XQqKZuKjlUjPG3x4ncDDe97DiTcIqhqg+djNQQ=; b=T4rf3K/ACXHiMVd4ffwfLB62tCFhH1uHuGhXld6bCuLBSKebMEYoaPkliASdH0PCfz kVWqxEjAHH3Nl+SRlJx5K8qdMz9NyxW5ybVrBCM28Ql42fbI9pCH5At1oblV44lNGDns VMrTiDVS7ZbIS0RGt+WSmoGH6IODAUFzoy1xirv5Txdh0gwZg2pwn2NtmN59TCgUSfc5 nOlOvneIIXjY4V+lBaTqX53LRsxuf7l9L5zYr0mtIgMA0jwM7CNjj+++GjX4SFHO5ceB mzVCyEj9ldzf15wiUgsRdvr7NlbdfKGLKE6wVDI66uD7lIkCiiyYZsWqUsnbqmAu6MzI iYLg== X-Gm-Message-State: AOAM530Jt3MjmGFM98inDJf4zzo22sMinhB2IpOJDI6COZ7TdHidw17+ XtaTeFk2l6xTdZlAZdXbbOJ+qA== X-Google-Smtp-Source: ABdhPJzSe612r8SEwzwUK0+Pvg4NnP8evvLcJg2H+zwJJRykU7NyQGrWpq8bSAJjF5Z4oWQxqCxl9w== X-Received: by 2002:a05:600c:4e8b:b0:38c:73d4:adb5 with SMTP id f11-20020a05600c4e8b00b0038c73d4adb5mr26026902wmq.34.1649608274686; Sun, 10 Apr 2022 09:31:14 -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 l6-20020a1c2506000000b0038e6fe8e8d8sm20616139wml.5.2022.04.10.09.31.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Apr 2022 09:31:14 -0700 (PDT) From: Bryan O'Donoghue To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, mchehab@kernel.org, linux-media@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 2/2] media: i2c: imx412: Add bulk regulator support Date: Sun, 10 Apr 2022 17:31:09 +0100 Message-Id: <20220410163109.3501513-3-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220410163109.3501513-1-bryan.odonoghue@linaro.org> References: <20220410163109.3501513-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 --- 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 be3f6ea55559..44b92718b6cf 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,8 @@ struct imx412 { struct media_pad pad; struct gpio_desc *reset_gpio; struct clk *inclk; + struct regulator_bulk_data supplies[ARRAY_SIZE(imx412_supply_names)]; + int num_supplies; struct v4l2_ctrl_handler ctrl_handler; struct v4l2_ctrl *link_freq_ctrl; struct v4l2_ctrl *pclk_ctrl; @@ -946,6 +955,17 @@ static int imx412_parse_hw_config(struct imx412 *imx412) return -EINVAL; } + /* Get optional DT defined regulators */ + imx412->num_supplies = ARRAY_SIZE(imx412_supply_names); + for (i = 0; i < imx412->num_supplies; i++) + imx412->supplies[i].supply = imx412_supply_names[i]; + + ret = devm_regulator_bulk_get(imx412->dev, + imx412->num_supplies, + imx412->supplies); + if (ret) + return ret; + ep = fwnode_graph_get_next_endpoint(fwnode, NULL); if (!ep) return -ENXIO; @@ -1011,6 +1031,13 @@ static int imx412_power_on(struct device *dev) struct imx412 *imx412 = to_imx412(sd); int ret; + ret = regulator_bulk_enable(imx412->num_supplies, + imx412->supplies); + if (ret < 0) { + dev_err(dev, "failed to enable regulators\n"); + goto error_reset; + } + gpiod_set_value_cansleep(imx412->reset_gpio, 1); ret = clk_prepare_enable(imx412->inclk); @@ -1044,6 +1071,9 @@ static int imx412_power_off(struct device *dev) clk_disable_unprepare(imx412->inclk); + regulator_bulk_disable(imx412->num_supplies, + imx412->supplies); + return 0; }