Skip to content
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 support for Pi 5 #5618

Merged
merged 142 commits into from
Sep 28, 2023
Merged

Add support for Pi 5 #5618

merged 142 commits into from
Sep 28, 2023

Conversation

popcornmix
Copy link
Collaborator

Add support for Pi 5.

This supports the new hardware in BCM2712 and RP1.

There are two 64-bit defconfig options.

bcm2711_defconfig will support all 64-bit Pi devices and uses a pagesize of 4K
bcm2712_defconfig switches to a 64K pagesize, and only works on Pi 5.

@6by9
Copy link
Contributor

6by9 commented Sep 28, 2023

@popcornmix We want to drop the top 3 patches marked DNI (Do Not Integrate) that mess with the workflow files.

@pelwell
Copy link
Contributor

pelwell commented Sep 28, 2023

And the first PCIe reset revert can be replaced with upstream commit 8eb8c27.

@pelwell
Copy link
Contributor

pelwell commented Sep 28, 2023

On the subject of workflow files, as long as we continue to guarantee that the only difference between bcm2712_defconfig and bcm2711_defconfig is the page size, we can omit a Pi 5-specific test build.

@6by9
Copy link
Contributor

6by9 commented Sep 28, 2023

On the subject of workflow files, as long as we continue to guarantee that the only difference between bcm2712_defconfig and bcm2711_defconfig is the page size, we can omit a Pi 5-specific test build.

It probably has some gain though in order to be able to use rpi-update to grab the appropriate build artifacts though (I'm hoping rpi-update looks at that bit of the extension too - I've not checked).

@pelwell
Copy link
Contributor

pelwell commented Sep 28, 2023

I've bumped overlaycheck in the utils repo, so subsequent pushes should pass.

@pelwell
Copy link
Contributor

pelwell commented Sep 28, 2023

rpi-update will need to grow a WANT_PI5 flag.

@popcornmix
Copy link
Collaborator Author

Updated (@pelwell please check pcie-bcmstb.c - it is now not the same as initial PR).

@popcornmix
Copy link
Collaborator Author

rpi-firmware will need the additional kernel2712.img built (and rpi-update will need checking that it copies it).
I'll also check what rpi-update from a PR does.

But I think we'll need the additional build artifact - otherwise rpi-update will bump you from a 16K pagesize to a 4K pagesize.

@pelwell
Copy link
Contributor

pelwell commented Sep 28, 2023

Updated (@pelwell please check pcie-bcmstb.c - it is now not the same as initial PR).

pcie-brcmstb.c now matches rpi-6.6.y in that respect. I'm happy this part needed changing to sit on top of that upstream change, but perhaps this is the wrong outcome. The question is whether PERST# also needs to be asserted on BCM2712 - the safe thing would be to add that case to the condition, since that matches the old behaviour, and then drop it if we decide it isn't necessary. I'll add a patch to that effect.

But I think we'll need the additional build artifact - otherwise rpi-update will bump you from a 16K pagesize to a 4K pagesize.

OK - I'll add the build type to the workflow.

@pelwell
Copy link
Contributor

pelwell commented Sep 28, 2023

I'll add a patch to that effect.

After discussion with Tim this is currently unnecessary because the bootloader does leave it reset, so I won't add such a patch at this time.

@popcornmix
Copy link
Collaborator Author

After discussion with Tim this is currently unnecessary because the bootloader does leave it reset, so I won't add such a patch at this time.

So current PR is good (wrt pcie-bcmstb.c)?

@pelwell
Copy link
Contributor

pelwell commented Sep 28, 2023

Yes, I think so.

I've bumped the workflows. There is still some issue with one of the overlays that I'll look at next.

@pelwell
Copy link
Contributor

pelwell commented Sep 28, 2023

@6by9 in vc4-kms-dsi-7inch-overlay.dts it references ts_i2c_frag, but no such label exists. I think the node you are aiming for is currently labelled frag13, but that doesn't fit with the nice user-friendly labels the rest of that file uses. However, changing edt-ft5406.dtsi could break edt-ft5406-overlay.dts

