Skip to content

GPIO Acquire/Release Semantics for 'AI Camera' #6884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: rpi-6.12.y
Choose a base branch
from

Conversation

roliver-rpi
Copy link
Contributor

No description provided.

@roliver-rpi roliver-rpi requested review from 6by9 and naushir June 5, 2025 13:02
Copy link
Contributor

@6by9 6by9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest all looks sane, even if the whole thing is rather icky in the first place.

Add support for the 'gpio-gate-clock-releasing' compatible string. The
behaviour is identical to that of 'gpio-gate-clock' but the gpio is
acquired on 'enable' and released on 'disable'.

Signed-off-by: Richard Oliver <richard.oliver@raspberrypi.com>
Document the gpio-gate-clock-releasing compatible string that enables
acquire/release GPIO semantics on gpio-gated clocks.

Signed-off-by: Richard Oliver <richard.oliver@raspberrypi.com>
The clock using by IMX500 in 'AI Camera' is gpio-gated. The GPIO used is
provided by an I2C-controlled rpi-rp2040-gpio-bridge on 'AI Camera'.
Both the IMX500 and gpio-bridge share a common regulator for their power
supply. Using 'gpio-gate-clock', the 'AI Camera' will never be
powered-down as the GPIO provided by the gpio-bridge is always claimed
by the clock driver. Switching to 'gpio-gate-clock-releasing' causes the
GPIO to be released by the clock driver when the clock is not needed.
This allows 'AI Camera' to be powered-down.

Signed-off-by: Richard Oliver <richard.oliver@raspberrypi.com>
This change amends various error-paths in imx500_start_streaming() to
ensure that pm_runtime refcounts do not remain erroneously incremented
on failure.

Signed-off-by: Richard Oliver <richard.oliver@raspberrypi.com>
When the imx500 driver is used as part of the 'AI Camera', the poweroff
state is never reached as the camera and gpio driver share a regulator.
By releasing the GPIOs when they are not in use, 'AI Camera' is able to
achieve a powered-down state.

Signed-off-by: Richard Oliver <richard.oliver@raspberrypi.com>
@roliver-rpi roliver-rpi force-pushed the dev/roliver/ai_camera_gpio_acquire_release branch from 7a6146a to 52ecb02 Compare June 6, 2025 09:54
@roliver-rpi
Copy link
Contributor Author

I believe all the review comments have been addressed. Are we happy for this to go in @6by9?

@6by9
Copy link
Contributor

6by9 commented Jun 9, 2025

Looks good to me.

Copy link
Contributor

@pelwell pelwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that there is no reference counting and no intention of re-entrancy or simultaneous use (at least by this driver), doesn't it point to a programming error for clk_gpio_gate_is_acquired to find that the GPIO is already acquired? In which case, given that clk_gpio_gate_acquire has an error return, why not drop clk_gpio_gate_is_acquired altogether and call ...acquire unconditionally?

{
struct clk_gpio *clk = to_clk_gpio(hw);

return clk->gpiod;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you are declaring non-zero to indicate success (although I'd have preferred !!clk->gpiod to make the type conversion more obvious), but clk_gpio_get_acquire leaves it containing an error code on failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants