platform/kernel/linux-rpi.git
4 months agomedia: bcm2835-unicam: Driver for CCP2/CSI2 camera interface
Naushir Patuck [Mon, 4 May 2020 09:25:41 +0000 (12:25 +0300)]
media: bcm2835-unicam: Driver for CCP2/CSI2 camera interface

Add a driver for the Unicam camera receiver block on BCM283x processors.
Compared to the bcm2835-camera driver present in staging, this driver
handles the Unicam block only (CSI-2 receiver), and doesn't depend on
the VC4 firmware running on the VPU.

The commit is made up of a series of changes cherry-picked from the
rpi-5.4.y branch of https://github.com/raspberrypi/linux/ with
additional enhancements, forward-ported to the mainline kernel.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reported-by: kbuild test robot <lkp@intel.com>
4 months agobrcmfmac: Prefer a ccode from OTP over nvram file
Phil Elwell [Fri, 26 Jun 2020 10:51:05 +0000 (11:51 +0100)]
brcmfmac: Prefer a ccode from OTP over nvram file

Allow the nvram file to set a default ccode (regulatory domain) without
overriding one set in OTP.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agomedia: irs1125: Keep HW in sync after imager reset
Markus Proeller [Tue, 16 Jun 2020 11:33:56 +0000 (13:33 +0200)]
media: irs1125: Keep HW in sync after imager reset

When closing the video device, the irs1125 is put in power down state.
To keep V4L2 ctrls and the HW in sync, v4l2_ctrl_handler_setup is
called after power up.

The compound ctrl IRS1125_CID_MOD_PLL however has a default value
of all zeros, which puts the imager into a non responding state.
Thus, this ctrl is not written by the driver into HW after power up.
The userspace has to take care to write senseful data.

Signed-off-by: Markus Proeller <markus.proeller@pieye.org>
4 months agomedia: irs1125: Atomic access to imager reconfiguration
Markus Proeller [Tue, 16 Jun 2020 11:31:36 +0000 (13:31 +0200)]
media: irs1125: Atomic access to imager reconfiguration

Instead of changing the exposure and framerate settings for all sequences,
they can be changed for every sequence individually now. Therefore the
IRS1125_CID_SAFE_RECONFIG ctrl has been removed and replaced by
IRS1125_CID_SAFE_RECONFIG_S<seq_num>_EXPO and *_FRAME ctrls.

The consistency check in the sequence ctrl IRS1125_CID_SEQ_CONFIG
is removed.

Signed-off-by: Markus Proeller <markus.proeller@pieye.org>
4 months agomedia: irs1125: Refactoring and debug messages
Markus Proeller [Tue, 16 Jun 2020 11:27:42 +0000 (13:27 +0200)]
media: irs1125: Refactoring and debug messages

Changed some variable names to comply with checkpatch --strict mode.
Debug messages added.

Signed-off-by: Markus Proeller <markus.proeller@pieye.org>
4 months agomedia: irs1125: Using i2c_transfer for ic2 reads
Markus Proeller [Tue, 16 Jun 2020 11:24:31 +0000 (13:24 +0200)]
media: irs1125: Using i2c_transfer for ic2 reads

Reading data over i2c is done by using i2c_transfer to ensure that this
operation can't be interrupted.

Signed-off-by: Markus Proeller <markus.proeller@pieye.org>
4 months agoPCI: brcmstb: Add DT property to control L1SS
Phil Elwell [Thu, 11 Jun 2020 08:57:03 +0000 (09:57 +0100)]
PCI: brcmstb: Add DT property to control L1SS

The BRCM PCIe block has controls to enable control of the CLKREQ#
signal by the L1SS, and to gate the refclk with the CLKREQ# input.
These controls are mutually exclusive - the upstream code sets the
latter, but some use cases require the former.

Add a Device Tree property - brcm,enable-l1ss - to switch to the
L1SS configuration.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agogpiolib: Don't prevent IRQ usage of output GPIOs
Phil Elwell [Tue, 24 Apr 2018 13:42:27 +0000 (14:42 +0100)]
gpiolib: Don't prevent IRQ usage of output GPIOs

Upstream Linux deems using output GPIOs to generate IRQs as a bogus
use case, even though the BCM2835 GPIO controller is capable of doing
so. A number of users would like to make use of this facility, so
disable the checks.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 months 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 months 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 months 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 months 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 months agostaging: vchiq: Load bcm2835_isp driver from vchiq
Naushir Patuck [Wed, 22 Apr 2020 07:32:32 +0000 (08:32 +0100)]
staging: vchiq: Load bcm2835_isp driver from vchiq

bcmn2835_isp is a platform driver dependent on vchiq,
therefore add the load/unload functions for it to vchiq.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 months agomedia: uapi: v4l-ctrls: Add CID base for the bcm2835-isp driver
Naushir Patuck [Tue, 21 Apr 2020 14:06:19 +0000 (15:06 +0100)]
media: uapi: v4l-ctrls: Add CID base for the bcm2835-isp driver

We are reserving controls for the new bcm2835-isp driver.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 months agomedia: uapi: v4l2-core: Add ISP statistics output V4L2 fourcc type
Naushir Patuck [Thu, 23 Apr 2020 09:20:26 +0000 (10:20 +0100)]
media: uapi: v4l2-core: Add ISP statistics output V4L2 fourcc type

Add V4L2_META_FMT_BCM2835_ISP_STATS V4L2 format type.

This new format will be used by the BCM2835 ISP device to return
out ISP statistics for 3A.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 months agomedia: uapi: Add MEDIA_BUS_FMT_SENSOR_DATA media bus format
Naushir Patuck [Tue, 21 Jan 2020 14:06:47 +0000 (14:06 +0000)]
media: uapi: Add MEDIA_BUS_FMT_SENSOR_DATA media bus format

This patch adds MEDIA_BUS_FMT_SENSOR_DATA used by the bcm2835-unicam
driver to support CSI-2 embedded data streams from camera sensors.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 months agomedia: uapi: v4l2-core: Add sensor ancillary data V4L2 foucc type.
Naushir Patuck [Wed, 1 Apr 2020 07:46:29 +0000 (08:46 +0100)]
media: uapi: v4l2-core: Add sensor ancillary data V4L2 foucc type.

Add V4L2_META_FMT_SENSOR_DATA format 4CC.

This new format will be used by the BCM2835 Unicam device to return
out camera sensor embedded data.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 months agospi: Force CS_HIGH if GPIO descriptors are used
Phil Elwell [Fri, 17 Apr 2020 09:46:19 +0000 (10:46 +0100)]
spi: Force CS_HIGH if GPIO descriptors are used

Commit f3186dd87669 ("spi: Optionally use GPIO descriptors for CS GPIOs")
amended of_spi_parse_dt() to always set SPI_CS_HIGH for SPI slaves whose
Chip Select is defined by a "cs-gpios" devicetree property.

This change breaks drivers whose probe functions set the mode field of
the spi_device because in doing so they clear the SPI_CS_HIGH flag.

Fix by setting SPI_CS_HIGH in spi_setup (under the same conditions as
in of_spi_parse_dt()).

See also: 83b2a8fe43bd ("spi: spidev: Fix CS polarity if GPIO descriptors are used")

