platform/kernel/linux-rpi.git
3 years agokbuild: Silence unavoidable dtc overlay warnings
Phil Elwell [Fri, 29 Jan 2021 10:34:11 +0000 (10:34 +0000)]
kbuild: Silence unavoidable dtc overlay warnings

Much effort has been put into finding ways to avoid warnings from dtc
about overlays, usually to do with the presence of #address-cells and
size-cells, but not exclusively so. Since the issues being warned about
are harmless, suppress the warnings to declutter the build output and
to avoid alarming users.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agospi: bcm2835: Workaround/fix for zero-length transfers
Phil Elwell [Thu, 28 Jan 2021 11:30:04 +0000 (11:30 +0000)]
spi: bcm2835: Workaround/fix for zero-length transfers

A relatively recent commit ([1]) contained optimisation for the PIO
SPI FIFO-filling functions. The commit message includes the phrase
"[t]he blind and counted loops are always called with nonzero count".
This is technically true, but it is still possible for count to become
zero before the loop is entered - if tfr->len is zero. Moving the loop
exit condition to the end of the loop saves a few cycles, but results
in a near-infinite loop should the revised count be zero on entry.

Strangely, zero-lengthed transfers aren't filtered by the SPI framework
and, even more strangely, the Python3 spidev library is triggering them
for no obvious reason.

Avoid the problem completely by bailing out of the main transfer
function early if trf->len is zero, although there may be a case for
moving the mitigation into the framework.

See: https://github.com/raspberrypi/linux/issues/4100

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
[1] 26751de25d25 ("spi: bcm2835: Micro-optimise FIFO loops")

3 years agoconfigs: Add CRYPTO_ADIANTUM=m
Phil Elwell [Fri, 22 Jan 2021 16:15:06 +0000 (16:15 +0000)]
configs: Add CRYPTO_ADIANTUM=m

See: https://github.com/raspberrypi/linux/issues/3648

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agoconfigs: Add NVMEM_RMEM=m for 2711
Phil Elwell [Fri, 22 Jan 2021 12:08:19 +0000 (12:08 +0000)]
configs: Add NVMEM_RMEM=m for 2711

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agoARM: multi_v7_defconfig: Enable nvmem's rmem driver
Nicolas Saenz Julienne [Fri, 11 Dec 2020 12:15:41 +0000 (13:15 +0100)]
ARM: multi_v7_defconfig: Enable nvmem's rmem driver

It'll be used by the RPi4 family of boards to access its bootloader
configuration.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
3 years agoarm64: defconfig: Enable nvmem's rmem driver
Nicolas Saenz Julienne [Fri, 11 Dec 2020 12:04:37 +0000 (13:04 +0100)]
arm64: defconfig: Enable nvmem's rmem driver

It'll be used by the RPi4 family of boards to access its bootloader
configuration.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
3 years agoARM: dts: bcm2711: Add reserved memory template to hold firmware configuration
Nicolas Saenz Julienne [Fri, 11 Dec 2020 11:22:01 +0000 (12:22 +0100)]
ARM: dts: bcm2711: Add reserved memory template to hold firmware configuration

RPi4's co-processor will copy the board's bootloader[1] configuration
into memory for the OS to consume. Specifically, for the bootloader
configuration and upgrade user-space routines to query it through
nvmem's sysfs interface.

Introduce a reserved-memory area template for the co-processor to edit
before booting the system so as for Linux not to overwrite that memory
and to expose it as an nvmem device.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
[1] https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2711_bootloader_config.md
---

Changes since v1:
 - Introduce compatible string
 - Change alias name to something more explicit

3 years agonvmem: Add driver to expose reserved memory as nvmem
Nicolas Saenz Julienne [Thu, 10 Dec 2020 11:13:49 +0000 (12:13 +0100)]
nvmem: Add driver to expose reserved memory as nvmem

Firmware/co-processors might use reserved memory areas in order to pass
data stemming from an nvmem device otherwise non accessible to Linux.
For example an EEPROM memory only physically accessible to firmware, or
data only accessible early at boot time.

In order to expose this data to other drivers and user-space, the driver
models the reserved memory area as an nvmem device.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---

Changes since v1:
 - Remove reserved memory phandle indirection by directly creating a
   platform device from the reserved memory DT node
 - Only map memory upon reading it to avoid corruption
 - Small cosmetic cleanups

3 years agodt-bindings: nvmem: Add bindings for rmem driver
Nicolas Saenz Julienne [Thu, 10 Dec 2020 18:22:45 +0000 (19:22 +0100)]
dt-bindings: nvmem: Add bindings for rmem driver

Firmware/co-processors might use reserved memory areas in order to pass
data stemming from an nvmem device otherwise non accessible to Linux.
For example an EEPROM memory only physically accessible to firmware, or
data only accessible early at boot time.

Introduce the dt-bindings to nvmem's rmem.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---

Changes since v1:
 - Update schema to new driver design

3 years agoconfigs: Add CONFIG_USB_NET_AQC111=m
Phil Elwell [Fri, 22 Jan 2021 09:28:06 +0000 (09:28 +0000)]
configs: Add CONFIG_USB_NET_AQC111=m

See: https://github.com/raspberrypi/linux/pull/4086

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agoconfigs: Add CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m
popcornmix [Thu, 21 Jan 2021 18:27:08 +0000 (18:27 +0000)]
configs: Add CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m

Signed-off-by: popcornmix <popcornmix@gmail.com>
3 years agostaging: vc04_services: ISP: Add colour denoise control
Naushir Patuck [Thu, 14 Jan 2021 09:20:52 +0000 (09:20 +0000)]
staging: vc04_services: ISP: Add colour denoise control

Add colour denoise control to the bcm2835 driver through a new v4l2
control: V4L2_CID_USER_BCM2835_ISP_CDN.

Add the accompanying MMAL configuration structure definitions as well.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
3 years agouapi: bcm2835-isp: Add colour denoise configuration
Naushir Patuck [Thu, 14 Jan 2021 09:18:42 +0000 (09:18 +0000)]
uapi: bcm2835-isp: Add colour denoise configuration

Add a configuration structure for colour denoise to the bcm2835_isp
driver.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
3 years agoconfigs: Enable BCM2835 thermal driver in kernel8
Phil Elwell [Tue, 19 Jan 2021 08:57:21 +0000 (08:57 +0000)]
configs: Enable BCM2835 thermal driver in kernel8

The arm64 version of bcm2711_defconfig is intended for Pi 4, but the
Raspberry Pi OS kernel8.img built from it is also used for Pi 3. It is
therefore necessary to include some legacy drivers such as the BCM2835
thermal driver, otherwise there is no support for reading the CPU
temperature on a Pi 3 in 64-bit mode.

See: https://github.com/raspberrypi/linux/issues/4077

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agovc4: Correct POS1_SCL for hvs5
Dom Cobley [Sun, 17 Jan 2021 17:07:02 +0000 (17:07 +0000)]
vc4: Correct POS1_SCL for hvs5

Fixes failure with 4096x1080 resolutions

