From patchwork Thu Apr 14 14:11:06 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: 562081 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 9A579C4332F for ; Thu, 14 Apr 2022 14:22:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343960AbiDNOZH (ORCPT ); Thu, 14 Apr 2022 10:25:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349428AbiDNOUI (ORCPT ); Thu, 14 Apr 2022 10:20:08 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79660A27D4 for ; Thu, 14 Apr 2022 07:11:13 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id m14so7101525wrb.6 for ; Thu, 14 Apr 2022 07:11:13 -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=pyYP5jTZGe1iIdHDva19cy+FXngavEB3nCuwJeLMONWVdDmXn0E8RKrg+0rOq0u3tW d0JxgTsu84DPkeNL91wMOiRqMerMqGQqqJqb52XEIxh7FQ0PhWL5UZwNnNnVUWZ3V4EA 1JsqvSS5rGl+OBMZulolrTIV1s+Dj98XZpaKtntpE3dFyRfv7QHIUPs+ZOy+fYhRuXFC QYoA+42MaRKLVc/Ou/CVFzuwLCWyGleWt/t4ubPVFMYYdB2kWYC9PaEYDiqSQkSiXHX0 xnm1IBIjDzR10x03a7FraNHA+10hzWX+h5BuC6scYa+iLx/PoraVGtC2EvuT2KMcFNBM XWVQ== 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=TZJP+Xc4Ik/WKOVG4aF5rNYVTK0ryZPhKfo8xJ8qASdoFgCfSDKCPzod3/n2zWRCj2 DS95hyNhV2ZST90WIrJd3tqp5YyHqo5bbjzJDTAXySEL/0eIIDKY4xw/WNJf2wS2zR7M ZnQqg0hz4yiUn3hte3ygf+kvvHJ0LfOtFTdiTNz1XyE56cWgEanta17KYtC8noZgu3fW 1wb/Tc6WPhBj+Pd5ZcRkzjAeRqNLe0HX+XGmxFrG3V6PcknMhMu6+Isbk00q1z0N9o9v 5iVzjy71JpJrvT3R75nwrFgqoqsASJZlGUwJ4VsbWpYgDPfDzsw2EozzHJBwavkl6yAy bOyA== X-Gm-Message-State: AOAM532i/YG9ASObnZ4C+LKh/o+XG0KBDf+QLLmgZs+O/Y2K2QigNM5V kibFDmRf2F8xKFauxo8wES5ymA== X-Google-Smtp-Source: ABdhPJzd87u4VitFe0hrj8sBPdroXixiqIUTNvmbFlySF6f6F5CRIzf/Iv3BIk/sb2XQY5K0qxBF3A== X-Received: by 2002:adf:f98e:0:b0:207:9eed:60d8 with SMTP id f14-20020adff98e000000b002079eed60d8mr2304802wrr.566.1649945471907; Thu, 14 Apr 2022 07:11:11 -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 61-20020adf8043000000b00205e1d92a41sm1934551wrk.74.2022.04.14.07.11.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 07:11:11 -0700 (PDT) From: Bryan O'Donoghue To: sakari.ailus@iki.fi, 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 v4 1/3] media: dt-bindings: imx412: Add regulator descriptions Date: Thu, 14 Apr 2022 15:11:06 +0100 Message-Id: <20220414141108.1365476-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220414141108.1365476-1-bryan.odonoghue@linaro.org> References: <20220414141108.1365476-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 Thu Apr 14 14:11:07 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: 562080 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 E18B3C4332F for ; Thu, 14 Apr 2022 14:23:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344816AbiDNOZY (ORCPT ); Thu, 14 Apr 2022 10:25:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349429AbiDNOUI (ORCPT ); Thu, 14 Apr 2022 10:20:08 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 797AEA27EC for ; Thu, 14 Apr 2022 07:11:14 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id u3so7110773wrg.3 for ; Thu, 14 Apr 2022 07:11:14 -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=eo7d7o1OtMwpdqCJpbeEvNSKLWc67zY7+ZWCbWv5/Vw=; b=no20RHpAWyr7dmRwZcAyyvT/XfIpQ4WWpxEG0H2Dh6T3UtAyaRgLIfHAGUsyHbZTVM KCLD+4C3ko3DOU2Bm0va1jbS7oD+rP1huS9RinSCzibGxawrsRFLMfBlpCBI8GtS5Uww K0TwJ6bYUCBfBO5cPqETHY9s9x1jGcgh4NERrbUvIz7gIQd4JdPJDar3fV64xx/MY+tQ QdRU9goJjnm53J2V42hQbU69ISn4F6OBn6Ta3xcbGDFamI8y7mV4MoJhPPVXGqFObbex LNTwMj+xDntKsHMrXfCtUEZGJxNG6I/++3snZ/tFdBhNJbDiiAOV/EbZEtKj/CniqJHu 73Mw== 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=eo7d7o1OtMwpdqCJpbeEvNSKLWc67zY7+ZWCbWv5/Vw=; b=oC0sjS3U2a+bZmQIJRsxqJ6rC9ZpyT7ToAqhHoID7aT87zS129txGYT2bky4aPaEOU ZEFn+b25NjFIGIS3nrl21q60g06PagJXn4pnp14gFDBqfmehamN7cJI3MNyciXs/GfLb 0AkKViq1hEDaOPZT/WJWjYwk9lbhdpZODdwnyJyLRywfzquSH1WjF4/bn3dyWytUjURA DMrRepVOQNBEHfNIAfepwY16Tp7uleiHYDmZcjs7egFk66b4Sm7QDoeqYbVF9fE7W7FB lXOYejxqBPPYBToACphmdHb1xz0sTrjxo9yr5K7D0LvAzKT3Nf3OWBq4TpRfrneZZFm6 yezQ== X-Gm-Message-State: AOAM533aAnrUtu1Q42igVrHhQu8osJ17HhjuGDaFOjjq1dRrEHFomCGM fC3RCM8XixYYepXU5UaVqH3HeA== X-Google-Smtp-Source: ABdhPJxvwdBc7TM4mXUFIoa4vM2Rwncv3jQRMspQhnRgTXJMH2YJHDlPL8r/i+CCRw3DqK6KFkLetQ== X-Received: by 2002:a5d:4882:0:b0:207:97dd:111c with SMTP id g2-20020a5d4882000000b0020797dd111cmr2420435wrq.115.1649945472992; Thu, 14 Apr 2022 07:11:12 -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 61-20020adf8043000000b00205e1d92a41sm1934551wrk.74.2022.04.14.07.11.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 07:11:12 -0700 (PDT) From: Bryan O'Donoghue To: sakari.ailus@iki.fi, 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 v4 2/3] media: i2c: imx412: Add bulk regulator support Date: Thu, 14 Apr 2022 15:11:07 +0100 Message-Id: <20220414141108.1365476-3-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220414141108.1365476-1-bryan.odonoghue@linaro.org> References: <20220414141108.1365476-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 | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/media/i2c/imx412.c b/drivers/media/i2c/imx412.c index be3f6ea55559..6d0746d6c634 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)]; + unsigned int num_supplies; struct v4l2_ctrl_handler ctrl_handler; struct v4l2_ctrl *link_freq_ctrl; struct v4l2_ctrl *pclk_ctrl; @@ -946,6 +955,16 @@ 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 +1030,12 @@ 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"); + return ret; + } + gpiod_set_value_cansleep(imx412->reset_gpio, 1); ret = clk_prepare_enable(imx412->inclk); @@ -1025,6 +1050,7 @@ static int imx412_power_on(struct device *dev) error_reset: gpiod_set_value_cansleep(imx412->reset_gpio, 0); + regulator_bulk_disable(imx412->num_supplies, imx412->supplies); return ret; } @@ -1044,6 +1070,8 @@ static int imx412_power_off(struct device *dev) clk_disable_unprepare(imx412->inclk); + regulator_bulk_disable(imx412->num_supplies, imx412->supplies); + return 0; }