From patchwork Sat May 31 19:05:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 893713 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 0090E12F5A5 for ; Sat, 31 May 2025 19:05:47 +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=1748718348; cv=none; b=H75WLDZiIAuPvpD9Z0173eWA8HfdUEuVeIVfGMyXcTBLn4bfelNTQ6wDXOGHf+3M4mmdVuBY+MpYh46FfLpI+mOLFLGr7ULbRyG67OihfucUmv0+XVl4717crNSKevDW9EavOthGVRU3qXoJtfNZTGVIAMDIxIAS7aPRGvhb4sg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748718348; c=relaxed/simple; bh=NJxGEEqwVUy5+P3xBlsdxuhfnXnZJv09UJtoUr64rak=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QeuXEAMpOxoh3MQ5BCB7TTdCT+RMAVaRyoMU3uGuO80rsB67Z1DkQAznvT6nA5O2c9YeDnRnjFpum72k9u6wPArS5iRgHvQdne53obpYlGZ55npJkVBKUKngkCIdduteOCRxxcYY8mU+Ny/s9uNL8EgExT/unsDHQSrh7cYVR3g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=h189i8ts; 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="h189i8ts" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7234DC4CEF1; Sat, 31 May 2025 19:05:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748718347; bh=NJxGEEqwVUy5+P3xBlsdxuhfnXnZJv09UJtoUr64rak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h189i8tsHm+6AYBlhFyg42H5lvGwaWMF9uAdICglCIxrgHP1P8Per80LZXzg/v/sA Nl99VPG28WDo56zjYagd5ZMTbFfJYMHMFFaCoz0rApAFy6VZpeb3sKHI0IZmn5WCuI MVoy3zAeFzIzzVaUU0sY5/fkaX+WvlBDlyUPyt8AHcTYuJYgDI/48g/KWxF0fQfVOq hwSFY/RaOGvRMn1lFJXwaRkr+83eydD0WCgO/HwtnCaBp39lOBdKTOYCoq/qzwXcJv N3PF6I4sEePyPRimUN27uTk6Y4QOaM8T4nYnJr7sH/xY+TKI/40MwEFLmncMdAIYAy UCLGefyy6R2hQ== From: Hans de Goede To: Sakari Ailus Cc: Hans de Goede , Mauro Carvalho Chehab , linux-media@vger.kernel.org Subject: [PATCH 1/2] media: hi556: Fix reset GPIO timings Date: Sat, 31 May 2025 21:05:33 +0200 Message-ID: <20250531190534.94684-2-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250531190534.94684-1-hansg@kernel.org> References: <20250531190534.94684-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Hans de Goede probe() requests the reset GPIO to be set to high when getting it. Immeditately after this hi556_resume() is called and sets the GPIO low. If the GPIO was low before requesting it this will result in the GPIO only very briefly spiking high and the sensor not being properly reset. The same problem also happens on back to back runtime suspend + resume. Fix this by adding a sleep of 2 ms in hi556_resume() before setting the GPIO low (if there is a reset GPIO). The final sleep is kept unconditional, because if there is e.g. no reset GPIO but a controllable clock then the sensor also needs some time after enabling the clock. Signed-off-by: Hans de Goede --- drivers/media/i2c/hi556.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/hi556.c b/drivers/media/i2c/hi556.c index aed258211b8a..d3cc65b67855 100644 --- a/drivers/media/i2c/hi556.c +++ b/drivers/media/i2c/hi556.c @@ -1321,7 +1321,12 @@ static int hi556_resume(struct device *dev) return ret; } - gpiod_set_value_cansleep(hi556->reset_gpio, 0); + if (hi556->reset_gpio) { + /* Assert reset for at least 2ms on back to back off-on */ + usleep_range(2000, 2200); + gpiod_set_value_cansleep(hi556->reset_gpio, 0); + } + usleep_range(5000, 5500); return 0; } From patchwork Sat May 31 19:05:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 893594 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 241D112F5A5 for ; Sat, 31 May 2025 19:05:49 +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=1748718349; cv=none; b=HGZQpbOH5iX2bu/ngTnYdylsUmzq+XBYBjB/NGs0plRWwoIuSas2dEl08Gq4GK025xakF+WxB3ItonmnCgdYrBoORtt2+UGc+XauMk4aQP217W8SVZ2O9bfiVtssCOPjJlJxO30aoX+hptbIEk0a0bxlhMXISpRsErVd6D05bTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748718349; c=relaxed/simple; bh=dp/scgIHX9go4ioONDi5Tw7mpr9mAUD6/zTwDHcF5mU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RIybAlgKw96RtpY43wGA5A8boyRSxJlKP/7GQpW8jsnzenpQ9d1Bbt/dXRPAhACCvD7tpwxanK2u8KdcXv/9DHcGJOn2vjHrAjGh/GPkp0mfUPUgpmIMdImLaQCe6uQ/LgpoSfZgpNuh7t7X8pqRlL1mSnoeEFoOK5rcN9iIWNo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=U1DWXxDZ; 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="U1DWXxDZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8A95C4CEE3; Sat, 31 May 2025 19:05:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748718349; bh=dp/scgIHX9go4ioONDi5Tw7mpr9mAUD6/zTwDHcF5mU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U1DWXxDZvTf16hnZi/2PZ0VsKVj0h/byIrajw2Wd7pUAQPMU3kGundo82WGkvtOAK Lwh4B/6a9uUL7bARX5/vKQIP6OWa1BmXnHzDkcOze2PpFt6zOhCtdP9Gjy7xfQ3+7w pmLAS9Tot7OOik0qwQtrcFqrqOqMOntOuKkMKtGzxEboEVrB4eU1tncGJYZZkTOtvN 6uCMtMuFKmUC++XwmincJHoahtoTM0UYx9K2TC+t0gmbY3UGQacSBX0mF47PL6agIa mwXNDLLsyFCHOa19Tbpu2TbZAHwPSbFO8YiJRDrU0beyMfUGmAWqLXOVPWG/FTv7FV zh3yCKHNU2rCA== From: Hans de Goede To: Sakari Ailus Cc: Hans de Goede , Mauro Carvalho Chehab , linux-media@vger.kernel.org Subject: [PATCH 2/2] media: hi556: Support full range of power rails Date: Sat, 31 May 2025 21:05:34 +0200 Message-ID: <20250531190534.94684-3-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250531190534.94684-1-hansg@kernel.org> References: <20250531190534.94684-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Hans de Goede Use regulator_bulk_* to get the array of potential power rails for the hi556. Previously the driver only supported avdd as only avdd is used on IPU6 designs. But other designs may also need the driver to control the other power rails and the new INT3472 handshake support also makes use of dvdd on IPU6 designs. Link: https://bugzilla.redhat.com/show_bug.cgi?id=2368506 Signed-off-by: Hans de Goede --- drivers/media/i2c/hi556.c | 40 +++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/drivers/media/i2c/hi556.c b/drivers/media/i2c/hi556.c index d3cc65b67855..110dd00c51ae 100644 --- a/drivers/media/i2c/hi556.c +++ b/drivers/media/i2c/hi556.c @@ -624,6 +624,12 @@ static const struct hi556_mode supported_modes[] = { }, }; +static const char * const hi556_supply_names[] = { + "dovdd", /* Digital I/O power */ + "avdd", /* Analog power */ + "dvdd", /* Digital core power */ +}; + struct hi556 { struct v4l2_subdev sd; struct media_pad pad; @@ -639,7 +645,7 @@ struct hi556 { /* GPIOs, clocks, etc. */ struct gpio_desc *reset_gpio; struct clk *clk; - struct regulator *avdd; + struct regulator_bulk_data supplies[ARRAY_SIZE(hi556_supply_names)]; /* Current mode */ const struct hi556_mode *cur_mode; @@ -1289,17 +1295,10 @@ static int hi556_suspend(struct device *dev) { struct v4l2_subdev *sd = dev_get_drvdata(dev); struct hi556 *hi556 = to_hi556(sd); - int ret; gpiod_set_value_cansleep(hi556->reset_gpio, 1); - - ret = regulator_disable(hi556->avdd); - if (ret) { - dev_err(dev, "failed to disable avdd: %d\n", ret); - gpiod_set_value_cansleep(hi556->reset_gpio, 0); - return ret; - } - + regulator_bulk_disable(ARRAY_SIZE(hi556_supply_names), + hi556->supplies); clk_disable_unprepare(hi556->clk); return 0; } @@ -1314,9 +1313,10 @@ static int hi556_resume(struct device *dev) if (ret) return ret; - ret = regulator_enable(hi556->avdd); + ret = regulator_bulk_enable(ARRAY_SIZE(hi556_supply_names), + hi556->supplies); if (ret) { - dev_err(dev, "failed to enable avdd: %d\n", ret); + dev_err(dev, "failed to enable regulators: %d", ret); clk_disable_unprepare(hi556->clk); return ret; } @@ -1335,7 +1335,7 @@ static int hi556_probe(struct i2c_client *client) { struct hi556 *hi556; bool full_power; - int ret; + int i, ret; ret = hi556_check_hwcfg(&client->dev); if (ret) @@ -1358,11 +1358,15 @@ static int hi556_probe(struct i2c_client *client) return dev_err_probe(&client->dev, PTR_ERR(hi556->clk), "failed to get clock\n"); - /* The regulator core will provide a "dummy" regulator if necessary */ - hi556->avdd = devm_regulator_get(&client->dev, "avdd"); - if (IS_ERR(hi556->avdd)) - return dev_err_probe(&client->dev, PTR_ERR(hi556->avdd), - "failed to get avdd regulator\n"); + for (i = 0; i < ARRAY_SIZE(hi556_supply_names); i++) + hi556->supplies[i].supply = hi556_supply_names[i]; + + ret = devm_regulator_bulk_get(&client->dev, + ARRAY_SIZE(hi556_supply_names), + hi556->supplies); + if (ret) + return dev_err_probe(&client->dev, ret, + "failed to get regulators\n"); full_power = acpi_dev_state_d0(&client->dev); if (full_power) {