[  284.315379] WARNING: CPU: 1 PID: 901 at drivers/gpu/drm/vc4/vc4_plane.c:981 vc4_plane_mode_set+0x1374/0x13c4
[  284.315385] Modules linked in: ir_rc5_decoder rpivid_hevc(C) bcm2835_codec(C) bcm2835_isp(C) bcm2835_mmal_vchiq(C) bcm2835_gpiomem v4l2_mem2mem videobuf2_dma_contig videobuf2_memops videobuf2_v4l2 videobuf2_common videodev mc cdc_acm xpad ir_rc6_decoder rc_rc6_mce gpio_ir_recv fuse
[  284.315509] CPU: 1 PID: 901 Comm: kodi.bin Tainted: G         C        5.10.7 #1
[  284.315514] Hardware name: BCM2711
[  284.315518] Backtrace:
[  284.315533] [<c0cc5ca0>] (dump_backtrace) from [<c0cc6014>] (show_stack+0x20/0x24)
[  284.315540]  r7:ffffffff r6:00000000 r5:68000013 r4:c18ecf1c
[  284.315549] [<c0cc5ff4>] (show_stack) from [<c0cca638>] (dump_stack+0xc4/0xf0)
[  284.315558] [<c0cca574>] (dump_stack) from [<c022314c>] (__warn+0xfc/0x158)
[  284.315564]  r9:00000000 r8:00000009 r7:000003d5 r6:00000009 r5:c08cc7dc r4:c0fd09b8
[  284.315572] [<c0223050>] (__warn) from [<c0cc67ec>] (warn_slowpath_fmt+0x74/0xe4)
[  284.315577]  r7:c08cc7dc r6:000003d5 r5:c0fd09b8 r4:00000000
[  284.315584] [<c0cc677c>] (warn_slowpath_fmt) from [<c08cc7dc>] (vc4_plane_mode_set+0x1374/0x13c4)
[  284.315589]  r8:00000000 r7:00000000 r6:00001000 r5:c404c600 r4:c2e34600
[  284.315596] [<c08cb468>] (vc4_plane_mode_set) from [<c08cc984>] (vc4_plane_atomic_check+0x40/0x1c0)
[  284.315601]  r10:00000001 r9:c2e34600 r8:c0e67068 r7:c0fc44e0 r6:c2ce3640 r5:c3d636c0
[  284.315605]  r4:c2e34600
[  284.315614] [<c08cc944>] (vc4_plane_atomic_check) from [<c0860504>] (drm_atomic_helper_check_planes+0xec/0x1ec)
[  284.315620]  r9:c2e34600 r8:c0e67068 r7:c0fc44e0 r6:c2ce3640 r5:c3d636c0 r4:00000006
[  284.315627] [<c0860418>] (drm_atomic_helper_check_planes) from [<c0860658>] (drm_atomic_helper_check+0x54/0x9c)
[  284.315633]  r9:c2e35400 r8:00000006 r7:00000000 r6:c2ba7800 r5:c3d636c0 r4:00000000
[  284.315641] [<c0860604>] (drm_atomic_helper_check) from [<c08b7ca8>] (vc4_atomic_check+0x25c/0x454)
[  284.315645]  r7:00000000 r6:c2ba7800 r5:00000001 r4:c3d636c0
[  284.315652] [<c08b7a4c>] (vc4_atomic_check) from [<c0881278>] (drm_atomic_check_only+0x5cc/0x7e0)
[  284.315658]  r10:c404c6c8 r9:ffffffff r8:c472c480 r7:00000003 r6:c3d636c0 r5:00000000
[  284.315662]  r4:0000003c r3:c08b7a4c
[  284.315670] [<c0880cac>] (drm_atomic_check_only) from [<c089ba60>] (drm_mode_atomic_ioctl+0x758/0xa7c)
[  284.315675]  r10:c3d46000 r9:c3d636c0 r8:c2ce8a70 r7:027e3a54 r6:00000043 r5:c1fbb800
[  284.315679]  r4:0281a858
[  284.315688] [<c089b308>] (drm_mode_atomic_ioctl) from [<c086e9f8>] (drm_ioctl_kernel+0xc4/0x108)
[  284.315693]  r10:c03864bc r9:c1fbb800 r8:c3d47e64 r7:c089b308 r6:00000002 r5:c2ba7800
[  284.315697]  r4:00000000
[  284.315705] [<c086e934>] (drm_ioctl_kernel) from [<c086ee28>] (drm_ioctl+0x1e8/0x3a0)
[  284.315711]  r9:c1fbb800 r8:000000bc r7:c3d47e64 r6:00000038 r5:c0e59570 r4:00000038
[  284.315719] [<c086ec40>] (drm_ioctl) from [<c041f354>] (sys_ioctl+0x35c/0x914)
[  284.315724]  r10:c2d08200 r9:00000000 r8:c36fa300 r7:befdd870 r6:c03864bc r5:c36fa301
[  284.315728]  r4:c03864bc
[  284.315735] [<c041eff8>] (sys_ioctl) from [<c0200040>] (ret_fast_syscall+0x0/0x28)
[  284.315739] Exception stack(0xc3d47fa8 to 0xc3d47ff0)
[  284.315745] 7fa0:                   027eb750 befdd870 00000000 c03864bc befdd870 00000000
[  284.315750] 7fc0: 027eb750 befdd870 c03864bc 00000036 027e3948 0281a640 0281a850 027e3a50
[  284.315756] 7fe0: b4b64100 befdd844 b4b5ba2c b49c994c
[  284.315762]  r10:00000036 r9:c3d46000 r8:c0200204 r7:00000036 r6:c03864bc r5:befdd870
[  284.315765]  r4:027eb750

Fixes: c54619b0bfb35c4153b3fb34916a6fa50dcf2dc1
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
3 years agovc4: Correct lbm size and calculation
Dom Cobley [Thu, 14 Jan 2021 16:01:50 +0000 (16:01 +0000)]
vc4: Correct lbm size and calculation

LBM base address is measured in units of pixels per cycle.
That is 4 for 2711 (hvs5) and 2 for 2708.

We are wasting 75% of lbm by indexing without the scaling.
But we were also using too high a size for the lbm resulting
in partial corruption (right hand side) of vertically
scaled images, usually at 4K or lower resolutions with more layers.

The physical RAM of LBM on 2711 is 8 * 1920 * 16 * 12-bit
(pixels are stored 12-bits per component regardless of format).

The LBM adress indexes work in units of pixels per clock,
so for 4 pixels per clock that means we have 32 * 1920 = 60K

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
3 years agoSQUASH: Revert "overlays: Fix dtc warnings in i2c-gpio"
Phil Elwell [Wed, 13 Jan 2021 21:27:56 +0000 (21:27 +0000)]
SQUASH: Revert "overlays: Fix dtc warnings in i2c-gpio"

This reverts commit 1c15edc0dca002c8536e9f1f5e1ec43017815018.

This revert and its neighbour are opposites. When squashing, delete
the original commits as well.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agoSQUASH: Revert: "overlays: Make the i2c-gpio overlay safe again"
Phil Elwell [Wed, 13 Jan 2021 21:25:38 +0000 (21:25 +0000)]
SQUASH: Revert: "overlays: Make the i2c-gpio overlay safe again"

This revert and its neighbour are opposites. When squashing, delete
the original commits as well.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agooverlays: seeed-can-fd-hat: clarify how to identify HAT version
Marc Kleine-Budde [Sat, 9 Jan 2021 16:03:32 +0000 (17:03 +0100)]
overlays: seeed-can-fd-hat: clarify how to identify HAT version

It turns out the used CAN SPI chip is not a good way to identify the version of
the CAN HAT.

There are two different board layouts of the Seeed Studio CAN BUS FD HAT. The
v1 board doesn't have a battery holder, while the v2 board has. Update the
overlay README accordinly.

