Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp607300lqj; Sun, 2 Jun 2024 13:27:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVTJYo3Y+uvwfe+xUTiuwTLijs2cKqQCrKdPf4VDkyx969tdbm21zGVM9wwwHqw6TRR7PxHxwwO9j9VNlNTxdMew7zwOQz+uCRwXZCIzQ== X-Google-Smtp-Source: AGHT+IGzFj7VNcxRltvKjLXB02XFWwJdcLhGMxn4NC1SMo/o0BcT6+IfNS4YTwvsRZur4FWkA0T4 X-Received: by 2002:a05:6000:1754:b0:354:c2c3:a319 with SMTP id ffacd0b85a97d-35e0f34f2b9mr5236765f8f.61.1717360079803; Sun, 02 Jun 2024 13:27:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717360079; cv=pass; d=google.com; s=arc-20160816; b=QkQFImEvPKVUb2i6BYPzKuVtpZ6Ib/8lv2yaRmkZLd5U/noXbipXZ/km4SuZfLXBoC MaMS6HDNYU4pk5pot2UldemDL0NjS9fQYHzc9pSm6P3QNLtUrVcSUk7RzgQwCbch4rG2 r2EFph1dln9CiQ2c9kE50RsHV0PeXPuTaWhrqe5Pm+tquPhGJpcWoSFe3st+u+4yYwmb alY2RR5M/tsUEyhVuKGg7LhkCfLfxc912vvWaS41LHOnns3V7JesiCR9aNYswf1NQfo7 BqkI1yP1syP0+IvinmDjIkoBsagpOiqjYa+NRFy0DTp0pIoYJkpXSGUtaAzz+ib0Us6J yu8Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Rfud00GhiUoBsKNNr1PLv8b+cenFrKxczN1IEfbbCGA=; fh=ng0FUFwPgHHqIHtWcUlLUSBs0e7fHIUGeuUhfcQSRgA=; b=eoBeaLHgpvYEIupfiAvBbjVGvoC+/hS1gsFq/1ixxU0TRL1vtmzMNVGWJhiLSjFyiH nQTYtBdgLRIsyda8Sv0brcQCCRz3CChk52TyoG/enlAeXgev5E2j0a7Z+xL/IOZBjHOt w/ROx6F8ehJku9QXuVjtI6Z3iiwyPlMe7dIK0D0tISmOvr5BvWmc9K9XZfStFQHgjnzC cdzys4aycM3AdY0XT39pZq0jOXEE3g4bqjDQQahwGE2r5r35zda25TvrGkK1eI3j+lX0 xrHkkn+b9NBXOMLBi360Iq8SbcRYXSFJSUCnYhQEaGL7h4V+FZ8MgAJ/TsjOMvLeaY+A U+cA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@luigi311.com header.s=x header.b=gRvUs8l0; arc=pass (i=1 spf=pass spfdomain=luigi311.com dkim=pass dkdomain=luigi311.com); spf=pass (google.com: domain of linux-kernel+bounces-198408-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198408-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a67ea38d937si350747466b.313.2024.06.02.13.27.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jun 2024 13:27:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-198408-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=fail header.i=@luigi311.com header.s=x header.b=gRvUs8l0; arc=pass (i=1 spf=pass spfdomain=luigi311.com dkim=pass dkdomain=luigi311.com); spf=pass (google.com: domain of linux-kernel+bounces-198408-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198408-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id BA8151F21FB7 for ; Sun, 2 Jun 2024 20:20:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 86F688121B; Sun, 2 Jun 2024 20:19:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=luigi311.com header.i=@luigi311.com header.b="gRvUs8l0" Received: from mail-108-mta113.mxroute.com (mail-108-mta113.mxroute.com [136.175.108.113]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03B84763E6 for ; Sun, 2 Jun 2024 20:19:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=136.175.108.113 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717359575; cv=none; b=Ml3SvC/ZH2JwW0kSKpkCQqL6lPCl7nIrVbcbu1sEbF6XBWWnD0F3Q8c913GiZbWFq95pUOMkh7RWp/OPsXGPJIiyFlsOrNZVCwTY/oir+MW89f/3D9t8JiA9AEWw9UVlBTfn5zc7py83m465SL67l9DpC3G0+aOraH3vJPEaZOg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717359575; c=relaxed/simple; bh=jrpDrwXWTfqruvVHzDUB/w0E8OgbIFxAqsRUJkK/6Tk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O9uetv+SSiydO/do1w3o44wgRyymviUDGAiS4GmaF9GJpeBPTJBD7+q4HNtqSxrdq6ygoxXx7xTEXtfju9RIPFtsF3pKfR5qZ9/jeexKVAICfiN4Pgx7MAN73cjQEXupZYPo3E1k9LunLnY0Mz5bIPopEEt/3HaSxyfYkohnKpU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=luigi311.com; spf=pass smtp.mailfrom=luigi311.com; dkim=pass (2048-bit key) header.d=luigi311.com header.i=@luigi311.com header.b=gRvUs8l0; arc=none smtp.client-ip=136.175.108.113 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=luigi311.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=luigi311.com Received: from filter006.mxroute.com ([136.175.111.3] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta113.mxroute.com (ZoneMTA) with ESMTPSA id 18fda966f5f000e2b6.010 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Sun, 02 Jun 2024 20:14:03 +0000 X-Zone-Loop: 5814708a563fb334b6a525dc0247c93a99bc93d50358 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=luigi311.com; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Rfud00GhiUoBsKNNr1PLv8b+cenFrKxczN1IEfbbCGA=; b=gRvUs8l0wLPyImdmv2LlcMVDTm Qrx1AxtAy1W/WrYtNCQ8QQarUXRwOkLw1pJapMEwgvBxNgWEkaew1gRzggntBlP/P7zYH1ARBAG+A n8Q0ayuWDyPlxN/FTwMHr6OBqxw25GiRsrL1J5GEIJg0Umb2ZtgM4mqEEFVT3/6cqmTYIKAbll9CH antACTtcDo8yOzIp0YIdcZ5xgKKaPm4e77FPkoxw50Qpj3qabN/dlNaK4lciiLZFFjB4r98B/IcVk sftPqg3talICmkv/RNM0AOjbE0JsiALnloh4nICYu9cwg0tQ9QkwMDQ9y28aRqiMPKuVIG+ewk05W vRvOAT1g==; From: git@luigi311.com To: linux-media@vger.kernel.org Cc: dave.stevenson@raspberrypi.com, jacopo.mondi@ideasonboard.com, mchehab@kernel.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, sakari.ailus@linux.intel.com, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, pavel@ucw.cz, phone-devel@vger.kernel.org, Luis Garcia Subject: [PATCH v6 05/23] media: i2c: imx258: Add regulator control Date: Sun, 2 Jun 2024 14:13:27 -0600 Message-ID: <20240602201345.328737-6-git@luigi311.com> In-Reply-To: <20240602201345.328737-1-git@luigi311.com> References: <20240602201345.328737-1-git@luigi311.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Authenticated-Id: personal@luigi311.com From: Dave Stevenson The device tree bindings define the relevant regulators for the sensor, so update the driver to request the regulators and control them at the appropriate times. Signed-off-by: Dave Stevenson Signed-off-by: Luis Garcia --- drivers/media/i2c/imx258.c | 42 +++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c index df7ed4716762..495eaada2945 100644 --- a/drivers/media/i2c/imx258.c +++ b/drivers/media/i2c/imx258.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -507,6 +508,16 @@ static const char * const imx258_test_pattern_menu[] = { "Pseudorandom Sequence (PN9)", }; +/* regulator supplies */ +static const char * const imx258_supply_name[] = { + /* Supplies can be enabled in any order */ + "vana", /* Analog (2.8V) supply */ + "vdig", /* Digital Core (1.2V) supply */ + "vif", /* IF (1.8V) supply */ +}; + +#define IMX258_NUM_SUPPLIES ARRAY_SIZE(imx258_supply_name) + /* Configurations for supported link frequencies */ #define IMX258_LINK_FREQ_634MHZ 633600000ULL #define IMX258_LINK_FREQ_320MHZ 320000000ULL @@ -611,6 +622,7 @@ struct imx258 { struct mutex mutex; struct clk *clk; + struct regulator_bulk_data supplies[IMX258_NUM_SUPPLIES]; }; static inline struct imx258 *to_imx258(struct v4l2_subdev *_sd) @@ -995,9 +1007,19 @@ static int imx258_power_on(struct device *dev) struct imx258 *imx258 = to_imx258(sd); int ret; + ret = regulator_bulk_enable(IMX258_NUM_SUPPLIES, + imx258->supplies); + if (ret) { + dev_err(dev, "%s: failed to enable regulators\n", + __func__); + return ret; + } + ret = clk_prepare_enable(imx258->clk); - if (ret) + if (ret) { dev_err(dev, "failed to enable clock\n"); + regulator_bulk_disable(IMX258_NUM_SUPPLIES, imx258->supplies); + } return ret; } @@ -1008,6 +1030,7 @@ static int imx258_power_off(struct device *dev) struct imx258 *imx258 = to_imx258(sd); clk_disable_unprepare(imx258->clk); + regulator_bulk_disable(IMX258_NUM_SUPPLIES, imx258->supplies); return 0; } @@ -1220,6 +1243,18 @@ static void imx258_free_controls(struct imx258 *imx258) mutex_destroy(&imx258->mutex); } +static int imx258_get_regulators(struct imx258 *imx258, + struct i2c_client *client) +{ + unsigned int i; + + for (i = 0; i < IMX258_NUM_SUPPLIES; i++) + imx258->supplies[i].supply = imx258_supply_name[i]; + + return devm_regulator_bulk_get(&client->dev, + IMX258_NUM_SUPPLIES, imx258->supplies); +} + static int imx258_probe(struct i2c_client *client) { struct imx258 *imx258; @@ -1230,6 +1265,11 @@ static int imx258_probe(struct i2c_client *client) if (!imx258) return -ENOMEM; + ret = imx258_get_regulators(imx258, client); + if (ret) + return dev_err_probe(&client->dev, ret, + "failed to get regulators\n"); + imx258->clk = devm_clk_get_optional(&client->dev, NULL); if (IS_ERR(imx258->clk)) return dev_err_probe(&client->dev, PTR_ERR(imx258->clk), -- 2.44.0