Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp550722lqm; Wed, 1 May 2024 08:33:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVussE0kt4sclnbypHB6/HNT99R/HuoEt64CbqpNavZsDolFjtJq63nO9gsfG/pas0CyoqaK3Qhi236Sy1+oC5CO50lezT7a1uLn4oUuA== X-Google-Smtp-Source: AGHT+IEXAhNw3kALC3riIq8aCqTjYUCJwn3z3HYjabBN2qS9XWpKt8otRFZ6SAH0yUT4iJqf1qV4 X-Received: by 2002:a05:6a21:800f:b0:1a9:6d13:d5b7 with SMTP id ou15-20020a056a21800f00b001a96d13d5b7mr2804913pzb.37.1714577592166; Wed, 01 May 2024 08:33:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714577592; cv=pass; d=google.com; s=arc-20160816; b=wC2LXb60220j3PeO2KbNcqXtE/5ayHkoXZjfUD3WIhyjGTRVn0Vd9gZQhn6Lc5njya TKjxS0WRlZ2c/BBOIdmYEgxcxLO5hez6aakfRdXYJ4059D8bNYMUIAKgQGqUzxJD4o/a quY39dNzem2RX+DEOsV2OFGCXeAQXF2bcYEST/OeBPNGWe+VYMNd7rd6YMAi9M4/Ua7Q 2sftHFOlscLMvgw8xfMF6CPT/KsnjkKK9WxIj4S6ttY0Bk/BwRiYpiu0PWAwo0W+AfZF AV7BIrHr0yQnmdi4ObvxsUYM70JPjgYoi7nS3maGhnX7EKy6oo/K1IGpYi6wYa5wisQc OvvQ== 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=eO8+zTRnY+XP3PnDf37loOmA3ej40WAz4EZNnX6WKweOHhLjfMD81xkNjJ7vEV1nkV LYB78jgHZLnv0gQYBrRng2+aROhmC0TgD3/gbMr1dqj1hRJ3ndXieish1I141J+hV6yG znEt2B5p8lmqwR9Rzqpy2aSXSRY9jhKP/7mKdFwmHSEOqmWJ4655LkNLROeCDOId6yYj OrysdXLG8l2WAgkg4cMCuiERIFuimvNAMc1f1z3hlZTZmCnTZoArACNTqtT7AOOXT+TG wJLeOJ0HwKvzALMnTKE5BlZ13lTfN+XZ3t+C/LEGo6WEYd6KrtI/bQhrHYu46zvsy6SG Xqfg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@luigi311.com header.s=x header.b="N/cA/wtG"; arc=pass (i=1 spf=pass spfdomain=luigi311.com dkim=pass dkdomain=luigi311.com); spf=pass (google.com: domain of linux-kernel+bounces-165479-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165479-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id k129-20020a633d87000000b005e83b6752bdsi21882432pga.269.2024.05.01.08.33.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 08:33:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165479-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=fail header.i=@luigi311.com header.s=x header.b="N/cA/wtG"; arc=pass (i=1 spf=pass spfdomain=luigi311.com dkim=pass dkdomain=luigi311.com); spf=pass (google.com: domain of linux-kernel+bounces-165479-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165479-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 3423AB21A04 for ; Wed, 1 May 2024 15:31:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D920412FF7B; Wed, 1 May 2024 15:30:44 +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="N/cA/wtG" Received: from mail-108-mta55.mxroute.com (mail-108-mta55.mxroute.com [136.175.108.55]) (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 E462812FF78 for ; Wed, 1 May 2024 15:30:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=136.175.108.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714577444; cv=none; b=PjvskKSegrEohJlcBMCVijC+rDmsTk33Wi+Bl+lGUIN9v/B0l35O6nB/dIKFQIJ2hlMDzd7QZcVej7oZ1pY1Hhw/L38G4l3mzH6YLXGUpCYDH3qKJUaXILDP/lR0juDcTjJNALylXfIgxXtToqwe0bSOdIZgsWTnd7p7q7Om0dA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714577444; c=relaxed/simple; bh=jrpDrwXWTfqruvVHzDUB/w0E8OgbIFxAqsRUJkK/6Tk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k9EEy2U5DpxHHl5CMaqc60D3ciguZ2YNwzp8tYsnYFZwPo/+P4gDvCAx/5Qsbk9cwlntV/Xr6icdqjCm68hcD+k5PMkXPWquQ5th0Ng2Tynk/XCujWMuvVmY59EuCpN8BT6P04rJaP48KVClD83vsL6uxVDTBf7/GoPCTJ6DU2Y= 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=N/cA/wtG; arc=none smtp.client-ip=136.175.108.55 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.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta55.mxroute.com (ZoneMTA) with ESMTPSA id 18f34c253dd0008ca2.010 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 01 May 2024 15:25:01 +0000 X-Zone-Loop: ada7f751941d9375f60fb2027ec17e1893b6b8cd888d 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=N/cA/wtGhgzw0fRH5QsJwtUPqo UOfuKMYgj9QBgfDvbpBSxAk38VJaNp/1jksxSFqgWxN2+U/S03DwQkrAJEqftAW4xw1mEqJgh6cOw FQqqiK93ak2zdrnERHLrmXgORwAvFkI/f4Xkj3zrksOTwcCzAnj+5jIXA7zfP50Q3A+si13qRi11s /a4pqW6j3jQYR6LDXTLxZT2bytPAZ0XWvWLsSjzy98XrF7q8PVUFnEusJEXsAy/yI6cJ8qGigE1dL wlSUJa3DhbqLV+t38D1UZx94VboI+wDjphcBs/0oH74meVMs5RN4+/SPORVTwnObB//ad1lsirOgJ RstkFnTg==; 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 v5 05/25] media: i2c: imx258: Add regulator control Date: Wed, 1 May 2024 09:24:22 -0600 Message-ID: <20240501152442.1072627-6-git@luigi311.com> In-Reply-To: <20240501152442.1072627-1-git@luigi311.com> References: <20240501152442.1072627-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