Link: https://github.com/Seeed-Studio/seeed-linux-dtoverlays/issues/13
Cc: Patrick Menschel <menschel.p@posteo.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
3 years agodtoverlays: Update sensor overlays to use cam1_reg where possible
Dave Stevenson [Wed, 6 Jan 2021 17:42:31 +0000 (17:42 +0000)]
dtoverlays: Update sensor overlays to use cam1_reg where possible

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>
3 years agodt: Add a camera regulator node to all downstream Pi platforms
Dave Stevenson [Wed, 6 Jan 2021 17:28:57 +0000 (17:28 +0000)]
dt: Add a camera regulator node to all downstream Pi platforms

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>
3 years agooverlays: add spi override to merus-amp overlay
Aaron Shaw [Sat, 26 Dec 2020 03:13:14 +0000 (03:13 +0000)]
overlays: add spi override to merus-amp overlay

adds an override to the merus-amp overlay to turn the spi bus off

Change-type: patch
Signed-off-by: Aaron Shaw <shawaj@gmail.com>
3 years agooverlays: add wm8960-soundcard overlay
Aaron Shaw [Sat, 2 Jan 2021 02:34:03 +0000 (02:34 +0000)]
overlays: add wm8960-soundcard overlay

add overlay for waveshare wm8960 simple-audio-card

Change-type: patch
Signed-off-by: Aaron Shaw <shawaj@gmail.com>
3 years agooverlays: Add overlay for Seeed Studio CAN BUS FD HAT v1 (based on mcp2517fd)
Marc Kleine-Budde [Sat, 2 Jan 2021 20:38:58 +0000 (21:38 +0100)]
overlays: Add overlay for Seeed Studio CAN BUS FD HAT v1 (based on mcp2517fd)

This patch adds the overlay for the Seeed Studio CAN BUS FD HAT v1 with two CAN
FD Channels (based on mcp2517fd).

https://www.seeedstudio.com/2-Channel-CAN-BUS-FD-Shield-for-Raspberry-Pi-p-4072.html

The overlay was generated by:
ovmerge -c spi1-1cs-overlay.dts,cs0_pin=18,cs0_spidev=false \
           mcp251xfd-overlay.dts,spi0-0,interrupt=25 \
           mcp251xfd-overlay.dts,spi1-0,interrupt=24

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
3 years agooverlays: give Seeed Studio CAN BUS FD HAT a -v2 postfix
Marc Kleine-Budde [Sat, 2 Jan 2021 20:08:59 +0000 (21:08 +0100)]
overlays: give Seeed Studio CAN BUS FD HAT a -v2 postfix

There are several versions of the Seeed Studio CAN BUS FD HAT. This is the
second version, based on the mcp2518fd, so give it a -v2 postfix.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
3 years agomedia: i2c: ov5647: Selection compliance fixes
Paul Elder [Tue, 22 Dec 2020 05:27:46 +0000 (14:27 +0900)]
media: i2c: ov5647: Selection compliance fixes

To comply with the intended usage of the V4L2 selection target when
used to retrieve a sensor image properties, adjust the rectangles
returned by the ov5647 driver.

The top/left crop coordinates of the TGT_CROP rectangle were set to
(0, 0) instead of (16, 16) which is the offset from the larger physical
pixel array rectangle. This was also a mismatch with the default values
crop rectangle value, so this is corrected. Found with v4l2-compliance.

While at it, add V4L2_SEL_TGT_CROP_BOUNDS support: CROP_DEFAULT and
CROP_BOUNDS have the same size as the non-active pixels are not readable
using the selection API. Found with v4l2-compliance.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
3 years agobcm2711-rpi.dtsi: Bump hdmi audio dma panic priority to max
Dom Cobley [Wed, 6 Jan 2021 18:16:29 +0000 (18:16 +0000)]
bcm2711-rpi.dtsi: Bump hdmi audio dma panic priority to max

Set panic priority to 15 and leave normal priority at 0

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
3 years agodt: Enable DMA_WIDE_SOURCE and DMA_WIDE_DEST for hdmi audio
popcornmix [Mon, 11 Jan 2021 13:06:23 +0000 (13:06 +0000)]
dt: Enable DMA_WIDE_SOURCE and DMA_WIDE_DEST for hdmi audio

Signed-off-by: popcornmix <popcornmix@gmail.com>
3 years agobcm2835-dma: Avoid losing CS flags after interrupt
Dom Cobley [Wed, 6 Jan 2021 18:16:10 +0000 (18:16 +0000)]
bcm2835-dma: Avoid losing CS flags after interrupt

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
3 years agobcm2835-dma: Move WAIT_RESP from extra to info
popcornmix [Mon, 11 Jan 2021 14:49:33 +0000 (14:49 +0000)]
bcm2835-dma: Move WAIT_RESP from extra to info

Questionable: Might want to drop
Signed-off-by: popcornmix <popcornmix@gmail.com>
3 years agobcm2835-dma: Add bcm2835-dma: Add DMA_WIDE_SOURCE and DMA_WIDE_DEST flags
Dom Cobley [Wed, 30 Dec 2020 14:51:29 +0000 (14:51 +0000)]
bcm2835-dma: Add bcm2835-dma: Add DMA_WIDE_SOURCE and DMA_WIDE_DEST flags

Use (reserved) bits 24 and 25 of the dreq value
(the second cell of the DT DMA descriptor) to request
that wide source reads or wide dest writes are required

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
3 years agostaging/bcm2835-isp: Log the number of excess supported formats
Dave Stevenson [Thu, 7 Jan 2021 11:43:22 +0000 (11:43 +0000)]
staging/bcm2835-isp: Log the number of excess supported formats

When logging that the firmware has provided more supported formats
than we had allocated storage for, log the number allocated and
returned.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agostaging/bcm2835-isp: Add the unpacked (16bpp) raw formats
Dave Stevenson [Thu, 7 Jan 2021 11:37:10 +0000 (11:37 +0000)]
staging/bcm2835-isp: Add the unpacked (16bpp) raw formats

Now that the firmware supports the unpacked (16bpp) variants
of the MIPI raw formats, add the mappings.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agostaging/bcm2835-codec: Log the number of excess supported formats
Dave Stevenson [Thu, 7 Jan 2021 11:41:26 +0000 (11:41 +0000)]
staging/bcm2835-codec: Log the number of excess supported formats

When logging that the firmware has provided more supported formats
than we had allocated storage for, log the number allocated and
returned.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agostaging/bcm2835-codec: Add the unpacked (16bpp) raw formats
Dave Stevenson [Thu, 7 Jan 2021 10:45:16 +0000 (10:45 +0000)]
staging/bcm2835-codec: Add the unpacked (16bpp) raw formats

Now that the firmware supports the unpacked (16bpp) variants
of the MIPI raw formats, add the mappings.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agostaging/vc04_services: Add additional unpacked raw formats
Dave Stevenson [Thu, 7 Jan 2021 10:43:20 +0000 (10:43 +0000)]
staging/vc04_services: Add additional unpacked raw formats

Support has been added for the unpacked (16bpp) versions of
the MIPI raw 10, 12, and 14 formats, so add the 4CCs for them.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agostaging/mmal-vchiq: Fix incorrect static vchiq_instance.
Dave Stevenson [Tue, 5 Jan 2021 14:34:20 +0000 (14:34 +0000)]
staging/mmal-vchiq: Fix incorrect static vchiq_instance.

For some reason lost in history function vchiq_mmal_init used
a static variable for storing the vchiq_instance.
This value is retrieved from vchiq per instance, so worked fine
until you try to call vchiq_mmal_init multiple times concurrently
when things then go wrong. This seemed to happen quite frequently
if using the cutdown firmware (no MMAL or VCSM services running)
as the vchiq_connect then failed, and one or other vchiq_shutdown
was working on an invalid handle.

Remove the static so that each caller gets a unique vchiq_instance.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agostaging/vc04-services/codec: Fix logical precedence issue
Dave Stevenson [Sat, 2 Jan 2021 10:51:58 +0000 (10:51 +0000)]
staging/vc04-services/codec: Fix logical precedence issue