Fixes: f3186dd87669 ("spi: Optionally use GPIO descriptors for CS GPIOs")
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
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 months agostaging: media: rpivid: Add Raspberry Pi V4L2 H265 decoder
John Cox [Thu, 5 Mar 2020 18:30:41 +0000 (18:30 +0000)]
staging: media: rpivid: Add Raspberry Pi V4L2 H265 decoder

This driver is for the HEVC/H265 decoder block on the Raspberry
Pi 4, and conforms to the V4L2 stateless decoder API.

Signed-off-by: John Cox <jc@kynesim.co.uk>
staging: media: rpivid: Select MEDIA_CONTROLLER and MEDIA_CONTROLLER_REQUEST_API

MEDIA_CONTROLLER_REQUEST_API is a hidden option. If rpivid depends on it,
the user would need to first enable another driver that selects
MEDIA_CONTROLLER_REQUEST_API, and only then rpivid would become available.

By selecting it instead of depending on it, it becomes possible to enable
rpivid without having to enable other potentially unnecessary drivers.

Signed-off-by: Hristo Venev <hristo@venev.name>
rpivid_h265: Fix width/height typo

Signed-off-by: popcornmix <popcornmix@gmail.com>
rpivid_h625: Fix build warnings

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
staging: rpivid: Fix crash when CMA alloc fails

If realloc to increase coeff size fails then attempt to re-allocate
the original size.  If that also fails then flag a fatal error to abort
all further decode.

Signed-off-by: John Cox <jc@kynesim.co.uk>
rpivid: Request maximum hevc clock

Query maximum and minimum clock from driver
and use those

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
rpivid: Switch to new clock api

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
rpivid: Only clk_request_done once

Fixes: 25486f49bfe2e3ae13b90478d1eebd91413136ad
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
media: rpivid: Remove the need to have num_entry_points set

VAAPI H265 has num entry points but never sets it. Allow a VAAPI
shim to work without requiring rewriting the VAAPI driver.
num_entry_points can be calculated from the slice_segment_addr
of the next slice so delay processing until we have that.

Also includes some minor cosmetics.

Signed-off-by: John Cox <jc@kynesim.co.uk>
media: rpivid: Convert to MPLANE

Use multi-planar interface rather than single plane interface. This
allows dmabufs holding compressed data to be resized.

Signed-off-by: John Cox <jc@kynesim.co.uk>
media: rpivid: Add an enable count to irq claim Qs

Add an enable count to the irq Q structures to allow the irq logic to
block further callbacks if resources associated with the irq are not
yet available.

Signed-off-by: John Cox <jc@kynesim.co.uk>
media: rpivid: Add a Pass0 to accumulate slices and rework job finish

Due to overheads in assembling controls and requests it is worth having
the slice assembly phase separate from the h/w pass1 processing. Create
a queue to service pass1 rather than have the pass1 finished callback
trigger the next slice job.

This requires a rework of the logic that splits up the buffer and
request done events. This code contains two ways of doing that, we use
Ezequiel Garcias <ezequiel@collabora.com> solution, but expect that
in the future this will be handled by the framework in a cleaner manner.

Fix up the handling of some of the memory exhaustion crashes uncovered
in the process of writing this code.

Signed-off-by: John Cox <jc@kynesim.co.uk>
media: rpivid: Map cmd buffer directly

It is unnecessary to have a separate dmabuf to hold the cmd buffer.
Map it directly from the kmalloc.

Signed-off-by: John Cox <jc@kynesim.co.uk>
media: rpivid: Improve values returned when setting output format

Guess a better value for the compressed bitstream buffer size

Signed-off-by: John Cox <jc@kynesim.co.uk>
media: rpivid: Improve stream_on/off conformance & clock setup

Fix stream on & off such that failures leave the driver in the correct
state.  Ensure that the clock is on when we are streaming and off when
all contexts attached to this device have stopped streaming.

Signed-off-by: John Cox <jc@kynesim.co.uk>
media: rpivid: Improve SPS/PPS error handling/validation

Move size and width checking from bitstream processing to control
validation

Signed-off-by: John Cox <jc@kynesim.co.uk>
media: rpivid: Fix H265 aux ent reuse of the same slot

It is legitimate, though unusual, for an aux ent associated with a slot
to be selected in phase 0 before a previous selection has been used and
released in phase 2. Fix such that if the slot is found to be in use
that the aux ent associated with it is reused rather than an new aux
ent being created. This fixes a problem where when the first aux ent
was released the second was lost track of.

This bug spotted in Nick's testing. It may explain some other occasional,
unreliable decode error reports where dmesg included "Missing DPB AUX
ent" logging.

Signed-off-by: John Cox <jc@kynesim.co.uk>
media: rpivid: Update to compile with new hevc decode params

DPB entries have moved from slice params to the new decode params
attribute - update to deal with this.  Also fixes fallthrough
warnings which seem to be new in 5.14.

Signed-off-by: John Cox <jc@kynesim.co.uk>
media: rpivid: Make slice ctrl dynamic

Allows the user to submit a whole frames worth of slice headers in
one lump along with a single bitstream dmabuf for the whole lot.
This saves potentially a lot of bitstream copying.

Signed-off-by: John Cox <jc@kynesim.co.uk>
media: rpivid: Only create aux entries for H265 if needed

Only create aux entries of mv info for frames where that info might
be used by a later frame.  This saves some memory bandwidth and
potentially some memory.

Signed-off-by: John Cox <jc@kynesim.co.uk>
media: rpivid: Avoid returning EINVAL to a G_FMT ioctl

V4L2 spec says that G/S/TRY_FMT IOCTLs should never return errors for
anything other than wrong buffer types. Improve the capture format
function such that this is so and unsupported values get converted
to supported ones properly.

Signed-off-by: John Cox <jc@kynesim.co.uk>
media: rpivid: Remove unused ctx state variable and defines

Remove unused ctx state tracking variable and associated defines.
Their presence implies they might be used, but they aren't.

Signed-off-by: John Cox <jc@kynesim.co.uk>
media: rpivid: Ensure IRQs have completed before uniniting context

Before uniniting the decode context sync with the IRQ queues to ensure
that decode no longer has any buffers in use.  This fixes a problem that
manifested as ffmpeg leaking CMA buffers when it did a stream off on
OUTPUT before CAPTURE, though in reality it was probably much more
dangerous than that.

Signed-off-by: John Cox <jc@kynesim.co.uk>
media: rpivid: remove min_buffers_needed from src queue

Remove min_buffers_needed=1 from src queue init. Src buffers are bound
to media requests therefore this setting is not needed and generates
a WARN in kernel 5.16.

Signed-off-by: John Cox <jc@kynesim.co.uk>
rpivid: Use clk_get_max_rate()

The driver was using clk_round_rate() to figure out the maximum clock
rate that was allowed for the HEVC clock.

Since we have a function to return it directly now, let's use it.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
media: rpivid: Apply V4L2 stateless API changes

media: rpivid: Fix fallthrough warning

Replace old-style /* FALLTHRU */ with fallthrough;

Signed-off-by: John Cox <jc@kynesim.co.uk>
media: rpivid: Set min value as well as max for HEVC_DECODE_MODE

As only one value can be accepted set both min and max to that value.

Signed-off-by: John Cox <jc@kynesim.co.uk>
media: rpivid: Accept ANNEX_B start codes

Allow the START_CODE control to take ANNEX_B as a value. This makes no
difference to any part of the decode process as the added bytes are in
data that we ignore. This helps my testing and may help userland code
that expects to send those bytes.