Would you like me to:
a. add ts_i2c_frag as a second label into edt-ft5406.dti,
b. add ts_i2c_frag as an alias but inside vc4-kms-v3d-pi5-overlay.dts,
c. change vc4-kms-v3d-pi5-overlay.dts to use frag13, or
d. change everything to use ts_i2c_frag instead?

@6by9
Copy link
Contributor

6by9 commented Sep 28, 2023

in vc4-kms-dsi-7inch-overlay.dts it references ts_i2c_frag, but no such label exists.

See commit d6e6b9a on the private branch. It just missed the cutoff yesterday, and looks like popcornmix hasn't included it in this PR or merged it into "dts: 2712: Update for device tree"

@6by9
Copy link
Contributor

6by9 commented Sep 28, 2023

DRM/KMS unit tests failing appears to be a build failure due to part of raspberrypi-gpiomem.c

2023-09-28T14:52:58.7457288Z ../drivers/char/raspberrypi-gpiomem.c:104:37: error: implicit declaration of function ‘phys_mem_access_prot’; did you mean ‘phys_mem_access_prot_allowed’? [-Werror=implicit-function-declaration]
2023-09-28T14:52:58.7457878Z [14:49:36] Configuring KUnit Kernel ...
2023-09-28T14:52:58.7500841Z   104 |                 vma->vm_page_prot = phys_mem_access_prot(file, base, len,
2023-09-28T14:52:58.7501241Z Generating .config ...
2023-09-28T14:52:58.7501769Z       |                                     ^~~~~~~~~~~~~~~~~~~~
2023-09-28T14:52:58.7502250Z       |                                     phys_mem_access_prot_allowed
2023-09-28T14:52:58.7503042Z ../drivers/char/raspberrypi-gpiomem.c:104:37: error: incompatible types when assigning to type ‘pgprot_t’ from type ‘int’

I'm not totally clear why it's even building gpiomem.

KUnit Tests/VC4 are failing as the test vc4/tests/vc4_test_lbm_size.c needs updating for the lbm_size having moved.
That should be easy to fix.

@pelwell
Copy link
Contributor

pelwell commented Sep 28, 2023

So, option d then. Cherry-picked.

@pelwell
Copy link
Contributor

pelwell commented Sep 28, 2023

Upstream build fixup pushed.

@6by9
Copy link
Contributor

6by9 commented Sep 28, 2023

VC4 unit tests fixed with 6by9@950224c (I'm not sure I can do a push to popcornmix's branch.

@6by9
Copy link
Contributor

6by9 commented Sep 28, 2023

drivers/char/Kconfig has RASPBERRYPI_GPIOMEM default to y. That would explain the build breakage for the generic unit tests, but is that what we want?
I guess if we default to not building it then the defconfig needs updating. As it's providing userspace access it could be a module, and only on 2711/2712 rather than all kernels.

The old BCM2835_DEVGPIOMEM option for bcm2835-gpiomem was a module.

@pelwell
Copy link
Contributor

pelwell commented Sep 28, 2023

Defaulting the gpiomem to a module makes sense - it's an anomaly that it isn't already.

@6by9
Copy link
Contributor

6by9 commented Sep 28, 2023

Commits 6by9@430bb5b and 6by9@bde073f sort the generic unit test CI failure.

430bb5b wants to go before "drivers: char: delete bcm2835-gpiomem", and bde073f fixes up "drivers: char: delete bcm2835-gpiomem".

popcornmix and others added 6 commits September 28, 2023 18:12
dtoverlays: Fix up edt5406 entries to match with vc4-kms-dsi-7inch

vc4-kms-dsi-7inch expects the touch fragment to be named ts_i2c_frag,
but edt5406 didn't do this.

Fixes: 736d601 ("dts: 2712: Update for device tree")

Signed-off-by: Dave Stevenson <[email protected]>
gpio-brcmstb: Report the correct bank width

gpio: brcmstb: Use bank address as gpiochip label

If the path to the device node is used as gpiochip label then
gpio-brcmstb instances with multiple banks end up with duplicated
names. Instead, use a combination of the driver name with the physical
address of the bank, which is both unique and helpful for devmem
debugging.

Signed-off-by: Phil Elwell <[email protected]>

gpio: mmio: Add DIRECT mode for shared access

The generic MMIO GPIO library uses shadow registers for efficiency,
but this breaks attempts by raspi-gpio to change other GPIOs in the
same bank. Add a DIRECT mode that makes fewer assumptions about the
existing register contents, but note that genuinely simultaneous
accesses are likely to lose updates.

Signed-off-by: Phil Elwell <[email protected]>

gpio: brcmstb: Don't always clear interrupt mask

If the GPIO controller is not being used as an interrupt source
leave the interrupt mask register alone. On BCM2712 it might be used
to generate interrupts to the VPU firmware, and on other devices it
doesn't matter since no interrupts will be generated.

Signed-off-by: Phil Elwell <[email protected]>
pinctrl: bcm2712: Reject invalid pulls

Reject attempts to set pulls on aon-sgpios, and fix pull shift
values.

pinctrl: bcm2712: Add 7712 support, fix 2712 count

Signed-off-by: Phil Elwell <[email protected]>

pinctrl-bcm2712: add EMMC pins so pulls can be set

These pins have pad controls but not mux controls. They look enough like
GPIOs to squeeze in at the end of the list though.

pinctrl: bcm2712: correct BCM2712C0 AON_GPIO pad pull control offset

Signed-off-by: Jonathan Bell <[email protected]>

pinctrl: bcm2712: on C0 the regular GPIO pad control register moves too

Signed-off-by: Jonathan Bell <[email protected]>

pinctrl: bcm2712: Implement (partially) pinconf_get

Signed-off-by: Phil Elwell <[email protected]>

pinctrl: bcm2712: Convert to generic pinconf

Remove the legacy brcm,* pin configuration support and replace it with
a proper generic pinconf interface, using named functions instead of
alt function numbers. This is nicer for users, less error-prone, and
immune to some of the C0->D0 changes.

Signed-off-by: Phil Elwell <[email protected]>

pinctrl: bcm2712: Remove vestigial pull parameter

Now the legacy brcm, pinconf parameters are no longer supported, this
custom pin config parameter is not needed.

Signed-off-by: Phil Elwell <[email protected]>

pinctrl: bcm2712: Guard against bad func numbers

Signed-off-by: Phil Elwell <[email protected]>

pinctrl: bcm2712: A better attempt at D0 support

The BCM2712D0 sparse pinctrl maps play havoc with the old GPIO_REGS
macro, so make the bit positions explicit. And delete the unwanted
GPIO and pinmux declarations on D0.

Note that a Pi 5 with D0 requires a separate DTS file with "bcm2712d0"
compatible strings.

Signed-off-by: Phil Elwell <[email protected]>

pinctrl: bcm2712: Delete base register constants

BCM2712D0 deletes many GPIOs and their associated mux and pad bits,
so much so that the offsets to the start of the pad control registers
changes. Remove the constant offsets from the *GPIO_REGS macros,
compensating by adjusting the per-GPIO values.

Signed-off-by: Phil Elwell <[email protected]>
mripard and others added 20 commits September 28, 2023 18:12
The BCM2712 has an evolution of what used to be called TXP in the
earlier SoCs, but is now called MOP.

There's a few differences still, so we can add a new compatible to deal
with them easily.

Signed-off-by: Maxime Ripard <[email protected]>
The BCM2712 features a simpler TXP called MOPLET. Let's add support for
it.

Signed-off-by: Maxime Ripard <[email protected]>
Some code path in vc4 are conditional to a generation and cannot be
executed on others. Let's put a WARN_ON if that ever happens.

Signed-off-by: Maxime Ripard <[email protected]>
Testing whether the VideoCore generation we want to mock is vc5 or vc4
worked so far, but will be difficult to extend to support BCM2712 (VC6).

Convert to a switch.

Signed-off-by: Maxime Ripard <[email protected]>
The DRM device pointer and the DRM encoder pointer are redundant, since
the latter is attached to the former and we can just follow the
drm_encoder->dev pointer.

Let's remove the drm_device pointer argument.

Signed-off-by: Maxime Ripard <[email protected]>
Some tests will need to retrieve the output that was just allocated by
vc4_mock_atomic_add_output().

Instead of making them look them up in the DRM device, we can simply
make vc4_mock_atomic_add_output() return an error pointer that holds the
allocated output instead of the error code.

Signed-off-by: Maxime Ripard <[email protected]>
The BCM2712 has a simpler pipeline that can only output to a writeback
connector and two HDMI controllers.

Let's allow our kunit tests to create a mock of that pipeline.

Signed-off-by: Maxime Ripard <[email protected]>
The BCM2712 has a simpler pipeline than the BCM2711, and thus the muxing
requirements are different. Create some tests to make sure we get proper
muxing decisions.

Signed-off-by: Maxime Ripard <[email protected]>
The name collide with the Full KMS functions that are going to be made
public.

Signed-off-by: Maxime Ripard <[email protected]>
The current mock planes were just using the regular drm_plane_state,
while the driver expect struct vc4_plane_state that subclasses
drm_plane_state.

Hook the proper implementations of reset, duplicate_state, destroy and
atomic_check to create vc4_plane_state.

Signed-off-by: Maxime Ripard <[email protected]>
Some tests will need to find a plane to run a test on for a given CRTC.
Let's create a small helper to do that.

Signed-off-by: Maxime Ripard <[email protected]>
We'll start to add some tests for the plane state logic, so let's create
a helper to add a plane to an existing atomic state.

Signed-off-by: Maxime Ripard <[email protected]>
We'll start testing our planes code in situations where we will use more
than XRGB8888, so let's add a few common pixel formats.

Signed-off-by: Maxime Ripard <[email protected]>
The BCM2712 comes with a different LBM size computation than the
previous generations, so let's add the few examples provided as kunit
tests to make sure we always satisfy those requirements.

Signed-off-by: Maxime Ripard <[email protected]>
On 2712, the firmware always runs these clock at a speed sufficient
for dual 4kp60.

The requests here prevent the gpu from going into its lowest voltage
mode, so just skip the clock requests.

With this applied the idle voltage on my pi 5 reduces from 0.7424V
to 0.72V.

Signed-off-by: Dom Cobley <[email protected]>
Avoid double buffering LBM allocations by making the
allocation a single alloc per crtc at atomic_flush.

Signed-off-by: Dave Stevenson <[email protected]>
vc4 has always fixed up the timing, so the values defined have
never actually appeared on the wire.
The display appears to want a slightly longer HFP, so extend
the timings and recompute the clock to give the same frame rate.

Signed-off-by: Dave Stevenson <[email protected]>
The 10.1" panel doesn't work with the timings defined. vc4
will always have been fixing up the timing due to the limited
integer divider, so compute the fixed up mode and use it
directly.

Signed-off-by: Dave Stevenson <[email protected]>
The driver does not lock the imx477 mutex when calling
imx477_set_framing_limits(), leading to:

WARNING: CPU: 3 PID: 426 at drivers/media/v4l2-core/v4l2-ctrls-api.c:934 __v4l2_ctrl_modify_range+0x1a0/0x210 [
videodev]

Fix this by taking the lock.

Signed-off-by: Tomi Valkeinen <[email protected]>
@popcornmix
Copy link
Collaborator Author

I believe I've squashed in commits that have been pushed/mentioned. Anything missing?

@pelwell
Copy link
Contributor

pelwell commented Sep 28, 2023

Nope - that looks good to me if the checks are passing.

@pelwell pelwell merged commit 2d3d203 into raspberrypi:rpi-6.1.y Sep 28, 2023
11 of 12 checks passed
@popcornmix popcornmix deleted the pi5_61 branch September 29, 2023 09:57
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Sep 29, 2023
popcornmix added a commit to raspberrypi/rpi-firmware that referenced this pull request Sep 29, 2023
ywbyun0815 pushed a commit to webosose/meta-webosose that referenced this pull request Nov 5, 2024
:Release Notes:
bcm2835-gpiomem was replaced by raspberrypi-gpiomem
with support for Pi 5

:Detailed Notes:
raspberrypi/linux#5618
raspberrypi/linux@36f254f
raspberrypi/linux@27bda80

:Testing Performed:
Only build tested.

:QA Notes:
Extra module installed into rpi image.

:Issues Addressed:
[WRR-2163] CCC: webos-rpi.inc: update gpiomem kernel module name

Cherry-picked-from-commit: c617f94170d2cf9d3fd4bbbffc61188110c359dd
Cherry-picked-from-branch:
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.