Two issues identified with operator precedence in logical
expressions. Fix them.

https://github.com/raspberrypi/linux/issues/4040

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agostaging: vchiq: Fix bulk transfers on 64-bit builds
Phil Elwell [Mon, 4 Jan 2021 11:06:51 +0000 (11:06 +0000)]
staging: vchiq: Fix bulk transfers on 64-bit builds

The recent change to the bulk transfer compat function missed the fact
the relevant ioctl command is VCHIQ_IOC_QUEUE_BULK_TRANSMIT32, not
VCHIQ_IOC_QUEUE_BULK_TRANSMIT, as any attempt to send a bulk block
to the VPU would have shown.

Fixes: a4367cd2b231 ("staging: vchiq: convert compat bulk transfer")

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agovc-sm-cma: fixed kbuild problem
gesangtome [Fri, 1 Jan 2021 10:03:17 +0000 (18:03 +0800)]
vc-sm-cma: fixed kbuild problem

error logs:
  drivers/staging/vc04_services/vc-sm-cma/Kconfig:1:error: recursive dependency detected!
  drivers/staging/vc04_services/vc-sm-cma/Kconfig:1:      symbol BCM_VC_SM_CMA is selected by BCM2835_VCHIQ_MMAL
  drivers/staging/vc04_services/vchiq-mmal/Kconfig:1:     symbol BCM2835_VCHIQ_MMAL depends on BCM2835_VCHIQ
  drivers/staging/vc04_services/Kconfig:14:       symbol BCM2835_VCHIQ is selected by BCM_VC_SM_CMA
  For a resolution refer to Documentation/kbuild/kconfig-language.rst
  subsection "Kconfig recursive dependency limitations"

Tested-by: make ARCH=arm64 bcm2711_defconfig
Test platform: fedora 33
Branch: rpi-5.10.y

3 years agoAdd overlay for Seeed Studio CAN BUS FD HAT (#4034)
menschel [Wed, 30 Dec 2020 20:55:34 +0000 (21:55 +0100)]
Add overlay for Seeed Studio CAN BUS FD HAT (#4034)

This patch adds the overlay for the Seeed Studio CAN BUS FD HAT
with two CAN FD Channels and an RTC.
https://www.seeedstudio.com/CAN-BUS-FD-HAT-for-Raspberry-Pi-p-4742.html

The overlay was generated by
ovmerge -c mcp251xfd-overlay.dts,spi0-0,interrupt=25 \
           mcp251xfd-overlay.dts,spi0-1,interrupt=24 \
           i2c-rtc-overlay.dts,pcf85063

Also, add description on how to generate overlays

Signed-off-by: Patrick Menschel <menschel.p@posteo.de>
3 years agooverlays: Rebuild "upstream" with latest ovmerge
Phil Elwell [Wed, 30 Dec 2020 20:00:38 +0000 (20:00 +0000)]
overlays: Rebuild "upstream" with latest ovmerge

The latest ovmerge drops disabled fragments, causing the "upstream"
overlay to change.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agostaging: vchiq: Fix bulk userdata handling
Phil Elwell [Tue, 22 Dec 2020 16:13:17 +0000 (16:13 +0000)]
staging: vchiq: Fix bulk userdata handling

The addition of the local 'userdata' pointer to
vchiq_irq_queue_bulk_tx_rx omitted the case where neither BLOCKING nor
WAITING modes are used, in which case the value provided by the
caller is replaced with a NULL.

Fixes: 4184da4f316a ("staging: vchiq: fix __user annotations")

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agodrm/vc4: Fixup fkms for API change
Dave Stevenson [Tue, 1 Dec 2020 14:57:41 +0000 (14:57 +0000)]
drm/vc4: Fixup fkms for API change

Atomic flush and check changed API, so fix up the downstream-only
FKMS driver.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agodrm/vc4: hdmi: Enable 10/12 bpc output
Maxime Ripard [Tue, 15 Dec 2020 15:42:43 +0000 (16:42 +0100)]
drm/vc4: hdmi: Enable 10/12 bpc output

The BCM2711 supports higher bpc count than just 8, so let's support it in
our driver.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agodrm/vc4: hdmi: Limit the BCM2711 to the max without scrambling
Maxime Ripard [Tue, 15 Dec 2020 15:42:42 +0000 (16:42 +0100)]
drm/vc4: hdmi: Limit the BCM2711 to the max without scrambling

Unlike the previous generations, the HSM clock limitation is way above
what we can reach without scrambling, so let's move the maximum
frequency we support to the maximum clock frequency without scrambling.

Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
3 years agodrm/vc4: hdmi: Use the connector state pixel rate for the PHY
Maxime Ripard [Tue, 15 Dec 2020 15:42:41 +0000 (16:42 +0100)]
drm/vc4: hdmi: Use the connector state pixel rate for the PHY

The PHY initialisation parameters are not based on the pixel clock but
the TMDS clock rate which can be the pixel clock in the standard case,
but could be adjusted based on some parameters like the bits per color.

Since the TMDS clock rate is stored in our custom connector state
already, let's reuse it from there instead of computing it again.

Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
3 years agodrm/vc4: hdmi: Store pixel frequency in the connector state
Maxime Ripard [Tue, 15 Dec 2020 15:42:40 +0000 (16:42 +0100)]
drm/vc4: hdmi: Store pixel frequency in the connector state

The pixel rate is for now quite simple to compute, but with more features
(30 and 36 bits output, YUV output, etc.) will depend on a bunch of
connectors properties.

Let's store the rate we have to run the pixel clock at in our custom
connector state, and compute it in atomic_check.

Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
3 years agodrm/vc4: hdmi: Create a custom connector state
Maxime Ripard [Tue, 15 Dec 2020 15:42:39 +0000 (16:42 +0100)]
drm/vc4: hdmi: Create a custom connector state

When run with a higher bpc than 8, the clock of the HDMI controller needs
to be adjusted. Let's create a connector state that will be used at
atomic_check and atomic_enable to compute and store the clock rate
associated to the state.

Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agodrm/vc4: hdmi: Don't access the connector state in reset if kmalloc fails
Maxime Ripard [Tue, 15 Dec 2020 15:42:38 +0000 (16:42 +0100)]
drm/vc4: hdmi: Don't access the connector state in reset if kmalloc fails

drm_atomic_helper_connector_reset uses kmalloc which, from an API
standpoint, can fail, and thus setting connector->state to NULL.
However, our reset hook then calls drm_atomic_helper_connector_tv_reset
that will access connector->state without checking if it's a valid
pointer or not.

Make sure we don't end up accessing a NULL pointer.

Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Suggested-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
3 years agodrm/vc4: hdmi: Take into account the clock doubling flag in atomic_check
Maxime Ripard [Tue, 15 Dec 2020 15:42:37 +0000 (16:42 +0100)]
drm/vc4: hdmi: Take into account the clock doubling flag in atomic_check

Commit 63495f6b4aed ("drm/vc4: hdmi: Make sure our clock rate is within
limits") was intended to compute the pixel rate to make sure we remain
within the boundaries of what the hardware can provide.

However, unlike what mode_valid was checking for, we forgot to take
into account the clock doubling flag that can be set for modes. Let's
honor that flag if it's there.

Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Reported-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Fixes: 63495f6b4aed ("drm/vc4: hdmi: Make sure our clock rate is within limits")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
3 years agodrm/vc4: Pass the atomic state to encoder hooks
Maxime Ripard [Tue, 15 Dec 2020 15:42:36 +0000 (16:42 +0100)]
drm/vc4: Pass the atomic state to encoder hooks

We'll need to access the connector state in our encoder setup, so let's
just pass the whole DRM state to our private encoder hooks.

Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
3 years agodrm/vc4: hvs: Align the HVS atomic hooks to the new API
Maxime Ripard [Mon, 7 Dec 2020 15:57:11 +0000 (16:57 +0100)]
drm/vc4: hvs: Align the HVS atomic hooks to the new API

Since the CRTC setup in vc4 is split between the PixelValves/TXP and the
HVS, only the PV/TXP atomic hooks were updated in the previous commits, but
it makes sense to update the HVS ones too.

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
3 years agodrm/atomic: Pass the full state to CRTC atomic begin and flush
Maxime Ripard [Wed, 28 Oct 2020 12:32:22 +0000 (13:32 +0100)]
drm/atomic: Pass the full state to CRTC atomic begin and flush

Commit f6ebe9f9c9233a6114eb922aba9a0c9ccc2d2e14 upstream.

The current atomic helpers have either their object state being passed as
an argument or the full atomic state.

The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.

Let's start convert all the remaining helpers to provide a consistent
interface, starting with the CRTC's atomic_begin and atomic_flush.

The conversion was done using the coccinelle script below, built tested on
all the drivers and actually tested on vc4.

virtual report

@@
struct drm_crtc_helper_funcs *FUNCS;
identifier old_crtc_state, old_state;
identifier crtc;
identifier f;
@@

 f(struct drm_crtc_state *old_crtc_state)
 {
...
  struct drm_atomic_state *old_state = old_crtc_state->state;
<...
- FUNCS->atomic_begin(crtc, old_crtc_state);
+ FUNCS->atomic_begin(crtc, old_state);
...>
 }

@@
struct drm_crtc_helper_funcs *FUNCS;
identifier old_crtc_state, old_state;
identifier crtc;
identifier f;
@@

 f(struct drm_crtc_state *old_crtc_state)
 {
...
  struct drm_atomic_state *old_state = old_crtc_state->state;
<...
- FUNCS->atomic_flush(crtc, old_crtc_state);
+ FUNCS->atomic_flush(crtc, old_state);
...>
 }

@@
struct drm_crtc_helper_funcs *FUNCS;
struct drm_crtc *crtc;
struct drm_crtc_state *crtc_state;
identifier dev, state;
identifier f;
@@

 f(struct drm_device *dev, struct drm_atomic_state *state, ...)
 {
<...
- FUNCS->atomic_begin(crtc, crtc_state);
+ FUNCS->atomic_begin(crtc, state);
...>
 }

@@
struct drm_crtc_helper_funcs *FUNCS;
struct drm_crtc *crtc;
struct drm_crtc_state *crtc_state;
identifier dev, state;
identifier f;
@@

 f(struct drm_device *dev, struct drm_atomic_state *state, ...)
 {
<...
- FUNCS->atomic_flush(crtc, crtc_state);
+ FUNCS->atomic_flush(crtc, state);
...>
 }

@@
identifier crtc, old_state;
@@

 struct drm_crtc_helper_funcs {
...
- void (*atomic_begin)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+ void (*atomic_begin)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
- void (*atomic_flush)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+ void (*atomic_flush)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
}

@ crtc_atomic_func @
identifier helpers;
identifier func;
@@

(
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_begin = func,
...,
};
|
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_flush = func,
...,
};
)

@ ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@

void func(struct drm_crtc *crtc,
struct drm_crtc_state *old_state)
{
... when != old_state
}

@ adds_old_state depends on crtc_atomic_func && !ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@

void func(struct drm_crtc *crtc, struct drm_crtc_state *old_state)
{
+ struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state, crtc);
...
}