Signed-off-by: John Cox <jc@kynesim.co.uk>
rpivid: Convert to new clock rate API

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 months agoRFC: media: Add media_request_{pin,unpin} API
Ezequiel Garcia [Sun, 21 Mar 2021 19:38:54 +0000 (16:38 -0300)]
RFC: media: Add media_request_{pin,unpin} API

This is probably not the API we will want to add, but it
should show what semantics are needed by drivers.

The goal is to allow the OUTPUT (aka source) buffer and the
controls associated to a request to be released from the request,
and in particular return the OUTPUT buffer back to userspace,
without signalling the media request fd.

This is useful for devices that are able to pre-process
the OUTPUT buffer, therefore able to release it before
the decoding is finished. These drivers should signal
the media request fd only after the CAPTURE buffer is done.

Tested-by: John Cox <jc@kynesim.co.uk>
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
4 months agomedia: dt-bindings: media: Add binding for the Raspberry PI HEVC decoder
Dave Stevenson [Tue, 17 Mar 2020 10:53:16 +0000 (10:53 +0000)]
media: dt-bindings: media: Add binding for the Raspberry PI HEVC decoder

Adds a binding for the HEVC decoder found on the BCM2711 / Raspberry Pi 4.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agomedia: videodev2.h: Add a format for column YUV4:2:0 modes
Dave Stevenson [Fri, 24 Jan 2020 14:28:21 +0000 (14:28 +0000)]
media: videodev2.h: Add a format for column YUV4:2:0 modes

Some of the Broadcom codec blocks use a column based YUV4:2:0 image
format, so add the documentation and defines for both 8 and 10 bit
versions.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agobcmgenet: Disable skip_umac_reset by default
popcornmix [Wed, 1 Apr 2020 10:22:44 +0000 (11:22 +0100)]
bcmgenet: Disable skip_umac_reset by default

Possible fixed upstream by 'net: bcmgenet: keep MAC in reset until PHY is up'

Signed-off-by: popcornmix <popcornmix@gmail.com>
4 months agodt-bindings: pci: Add DT docs for Brcmstb PCIe device
Jim Quinlan [Mon, 15 Jan 2018 23:28:39 +0000 (18:28 -0500)]
dt-bindings: pci: Add DT docs for Brcmstb PCIe device

The DT bindings description of the Brcmstb PCIe device is described.  This
node can be used by almost all Broadcom settop box chips, using
ARM, ARM64, or MIPS CPU architectures.

Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
4 months agoof: overlay: Correct symbol path fixups
Phil Elwell [Thu, 6 Feb 2020 12:23:15 +0000 (12:23 +0000)]
of: overlay: Correct symbol path fixups

When symbols from overlays are added to the live tree their paths must
be rebased. The translated symbol is normally the result of joining
the fragment-relative path (with a leading "/") to the target path
(either copied directly from the "target-path" property or resolved
from the phandle). This translation fails when the target is the root
node (a common case for Raspberry Pi overlays) because the resulting
path starts with a double slash. For example, if target-path is "/" and
the fragment adds a node called "newnode", the label associated with
that node will be assigned the path "//newnode", which can't be found
in the tree.

Fix the failure case by explicitly replacing a target path of "/" with
an empty string.

Fixes: d1651b03c2df ("of: overlay: add overlay symbols to live device tree")

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agovideo: fbdev: bcm2708_fb: Use common compat header
Phil Elwell [Mon, 2 Mar 2020 14:42:23 +0000 (14:42 +0000)]
video: fbdev: bcm2708_fb: Use common compat header

The definition of compat_ptr is now common for most platforms, but
requires the inclusion of <linux/compat.h>.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agopinctrl: bcm2835: Remove gpiochip on error
Phil Elwell [Mon, 6 Jan 2020 16:04:30 +0000 (16:04 +0000)]
pinctrl: bcm2835: Remove gpiochip on error

A failure in gpiochip_irqchip_add leads to a leak of a gpiochip. Fix
the leak with the use of devm_gpiochip_add_data.

Fixes: 85ae9e512f43 ("pinctrl: bcm2835: switch to GPIOLIB_IRQCHIP")
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 months agostaging: vchiq_arm: Give vchiq children DT nodes
Phil Elwell [Mon, 3 Feb 2020 17:30:46 +0000 (17:30 +0000)]
staging: vchiq_arm: Give vchiq children DT nodes

vchiq kernel clients are now instantiated as platform drivers rather
than using DT, but the children of the vchiq interface may still
benefit from access to DT properties. Give them the option of a
a sub-node of the vchiq parent for configuration and to allow
them to be disabled.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agoInitialise rpi-firmware before clk-bcm2835
Luke Hinds [Wed, 22 Jan 2020 16:03:00 +0000 (16:03 +0000)]
Initialise rpi-firmware before clk-bcm2835

The IMA (Integrity Measurement Architecture) looks for a TPM (Trusted
Platform Module) having been registered when it initialises; otherwise
it assumes there is no TPM. It has been observed on BCM2835 that IMA
is initialised before TPM, and that initialising the BCM2835 clock
driver before the firmware driver has the effect of reversing this
order.

Change the firmware driver to initialise at core_initcall, delaying the
BCM2835 clock driver to postcore_initcall.

See: https://github.com/raspberrypi/linux/issues/3291
     https://github.com/raspberrypi/linux/pull/3297

Signed-off-by: Luke Hinds <lhinds@redhat.com>
Co-authored-by: Phil Elwell <phil@raspberrypi.org>
4 months agoARM: bcm: Backport BCM2711 support from upstream
Stefan Wahren [Fri, 27 Dec 2019 10:40:56 +0000 (11:40 +0100)]
ARM: bcm: Backport BCM2711 support from upstream

Make the BCM2711 a different machine, but keep it in board_bcm2835.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
4 months agostaging: vchiq: Use the old dma controller for OF config on platform devices
Dave Stevenson [Tue, 18 Jun 2019 11:15:50 +0000 (12:15 +0100)]
staging: vchiq: Use the old dma controller for OF config on platform devices

vchiq on Pi4 is no longer under the soc node, therefore it
doesn't get the dma-ranges for the VPU.

Switch to using the configuration of the old dma controller as
that will set the dma-ranges correctly.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agostaging: vchiq_arm: Set up dma ranges on child devices
Dave Stevenson [Tue, 29 Jan 2019 16:13:25 +0000 (16:13 +0000)]
staging: vchiq_arm: Set up dma ranges on child devices

The VCHIQ driver now loads the audio, camera, codec, and vc-sm
drivers as platform drivers. However they were not being given
the correct DMA configuration.

Call of_dma_configure with the parent (VCHIQ) parameters to be
inherited by the child.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agoclk-raspberrypi: Allow cpufreq driver to also adjust gpu clocks
popcornmix [Mon, 9 Sep 2019 14:49:56 +0000 (15:49 +0100)]
clk-raspberrypi: Allow cpufreq driver to also adjust gpu clocks

For performance/power it is beneficial to adjust gpu clocks with arm clock.
This is how the downstream cpufreq driver works

Signed-off-by: popcornmix <popcornmix@gmail.com>
4 months agov3d_gem: Kick the clock so firmware knows we are using firmware clock interface
popcornmix [Thu, 5 Sep 2019 16:59:14 +0000 (17:59 +0100)]
v3d_gem: Kick the clock so firmware knows we are using firmware clock interface

