From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 978773D6F for ; Sun, 29 Jun 2025 20:56:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751230608; cv=none; b=czJBJ5qHORCHXHk9LKHY7WfGN5YP44nQA8JAaQyayrY6TdIR3pYivMvaGDST3ralKDp0b/zcqnCHC/ybsD8yEuyrxSqGe4qKix2fr94EzfyDtQjphHYy2JA2rEwr8vF8dSS6dE1bsIZ1Ut7sG/XsshqI0FctO2UMt19hBICP3bU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751230608; c=relaxed/simple; bh=jOQ0ydVCXQtW08ekoEKwPCNyvlUp6Lasj7+Rless9zw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TXwjdteo8Y9o9ITEz9QfCYndbvIDzuxwDvp/PmWh3i5DdBtwQ8vu/cqaWT9gFqAJ6VVrZieTx2LVA/sbPlOo0kRnf/o4y8hCzPe9Kle1hBklCz1+MlmdlVifD+lGZOzB/39tA68oKm+nRcDpJ0F2tFoz0gPSb4F3DcA0v5D35CI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q59paoJX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q59paoJX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D64DC4CEEF; Sun, 29 Jun 2025 20:56:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751230608; bh=jOQ0ydVCXQtW08ekoEKwPCNyvlUp6Lasj7+Rless9zw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q59paoJXg2Zd1TuusVEK/IJ6uLqKZK5x/eDxcBbW5SvlWADu5G68mqBO9P8BgPKU0 ifcWgWK8bQMP/jJacEkuZRFC5McR4Agot8lE3vEMoZLOlupT1Z3B1qERR5N+j6vqEJ pZNx3VZck6jIY6d3lgwstXjEdc2TI3TW+2CJP9vJAhzAemeymoHuzp9jwQmy70clb9 bbWp2ZhU9Hd/OymHL4htDqGbHwwLgtLpS+GfGjY3c2gAUn+p1128G2CABHRiaukAMB aPC1mwU8/k/dm4eNFxdK137K+MIRE1AFKy6lP7AzCdSmYK3PhLcWV8Wn8OmfbCmD8W Y6JGJf2foVKdA== From: Hans de Goede To: Sakari Ailus , Laurent Pinchart Cc: Hans de Goede , Mathis Foerst , linux-media@vger.kernel.org Subject: [PATCH v3 08/15] media: mt9m114: Put sensor in reset on power down Date: Sun, 29 Jun 2025 22:56:18 +0200 Message-ID: <20250629205626.68341-9-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250629205626.68341-1-hansg@kernel.org> References: <20250629205626.68341-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Put the sensor back in reset on power down. Putting the sensor in reset reduces power-consumption by putting all the data / ctrl pins in High-Z mode. This helps save power on designs where the regulators may need to stay on while the sensor is powered down. This also ensures that the sensor is properly reset on power up, since now the sensor will see a reset high to low transition after the regulators have been turned on. Reviewed-by: Laurent Pinchart Signed-off-by: Hans de Goede --- Changes in v3: - Improve commit message Changes in v2 - After setting reset high wait 20 clk cycles before disabling the clk and regulators --- drivers/media/i2c/mt9m114.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c index c10100d8fd4a..d4aad77b095b 100644 --- a/drivers/media/i2c/mt9m114.c +++ b/drivers/media/i2c/mt9m114.c @@ -2207,6 +2207,13 @@ static int mt9m114_power_on(struct mt9m114 *sensor) static void mt9m114_power_off(struct mt9m114 *sensor) { + unsigned int duration; + + gpiod_set_value(sensor->reset, 1); + /* Power off takes 10 clock cycles. Double it to be safe. */ + duration = DIV_ROUND_UP(2 * 10 * 1000000, sensor->clk_freq); + fsleep(duration); + clk_disable_unprepare(sensor->clk); regulator_bulk_disable(ARRAY_SIZE(sensor->supplies), sensor->supplies); } -- 2.49.0