@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
expression E;
type T;
@@

void func(...)
{
...
- T state = E;
+ T crtc_state = E;
<+...
- state
+ crtc_state
...+>

}

@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
type T;
@@

void func(...)
{
...
- T state;
+ T crtc_state;
<+...
- state
+ crtc_state
...+>

}

@@
identifier old_state;
identifier crtc;
@@

 void vc4_hvs_atomic_flush(struct drm_crtc *crtc,
-    struct drm_crtc_state *old_state
+    struct drm_atomic_state *state
   )
{
+ struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state, crtc);
...
}

@@
identifier old_state;
identifier crtc;
@@

 void vc4_hvs_atomic_flush(struct drm_crtc *crtc,
-    struct drm_crtc_state *old_state
+    struct drm_atomic_state *state
   );

@@
identifier old_state;
identifier crtc;
@@

 void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
-    struct drm_crtc_state *old_state
+    struct drm_atomic_state *state
   )
{
...
}

@@
identifier old_state;
identifier crtc;
@@

 void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
-    struct drm_crtc_state *old_state
+    struct drm_atomic_state *state
   );

@@
identifier old_state;
identifier crtc;
@@

 void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
-    struct drm_crtc_state *old_state
+    struct drm_atomic_state *state
   )
{
...
}

@@
identifier old_state;
identifier crtc;
@@

 void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
-    struct drm_crtc_state *old_state
+    struct drm_atomic_state *state
   );

@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
identifier old_state;
identifier crtc;
@@

void func(struct drm_crtc *crtc,
-        struct drm_crtc_state *old_state
+        struct drm_atomic_state *state
       )
{ ... }

@ include depends on adds_old_state @
@@

 #include <drm/drm_atomic.h>

@ no_include depends on !include && adds_old_state @
@@

+ #include <drm/drm_atomic.h>
  #include <drm/...>

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20201028123222.1732139-2-maxime@cerno.tech
3 years agodrm/atomic: Pass the full state to CRTC atomic_check
Maxime Ripard [Wed, 28 Oct 2020 12:32:21 +0000 (13:32 +0100)]
drm/atomic: Pass the full state to CRTC atomic_check

Commit 29b77ad7b9ca8c87152a1a9e8188970fb2a93df4 upstream.

The current atomic helpers have either their object state being passed as
an argument or the full atomic state.

The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.

Let's start convert all the remaining helpers to provide a consistent
interface, starting with the CRTC's atomic_check.

The conversion was done using the coccinelle script below,
built tested on all the drivers and actually tested on vc4.

virtual report

@@
struct drm_crtc_helper_funcs *FUNCS;
struct drm_crtc *crtc;
struct drm_crtc_state *crtc_state;
identifier dev, state;
identifier ret, f;
@@

 f(struct drm_device *dev, struct drm_atomic_state *state)
 {
<...
- ret = FUNCS->atomic_check(crtc, crtc_state);
+ ret = FUNCS->atomic_check(crtc, state);
...>
 }

@@
identifier crtc, new_state;
@@

 struct drm_crtc_helper_funcs {
  ...
- int (*atomic_check)(struct drm_crtc *crtc, struct drm_crtc_state *new_state);
+ int (*atomic_check)(struct drm_crtc *crtc, struct drm_atomic_state *state);
  ...
}

@ crtc_atomic_func @
identifier helpers;
identifier func;
@@

static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_check = func,
...,
};

@ ignores_new_state @
identifier crtc_atomic_func.func;
identifier crtc, new_state;
@@

 int func(struct drm_crtc *crtc,
struct drm_crtc_state *new_state)
 {
... when != new_state
 }

@ adds_new_state depends on crtc_atomic_func && !ignores_new_state @
identifier crtc_atomic_func.func;
identifier crtc, new_state;
@@

 int func(struct drm_crtc *crtc, struct drm_crtc_state *new_state)
 {
+ struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state, crtc);
  ...
 }

@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
expression E;
type T;
@@

 int func(...)
 {
...
- T state = E;
+ T crtc_state = E;
  <+...
- state
+ crtc_state
  ...+>
 }