Setting the v3d clock to low value allows firmware to handle dvfs in case
where v3d hardware is not being actively used (e.g. console use).

Signed-off-by: popcornmix <popcornmix@gmail.com>
4 months agov3d_drv: Handle missing clock more gracefully
popcornmix [Fri, 23 Aug 2019 15:34:38 +0000 (16:34 +0100)]
v3d_drv: Handle missing clock more gracefully

Signed-off-by: popcornmix <popcornmix@gmail.com>
4 months agonet:phy:2711 Allow ethernet LED mode to be set via device tree
James Hughes [Thu, 31 Oct 2019 14:39:44 +0000 (14:39 +0000)]
net:phy:2711 Allow ethernet LED mode to be set via device tree

Add device tree entries and code to allow the specification of
the lighting modes for the LED's on the ethernet connector.

Signed-off-by: James Hughes <james.hughes@raspberrypi.org>
net:phy:2711 Change the default ethernet LED actions

This should return default behaviour back to that of previous
releases.

4 months agostaging: vchiq_arm: Register bcm2835-codec as a platform driver
Dave Stevenson [Wed, 6 Nov 2019 13:57:58 +0000 (13:57 +0000)]
staging: vchiq_arm: Register bcm2835-codec as a platform driver

Following the same pattern as bcm2835-camera and bcm2835-audio,
register the V4L2 codec driver as a platform driver

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agostaging: vchiq_arm: Register vcsm-cma as a platform driver
Dave Stevenson [Wed, 6 Nov 2019 13:57:48 +0000 (13:57 +0000)]
staging: vchiq_arm: Register vcsm-cma as a platform driver

Following the same pattern as bcm2835-camera and bcm2835-audio,
register the vcsm-cma driver as a platform driver

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agodrm/v3d: Suppress all but the first MMU error
Phil Elwell [Mon, 11 Nov 2019 20:18:08 +0000 (20:18 +0000)]
drm/v3d: Suppress all but the first MMU error

The v3d driver currently encounters a lot of MMU PTE exceptions, so
only log the first to avoid swamping the kernel log.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 months agomedia: i2c: Add a driver for the Infineon IRS1125 depth sensor
Markus Proeller [Thu, 10 Oct 2019 17:12:36 +0000 (19:12 +0200)]
media: i2c: Add a driver for the Infineon IRS1125 depth sensor

The Infineon IRS1125 is a time of flight depth sensor that
has a CSI-2 interface.

Add a V4L2 subdevice driver for this device.

Signed-off-by: Markus Proeller <markus.proeller@pieye.org>
4 months agodt-bindings: Add binding for the Infineon IRS1125 sensor
Markus Proeller [Thu, 10 Oct 2019 17:12:08 +0000 (19:12 +0200)]
dt-bindings: Add binding for the Infineon IRS1125 sensor

Adds a binding for the Infineon IRS1125 time-of-flight depth
sensor.

Signed-off-by: Markus Proeller <markus.proeller@pieye.org>
4 months agoARM: bcm: Switch board, clk and pinctrl to bcm2711 compatible
Stefan Wahren [Thu, 19 Sep 2019 18:45:30 +0000 (20:45 +0200)]
ARM: bcm: Switch board, clk and pinctrl to bcm2711 compatible

After the decision to use bcm2711 compatible for upstream, we should
switch all accepted compatibles to bcm2711. So we can boot with
one DTB the down- and the upstream kernel.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
4 months agostaging:bcm2835-camera: Fix the cherry-pick of AWB Greyworld
Dave Stevenson [Mon, 8 Feb 2021 11:48:35 +0000 (11:48 +0000)]
staging:bcm2835-camera: Fix the cherry-pick of AWB Greyworld

The cherry-pick of the patch that added the greyworld AWB mode
was incomplete. Fix it up.

Fixes: b3ef481fe243 "staging: bcm2835-camera: Add greyworld AWB mode"
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agomedia: v4l2: Add Greyworld AWB control name
John Cox [Fri, 6 Aug 2021 13:32:44 +0000 (14:32 +0100)]
media: v4l2: Add Greyworld AWB control name

Add name for greyworld to white_balance preset names.
This patch previously applied to v4l2-ctrl.c but that was split
and deleted.

Signed-off-by: John Cox <jc@kynesim.co.uk>
4 months agostaging: bcm2835-camera: Add greyworld AWB mode
Dave Stevenson [Fri, 6 Sep 2019 14:13:06 +0000 (15:13 +0100)]
staging: bcm2835-camera: Add greyworld AWB mode

This is mainly used for the NoIR camera which has no IR
filter and can completely confuse normal AWB presets.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agov4l2: Add a Greyworld AWB mode.
Dave Stevenson [Fri, 6 Sep 2019 14:04:51 +0000 (15:04 +0100)]
v4l2: Add a Greyworld AWB mode.

Adds a simple greyworld white balance preset, mainly for use
with cameras without an IR filter (eg Raspberry Pi NoIR)

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agoDocumentation: devicetree: Add documentation for imx378 sensor
David Plowman [Tue, 29 Jun 2021 13:38:23 +0000 (14:38 +0100)]
Documentation: devicetree: Add documentation for imx378 sensor

The imx378 sensor is compatible with the imx477 and shares common
device tree settings.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
4 months agomedia: i2c: imx519: Support for the Sony IMX519 sensor
Lee Jackson [Fri, 27 Aug 2021 06:36:55 +0000 (14:36 +0800)]
media: i2c: imx519: Support for the Sony IMX519 sensor

dt-bindings: media: i2c: Add IMX519 CMOS sensor binding

Add YAML device tree binding for IMX519 CMOS image sensor, and
the relevant MAINTAINERS entries.

Signed-off-by: Lee Jackson <info@arducam.com>
media: i2c: Add driver for IMX519 sensor

Adds a driver for the 16MPix IMX519 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:

4656x3496 10-bit @ 10fps
3840x2160 10-bit (cropped) @ 21fps
2328x1748 10-bit (binned) @ 30fps
1920x1080 10-bit (cropped/binned) @ 60fps
1280x720 10-bit (cropped/binned) @ 120fps

Signed-off-by: Lee Jackson <info@arducam.com>
media: i2c: imx519: Advertise embedded data node on media pad 1

This commit updates the imx519 driver to adverise support for embedded
data streams.

The imx519 sensor subdevice overloads the media pad to differentiate
between image stream (pad 0) and embedded data stream (pad 1) when
performing the v4l2_subdev_pad_ops functions.

Signed-off-by: Lee Jackson <info@arducam.com>
media: i2c: imx519: Sensor should report RAW color space

Tested on Raspberry Pi running libcamera.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
media: i2c: Update imx519 Kconfig entry

Bring the IMX519 Kconfig declaration in line with the upstream entries.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agomedia: i2c: imx477: Support for the Sony IMX477 sensor
Naushir Patuck [Thu, 7 May 2020 14:50:54 +0000 (15:50 +0100)]
media: i2c: imx477: Support for the Sony IMX477 sensor

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>
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>
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>
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>
media: i2c: imx477: Parse and register properties

Parse device properties and register controls for them using the V4L2
fwnode properties helpers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
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>
media: i2c: imx477: Remove auto frame length adjusting

