platform/kernel/linux-rpi.git
4 years agoRevert "overlays: gpio-keys: Avoid open-drain warnings"
Phil Elwell [Fri, 5 Jun 2020 15:06:59 +0000 (16:06 +0100)]
Revert "overlays: gpio-keys: Avoid open-drain warnings"

This reverts commit 907e08e6e70dd557a1f5cd03ef28492ffebffb08.

4 years agosnd_bcm2835: disable HDMI audio when vc4 is used (#3640)
Hristo Venev [Fri, 5 Jun 2020 09:22:49 +0000 (09:22 +0000)]
snd_bcm2835: disable HDMI audio when vc4 is used (#3640)

Things don't work too well when both the vc4 driver and the firmware
driver are trying to control the same audio output:

[  763.569406] bcm2835_audio bcm2835_audio: vchi message timeout, msg=5

Hence, when the vc4 HDMI driver is used, let it control audio. This is done
by introducing a new device tree property to the audio node, and
extending the vc4-kms-v3d overlays to set it appropriately.

Signed-off-by: Hristo Venev <hristo@venev.name>
4 years agovc4: cec: Restore cec physical address on reconnect
Dom Cobley [Wed, 3 Jun 2020 11:20:19 +0000 (12:20 +0100)]
vc4: cec: Restore cec physical address on reconnect

Currently we call cec_phys_addr_invalidate on a hotplug deassert.
That may be due to a TV power cycling, or an AVR being switched
on (and switching edid). This makes CEC unusable.

Set it back up again on the hotplug assert.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
4 years agostaging: vchiq_arm: Use g_dma_dev for dma_unmap_sg
Phil Elwell [Thu, 4 Jun 2020 16:23:36 +0000 (17:23 +0100)]
staging: vchiq_arm: Use g_dma_dev for dma_unmap_sg

Commit "staging: vchiq_arm: Clean up 40-bit DMA support" failed to
change one of the calls to dma_unmap_sg to pass in g_dma_dev (rather
than g_dev). Correct that oversight.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agovc4: Set driver_name for card
Dom Cobley [Tue, 2 Jun 2020 18:31:49 +0000 (19:31 +0100)]
vc4: Set driver_name for card

Allows use of the same alsa conf file for hdmi1

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
4 years agoconfigs: Add SND_SOC_MAX98357A=m
Phil Elwell [Tue, 2 Jun 2020 09:06:05 +0000 (10:06 +0100)]
configs: Add SND_SOC_MAX98357A=m

Enable the MAX98357A driver.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoAdd Micro Crystal RV-1805 to i2c-rtc overlays
Kevin P. Fleming [Mon, 1 Jun 2020 11:02:00 +0000 (07:02 -0400)]
Add Micro Crystal RV-1805 to i2c-rtc overlays

While the RV-1805 is supported by the rtc-abx80x driver via
auto-detection, in order for it to be initialized properly
it must be explcitly selected.

Signed-off-by: Kevin P. Fleming <kevin+linux@km6g.us>
4 years agomedia: bcm2835-isp: fix bytes per line calculations for some image formats
David Plowman [Fri, 29 May 2020 13:36:56 +0000 (14:36 +0100)]
media: bcm2835-isp: fix bytes per line calculations for some image formats

The bytes per line numbers calculated by get_bytesperline was not
matching the equivalent calculation being performed by the VideoCore
(mostly by the calculate_pitch function there), resulting in failures
to set the image format with some image width values. This patches up
the RGB24 and YUYV type formats to match the VideoCore calculation.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
4 years agooverlays: i2c-rtc-gpio: Fix trickle-resistor-ohms param
Phil Elwell [Fri, 29 May 2020 15:55:12 +0000 (16:55 +0100)]
overlays: i2c-rtc-gpio: Fix trickle-resistor-ohms param

The abx80x implementation of the trickle-resistor-ohms parameter is
missing the ":0" indicating that the target is an integer/cell value.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agonet: rtl8192cu: fix gcc misleading whitespace warning
David Lechner [Sun, 24 Nov 2019 22:40:48 +0000 (16:40 -0600)]
net: rtl8192cu: fix gcc misleading whitespace warning

This fixes a gcc warning about misleading whitespace.

Signed-off-by: David Lechner <david@lechnology.com>
4 years agooverlays: Add spi0 overlay to support sc16is752
bjorn [Thu, 7 May 2020 03:11:43 +0000 (05:11 +0200)]
overlays: Add spi0 overlay to support sc16is752

Signed-off-by: Bjorn <beikeland@gmail.com>
4 years agooverlays: gpio-shutdown: Add information for Raspberry Pi 1 Model B rev 1
Pali Rohár [Thu, 30 Apr 2020 17:41:10 +0000 (19:41 +0200)]
overlays: gpio-shutdown: Add information for Raspberry Pi 1 Model B rev 1

Raspberry Pi 1 Model B rev 1 uses GPIO1 for power-up instead of GPIO3.

4 years agooverlays: gpio-shutdown: Add information for SysV init / inittab
Pali Rohár [Thu, 30 Apr 2020 17:40:07 +0000 (19:40 +0200)]
overlays: gpio-shutdown: Add information for SysV init / inittab

KeyboardSignal and kb::kbrequest can be used to call /sbin/shutdown

4 years agooverlays: i2c-rtc: Fix trickle-resistor-ohms param
Phil Elwell [Fri, 29 May 2020 13:41:13 +0000 (14:41 +0100)]
overlays: i2c-rtc: Fix trickle-resistor-ohms param

The abx80x implementation of the trickle-resistor-ohms parameter is
missing the ":0" indicating that the target is an integer/cell value.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agobrcmfmac: BCM43436 needs dedicated firmware
Phil Elwell [Tue, 19 May 2020 08:46:12 +0000 (09:46 +0100)]
brcmfmac: BCM43436 needs dedicated firmware

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoconfigs: Build HWMON core into kernel
Chen-Yu Tsai [Fri, 15 May 2020 07:56:14 +0000 (15:56 +0800)]
configs: Build HWMON core into kernel

To expose thermal regions as hwmon devices, the HWMON core has to be
built-in, so that THERMAL_HWMON can be enabled.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
4 years agoconfigs: Switch to upstream thermal sensor for RPi 4 - BCM2711_THERMAL
Chen-Yu Tsai [Fri, 15 May 2020 07:38:12 +0000 (15:38 +0800)]
configs: Switch to upstream thermal sensor for RPi 4 - BCM2711_THERMAL

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
4 years agoARM: dts: bcm2711-rpi: Remove downstream thermal sensor node
Chen-Yu Tsai [Thu, 14 May 2020 09:39:30 +0000 (17:39 +0800)]
ARM: dts: bcm2711-rpi: Remove downstream thermal sensor node

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
4 years agoRevert "thermal: brcmstb_thermal: Add BCM2838 support"
Chen-Yu Tsai [Thu, 14 May 2020 09:24:28 +0000 (17:24 +0800)]
Revert "thermal: brcmstb_thermal: Add BCM2838 support"

This reverts commit 9d62448adc918a94fba091d475d0e6f1648c36f4.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
4 years agoRevert "thermal: brcmstb_thermal: Correct SoC name"
Chen-Yu Tsai [Thu, 14 May 2020 09:24:24 +0000 (17:24 +0800)]
Revert "thermal: brcmstb_thermal: Correct SoC name"

This reverts commit 6642a4f0769be5732fd372a5637fc1b01d62f93a.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
4 years agoARM: configs: Build BCM2711 thermal as module
Stefan Wahren [Mon, 13 Jan 2020 18:56:18 +0000 (19:56 +0100)]
ARM: configs: Build BCM2711 thermal as module

Commit 1a90e73248c4d0add6583bd88bb5e082c3e090bc upstream.

This builds the BCM2711 thermal driver as module for the Raspberry Pi 4.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/1578941778-23321-5-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
4 years agoARM: dts: bcm2711: Enable thermal
Stefan Wahren [Mon, 13 Jan 2020 18:56:17 +0000 (19:56 +0100)]
ARM: dts: bcm2711: Enable thermal

Commit a1d6989bf12b01cd9198e2c31a96678ac9c47415 upstream.

This enables thermal for the BCM2711 (used on Raspberry Pi 4) by adding
the AVS monitor and a subnode for the thermal part.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/1578941778-23321-4-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
4 years agothermal: Add BCM2711 thermal driver
Stefan Wahren [Mon, 13 Jan 2020 18:56:16 +0000 (19:56 +0100)]
thermal: Add BCM2711 thermal driver

Commit 59b781352dc4cb9ae27a8ddae0cda979d29d8af7 upstream.

This adds the thermal sensor driver for the Broadcom BCM2711 SoC,
which is placed on the Raspberry Pi 4. The driver only provides
SoC temperature reading so far.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/1578941778-23321-3-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
4 years agodt-bindings: Add Broadcom AVS RO thermal
Stefan Wahren [Mon, 13 Jan 2020 18:56:15 +0000 (19:56 +0100)]
dt-bindings: Add Broadcom AVS RO thermal

Commit ee31ff373da6602e7a4e60fe11322b41ac38eb22 upstream.

Since the BCM2711 doesn't have a AVS TMON block, the thermal information
must be retrieved from the AVS ring oscillator block. This block is part
of the AVS monitor which contains a bunch of raw sensors.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/1578941778-23321-2-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
4 years agomedia: bcm2835-unicam: change minimum number of vb2_queue buffers to 1
David Plowman [Thu, 28 May 2020 10:09:48 +0000 (11:09 +0100)]
media: bcm2835-unicam: change minimum number of vb2_queue buffers to 1

Since the unicam driver was modified to write to a dummy buffer when no
user-supplied buffer is available, it can now write to and return a
buffer even when there's only a single one. Enable this by changing the
min_buffers_needed in the vb2_queue; it will be useful for enabling
still captures without allocating more memory than absolutely necessary.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
4 years agoRevert "zswap: Uncross module parameter setting functions"
Phil Elwell [Mon, 25 May 2020 20:52:40 +0000 (21:52 +0100)]
Revert "zswap: Uncross module parameter setting functions"

This reverts commit e5e8a2214dff0c43580afc5dc22d496f667c3bbf.

4 years agoARM: dts: Update for new VCHIQ BCM2711 DMA support
Phil Elwell [Wed, 20 May 2020 15:36:57 +0000 (16:36 +0100)]
ARM: dts: Update for new VCHIQ BCM2711 DMA support

Now that the enhanced BCM2711 DMA controller is located by compatible
string and used directly for generating bulk transfer addresses,
remove the workaround of moving the vchiq node.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agostaging: vchiq_arm: Clean up 40-bit DMA support
Phil Elwell [Wed, 20 May 2020 15:36:33 +0000 (16:36 +0100)]
staging: vchiq_arm: Clean up 40-bit DMA support

Manage the split between addresses for the VPU and addresses for the
40-bit DMA controller with a dedicated DMA device pointer that on non-
BCM2711 platforms is the same as the main VCHIQ device. This allows
the VCHIQ node to stay in the usual place in the DT, and removes the
ugly VC_SAFE macros.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agomedia: i2c: imx477: Return correct result on sensor id verification
Naushir Patuck [Tue, 19 May 2020 15:56:33 +0000 (16:56 +0100)]
media: i2c: imx477: Return correct result on sensor id verification

The test should return -EIO if the register read id does not match
the expected sensor id.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 years agodrm/vc4: Add FKMS as an acceptable node for dma ranges.
Dave Stevenson [Tue, 19 May 2020 15:20:30 +0000 (16:20 +0100)]
drm/vc4: Add FKMS as an acceptable node for dma ranges.

Under FKMS, the firmware (via FKMS) also requires the VideoCore cache
aliases for image planes, as defined by the dma-ranges under /soc.

Add rpi-firmware-kms to the list of acceptable nodes to look for
to copy dma config from.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agodrm/vc4: Adopt the dma configuration from the HVS or V3D component
Dave Stevenson [Tue, 19 May 2020 13:54:28 +0000 (14:54 +0100)]
drm/vc4: Adopt the dma configuration from the HVS or V3D component

vc4_drv isn't necessarily under the /soc node in DT as it is a
virtual device, but it is the one that does the allocations.
The DMA addresses are consumed by primarily the HVS or V3D, and
those require VideoCore cache alias address mapping, and so will be
under /soc.

During probe find the a suitable device node for HVS or V3D,
and adopt the DMA configuration of that node.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agoconfigs: Add ZSWAP=y, ZBUD=m, Z3FOLD=m
Phil Elwell [Tue, 5 May 2020 14:25:06 +0000 (15:25 +0100)]
configs: Add ZSWAP=y, ZBUD=m, Z3FOLD=m

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agozswap: Defer zswap initialisation
Phil Elwell [Tue, 5 May 2020 14:23:32 +0000 (15:23 +0100)]
zswap: Defer zswap initialisation

Enabling zswap support in the kernel configuration costs about 1.5MB
of RAM, even when zswap is not enabled at runtime. This cost can be
reduced significantly by deferring initialisation (including pool
creation) until the "enabled" parameter is set to true. There is a
small cost to this in that some initialisation code has to remain in
memory after the init phase, just in case they are needed later,
but the total size increase is negligible.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agozswap: Uncross module parameter setting functions
Phil Elwell [Tue, 19 May 2020 14:47:02 +0000 (15:47 +0100)]
zswap: Uncross module parameter setting functions

The "compressor" and "zpool" parameters of the zswap module each has
a custom setter function that calls __zswap_param_set with specific
parameters, but the "zpool" setter uses parameters that are correct for
the "compressor" parameter, and vice-versa.

Fix this by swapping the function bodies over.

Fixes: 90b0fc26d5db ("zswap: change zpool/compressor at runtime")

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agomedia: bcm2835-unicam: Retain packing information on G_FMT
Dave Stevenson [Tue, 19 May 2020 10:46:47 +0000 (11:46 +0100)]
media: bcm2835-unicam: Retain packing information on G_FMT

The change to retrieve the pixel format always on g_fmt didn't
check whether the native or unpacked version of the format
had been requested, and always returned the packed one.
Correct this so that the packing setting is retained whereever
possible.

Fixes "9d59e89 media: bcm2835-unicam: Re-fetch mbus code from subdev
on a g_fmt call"

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agoSwitch to snd_soc_dai_set_bclk_ratio
j-schambacher [Tue, 19 May 2020 11:56:17 +0000 (13:56 +0200)]
Switch to snd_soc_dai_set_bclk_ratio
Replaces obsolete function snd_soc_dai_set_tdm_slot

Signed-off-by: Joerg Schambacher <joerg@i2audio.com>
4 years agooverlays: Fix audio parameter of vc4-kms-v3d
Phil Elwell [Mon, 18 May 2020 08:46:48 +0000 (09:46 +0100)]
overlays: Fix audio parameter of vc4-kms-v3d

The CMA handling change broke the audio parameter - the fragment
numbering has changed - so fix it.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoconfigs: Restore missing NF_TABLES settings
Phil Elwell [Fri, 15 May 2020 16:18:20 +0000 (17:18 +0100)]
configs: Restore missing NF_TABLES settings

The arm bcm2711_defconfig and the arm64 bcmrpi3_defconfig have been
missing their NF_TABLES settings. Restore them.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agostaging:vc04_services: bcm2835-camera: Request headers with I-frame
Dave Stevenson [Fri, 15 May 2020 12:48:59 +0000 (13:48 +0100)]
staging:vc04_services: bcm2835-camera: Request headers with I-frame

V4L2 wishes to have the codec header bytes in the same buffer as the
first encoded frame, so it does become 1-in 1-out for encoding.
The firmware now has an option to do this, so enable it.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agostaging:vc04_services: bcm2835-codec: Avoid fragmenting buffers
Dave Stevenson [Fri, 15 May 2020 12:47:13 +0000 (13:47 +0100)]
staging:vc04_services: bcm2835-codec: Avoid fragmenting buffers

The firmware by default is quite happy to fragment encoded
frames as the original MMAL and IL APIs support this.
V4L2 doesn't, so we need to enable the firmware option to avoid this.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agostaging:vc04_services: bcm2835-codec: Request headers with I-frame
Dave Stevenson [Fri, 15 May 2020 12:43:08 +0000 (13:43 +0100)]
staging:vc04_services: bcm2835-codec: Request headers with I-frame

V4L2 wishes to have the codec header bytes in the same buffer as the
first encoded frame, so it does become 1-in 1-out for encoding.
The firmware now has an option to do this, so enable it.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agostaging: vc04_services: mmal-vchiq: Update parameters list
Dave Stevenson [Fri, 15 May 2020 12:42:10 +0000 (13:42 +0100)]
staging: vc04_services: mmal-vchiq: Update parameters list

Adds in a couple of new MMAL parameter defines.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agodrm/vc4: Fix VIC usage with Broadcast RGB
Dave Stevenson [Thu, 14 May 2020 13:44:15 +0000 (14:44 +0100)]
drm/vc4: Fix VIC usage with Broadcast RGB

Adding the Broadcast RGB range selection broke the VIC
field of the AVI infoframes on HDMI, zeroing them for all
modes on an HDMI monitor.

Correct this so that it is only zeroed if the range is
contrary to the standard range of the mode.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agosc16is7xx: Fix for hardware flow control
Phil Elwell [Wed, 13 May 2020 19:10:15 +0000 (20:10 +0100)]
sc16is7xx: Fix for hardware flow control

The SC16IS7XX hardware flow control is mishandled by the driver in
a number of ways:

  1. The set_baud method accidentally clears it when setting EFR bit.
  2. Even though hardware flow control is enabled, it isn't indicated
     back to the serial framework.
  3. Applying the flow control clears the EFR bit.
  4. The CTS support is not indicated in the return from
     sc16is7xx_get_mctrl.

Address all of those issues using a mixture of patches found on the
linked pages.

See: https://github.com/raspberrypi/linux/issues/2542
See: https://www.spinics.net/lists/linux-serial/msg21794.html

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agomedia: bcm2835-unicam: Always service interrupts
Dave Stevenson [Wed, 13 May 2020 17:28:27 +0000 (18:28 +0100)]
media: bcm2835-unicam: Always service interrupts

From when bringing up the driver, there was a check in the isr
to ignore interrupts (claiming them handled) should the driver
not be streaming.

The VPU now will not register a camera driver if it finds a
CSI2 node enabled in device tree, therefore this flawed check is
redundant.

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

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agoconfigs: Use the upstream cpufreq driver
Phil Elwell [Tue, 12 May 2020 16:18:28 +0000 (17:18 +0100)]
configs: Use the upstream cpufreq driver

Switch to the upstream cpufreq driver on non-BCM2835 Pis.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoconfigs: Include the firmware-clocks driver
Phil Elwell [Tue, 12 May 2020 16:17:45 +0000 (17:17 +0100)]
configs: Include the firmware-clocks driver

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoARM: dts: Enable firmware-clocks on all Pis
Phil Elwell [Wed, 6 May 2020 16:02:26 +0000 (17:02 +0100)]
ARM: dts: Enable firmware-clocks on all Pis

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agodefconfig: Add CMA and system dma-heaps to the config
Dave Stevenson [Fri, 8 May 2020 19:44:12 +0000 (20:44 +0100)]
defconfig: Add CMA and system dma-heaps to the config

The CMA dma-heap allocator can be used in place of vcsm-cma
doing the allocation side, thereby simplifying that driver.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agodma-heap: Make the symbol 'dma_heap_ioctl_cmds' static
zhong jiang [Tue, 17 Dec 2019 19:08:22 +0000 (00:38 +0530)]
dma-heap: Make the symbol 'dma_heap_ioctl_cmds' static

Commit 7d411afe8444060454a53b1f9b70ee78b3e75ef1 upstream.

Fix the following sparse warning.

drivers/dma-buf/dma-heap.c:109:14: warning: symbol 'dma_heap_ioctl_cmds'
was not declared. Should it be static?

Acked-by: Andrew F. Davis <afd@ti.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: zhong jiang <zhongjiang@huawei.com>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
 [sumits: rebased over IOCTL rename patches]
Link: https://patchwork.freedesktop.org/patch/msgid/20191217190822.1969-1-sumit.semwal@linaro.org
4 years agodma-buf: fix resource leak on -ENOTTY error return path
Colin Ian King [Mon, 16 Dec 2019 16:10:59 +0000 (16:10 +0000)]
dma-buf: fix resource leak on -ENOTTY error return path

Commit f9d3b2c600075d1f79efcd5cdb1718c2f554c0f9 upstream.

The -ENOTTY error return path does not free the allocated
kdata as it returns directly. Fix this by returning via the
error handling label err.

Addresses-Coverity: ("Resource leak")
Fixes: c02a81fba74f ("dma-buf: Add dma-buf heaps framework")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20191216161059.269492-1-colin.king@canonical.com
4 years agodma-buf: heaps: Remove redundant heap identifier from system heap name
Andrew F. Davis [Mon, 16 Dec 2019 13:34:05 +0000 (08:34 -0500)]
dma-buf: heaps: Remove redundant heap identifier from system heap name

The heaps are already in a directory of heaps, adding _heap to a heap
name is redundant. This patch is only a name change, no logic is changed.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20191216133405.1001-3-afd@ti.com
4 years agodma-buf: heaps: Use _IOCTL_ for userspace IOCTL identifier
Andrew F. Davis [Mon, 16 Dec 2019 13:34:04 +0000 (08:34 -0500)]
dma-buf: heaps: Use _IOCTL_ for userspace IOCTL identifier

Commit b3b4346544b571c96d46be615b9db69a601ce4c8 upstream.

This is more consistent with the DMA and DRM frameworks convention. This
patch is only a name change, no logic is changed.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20191216133405.1001-2-afd@ti.com
4 years agokselftests: Add dma-heap test
John Stultz [Tue, 3 Dec 2019 17:26:41 +0000 (17:26 +0000)]
kselftests: Add dma-heap test

Commit a8779927fd86c91f5400bfcbccfa018a667d8350 upstream.

Add very trivial allocation and import test for dma-heaps,
utilizing the vgem driver as a test importer.

A good chunk of this code taken from:
  tools/testing/selftests/android/ion/ionmap_test.c
  Originally by Laura Abbott <labbott@redhat.com>

Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Liam Mark <lmark@codeaurora.org>
Cc: Pratik Patel <pratikp@codeaurora.org>
Cc: Brian Starkey <Brian.Starkey@arm.com>
Cc: Vincent Donnefort <Vincent.Donnefort@arm.com>
Cc: Sudipto Paul <Sudipto.Paul@arm.com>
Cc: Andrew F. Davis <afd@ti.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Chenbo Feng <fengc@google.com>
Cc: Alistair Strachan <astrachan@google.com>
Cc: Hridya Valsaraju <hridya@google.com>
Cc: Sandeep Patil <sspatil@google.com>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Dave Airlie <airlied@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Reviewed-by: Brian Starkey <brian.starkey@arm.com>
Acked-by: Sandeep Patil <sspatil@android.com>
Acked-by: Laura Abbott <labbott@redhat.com>
Tested-by: Ayan Kumar Halder <ayan.halder@arm.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20191203172641.66642-6-john.stultz@linaro.org
4 years agodma-buf: heaps: Add CMA heap to dmabuf heaps
John Stultz [Tue, 3 Dec 2019 17:26:40 +0000 (17:26 +0000)]
dma-buf: heaps: Add CMA heap to dmabuf heaps

Commit b61614ec318aae0c77ecd2816878d851dd61d9a6 upstream.

This adds a CMA heap, which allows userspace to allocate
a dma-buf of contiguous memory out of a CMA region.

This code is an evolution of the Android ION implementation, so
thanks to its original author and maintainters:
  Benjamin Gaignard, Laura Abbott, and others!

NOTE: This patch only adds the default CMA heap. We will enable
selectively adding other CMA memory regions to the dmabuf heaps
interface with a later patch (which requires a dt binding)

Cc: Laura Abbott <labbott@redhat.com>
Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Liam Mark <lmark@codeaurora.org>
Cc: Pratik Patel <pratikp@codeaurora.org>
Cc: Brian Starkey <Brian.Starkey@arm.com>
Cc: Vincent Donnefort <Vincent.Donnefort@arm.com>
Cc: Sudipto Paul <Sudipto.Paul@arm.com>
Cc: Andrew F. Davis <afd@ti.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Chenbo Feng <fengc@google.com>
Cc: Alistair Strachan <astrachan@google.com>
Cc: Hridya Valsaraju <hridya@google.com>
Cc: Sandeep Patil <sspatil@google.com>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Dave Airlie <airlied@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Reviewed-by: Brian Starkey <brian.starkey@arm.com>
Acked-by: Sandeep Patil <sspatil@android.com>
Acked-by: Laura Abbott <labbott@redhat.com>
Tested-by: Ayan Kumar Halder <ayan.halder@arm.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20191203172641.66642-5-john.stultz@linaro.org
4 years agodma-buf: heaps: Add system heap to dmabuf heaps
John Stultz [Tue, 3 Dec 2019 17:26:39 +0000 (17:26 +0000)]
dma-buf: heaps: Add system heap to dmabuf heaps

Commit efa04fefebbd724ffda7f49e42d057a7217c45b0 upstream.

This patch adds system heap to the dma-buf heaps framework.

This allows applications to get a page-allocator backed dma-buf
for non-contiguous memory.

This code is an evolution of the Android ION implementation, so
thanks to its original authors and maintainters:
  Rebecca Schultz Zavin, Colin Cross, Laura Abbott, and others!

Cc: Laura Abbott <labbott@redhat.com>
Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Liam Mark <lmark@codeaurora.org>
Cc: Pratik Patel <pratikp@codeaurora.org>
Cc: Brian Starkey <Brian.Starkey@arm.com>
Cc: Vincent Donnefort <Vincent.Donnefort@arm.com>
Cc: Sudipto Paul <Sudipto.Paul@arm.com>
Cc: Andrew F. Davis <afd@ti.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Chenbo Feng <fengc@google.com>
Cc: Alistair Strachan <astrachan@google.com>
Cc: Hridya Valsaraju <hridya@google.com>
Cc: Sandeep Patil <sspatil@google.com>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Dave Airlie <airlied@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Reviewed-by: Brian Starkey <brian.starkey@arm.com>
Acked-by: Sandeep Patil <sspatil@android.com>
Acked-by: Laura Abbott <labbott@redhat.com>
Tested-by: Ayan Kumar Halder <ayan.halder@arm.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20191203172641.66642-4-john.stultz@linaro.org
4 years agodma-buf: heaps: Add heap helpers
John Stultz [Tue, 3 Dec 2019 17:26:38 +0000 (17:26 +0000)]
dma-buf: heaps: Add heap helpers

Commit 5248eb12fea890a03b4cdc3ef546d6319d4d9b73 upstream.

Add generic helper dmabuf ops for dma heaps, so we can reduce
the amount of duplicative code for the exported dmabufs.

This code is an evolution of the Android ION implementation, so
thanks to its original authors and maintainters:
  Rebecca Schultz Zavin, Colin Cross, Laura Abbott, and others!

Cc: Laura Abbott <labbott@redhat.com>
Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Liam Mark <lmark@codeaurora.org>
Cc: Pratik Patel <pratikp@codeaurora.org>
Cc: Brian Starkey <Brian.Starkey@arm.com>
Cc: Vincent Donnefort <Vincent.Donnefort@arm.com>
Cc: Sudipto Paul <Sudipto.Paul@arm.com>
Cc: Andrew F. Davis <afd@ti.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Chenbo Feng <fengc@google.com>
Cc: Alistair Strachan <astrachan@google.com>
Cc: Hridya Valsaraju <hridya@google.com>
Cc: Sandeep Patil <sspatil@google.com>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Dave Airlie <airlied@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Reviewed-by: Brian Starkey <brian.starkey@arm.com>
Acked-by: Sandeep Patil <sspatil@android.com>
Acked-by: Laura Abbott <labbott@redhat.com>
Tested-by: Ayan Kumar Halder <ayan.halder@arm.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20191203172641.66642-3-john.stultz@linaro.org
4 years agodma-buf: Add dma-buf heaps framework
Andrew F. Davis [Tue, 3 Dec 2019 17:26:37 +0000 (17:26 +0000)]
dma-buf: Add dma-buf heaps framework

Commit c02a81fba74fe3488ad6b08bfb5a1329005418f8 upstream.
This framework allows a unified userspace interface for dma-buf
exporters, allowing userland to allocate specific types of memory
for use in dma-buf sharing.

Each heap is given its own device node, which a user can allocate
a dma-buf fd from using the DMA_HEAP_IOC_ALLOC.

This code is an evoluiton of the Android ION implementation,
and a big thanks is due to its authors/maintainers over time
for their effort:
  Rebecca Schultz Zavin, Colin Cross, Benjamin Gaignard,
  Laura Abbott, and many other contributors!

Cc: Laura Abbott <labbott@redhat.com>
Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Liam Mark <lmark@codeaurora.org>
Cc: Pratik Patel <pratikp@codeaurora.org>
Cc: Brian Starkey <Brian.Starkey@arm.com>
Cc: Vincent Donnefort <Vincent.Donnefort@arm.com>
Cc: Sudipto Paul <Sudipto.Paul@arm.com>
Cc: Andrew F. Davis <afd@ti.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Chenbo Feng <fengc@google.com>
Cc: Alistair Strachan <astrachan@google.com>
Cc: Hridya Valsaraju <hridya@google.com>
Cc: Sandeep Patil <sspatil@google.com>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Dave Airlie <airlied@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Brian Starkey <brian.starkey@arm.com>
Acked-by: Sandeep Patil <sspatil@android.com>
Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20191203172641.66642-2-john.stultz@linaro.org
4 years agoudmabuf: fix dma-buf cpu access
Gurchetan Singh [Tue, 17 Dec 2019 23:02:28 +0000 (15:02 -0800)]
udmabuf: fix dma-buf cpu access

Commit 1ffe09590121fbb3786d6c860acdd200f7ab095c upstream.

I'm just going to put Chia's review comment here since it sums
the issue rather nicely:

"(1) Semantically, a dma-buf is in DMA domain.  CPU access from the
importer must be surrounded by {begin,end}_cpu_access.  This gives the
exporter a chance to move the buffer to the CPU domain temporarily.

(2) When the exporter itself has other means to do CPU access, it is
only reasonable for the exporter to move the buffer to the CPU domain
before access, and to the DMA domain after access.  The exporter can
potentially reuse {begin,end}_cpu_access for that purpose.

Because of (1), udmabuf does need to implement the
{begin,end}_cpu_access hooks.  But "begin" should mean
dma_sync_sg_for_cpu and "end" should mean dma_sync_sg_for_device.

Because of (2), if userspace wants to continuing accessing through the
memfd mapping, it should call udmabuf's {begin,end}_cpu_access to
avoid cache issues."

Reported-by: Chia-I Wu <olvaffe@gmail.com>
Suggested-by: Chia-I Wu <olvaffe@gmail.com>
Fixes: 284562e1f348 ("udmabuf: implement begin_cpu_access/end_cpu_access hooks")
Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/20191217230228.453-1-gurchetansingh@chromium.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
4 years agoudmabuf: implement begin_cpu_access/end_cpu_access hooks
Gurchetan Singh [Tue, 3 Dec 2019 01:36:27 +0000 (17:36 -0800)]
udmabuf: implement begin_cpu_access/end_cpu_access hooks

Commit 284562e1f34874e267d4f499362c3816f8f6bc3f upstream.

With the misc device, we should end up using the result of
get_arch_dma_ops(..) or dma-direct ops.

This can allow us to have WC mappings in the guest after
synchronization.

Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/20191203013627.85991-4-gurchetansingh@chromium.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
4 years agoudmabuf: separate out creating/destroying scatter-table
Gurchetan Singh [Tue, 3 Dec 2019 01:36:26 +0000 (17:36 -0800)]
udmabuf: separate out creating/destroying scatter-table

Commit 17a7ce203490459cff14fb1c8f9a15d65fd1c544 upstream.

These are nice functions and can be re-used.

Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/20191203013627.85991-3-gurchetansingh@chromium.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
4 years agoudmabuf: add a pointer to the miscdevice in dma-buf private data
Gurchetan Singh [Tue, 3 Dec 2019 01:36:25 +0000 (17:36 -0800)]
udmabuf: add a pointer to the miscdevice in dma-buf private data

Commit c1bbed668997268c9edccdc9db1bd1487d9e20b0 upstream.

Will be used later.

v2: rename 'udmabuf_misc' to 'device' (kraxel)

Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/20191203013627.85991-2-gurchetansingh@chromium.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
4 years agoudmabuf: use cache_sgt_mapping option
Gurchetan Singh [Tue, 3 Dec 2019 01:36:24 +0000 (17:36 -0800)]
udmabuf: use cache_sgt_mapping option

Commit bc7a71da43b48333f84c6534ab43d240e34cf9eb uptream.

The GEM prime helpers do it, so should we. It's also possible to make
it optional later.

Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/20191203013627.85991-1-gurchetansingh@chromium.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
4 years agoudmabuf: Remove deleted map/unmap handlers.
Maarten Lankhorst [Tue, 26 Nov 2019 14:25:16 +0000 (15:25 +0100)]
udmabuf: Remove deleted map/unmap handlers.

Commit 19d32ace8b6acebc45da1ea748000ac79ccc7721 upstream.

Commit 7f0de8d80816 ("dma-buf: Drop dma_buf_k(un)map") removed map/unmap
handlers, but they still existed in udmabuf. Remove them there as well

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Fixes: 7f0de8d80816 ("dma-buf: Drop dma_buf_k(un)map")
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: linux-media@vger.kernel.org
Cc: linaro-mm-sig@lists.linaro.org
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20191126142516.630200-1-maarten.lankhorst@linux.intel.com
4 years agoconfigs: Add imx477 sensor driver to all Raspberry Pi defconfigs
Naushir Patuck [Thu, 7 May 2020 14:36:25 +0000 (15:36 +0100)]
configs: Add imx477 sensor driver to all Raspberry Pi defconfigs

This commit enables the imx477 sensor driver in the following
defconfigs:

bcm2709_defconfig
bcm2711_defconfig
bcmrpi_defconfig
bcmrpi3_defconfig

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 years agomedia: i2c: imx477: Add support for adaptive frame control
Naushir Patuck [Fri, 8 May 2020 08:41:17 +0000 (09:41 +0100)]
media: i2c: imx477: Add support for adaptive frame control

Use V4L2_CID_EXPOSURE_AUTO_PRIORITY to control if the driver should
automatically adjust the sensor frame length based on exposure time,
allowing variable frame rates and longer exposures.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 years agomedia: i2c: Add driver for Sony IMX477 sensor
Naushir Patuck [Fri, 8 May 2020 09:00:12 +0000 (10:00 +0100)]
media: i2c: Add driver for Sony IMX477 sensor

Adds a driver for the 12MPix Sony IMX477 CSI2 sensor.
Whilst the sensor supports 2 or 4 CSI2 data lanes, this driver
currently only supports 2 lanes.

The following Bayer modes are currently available:

4056x3040 12-bit @ 10fps
2028x1520 12-bit (binned) @ 40fps
2028x1050 12-bit (cropped/binned) @ 50fps
1012x760 10-bit (scaled) @ 120 fps

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 years agodtoverlays: Add IMX477 sensor overlay
Naushir Patuck [Thu, 7 May 2020 14:50:04 +0000 (15:50 +0100)]
dtoverlays: Add IMX477 sensor overlay

Add an overlay for the Sony IMX477 CMOS sensor device.
Also update overlay README and Makefile.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 years agodt-bindings: media: i2c: Add IMX477 CMOS sensor binding
Naushir Patuck [Thu, 7 May 2020 14:50:54 +0000 (15:50 +0100)]
dt-bindings: media: i2c: Add IMX477 CMOS sensor binding

Add YAML device tree binding for IMX477 CMOS image sensor.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 years agoraspberrypi: dts: Switch to discrete ALSA devices
Phil Elwell [Tue, 12 May 2020 07:32:42 +0000 (08:32 +0100)]
raspberrypi: dts: Switch to discrete ALSA devices

Add the command line options required to enable audio over discrete
ALSA devices.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agooverlays: Move "fixed-clock" nodes to the root
Phil Elwell [Mon, 11 May 2020 14:12:21 +0000 (15:12 +0100)]
overlays: Move "fixed-clock" nodes to the root

Apart from some special cases, device objects are only created for
nodes if they are children of a bus or the root node. "fixed-clock"
is one of the exceptions that will be instantiated wherever it is
found, but only during kernel initialisation - ruling out loading the
overlay at runtime.

Move most of the affected clocks to be children of the root, only
leaving those in overlays that could be multiply instantiated, to avoid
a potential name clash.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agooverlays: tc358743: Use intra-overlay fragments
Phil Elwell [Mon, 11 May 2020 10:55:45 +0000 (11:55 +0100)]
overlays: tc358743: Use intra-overlay fragments

The tc358743 overlay was written using a workaround to a problem with
fragments that target other fragments, but this had the unfortunate
side-effect of preventing the overlay from being applied at runtime
(the kernel doesn't allow nodes to be overwritten by an overlay, only
properties).

The current firmware and dtoverlay/dtparam utilities include support
for these "intra-overlay" fragments, so remove the workaround and do
it properly.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoconfig: Enable CONFIG_DRM_VC4_HDMI_CEC
Dom Cobley [Thu, 7 May 2020 17:16:09 +0000 (18:16 +0100)]
config: Enable CONFIG_DRM_VC4_HDMI_CEC

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
4 years agovc4_hdmi: Remove cec_available flag as always supported
Dom Cobley [Thu, 7 May 2020 17:16:09 +0000 (18:16 +0100)]
vc4_hdmi: Remove cec_available flag as always supported

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
4 years agovc4_hdmi: Adjust CEC ref clock based on its input clock
Dom Cobley [Thu, 7 May 2020 17:16:08 +0000 (18:16 +0100)]
vc4_hdmi: Adjust CEC ref clock based on its input clock

2711 uses a fixed 27MHz input, earlier models use the HSM clock

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
4 years agovc4_hdmi: Make irq shared
Dom Cobley [Thu, 7 May 2020 17:16:08 +0000 (18:16 +0100)]
vc4_hdmi: Make irq shared

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
4 years agovc4_hdmi_regs: Make interrupt mask variant specific
Dom Cobley [Thu, 7 May 2020 17:16:08 +0000 (18:16 +0100)]
vc4_hdmi_regs: Make interrupt mask variant specific

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
4 years agovc4_hdmi_regs: Add Intr2 register block
Dom Cobley [Thu, 7 May 2020 17:16:07 +0000 (18:16 +0100)]
vc4_hdmi_regs: Add Intr2 register block

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
4 years agovc4_hdmi: Fix up CEC registers
Dom Cobley [Thu, 7 May 2020 17:16:07 +0000 (18:16 +0100)]
vc4_hdmi: Fix up CEC registers

Fix an incorrect register address, add a
missing one and reorder into address order

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
4 years agovc4_hdmi: Fix register offset when sending longer CEC messages
Dom Cobley [Thu, 7 May 2020 17:16:07 +0000 (18:16 +0100)]
vc4_hdmi: Fix register offset when sending longer CEC messages

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
4 years agooverlays: sc16is752-spi1: Add xtal parameter
Phil Elwell [Wed, 6 May 2020 13:25:20 +0000 (14:25 +0100)]
overlays: sc16is752-spi1: Add xtal parameter

The other sc16is75x overlays have an xtal parameter to allow a
different crystal frequency to be specified, but sc16is752-spi1
doesn't. Fix this omission.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agovideo: bcm2708_fb: Disable FB if no displays found
Phil Elwell [Tue, 5 May 2020 18:45:41 +0000 (19:45 +0100)]
video: bcm2708_fb: Disable FB if no displays found

If the firmware hasn't detected a display, the driver would assume
one display was available, but because it had failed to retrieve the
display size it would try to allocate a zero-sized buffer.

Avoid the allocation failure by bailing out early if no display is
found.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agomedia: bcm2835: unicam: Fix uninitialized warning
Jacko Dirks [Tue, 5 May 2020 12:33:31 +0000 (14:33 +0200)]
media: bcm2835: unicam: Fix uninitialized warning

Signed-off-by: Jacko Dirks <jdirks.linuxdev@gmail.com>
4 years agomedia: i2c: tc358743: Fix fallthrough warning
Jacko Dirks [Tue, 5 May 2020 12:28:14 +0000 (14:28 +0200)]
media: i2c: tc358743: Fix fallthrough warning

Signed-off-by: Jacko Dirks <jdirks.linuxdev@gmail.com>
4 years agooverlays: Make use of intra-overlay fragments
Phil Elwell [Mon, 4 May 2020 14:13:24 +0000 (15:13 +0100)]
overlays: Make use of intra-overlay fragments

The firmware and runtime overlay support has recently been updated to
correctly process fragments that target other fragments within the
overlay. Make use of that ability and avoid the use of the awkward
target-path = "<alias>/..." workaround and for better readability.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agovc4_hdmi_phy: Fix typo in phy_get_cp_current
popcornmix [Mon, 6 Apr 2020 16:07:31 +0000 (17:07 +0100)]
vc4_hdmi_phy: Fix typo in phy_get_cp_current

This is stored in a 6-bit register field which causes a WARN

Signed-off-by: popcornmix <popcornmix@gmail.com>
4 years agoconfigs: Add missing TOUCHSCREEN_RASPBERRYPI_FW=m
Phil Elwell [Mon, 4 May 2020 12:38:39 +0000 (13:38 +0100)]
configs: Add missing TOUCHSCREEN_RASPBERRYPI_FW=m

The 32- and 64-bit bcm2711 defconfigs are missing support for the
official Raspberry Pi touchscreen.

Restore the missing config settings.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoconfigs: Add missing PPS configs
Phil Elwell [Mon, 4 May 2020 10:06:04 +0000 (11:06 +0100)]
configs: Add missing PPS configs

The arm64 bcm2711_defconfig was inexplicably missing three PPS config
options. Add them, along with another missing option from
bcmrpi3_defconfig.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agooverlays: gpio-keys: Avoid open-drain warnings
Phil Elwell [Sat, 2 May 2020 12:43:06 +0000 (13:43 +0100)]
overlays: gpio-keys: Avoid open-drain warnings

The i2c-gpio driver expects to use a GPIO in open-drain mode. Failure
to configure it in that way causes alarming warnings in the kernel log.
The BCM283x and BCM2711 GPIO blocks don't support open-drain mode,
but i2c-gpio works anyway. Silence the warning by declaring that
open-drain mode has been enabled by other means.

See: https://github.com/raspberrypi/firmware/issues/1381

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agostaging: vc04_services: isp: Make all references to bcm2835_isp_fmt const
Dave Stevenson [Fri, 1 May 2020 15:54:20 +0000 (16:54 +0100)]
staging: vc04_services: isp: Make all references to bcm2835_isp_fmt const

The array of potential formats and their configuration should be const.
Rework all accesses so that this is possible.

The list of supported formats was taking a copy of entries from this table.
This is unnecessary, therefore allocate an array of pointers instead of
an array of entries.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agostaging: vc04_services: isp: Remove duplicated initialisation
Dave Stevenson [Fri, 1 May 2020 16:49:08 +0000 (17:49 +0100)]
staging: vc04_services: isp: Remove duplicated initialisation

With the codec code from which this was derived, the driver had to
get the supported formats for both input and output ports.
This had been copied across, however here we have independent nodes
for each port, but the code had been left in to do the same thing
twice.
Remove the duplicate.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agooverlays: Make the i2c-gpio overlay safe again
Phil Elwell [Fri, 1 May 2020 16:56:13 +0000 (17:56 +0100)]
overlays: Make the i2c-gpio overlay safe again

Like many overlays, the i2c-gpio overlay goes to efforts to avoid
generating warnings about #address-cells and #size-cells not
being defined, which it does by defining them. Unfortunately this
is fatal if they don't match what the system requires, and the
recent switch to #size-cells = 2 on 2711 made i2c-gpio very
dangerous.

In the absence of the knowledge of a clean way to fix this, just delete
the declarations and suffer the warnings.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoARM: dts: bcm2711: Allow 40-bit DMA for SPI
Phil Elwell [Thu, 30 Apr 2020 11:43:05 +0000 (12:43 +0100)]
ARM: dts: bcm2711: Allow 40-bit DMA for SPI

Add the spi_dma4 DT parameter to enable use of the 40-bit DMA channels
to drive SPI. Note that there are only 3-4 40-bit channels available,
and using this parameter claims 2 of them.

Usage: dtparam=spi_dma4

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agobcm2835-dma: Add proper 40-bit DMA support
Phil Elwell [Thu, 4 Apr 2019 12:33:47 +0000 (13:33 +0100)]
bcm2835-dma: Add proper 40-bit DMA support

BCM2711 has 4 DMA channels with a 40-bit address range, allowing them
to access the full 4GB of memory on a Pi 4.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agoSQUASH: spi: Demote SPI_CS_HIGH warning to KERN_DEBUG
Phil Elwell [Fri, 1 May 2020 13:58:23 +0000 (14:58 +0100)]
SQUASH: spi: Demote SPI_CS_HIGH warning to KERN_DEBUG

This warning is unavoidable from a client's perspective and
doesn't indicate anything wrong (just surprising).

SQUASH with "spi: use_gpio_descriptor fixup moved to spi_setup"

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agostaging: vc04_services: ISP: Add enum_framesizes ioctl
Naushir Patuck [Fri, 1 May 2020 13:15:24 +0000 (14:15 +0100)]
staging: vc04_services: ISP: Add enum_framesizes ioctl

This is used to enumerate available frame sizes on all nodes
apart from statistics output.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 years agomedia: bcm2835-unicam: Fix reference counting in unicam_open
Dave Stevenson [Thu, 30 Apr 2020 08:52:50 +0000 (09:52 +0100)]
media: bcm2835-unicam: Fix reference counting in unicam_open

The reference counting of node->open was only incremented after
a check that the node was v4l2_fh_is_singular_file, which resulted
in the counting going wrong and s_power not being called at an
appropriate time.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agomedia: bcm2835-unicam: Do not stop streaming in unicam_release
Dave Stevenson [Wed, 29 Apr 2020 21:05:09 +0000 (22:05 +0100)]
media: bcm2835-unicam: Do not stop streaming in unicam_release

unicam_release calls _vb2_fop_release, which will call stop_streaming
if that particular node was streaming. Calling it unconditionally (as
the code was) means that if a second handle was opened eg to alter
a setting, on closing that connection it also stopped Unicam.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agomedia: bcm2835-unicam: Add support for VIDIOC_[S|G]_SELECTION
Dave Stevenson [Wed, 29 Apr 2020 15:45:02 +0000 (16:45 +0100)]
media: bcm2835-unicam: Add support for VIDIOC_[S|G]_SELECTION

Sensors are now reflecting cropping and scaling parameters through
the selection API, therefore Unicam needs to forward the requests
through to the subdev.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agomedia: i2c: imx219: Declare that the driver can create events
Dave Stevenson [Mon, 20 Apr 2020 10:01:21 +0000 (11:01 +0100)]
media: i2c: imx219: Declare that the driver can create events

The flag V4L2_SUBDEV_FL_HAS_EVENTS is required if the subdev can
generate events. It can create events from the ctrl handler, therefore
this is required.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>