@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
type T;
@@

 int func(...)
 {
  ...
- T state;
+ T crtc_state;
  <+...
- state
+ crtc_state
  ...+>
 }

@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
identifier new_state;
identifier crtc;
@@

 int func(struct drm_crtc *crtc,
-        struct drm_crtc_state *new_state
+        struct drm_atomic_state *state
       )
 { ... }

@@
identifier new_state;
identifier crtc;
@@

 int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
-                             struct drm_crtc_state *new_state
+                             struct drm_atomic_state *state
               )
 {
+       struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state, crtc);
...
 }

@@
identifier new_state;
identifier crtc;
@@

 int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
-                             struct drm_crtc_state *new_state
+                             struct drm_atomic_state *state
               );

@ include depends on adds_new_state @
@@

 #include <drm/drm_atomic.h>

@ no_include depends on !include && adds_new_state @
@@

+ #include <drm/drm_atomic.h>
  #include <drm/...>

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20201028123222.1732139-1-maxime@cerno.tech
3 years agodrm/atomic: Pass the full state to CRTC atomic enable/disable
Maxime Ripard [Thu, 8 Oct 2020 12:44:08 +0000 (14:44 +0200)]
drm/atomic: Pass the full state to CRTC atomic enable/disable

Commit 351f950db4ab28c321a1bd4b92e4bb03e34c4703 upstream.

If the CRTC driver ever needs to access the full DRM state, it can't do so
at atomic_enable / atomic_disable time since drm_atomic_helper_swap_state
will have cleared the pointer from the struct drm_crtc_state to the struct
drm_atomic_state before calling those hooks.

In order to allow that, let's pass the full DRM state to atomic_enable and
atomic_disable. The conversion was done using the coccinelle script below,
built tested on all the drivers and actually tested on vc4.

virtual report

@@
struct drm_crtc_helper_funcs *FUNCS;
identifier dev, state;
identifier crtc, crtc_state;
@@

 disable_outputs(struct drm_device *dev, struct drm_atomic_state *state)
 {
  <...
- FUNCS->atomic_disable(crtc, crtc_state);
+ FUNCS->atomic_disable(crtc, state);
  ...>
 }

@@
struct drm_crtc_helper_funcs *FUNCS;
identifier dev, state;
identifier crtc, crtc_state;
@@

 drm_atomic_helper_commit_modeset_enables(struct drm_device *dev, struct drm_atomic_state *state)
 {
  <...
- FUNCS->atomic_enable(crtc, crtc_state);
+ FUNCS->atomic_enable(crtc, state);
  ...>
 }

@@
identifier crtc, old_state;
@@

 struct drm_crtc_helper_funcs {
...
- void (*atomic_enable)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+ void (*atomic_enable)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
- void (*atomic_disable)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+ void (*atomic_disable)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
}

@ crtc_atomic_func @
identifier helpers;
identifier func;
@@

(
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_enable = func,
...,
};
|
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_disable = func,
...,
};
)

@ ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@

void func(struct drm_crtc *crtc,
struct drm_crtc_state *old_state)
{
... when != old_state
}

@ adds_old_state depends on crtc_atomic_func && !ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@

void func(struct drm_crtc *crtc, struct drm_crtc_state *old_state)
{
+ struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state, crtc);
...
}

@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
expression E;
type T;
@@

void func(...)
{
...
- T state = E;
+ T crtc_state = E;
<+...
- state
+ crtc_state
...+>

}

@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
type T;
@@

void func(...)
{
...
- T state;
+ T crtc_state;
<+...
- state
+ crtc_state
...+>

}

@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
identifier old_state;
identifier crtc;
@@

void func(struct drm_crtc *crtc,
-        struct drm_crtc_state *old_state
+        struct drm_atomic_state *state
       )
{ ... }

@ include depends on adds_old_state @
@@

 #include <drm/drm_atomic.h>

@ no_include depends on !include && adds_old_state @
@@

+ #include <drm/drm_atomic.h>
  #include <drm/...>

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/845aa10ef171fc0ea060495efef142a0c13f7870.1602161031.git-series.maxime@cerno.tech
3 years agostaging/vc04_services/codec: Clear last buf dequeued flag on START
Dave Stevenson [Sun, 13 Dec 2020 16:54:43 +0000 (16:54 +0000)]
staging/vc04_services/codec: Clear last buf dequeued flag on START

It appears that the V4L2 M2M framework requires the driver to manually
call vb2_clear_last_buffer_dequeued on the CAPTURE queue during a
V4L2_DEC_CMD_START.
Add such a call.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agostaging/vc04_services/codec: Add support for CID MPEG_HEADER_MODE
Dave Stevenson [Sun, 13 Dec 2020 16:45:58 +0000 (16:45 +0000)]
staging/vc04_services/codec: Add support for CID MPEG_HEADER_MODE

Control V4L2_CID_MPEG_VIDEO_HEADER_MODE controls whether the encoder
is meant to emit the header bytes as a separate packet or with the
first encoded frame.
Add support for it.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agomedia: i2c: imx477: Selection compliance fixes
Naushir Patuck [Wed, 9 Dec 2020 11:30:12 +0000 (11:30 +0000)]
media: i2c: imx477: Selection compliance fixes

To comply with the intended usage of the V4L2 selection target when
used to retrieve a sensor image properties, adjust the rectangles
returned by the imx477 driver.

The top/left crop coordinates of the TGT_CROP rectangle were set to
(0, 0) instead of (8, 16) which is the offset from the larger physical
pixel array rectangle. This was also a mismatch with the default values
crop rectangle value, so this is corrected. Found with v4l2-compliance.

While at it, add V4L2_SEL_TGT_CROP_BOUNDS support: CROP_DEFAULT and
CROP_BOUNDS have the same size as the non-active pixels are not readable
using the selection API. Found with v4l2-compliance.

This commit mirrors 543790f777ba1b3264c168c653db6d415e7c983f done for
the imx219 sensor.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
3 years agooverlays: Add missing addresses to ads1015/ads1115
Phil Elwell [Wed, 16 Dec 2020 09:28:17 +0000 (09:28 +0000)]
overlays: Add missing addresses to ads1015/ads1115

The overlays for the ads1015 and ads1115 I2C ADCs omitted the addresses
in the main device node names. As well as breaking the conventions for
I2C devices, this prevents the firmware from renaming them when the
"reg" property is modified, which in turn stops the overlays from being
instantiated multiple times.

See: https://www.raspberrypi.org/forums/viewtopic.php?f=107&t=294465

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agodrm/vc4: Make normalize_zpos conditional on using fkms
Dom Cobley [Tue, 15 Dec 2020 16:26:51 +0000 (16:26 +0000)]
drm/vc4: Make normalize_zpos conditional on using fkms

Eric's view was that there was no point in having zpos
support on vc4 as all the planes had the same functionality.

Can be later squashed into (and fixes):
drm/vc4: Add firmware-kms mode

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
3 years agooverlays: mpu6050: Add 'addr' parameter
Phil Elwell [Tue, 15 Dec 2020 17:02:17 +0000 (17:02 +0000)]
overlays: mpu6050: Add 'addr' parameter

The mpu6050 starts up at address 0x68 by default, but can be set to
0x69 if the ADO pin is pulled high. Give the overlay an addr parameter
to allow devices at the alternate address to be used.

See: https://github.com/Hexxeh/rpi-firmware/issues/252

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agonet: lan78xx: Ack pending PHY ints when resetting
Phil Elwell [Tue, 15 Dec 2020 16:38:37 +0000 (16:38 +0000)]
net: lan78xx: Ack pending PHY ints when resetting