The V4L2_CID_EXPOSURE_AUTO_PRIORITY was used to let the sensor control
frame length (effectively framerate) based on the requested exposure
time requested. Remove this feature as it is never used, and goes
against how V4L2 likes to handle exposure and vblank controls.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
media: i2c: imx477: Add very long exposure control to the driver

Add support for very long exposures by using the exposure multiplier
register. Userland does not need to pass any additional controls to
enable long exposures, it simply requests a larger vblank to extend the
exposure control range appropriately.

Currently, since hblank is fixed, a maximum of approximately 124 seconds
of exposure time can be used. In a future change, hblank could also be
controlled in userland to give over 200 seconds of exposure time.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
media: i2c: imx477: Fix crop height for 2028x1080 mode

The crop height for this mode was set at 2600 lines, it should be 2160
lines instead.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
media: i2c: imx477: Replace existing 1012x760 mode

The existing 1012x760 120 fps mode has significant IQ problem using
the internal sensor scaler. Replace this mode with a 1332x990 120 fps
mode instead. This new mode has a smaller field of view, but does not
suffer from the bad IQ of the original mode.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
media: i2c: imx477: Remove internal v4l2_mbus_framefmt from the state

The only field in this struct that is used is the format code, so
replace the struct with this single field.

Save the format code in imx477_set_pad_format() when setting up a new
mode so that imx477_get_pad_format() performs the right lookup.
Otherwise, this caused a bug where the mode lookup occurred on the
12-bit table rather than the 10-bit table.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
media: i2c: imx477: Remove unused function parameter

The struct imx477 *ctrl parameter is not used in the function
imx477_adjust_exposure_range(), so remove it.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
media: i2c: imx477: Fix for long exposure limit calculations

Do not scale IMX477_EXPOSURE_OFFSET with the long exposure factor during
the limit calculations. This allows larger exposure times, and does seem to be
what the sensor is doing internally.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
media: i2c: imx477: Extend driver to support imx378 sensor

The imx378 sensor is almost identical to the imx477 and can be
supported as a "compatible" sensor with just a few extra register
writes.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
media: i2c: imx477: Fix framerates for 1332x990 mode

The imx477 driver's line length for this mode had not been updated to
the value supplied to us by the sensor manufacturer. With this
correction the sensor delivers the framerates that are expected.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
media: i2c: imx477: Allow control of on-sensor DPC

A module parameter "dpc_enable" is added to allow the control of the
sensor's on-board DPC (Defective Pixel Correction) function.

This is a global setting to be configured before using the sensor;
there is no intention that this would ever be changed on-the-fly.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
media: i2c: imx477: Sensor should report RAW color space

Tested on Raspberry Pi running libcamera.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
media: i2c: imx477: Add vsync trigger_mode parameter

trigger_mode == 0 (default) => no effect / no registers written
trigger_mode == 1           => source
trigger_mode == 2           => sink

This can be set e.g. in /boot/cmdline.txt as imx477.trigger_mode=N

Signed-off-by: Jonas Jacob <jonas.jacob@neocortexvision.com>
media: i2c: Update imx477 Kconfig entry

Bring the IMX477 Kconfig declaration in line with upstream entries.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
media: i2c: imx477: Correct minimum exposure lines

The minimum number of exposure lines value (IMX477_EXPOSURE_MIN) was
previously 20 but this is not correct. The datasheet is not completely
explicit, however the new value of 4 has been tested with all the
sensor modes supported by this driver, and matches the lowest exposure
value of 114us that could be achieved wtih Raspberry Pi's legacy
firmware driver.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
media: i2c: imx477: Allow dynamic horizontal blanking control

Currently, the V4L2_CID_HBLANK control is marked as read-only. Remove this
restriction and allow userland to modify the control if needed.

Set the maximum limit of the line length to 0xfff0.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
media: i2c: imx477: Reset hblank on mode switch

Reset the hblank control to the minimum value on every mode switch. This is to
account for userland instances that do not yet control hblank, otherwise it
gets set to a non-optimal value.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
media: i2c: imx477: Do not unconditionally adjust hblank and vblank limits

On a mode change, only call imx477_set_framing_limits() to adjust the hblank
and vblank limits if the new mode is different from the existing mode. This
preserves any manual control values the user might have set.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 months agoarch/arm64: Add Revision, Serial, Model to cpuinfo
Phil Elwell [Tue, 3 Sep 2019 17:17:25 +0000 (18:17 +0100)]
arch/arm64: Add Revision, Serial, Model to cpuinfo

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 months agoarch/arm: Add model string to cpuinfo
Phil Elwell [Tue, 3 Sep 2019 17:16:56 +0000 (18:16 +0100)]
arch/arm: Add model string to cpuinfo

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 months agonet: bcmgenet: Workaround #2 for Pi4 Ethernet fail
Phil Elwell [Fri, 9 Aug 2019 07:51:43 +0000 (08:51 +0100)]
net: bcmgenet: Workaround #2 for Pi4 Ethernet fail

Some combinations of Pi 4Bs and Ethernet switches don't reliably get a
DCHP-assigned IP address, leaving the unit with a self=assigned 169.254
address. In the failure case, the Pi is left able to receive packets
but not send them, suggesting that the MAC<->PHY link is getting into
a bad state.

It has been found empirically that skipping a reset step by the genet
driver prevents the failures. No downsides have been discovered yet,
and unlike the forced renegotiation it doesn't increase the time to
get an IP address, so the workaround is enabled by default; add

  genet.skip_umac_reset=n

to the command line to disable it.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 months agohid: usb: Add device quirks for Freeway Airmouse T3 and MX3
Jonathan Bell [Thu, 1 Aug 2019 15:41:20 +0000 (16:41 +0100)]
hid: usb: Add device quirks for Freeway Airmouse T3 and MX3

These wireless mouse/keyboard combo remote control devices specify
multiple "wheel" events in their report descriptors. The wheel events
are incorrectly defined and apparently map to accelerometer data, leading
to spurious mouse scroll events being generated at an extreme rate when
the device is moved.

As a workaround, use HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE to mask
feeding the extra wheel events to the input subsystem.

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

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
4 months agodrivers: char: add chardev for mmap'ing the RPiVid control registers
Jonathan Bell [Thu, 9 May 2019 13:30:37 +0000 (14:30 +0100)]
drivers: char: add chardev for mmap'ing the RPiVid control registers

Based on the gpiomem driver, allow mapping of the decoder register
spaces such that userspace can access control/status registers.
This driver is intended for use with a custom ffmpeg backend accelerator
prior to a v4l2 driver being written.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
driver: char: rpivid: Destroy the legacy device on remove

The legacy name support created a new device that was never destroyed.
If the driver was unloaded and reloaded, it failed due to the
device already existing.

Fixes: "75f1d14 driver: char: rpivid - also support legacy name"
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
driver: char: rpivid: Clean up error handling use of ERR_PTR/IS_ERR

The driver used an unnecessary intermediate void* variable so it
only called ERR_PTR once to convert to the error value.

Switch to converting as the error arises to remove these intermediate
variables.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
driver: char: rpivid: Add error handling to the legacy device load

The return value from device_create for the legacy device was never
checked or handled. Add the required error handling.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
driver: char: rpivid: Fix coding style whitespace issues.

Makes checkpatch happier.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
driver: char: rpimem: Add SPDX licence header.

Stops checkpatch complaining.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
driver: char: rpivid: Fix access to freed memory

