-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Add a camera regulator node(s) to allow sharing on CM4 and remove firmware nastiness #4051
Conversation
@naushir Could you give this a quick test on your system(s)? It works for me, but I've only really tested CM4 and Pi4 and IMX477 and OV9281. All the others are pretty much copy/paste, but any greater test coverage would be appreciated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From reading it through it looks like it would work, but there's a lot of repetition. Would you consider either pushing both regulators into a common base dtsi file (or files) or a new file created for the purpose, then overriding just the gpio declarations in the per-board files?
@@ -16,7 +31,7 @@ | |||
|
|||
&gpio { | |||
spi0_pins: spi0_pins { | |||
brcm,pins = <9 10 11>; | |||
brcm,pins = < 9 10 11>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace.
@@ -603,3 +611,4 @@ | |||
<&spi0>, "dmas:8=", <&dma40>; | |||
}; | |||
}; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace
}; | ||
|
||
aliases { | ||
cam0_reg = &cam1_reg; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll have to explain this, especially as it's the only cam_reg alias.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably where I've got it wrong between aliases and labels.
CM4 shares the same GPIO to control both CAM0 & CAM1, so I want the same regulator node to be referenced as either cam1_reg or cam0_reg from overlays.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internal references usually require phandles, which are the compiled equivalent of labels. Just put a second, cam0_reg
label on the cam1_reg
node.
@@ -65,6 +65,18 @@ | |||
enable-active-high; | |||
gpio = <&expgpio 6 GPIO_ACTIVE_HIGH>; | |||
}; | |||
|
|||
cam1_reg: cam1_reg { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer these patches to go after the "Downstream rpi- changes" comment below.
Sure, happy to make whatever changes you want. It was easier to create the PR and get comments than to discuss abstracts. |
Yes - I'd much rather discuss something concrete. |
3403b48
to
ab9e2a6
Compare
Looking at this, the CM4 config which wants
vs the rest which want
is the awkward bit. A couple of options I can think of:
so each platform could then do
except that the included file isn't a complete dt description. Preference? I'm assuming the former. |
e742136
to
9a4a1be
Compare
On the assumption that the former approach was going to be preferred, I've made the updates (and removed the whitespace issues). It also makes things clearer as it's rebased the branch. |
9a4a1be
to
e267db1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is technically possible to have a common include file that declares both regulators. The labels can be attached by the including file by changing:
&cam1_reg {
to:
cam1_reg: /cam1_reg {
This is not a request, just something to consider.
Having said that, I'm largely happy with the current state of the PR except for the bits that still need deleting and (from what I could see) the absence of the file to be included.
As cam0 physically doesn't exist on most of these platforms I'd prefer for the regulator node not to exist either, otherwise it's likely to cause confusion. And the good old forgetting to |
The current firmware fixup of camera sensor overlays is not particularly nice, and it stops you being able to load them dynamically. It's also incompatible with creating a simple DT that can be loaded for both CAM1 and CAM0 on a CM as they would both try to claim the one GPIO. Almost all sensors have a hook of some form for a regulator, so it's relatively straightforward to convert them all to use a fixed regulator with GPIO control. Add a fixed regulator node for each platform with the GPIO correctly configured for the camera shutdown line. (The LED line is ignored). Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Update those overlays that use the regulator framework to use the new cam1_reg node to control the camera shutdown line, and remove the firmware workaround nodes. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
e267db1
to
82d65b6
Compare
Updated. |
Do you think someone might want an overlay that can target either camera port, selectable by a parameter? I believe that the lack of a label in the base DTB that is referred to be the overlay will currently prevent such an overlay being applied, even if it is the target of a dormant fragment. On second thoughts, it might be better to fix this case in the overlay application mechanisms. |
I was considering whether we can parameterise some of the overlays as it would be nice for them to be generic. I'm rebuilding due to the bump to 5.10.6 at present, but will experiment when complete to see if it fails. I think it may make the overlay overly complex anyway, as the csiN endpoint has to point to the sensor endpoint and vice versa. Then again aren't those labels only local to the overlay, so irrelevant whilst applying the second one? eg https://github.com/raspberrypi/linux/blob/rpi-5.10.y/arch/arm/boot/dts/overlays/ov9281-overlay.dts |
I'm happy to merge as is - things can still be changed should the need arise. |
I'm happy if you're happy! The intent of having cam1_reg and cam0_reg should remain from now on, but the exact use of those from within overlays can be tweaked. |
kernel: overlays: seeed-can-fd-hat: clarify how to identify HAT version See: raspberrypi/linux#4072 kernel: Add a camera regulator node(s) to allow sharing on CM4 and remove firmware nastiness See: raspberrypi/linux#4051 firmware: isp: Fix handling of different YUV colour spaces firmware: poe_hat: Actually close the I2C handle
kernel: overlays: seeed-can-fd-hat: clarify how to identify HAT version See: raspberrypi/linux#4072 kernel: Add a camera regulator node(s) to allow sharing on CM4 and remove firmware nastiness See: raspberrypi/linux#4051 firmware: isp: Fix handling of different YUV colour spaces firmware: poe_hat: Actually close the I2C handle
kernel: overlays: seeed-can-fd-hat: clarify how to identify HAT version See: raspberrypi/linux#4072 kernel: Add a camera regulator node(s) to allow sharing on CM4 and remove firmware nastiness See: raspberrypi/linux#4051 firmware: isp: Fix handling of different YUV colour spaces firmware: poe_hat: Actually close the I2C handle Signed-off-by: Christian Stewart <christian@paral.in>
kernel: overlays: seeed-can-fd-hat: clarify how to identify HAT version See: raspberrypi/linux#4072 kernel: Add a camera regulator node(s) to allow sharing on CM4 and remove firmware nastiness See: raspberrypi/linux#4051 firmware: isp: Fix handling of different YUV colour spaces firmware: poe_hat: Actually close the I2C handle Signed-off-by: Christian Stewart <christian@paral.in>
kernel: overlays: seeed-can-fd-hat: clarify how to identify HAT version See: raspberrypi/linux#4072 kernel: Add a camera regulator node(s) to allow sharing on CM4 and remove firmware nastiness See: raspberrypi/linux#4051 firmware: isp: Fix handling of different YUV colour spaces firmware: poe_hat: Actually close the I2C handle Signed-off-by: Christian Stewart <christian@paral.in>
kernel: overlays: seeed-can-fd-hat: clarify how to identify HAT version See: raspberrypi/linux#4072 kernel: Add a camera regulator node(s) to allow sharing on CM4 and remove firmware nastiness See: raspberrypi/linux#4051 firmware: isp: Fix handling of different YUV colour spaces firmware: poe_hat: Actually close the I2C handle Signed-off-by: Christian Stewart <christian@paral.in>
kernel: overlays: seeed-can-fd-hat: clarify how to identify HAT version See: raspberrypi/linux#4072 kernel: Add a camera regulator node(s) to allow sharing on CM4 and remove firmware nastiness See: raspberrypi/linux#4051 firmware: isp: Fix handling of different YUV colour spaces firmware: poe_hat: Actually close the I2C handle Signed-off-by: Christian Stewart <christian@paral.in>
kernel: overlays: seeed-can-fd-hat: clarify how to identify HAT version See: raspberrypi/linux#4072 kernel: Add a camera regulator node(s) to allow sharing on CM4 and remove firmware nastiness See: raspberrypi/linux#4051 firmware: isp: Fix handling of different YUV colour spaces firmware: poe_hat: Actually close the I2C handle Signed-off-by: Christian Stewart <christian@paral.in>
kernel: overlays: seeed-can-fd-hat: clarify how to identify HAT version See: raspberrypi/linux#4072 kernel: Add a camera regulator node(s) to allow sharing on CM4 and remove firmware nastiness See: raspberrypi/linux#4051 firmware: isp: Fix handling of different YUV colour spaces firmware: poe_hat: Actually close the I2C handle Signed-off-by: Christian Stewart <christian@paral.in>
At the moment the firmware fixes up where the camera shutdown line goes, which means those overlays can't be dynamically loaded.
Because the overlays are claiming GPIOs it also means there isn't an easy way to load a very similar overlay for both CAM0 and CAM1 on a CM4 where the same GPIO is shared for both camera modules.
Adds a new cam1_reg node (and cam0_reg on CMs), and update those overlays that use regulators to use it.