lan78xx_link_reset explicitly clears the MAC's view of the PHY's IRQ
status. In doing so it potentially leaves the PHY with a pending
interrupt that will never be acknowledged, at which point no further
interrupts will be generated.

Avoid the problem by acknowledging any pending PHY interrupt after
clearing the MAC's status bit.

See: https://github.com/raspberrypi/linux/issues/2937

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agoRevert "media: videobuf2: Fix length check for single plane dmabuf queueing"
Naushir Patuck [Tue, 15 Dec 2020 14:51:55 +0000 (14:51 +0000)]
Revert "media: videobuf2: Fix length check for single plane dmabuf queueing"

This reverts commit 961d3b27a2aff52dda0b97d35085a743a27c2f46.

The updated length check for dmabuf types broke existing usage in v4l2
userland clients.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
3 years agostaging/bcm2835-codec: Ensure OUTPUT timestamps are always forwarded
Dave Stevenson [Wed, 4 Nov 2020 18:31:02 +0000 (18:31 +0000)]
staging/bcm2835-codec: Ensure OUTPUT timestamps are always forwarded

The firmware by default tries to ensure that decoded frame
timestamps always increment. This is counter to the V4L2 API
which wants exactly the OUTPUT queue timestamps passed to the
CAPTURE queue buffers.

Disable the firmware option.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agooverlays: Fix cut-and-paste error in README
Phil Elwell [Mon, 7 Dec 2020 17:18:39 +0000 (17:18 +0000)]
overlays: Fix cut-and-paste error in README

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agooverlays: Add PCF85063 and PCF85063A to i2c-rtc
Phil Elwell [Mon, 7 Dec 2020 08:49:53 +0000 (08:49 +0000)]
overlays: Add PCF85063 and PCF85063A to i2c-rtc

Add support for the PCF85063 and PCF85063A RTC devices to the
i2c-rtc overlay.

Also enable the device to be used on i2c0 (i2c_vc) on GPIOs 0&1 (use
parameter "i2c0") and GPIOs 44 & 45 (use parameter "i2c_csi_dsi").

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agoconfigs: Add RTC_DRV_PCF85063=m
Phil Elwell [Mon, 7 Dec 2020 08:33:19 +0000 (08:33 +0000)]
configs: Add RTC_DRV_PCF85063=m

Include the driver module for the PCF85063 and PCF85063A RTC devices.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agoARM: dts: CM4 audio pins are not connected
Phil Elwell [Mon, 7 Dec 2020 09:35:57 +0000 (09:35 +0000)]
ARM: dts: CM4 audio pins are not connected

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agoPCI: brcmstb: Advertise MSI-X support
Phil Elwell [Thu, 3 Dec 2020 13:44:42 +0000 (13:44 +0000)]
PCI: brcmstb: Advertise MSI-X support

Although the BRCMSTB PCIe interface doesn't technically support the
MSI-X spec, in practise it seems to work provided no more than 32
MSI-Xs are required. Add the required flag to the driver to allow
experimentation with devices that demand MSI-X support.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agomedia: bcm2835-unicam: Clear clock state when stopping streaming
Naushir Patuck [Wed, 2 Dec 2020 16:48:41 +0000 (16:48 +0000)]
media: bcm2835-unicam: Clear clock state when stopping streaming

Commit 65e08c465020d4c5b51afb452efc2246d80fd66f failed to clear the
clock state when the device stopped streaming. Fix this, as it might
again cause the same problems when doing an unprepare.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
3 years agomedia: bcm2835-unicam: Return early from stop_streaming() if stopped
Naushir Patuck [Wed, 2 Dec 2020 15:26:09 +0000 (15:26 +0000)]
media: bcm2835-unicam: Return early from stop_streaming() if stopped

clk_disable_unprepare() is called unconditionally in stop_streaming().
This is incorrect in the cases where start_streaming() fails, and
unprepares all clocks as part of the failure cleanup. To avoid this,
ensure that clk_disable_unprepare() is only called in stop_streaming()
if the clocks are in a prepared state.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
3 years agomedia: bcm2835-unicam: Correctly handle error propagation for stream on
Naushir Patuck [Wed, 2 Dec 2020 15:22:23 +0000 (15:22 +0000)]
media: bcm2835-unicam: Correctly handle error propagation for stream on

On a failure in start_streaming(), the error code would not propagate to
the calling function on all conditions. This would cause the userland
caller to not know of the failure.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
3 years agoOverlay: Update Allo Piano Plus dac driver for 5.4.y kernels.
paul-1 [Thu, 5 Nov 2020 00:17:48 +0000 (19:17 -0500)]
Overlay: Update Allo Piano Plus dac driver for 5.4.y kernels.

Create unique names for the two instances of the codec driver.

Signed-off-by: Paul Hermann <paul@picoreplayer.org>
3 years agoAdd allo boss2 config
Sudeep [Fri, 23 Oct 2020 10:22:38 +0000 (15:52 +0530)]
Add allo boss2 config

Signed-off-by: Sudeep <sudeepkumar@cem-solutions.net>
3 years agoAdd allo boss2 overlay
Sudeep [Fri, 23 Oct 2020 10:21:15 +0000 (15:51 +0530)]
Add allo boss2 overlay

Signed-off-by: Sudeep <sudeepkumar@cem-solutions.net>
3 years agoAllo boss2 driver
Sudeep [Fri, 23 Oct 2020 10:17:17 +0000 (15:47 +0530)]
Allo boss2 driver

Signed-off-by: Sudeep <sudeepkumar@cem-solutions.net>
3 years agodrm/vc4: Correct DSI register definition
Dave Stevenson [Mon, 30 Nov 2020 16:16:03 +0000 (16:16 +0000)]
drm/vc4: Correct DSI register definition

The DSI1_PHY_AFEC0_PD_DLANE1 and DSI1_PHY_AFEC0_PD_DLANE3 register
definitions were swapped, so trying to use more than a single data
lane failed as lane 1 would get powered down.
(In theory a 4 lane device would work as all lanes would remain
powered).

Correct the definitions.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agovc4_hdmi: Move hdmi reset to bind
Dom Cobley [Thu, 22 Oct 2020 18:07:24 +0000 (19:07 +0100)]
vc4_hdmi: Move hdmi reset to bind

The hdmi reset got moved to a later point in
"drm/vc4: hdmi: Add reset callback"

which now occurs after vc4_hdmi_cec_init
and so tramples the setup of registers like
HDMI_CEC_CNTRL_1

This only affects pi0-3 as on pi4 the cec
resgisters are in a separate block

Fixes: ed9a1f6eb4402b25b8a983dc4bfe40f025176e03
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
3 years agodt: Use compatible string for BCM2711 DSI1
Dave Stevenson [Thu, 12 Nov 2020 18:42:30 +0000 (18:42 +0000)]
dt: Use compatible string for BCM2711 DSI1

Updates the compatible string for DSI1 on BCM2711 to
differentiate it from BCM2835.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agodrm/vc4: Add configuration for BCM2711 DSI1.
Dave Stevenson [Thu, 12 Nov 2020 17:18:13 +0000 (17:18 +0000)]
drm/vc4: Add configuration for BCM2711 DSI1.

BCM2711 DSI1 doesn't have the issue with the ARM not being
able to write to the registers, therefore remove the DMA
workaround for that compatible string.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agodt-bindings: Add compatible for BCM2711 DSI1
Dave Stevenson [Thu, 12 Nov 2020 17:01:52 +0000 (17:01 +0000)]
dt-bindings: Add compatible for BCM2711 DSI1