The error path during probe frees the private memory block, and
then promptly dereferences it to log an error message.

Use the base device instead of the pointer to it in the private
structure.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
driver: char: rpivid: Remove legacy name support

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
driver: char: rpivid: Don't map more than wanted

Limit mappings to the permitted range, but don't map more than asked
for otherwise we walk off the end of the allocated VMA.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agodrm/v3d: Clock V3D down when not in use.
Eric Anholt [Thu, 2 May 2019 20:22:53 +0000 (13:22 -0700)]
drm/v3d: Clock V3D down when not in use.

My various attempts at re-enabling runtime PM have failed, so just
crank the clock down when V3D is idle to reduce power consumption.

Signed-off-by: Eric Anholt <eric@anholt.net>
drm/v3d: Plug dma_fence leak

The irq_fence and done_fence are given a reference that is never
released. The necessary dma_fence_put()s seem to have been
deleted in error in an earlier commit.

Fixes: 0b73676836b2 ("drm/v3d: Clock V3D down when not in use.")

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 months agoi2c: bcm2835: Set clock-stretch timeout to 35ms
Phil Elwell [Fri, 12 Jul 2019 14:38:35 +0000 (15:38 +0100)]
i2c: bcm2835: Set clock-stretch timeout to 35ms

The BCM2835 I2C blocks have a register to set the clock-stretch
timeout - how long the device is allowed to hold SCL low - in bus
cycles. The current driver doesn't write to the register, therefore
the default value of 64 cycles is being used for all devices.

Set the timeout to the value recommended for SMBus - 35ms.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 months agoarm: bcm2835: Add bcm2838 compatible string.
Phil Elwell [Tue, 11 Jun 2019 16:38:28 +0000 (17:38 +0100)]
arm: bcm2835: Add bcm2838 compatible string.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 months agousbhid: call usb_fixup_endpoint after mangling intervals
Jonathan Bell [Tue, 11 Jun 2019 10:42:03 +0000 (11:42 +0100)]
usbhid: call usb_fixup_endpoint after mangling intervals

Lets the mousepoll override mechanism work with xhci.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
4 months agousb: xhci: drop and add the endpoint context in xhci_fixup_endpoint()
Jonathan Bell [Fri, 10 Mar 2023 14:21:42 +0000 (14:21 +0000)]
usb: xhci: drop and add the endpoint context in xhci_fixup_endpoint()

Setting both the Drop and Add bits on the input context prevents the
corruption of split transactions seen with the BCM2711 XHCI controller,
which is a dwc3 variant.

This is a downstream feature that allows usbhid to restrict polling
intervals on mice and keyboards, and was only tested on a VL805 which
didn't complain about the fact the endpoint got added twice.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
4 months agousb: xhci: workaround for bogus SET_DEQ_PENDING endpoint state
Jonathan Bell [Wed, 11 Aug 2021 14:33:57 +0000 (15:33 +0100)]
usb: xhci: workaround for bogus SET_DEQ_PENDING endpoint state

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

An unknown unsafe memory access can result in the ep_state variable
in xhci_virt_ep being trampled with a stuck SET_DEQ_PENDING state
despite successful completion of a Set TR Deq Pointer command.

All URB enqueue/dequeue calls for the endpoint will fail in this state
so no transfers are possible until the device is reconnected.

As a workaround, clear the flag if we see it set and issue a new Set
TR Deq command anyway - this should be harmless, as a prior Set TR Deq
command will only have been issued in the Stopped state, and if the
endpoint is Running then the controller is required to ignore it and
respond with a Context State Error event TRB.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
4 months agoxhci: implement xhci_fixup_endpoint for interval adjustments
Jonathan Bell [Tue, 11 Jun 2019 10:33:39 +0000 (11:33 +0100)]
xhci: implement xhci_fixup_endpoint for interval adjustments

Must be called in a non-atomic context, after the endpoint
has been registered with the hardware via xhci_add_endpoint
and before the first URB is submitted for the endpoint.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
4 months agousb: add plumbing for updating interrupt endpoint interval state
Jonathan Bell [Tue, 11 Jun 2019 09:55:00 +0000 (10:55 +0100)]
usb: add plumbing for updating interrupt endpoint interval state

xHCI caches device and endpoint data after the interface is configured,
so an explicit command needs to be issued for any device driver wanting
to alter the polling interval of an endpoint.

Add usb_fixup_endpoint() to allow drivers to do this. The fixup must be
called after calculating endpoint bandwidth requirements but before any
URBs are submitted.

If polling intervals are shortened, any bandwidth reservations are no
longer valid but in practice polling intervals are only ever relaxed.

Limit the scope to interrupt transfers for now.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
4 months agonet: genet: enable link energy detect powerdown for external PHYs
Jonathan Bell [Tue, 14 May 2019 16:17:59 +0000 (17:17 +0100)]
net: genet: enable link energy detect powerdown for external PHYs

There are several warts surrounding bcmgenet_mii_probe() as this
function is called from ndo_open, but it's calling registration-type
functions. The probe should be called at probe time and refactored
such that the PHY device data can be extracted to limit the scope
of this flag to Broadcom PHYs.

For now, pass this flag in as it puts our attached PHY into a low-power
state when disconnected.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
4 months agobcmgenet: Better coalescing parameter defaults
Phil Elwell [Wed, 27 Mar 2019 13:45:46 +0000 (13:45 +0000)]
bcmgenet: Better coalescing parameter defaults

Set defaults for TX and RX packet coalescing to be equivalent to:

  # ethtool -C eth0 tx-frames 10
  # ethtool -C eth0 rx-usecs 50

This may be something we want to set via DT parameters in the
future.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 months agobcmgenet: constrain max DMA burst length
Jonathan Bell [Wed, 12 Sep 2018 13:44:53 +0000 (14:44 +0100)]
bcmgenet: constrain max DMA burst length

4 months agohwrng: iproc-rng200: Add BCM2838 support
Stefan Wahren [Sat, 4 May 2019 15:06:15 +0000 (17:06 +0200)]
hwrng: iproc-rng200: Add BCM2838 support

The HWRNG on the BCM2838 is compatible to iproc-rng200, so add the
support to this driver instead of bcm2835-rng.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
hwrng: iproc-rng200: Correct SoC name

The Pi 4 SoC is called BCM2711, not BCM2838.

Fixes: "hwrng: iproc-rng200: Add BCM2838 support"

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agoarm: bcm2835: DMA can only address 1GB
Phil Elwell [Wed, 29 May 2019 14:47:42 +0000 (15:47 +0100)]
arm: bcm2835: DMA can only address 1GB

The legacy peripherals can only address the first gigabyte of RAM, so
ensure that DMA allocations are restricted to that region.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 months agoarm: bcm2835: Fix FIQ early ioremap
Phil Elwell [Wed, 20 Feb 2019 08:49:39 +0000 (08:49 +0000)]
arm: bcm2835: Fix FIQ early ioremap

The ioremapping creates mappings within the vmalloc area. The
equivalent early function, create_mapping, now checks that the
requested explicit virtual address is between VMALLOC_START and
VMALLOC_END. As there is no reason to have any correlation between
the physical and virtual addresses, put the required mappings at
VMALLOC_START and above.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 months agow1: w1-gpio: Make GPIO an output for strong pullup
Phil Elwell [Wed, 12 Jun 2019 16:15:05 +0000 (17:15 +0100)]
w1: w1-gpio: Make GPIO an output for strong pullup