DSI1 on BCM2711 doesn't require the DMA workaround that is used
on BCM2835/6/7, therefore it needs a new compatible string.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agodrm/vc4: Add support for DSI0
Dave Stevenson [Wed, 11 Nov 2020 17:18:01 +0000 (17:18 +0000)]
drm/vc4: Add support for DSI0

DSI0 was partially supported, but didn't register with the main
driver, and the code was inconsistent as to whether it checked
port == 0 or port == 1.

Add compatible string and other support to make it consistent.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agomedia: ov9281: Add 1280x720 and 640x480 modes
Dave Stevenson [Sun, 22 Nov 2020 11:01:08 +0000 (11:01 +0000)]
media: ov9281: Add 1280x720 and 640x480 modes

Breaks out common register set and adds the different registers
for 1280x720 (cropped) and 640x480 (skipped) modes

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agoconfigs: Enable WireGuard kernel module on armhf configs
MichaIng [Mon, 23 Nov 2020 15:17:31 +0000 (16:17 +0100)]
configs: Enable WireGuard kernel module on armhf configs

CONFIG_WIREGUARD=m implies CONFIG_ARM_CRYPTO=y, hence the latter is removed.

Signed-off-by: MichaIng <micha@dietpi.com>
3 years agoconfigs: Restore BRIDGE_NETFILTER=m
Phil Elwell [Mon, 23 Nov 2020 14:56:18 +0000 (14:56 +0000)]
configs: Restore BRIDGE_NETFILTER=m

CONFIG_BRIDGE_NETFILTER=m used to be the default when CONFIG_NETFILTER
was enabled, but that was removed in 5.9. The way that defconfigs work
caused this wanted setting to be lost in rpi-5.9.y and rpi-5.10.y -
restore it now.

See: https://github.com/Hexxeh/rpi-firmware/issues/248

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agoconfigs: Regenerate the defconfigs
Phil Elwell [Mon, 23 Nov 2020 14:53:14 +0000 (14:53 +0000)]
configs: Regenerate the defconfigs

The CAN_ISOTP setting was in the wrong position, and it's better for
bisecting and reverting if this doesn't get rolled into the next
config-changing commit.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agomcp251xfd: add overlay
Marc Kleine-Budde [Thu, 14 Nov 2019 23:54:07 +0000 (00:54 +0100)]
mcp251xfd: add overlay

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
3 years agoAdd devicetree support for RaspberryPi 7" panel over DSI I2C
Dave Stevenson [Tue, 10 Nov 2020 17:49:35 +0000 (17:49 +0000)]
Add devicetree support for RaspberryPi 7" panel over DSI I2C

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agodrm/panel/raspberrypi-ts: Insert delay before polling for startup state
Dave Stevenson [Tue, 10 Nov 2020 11:21:56 +0000 (11:21 +0000)]
drm/panel/raspberrypi-ts: Insert delay before polling for startup state

In switching to the hardware I2C controller there is an issue
where we seem to not get back the correct state from the Pi
touchscreen.
Insert a delay before polling to avoid this condition.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agodrm/panel/raspberrypi-touchscreen: Use independent I2C actions with delay.
Dave Stevenson [Thu, 23 Apr 2020 09:17:18 +0000 (10:17 +0100)]
drm/panel/raspberrypi-touchscreen: Use independent I2C actions with delay.

We now have the hardware I2C controller pinmuxed to the drive the
display I2C, but this controller does not support clock stretching.
The Atmel micro-controller in the panel requires clock stretching
to allow it to prepare any data to be read.

Split the rpi_touchscreen_i2c_read into two independent transactions with
a delay between them for the Atmel to prepare the data.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agodtoverlays: Add an overlay for the EDT FT5406 touchscreen
Dave Stevenson [Fri, 6 Nov 2020 18:52:25 +0000 (18:52 +0000)]
dtoverlays: Add an overlay for the EDT FT5406 touchscreen

This touchscreen controller is used by the 7" DSI panel, and
this overlay configures it for when it is NOT being polled by
the firmware.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agoInput: edt-ft5x06: Poll the device if no interrupt is configured.
Dave Stevenson [Fri, 6 Nov 2020 18:45:10 +0000 (18:45 +0000)]
Input: edt-ft5x06: Poll the device if no interrupt is configured.

Not all systems have the interrupt line wired up, so switch to
polling the touchscreen off a timer if no interrupt line is
configured.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 years agovc4: Clear unused infoframe packet RAM registers
Dom Cobley [Tue, 10 Nov 2020 20:04:08 +0000 (20:04 +0000)]
vc4: Clear unused infoframe packet RAM registers

Using a hdmi analyser the bytes in packet ram
registers beyond the length were visible in the
infoframes and it flagged the checksum as invalid.

Zeroing unused words of packet RAM avoids this

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
3 years agoPCI: brcmstb: Restore initial fundamental reset
Phil Elwell [Wed, 11 Nov 2020 17:08:33 +0000 (17:08 +0000)]
PCI: brcmstb: Restore initial fundamental reset

[1] replaced a single reset function with a pointer to one of two
implementations, but also removed the call asserting the reset
at the start of brcm_pcie_setup. Doing so breaks Raspberry Pis with
VL805 XHCI controllers lacking dedicated SPI EEPROMs, which have been
used for USB booting but then need to be reset so that the kernel
can reconfigure them. The lack of a reset causes the firmware's loading
of the EEPROM image to RAM to fail, breaking USB for the kernel.

See: https://www.raspberrypi.org/forums/viewtopic.php?p=1758157#p1758157

Fixes: 04356ac30771 ("PCI: brcmstb: Add bcm7278 PERST# support")

[1] 04356ac30771 ("PCI: brcmstb: Add bcm7278 PERST# support")

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agovc4_hdmi: Report that 3d/stereo is allowed
Dom Cobley [Mon, 9 Nov 2020 19:49:32 +0000 (19:49 +0000)]
vc4_hdmi: Report that 3d/stereo is allowed

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
3 years agoconfigs: Add CAN_MCP251XFD=m and CAN_ISOTP=m
menschel [Fri, 6 Nov 2020 22:32:22 +0000 (23:32 +0100)]
configs: Add CAN_MCP251XFD=m and CAN_ISOTP=m

* Add mcp251xfd driver module to the RPi kernel builds.
* Add isotp can protocol module to the RPi kernel builds.

Signed-off-by: Patrick Menschel <menschel.p@posteo.de>
3 years agoARM: dts: bcm27xx: Remove enable_headphones setting
Phil Elwell [Thu, 5 Nov 2020 11:39:35 +0000 (11:39 +0000)]
ARM: dts: bcm27xx: Remove enable_headphones setting

The enable_headphones parameter of the snd_bcm2835 module is forced
to 1 if enable_compat_alsa is 0, so setting them both on the kernel
command line is pointless (and, in the case of Pi 400 and Pi Zeroes,
confusing).

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agooverlays: Deprecate and delete the sdtweak overlay
Phil Elwell [Wed, 4 Nov 2020 11:25:02 +0000 (11:25 +0000)]
overlays: Deprecate and delete the sdtweak overlay

The sdtweak overlay has been superseded by the board-specific
sd_* parameters such as sd_poll_once, sd_overclock etc.

For example, replace:

    dtoverlay=sdtweak,poll_once

with:

    dtparam=sd_poll_once

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
3 years agoARM: dts: Add bcm2711-rpi-400.dts
Phil Elwell [Tue, 14 Jul 2020 13:21:33 +0000 (14:21 +0100)]
ARM: dts: Add bcm2711-rpi-400.dts

Signed-off-by: Phil Elwell <phil@raspberrypi.com>