The logic to drive the data line high to implement a strong pullup
assumed that the pin was already an output - setting a value does
not change an input.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 months agostaging: mmal-vchiq: Fix memory leak in error path
Dave Stevenson [Thu, 2 May 2019 14:50:01 +0000 (15:50 +0100)]
staging: mmal-vchiq: Fix memory leak in error path

On error, vchiq_mmal_component_init could leave the
event context allocated for ports.
Clean them up in the error path.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agostaging: mmal-vchiq: Free the event context for control ports
Dave Stevenson [Wed, 1 May 2019 12:27:23 +0000 (13:27 +0100)]
staging: mmal-vchiq: Free the event context for control ports

vchiq_mmal_component_init calls init_event_context for the
control port, but vchiq_mmal_component_finalise didn't free
it, causing a memory leak..

Add the free call.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agostaging: mmal-vchiq: Update mmal_parameters.h with recently defined params
Dave Stevenson [Mon, 18 Feb 2019 15:52:29 +0000 (15:52 +0000)]
staging: mmal-vchiq: Update mmal_parameters.h with recently defined params

mmal_parameters.h hasn't been updated to reflect additions made
over the last few years. Update it to reflect the currently
supported parameters.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agostaging: mmal_vchiq: Add in the Bayer encoding formats
Dave Stevenson [Wed, 13 Feb 2019 12:33:29 +0000 (12:33 +0000)]
staging: mmal_vchiq: Add in the Bayer encoding formats

The list of formats was copied before Bayer support was added.
The ISP supports Bayer and is being supported by the bcm2835_codec
driver, so add in the encodings for them.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agostaging: mmal-vchiq: Fix client_component for 64 bit kernel
Dave Stevenson [Tue, 22 Jan 2019 12:04:09 +0000 (12:04 +0000)]
staging: mmal-vchiq: Fix client_component for 64 bit kernel

The MMAL client_component field is used with the event
mechanism to allow the client to identify the component for
which the event is generated.
The field is only 32bits in size, therefore we can't use a
pointer to the component in a 64 bit kernel.

Component handles are already held in an array per VCHI
instance, so use the array index as the client_component handle
to avoid having to create a new IDR for this purpose.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agomedia: videobuf2: Allow exporting of a struct dmabuf
Dave Stevenson [Mon, 29 Oct 2018 17:57:45 +0000 (17:57 +0000)]
media: videobuf2: Allow exporting of a struct dmabuf

videobuf2 only allowed exporting a dmabuf as a file descriptor,
but there are instances where having the struct dma_buf is
useful within the kernel.

Split the current implementation into two, one step which
exports a struct dma_buf, and the second which converts that
into an fd.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agostaging: vc04_services: Support sending data to MMAL ports
Dave Stevenson [Mon, 24 Sep 2018 17:26:02 +0000 (18:26 +0100)]
staging: vc04_services: Support sending data to MMAL ports

Add the ability to send data to ports. This only supports
zero copy mode as the required bulk transfer setup calls
are not done.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agostaging: mmal-vchiq: Add support for event callbacks.
Dave Stevenson [Mon, 24 Sep 2018 17:15:38 +0000 (18:15 +0100)]
staging: mmal-vchiq: Add support for event callbacks.

(Preparation for the codec driver).
The codec uses the event mechanism to report things such as
resolution changes. It is signalled by the cmd field of the buffer
being non-zero.

Add support for passing this information out to the client.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agostaging: mmal-vchiq: Avoid use of bool in structures
Dave Stevenson [Mon, 29 Oct 2018 16:20:46 +0000 (16:20 +0000)]
staging: mmal-vchiq: Avoid use of bool in structures

Fixes up a checkpatch error "Avoid using bool structure members
because of possible alignment issues".

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agomedia: tc358743: Return an appropriate colorspace from tc358743_set_fmt
Dave Stevenson [Thu, 22 Nov 2018 17:31:06 +0000 (17:31 +0000)]
media: tc358743: Return an appropriate colorspace from tc358743_set_fmt

When calling tc358743_set_fmt, the code was calling tc358743_get_fmt
to choose a valid format. However that sets the colorspace
based on what was read back from the chip. When you set the format,
then the driver would choose and program the colorspace based
on the format code.

The result was that if you called try or set format for UYVY
when the current format was RGB3 then you would get told sRGB,
and try RGB3 when current was UYVY and you would get told
SMPTE170M.

The value programmed into the chip is determined by this driver,
therefore there is no need to read back the value. Return the
colorspace based on the format set/tried instead.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agoMAINTAINERS: Add entry for BCM2835 Unicam driver
Dave Stevenson [Wed, 31 Oct 2018 14:59:40 +0000 (14:59 +0000)]
MAINTAINERS: Add entry for BCM2835 Unicam driver

Adds entry for the new BCM2835 Unicam (CSI-2 receiver) driver

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agodt-bindings: Document BCM283x CSI2/CCP2 receiver
Dave Stevenson [Wed, 31 Oct 2018 14:59:06 +0000 (14:59 +0000)]
dt-bindings: Document BCM283x CSI2/CCP2 receiver

Document the DT bindings for the CSI2/CCP2 receiver peripheral
(known as Unicam) on BCM283x SoCs.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
Acked-by: Rob Herring <robh@kernel.org>
4 months agomedia: videodev2: Add helper defines for printing FOURCCs
Dave Stevenson [Wed, 31 Oct 2018 14:58:08 +0000 (14:58 +0000)]
media: videodev2: Add helper defines for printing FOURCCs

New helper defines that allow printing of a FOURCC using
printf(V4L2_FOURCC_CONV, V4L2_FOURCC_CONV_ARGS(fourcc));

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agomedia: adv7180: Add YPrPb support for ADV7282M
Dave Stevenson [Wed, 31 Oct 2018 14:57:56 +0000 (14:57 +0000)]
media: adv7180: Add YPrPb support for ADV7282M

The ADV7282M can support YPbPr on AIN1-3, but this was
not selectable from the driver. Add it to the list of
supported input modes.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agomedia: adv7180: Default to the first valid input
Dave Stevenson [Wed, 31 Oct 2018 14:57:46 +0000 (14:57 +0000)]
media: adv7180: Default to the first valid input

The hardware default is differential CVBS on AIN1 & 2, which
isn't very useful.

Select the first input that is defined as valid for the
chip variant (typically CVBS_AIN1).

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agomedia: tc358743: Check I2C succeeded during probe.
Dave Stevenson [Wed, 31 Oct 2018 14:57:34 +0000 (14:57 +0000)]
media: tc358743: Check I2C succeeded during probe.

The probe for the TC358743 reads the CHIPID register from
the device and compares it to the expected value of 0.
If the I2C request fails then that also returns 0, so
the driver loads thinking that the device is there.

Generally I2C communications are reliable so there is
limited need to check the return value on every transfer,
therefore only amend the one read during probe to check
for I2C errors.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agomedia: tc358743: Add support for 972Mbit/s link freq.
Dave Stevenson [Wed, 31 Oct 2018 14:57:21 +0000 (14:57 +0000)]
media: tc358743: Add support for 972Mbit/s link freq.

Adds register setups for running the CSI lanes at 972Mbit/s,
which allows 1080P50 UYVY down 2 lanes.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agomedia: tc358743: Increase FIFO level to 374.
Dave Stevenson [Wed, 31 Oct 2018 14:56:59 +0000 (14:56 +0000)]
media: tc358743: Increase FIFO level to 374.

The existing fixed value of 16 worked for UYVY 720P60 over
2 lanes at 594MHz, or UYVY 1080P60 over 4 lanes. (RGB888
1080P60 needs 6 lanes at 594MHz).
It doesn't allow for lower resolutions to work as the FIFO
underflows.

374 is required for 1080P24-30 UYVY over 2 lanes @ 972Mbit/s, but
>374 means that the FIFO underflows on 1080P50 UYVY over 2 lanes
@ 972Mbit/s.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agolan78xx: EEE support is now a PHY property
Phil Elwell [Tue, 5 Mar 2019 09:51:22 +0000 (09:51 +0000)]
lan78xx: EEE support is now a PHY property

Now that EEE support is a property of the PHY, use the PHY's DT node
when querying the EEE-related properties.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 months agolan78xx: Debounce link events to minimize poll storm
Joshua Emele [Thu, 8 Nov 2018 00:07:40 +0000 (16:07 -0800)]
lan78xx: Debounce link events to minimize poll storm

The bInterval is set to 4 (i.e. 8 microframes => 1ms) and the only bit
that the driver pays attention to is "link was reset". If there's a
flapping status bit in that endpoint data, (such as if PHY negotiation
needs a few tries to get a stable link) then polling at a slower rate
would act as a de-bounce.

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

4 months agofirmware: raspberrypi: Report the fw variant during probe
Dave Stevenson [Thu, 10 Jan 2019 17:58:06 +0000 (17:58 +0000)]
firmware: raspberrypi: Report the fw variant during probe

The driver already reported the firmware build date during probe.
The mailbox calls have been extended to also report the variant
 1 = standard start.elf
 2 = start_x.elf (includes camera stack)
 3 = start_db.elf (includes assert logging)
 4 = start_cd.elf (cutdown version for smallest memory footprint).
Log the variant during probe.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
firmware: raspberrypi: Report the fw git hash during probe

The firmware can now report the git hash from which it was built
via the mailbox, so report it during probe.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agonet: lan78xx: Support auto-downshift to 100Mb/s
Phil Elwell [Mon, 26 Nov 2018 19:46:58 +0000 (19:46 +0000)]
net: lan78xx: Support auto-downshift to 100Mb/s

Ethernet cables with faulty or missing pairs (specifically pairs C and
D) allow auto-negotiation to 1000Mbs, but do not support the successful
establishment of a link. Add a DT property, "microchip,downshift-after",
to configure the number of auto-negotiation failures after which it
falls back to 100Mbs. Valid values are 2, 3, 4, 5 and 0, where 0 means
never downshift.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 months agoserial: sc16is7xx: Don't spin if no data received
Phil Elwell [Fri, 2 Feb 2024 15:41:29 +0000 (15:41 +0000)]
serial: sc16is7xx: Don't spin if no data received

There are multiple causes of interrupts, errors being one, and only the
receipt of data warrants continued polling.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agofirmware: raspberrypi: Add backward compatible get_throttled
Stefan Wahren [Sat, 13 Oct 2018 11:31:21 +0000 (13:31 +0200)]
firmware: raspberrypi: Add backward compatible get_throttled

Avoid a hard userspace ABI change by adding a compatible get_throttled
sysfs entry. Its value is now feed by the GET_THROTTLED requests of the
new hwmon driver. The first access to get_throttled will generate
a warning.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
4 months agocxd2880: CXD2880_SPI_DRV should select DVB_CXD2880 with MEDIA_SUBDRV_AUTOSELECT
popcornmix [Mon, 17 Sep 2018 16:31:18 +0000 (17:31 +0100)]
cxd2880: CXD2880_SPI_DRV should select DVB_CXD2880 with MEDIA_SUBDRV_AUTOSELECT

4 months agolan78xx: Move enabling of EEE into PHY init code
Phil Elwell [Thu, 5 Apr 2018 13:46:11 +0000 (14:46 +0100)]
lan78xx: Move enabling of EEE into PHY init code

Enable EEE mode as soon as possible after connecting to the PHY, and
before phy_start. This avoids a second link negotiation, which speeds
up booting and stops the interface failing to become ready.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 months agobrcmfmac: Re-enable firmware roaming support
Phil Elwell [Wed, 20 Jun 2018 11:20:01 +0000 (12:20 +0100)]
brcmfmac: Re-enable firmware roaming support

As of 4.18, a firmware that implements the update_connect_params
method but doesn't claim to support roaming causes an error. We
disabled firmware roaming in 4.4 [1] because it appeared to
prevent disconnects, but let's try with the current firmware to see
if things have improved.

[1] https://github.com/raspberrypi/linux/commit/dd9188011786fb62a7960922f31e8e086fb2009b

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 months agonet: lan78xx: Disable TCP Segmentation Offload (TSO)
Dave Stevenson [Wed, 13 Jun 2018 14:21:10 +0000 (15:21 +0100)]
net: lan78xx: Disable TCP Segmentation Offload (TSO)

TSO seems to be having issues when packets are dropped and the
remote end uses Selective Acknowledge (SACK) to denote that
data is missing. The missing data is never resent, so the
connection eventually stalls.

There is a module parameter of enable_tso added to allow
further debugging without forcing a rebuild of the kernel.

https://github.com/raspberrypi/linux/issues/2449
https://github.com/raspberrypi/linux/issues/2482

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 months agoirqchip: irq-bcm2835: Calc. FIQ_START at boot-time
Phil Elwell [Thu, 14 Jun 2018 10:21:04 +0000 (11:21 +0100)]
irqchip: irq-bcm2835: Calc. FIQ_START at boot-time

ad83c7cb2f37 ("irqchip/irq-bcm2836: Add support for DT interrupt polarity")
changed the way that the BCM2836/7 local interrupts are mapped; instead
of being pre-mapped they are now mapped on-demand. A side effect of this
change is that the call to irq_of_parse_and_map from armctrl_of_init
creates a new mapping, forming a gap between the IRQs and the FIQs. This
 gap breaks the FIQ<->IRQ mapping which up to now has been done by assuming:

1) that the value of FIQ_START is the same as the number of normal IRQs
that will be mapped (still true), and

2) that this value is also the offset between an IRQ and its equivalent
FIQ (which is no longer the case).

Remove both assumptions by measuring the interval between the last IRQ
and the last FIQ, passing it as the parameter to init_FIQ().

Fixes: https://github.com/raspberrypi/linux/issues/2432

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 months agofirmware/raspberrypi: Notify firmware of a reboot
Phil Elwell [Sat, 12 May 2018 20:35:43 +0000 (21:35 +0100)]
firmware/raspberrypi: Notify firmware of a reboot

Register for reboot notifications, sending RPI_FIRMWARE_NOTIFY_REBOOT
over the mailbox interface on reception.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 months agoAdd ability to export gpio used by gpio-poweroff
Nick Bulleid [Thu, 10 May 2018 20:57:02 +0000 (21:57 +0100)]
Add ability to export gpio used by gpio-poweroff

Signed-off-by: Nick Bulleid <nedbulleid@fastmail.com>
Added export feature to gpio-poweroff documentation

Signed-off-by: Nick Bulleid <nedbulleid@fastmail.com>