Compare commits

...

671 Commits

Author SHA1 Message Date
Phil Elwell
5b74986eb5 Revert "drm/vc4: tests: Add helper to add a new plane to a state"
This reverts commit 379066bd69.
2024-08-05 16:50:43 +01:00
Phil Elwell
a8366aef06 dts: bcm2712-rpi: The SoC gpiochips start at 10
Make the BCM2712's onboard GPIOs start at gpiochip10, marking them out
as system resources and preventing accidental use by existing Pi 5
code.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 16:29:26 +01:00
Phil Elwell
13bc681b94 dts: bcm2712-rpi: Add gpiochip0 alias
Add a gpiochip0 aliase pointing to the rp1 GPIO node, making it appear
as gpiochip0.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 16:29:26 +01:00
Phil Elwell
e9525c45eb gpiolib: Override gpiochip numbers with DT aliases
In the same way that other subsystems support the setting of device
id numbers from Device Tree aliases, allow gpiochip numbers to be
derived from "gpiochip<n>" aliases.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 16:29:26 +01:00
Jonathan Bell
74b1c6efcb DTS: bcm2712: enable SD slot CQE by default on Pi 5
The corresponding driver implementation has seen sufficient testing,
so enable by default. Retain the dtparam so it can be turned off for test.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 16:29:26 +01:00
Dave Stevenson
93d32799b4 dtoverlays: Document display_[width|height] on hd44780-lcd overlay
The default values defining a 16x2 display weren't documented,
so add them.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 16:29:26 +01:00
Dave Stevenson
5b1e1ff550 dtoverlays: Add overlay for HD44780 via I2C PCF8574 backpack
Many HD44780 LCD displays are connected via very common I2C
GPIO expander.
We have an overlay for connecting the displays directly to GPIOs,
but not one for it connected via a backpack. Add such an overlay.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 16:29:26 +01:00
Phil Elwell
9604005eab fixup! pinctrl: bcm2712 pinctrl/pinconf driver
Fix cut-and-paste error spotted during upstreaming process.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 16:29:26 +01:00
Phil Elwell
8469c770f2 overlays: i2c-rtc: Correct bq32000 property name
The DT property for the BQ32000 controlled by trickle-resistor-ohms
parameter should be "trickle-resistor-ohms", not "abracon,tc-resistor".

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 16:29:25 +01:00
Phil Elwell
7c419054d2 .github/workflows: More jobs for kernel builds
Using the "cores * 1.5" heuristic, configure the kernel builds for the
4-core GitHub-hosted runners.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 16:29:25 +01:00
Phil Elwell
f6d2f9fdbc configs: Enable SSD1327 display support
There is now an ssd1327-spi overlay, but it's of little use without
the corresponding display drivers. Add them as modules to the usual
defconfig files.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:39 +01:00
Phil Elwell
473f6991e8 hwmon: (adt7410) Add DT compatible strings
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:39 +01:00
Phil Elwell
984313dc1a spi: dw: Clamp the minimum clock speed
The DW SPI interface has a 16-bit clock divider, where the bottom bit
of the divisor must be 0. Limit how low the clock speed can go to
prevent the clock divider from being truncated, as that could lead to
a much higher clock rate than requested.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:39 +01:00
Phil Elwell
fbf0815761 spi: dw: Fix non-DMA transmit-only transfers
Ensure the transmit FIFO has emptied before ending the transfer by
dropping the TX threshold to 0 when the last byte has been pushed into
the FIFO. Include a similar fix for the non-IRQ paths.

See: https://github.com/raspberrypi/linux/issues/6285
Fixes: 6014649de7 ("spi: dw: Save bandwidth with the TMOD_TO feature")
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:39 +01:00
Dave Stevenson
ff7565946e drm/vc4: Limit max_bpc to 8 on Pi0-3
Pi 0-3 have no deep colour support and only 24bpp output,
so max_bpc should remain as 8.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:39 +01:00
Jonathan Bell
e72f0ab539 sound/soc: dwc-i2s: choose FIFO thresholds based on DMA burst constraints
Valid ranges for the I2S peripheral's FIFO configuration include a depth
of 16 - unconditionally setting the burst length to 16 with a fifo
threshold of size/2 will cause under/overflows.

For DMA engines with restricted capabilities the requested burst length
and FIFO thresholds need to be adjusted downward accordingly.

Both the RX and TX FIFOs operate on "less-than" thresholds. Setting the
TX threshold to fifo_size minus burst means the FIFO is kept nearly-full.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:39 +01:00
Jonathan Bell
9b91c02c88 DT: bindings: add a dma-maxburst property to snps,designware-i2s
Do an end-run around ASoC in lieu of not being able to easily find the
associated DMA controller capabilities.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:39 +01:00
Jonathan Bell
675b125ca3 tty/serial: pl011: restrict RX burst FIFO threshold
If the associated DMA controller has lower burst length support than the
level the FIFO is set to, then bytes will be left in the RX FIFO at the
end of a DMA block - requiring a round-trip through the timeout interrupt
handler rather than an end-of-block DMA interrupt.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:39 +01:00
Jonathan Bell
3d26b77bd8 drivers: dw-axi-dmac: make more sensible choices about memory accesses
There's no real need to constrain MEM access widths to 32-bit (or
narrower), as the DMAC is intelligent enough to size memory accesses
appropriately. Wider accesses are more efficient.

Similarly, MEM burst lengths don't need to be a function of DEV burst
lengths - the DMAC packs/unpacks data into/from its internal channel
FIFOs appropriately. Longer accesses are more efficient.

However, the DMAC doesn't have complete support for unaligned accesses,
and blocks are always defined in integer multiples of SRC_WIDTH, so odd
source lengths or buffer alignments will prevent wide accesses being
used, as before.

There is an implicit requirement to limit requested DEV read burst
lengths to less than the hardware's maximum configured MSIZE - otherwise
RX data will be left over at the end of a block. There is no config
register that reports this value, so the AXI burst length parameter is
used to produce a facsimile of it. Warn if such a request arrives that
doesn't respect this.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:39 +01:00
Jonathan Bell
34e3262a41 spi: dw: don't immediately kill DMA transfers if an error occurs
Disabling the peripheral resets controller state which has a dangerous
side-effect of disabling the DMA handshake interface while it is active.
This can cause DMA channels to hang.

The error recovery pathway will wait for DMA to stop and reset the chip
anyway, so mask further FIFO interrupts and let the transfer finish
gracefully.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:38 +01:00
Phil Elwell
cbd4af3594 spi: dw: Save bandwidth with the TMOD_RO feature
TMOD_RO is the receive-only mode that doesn't require data in the
transmit FIFO in order to generate clock cycles. Using TMOD_RO when the
device doesn't care about the data sent to it saves CPU time and memory
bandwidth.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:38 +01:00
Phil Elwell
eed7dab3fa spi: dw: Save bandwidth with the TMOD_TO feature
TMOD_TO is the transmit-only mode that doesn't put data into the receive
FIFO. Using TMOD_TO when the user doesn't want the received data saves
CPU time and memory bandwidth.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:38 +01:00
Dave Stevenson
e19a3df47f staging: bcm2835-codec: Add support for H264 level 5.0 and 5.1
We do NOT claim to support decoding in real-time for these levels,
but can transcode some content, and handle 1920x1200.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:38 +01:00
Dave Stevenson
89f5d4b412 staging: bcm2835-codec: Disable HEADER_ON_OPEN for video encode
Video encode can defer generating the header until the first
frame is presented, which allows it to take the colourspace
information from the frame rather than just the format.

Enable that for the V4L2 driver now that the firmware populates
all the parameters.

https://github.com/raspberrypi/firmware/issues/1885

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:38 +01:00
Jonathan Bell
6018b35aa2 pinctrl: rp1: jump through hoops to avoid PCIe latency issues
Automatic link power saving plus the ability of a root complex to buffer
pending posted write transfers (and consider them complete before being
transmitted on the wire) causes compression of updates to GPIO state.

The large bandwidth of a Gen 2 x4 link means the writes toggle state
inside RP1 as fast as it can go (~20MHz), which is bad for applications
wanting bitbash with at least a few microseconds of delay between
updates.

By tailoring IO access patterns to a special Root Complex register,
writes to GPIOs can be stalled until the link wakes - meaning all writes
end up with a reasonably consistent minimum pacing (~200ns).

Additionally, write barriers have no effect other than to arbitrarily
delay some writes by a small, variable amount - so remove the vast
majority of these in areas that could be hot-paths.

Although the IO memory is mapped with Device strongly-ordered semantics,
this doesn't prevent the splitter inside BCM2712 from letting an MMIO
read request to a GPIO register get ahead of the pacing writes to the
Root Complex register. So each pin state read must flush writes out to
the Outer-Shareable domain.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:38 +01:00
Dave Stevenson
2a04bc8cc2 media: platform: Move bcm2835-unicam compatible to downstream driver
The upstream Unicam driver needs a set of userland changes to get
libcamera to run, and those aren't written or merged yet.

Move the "brcm,bcm2835-unicam" compatible from the upstream driver
to the old downstream version so that users can run libcamera
against 6.10.
Once the libcamera changes have been merged this can be reverted
to use the upstream driver.

If using the non-legacy compatible then assume we want to use
media-controller API for configuration.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:38 +01:00
Dave Stevenson
3f63a01ca5 media: bcm2835-unicam: Reinstate old downstream driver as legacy
Whilst the Unicam driver has now been upstreamed it only supports
configuration via Media Controller (not driven from the /dev/videoN
node), which makes life significantly harder for simple devices such
as mono sensors, and HDMI or analogue video to CSI2 bridge chips
(eg TC358743 and ADV7282M).

Fix up the downstream driver so that it builds, reinstate the links
from Kconfig and Makefile to it, and give it a new Kconfig name
(VIDEO_BCM2835_UNICAM_LEGACY).

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:38 +01:00
Nick Hollinghurst
15286375be drm: rp1: rp1-dsi: Switch to PLL_SYS source for DPI when 8 * lanes > bpp
To support 4 lanes, re-parent DPI clock source between DSI byteclock
(using the new "variable sources" defined in clk-rp1) and PLL_SYS.
This is to cover cases in which byteclock < pixclock <= 200MHz.

Tidying: All frequencies now in Hz (not kHz), where DSI speed is now
represented by byteclock to simplify arithmetic. Clamp DPI and byte
clocks to their legal ranges; fix up HSTX timeout to avoid an unsafe
assumption that it would return to LP state for every scanline.

Because of RP1's clock topology, the ratio between DSI and DPI clocks
may not be exact with 3 or 4 lanes, leading to slightly irregular
timings each time DSI switches between HS and LP states. Tweak to
inhibit LP during Horizontal BP when sync pulses were requested.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
2024-08-05 11:15:38 +01:00
Nick Hollinghurst
def3273b77 clk: clk-rp1: Add "varsrc" clocks to represent MIPI byte clocks
Add a new class of clocks to RP1 to represent clock sources whose
frequency changes at run-time as a side-effect of some other driver.
Specifically this is for the two MIPI DSI byte-clock sources.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
2024-08-05 11:15:38 +01:00
Nick Hollinghurst
670c24ac14 dt-bindings: clk: rp1: Add clocks representing MIPI DSI byteclock
Define two new RP1 clocks, representing the MIPI DSI byteclock
sources for the dividers used to generate MIPI[01] DPI pixel clocks.
(Previously they were represented by "fake" fixed clocks sources).

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
2024-08-05 11:15:38 +01:00
Chien-Chia Chen
b4090cef03 brcmfmac: support extsae with psk / 1x offloading
support sae executed in wpa_supplicant and offload 4-way handshake offload.

Signed-off-by: Chien-Chia Chen <carella.chen@infineon.com>

JIRA: SWWLAN-142424
2024-08-05 11:15:38 +01:00
Phil Elwell
e4867bc9e2 brcmfmac: Add "extsae" as an alias for "sae_ext"
The Cypress firmwares use "extsae" to indicate wpa_supplicant-hosted
SAE/WPA3.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:38 +01:00
Phil Elwell
541cf493ab brcmfmac: Only match complete feature names
The firmware advertises its features as a string of words separated by
spaces. Ensure that feature names are only matched in their entirety.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:38 +01:00
Jonathan Bell
4598a6fc5c mmc: restrict posted write counts for SD cards in CQ mode
Command Queueing requires Write Cache and Power off Notification support
from the card - but using the write cache forms a contract with the host
whereby the card expects to be told about impending power-down.

The implication is that (for performance) the card can do unsafe things
with pending write data - including reordering what gets committed to
nonvolatile storage at what time.

Exposed SD slots and platforms powered by hotpluggable means (i.e.
Raspberry Pis) can't guarantee that surprise removal won't happen.

To limit the scope for cards to invent new ways to trash filesystems,
limit pending writes to 1 (equivalent to the non-CQ behaviour).

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

fixup: mmc: restrict posted write counts for SD cards in CQ mode

Leaving card->max_posted_writes unintialised was a bad thing to do.

Also, cqe_enable is 1 if hsq is enabled as hsq substitutes the cqhci
implementation with its own.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:38 +01:00
Phil Elwell
335e498226 dmaengine: dw-axi-dmac: Honour snps,block-size
The snps,block-size DT property declares the maximum block size for each
channel of the dw-axi-dmac. However, the driver ignores these when
setting max_seg_size and uses MAX_BLOCK_SIZE (4096) instead.

To take advantage of the efficiencies of larger blocks, calculate the
minimum block size across all channels and use that instead.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:38 +01:00
Richard Oliver
bba392935b spi: Add a driver for the RPI RP2040 GPIO bridge
The Raspberry Pi RP2040 GPIO bridge is an I2C-attached device exposing
both a Tx-only SPI controller, and a GPIO controller.

Due to the relative difference in transfer rates between standard-mode
I2C and SPI, the GPIO bridge makes use of 12 MiB of non-volatile storage
to cache repeated transfers. This cache is arranged in ~8 KiB blocks and
is addressed by the MD5 digest of the data contained therein.

Optionally, this driver is able to take advantage of Raspberry Pi RP1
GPIOs to achieve faster than I2C data transfer rates.

Signed-off-by: Richard Oliver <richard.oliver@raspberrypi.com>
2024-08-05 11:15:37 +01:00
Richard Oliver
1668711044 spi: dt-bindings: Add RPI RP2040 GPIO Bridge
Add YAML device tree bindings for the Raspberry Pi RP2040 GPIO Bridge.

Signed-off-by: Richard Oliver <richard.oliver@raspberrypi.com>
2024-08-05 11:15:37 +01:00
Naushir Patuck
ce91a834d9 media: pisp_be: Re-introduce video node offset
Offset the backend dev-nodes starting at /dev/video20
onwards to maintain backward compatibility with the
pre-upstreamed kernel driver.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:37 +01:00
Jacopo Mondi
0913de9e8e media: pisp_be: Re-introduce multi-context support
Re-introduce multi-context support that was dropped from the
mainline driver version.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-08-05 11:15:37 +01:00
Jacopo Mondi
51551e5cf6 media: pisp-be: Backport the mainline PiSP BE driver
Backport to rpi-6.6.y the mainline version of the PiSP BE driver.

The backported version of the driver corresponds to the one available
at:
https://lore.kernel.org/all/20240626181440.195137-1-jacopo.mondi@ideasonboard.com/

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-08-05 11:15:37 +01:00
Dom Cobley
f522af8b26 fs/ntfs3: Fix memory corruption when page_size changes
The rework in fs/ntfs3: Reduce stack usage
changes log->page_size but doesn't change the associated
log->page_mask and log->page_bits.

That results in the bytes value in read_log_page
getting a negative value, which is bad when it is
passed to memcpy.

The kernel panic can be observed when connecting an
ntfs formatted drive that has previously been connected
to a Windows machine to a Raspberry Pi 5, which by defauilt
uses a 16K kernel pagesize.

Fixes: 865e7a7700 ("fs/ntfs3: Reduce stack usage")
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:37 +01:00
Jonathan Bell
087ea7acd0 drivers: mmc: core: handle card-removal when running CQE recovery
Recovery claims the MMC card so the card-detect work gets significantly
delayed - leading to lots of error recovery loops that can never do
anything but fail.

Explicitly detect the card after CQE has halted and bail if it's not
there.

Also ratelimit a not-very-descriptive warning - one occurrence in dmesg
is enough to signal that something is amiss.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:37 +01:00
Jonathan Bell
d27e07bc37 drivers: mmc: sdhci-brcmstb: improve bcm2712 card removal handling
If the controller is being reset, then the CQE needs to be reset as well.

For removable cards, CQHCI_SSC1 must specify a polling mode (CBC=0)
otherwise it's possible that the controller stops emitting periodic
CMD13s on card removal, without raising an error status interrupt.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:37 +01:00
Kieran Bingham
b6c1a5fd90 staging: vc04_services: bcm2835-codec: Explicitly set DMA mask
The platform model originally handled the DMA mask. Now that
we are on the vchiq_bus we need to explicitly set this.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-08-05 11:15:37 +01:00
Kieran Bingham
b074b0039a staging: vc04_services: bcm2835-v4l2-isp: Explicitly set DMA mask
The platform model originally handled the DMA mask. Now that
we are on the vchiq_bus we need to explicitly set this.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-08-05 11:15:37 +01:00
Kieran Bingham
27375d478a staging: vc04_services: vc-sm-cma: Explicitly set DMA mask
The platform model originally handled the DMA mask. Now that
we are on the vchiq_bus we need to explicitly set this.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-08-05 11:15:37 +01:00
Phil Elwell
7ab4c3ea47 lan78xx: Return tx_lpi_timer even if disabled
Disabling tx_lpi or eee should not cause the value of tx_lpi_timer to
be lost, even though it is not useful until they are re-enabled.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:37 +01:00
Phil Elwell
bf970685c5 lan78xx: Read initial EEE status from DT
Add two new DT properties:
* microchip,eee-enabled  - a boolean to enable EEE
* microchip,tx-lpi-timer - time in microseconds to wait before entering
                           low power state

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:37 +01:00
Jonathan Bell
9e2791d28a mmc: sdhci: extend maximum ADMA transfer length to 4MiB
This gains about 8-12% sequential write speed with the fastest SD/eMMC
cards, and Class A1/A2 card sequential performance is only assured with
a 4MiB write length.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:37 +01:00
Jonathan Bell
553da46dc1 mmc: sd: halt CQHCI before issuing a cache flush command
SD cards perform cache flushes by a CMD49 extension register write -
which needs to be started from the SDHCI command/argument registers and
not a CQHCI slot.

Host access to SD/CQ registers should be exclusive to one or the other,
so issue a halt before doing the command.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:37 +01:00
Jonathan Bell
c78de717d1 mmc: sdhci-brcmstb: add hs400_downgrade callback for bcm2712
The attached PHY performs parameter validation, so the switch from HS200
to HS (before selecting HS400/HS400es) with a 200MHz clock fails to
update pad timings and results in CRC errors from the card.

Underclocking the interface is safe, so do that in the downgrade callback.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:36 +01:00
Phil Elwell
783dc8ccb2 drivers: media: pcie: hailo: Fix include paths
An attempt to fix the include paths - they look reasonable, but the
GitHub auto-builds fail.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:36 +01:00
Michiiel
b13516316a vc4/hdmi: Fix Hsync and Vsync polarity changes
Polarity bits were only ever set and never cleared.
Make sure they can also be cleared.

Signed-off-by: Michiel Vanbiervliet <michiel.vanbiervliet@gmail.com>
2024-08-05 11:15:36 +01:00
Dave Stevenson
c7a5e587d6 media: bcm2835-unicam: Add support for unpacked 14bit Bayer formats
Now that the 14bit non-packed Bayer formats are defined, add them
into the supported formats lookup table.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:36 +01:00
Dave Stevenson
d945f9825f media: bcm2835-unicam: Add support for 14bit mono sources
Now that V4L2_PIX_FMT_Y14 and V4L2_PIX_FMT_Y14P are defined,
allow passing 14bit mono data through the peripheral.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:36 +01:00
Dave Stevenson
ac7e378709 media: bcm2835-unicam: Add support for 12bit mono packed format
Now that V4L2_PIX_FMT_Y12P is defined, allow passing raw 12bit
mono packed data through the peripheral.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:36 +01:00
Stefan Wahren
7b3c1b0a62 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>
2024-08-05 11:15:36 +01:00
Phil Elwell
e49dbdb6ce arm: bcm2835: Add bcm2838 compatible string.
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2024-08-05 11:15:36 +01:00
Kieran Bingham
8fc8a0edeb staging: vc04_services: bcm2835-v4l2-codec: Register with vchiq_bus_type
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-08-05 11:15:36 +01:00
Kieran Bingham
2559b85f2f staging: vc04_services: bcm2835-v4l2-isp: Register with vchiq_bus_type
Register the bcm2835-v4l2-isp driver with the vchiq_bus_type instead of
using the platform driver/device.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-08-05 11:15:36 +01:00
Kieran Bingham
4fccc41367 staging: vc04_services: vc-sm-cma: Register with vchiq_bus_type
Register the vcsm rive with the vchiq_bus_type instead of useing the
platform driver/device.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-08-05 11:15:36 +01:00
Kieran Bingham
35649b3a18 staging: vc04_services: bcm2835-codec: Drop include Makefile directive
Drop the include directive. They can break the build, when one only
wants to build a subdirectory. Replace with "../" for the includes in
the bcm2835-v4l2-codec instead.

The fix is equivalent to the four patches between 29d49a76c5
("staging: vc04_services: bcm2835-audio: Drop include Makefile
directive")...2529ca211402 ("staging: vc04_services: interface: Drop
include Makefile directive")

Fixes: afaec52747 ("staging: vc04_services: Add a V4L2 M2M codec driver")
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-08-05 11:15:36 +01:00
Kieran Bingham
6efb1b8773 staging: vc04_services: bcm2835-isp: Drop include Makefile directive
Drop the include directive. They can break the build, when one only
wants to build a subdirectory. Replace with "../" for the includes in
the bcm2835-isp instead.

The fix is equivalent to the four patches between 29d49a76c5
("staging: vc04_services: bcm2835-audio: Drop include Makefile
directive")...2529ca211402 ("staging: vc04_services: interface: Drop
include Makefile directive")

Fixes: c8f89c9551c1 ("staging: vc04_services: ISP: Add a more complex ISP processing component")
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-08-05 11:15:36 +01:00
Kieran Bingham
d93b541254 staging: vc04_services: vc-sm-cma: Drop include Makefile directive
Drop the include directive. They can break the build, when one only
wants to build a subdirectory. Replace with "../" for the includes in
the vc_sm files instead.

The fix is equivalent to the four patches between 29d49a76c5
("staging: vc04_services: bcm2835-audio: Drop include Makefile
directive")...2529ca211402 ("staging: vc04_services: interface: Drop
include Makefile directive")

Fixes: b1ab7a05eb6c ("staging: vc04_services: Add new vc-sm-cma driver")
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-08-05 11:15:36 +01:00
Kieran Bingham
797afd0aea staging: vc04_services: vc-sm-cma: Remove deprecated header
The vchiq_connected.h header was removed in f875976ecf ("staging:
vc04_services: Drop vchiq_connected.[ch] files") to simplify the
implementation.

Update the vc_sm driver accordingly which can still use the same
functions through the vchiq_arm.h header declarations.

Fixes: b1ab7a05eb6c ("staging: vc04_services: Add new vc-sm-cma driver")
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-08-05 11:15:36 +01:00
Umang Jain
40f0fbc3b6 staging: vc04_services: Add helpers for vchiq driver data
Add helpers to set and get vchiq driver data. vchiq_set_drvdata() and
vchiq_get_drvdata() wraps dev_set_drvdata() and dev_get_drvdata()
respectively.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-08-05 11:15:36 +01:00
Dom Cobley
ffc9d62801 drivers: media: pci: Add wrapper after removal of follow_pfn 2024-08-05 11:15:35 +01:00
Naushir Patuck
3908e88d8c drivers: media: pci: Add Hailo accelerator device drivers
Add version 4.17.1 of the Hailo PCIe device drivers.
Sourced from https://github.com/hailo-ai/hailort-drivers/

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:35 +01:00
Dave Stevenson
d4f575dc85 drm/bridge: panel: Name an associated backlight device
Pass the DRM connector name to any configured backlight
device so that userspace can associate the two items.

Ideally this should be in drm_panel, but it is bridge/panel
that creates the drm_connector and therefore knows the name.

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

drm/bridge: panel: Ensure backlight is reachable

Ensure that the various options of modules vs builtin results
in being able to call into the backlight code.

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

Fixes: 573f8fd0ab ("drm/bridge: panel: Name an associated backlight device")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:35 +01:00
Dave Stevenson
64b90fa9b3 backlight: Add a display name to the core, and a function to set it
The naming of backlight devices is not terribly useful for
associating a backlight controller with a display (assuming
it is attached to one).

Add a sysfs node that will return a display name that can be set
by other subsystems.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:35 +01:00
Jonathan Bell
5f4953eed5 drivers: pcie-brcmstb: add best-effort workaround for QoS bug on bcm2712
If a set of read requests are issued by an endpoint, they are streamed
into a resynchronisation FIFO prior to exiting the RC. This FIFO has an
edge case where it can drop QoS for a request to 0 if there's a single
outstanding read request in the FIFO, and another is pushed when the
FIFO is popped. Requests with a QoS of 0 can take hundreds of
microseconds to complete.

By adding an experimentally-determined amount of backpressure on the pop
side, the critical level transition can largely be avoided.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:35 +01:00
David Plowman
dc47133556 drivers: staging: bcm2835-isp: Respect caller's stride value
The stride value reported for output image buffers should be at least
as large as any value that was passed in by the caller (subject to
correct alignment for the pixel format). If the value is zero (meaning
no value was passed), or is too small, the minimum acceptable value
will be substituted.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2024-08-05 11:15:35 +01:00
Dave Stevenson
a57318e3c3 drm/vc4: dpi: Add override for RGB order
There are no MEDIA_BUS_FMT_* defines for GRB or BRG, and adding
them is a pain.

Add a DT override to allow setting the order.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:35 +01:00
Dave Stevenson
59fb1996a1 regulator: rpi_panel_v2: Add delay on I2C reads
As with many microcontrollers, the panel wants to use clock
stretching during a read so that the appropriate return value
can be generated and programmed into the hardware.
With Pi0-3 really not supporting clock stretching, this resulted
in the panel firmware dying.

Insert a delay between the write and the read to give the firmware
a chance to generate the relevant return value.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:35 +01:00
Dave Stevenson
5b25229bfe regulator: rpi_panel_v2: Add remove and shutdown hooks
Add shutdown and remove hooks so that the panel gets powered
off with the system.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:35 +01:00
Phil Elwell
9d98d0afef spi: dw: Handle any number of gpiod CS lines
Even when configured to use only gpiod CS lines, the DW SPI controller
still expects a bit to be set in the SER register, otherwise transfers
stall. For the csgpiod case, nominate bit 0 for the job.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:35 +01:00
Dave Stevenson
0ba8131c37 drm/vc4: Fix potential null pointer read when disabling vblank
vc4_disable_vblank assumed that vc4_encoder was always assigned,
which isn't guaranteed.

If it isn't assigned then disable the interrupt anyway as it's
not connected.

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

Fixes: 63c0bcc4b7 ("drm/vc4: Add option to call from crtc to encoder on vblank")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:35 +01:00
Phil Elwell
9e432228e0 pinctrl: bcm2835: Persist outputs by default
Having accepted the upstream change to add the persist_gpio_outputs
parameter, make it true by default.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:35 +01:00
Nick Hollinghurst
e3a18915ec drm: rp1: dpi: Add support for MEDIA_BUS_FMT_RGB565_1X24_CPADHI
This new format corresponds to the Raspberry Pi legacy DPI mode 3.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
2024-08-05 11:15:35 +01:00
Dave Stevenson
45249ec596 regulator/rpi-panel: Power off display on shutdown
Adds a shutdown function to turn off the backlight, bridge, and
touch controller on shutdown.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:35 +01:00
Dave Stevenson
b38c526015 drm/vc4: Fixup mode for 7inch panel on DSI0
The TC358762 bridge and panel decodes the mode differently on
DSI0 to DSI1 for no obvious reason, and results in a shift off
the screen.
Whilst it would be possible to change the compatible used for
the panel, that then messes up Pi5.

As it appears to be restricted to vc4 DSI0, fix up the mode
in vc4_dsi.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:35 +01:00
Dave Stevenson
50fb0ec219 drm/panel-simple: Increase pixel clock on Pi 7inch panel
The Toshiba bridge is very fussy and doesn't like the CM3
output when being told to produce a 27.777MHz pixel clock, which
is an almost perfect match to the DSI link integer divider.

Increasing to 30MHz will switch the DSI link from 333MHz to 400MHz
and makes the bridge happy with the same video timing as works
on Pi4.
(Pi4 will be using a link frequency of 375MHz due to a 3GHz
parent PLL).

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:35 +01:00
Dave Stevenson
5befd66c2f drm/panel-simple: Fix 7inch panel mode for misalignment
The 7inch panel is one line off the screen both horizontally
and vertically.

Alter the panel mode to correct this.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:34 +01:00
Dave Stevenson
3bd2e7f756 drm/vc4: Add vblank callback to DSI0 to reset FIFO
The pixel to byte FIFO appears to not always reset correctly,
which can lead to colour errors and/or horizontal shifts.
Reset on every vblank to work around the issue.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:34 +01:00
Dave Stevenson
d5dbb7acf2 drm/vc4: Add option to call from crtc to encoder on vblank
DSI0 is misbehaving and needs to action things on vblank to
work around it.
Add a new hook to call across during vblank.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:34 +01:00
Dave Stevenson
17e653cf15 drm/vc4: Ensure DSI is enabled for FIFO resets
The block must be enabled for the FIFO resets to be actioned,
so ensure this is the case.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:34 +01:00
Dave Stevenson
cb2076b8ec drm: vc4: Reset DSI AFE on disable
vc4_dsi_bridge_disable wasn't resetting things during shutdown,
so add that in.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:34 +01:00
Dave Stevenson
516ee394f8 drm: vc4: dsi: Clocks should be running before reset
The initialisation sequence differs slightly from the documentation
in that the clocks are meant to be running before resets and
similar.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:34 +01:00
Dave Stevenson
4d55d22b72 drm/bridge: tc358762: revert move ops to enable
Reverts 8a4b2fc9c9 ("drm/bridge: tc358762: Split register programming from pre-enable to enable")
as we want the config commands sent before video starts.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:34 +01:00
Dave Stevenson
ba428a9202 drm/bridge: tc358762: Program the DPI mode into the chip
The autodetection of resolution/timing by the TC358762 can lead
to the display being shifted by a pixel or two.

Program the TC358762 with the requested mode timing so that
it can reproduce it accurately.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:34 +01:00
Nick Hollinghurst
ced5732a97 drm: rp1: vec: Support more video modes in the RP1 VEC driver
Support a wider range of pixel clock rates. The driver will round
pixclock up to 108MHz/n but tries to honour the desired image width
and position (of the centre of the display relative to HSYNC_STARTs).
This adds complexity but removes the need for separate 13.5MHz and
15.428MHz modes.

Support "fake" double-rate progressive modes (in which only every
2nd scanline is displayed). To work around aspect ratio issues.

Add Monochrome TV mode support. Add "vintage" modes (544x380i for
System A; 848x738i for System E) when configured for Monochrome.

Add a way to create a "custom" display mode from a module parameter.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
2024-08-05 11:15:34 +01:00
Dave Stevenson
cd6ae1664f drm/panel-simple: Remove custom handling of orientation
The framework now handles reading orientation from DT, therefore
remove the custom get_orientation hook from panel-simple.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:34 +01:00
Dave Stevenson
c050e393b6 drm/panel: Add and initialise an orientation field to drm_panel from OF
"rotation" is listed as a standard property of panels in panel-common.yaml,
therefore it would be logical to process that from within the core
code should a panel driver not implement the get_orientation hook.

Call of_drm_get_panel_orientation from
drm_connector_set_orientation_from_panel to get that information.

This removes the need for any boiler-plate in panel drivers for calling
drm_connector_set_orientation_from_panel or
drm_connector_set_panel_orientation.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:34 +01:00
Nick Hollinghurst
ec29b3ff83 DRM: rp1: rp1-dsi: Fix escape clock divider and timeouts.
Escape clock divider was fixed at 5, which is correct at 800Mbps/lane
but increasingly out of spec for higher rates. Compute it correctly.

High speed timeout was fixed at 5*512 == 2560 byte-clocks per lane.
Compute it conservatively to be 8/7 times the line period (assuming
there will be a transition to LP some time during each scanline?)
keeping the old value as a lower bound. Increase LPRX TO to 1024,
and BTA TO to 0xb00 (same value as in bridge/synopsys/dw-mipi-dsi).

(No change to LP_CMD_TIM. To do: compute this correctly.)

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
2024-08-05 11:15:34 +01:00
Dom Cobley
a8750f6de6 vc4/hdmi: Ignore hotplug interrupt with force_hotplug
The intention of the vc4.force_hotplug setting is to
ignore hotplug completely.

It can be used when a display toggles hotplug when
switching AV inputs, going into standby or changing a
KVM switch, and some side effect of that is unwanted.

It turns out while vc4.force_hotplug currently makes
hotplug always read as asserted, that isn't enough to
stop drm doing lots of stuff, including re-reading
the edid.

An example of what drm does with a hotplug deasert/assert
and vc4.force_hotplug=1 currently is:

https://paste.debian.net/hidden/dc07434b/

That is unwanted. Lets ignore the hotplug interrupt
completely so drm is blissfully unaware of the hotplug change.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:34 +01:00
Naushir Patuck
ea4e6d1f1a drivers: media: cfe: Add remap entries for mono formats
The 8-bit and 16-bit mono formats were missing the appropriate remap
entries in the format table.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:34 +01:00
popcornmix
438ecf296e dw-axi-dmac-platform: Avoid trampling with zero length buffer
This code:
for_each_sg(sgl, sg, sg_len, i)
  num_sgs += DIV_ROUND_UP(sg_dma_len(sg), axi_block_len);

determines how many hw_desc are allocated.
If sg_dma_len(sg)=0 we don't allocate for this sgl.

However in the next loop, we will increment loop
for this case, and loop gets higher than num_sgs
and we trample memory.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:34 +01:00
Dave Stevenson
79ef226b44 media: bcm2835-unicam: Add option for a GPIO to reflect FS/FE timing
The legacy stack had an option to have a GPIO track frame start and
end events to give basic synchronisation to the incoming image stream.
https://forums.raspberrypi.com/viewtopic.php?t=190314

Replicate this in the kernel Unicam driver.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:34 +01:00
Ben Hutchings
450b21a977 module: Avoid ABI changes when debug info is disabled
CI builds are done with debug info disabled, but this removes some
members from struct module.  This causes builds to fail if there is an
ABI reference for the current ABI.

Define these members unconditionally, so that there is no ABI change.
2024-08-05 11:15:33 +01:00
Jonathan Bell
42bf7017a2 drivers: mmc: disable write-caching on Samsung 2023 model year SD cards
Samsung EVO Plus, Pro Plus and Evo Ultimate cards of this era appear to
have a broken cache-flush implementation when operating in CQ mode.

Unfortunately the cards seem to use a separate CID name string for every
variant and capacity, so nobble the cache feature for this MANFID, OEMID
and year. Turning this off seems to have negligible impact on
random-write throughput in non-CQ mode.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:33 +01:00
Jonathan Bell
1649815e23 drivers: mmc: apply SD quirks earlier during probe
Applying MMC_QUIRK_BROKEN_SD_CACHE is broken, as the card's extended
registers are parsed prior to the quirk being applied in mmc_blk.

Split this out into an SD-specific list of quirks and apply in
mmc_sd_init_card instead.

Fixes: c467c8f081 ("mmc: Add MMC_QUIRK_BROKEN_SD_CACHE for Kingston Canvas Go Plus from 11/2019")

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:33 +01:00
Dom Cobley
a9a774ffe2 nvmem: raspberrypi: Add nvmem driver for accessing OTP data
This supports reading and writing OTP using the firmware
mailbox interface.

It needs supporting firmware to run.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:33 +01:00
Phil Elwell
de9892ea1e i2c: designware: Make the SDA hold time half LCNT
In the absence of a value in Device Tree, set the SDA hold time to half
the SCL low time.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:33 +01:00
Phil Elwell
5745d99a06 i2c: designware: Add support for bus clear feature
Newer versions of the DesignWare I2C block support the detection of
stuck signals, and a mechanism to recover from them. Add the required
software support to the driver.

This change was prompted by the observation that reading a single byte
from register 0 of a VEML7700 seems to cause it to issue an ACK too
early, and the controller to complain about losing arbitration. There
is a suspicion that this may be a more widespread problem, but at least
this patch prevents the bus from locking up.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:33 +01:00
Jonathan Bell
95d0026763 drivers: mmc: handle 1024-byte SD General Info lengths
The spec allows for up to two 512-byte pages to be allocated for the
Extension Register General Info block, so allocate accordingly.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:33 +01:00
Jonathan Bell
8224f9503d drivers: mmc: add debugfs entries for SD extension registers
Also report the card's supported queue depth in the message log.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:33 +01:00
Jonathan Bell
a02a47bcc9 drivers: mmc: be more cautious when manipulating Command Queue enable
Don't attempt to turn on CQ if the other mandatory features are not
indicated as supported by the card. Also make sure that the register write
actually stuck, as some cards claim support but never report back that
the queue engine is enabled.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:33 +01:00
Jonathan Bell
e4ff79a526 drivers: mmc: export SD extension register read/write functions
Certain status bits in these registers may need polling outside of
SD-specific code. Export in sd_ops.h

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:33 +01:00
Jonathan Bell
ef6fd9abe0 drivers: mmc: cqhci: clear CQHCI_CTL if halt fails
The eMMC spec says that in certain circumstances the controller can't
respond to a halt request - in practice, this occurs if a CMD
timeout happens (card went away/crashed).

Clear the halt request by writing 0 to CQHCI_CTL. Also fix a logic error
testing for halt in cqhci_request.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:33 +01:00
Dave Stevenson
d9471d6945 drm/vc4: Enable bg_fill if there are no planes enabled
The default was to have enable_bg_fill disabled and the first
plane set it if it wasn't opaque and covering the whole screen.
However that meant that if no planes were enabled, then the
background fill wasn't enabled, and would give a striped
output from the uninitialised output buffer.

Initialise it to enabled to avoid this.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:33 +01:00
Jonathan Bell
de3a069cf8 drivers: sdhci-brcmstb: work around mystery CQE CMD_IDLE_TIMER trampling
For unknown reasons the controller seems to reset the idle polling timer
interval on CQE enable/disable to 8 clocks which is extremely short.

Just use the reset value in the eMMC spec (4096 clock periods which at
200MHz is ~20uS).

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:33 +01:00
Jonathan Bell
dd3f630b2f drivers: mmc: trigger activity LED when CQE is active
Add a LED_FULL trigger equivalent to mmc_start_request() in
mmc_cqe_start_req(), otherwise it stays off forever.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:33 +01:00
Jonathan Bell
d8e24db63c drivers: mmc: preallocate a block for SD extension register accesses
The Performance Extension register is regularly accessed in a hot path
to do write cache flushes. Don't invoke kmalloc/kfree for every access,
preallocate a 512B buffer for this purpose.

Also remove an unused alloc in sd_enable_cache().

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:33 +01:00
Jonathan Bell
8d8fb1a4b5 drivers: mmc: add SD support for Command Queueing
Application class A2 cards require CQ to be enabled to realise their
stated performance figures. Add support to enable/disable card CQ via
the Performance Enhancement extension register, and cater for the slight
differences in command set versus eMMC.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:33 +01:00
Mike Cui
33423251b1 brcmfmac: Fix 802.1x
Commit 7d239fbf9d broke 802.1X authentication by setting
profile->use_fwsup = NONE whenever PSK is not used. However
802.1X does not use PSK and requires profile->use_fwsup set
to 1X, or brcmf_cfg80211_set_pmk() fails. Fix this by checking
that profile->use_fwsup is not already set to 1X and avoid
setting it to NONE in that case.

Fixes: 7d239fbf9d (brcmfmac: Fix interoperating DPP and other encryption network access)
Fixes: https://github.com/raspberrypi/linux/issues/5964
2024-08-05 11:15:32 +01:00
Chung-Hsien Hsu
8f455840cb brcmfmac: support external SAE authentication in station mode
Firmware has SME functionality but would like the userspace to handle
SAE authentication. This patch adds support for such an external SAE
authentication mechanism in station mode.

Signed-off-by: Chung-Hsien Hsu <chung-hsien.hsu@infineon.com>
Signed-off-by: Chi-hsien Lin <chi-hsien.lin@infineon.com>
2024-08-05 11:15:32 +01:00
Kurt Lee
686d30d541 brcmfmac: Fix interoperating DPP and other encryption network access
1. If firmware supports 4-way handshake offload but not supports DPP
4-way offload, when user first connects encryption network, driver will
set "sup_wpa 1" to firmware, but it will further result in DPP
connection failure since firmware won't send EAPOL frame to host.

2. Fix DPP AP mode handling action frames.

3. For some firmware without fwsup support, the join procedure will be
skipped due to "sup_wpa" iovar returning not-support. Check the fwsup
feature before do such iovar.

Signed-off-by: Kurt Lee <kurt.lee@cypress.com>
Signed-off-by: Double Lo <double.lo@cypress.com>
Signed-off-by: Chi-hsien Lin <chi-hsien.lin@cypress.com>
2024-08-05 11:15:32 +01:00
Praveen Babu C
837bccf789 non-upstream: support DS1 exit firmware re-download
In deep sleep mode (DS1) ARM is off and once exit trigger comes than
mailbox Interrupt comes to host and whole reinitiation should be done
in the ARM to start TX/RX.

Also fix below issus for DS1 exit:
1. Sent Tx Control frame only after firmware redownload complete (check
F2 Ready before sending Tx Control frame to Firmware)
2. intermittent High DS1 TX Exit latency time (almost 3sec) ==> This is
fixed by skipping host Mailbox interrupt Multiple times (ulp state
mechanism)
3. RX GlOM save/restore in Firmware
4. Add ULP event enable & event_msgs_ext iovar configuration in FMAC
5. Add ULP_EVENT_RECV state machine for sbwad support
6. Support 2 Byte Shared memory read for DS1 Exit HUDI implementation

Signed-off-by: Praveen Babu C <pucn@cypress.com>
Signed-off-by: Naveen Gupta <nagu@cypress.com>
[Merge from 4.14.77 to 5.4.18; set BRCMF_SDIO_MAX_ACCESS_ERRORS to 20]
Signed-off-by: Chi-hsien Lin <chi-hsien.lin@cypress.com>
JIRA: SWWLAN-135583
JIRA: SWWLAN-136577
2024-08-05 11:15:32 +01:00
Phil Elwell
84ebc88f57 i2c: mux: Add support for generic base-nr property
i2c_mux_add_adapter takes a force_nr parameter that allows an explicit
bus number to be associated with a channel. However, only i2c-mux-reg
and i2c-mux-gpio make use of it.

To help with situations where it is desirable to have a fixed, known
base address for the channels of a mux, create a "base-nr" property.
When force_nr is 0 and base-nr is set and non-zero, form a force_nr
value from the sum of base-nr and the channel ID.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:32 +01:00
Dave Stevenson
52fdbb56ae regulator: Add a regulator for the new LCD panels
The newer Raspberry Pi 5" and 7" panels have a slightly different
register map to the original one.
Add a new driver for this regulator.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:32 +01:00
David Turner
a13c98e22b vc4: Add jack detection to HDMI audio driver
Add ALSA jack detection to the vc4-hdmi audio driver so userspace knows
when to add/remove HDMI audio devices.

Signed-off-by: David Turner <david.turner@raspberrypi.com>
2024-08-05 11:15:32 +01:00
Jonathan Bell
f2d47b3fde dt-bindings: add additional RP1 PLL output channels
PLL_AUDIO has a ternary divider (a copy of the secondary divider) and
PLL_VIDEO has a primary phased output.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:32 +01:00
Phil Elwell
483eae440d Bluetooth: btbcm: Add entry for BCM43439 UART BT
This patch adds the device ID for the BCM4343A2 module, found e.g. in
the Infineon (Cypress) CYW43439 chip. The required firmware file is
named 'BCM4343A2.hcd'.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:32 +01:00
Phil Elwell
4374ab55bf arm64/Kconfig: Don't set DMA_BOUNCE_UNALIGNED_KMALLOC
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers
(64MB, by default) to be allocated, even on systems where the DMA
controller can reach all of RAM. This is a huge amount of RAM to
waste on a device with only 512MB to start with, such as the Zero 2 W.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:32 +01:00
Dom Cobley
38280be498 vc4/hvs: Fix lbm size calculation for yuv
The code was reducing the number of components by one when we were not
blending with alpha. But that only makes sense if the components include
alpha.

For YUV, we were reducing the number of components for Y from one to zero
which resulted in no lbm space being allocated.

Fixes: https://github.com/raspberrypi/linux/issues/5912
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:32 +01:00
Dave Stevenson
1c257a2f8e drm/vc4: Disable overrun interrupts
We have a read-modify-write race when updating SCALER_DISPCTRL for
underrun and end-of-frame interrupts.
Ideally it would be fixed via a spinlock or similar, but that will
require a reasonable amount of study to ensure we don't get deadlocks.

The underrun reporting is only for debug, so disable it for now.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:32 +01:00
Dom Cobley
c75dc7cefa vc4/hvs: Support fixed alpha correctly on 2712D0
2712D0 removed alpha_mode from control word 2 for choosing fixed alpha
and replaced it with the previously reserved value of 3 in alpha_mask.

Handle this to fix corrupt desktop when using X on 2712D0

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:32 +01:00
Dave Stevenson
6be42ffbe1 drm/vc4: Drop planes that have 0 destination size
There is no point in trying to create a dlist entry for planes
that have a 0 crtc size, and it can also cause grief in the vc6
dlist generation as it takes width-1 and height-1, causing wrap
around.
Drop these planes.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:32 +01:00
Phil Elwell
af9c792112 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>
2024-08-05 11:15:32 +01:00
Phil Elwell
d679088cfc i2c: designware: Support non-standard bus speeds
Add support for non-standard bus speeds by treating them as detuned
versions of the slowest standard speed not less than the requested
speed.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:32 +01:00
Phil Elwell
d96105ae8e i2c: designware: Use SCL rise and fall times in DT
Calculate the HCNT and LCNT values for all modes using the rise and
fall times of SCL, the aim being a 50/50 mark/space ratio.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:31 +01:00
Dave Stevenson
fdbd61d3c9 drm/vc4: Initialise the tv_mode property default from cmdline_mode.
With the command line parser now providing the information about
the tv mode, use that as the preferred choice for initialising the
default of the tv_mode property.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:31 +01:00
Jonathan Bell
e4c35d5356 drivers: usb: dwc3: add FS/LS bus instance parkmode disable bit
There are three parkmode disable bits, one for each bus instance type.
Add FS/LS and parse the quirk out of DT. Also update the slightly
mangled quirk descriptions.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:31 +01:00
Jonathan Bell
6cfa1d19ce dt-bindings: usb: update dwc3 bindings for parkmode-disable quirks
There are three disable bits, one for each bus-instance type. Add a
quirk to cover the FS/LS type, and update the slightly mangled quirk
descriptions in the process.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:31 +01:00
Jonathan Bell
7f158ba51b mmc: bcm2835-sdhost: use Host Software Queueing mechanism
See commit 511ce378e1 ("mmc: Add MMC host software queue support")

Introduced in 5.8, this feature lets the block layer issue up to 2
pending requests to the MMC layer which in certain cases can improve
throughput, but in the case of this driver can significantly reduce
context switching when performing random reads.

On bcm2837 with a performant class A1 card, context switches under FIO
random 4k reads go from ~8800 per second to ~5800, with a reduction in
hardIRQs per second from ~5800 to ~4000. There is no appreciable
difference in throughput.

For bcm2835, and for workloads other than random read, HSQ is a wash in
terms of throughput and CPU load.

So, use it by default.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:31 +01:00
Dave Stevenson
419778e381 drm/vc4: Flush stale dlist entries if allocation fails
This is largely for debug at present.
For reasons unknown we are not getting the end of frame interrupts
that should trigger a sweep of stale dlist entries.

On allocation failure clear out ALL stale entries, and retry the
allocation. Log the interrupt status so we have debug regarding
whether the HVS believes the interrupt is enabled.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:31 +01:00
Dave Stevenson
4b4fab7b2d drm/vc4: Optimise vc4_hvs_dlist_free_work to only read frcnt and active once
vc4_hvs_dlist_free_work was iterating through the list of stale
dlist entries and reading the frame count and active flags from
the hardware for each one.

Read the frame count and active flags once, and then use the
cached value in the loop.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:31 +01:00
Dom Cobley
da8c64ea04 vc4/hdmi: Update MAI_THR for D0
2712D0 has increased the fifo sizes of MAI_THR blocks,
resulting in adjusted bit offsets. Handle that.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:31 +01:00
Dom Cobley
5ea4218070 vc4/hvs: Updates to support D0 alpha and csc changes
2712D0 has a simpler colourspace conversion matrix block
so set that up.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:31 +01:00
Dom Cobley
fe92087d11 vc4/hvs: Add support for D0 register changes
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:31 +01:00
Phil Elwell
bdd35a3e90 spi: bcm2835: Support spi0-0cs and SPI_NO_CS mode
The forced conversion of native CS lines into software CS lines is done
whether or not the controller has been given any CS lines to use. This
breaks the use of the spi0-0cs overlay to prevent SPI from claiming any
CS lines, particularly with spidev which doesn't pass in the SPI_NO_CS
flag at creation.

Use the presence of an empty cs-gpios property as an indication that no
CS lines should be used, bypassing the native CS conversion code.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:31 +01:00
Dave Stevenson
7d6b6b553f media: i2c: adv7180: Add support for V4L2_CID_LINK_FREQ
For CSI2 receivers that need to know the link frequency,
add it as a control to the driver.
Interlaced modes are 216Mbp/s or 108MHz, whilst going through
the I2P to deinterlace gives 432Mb/s or 216MHz.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:31 +01:00
Dave Stevenson
b4e8b70466 media: i2c: adv7180: Use MEDIA_BUS_FMT_UYVY8_1X16 for CSI2 output
CSI2 devices are meant to use the 1Xnn formats rather than 2Xnn
such as MEDIA_BUS_FMT_UYVY8_2X8.

For devices with ADV7180_FLAG_MIPI_CSI2 set, use
MEDIA_BUS_FMT_UYVY8_1X16.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:31 +01:00
Dom Cobley
5081c00e0a drm/vc4: Fixup of patches adding debugfs functions
Fixes: d869ef6a96a3 ("drm/vc4: Add debugfs node that dumps the vc5 gamma PWL entries")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:31 +01:00
Dave Stevenson
0919551e9d drm/vc4: Fix reading of frame count on GEN5 / Pi4
The frame count values moved within registers DISPSTAT1 and
DISPSTAT2 with GEN5, so update the accessor function to
accommodate that.

Fixes: b51cd7ad14 ("drm/vc4: hvs: Fix frame count register readout")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:31 +01:00
Phil Elwell
9557078b82 firmware/psci: Pass given partition number through
Pi 5 uses BL31 as its armstub file, so the reset goes via PSCI. Parse
any "reboot" parameter as a partition number to reboot into.
N.B. This code path is only used if reboot mode has been set to warm
or soft.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:31 +01:00
Kieran Bingham
9a05d2b44a media: i2c: Add ROHM BU64754 Camera Autofocus Actuator
Add support for the ROHM BU64754 Motor Driver for Camera Autofocus. A
V4L2 Subdevice is registered and provides a single
V4L2_CID_FOCUS_ABSOLUTE control.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-08-05 11:15:30 +01:00
Kieran Bingham
197963d714 media: dt-bindings: i2c: Add Rohm BU64754 bindings
Add YAML device tree bindings for the ROHM BU64754 VCM Motor Driver for
Camera Autofocus.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-08-05 11:15:30 +01:00
Dave Stevenson
a0c585e1bd drm/vc4: Mop and moplet have different register offsets for high addr
MOP uses register offset 0x24 for the high bits of the address,
whilst Moplet uses 0x1c.

Handle this difference between the block types.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:30 +01:00
Dave Stevenson
7188e2c52f drm/vc4: Correct HVS muxing setup for the moplet
The moplet registers as VC4_ENCODER_TYPE_TXP1 and can be
fed from mux output 2 of HVS channel 1.

Correct the option which checked for VC4_ENCODER_TYPE_TXP0

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:30 +01:00
Phil Elwell
c54bf83951 dtc update 2024-08-05 11:15:30 +01:00
Dave Stevenson
6e98e32cd3 drm: vc4: Block swiotlb bounce buffers being imported as dmabuf
The dmabuf import already checks that the backing buffer is contiguous
and rejects it if it isn't. vc4 also requires that the buffer is
in the bottom 1GB of RAM, and this is all correctly defined via
dma-ranges.

However the kernel silently uses swiotlb to bounce dma buffers
around if they are in the wrong region. This relies on dma sync
functions to be called in order to copy the data to/from the
bounce buffer.

DRM is based on all memory allocations being coherent with the
GPU so that any updates to a framebuffer will be acted on without
the need for any additional update. This is fairly fundamentally
incompatible with needing to call dma_sync_ to handle the bounce
buffer copies, and therefore we have to detect and reject mappings
that use bounce buffers.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:30 +01:00
Dave Stevenson
e510bdf2a5 drm: vc4: Free the dlist alloc immediately if it never hit the hw
atomic_check creates a state, and allocates the dlist memory for
it such that atomic_flush can not fail.

On destroy that dlist allocation was being put in the stale list,
even though it had never been programmed into the hardware,
therefore doing lots of atomic_checks could consume all the dlist
memory and fail.

If the dlist has never been programmed into the hardware, then
free it immediately.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:30 +01:00
Dave Stevenson
185cb95e3c drm/bridge: display-connector: Select DRM_KMS_HELPER
Commit 7cd70656d1 ("drm/bridge: display-connector: implement
bus fmts callbacks") added use of drm_atomic_helper_bridge_*
functions, but didn't select the dependency of DRM_KMS_HELPER.
If nothing else selected that dependency it resulted in a
build failure.

Select the missing dependency.

Fixes: 7cd70656d1 ("drm/bridge: display-connector: implement bus fmts callbacks")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:30 +01:00
Dave Stevenson
190082f811 drm/vc4: Drop planes that are completely off-screen
It is permitted for a plane to be configured such that none
of it is on-screen via either negative dest rectangle X,Y
offset, or just an offset that is greater than the crtc
dimensions.

These planes were resized via drm_atomic_helper_check_plane_state
such that the source rectangle had a zero width or height, but
they still created a dlist entry even though they contributed
no pixels. In the case of vc6_plane_mode_set, that it could result
in negative values being written into registers, which caused
incorrect behaviour.

Drop planes that result in a source width or height of 0 pixels
to avoid the incorrect rendering.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:30 +01:00
Dave Stevenson
f396a937d1 media/i2c: ov7251: Switch from V4L2_CID_GAIN to V4L2_CID_ANALOGUE_GAIN
The mainline driver has implemented analogue gain using the control
V4L2_CID_GAIN instead of V4L2_CID_ANALOGUE_GAIN.

libcamera requires V4L2_CID_ANALOGUE_GAIN, and therefore fails.

Update the driver to use V4L2_CID_ANALOGUE_GAIN.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:30 +01:00
Ram Chandrasekar
14316518e4 drivers: thermal: step_wise: add support for hysteresis
Step wise governor increases the mitigation level when the temperature
goes above a threshold and will decrease the mitigation when the
temperature falls below the threshold. If it were a case, where the
temperature hovers around a threshold, the mitigation will be applied
and removed at every iteration. This reaction to the temperature is
inefficient for performance.

The use of hysteresis temperature could avoid this ping-pong of
mitigation by relaxing the mitigation to happen only when the
temperature goes below this lower hysteresis value.

Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
Signed-off-by: Lina Iyer <ilina@codeaurora.org>

drivers: thermal: step_wise: avoid throttling at hysteresis temperature after dropping below it

Signed-off-by: Serge Schneider <serge@raspberrypi.org>

Fix hysteresis support in gov_step_wise.c

Directly get hyst value instead of going through an
optional and, now, unimplemented function.

Signed-off-by: Jürgen Kreileder <jk@blackdown.de>
2024-08-05 11:15:30 +01:00
Jonathan Bell
48d2fc5cdc xhci: Use more event ring segment table entries
Users have reported log spam created by "Event Ring Full" xHC event
TRBs. These are caused by interrupt latency in conjunction with a very
busy set of devices on the bus. The errors are benign, but throughput
will suffer as the xHC will pause processing of transfers until the
event ring is drained by the kernel. Expand the number of event TRB slots
available by increasing the number of event ring segments in the ERST.

Controllers have a hardware-defined limit as to the number of ERST
entries they can process, so make the actual number in use
min(ERST_MAX_SEGS, hw_max).

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:30 +01:00
Phil Elwell
052a061ce5 w1: Disable kernel log spam
See: https://forums.raspberrypi.com/viewtopic.php?p=2159344

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:30 +01:00
Phil Elwell
2866161523 gpio-poweroff: Disable the WARN
With the new support for a chain of sys_off handlers, gpio-poweroff
does not disable a normal shutdown (though it does delay it). There
is therefore no need for the noisy WARN from the kernel.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:30 +01:00
Nick Bulleid
51483b404f 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>
2024-08-05 11:15:30 +01:00
Jonathan Bell
2c3e048675 dt-bindings: mmc: sdhci-of-dwcmhsc: Add Raspberry Pi RP1 support
The DWC MSHC controller on RP1 needs differentiating from the generic
version.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:29 +01:00
Jonathan Bell
490b0e379b drivers: mmc: sdhci: add SPURIOUS_INT_RESP quirk
Certain controllers (dwc-mshc) generate timeout conditions separately to
command-completion conditions, where the end result is interrupts are
separated in time depending on the current SDCLK frequency.

This causes spurious interrupts if SDCLK is slow compared to the CPU's
ability to process and return from interrupt. This occurs during card
probe with an empty slot where all commands that would generate a
response time out.

Add a quirk to squelch command response interrupts when a command
timeout interrupt is received.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:29 +01:00
Dom Cobley
2c77355cfc drm/vc4: crtc: Support odd horizontal timings on BCM2712
BCM2711 runs pixelvalve at two pixels per clock cycle which results
in an unfortunate limitation that odd horizontal timings are not
possible. This is apparent on the standard DMT mode of 1366x768@60
which cannot be driven with correct timing.

BCM2712 defaults to the same behaviour, but has a mode to support
odd timings. While internally it still runs at two pixels per clock,
setting the PV_VCONTROL_ODD_TIMING bit makes it appear externally
to behave as it is one pixel per clock.

Switching to this mode fixes 1366x768@60 mode, and other custom
resultions with odd horizontal timings.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

drm/vc4: Disable the 2pixel/clock odd timings workaround for interlaced

Whilst BCM2712 does fix using odd horizontal timings, it doesn't
work with interlaced modes.

Drop the workaround for interlaced modes and revert to the same
behaviour as BCM2711.

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

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:29 +01:00
Dave Stevenson
f89077ebd1 drm/vc4: Log the size of the dlist allocation that was attempted
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:29 +01:00
Dave Stevenson
e5e9cb3a2c drm/vc4: Add hvs_dlist_allocs debugfs function.
Users are reporting running out of DLIST memory. Add a
debugfs file to dump out all the allocations.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:29 +01:00
Dave Stevenson
182560c9ea drm/vc4: Free all stale dlists if channel is disabled
The code handling freeing stale dlists had 2 issues:
- it disabled the interrupt as soon as the first EOF interrupt
  occurred, even if it didn't clear all stale allocations, thus
  leading to stale entries
- It didn't free stale entries from disabled channels, so eg
  "kmstest -c 0" could leave a stale alloc on channel 1 floating
  around.

Keep the interrupt enabled whilst there are any outstanding
allocs, and discard those on disabled channels. This second
channel does require us to call vc4_hvs_stop_channel from
vc4_crtc_atomic_disable so that the channel actually gets stopped.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:29 +01:00
Dave Stevenson
ba36e03463 drm/vc4: Drop WARN for HVS FIFOs not being empty
The reset condition for the EMPTY flag in DISPSTATx is 0,
so seeing as we've just reset the pipeline there is no
guarantee that the flag will denote empty if it hasn't been
enabled.

Drop the WARN.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:29 +01:00
Dave Stevenson
95098e449f drm/vc4: Correct logic on stopping an HVS channel
When factoring out __vc4_hvs_stop_channel, the logic got inverted from
	if (condition)
	  // stop channel
to
	if (condition)
	  goto out
	//stop channel
	out:
and also changed the exact register writes used to stop the channel.

Correct the logic so that the channel is actually stopped, and revert
to the original register writes.

Fixes: 6d01a106b4 ("drm/vc4: crtc: Move HVS init and close to a function")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:29 +01:00
Jonathan Bell
9d27e8056a dt-bindings: PCI: brcmstb: add optional property - "brcm,tperst-clk-ms"
This property can be used to delay deassertion of external fundamental
reset, which may be useful for endpoints that require an extended time for
internal setup to complete.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:29 +01:00
Dave Stevenson
2e6ab02600 drm/connector: Change DRM card alias from underscore to hyphen
Apparently aliases are only allowed lower case and hyphens,
so swap the use of underscore to hyphen.

Fixes: 3aa1f24775 ("drm: Look for an alias for the displays to use as the DRM device name")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:29 +01:00
Dave Stevenson
8cf01a263e drm/fb-helper: Look up preferred fbdev node number from DT
For situations where there are multiple DRM cards in a system,
add a query of DT for "drm_fb" designations for cards to set
their preferred /dev/fbN designation.

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

drm/fb_helper: Change query for FB designation from drm_fb to drm-fb

Fixes: 1216ea56c2 ("drm/fb-helper: Look up preferred fbdev node number from DT")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:29 +01:00
Dave Stevenson
be2b2322e1 fbdev: Allow client to request a particular /dev/fbN node
Add a flag custom_fb_num to denote that the client has
requested a specific fbdev node number via node.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:29 +01:00
Dave Stevenson
a5394694c1 drm/vc4: Correct address offset for planes with src_[xy] offsets
11cf37e741 switched to using drm_fb_dma_get_gem_addr instead of
drm_fb_dma_get_gem_obj and adding fb->offset[].

However the tiled formats need to compute the offset in a more
involved manner than drm_fb_dma_get_gem_addr applies, and we
were ending up with the offset for src_[xy] being applied twice.

Switch back to using drm_fb_dma_get_gem_obj and fully computing
the offsets ourselves.

Fixes: 11cf37e741 ("drm/vc4: Move the buffer offset out of the vc4_plane_state")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:29 +01:00
John Cox
4b959b6945 media/rpivid: Allow use of iommu in rpivid
In order to use iommu on hevc set dma mask_and_coherent in probe.
I am assured dma_set_mask_and_coherent is benign on Pi4 (which has
no iommu) and it seems to be so in practice.
Also adds a bit of debug to make internal buffer allocation failure
easier to spot in future

Signed-off-by: John Cox <jc@kynesim.co.uk>
2024-08-05 11:15:29 +01:00
Dave Stevenson
0b7283b860 media: i2c: ov9282: Read chip ID via 2 reads
Vision Components have made an OV9281 module which blocks reading
back the majority of registers to comply with NDAs, and in doing
so doesn't allow auto-increment register reading as used when
reading the chip ID.

Use two reads and manually combine the results.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:29 +01:00
Dom Cobley
57527958d4 vc4/drm: Remove the clear of SCALER_DISPBKGND_FILL
Since "drm/vc4: hvs: Support BCM2712 HVS" booting Pi4
with dual 4kp30 displays connected fails with:
vc4-drm gpu: [drm] *ERROR* [CRTC:107:pixelvalve-4] flip_done timed out

It has been tracked down to the referenced commit adding a
path to clear the SCALER_DISPBKGND_FILL when not required.

Dual 4kp30 works with a core clock of 297MHz when background fill
is enabled, but requires a higher value with it disabled.
320MHz still fails, while 330MHz seems okay.

Lets always enable background fill for Pi0-4.

Fixes: e84da23522 ("drm/vc4: hvs: Support BCM2712 HVS")

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:29 +01:00
Dave Stevenson
9179cf19ca drm: Look for an alias for the displays to use as the DRM device name
Allow DT aliases of eg DSI2 to force make DRM allocate the
display with the requested name.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:28 +01:00
Naushir Patuck
f36b920715 media: i2c: Move Kconfig entry for IMX477 to the camera sensor section
It was accidentally placed in the audio decoder section.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:28 +01:00
Dave Stevenson
9dccfea3b8 drm/vc4: Assign LBM memory during atomic_flush.
Avoid double buffering LBM allocations by making the
allocation a single alloc per crtc at atomic_flush.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:28 +01:00
Dom Cobley
7c86445a1c drm/vc4: kms: Avoid setting core and disp clocks for hdmi modes
On 2712, the firmware always runs these clock at a speed sufficient
for dual 4kp60.

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

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

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:28 +01:00
Maxime Ripard
e1ba8f8e10 drm/vc4: tests: Introduce a test for LBM buffer size
The BCM2712 comes with a different LBM size computation than the
previous generations, so let's add the few examples provided as kunit
tests to make sure we always satisfy those requirements.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:28 +01:00
Maxime Ripard
6f6018933d drm/vc4: tests: Support a few more plane formats
We'll start testing our planes code in situations where we will use more
than XRGB8888, so let's add a few common pixel formats.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:28 +01:00
Maxime Ripard
379066bd69 drm/vc4: tests: Add helper to add a new plane to a state
We'll start to add some tests for the plane state logic, so let's create
a helper to add a plane to an existing atomic state.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:28 +01:00
Maxime Ripard
7149bb9635 drm/vc4: tests: Add function to lookup a plane for a CRTC
Some tests will need to find a plane to run a test on for a given CRTC.
Let's create a small helper to do that.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:28 +01:00
Maxime Ripard
1dba98001c drm/vc4: tests: Use custom plane state for mock
The current mock planes were just using the regular drm_plane_state,
while the driver expect struct vc4_plane_state that subclasses
drm_plane_state.

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

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:28 +01:00
Maxime Ripard
1b0209437f drm/vc4: tests: Add tests for BCM2712 PixelValve Muxing
The BCM2712 has a simpler pipeline than the BCM2711, and thus the muxing
requirements are different. Create some tests to make sure we get proper
muxing decisions.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:28 +01:00
Maxime Ripard
db425e5f91 drm/vc4: tests: Add BCM2712 mock driver
The BCM2712 has a simpler pipeline that can only output to a writeback
connector and two HDMI controllers.

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

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:28 +01:00
Maxime Ripard
327a082f67 drm/vc4: tests: Return the allocated output
Some tests will need to retrieve the output that was just allocated by
vc4_mock_atomic_add_output().

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

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:28 +01:00
Maxime Ripard
1abfb5f385 drm/vc4: tests: Drop drm parameter for vc4_find_crtc_for_encoder
The DRM device pointer and the DRM encoder pointer are redundant, since
the latter is attached to the former and we can just follow the
drm_encoder->dev pointer.

Let's remove the drm_device pointer argument.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:28 +01:00
Maxime Ripard
930a93b566 drm/vc4: tests: Switch generation mockup to a switch
Testing whether the VideoCore generation we want to mock is vc5 or vc4
worked so far, but will be difficult to extend to support BCM2712 (VC6).

Convert to a switch.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:28 +01:00
Maxime Ripard
235c925636 drm/vc4: Add additional warn_on
Some code path in vc4 are conditional to a generation and cannot be
executed on others. Let's put a WARN_ON if that ever happens.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:28 +01:00
Maxime Ripard
e6ec38e84b drm/vc4: txp: Add BCM2712 MOPLET support
The BCM2712 features a simpler TXP called MOPLET. Let's add support for
it.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:28 +01:00
Maxime Ripard
f0c1c7b4ea drm/vc4: txp: Add support for BCM2712 MOP
The BCM2712 has an evolution of what used to be called TXP in the
earlier SoCs, but is now called MOP.

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

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:27 +01:00
Maxime Ripard
f2ad577a26 drm/vc4: txp: Add a new TXP encoder type
Starting with BCM2712, we'll have a two TXP. Let's follow the HDMI
example and add two encoder types for TXP: TXP0 and TXP1.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:27 +01:00
Maxime Ripard
26d40a456c drm/vc4: txp: Move the encoder type in the variant structure
We'll have multiple TXP instances in the BCM2712, so we can't use a
single encoder type anymore. Let's tie the encoder type to the
compatible.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:27 +01:00
Maxime Ripard
fd63960bcd drm/vc4: txp: Handle 40-bits DMA Addresses
The BCM2712 MOP and MOPLET can handle addresses larger than 32bits
through an extra register. We can easily support it and make it
conditional based on the compatible through a boolean in our variant
structure.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:27 +01:00
Maxime Ripard
64a3d812f9 drm/vc4: txp: Add horizontal and vertical size offset toggle bit
The new writeback controllers that can be found on the BCM2712 require
to have their horizontal and vertical size reduced by one.

Let's tie that behaviour to the compatible so we can support both the
new and old controllers.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:27 +01:00
Maxime Ripard
551db18321 drm/vc4: txp: Add byte enable toggle bit
The MOPLET doesn't have the BYTE_ENABLE field to set, but the TXP and
MOP do, so let's add a boolean to control whether or not we need to set
it.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:27 +01:00
Maxime Ripard
60e0a53afa drm/vc4: txp: Rename TXP data structure
The TXP data structure has a name too generic for the multiple variants
we'll have to support. Let's rename it to mention the SoC it applies to.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:27 +01:00
Maxime Ripard
0b9ea3de6b drm/vc4: txp: Introduce structure to deal with revision differences
The BCM2712 will have several TXP with small differences. Let's add a
structure tied to the compatible to deal with those differences.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:27 +01:00
Maxime Ripard
0e919d4338 drm/vc4: hdmi: Add support for BCM2712 HDMI controllers
The HDMI controllers found in the BCM2712 are largely the ones found in
the BCM2711 with a different PHY.

There's some difference with how timings are split between registers,
and HDMI1 is now able to run at 4k/60Hz.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:27 +01:00
Maxime Ripard
f5ef5a6293 drm/vc4: crtc: Add support for BCM2712 PixelValves
The PixelValves found on the BCM2712 are similar to the ones found in
the previous generation.

Compared to BCM2711, the pixelvalves only drive one HDMI controller each
and HDMI1 PixelValve has a FIFO long enough to support 4k at 60Hz.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:27 +01:00
Maxime Ripard
ccd27cda3a drm/vc4: hvs: Support BCM2712 HVS
The HVS found in the BCM2712, while having a similar role, is very
different from the one found in the previous SoCs. Indeed, the register
layout is fairly different, and the DLIST format is new as well.

Let's introduce the needed functions to support the new HVS.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>

drm/vc4: Fix atomic_async_check to call the right mode_set function

vc4_plane_atomic_async_check was always calling vc4_plane_mode_set
to validate and generate the dlist for the check. If async_check
decided it had to fall back to a sync commit, then this GEN4/5
dlist could get used on GEN6.

Call either vc4_plane_mode_set or vc6_plane_mode_set as appropriate.

Fixes: 1ab1fbbb7e ("drm/vc4: hvs: Support BCM2712 HVS")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>

drm/vc4: Add 2712 support to vc4_plane_async_set_fb

vc4_plane_async_set_fb directly overwrites the plane address in
the dlist entry, but hadn't been updated for the GEN6 / 2712
dlist format, corrupting the address in the process.

Add support for the 2712 dlist format to the function.

Fixes: 1ab1fbbb7e ("drm/vc4: hvs: Support BCM2712 HVS")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:27 +01:00
Maxime Ripard
7cf8bb8091 drm/vc4: drv: Support BCM2712
The BCM2712 has an improved display pipeline, most notably with a
different HVS and only HDMI and writeback outputs.

Let's introduce it as a new VideoCore generation and compatible.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:27 +01:00
Maxime Ripard
2a48b4ded9 dt-bindings: display: Add BCM2712 KMS driver bindings
The BCM2712 SoC comes with a new variation of the videocore display
pipeline. Let's create a new compatible for it.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:27 +01:00
Maxime Ripard
f6cc893245 dt-bindings: display: Add BCM2712 MOPLET bindings
The BCM2712 has a MOPLET controller which is basically a TXP without the
transpose feature.

Express that by adding a new compatible for it.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:27 +01:00
Maxime Ripard
0bba22a821 dt-bindings: display: Add BCM2712 MOP bindings
The BCM2712 has a MOP controller which is basically a new revision of
the TXP.

Express that by adding a new compatible for it.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:27 +01:00
Maxime Ripard
7a6ff7a770 dt-bindings: display: Add BCM2712 PixelValve bindings
The BCM2712 has 3 different pixelvalves that are similar to the ones
found in the previous generations but with slightly different
capabilities.

Express that using a new set of compatibles.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:27 +01:00
Maxime Ripard
17df893f91 dt-bindings: display: Add BCM2712 HVS bindings
The BCM2712 has a completely different HVS than the previous
generations, so let's add a new compatible for it.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:26 +01:00
Maxime Ripard
76432ac092 dt-bindings: display: Add BCM2712 HDMI bindings
The BCM2712 HDMI controller uses a slightly different HDMI controller
than the BCM2711, and a completely different PHY.

Let's introduce a new compatible for it.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:26 +01:00
Tim Gover
9c06703565 drm/vc4: Enable SCALER_CONTROL early in HVS init
Always enable SCALER_CONTROL before attempting other HVS
operations. It's safe to write to some parts of the HVS but
in general it's dangerous to do this because it can cause bus
lockups.

Signed-off-by: Tim Gover <tim.gover@raspberrypi.com>
2024-08-05 11:15:26 +01:00
Dom Cobley
d3fe731f71 drm/vc4: hvs: Remove ABORT_ON_EMPTY flag
ABORT_ON_EMPTY chooses whether the HVS abandons the current frame
when it experiences an underflow, or attempts to continue.

In theory the frame should be black from the point of underflow,
compared to a shift of sebsequent pixels to the left.

Unfortunately it seems to put the HVS is a bad state where it is not
possible to recover simply. This typically requires a reboot
following the 'flip done timed out message'.

Discussion with Broadcom has suggested we don't use this flag.
All their testing is done with it disabled.

Additionally setting BLANK_INSERT_EN causes the HDMI to output
blank pixels on an underflow which avoids it losing sync.

After this change a 'flip done timed out' due to sdram bandwidth
starvation or too low a clock is recoverable once the situation improves.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:26 +01:00
Dave Stevenson
e0165b214a drm: vc4: Remove incorrect limit from hvs_dlist debugfs function
The debugfs function to dump dlists aborted at 256 bytes,
when actually the dlist memory is generally significantly
larger but varies based on SoC.

We already have the correct limit in __vc4_hvs_alloc, so
store it for use in the debugfs dlist function.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:26 +01:00
Dave Stevenson
4e91c4ed6c drm/vc4: Fix dlist debug not resetting the next entry pointer
The debug function to display the dlists didn't reset next_entry_start
when starting each display, so resulting in not stopping the
list at the correct place.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:26 +01:00
Dave Stevenson
93bac3b2d2 drm/vc4: Move the buffer offset out of the vc4_plane_state
The offset fields in vc4_plane_state are described as being
the offset for each buffer in the bo, however it is used to
store the complete DMA address that is then written into the
register.

The DMA address including the fb ofset  can be retrieved
using drm_fb_dma_get_gem_addr, and the offset adjustment due to
clipping is local to vc4_plane_mode_set.
Drop the offset field from the state, and compute the complete
DMA address in vc4_plane_mode_set.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:26 +01:00
Dom Cobley
efa1784924 drm/vc4: hdmi: Avoid hang with debug registers when suspended
Trying to read /sys/kernel/debug/dri/1/hdmi1_regs
when the hdmi is disconnected results in a fatal system hang.

This is due to the pm suspend code disabling the dvp clock.
That is just a gate of the 108MHz clock in DVP_HT_RPI_MISC_CONFIG,
which results in accesses hanging AXI bus.

Protect against this.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:26 +01:00
Dave Stevenson
d222bef1e8 drm/vc4: UV planes vertical scaling must always be enabled
It has been observed that a YUV422 unity scaled plane isn't displayed.
Enabling vertical scaling on the UV planes solves this. There is
already a similar clause to always enable horizontal scaling on the
UV planes.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:26 +01:00
Maxime Ripard
33f50afe37 drm/vc4: hvs: Change prototype of __vc4_hvs_alloc to pass registers
The BCM2712 HVS has registers to report the size of the various SRAM the
driver uses, and their size actually differ depending on the stepping.

The initialisation of the memory pools happen in the __vc4_hvs_alloc()
function that also allocates the main HVS structure, that will then hold
the pointer to the memory mapping of the registers.

This creates some kind of circular dependency that we can break by
passing the mapping pointer as an argument for __vc4_hvs_alloc() to use
to query to get the SRAM sizes and initialise the memory pools
accordingly.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:26 +01:00
Maxime Ripard
7416dc3af3 drm/vc4: hvs: Rework LBM alignment
With the introduction of the support for BCM2712, the check of whether
we're running on vc5 or not to compute the LBM alignment requirement
doesn't work anymore.

Moreover, the LBM size will need to be computed in words for the
BCM2712, while we've had sizes in bytes so far.

Aligning on either 64 or 32 words is thus fairly harmful on BCM2712, so
let's just explicitly align the size when needed, and then call
drm_mm_insert_node_generic() with an alignment of 1.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:26 +01:00
Maxime Ripard
aaae77a183 drm/vc4: plane: Change ptr0_offset to an array
The BCM2712 will have a fairly different dlist, that will feature one
Pointer 0 word for each plane.

Let's prepare by changing the ptr0_offset variable that holds the offset
in a dlist of the pointer 0 word to an array.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:26 +01:00
Maxime Ripard
d56166ade4 drm/vc4: hvs: Rename hvs_regs list
The HVS register set has been heavily modified in the BCM2712, and we'll
thus need a separate debugfs_reg32 array for it.

The name hvs_regs is thus a bit too generic, so let's rename it to
something more specific.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:26 +01:00
Maxime Ripard
70c299d4b9 drm/vc4: hvs: Create cob_init function
Just like the HVS itself, the COB parameters will be fairly different in
the BCM2712.

Let's move the COB parameters computation and its initialisation to a
separate function that will be easier to extend in the future.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:26 +01:00
Maxime Ripard
2359d43f5d drm/vc4: hvs: Create hw_init function
Since the BCM2712 will feature a significantly different HVS, let's move
the hardware initialisation part of our bind function into a separate
function.

That way, it will be easier to extend in the future.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:26 +01:00
Maxime Ripard
7cbf7fc0ee drm/vc4: hvs: Test if the EOF interrupts are enabled
We currently enable the EOF interrupts through the CRTC destroy_state
implementation.

However, nothing guarantees that we can't call destroy_state multiple
times in a row, and therefore before the EOF interrupt even happens.

This means we would enable the interrupt multiple times but disable it
only once. It wasn't an issue so far since the interrupts were only
enabled by setting a bit in a register, but with BCM2712 we will use an
external interrupt controller, with a refcounted interrupt.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:26 +01:00
Maxime Ripard
83185f221f drm/vc4: hvs: Use switch statement to simplify enabling/disabling irq
Since we'll support BCM2712 soon, let's move the logic to enable and
disable the end-of-frame interrupts to a switch to extend it more
easily.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:25 +01:00
Maxime Ripard
7756730078 drm/vc4: hvs: Use switch statement to simplify vc4_hvs_get_fifo_from_output
Since we'll support BCM2712 soon, let's move the logic behind
vc4_hvs_get_fifo_from_output() to a switch to extend it more easily.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:25 +01:00
Maxime Ripard
5725c0cb8b drm/vc4: Make v3d paths unavailable on any generation newer than vc4
The V3D IP has been separate since BCM2711, so let's make sure we issue
a WARN if we're running not only on BCM2711, but also anything newer.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:25 +01:00
Maxime Ripard
e760ac3e7f drm/vc4: Introduce generation number enum
With the introduction of the BCM2712 support, we will get yet another
generation of display engine to support.

The binary check of whether it's VC5 or not thus doesn't work anymore,
especially since some parts of the driver will have changed with BCM2711,
and some others with BCM2712.

Let's introduce an enum to store the generation the driver is running
on, which should provide more flexibility.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:25 +01:00
Maxime Ripard
8562690f02 drm/vc4: crtc: Move assigned_channel to a variable
We access multiple times the vc4_crtc_state->assigned_channel variable
in the vc4_crtc_get_scanout_position() function, so let's store it in a
local variable.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:25 +01:00
Maxime Ripard
2c5eb6d306 drm/vc4: plane: Use return variable in atomic_check
The vc4_plane_atomic_check() directly returns the result of the final
function it calls.

Using the already defined ret variable to check its content on error,
and a separate return 0 on success, makes it easier to extend.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:25 +01:00
Maxime Ripard
c04a10407a drm/vc4: plane: Add more debugging for LBM allocation
LBM allocations need a different size depending on the line length,
format, etc.

This can get tricky, and fail. Let's add some more prints to ease the
debugging when it does.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:25 +01:00
Maxime Ripard
d998c87c22 drm/vc4: hvs: Print error if we fail an allocation
We need to allocate a few additional structures when checking our
atomic_state, especially related to hardware SRAM that will hold the
plane descriptors (DLIST) and the current line context (LBM) during
composition.

Since those allocation can fail, let's add some error message in that
case to help debug what goes wrong.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:25 +01:00
Maxime Ripard
5e6381c893 drm/vc4: hvs: More logging for dlist generation
DLIST generation can get pretty tricky and there's not a lot of debug in
the driver to help. Let's add a few more to track the generated DLIST
size.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:25 +01:00
Maxime Ripard
828bf21720 drm/vc4: hdmi: Warn if writing to an unknown HDMI register
The VC4 HDMI driver has a bunch of accessors to read from a register.
The read accessor was warning when accessing an unknown register, but
the write one was just returning silently.

Let's make sure we warn also when writing to an unknown register.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:25 +01:00
Maxime Ripard
9ad7dfe47c drm/vc4: hdmi: Enable the audio clock
The audio clock is used by the HDMI controller driver and we were using
it to get its audio rate and compute the dividers needed to reach a
given audio sample rate.

However, we were never enabling it, which was resulting in lockups on
the BCM2712.

Fixes: 632ee3aa87 ("drm/vc4: hdmi: Add audio-related callbacks")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:25 +01:00
Dom Cobley
e7c1e1d345 drm/vc4: Treat zero sized destination as full screen
Kodi video planes come through with all zeros for fullscreen
Without this check, we WARN when writing width-1, height-1
to destination dlist

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:25 +01:00
Dom Cobley
9f242e89bc vc4_drv: Avoid panic when booted with no kms
If kms/fkms overlay is not present we have no matching drivers
and so match is NULL.

It is not safe to call component_master_add_with_match with a null match argument.

So don't do that

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:25 +01:00
Dom Cobley
e80d51a339 dt-bindings: rtc: new binding for Raspberry Pi RTC driver
Add binding for the new RTC driver for Raspberry Pi.
This platform has an RTC managed by firmware, and this RTC
driver provides the simple mailbox interface to access it.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

dt: bindings: update rpi-rtc binding

Add property for bcm2712 firmware RTC driver charger control

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:25 +01:00
Dom Cobley
6caa0ffaea rtc: rtc-rpi: Add simple RTC driver for Raspberry Pi
This supports setting and reading the real time clock
and supports wakeup alarms.

To support wake up alarms you want this bootloader config:
 POWER_OFF_ON_HALT=1
 WAKE_ON_GPIO=0

You can test with:
  echo +600 | sudo tee /sys/class/rtc/rtc0/wakealarm
  sudo halt

That will halt (in an almost no power state),
then wake and restart after 10 minutes.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

drivers: rtc-rpi: add battery charge circuit control and readback

Parse devicetree for a charger voltage and apply it. If nonzero and a
valid voltage, the firmware will enable charging, otherwise the charger
circuit is disabled.

Add sysfs attributes to read back the supported charge voltage range,
the measured battery voltage, and the charger setpoint.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:25 +01:00
Dom Cobley
69175d6844 irqchip/irq-brcmstb-l2: Add config for 2711 controller
We currently see these regularly:
[   25.157560] irq 31, desc: 00000000c15e6d2c, depth: 0, count: 0, unhandled: 0
[   25.164658] ->handle_irq():  00000000b1775675, brcmstb_l2_intc_irq_handle+0x0/0x1a8
[   25.172352] ->irq_data.chip(): 00000000fea59f1c, gic_chip_mode1+0x0/0x108
[   25.179166] ->action(): 000000003eda6d6f
[   25.183096] ->action->handler(): 000000002c09e646, bad_chained_irq+0x0/0x58
[   25.190084]      IRQ_LEVEL set
[   25.193142]    IRQ_NOPROBE set
[   25.196198]  IRQ_NOREQUEST set
[   25.199255]   IRQ_NOTHREAD set

with:
$ cat /proc/interrupts  | grep 31:
 31:          1          0          0          0     GICv2 129 Level     (null)

The interrupt is described in DT with IRQ_TYPE_LEVEL_HIGH

But the current compatible string uses the controller in edge triggered mode
(as that config matches our register layout).

Add a new compatible structure for level driven interrupt with our register layout.

We had already been using this compatible string in device tree, so no change needed
there.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:25 +01:00
Nick Hollinghurst
a9d74790dd drivers: iommu: Add BCM2712 IOMMU
Add a driver for BCM2712 IOMMUs.
There is a small driver for the Shared IOMMU TLB Cache.
Each IOMMU instance is a separate device.

IOMMUs are set up with a "pass-through" range covering
the lowest 40BGytes (which should cover all of SDRAM)
for the benefit of non-IOMMU-aware devices that share
a physical IOMMU; and translation for addresses in the
range 40GB to 42GB.

An optional parameter adds a DMA offset (which otherwise
would be lost?) to virtual addresses for DMA masters on a
bus such as PCIe.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>

iommu: bcm2712-iommu: Map and unmap multiple pages in a single call

For efficiency, the map_pages() and unmap_pages() calls now pay
attention to their "count" argument.

Remove a special case for a "pass-through" address range, which
the DMA/IOMMU subsystem isn't told exists and should never use.

Fix a bug where we omitted to set *mapped to 0 in error cases.
Minor style fixes and tidying.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>

iommu/bcm2712: don't allow building as module

Since bcm2712-iommu{,-cache}.c doesn't have usual module descriptors
such as `MODULE_LICENSE`, configuring this as 'M' fails the build with
`ERROR: modpost: missing MODULE_LICENSE() in <...>/bcm2712-iommu.o`.
Since it seems like the code is not intended to be built as a module
anyway (it registers the driver with `builtin_platform_driver()`), don't
allow building this code as a module.

Signed-off-by: Ratchanan Srirattanamet <peathot@hotmail.com>
2024-08-05 11:15:24 +01:00
Dom Cobley
d652818b9a dmaengine: bcm2835: Rename to_bcm2711_cbaddr to to_40bit_cbaddr
As the shifted address also applies to bcm2712,
give the function a more specific name.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:24 +01:00
Maxime Ripard
56c8d339dd dmaengine: bcm2835: HACK: Support DMA-Lite channels
The BCM2712 has a DMA-Lite controller that is basically a BCM2835-style
DMA controller that supports 40 bits DMA addresses.

We need it for HDMI audio to work, but this breaks BCM2835-38 so we
should rework this later.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>

dmaengine: bcm2835: Fix dma driver for BCM2835-38

The previous commit broke support on older devices.
Make the breaking parts of patch conditional on
the device being used.

Fixes: 6e1856ac7c39 ("dmaengine: bcm2835: HACK: Support DMA-Lite channels")

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:24 +01:00
Phil Elwell
d557233b06 dmaengine: bcm2835: Add BCM2712 support
BCM2712 has 6 40-bit channels - DMA6 to DMA11. Add a new compatible
string to indicate that the current platform is BCM2712.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:24 +01:00
Iago Toral Quiroga
eda6e6c16c dt-bindings: gpu: v3d: Add BCM2712 to compatibility list 2024-08-05 11:15:24 +01:00
Iago Toral Quiroga
a07e7ca28d drm/v3d: add brcm,2712-v3d as a compatible V3D device 2024-08-05 11:15:24 +01:00
Nick Hollinghurst
ba63ed77ea spi: spi-gpio: Implement spidelay when requested bit rate <= 1 Mbps
Formerly the delay was omitted as bit-banged SPI seldom achieved
even one Mbit/s; but some modern platforms can run faster, and
some SPI devices may need to be clocked slower.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
2024-08-05 11:15:24 +01:00
Nick Hollinghurst
31e821d2c6 spi: gpio: Fix spi-gpio to correctly implement sck-idle-input
Formerly, if configured using DT, CS GPIOs were driven from spi.c
and it was possible for CS to be asserted (low) *before* starting
to drive SCK. CS GPIOs have been brought under control of this
driver in both ACPI and DT cases, with a fixup for GPIO polarity.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
2024-08-05 11:15:24 +01:00
Phil Elwell
17d368507a soc: bcm: bcm2835-power: Add support for BCM2712
BCM2712 has a PM block but neither ASB nor RPIVID_ASB. Use the absence
of the "asb" register range to indicate BCM2712 and its different PM
register range.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:24 +01:00
Phil Elwell
dca9999e06 mfd: bcm2835-pm: Add support for BCM2712
BCM2712 lacks the "asb" and "rpivid_asb" register ranges, but still
requires the use of the bcm2835-power driver to reset the V3D block.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:24 +01:00
Phil Elwell
737a72c659 hwmon: Add RP1 ADC and temperature driver
Signed-off-by: Phil Elwell <phil@raspberrypi.com>

drivers: hwmon: rp1-adc: check conversion validity before supplying value

The SAR ADC architecture may complete a conversion but instability in the
comparator can corrupt the result. Such corruption is signalled in the CS
ERR bit, asserted alongside each conversion result.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:24 +01:00
Phil Elwell
40982bcc47 dt-bindings: net: cdns,macb: AXI tuning properties
Add optional properties to tune the AXI interface -
cdns,aw2w-max-pipe, cdns,ar2r-max-pipe and cdns,use-aw2b-fill.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:24 +01:00
Naushir Patuck
5453add76d media: rp1: Add CFE (Camera Front End) support
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

v4l2: Add pisp compression format support to v4l2

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

media: rp1: cfe: Fix use of freed memory on errors

cfe_probe_complete() calls cfe_put() on both success and fail code paths.
This works for the success path, but causes the cfe_device struct to be
freed, even if it will be used later in the teardown code.

Fix this by making the ref handling a bit saner: Let the video nodes
have the refs as they do now, but also keep a ref in the "main" driver,
released only at cfe_remove() time. This way the driver does not depend
on the video nodes keeping the refs.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Fix width & height in cfe_start_channel()

The logic for handling width & height in cfe_start_channel() is somewhat
odd and, afaics, broken. The code reads:

bool start_fe = is_fe_enabled(cfe) &&
                test_all_nodes(cfe, NODE_ENABLED, NODE_STREAMING);

if (start_fe || is_image_output_node(node)) {
        width = node->fmt.fmt.pix.width;
        height = node->fmt.fmt.pix.height;
}

cfe_start_channel() is called for all video nodes that will be used. So
this means that if, say, fe_stats is enabled as the last node, start_fe
will be true, and width and height will be taken from fe_stats' node.
The width and height will thus contain garbage, which then gets
programmed to the csi2 registers.

It seems that this often still works fine, though, probably if the width
& height are large enough.

Drop the above code, and instead get the width & height from the csi2
subdev's sink pad for the csi2 channel that is used. For metadata the
width & height will be 0 as before.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Fix verbose debug print

The debug print in cfe_schedule_next_csi2_job() is printed every frame,
and should thus use cfe_dbg_irq() to avoid spamming, rather than cfe_dbg().

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Rename xxx_dbg_irq() to xxx_dbg_verbose()

Rename the xxx_dbg_irq() macros to xxx_dbg_verbose(), as they can be
used to verbose debugs outside irq context too.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Add verbose debug module parameter

Expose the verbose debug flag as a module parameter.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Drop unused field

Drop 'sensor_embedded_data' field, as it is unused.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Fix default meta format's field

Set default meta format's field to V4L2_FIELD_NONE, instead of zeroing
it which indicates V4L2_FIELD_ANY. Metadata doesn't have fields, so NONE
makes sense, and furthermore the default v4l2 link validation will check
for matching fields, or that the sink field is NONE.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Fail streaming if FE_CONFIG node is not enabled

When the FE is enabled, ensure that the FE_CONFIG node is enabled.
Otherwise fail cfe_start_streaming() entirely.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

drivers: media: rp1_cfe: Remove PISP specific MBUS formats

Remove the MEDIA_BUS_FMT_PISP* format codcs entirely. For the image
pad formats, use the 16-bit Bayer format mbus codes instead. For the
config and stats pad formats, use MEDIA_BUS_FMT_FIXED.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

drivers: media: rp1_cfe: Fix link validate test for pixel format

Now that we have removed unique PISP media bus codes, the cfe format
table has multiple entries with the same media bus code for 16-bit
formats. The test in cfe_video_link_validate() did not account for this.
Fix it by testing the media bus code and the V4L2 pixelformat 4cc
together.

As a drive-by, ensure we have a valid CSI2 datatype id when programming
the hardware block.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

drivers: media: cfe: Set the CSI-2 link frequency correctly

Use the sensor provided link frequency to set the DPHY timing parameters
on stream_on. This replaces the hard-coded 999 MHz value currently being
used. As a fallback, revert to the original 999 Mhz link frequency.

As a drive-by, fix a 80-character line formatting error.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

drivers: media: cfe: Don't confuse MHz and Mbps

The driver was interchaning these units when talking about link rate.
Fix this to avoid confusion. Apart from the logging message change,
there is no function change in this commit.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

media: rp1: csi2: Fix missing reg writes

The driver has two places where it writes a register based on a
condition, and when that condition is false, the driver presumes that
the register has the reset value. This is not a good idea, so fix those
places to always write the register.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: fe: Use ~0, not -1, when working with unsigned values

Use ~0, not -1, when working with unsigned values (-1 is not unsigned).

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: Add back reg write debug prints

Add back debug prints in csi2 and pisp_fe reg_write() functions, but use
the 'irq' variants to avoid spamming in normal situation.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: csi2: Track CSI-2 errors

Track the errors from the CSI-2 receiver: overflows and discards. These
are recorded in a table which can be read by the userspace via debugfs.

As tracking the errors may cause much more interrupt load, the tracking
needs to be enabled with a module parameter.

Note that the recording is not perfect: we only record the last
discarded DT for each discard type, instead of recording all of them.
This means that e.g. if the device is discarding two unmatched DTs, the
debugfs file only shows the last one recorded. Recording all of them
would need a more sophisticated recording system to avoid the need of a
very large table, or dynamic allocation.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: csi2: Set values for enum csi2_mode

Set hardcoded values for enum csi2_mode, as the values will be
programmed to HW registers.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: fe: Fix default mbus code

When pisp_fe_pad_set_fmt() is given an mbus code that CFE does not
support, it currently defaults to MEDIA_BUS_FMT_SBGGR10_1X10. This is
not correct, as FE does not support SBGGR10.

Set the default to MEDIA_BUS_FMT_SRGGB16_1X16 instead.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

drivers: media: cfe: Find the source pads on the sensor entity

The driver was assuming that pad 0 on the sensor entity was the
appropriate source pad, but this isn't necessarily the case.
With video-mux, it has the sink pads first, and then the source
pad as the last one.

Iterate through the sensor pads to find the relevant source pads.

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

media: rp1: cfe: Expose find_format_by_pix()

Make find_format_by_pix() accessible to other files in the driver.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Add cfe_find_16bit_code() and cfe_find_compressed_code()

Add helper functions which, given an mbus code, return the 16-bit
remapped mbus code or the compressed mbus code.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: csi2: Use get_frame_desc to get CSI-2 VC and DT

Use get_frame_desc pad op for asking the CSI-2 VC and DT from the source
device driver, instead of hardcoding to VC 0, and getting the DT from a
formats table. To keep backward compatibility with sources that do not
implement get_frame_desc, implement a fallback mechanism that always
uses VC 0, and gets the DT from the formats table, based on the CSI2's
sink pad's format.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Add is_image_node()

The hardware supports streaming from memory (in addition to streaming
from the CSI-2 RX), but the driver does not support this at the moment.

There are multiple places in the driver which uses
is_image_output_node(), even if the "output" part is not relevant. Thus,
in a minor preparation for the possible support for streaming from
memory, and to make it more obvious that the pieces of code are not
about the "output", add is_image_node() which will return true for both
input and output video nodes.

While at it, reformat also the metadata related macros to fit inside 80
columns.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Dual purpose video nodes

The RP1 CSI-2 DMA can capture both video and metadata just fine, but at
the moment the video nodes are only set to support either video or
metadata.

Make the changes to support both video and metadata. This mostly means
tracking both video format and metadata format separately for each video
node, and using vb2_queue_change_type() to change the vb2 queue type
when needed.

Briefly, this means that the user can get/set both video and meta
formats to a single video node. The vb2 queue buffer type will be
changed when the user calls REQBUFS or CREATE_BUFS ioctls. This buffer
type will be then used as the "mode" for the video node when the user
starts the streaming, and based on that either the video or the meta
format will be used.

A bunch of macros are added (node_supports_xxx()), which tell if a node
can support a particular mode, whereas the existing macros
(is_xxx_node()) will tell if the node is currently in a particular mode.
Note that the latter will only work correctly between the start of the
streaming and the end of the streaming, and thus should be only used in
those code paths.

However, as the userspace (libcamera) does not support dual purpose
video nodes, for the time being let's keep the second video node as
V4L2_CAP_META_CAPTURE only to keep the userspace working.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: Drop LE handling

The driver registers for line-end interrupts, but never uses them. This
just causes extra interrupt load, with more complexity in the driver.

Drop the LE handling. It can easily be added back if later needed.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Improve link validation for metadata

Improve the link validation for metadata by:
- Allowing capture buffers that are larger than the incoming frame
  (instead of requiring exact match).

- Instead of assuming that a metadata unit ("pixel") is 8 bits, use
  find_format_by_code() to get the format and use the bit depth from
  there. E.g. bit depth for RAW10 metadata will be 10 bits, when we
  move to the upstream metadata formats.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

drivers: media: cfe: Add more robust ISR handlers

Update the ISR logic to be more robust to sensors in problematic states
where interrupts may start arriving overlapped and/or missing.

1) Test for cur_frame in the FE handler, and if present, dequeue it in
an error state so that it does not get orphaned.

2) Move the sequence counter and timestamp variables to the node
structures.  This allows the ISR to track channels running ahead when
interrupts arrive unordered.

3) Add a test to ensure we don't have a spurios (but harmlesS) call to
the FE handler in some circumstances.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

media: rp1: cfe: Fix error paths in cfe_start_streaming

Noted that if we get "node link is not enabled", then we also
get the videobuf2 splat for the driver not cleaning up correctly
on a failed start_streaming, and indeed we weren't returning the
buffers.

Checking the other error paths, noted that the "FE enabled, but
FE_CONFIG node is not" path was not calling pm_runtime_put.

Fix both paths.

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

drivers: media: cfe: Increase default size of embedded buffer

Increase the size of the default embedded buffer to 16k. This is done to
match what is advertised by the IMX219 driver and workaround a problem
where the embedded stream is not actually used. Without full streams API
support, the media pipeline validation will fail in these circumstances.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

media: rp1: cfe: Actually use the number of lanes configured

The driver was calling get_mbus_config to ask the sensor subdev
how many CSI2 data lanes it wished to use and with what other
properties, but then failed to pass that to the DPHY configuration.

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

media: rp1: csi2: Fix csi2_pad_set_fmt()

The CSI-2 subdev's set_fmt currently allows setting the source and sink
pad formats quite freely. This is not right, as the CSI-2 block can only
do one of the following when processing the stream: 1) pass through as
is, 2) expand to 16-bits, 3) compress.

The csi2_pad_set_fmt() should take this into account, and only allow
changing the source side mbus code, compared to the sink side format.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: csi2: Use standard link_validate

The current csi2_link_validate() skips some important checks. Let's
rather use the standard v4l2_subdev_link_validate_default() as the
link_validate hook.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: csi2: Squash fixes

media: rp1: fe: Fix pisp_fe_pad_set_fmt()

pisp_fe_pad_set_fmt() allows setting the pad formats quite freely. This
is not correct, and the function should only allow formats as supported
by the hardware. Fix this by:

Allow no format changes for FE_CONFIG_PAD and FE_STATS_PAD. They should
always be the hardcoded initial ones.

Allow setting FE_STREAM_PAD freely (but the mbus code must be
supported), and propagate the format to the FE_OUTPUT0_PAD and
FE_OUTPUT1_PAD pads.

Allow changing the mbus code for FE_OUTPUT0_PAD and FE_OUTPUT1_PAD pads
only if the mbus code is the compressed version of the sink side code.

TODO: FE supports scaling and cropping. This should be represented here
too?

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: fe: Use standard link_validate

The current pisp_fe_link_validate() skips some important checks. Let's
rather use the standard v4l2_subdev_link_validate_default() as the
link_validate hook.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

drivers: media: cfe: Add 16-bit and compressed mono format support

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

media: rp1: cfe: Add missing remaps

8-bit bayer formats are missing remap definitions. Add them.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Add missing compressed remaps

16-bit bayer formats are missing compressed remap definitions. Add them.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

drivers: media: pisp_be: pisp_fe: Update UAPI header licenses

Update the license tags on the pisp UAPI header files with the
"Linux-syscall-note" clause.  Also replace the "GPL-2.0" tag with the
preferred "GPL-2.0-only" tag.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

media: rp1: cfe: Use the MIPI_CSI2_DT_xxx defines for csi_dt

Seeing as we now have the CSI2 data types defined, make use of
them instead of hardcoding the values.

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

media: rp1: cfe: Add a csi_dt value for 16bit formats

Raw 16bit formats didn't have a csi_dt value defined, which
presumably would trip the WARN_ON(!fmt->csi_dt); in
cfe_start_channel.

The value is defined in CSI2 v2.0 as 0x2e, so set it accordingly.

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

drivers: media: pisp_be: Add mono and 48-bit RGB pixel format support

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

drivers: media: pisp_be: Update seqeuence numbers of the buffers

Add a framebuffer sequence counter and increment on every completed job.
This counter is then used to update the VB2 buffer sequence count before
calling vb2_buffer_done().

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:24 +01:00
Nick Hollinghurst
ab0e4816e1 drm: Add RP1 VEC driver
Add support for the RP1 VEC hardware.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>

drm: rp1: rp1-vec: Allow non-standard modes with various crops

Tweak sync timings in the advertised modelines.

Accept other, custom modes, provided they fit within the active
area of one of the existing hardware-supported TV modes.

Instead of always padding symmetrically, try to respect the user's
[hv]sync_start values, allowing the image to be shifted around
the screen (to fine-tune overscan correction).

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>

drm/rp1: depends on, instead of select, MFD_RP1

According to kconfig-language.txt [1], select should be used only for
"non-visible symbols ... and for symbols with no dependencies". Since
MFD_RP1 both is visible and has a dependency, "select" should not be
used and "depends on" should be used instead.

In particular, this fixes the build of this kernel tree on NixOS, where
its kernel config system will try to answer 'M' to as many config as
possible.

[1] https://www.kernel.org/doc/html/latest/kbuild/kconfig-language.html

Signed-off-by: Ratchanan Srirattanamet <peathot@hotmail.com>

drm: rp1: Use tv_mode from the command line and fix for Linux 6.6

Use the standard enum drm_connector_tv_mode instead of a private
enum and switch from the legacy to the standard tv_mode property.

Remove the module parameter "tv_norm". Instead, get tv_mode from
the command line and make this the connector's default TV mode.

Don't restrict the choice of modes based on tv_mode, but interpret
nonstandard combinations as NTSC or PAL, depending on resolution.
Thus the default tv_mode=NTSC effectively means "Auto".

Tweak the advertised horizontal timings for 625/50 to match Rec.601

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>

drm: rp1: VEC and DPI drivers: Fix bug #5901

Rework probe() to use devm_drm_dev_alloc(), embedding the DRM
device in the DPI or VEC device as now seems to be recommended.

Change order of resource allocation and driver initialization.
This prevents it trying to write to an unmapped register during
clean-up, which previously could crash.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
2024-08-05 11:15:24 +01:00
Nick Hollinghurst
d6e895ee02 drm: Add RP1 DPI driver
Add support for the RP1 DPI hardware.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>

drm/rp1: depends on, instead of select, MFD_RP1

According to kconfig-language.txt [1], select should be used only for
"non-visible symbols ... and for symbols with no dependencies". Since
MFD_RP1 both is visible and has a dependency, "select" should not be
used and "depends on" should be used instead.

In particular, this fixes the build of this kernel tree on NixOS, where
its kernel config system will try to answer 'M' to as many config as
possible.

[1] https://www.kernel.org/doc/html/latest/kbuild/kconfig-language.html

Signed-off-by: Ratchanan Srirattanamet <peathot@hotmail.com>

drm: rp1: VEC and DPI drivers: Fix bug #5901

Rework probe() to use devm_drm_dev_alloc(), embedding the DRM
device in the DPI or VEC device as now seems to be recommended.

Change order of resource allocation and driver initialization.
This prevents it trying to write to an unmapped register during
clean-up, which previously could crash.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
2024-08-05 11:15:24 +01:00
Nick Hollinghurst
68ed5a951e drm: Add RP1 DSI driver
Add support for the RP1 DSI hardware.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>

drm/rp1: depends on, instead of select, MFD_RP1

According to kconfig-language.txt [1], select should be used only for
"non-visible symbols ... and for symbols with no dependencies". Since
MFD_RP1 both is visible and has a dependency, "select" should not be
used and "depends on" should be used instead.

In particular, this fixes the build of this kernel tree on NixOS, where
its kernel config system will try to answer 'M' to as many config as
possible.

[1] https://www.kernel.org/doc/html/latest/kbuild/kconfig-language.html

Signed-off-by: Ratchanan Srirattanamet <peathot@hotmail.com>
2024-08-05 11:15:24 +01:00
Phil Elwell
f7bc75cbfc pwm: Add support for RP1 PWM
Add a driver for the RP1 PWM block.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:23 +01:00
Phil Elwell
13257b8cb1 spi: dw: Handle combined tx and rx messages
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:23 +01:00
Phil Elwell
88564b5fd0 dmaengine: dw-axi-dmac: Fixes for RP1
Don't assume that DMA addresses of devices are the same as their
physical addresses - convert correctly.

The CFG2 register layout is used when there are more than 8 channels,
but also when configured for more than 16 target peripheral devices
because the index of the handshake signal has to be made wider.

Reset the DMAC on probe

The driver goes to the trouble of tracking when transfers have been
paused, but then doesn't report that state when queried.

Not having APB registers is not an error - for most use cases it's
not even of interest, it's expected. Demote the message to debug level,
which is disabled by default.

Each channel has a descriptor pool, which is shared between transfers.
It is unsafe to treat the total number of descriptors allocated from a
pool as the number allocated to a specific transfer; doing so leads
to releasing buffers that shouldn't be released and walking off the
ends of descriptor lists. Instead, give each transfer descriptor its
own count.

Support partial transfers:
Some use cases involve streaming from a device where the transfer only
proceeds when the device's FIFO occupancy exceeds a certain threshold.
In such cases (e.g. when pulling data from a UART) it is important to
know how much data has been transferred so far, in order that remaining
bytes can be read from the FIFO directly by software.

Add the necessary code to provide this "residue" value with a finer,
sub-transfer granularity.

In order to prevent the occasional byte getting stuck in the DMA
controller's internal buffers, restrict the destination memory width
to the source register width.

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

dmaengine: dw-axi-dmac: Fix a non-atomic update

dw_axi_dma_interrupt disables interrupts for the duration of the channel
handling. It does so by clearing a bit in the DMA_CFG register - an
action that involves a read-modify-write. That in itself would be safe
because there will be no further interrupts, hence no reentrancy, were
it the only bit of code accessing that register.

The only neighbour of INT_EN is DMAC_EN - the main enable for the block.
That's not the sort of thing you would expect to be modified during the
normal course of operation, but bizarrely it is set at the start of the
transfer of every block, in axi_chan_block_xfer_star, by a call to
axi_dma_enable. This can lead to INT_EN being accidentally cleared,
which causes all DMA transfers to time out.

One might think that the enabling was being delayed until the first
transfer, but the probe function calls axi_dma_resume which in turn
calls axi_dma_enable, so that isn't the case.

Fix the atomicity problem by removing the spurious call to
axi_dma_enable.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:23 +01:00
Phil Elwell
39e5b43731 i2c: designware: Add SMBUS quick command support
The SMBUS emulation code turns an SMBUS quick command into a zero-
length read. This controller can't do zero length accesses, but it
can do quick commands, so reverse the emulation. The alternative
would be to properly implement the SMBUS support but that is a lot
more work, and unnecessary just to get i2cdetect working.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:23 +01:00
Phil Elwell
75008c9f41 clk: rp1: Add sdio-clk driver
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:23 +01:00
Liam Fraser
df618a8826 mmc: sdhci-of-dwcmshc: define sdio timeout clocks
Signed-off-by: Liam Fraser <liam@raspberrypi.com>

mmc: sdhci-of-dwcmshc: rp1 sdio changes

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

drivers: mmc: sdhci-of-dwcmshc: add RP1 dt ID and quirks

Differentiate the RP1 variant of the Designware MSHC controller(s).

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:23 +01:00
Phil Elwell
69adc0c1f4 serial: pl011: rp1 uart support
Signed-off-by: Phil Elwell <phil@raspberrypi.com>

ARM: pl011: Add rs485 to the RP1 support

pl011_axi_probe, added for RP1 support, lacks the rs485 additions that
appeared during its development.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:23 +01:00
Phil Elwell
147d504a87 pinctrl: Add rp1 driver
RP1 exposes GPIOs. Add a pinctrl driver to allow control of those.

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

pinctrl: rp1: Use the correct per-bank GPIO base

The GPIO start for each bank - min_gpio - must be used in the IRQ
handler.

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

pinctrl: rp1: Allow legacy brcm,pins on all banks

Support the use of the brcm,pins property for GPIOs in banks 1 and 2,
but only for inputs and outputs - no other legacy mapping.

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

pinctrl: rp1: Support interrupt CPU affinity

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

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

pinctrl: rp1: Clear events when setting IRQ type

When setting the interrupt type, it is unlikely that any latched events
are of interest, so clear them.

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

pinctrl: rp1: Add strict_gpiod module parameter

Setting strict_gpiod to Y makes libgpiod and the gpiod utilities behave
as documented, i.e. pins are returned to being GPIO inputs when they are
released.

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

pinctrl: rp1: Use persist_gpio_outputs

Following 8ff05989b4, adopt the same
parameter name but with the opposite default.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:23 +01:00
Phil Elwell
e852319be3 dt-bindings: pinctrl: Add bindings for Raspberry Pi RP1
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:23 +01:00
Phil Elwell
abab741e52 clk: Add rp1 clock driver
RP1 contains various PLLs and clocks for driving the hardware
blocks, so add a driver to configure these.

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

drivers: clk: rp1: add GPCLK source muxes and additional PLL dividers

General-purpose clocks are routed (via a pad) to a large variety of
peripheral aux muxes, and themselves gather a large variety of source
clocks. Entries without a corresponding name string should not be
selected - they bring out internal test/debug clocks which may be
intermittent or very high frequency.

As the GPCLK inputs to peripheral muxes come from a pad, differentiate
the source name from the divider output name. This allows the
possibility of specifying an off-chip clock source to drive the internal
peripheral clock.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

drivers: clk: rp1: constrain clock divider outputs to design maximums

Overclocking peripherals is generally a bad thing to do - so reject any
attempt to set a clock output higher than it should be.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

clk: rp1: Reserve pll_audio* for clk_i2s

Prevent all clocks except clk_i2s from using the audio PLLs as sources,
so that clk_i2s may be allowed to change them as needed.

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

clk: rp1: Allow clk_i2s to change the audio PLLs

Add dedicated code allowing the audio PLLs to be changed, enabling
perfect I2S clock generation. The slowest legal pll_audio_core and
pll_audio will be selected that leads to the required clk_i2s rate.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:23 +01:00
Phil Elwell
fe21076eeb dt-bindings: clock: Add bindings for Raspberry Pi RP1
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:23 +01:00
Phil Elwell
307e605561 mfd: Add rp1 driver
RP1 is a multifunction PCIe device that exposes a range of
peripherals.
Add the parent driver to manage these.

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

mfd: rp1: Support interrupt CPU affinity

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:23 +01:00
Phil Elwell
e97575a6e1 dt-binding: mfd: Add binding for Raspberry Pi RP1
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:23 +01:00
Naushir Patuck
858e4197c6 V4L2: Add PiSP compressed formats to V4L2
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:23 +01:00
Naushir Patuck
7af2bef4d2 V4L2: Add PiSP opaque formats to V4L2
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:23 +01:00
Jonathan Bell
7691cae72a usb: dwc3: Set DMA and coherent masks early
dwc3 allocates scratch and event buffers in the top-level driver. Hack the
probe function to set the DMA mask before trying to allocate these.

I think the event buffers are only used in device mode, but the scratch
buffers may be used if core hibernation is enabled.

usb: dwc3: add support for new DT quirks

Apply the optional axi-pipe-limit and dis-in-autoretry-quirk properties
during driver probe.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

phy: phy-brcm-usb: Add 2712 support

usb: dwc3: if the host controller instance number is present in DT, use it

If two instances of a dwc3 host controller are specified in devicetree,
then the probe order may be arbitrary which results in the device names
swapping on a per-boot basis.

If a "usb" alias with the instance number is specified, then use
that to construct the device name instead of autogenerating one.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

rp1 dwc3 changes

drivers: usb: dwc3: allow setting GTXTHRCFG on dwc_usb3.0 hardware

Equivalent register fields exist in the SuperSpeed Host version of the
hardware, so allow the use of TX thresholds if specified in devicetree.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

drivers: usb: dwc3: remove downstream quirk dis-in-autoretry

Upstream have unilaterally disabled the feature.

Partially reverts 6e9142a26ee0fdc3a5adc49ed6cedc0b16ec2ed1 (downstream)

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:22 +01:00
Phil Elwell
b823ccd8a2 net: macb: Also set DMA coherent mask
macb: Add device tree properties that allow configuration of the AXI max pipeline register

net: macb: add support for ethtool interrupt moderation configuration

Only global throttling of rx or tx by time quanta is supported.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

macb: add platform device shutdown function. Prevents AXI master over PCIE from hanging when the host is rebooted.

net: macb: increase polling interval for MDIO completion

MDIO is a slow bus (single-digit MHz). Polling at 1us intervals
is a bit aggressive, so increase to 100us as the transaction
usually takes 100-200us to complete.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

net: macb: Several patches for RP1

64-bit RX fix

Also set DMA coherent mask

Add device tree properties that allow configuration of the AXI max
pipeline register

Add support for ethtool interrupt moderation configuration

Only global throttling of rx or tx by time quanta is supported.

Add platform device shutdown function. Prevents AXI master over PCIE
from hanging when the host is rebooted.

Increase polling interval for MDIO completion

MDIO is a slow bus (single-digit MHz). Polling at 1us intervals
is a bit aggressive, so increase to 100us as the transaction
usually takes 100-200us to complete.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

net: macb: Support the phy-reset-gpios property

Allow a PHY to be reset with an optional GPIO. The reset duration can
be specified in milliseconds - the default is 10ms.

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

drivers: net: macb: close device on driver shutdown

Fix some suspicious locking and instead call into macb_close, which
deregisters and frees all resources the corresponding macb_open
claimed.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

net: macb: add hack to prevent TX stalls in a quiet system

See https://github.com/raspberrypi/linux-2712/issues/89

There is some critical window during TX where a further write to the
TSTART bit while TX is active does not cause newly queued TX descriptors
to be consumed.

For now "wait a bit, then try anyway" seems to work.

Requires further investigation, but this unsticks NFS reliably.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

net: macb: set default interrupt moderation for GEM hardware

Defaulting to intmod = 0 is antisocial, as the MAC can generate over
130,000 interrupts per second. 50us is a sensible default.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:22 +01:00
Phil Elwell
0959466df3 reset: reset-brcmstb-rescal: Support shared use
reset_control_reset should not be used with shared reset controllers.
Add support for reset_control_assert and _deassert to get the desired
behaviour and avoid ugly warnings in the kernel log.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:22 +01:00
Phil Elwell
615341c3ab irqchip: irq-bcm2712-mip: Support for 2712's MIP
irqchip: irq-bcm2712-mip: specify bitmap search size as ilog2(N) not N

Freeing also has the same interface.

irqchip: irq-bcm2712-mip: Fix build warnings

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

irqchip: bcm2712-mip: add a quick hack to optionally shift MSI vectors

There are two MIP peripherals in bcm2712, the first gets a first-class
treatment where 64 consecutive GIC SPIs are assigned to all 64 output
vectors. The second gets an agglomeration of 17 GIC SPIs, but only 8 of
these are consecutive starting at the 8th output vector.

For now, allow the use of this smaller contiguous range within a larger
whole.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:22 +01:00
Phil Elwell
40788e90bf sdhci: Add SD Express hook
sdhci: remove PYA0_INTR_BUG quirk. Add quirks to disable some of the higher SDR speeds at 1.8v.
2024-08-05 11:15:22 +01:00
Ulf Hansson
8e952c6cb9 mmc: brcmstb: add support for BCM2712
BCM2712 has an SD Express capable SDHCI implementation and uses
the SDIO CFG register block present on other STB chips.

Add plumbing for SD Express handover and BCM2712-specific functions.

Due to the common bus infrastructure between BCM2711 and BCM2712,
the driver also needs to implement 32-bit IO accessors.

mmc: brcmstb: override card presence if broken-cd is set

Not just if the card is declared as nonremovable.

sdhci: brcmstb: align SD express switchover with SD spec v8.00

Part 1 of the Physical specification, figure 3-24, details the switch
sequence for cards initially probed as SD. Add a missing check for DAT2
level after switching VDD2 on.

sdhci: brcmstb: clean up SD Express probe and error handling

Refactor to avoid spurious error messages in dmesg if the requisite SD
Express DT nodes aren't present.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

mmc: sdhci-brcmstb: only use the delay line PHY for tuneable speeds

The MMC core has a 200MHz core clock which allows the use of DDR50 and
below without incremental phase tuning. SDR50/SDR104 and the EMMC HS200
speeds require tuning.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

mmc: sdhci-brcmstb: remove 32-bit accessors for BCM2712

The reason for adding these are lost to the mists of time (and for a
previous chip revision). Removing these accessors appears to have no ill
effect on production chips, so get rid of the unnecessary RMW cycles.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

drivers: mmc: sdhci-brcmstb: fix usage of SD_PIN_SEL on BCM2712

The SDIO_CFG register SD_PIN_SEL conflates two settings - whether eMMC
HS or SD UHS timings are applied to the interface, and whether or not
the card-detect line is functional. SD_PIN_SEL can only be changed when
the SD clock isn't running, so add a bcm2712-specific clock setup.

Toggling SD_PIN_SEL at runtime means the integrated card-detect feature
can't be used, so this controller needs a cd-gpios property.

Also fix conditionals for usage of the delay-line PHY - no-1-8-v will
imply no bits set in hsemmc_mask or uhs_mask, so remove it.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

drivers: sdhci-brcmstb: set CQE timer clock frequency

CQHCI keeps track of tags in flight with internal timers, so the clock
frequency driving the timer needs to be specified. The config registers
default to 0 (100kHz) which means timeouts will be significantly shorter
than they should be. Assume the timer clock comes from the controller
base clock.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:22 +01:00
Phil Elwell
d86d5a7503 pinctrl: bcm2712 pinctrl/pinconf driver
pinctrl: bcm2712: Reject invalid pulls

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

pinctrl: bcm2712: Add 7712 support, fix 2712 count

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

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

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

pinctrl: bcm2712: correct BCM2712C0 AON_GPIO pad pull control offset

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

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

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

pinctrl: bcm2712: Implement (partially) pinconf_get

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

pinctrl: bcm2712: Convert to generic pinconf

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

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

pinctrl: bcm2712: Remove vestigial pull parameter

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

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

pinctrl: bcm2712: Guard against bad func numbers

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

pinctrl: bcm2712: A better attempt at D0 support

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

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

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

pinctrl: bcm2712: Delete base register constants

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

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

pinctrl: bcm2712: Fix for sparse GPIOs

BCM2712D0's sparse GPIO map revealed that it is not safe to treat
group_selector as the GPIO number - it is an index into the array of
pinctrl_pin_descs, and the "number" member says which GPIO it refers to.

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

pinctrl: bcm2712: Fix for the first valid GPIO

A non-zero mux bit number is used to detect a valid entry in the
pin_regs tables, but GPIO 0 (GPIO 1 on D0) is a valid GPIO with a mux
bit number of zero, so add a high-bit on all valid entries to
distinguish this from an uninitialised row in the table.

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

drivers: pinctrl: add BCM2712D0 EMMC pins

The pad control registers are concatenated onto the GPIO pad control
registers, as with previous steppings.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:22 +01:00
Phil Elwell
f1bb46b23f Allow RESET_BRCMSTB on ARCH_BCM2835 2024-08-05 11:15:22 +01:00
Dom Cobley
5be0add8c8 gpio_brcmstb: Allow to build for ARCH_BCM2835
gpio-brcmstb: Report the correct bank width

gpio: brcmstb: Use bank address as gpiochip label

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

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

gpio: mmio: Add DIRECT mode for shared access

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

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

gpio: brcmstb: Don't always clear interrupt mask

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

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

gpio: brcmstb: Use dynamic GPIO base numbers

Forcing a gpiochip to have a fixed base number now leads to a warning
message. Remove the need to do so by calculating hwirq numbers based
on bank numbers.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Fixes: 3b0213d56e ("gpio: Add GPIO support for Broadcom STB SoCs")
2024-08-05 11:15:22 +01:00
Phil Howard
1f61f891c9 rtc: rv3028: Add backup switchover mode support
Signed-off-by: Phil Howard <phil@pimoroni.com>
2024-08-05 11:15:22 +01:00
Dom Cobley
931b7d6ef8 bcm2835-unicam: hacks to allow it to build
media: bcm2835-unicam: Fix up async notifier usage

Fixes "8a090fc3e549 bcm2835-unicam: hacks to allow it to build"
2024-08-05 11:15:22 +01:00
Dave Stevenson
47b7b78764 drm/ili9486: Resolve clash in spi_device_id names
For "Really Good Reasons" [1] the SPI core requires a match
between compatible device strings and the name in spi_device_id.

The ili9486 driver uses compatible strings "waveshare,rpi-lcd-35"
and "ozzmaker,piscreen", but "rpi-lcd-35" and "piscreen" are missing,
so add them.

Compatible string "ilitek,ili9486" is already used by
staging/fbtft/fb_ili9486, therefore leaving it present in ili9486 as an
spi_device_id causes the incorrect module to be loaded, therefore remove
this id.

[1] https://elixir.bootlin.com/linux/latest/source/drivers/spi/spi.c#L487

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:22 +01:00
Nicolai Buchwitz
c0fe833edd cfg80211: ship debian certificates as hex files
Loading the regulatory database from the debian files fails with

"loaded regulatory.db is malformed or signature is missing/invalid"

due to missing certificates.  Add these debian-specific certificates
from upstream to fix this error. See #5536 for details.

The certificates have been imported as following:

patch -p1 <<<$(
curl https://salsa.debian.org/kernel-team/linux/-/raw/\
master/debian/patches/debian/\
wireless-add-debian-wireless-regdb-certificates.patch
)

Signed-off-by: Nicolai Buchwitz <n.buchwitz@kunbus.com>
2024-08-05 11:15:22 +01:00
Jonathan Bell
ceb63ee9e9 usb: xhci: add XHCI_VLI_HUB_TT_QUIRK
The integrated USB2.0 hub in the VL805 chipset has a bug where it
incorrectly determines the remaining available frame time before the
host next sends a SOF packet with an incremented frame_number.

See the USB2.0 specification sections 11.3 and 11.14.2.3.

The hub's non-periodic TT handler can transmit the IN/OUT handshake
token too late, so a following 64-byte DATA0/1 packet causes the ACK
handshake to collide with the propagated SOF. This causes port babble.

Avoid ringing doorbells for vulnerable endpoints during uFrame 7 if the
TR is Idle to stop one source of babble. An IN transfer for a Running TR
may happen at any time, so there's not much we can do about that.

Ideally a hub firmware update to properly implement frame timeouts is
needed, and to avoid spinning for up to 125us when submitting TDs to
Idle rings.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

xhci: constrain XHCI_VLI_HUB_TT_QUIRK to old firmware versions

VLI have a firmware update for the VL805 which resolves the incorrect
frame time calculation in the hub's TT. Limit applying the quirk to
known-bad firmwares.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:22 +01:00
Jonathan Bell
a498f712d2 usb: xhci: add VLI_SS_BULK_OUT_BUG quirk
The VL805 can cause data corruption if a SS Bulk OUT endpoint enters a
flow-control condition and there are TRBs in the transfer ring that are
not an integral size of wMaxPacket and the endpoint is behind one or more
hubs.

This is frequently the case encountered when FAT32 filesystems are
present on mass-storage devices with cluster sizes of 1 sector, and the
filesystem is being written to with an aggregate of small files.

The initial implementation of this quirk separated TRBs that didn't
adhere to this limitation into two - the first a multiple of wMaxPacket
and the second the 512-byte remainder - in an attempt to force TD
fragments to align with packet boundaries. This reduced the incidence
rate of data corruption but did not resolve it.

The fix as recommended by VIA is to disable bursts if this sequence of
TRBs can occur.

Limit turning off bursts to just USB mass-storage devices by searching
the device's configuration for an interface with a class type of
USB_CLASS_MASS_STORAGE.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:22 +01:00
Jonathan Bell
eee04fbcfa usb: xhci: borrow upstream TRB_FETCH quirk on VL805 hosts
This reimplements 5a57342 usb: xhci: add VLI_TRB_CACHE_BUG quirk

The downstream implementation required a fair bit of driver surgery to
allow for truncated ring segments, which needed to shrink by a small
amount to avoid the cache prefetcher from reading off the end of one
segment and into another.

An upstream implementation for a similar bug on a different controller
just doubles the size of the memory allocated for ring segments, which
is a bit more wasteful (+4K per allocation) but means less code churn.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:22 +01:00
Jonathan Bell
46ea911343 xhci: quirks: add link TRB quirk for VL805
The VL805 controller can't cope with the TR Dequeue Pointer for an endpoint
being set to a Link TRB. The hardware-maintained endpoint context ends up
stuck at the address of the Link TRB, leading to erroneous ring expansion
events whenever the enqueue pointer wraps to the dequeue position.

If the search for the end of the current TD and ring cycle state lands on
a Link TRB, move to the next segment.

Link: https://github.com/raspberrypi/linux/issues/3919

[6.5.y Fixup - move downstream quirk bits further along]

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:21 +01:00
Naushir Patuck
48aeb335a7 drivers: media: bcm2835_unicam: Improve frame sequence count handling
Ensure that the frame sequence counter is incremented only if a previous
frame start interrupt has occurred, or a frame start + frame end has
occurred simultaneously.

This corresponds the sequence number with the actual number of frames
produced by the sensor, not the number of frame buffers dequeued back
to userland.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:21 +01:00
Phil Elwell
39f4dcab49 serial: sc16is7xx: Read modem line state at startup
This patch sets the driver modem line state to the actual line state
at driver startup.

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

Signed-off-by: Earl Schmidt <schmidt.earl.f@gmail.com>
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:21 +01:00
Phil Elwell
4eee3aaa07 pps: Compatibility hack should be X86-specific
As of [1], using PPS_FETCH on a 64-bit ARM kernel with a 32-bit userland
is broken, returning a timeout. This is because the requested 4-byte
alignment for struct pps_ktime_compat (illegal on arm64) results in the
timeout flags field being uninitialised.

Make the hack specific to X86_64 builds with CONFIG_COMPAT defined.

[1] commit c2a49fe8ee ("pps: fix padding issue with PPS_FETCH for
    ioctl_compat")

See: https://github.com/raspberrypi/linux/issues/5430
Fixes: c2a49fe8ee ("pps: fix padding issue with PPS_FETCH for ioctl_compat")
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:21 +01:00
Dave Stevenson
9cbe7d36be i2c-bcm2835: Implement I2C_M_IGNORE_NAK
Now that transfers aren't aborted immediately (and uncleanly) on
errors, and the FIFOs are always drained after all transfers, we
can implement I2C_M_IGNORE_NAK by ignoring the returned error
value.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:21 +01:00
Dave Stevenson
2609c39334 i2c-bcm2835: Do not abort transfers on ERR if still active
If a transaction is aborted immediately on ERR being reported,
then the bus is not returned to the STOP condition, and devices
generally get very upset.

Handle the ERR and CLKT conditions only when TA is not set.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:21 +01:00
Dave Stevenson
aa4f5854d3 i2c-bcm2835: Flush FIFOs cleanly on error
On error condition, note the error return code, but still
handle the FIFOs in the normal way rather than relying on
C_CLEAR flushing everything cleanly.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:21 +01:00
Dom Cobley
de1635d8a8 drm/vc4: hdmi: Increase MAI fifo dreq threshold
Now we wait for write responses and have a burst
size of 4, we can set the fifo threshold much higher.

Set it to 28 (of the 32 entry size) to keep fifo
fuller and reduce chance of underflow.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:21 +01:00
Phil Elwell
cfd337c977 spi: bcm2835: Use phys addresses for slave DMA config
Contrary to what struct snd_dmaengine_dai_dma_data suggests, the
configuration of addresses of DMA slave interfaces should be done in
CPU physical addresses.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:21 +01:00
Phil Elwell
2a97746935 mmc: bcm2835: Use phys addresses for slave DMA config
Contrary to what struct snd_dmaengine_dai_dma_data suggests, the
configuration of addresses of DMA slave interfaces should be done in
CPU physical addresses.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:21 +01:00
Phil Elwell
46890823f8 drm/vc4: Use phys addresses for slave DMA config
Slave addresses for DMA are meant to be supplied as physical addresses
(contrary to what struct snd_dmaengine_dai_dma_data does).

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:21 +01:00
Phil Elwell
0ebd89a9d2 pinctrl: bcm2835: Workaround for edge IRQ loss
It has been observed that edge events can be lost when GPIO edges occur
close to each other. Investigation suggests this is due to a hardware
bug, although no mechanism has been identified.

Work around the event loss by moving the IRQ acknowledgement into the
main ISR, adding missing events by explicit level-change detection.

See: https://forums.raspberrypi.com/viewtopic.php?t=350295

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:21 +01:00
Phil Elwell
92cf8d4b94 Bluetooth: hci_bcm: Add more invalid BDADDRs
The kernel needs to recognise the default BDADDRs used by the Bluetooth
modems, so add a few more that we care about.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:21 +01:00
Phil Elwell
3cb24a947b Bluetooth: hci_sync: Add fallback-bd-address prop
The kernel Bluetooth framework understands that devices may not
be programmed with valid Bluetooth addresses. It also has the ability
to override a Bluetooth address with the value of the local-bd-address
DT property, but it ignores the validity of the existing address when
doing so.

Add a new boolean property, fallback-bd-address, which indicates that
the given local-bd-address property should only be used if the device
does not already have a valid BDADDR.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:21 +01:00
Phil Elwell
606326dd1c serial: 8250: Add NOMSI bug for bcm2835aux
The BCM2835 mini-UART has no modem status interrupt, causing all
transmission to stop, never to use, if a speed change ever happens
while the CTS signal is high.

Add a simple polling mechanism in order to allow recovery in that
situation.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:21 +01:00
Dave Stevenson
0dd2fc1486 input: goodix: Add option to poll instead of relying on IRQ line
The interrupt line from the touch controller is not necessarily
connected to the SoC, so add the option to poll for touch info.

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

input: goodix: Include I2C details in names for the devices

libinput uses the input device name alone. If you have two
identical input devices, then there is no way to differentiate
between them, and in the case of touchscreens that means no
way to associate them with the appropriate display device.

Add the I2C bus and address to the start of the input device
name so that the name is always unique within the system.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:21 +01:00
Dave Stevenson
070b91d3d9 media: bcm2835-unicam: Start and stop media_pipeline with same node
media_pipeline_start and media_pipeline_stop now validate that
the pipeline is being started and stopped with the same pipe
and pad handles.
When running with embedded metadata (eg imx477 and imx708), the
start typically happens from the metadata pad, whilst stop is
always from the image pad.

Always pass the image pad to media_pipeline_start to ensure
that the calls are balanced.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:20 +01:00
Naushir Patuck
df7df636b5 dt-bindings: media: i2c: Replace IMX708 sensor binding documentation file
Replace the existing imx708.yaml file with sony,imx708.yaml that follows
the latest devicetree conventions for camera sensors.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:20 +01:00
Phil Elwell
4fd0dcb25a fbdev: Don't cancel deferred work if pagelist empty
Since [1], the fbdev deferred IO framework is careful to cancel
pending updates on close to prevent dirty pages being accessed after
they may have been reused. However, this is not necessary in the case
that the pagelist is empty, and drivers that don't make use of the
pagelist may have wanted updates cancelled for no good reason.

Avoid penalising fbdev drivers that don't make use of the pagelist by
making the cancelling of deferred IO on close conditional on there
being a non-empty pagelist.

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

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

[1] 3efc61d952 ("fbdev: Fix invalid page access after closing deferred I/O devices")
2024-08-05 11:15:20 +01:00
Phil Elwell
938f5d4e28 hwrng: bcm2835 - sleep more intelligently
While waiting for random data, use sleeps that are proportional
to the amount of data expected. Prevent indefinite waits by
giving up if nothing is received for a second.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:20 +01:00
David Plowman
33596623f6 media: i2c: imx219: Correct the minimum vblanking value
The datasheet for this sensor documents the minimum vblanking as being
32 lines. It does fix some problems with occasional black lines at the
bottom of images (tested on Raspberry Pi).

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2024-08-05 11:15:20 +01:00
Phil Elwell
30342758d6 iio: light: veml6070: Add DT compatible string
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:20 +01:00
Phil Elwell
7569ec9e1a iio: light: tsl4531: Add DT compatible string
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:20 +01:00
Phil Elwell
b9d30524c3 hwmon: (sht3x) Add DT compatible string
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:20 +01:00
Phil Elwell
cf33dcbe93 rtc: ds3232: Add DT compatible string for ds3234
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:20 +01:00
Phil Elwell
edc67653e3 hwmon: (ds1621) Add DT compatible strings
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:20 +01:00
Phil Elwell
b5295d8e1e hwmon: (aht10): Add DT compatible string
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:20 +01:00
Phil Elwell
00597760ed gpio: pca953x: Add ti,tca9554 compatible string
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:20 +01:00
Phil Elwell
851065f3aa iio: adc: mcp3422: Add correct compatible strings
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:20 +01:00
Dave Stevenson
1a6482c80d media: bcm2835-unicam: Add support for RAW16 formats
With the RAW16 formats now having a defined CSI2 data type ID,
they can be added to the driver.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:20 +01:00
Dave Stevenson
a56526cd35 media: bcm2835-unicam: Use mipi-csi2.h header for data type values
The MIPI CSI2 data type ID values are now defined in the
mipi-csi2.h header, so use those defines instead of hard
coding them in the driver.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:20 +01:00
Nick Hollinghurst
e853b73878 media/i2c: Add a driver for the Sony IMX708 image sensor
The imx708 is a 12MP MIPI sensor with a 16:9 aspect ratio, here using
two CSI-2 lanes. It is a "quad Bayer" sensor with all 3 modes offering
10-bit output:

12MP: 4608x2592 up to 14.35fps (full FoV)
1080p: 2304x1296 up to 56.02fps (full FoV)
720p: 1536x864 up to 120.12fps (cropped)

This imx708 sensor driver is based heavily on the imx477 driver and
has been tested on the Raspberry Pi platform using libcamera.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>

drivers: media: imx708: Enable long exposure mode

Enable long exposure modes by using the long exposure shift register setting
in the imx708 sensor.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

drivers: media: i2c: imx708: Fix crop information

The 1536x864 mode contained incorrect crop information.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>

drivers: media: i2c: imx708: Fix WIDE_DYNAMIC_RANGE control with long exposure

Setting V4L2_CID_WIDE_DYNAMIC_RANGE was causing the long exposure
shift count to be reset, which is incorrect if the user has already
changed the frame length to cause it to have a non-zero value.

Because it only updates control ranges and doesn't set any registers,
the control can also be applied when the sensor is not powered on.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>

drivers: media: imx708: Increase usable link frequencies

Add support for three different usable link frequencies (default 450Mhz,
447Mhz, and 453MHz) for the IMX708 camera sensor. The choice of
frequency is handled thorugh the "link-frequency" overlay parameter.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

drivers: media: imx708: Remove unused control fields

Remove unused and redundant control fields from the state structure.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

drivers: media: imx708: Tidy-ups to address upstream review comments

This commit addresses vaious tidy-ups requesed for upstreaming the
IMX708 driver. Notably:

- Remove #define IMX708_NUM_SUPPLIES and use ARRAY_SIZE() directly
- Use dev_err_probe where possible in imx708_probe()
- Fix error handling paths in imx708_probe()

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

drivers: media: imx708: Follow the standard devicetree labels

Switch the system clock name from "xclk" to "inclk".
Use lower case lables for all regulator names.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

drives: media: imx708: Put HFLIP and VFLIP controls in a cluster

Create a cluster for the HVLIP and VFLIP controls so they are treated
as a single composite control.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

drivers: media: imx708: Adjust broken line correction parameter

In full-resolution mode, the LPF_INTENSITY_EN and LPF_INTENSITY
registers control Quad Bayer Re-mosaic broken line correction.
Expose this as a module parameter "qbc_adjust": zero disables
the correction and values in the range 2 to 5 set its strength.

There is a trade-off between coloured and monochrome patterns.
The previous fixed value 4 could produce ladder/spots artefacts
in coloured textures. The new default value 2 may suit a wider
range of scenes.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>

media: i2c: imx708: Squash fixes
2024-08-05 11:15:20 +01:00
Dave Stevenson
d56c85d65a dtbindings: media: i2c: Add IMX708 CMOS sensor binding
Add YAML devicetree binding for IMX708 CMOS image sensor.
Let's also add a MAINTAINERS entry for the binding and driver.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:19 +01:00
Dave Stevenson
490af31749 media: dw9807-vcm: Smooth the first user movement of the lens
The power up/down sequence is already ramped. Extend this to
the first user movement as well, as this will generally avoid
the "tick" noises due to rapid movements and overshooting.
Subsequent movements are generally smaller and so don't cause
issues.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:19 +01:00
Dave Stevenson
be4568430c media: dw9807-vcm: Add regulator support to the driver
Uses the regulator notifier framework so that the current
focus position will be restored whenever any user of the
regulator powers it up. This means that should the VCM
and sensor share a common regulator then starting the sensor
will automatically restore the default position. If they
have independent regulators then it will behave be powered
up when the VCM subdev is opened.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:19 +01:00
Dave Stevenson
b86863ed9f media: dt-bindings: Add regulator to dw9807-vcm
The VCM driver will often be controlled via a regulator,
therefore add in the relevant DT hooks.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:19 +01:00
Dave Stevenson
acaa64c71c media: dw9807-vcm: Add support for DW9817 bidirectional VCM driver
The DW9817 is effectively the same as DW9807 from a programming
interface, however it drives +/-100mA instead of 0-100mA. This means
that the power on ramp needs to take the lens from the midpoint, and
power off return it there. It also changes the default position for
the module.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:19 +01:00
Dave Stevenson
37526b0363 media: dt-bindings: Add DW9817 to DW9807 binding
The DW9817 is programmatically the same as DW9807, but
the output drive is a bi-directional -100 to +100mA
instead of 0-100mA.

Add the appropriate compativle string.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:19 +01:00
Phil Elwell
a38763dc6f net: bcmgenet: Add 'eee' module parameter
On some switches, having EEE enabled causes the link to become
unstable. With this patch, adding 'genet.eee=N' to the kernel command
line will cause EEE to be disabled on the link.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:19 +01:00
Dave Stevenson
19c6b06c8a media: i2c: ov7251: Add module param to select ext trig mode
As there isn't currently a defined mechanism for selecting an
external trigger mode on image sensors, copy the imx477
approach of using a module parameter to enable ext trig.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:19 +01:00
Dave Stevenson
bd308851ef media: adv7180: Nasty hack to allow input selection.
Whilst the adv7180 driver support s_routing, nothing else
does, and there is a missing lump of framework code to
define the mapping from connectors on a board to the inputs
they represent on the ADV7180.

Add a nasty hack to take a module parameter that is passed in
to s_routing on any call to G_STD, or S_STD (or subdev
g_input_status call).

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
2024-08-05 11:15:19 +01:00
Dom Cobley
bde274fa46 media: bcm2835-unicam: Fix up start/stop api change
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:19 +01:00
Naushir Patuck
88f8d767a5 media: bcm2835-unicam: Fix for possible dummy buffer overrun
The Unicam hardware has been observed to cause a buffer overrun when using the
dummy buffer as a circular buffer. The conditions that cause the overrun are not
fully known, but it seems to occur when the memory bus is heavily loaded.

To avoid the overrun, program the hardware with a buffer size of 0 when using
the dummy buffer. This will cause overrun into the allocated dummy buffer, but
avoid out of bounds writes.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:19 +01:00
Dave Stevenson
a83353eb2b media: video-mux: Read CSI2 config from FW, and pass to receiver
There is no obligation for all source devices on a video-mux to
require the same bus configuration, so read the configuration
from the sink ports, and relay via get_mbus_config on the source
port.
If the sources support get_mbus_config, then call that first.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:19 +01:00
Naushir Patuck
9bcf9cd8a2 media: bcm2835-unicam: Correctly handle FS + FE ISR condtion
If we get a simultaneous FS + FE interrupt for the same frame, it cannot be
marked as completed and returned to userland as the framebuffer will be refilled
by Unicam on the next sensor frame. Additionally, the timestamp will be set to 0
as the FS interrupt handling code will not have run yet.

To avoid these problems, the frame is considered dropped in the FE handler,
and will be returned to userland on the subsequent sensor frame.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:19 +01:00
Jonathan Lemon
f48d066fcb Populate phy driver block for BCM54213PE
The BCM54213PE identifier is a RPI-specific addition.
Populate the remainder of the driver functions, including the
required probe routine.

Add a version of bcm54xx_suspend, from upstream.

Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
2024-08-05 11:15:19 +01:00
Dom Cobley
b2e054b9cf Add HDMI1 facility to the driver.
Also check for which HDMI devices are connected and only create
devices for those that are present.

Signed-off-by: James Hughes <james.hughes@raspberrypi.org>
Signed-off-by: Dom Cobley <popcornmix@gmail.com>

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>

staging: bcm2835-audio: Add disable-headphones flag

Add a property to allow the headphone output to be disabled. Use an
integer property rather than a boolean so that an overlay can clear it.

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

staging: bcm2835-audio: Find compatible firmware node

Commit "ARM: dts: Adopt the upstream snd_bcm2835 handling" removed the
audio section from the DT and the driver can no longer access the
referenced firmware node 'brcm,firmware'. Fix that by searching for a
compatible firmware node instead, similar to drivers/gpu/drm/vc4.

Fixes: b9e62329e096 ("ARM: dts: Adopt the upstream snd_bcm2835 handling")
Signed-off-by: Juerg Haefliger <juergh@proton.me>

staging: bcm2835-audio: Fix firmware node refcounting

Decrement firmware node refcounts on all exit paths in set_hdmi_enables().

Signed-off-by: Juerg Haefliger <juergh@proton.me>

staging: bcm2835-audio: Log errors in case of firmware query failures

The driver queries the firmware for the number of detected HDMI displays
and their IDs. Log error messages if queries fail.

Signed-off-by: Juerg Haefliger <juergh@proton.me>

staging: bcm2835-audio: Fix unused enable_hdmi module parameter

The commit "Add HDMI1 facility to the driver." made the enable_hdmi module
parameter unused. Fix that by making it a global switch for all available
HDMI audio outputs.

Fixes: 755f336608 ("Add HDMI1 facility to the driver.")
Signed-off-by: Juerg Haefliger <juergh@proton.me>

staging: bcm2835-audio: Fix unused enable_headphones module parameter

Since commit "staging: bcm2835-audio: Add disable-headphones flag" the
enabling/disabling of the headphones output is solely determined by the
presence of the DT property 'brcm,disable-headphones' and the
enable_headphones module parameter is unused. Fix that by making it a
global switch.

Fixes: ee90e47d88 ("staging: bcm2835-audio: Add disable-headphones flag")
Signed-off-by: Juerg Haefliger <juergh@proton.me>
2024-08-05 11:15:19 +01:00
Lee Jackson
62496598fb media: i2c: Add driver of Arducam 64MP camera
Add a driver for the Arducam 64MP camera 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:

9152x6944 10-bit @ 2.7fps
4624x3472 10-bit (binned) @ 10fps
3840x2160 10-bit (cropped/binned) @ 20fps
2312x1736 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: arducam_64mp: Advertise embedded data node on media pad 1

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

The arducam_64mp 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: arducam_64mp: Modify the line length of 1280x720 resolution

Arducam 64MP has specific requirements for the line length, and if these
conditions are not met, the camera will not function properly. Under the
previous configuration, once a stream off operation is performed, the
camera will not output any data, even if a stream on operation is
performed. This prevents us from switching from 1280x720 to another
resolution.

Signed-off-by: Lee Jackson <lee.jackson@arducam.com>

media: i2c: arducam_64mp: Add 8000x6000 resolution

Added 8000x6000 10-bit (cropped) @ 3fps mode for Arducam 64MP

Signed-off-by: Lee Jackson <lee.jackson@arducam.com>

media: i2c: arducam_64mp: Add PDAF support

Enable PDAF output for all modes, and also need to modify Embedded Line
Width to 11560 * 3 (two lines of Embedded Data + one line of PDAF).

Signed-off-by: Lee Jackson <lee.jackson@arducam.com>

drivers: media: arducam_64mp: Add V4L2_CID_LINK_FREQ control

Add V4L2_CID_LINK_FREQ as a read-only control with a value of 456 Mhz.
This will be used by the CFE driver to corretly setup the DPHY timing
parameters in the CSI-2 block.

Signed-off-by: Lee Jackson <lee.jackson@arducam.com>
2024-08-05 11:15:18 +01:00
Lee Jackson
a8f0ba11bf media: dt-bindings: media: i2c: Add Arducam 64MP CMOS sensor binding
Add YAML device tree binding for Arducam 64MP CMOS image sensor, and
the relevant MAINTAINERS entries.

Signed-off-by: Lee Jackson <info@arducam.com>
2024-08-05 11:15:18 +01:00
Jason A. Donenfeld
26f8b060a6 random: do not use jump labels before they are initialized
[ I would like to pursue fixing this more directly first before actually
  merging this, but I thought I'd send this to the list now anyway as a
  the "backup" plan. If I can't figure out how to make headway on the
  main plan in the next few days, it'll be easy to just do this. ]

Stephen reported that a static key warning splat appears during early
boot on systems that credit randomness from device trees that contain an
"rng-seed" property, because because setup_machine_fdt() is called
before jump_label_init() during setup_arch():

 static_key_enable_cpuslocked(): static key '0xffffffe51c6fcfc0' used before call to jump_label_init()
 WARNING: CPU: 0 PID: 0 at kernel/jump_label.c:166 static_key_enable_cpuslocked+0xb0/0xb8
 Modules linked in:
 CPU: 0 PID: 0 Comm: swapper Not tainted 5.18.0+ #224 44b43e377bfc84bc99bb5ab885ff694984ee09ff
 pstate: 600001c9 (nZCv dAIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
 pc : static_key_enable_cpuslocked+0xb0/0xb8
 lr : static_key_enable_cpuslocked+0xb0/0xb8
 sp : ffffffe51c393cf0
 x29: ffffffe51c393cf0 x28: 000000008185054c x27: 00000000f1042f10
 x26: 0000000000000000 x25: 00000000f10302b2 x24: 0000002513200000
 x23: 0000002513200000 x22: ffffffe51c1c9000 x21: fffffffdfdc00000
 x20: ffffffe51c2f0831 x19: ffffffe51c6fcfc0 x18: 00000000ffff1020
 x17: 00000000e1e2ac90 x16: 00000000000000e0 x15: ffffffe51b710708
 x14: 0000000000000066 x13: 0000000000000018 x12: 0000000000000000
 x11: 0000000000000000 x10: 00000000ffffffff x9 : 0000000000000000
 x8 : 0000000000000000 x7 : 61632065726f6665 x6 : 6220646573752027
 x5 : ffffffe51c641d25 x4 : ffffffe51c13142c x3 : ffff0a00ffffff05
 x2 : 40000000ffffe003 x1 : 00000000000001c0 x0 : 0000000000000065
 Call trace:
  static_key_enable_cpuslocked+0xb0/0xb8
  static_key_enable+0x2c/0x40
  crng_set_ready+0x24/0x30
  execute_in_process_context+0x80/0x90
  _credit_init_bits+0x100/0x154
  add_bootloader_randomness+0x64/0x78
  early_init_dt_scan_chosen+0x140/0x184
  early_init_dt_scan_nodes+0x28/0x4c
  early_init_dt_scan+0x40/0x44
  setup_machine_fdt+0x7c/0x120
  setup_arch+0x74/0x1d8
  start_kernel+0x84/0x44c
  __primary_switched+0xc0/0xc8
 ---[ end trace 0000000000000000 ]---
 random: crng init done
 Machine model: Google Lazor (rev1 - 2) with LTE

A trivial fix went in to address this on arm64, 73e2d827a5 ("arm64:
Initialize jump labels before setup_machine_fdt()"). But it appears that
fixing it on other platforms might not be so trivial. Instead, defer the
setting of the static branch until later in the boot process.

Fixes: f5bda35fba ("random: use static branch for crng_ready()")
Reported-by: Stephen Boyd <swboyd@chromium.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Phil Elwell <phil@raspberrypi.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2024-08-05 11:15:18 +01:00
Dave Stevenson
9e24ee64cf vc04_services: vchiq-mmal: Add defines for mmal_es_format flags
There is a flags field in struct mmal_es_format, but the defines
for what the bits meant weren't included in the headers.
For V4L2_PIX_FMT_NV12_COL128 support we need them, so add them in.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:18 +01:00
Phil Elwell
96a5624dd4 hwmon: emc2305: fixups for driver submitted to mailing lists
The driver had a number of issues, checkpatch warnings/errors,
and other limitations, so fix these up to make it usable.

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

hwmon: emc2305: Add calls to initialise of cooling maps

Commit 46ef9d4ed2 ("hwmon: emc2305: fixups for driver submitted to
mailing lists") missed adding the call to thermal_of_cooling_device_register
required to configure any cooling maps for the device, hence stopping it
from actually ever changing speed.

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

hwmon: emc2305: Change OF properties pwm-min & pwm-max to u8

There is no DT binding for emc2305 as mainline are still
discussing how to do a generic fan binding.
The 5.15 driver was reading the "emc2305," properties
"cooling-levels", "pwm-max", "pwm-min", and "pwm-channel" as u8.
The overlay was writing them as u16 (;) so it was working.

The 6.1 driver was reading as u32, which failed as there is
insufficient data.

As this is all downstream only, revert to u8 to match 5.15.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:18 +01:00
Michael Shych
256d945290 dt-bindings: hwmon: add microchip,emc2305.yaml dt binding description.
Submitted to linux-hwmon mailing list at
https://patchwork.kernel.org/project/linux-hwmon/patch/20220430114905.53448-3-michaelsh@nvidia.com/

Add basic description of emc2305 driver device tree binding.

Signed-off-by: Michael Shych <michaelsh@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>

dtbindings: Fixup microchip,emc2305.yaml bindings

The bindings submitted to mainline had some issues, so fix them up.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:18 +01:00
Dave Stevenson
af61fded52 thermal: broadcom: Use dev_err_probe to suppress defer errors
It is quite common for the devm_thermal_zone_of_sensor_register
to need to defer, so avoid spamming the log by using
dev_err_probe instead of dev_err.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:18 +01:00
Lee Jackson
65c3ec5bb1 media: i2c: Add driver of Arducam Pivariety series camera
Add a driver for the Arducam Pivariety series CSI2 camera sensor.

Signed-off-by: Lee Jackson <info@arducam.com>

SQUASH: Fix VIDEO_ARDUCAM_PIVARIETY Kconfig entry

The cherry-pick from rpi-5.17.y put it in the wrong section, and failed
to update it for 5.18.

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

media: i2c: arducam-pivariety: Add custom controls

Add support for strobe_shift, strobe_width and mode custom controls.

Signed-off-by: Lee Jackson <info@arducam.com>
2024-08-05 11:15:18 +01:00
Lee Jackson
6f6530270e media: dt-bindings: media: i2c: Add Arducam Pivariety Series CMOS sensor binding
Add YAML device tree binding for Arducam Pivariety CMOS image sensor, and
the relevant MAINTAINERS entries.

Signed-off-by: Lee Jackson <info@arducam.com>
2024-08-05 11:15:18 +01:00
Lee Jackson
b6413f621c dt-bindings: vendor-prefixes: Add Arducam
Add vendor prefix for Arducam (https://arducam.com).

Signed-off-by: Lee Jackson <info@arducam.com>
2024-08-05 11:15:18 +01:00
Scovotto Davide
4865054492 tpm_tis_spi_main: Force probe routine to run synchronously with driver and device registration when IMA is enabled
Co-authored-by: Alberto Solavagione <albertosolavagione30@gmail.com>
Co-developed-by: Alberto Solavagione <albertosolavagione30@gmail.com>
Signed-off-by: Alberto Solavagione <albertosolavagione30@gmail.com>
Signed-off-by: Davide Scovotto <scovottodavide@gmail.com>
2024-08-05 11:15:18 +01:00
David Plowman
bbd418372f mm,page_alloc,cma: introduce a customisable threshold for allocating pages in cma
On some platforms the cma area can be half the entire system memory,
meaning that allocations start happening in the cma area immediately.
This leads to fragmentation and subsequent fatal cma_alloc failures.

We introduce an "alloc_in_cma_threshold" parameter which requires that
this many sixteenths of the free pages must be in cma before it will
try to use them. By default this is set to 12, but the previous
behaviour can be restored by setting it to 8 on startup.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2024-08-05 11:15:18 +01:00
Naushir Patuck
74d485bece drivers: staging: bcm2835-isp: Clear LS table handle in the firmware
When all nodes have stopped streaming, ensure the firmware has released its
handle on the LS table dmabuf. This is done by passing a null handle in the
LS params.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:18 +01:00
Dave Stevenson
051242eb07 media: i2c: ov5647: Use v4l2_async_register_subdev_sensor for lens binding
v4l2_async_register_subdev doesn't bind in lens or flash drivers,
but v4l2_async_register_subdev_sensor does.
Switch to using v4l2_async_register_subdev_sensor.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:18 +01:00
Dave Stevenson
8bb1a827c9 media: i2c: Add driver for AD5398 VCM lens driver
Adds a driver for the Analog Devices AD5398 10 bit
I2C DAC which is commonly used for driving VCM lens
mechanisms.

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

media: i2c: Rename ad5398 to ad5398_vcm

There's already a regulator module called ad5398 that exposes
this device through the regulator API. That is meaningless in
the terms that it uses and how it maps to V4L2, so a new driver
was added. However the module name collision wasn't noted, so
rename it now.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:18 +01:00
Dave Stevenson
a51d3ad17c dt-bindings: media: i2c: Add binding for ad5398 VCM
Add a binding for Analog Devices AD5398 10bit current
sinking DAC when used as a lens VCM driver.

FIXME: Convert to YAML

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:17 +01:00
Naushir Patuck
98c82ebab0 drivers: staging: bcm2835-isp: Do not cleanup mmal vcsm buffer on stop_streaming
On stop_streaming() the vcsm buffer handle gets released by the buffer cleanup
code.  This will subsequently cause and error if userland re-queues the same
buffer on the next start_streaming() call.

Remove this cleanup code and rely on the vb2_ops->buf_cleanup() call to do the
cleanups instead.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:17 +01:00
David Plowman
21aa728ac6 staging: vc04_services: isp: Permit all sRGB colour spaces on ISP outputs
ISP outputs actually support all colour spaces that are fundamentally
sRGB underneath, regardless of whether an RGB or YUV output format is
actually requested.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2024-08-05 11:15:17 +01:00
Dave Stevenson
9703778c03 media/i2c: Add driver for Omnivision OV2311
Omnivision OV2311 is a CSI2 1600x1300 global shutter image sensor.
Add a driver for it.

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

media: i2c: Update ov2311 Kconfig entry

Bring the OV2311 Kconfig declaration in line with upstream entries.

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

media: i2c: ov2311: Fix uninitialized variable usage

Signed-off-by: Alexander Winkowski <dereference23@outlook.com>
2024-08-05 11:15:17 +01:00
Dave Stevenson
c74bf62b97 media: i2c: ov7251: Reinstate setting ov7251_global_init_setting
"media: i2c: Remove .s_power() from ov7251" removed the call that
sent ov7251_global_init_setting to the sensor. Send it when starting
streaming.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:17 +01:00
Dave Stevenson
56a104500d media: bcm2835-unicam: Handle a repeated frame start with no end
In the case of 2 frame starts being received with no frame end
between, the queued buffer held in next_frm was lost as the
pointer was overwritten with the dummy buffer.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:17 +01:00
Phil Elwell
d6bc6b2239 spi: gpio: Add sck-idle-input property
The sck-idle-input property indicates that the spi-gpio driver should
return the SCK line to an input when the chip select signals are
inactive.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:17 +01:00
Phil Elwell
8e9dfb6946 bindings: Add sck-idle-input to spi-gpio
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:17 +01:00
Alex Crawford
41a8bf4465 i2c: bcm2835: Make clock-stretch timeout configurable
The default clock-stretch timeout is 35 mS, which works well for
SMBus, but there are some I2C devices which can stretch the clock even
longer. Rather than trying to prescribe a safe default for everyone,
allow the timeout to be configured.

Signed-off-by: Alex Crawford <raspberrypi/linux@code.acrawford.com>
2024-08-05 11:15:17 +01:00
Nathan Chancellor
e078b3eb5b media: bcm2835-unicam: Set ret on error path in unicam_async_complete()
Clang warns:

  drivers/media/platform/bcm2835/bcm2835-unicam.c:3109:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
          if (!source_pads) {
              ^~~~~~~~~~~~
  drivers/media/platform/bcm2835/bcm2835-unicam.c:3152:9: note: uninitialized use occurs here
          return ret;
                 ^~~
  drivers/media/platform/bcm2835/bcm2835-unicam.c:3109:2: note: remove the 'if' if its condition is always false
          if (!source_pads) {
          ^~~~~~~~~~~~~~~~~~~
  drivers/media/platform/bcm2835/bcm2835-unicam.c:3091:9: note: initialize the variable 'ret' to silence this warning
          int ret;
                 ^
                  = 0
  1 warning generated.

When the if condition is true, ret will be used uninitialized, which
could result in undesirable behavior. Set ret to -ENODEV on the error
path, which is a standard error code for the ->complete() callback.

Fixes: d056e86eb3 ("media/bcm2835-unicam: Parse pad numbers correctly")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
2024-08-05 11:15:17 +01:00
Naushir Patuck
992b28b414 drivers: bcm2835_unicam: Disable trigger mode operation
On a Pi3 B/B+ platform the imx219 sensor frequently generates a single corrupt
frame when the sensor first starts. This can either be a missing line, or
invalid samples within the line. This only occurrs using the Unicam kernel
driver.

Disabling trigger mode elimiates this corruption. Since trigger mode is a
legacy feature copied from the firmware driver and not expected to be needed,
remove it. Tested on the Raspberry Pi cameras and shows no ill effects.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:17 +01:00
Dave Stevenson
6839f40368 power: rpi-poe: Add option of being created by MFD or FW
The firmware can only use I2C0 if the kernel isn't, therefore
with libcamera and DRM using it the PoE HAT fan control needs
to move to the kernel.

Add the option for the driver to be created by the PoE HAT core
MFD driver, and use the I2C regmap that provides to control fan
functions.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:17 +01:00
Dave Stevenson
ede2feda14 power: rpi-poe: Drop CURRENT_AVG as it is not hardware averaged
As documented the _AVG parameters are meant to be hardware
averaged, but the implementation for the PoE+ HAT was done in
software in the firmware.

Drop the property.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:17 +01:00
Dave Stevenson
bcb2277b12 pwm: raspberrypi-poe: Add option of being created by MFD or FW
The firmware can only use I2C0 if the kernel isn't, therefore
with libcamera and DRM using it the PoE HAT fan control needs
to move to the kernel.

Add the option for the driver to be created by the PoE HAT core
MFD driver, and use the I2C regmap that provides to control fan
functions.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:17 +01:00
Dave Stevenson
29a69f0020 mfd: simple-mfd-i2c: Add configuration for RPi POE HAT
The Raspbery Pi PoE+ HAT exposes a fan controller and power
supply status reporting via a single I2C address.

Create an MFD device that allows loading of the relevant
sub-drivers, with a shared I2C regmap.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:17 +01:00
Padmanabha Srinivasaiah
7db7923837 bcm2835-v4l2-isp: Add missing lock initialization
ISP device allocation is dynamic hence the locks too.
struct mutex queue_lock is not initialized which result in bug.

Fixing same by initializing it.

[   29.847138] INFO: trying to register non-static key.
[   29.847156] The code is fine but needs lockdep annotation, or maybe
[   29.847159] you didn't initialize this object before use?
[   29.847161] turning off the locking correctness validator.
[   29.847167] CPU: 1 PID: 343 Comm: v4l_id Tainted: G         C        5.15.11-rt24-v8+ #8
[   29.847187] Hardware name: Raspberry Pi 4 Model B Rev 1.4 (DT)
[   29.847194] Call trace:
[   29.847197]  dump_backtrace+0x0/0x1b8
[   29.847227]  show_stack+0x20/0x30
[   29.847240]  dump_stack_lvl+0x8c/0xb8
[   29.847254]  dump_stack+0x18/0x34
[   29.847263]  register_lock_class+0x494/0x4a0
[   29.847278]  __lock_acquire+0x80/0x1680
[   29.847289]  lock_acquire+0x214/0x3a0
[   29.847300]  mutex_lock_nested+0x70/0xc8
[   29.847312]  _vb2_fop_release+0x3c/0xa8 [videobuf2_v4l2]
[   29.847346]  vb2_fop_release+0x34/0x60 [videobuf2_v4l2]
[   29.847367]  v4l2_release+0xc8/0x108 [videodev]
[   29.847453]  __fput+0x8c/0x258
[   29.847476]  ____fput+0x18/0x28
[   29.847487]  task_work_run+0x98/0x180
[   29.847502]  do_notify_resume+0x228/0x3f8
[   29.847515]  el0_svc+0xec/0xf0
[   29.847523]  el0t_64_sync_handler+0x90/0xb8
[   29.847531]  el0t_64_sync+0x180/0x184

Signed-off-by: Padmanabha Srinivasaiah <treasure4paddy@gmail.com>
2024-08-05 11:15:16 +01:00
Dave Stevenson
b5eb16d4a7 uapi/v4l2-controls: Reset V4L2_CID_USER_BCM2835_ISP_BASE to same as 5.10
https://github.com/raspberrypi/linux/issues/4440

Upstream has added additional device specific controls, so the
V4L2_CID_USER_BASE + 0x10e0 value that had been defined for use with
the ISP has been taken by something else (and +0x10f0 has been used as
well)

Duplicate the use on V4L2_CID_USER_BASE + 0x10e0 so that userspace
(libcamera) doesn't need to change. Once the driver is upstream, then
we'll update libcamera to adopt the new value as it then won't change.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:16 +01:00
Phil Elwell
d8fcc46743 staging/bcm2835-isp: Fix cleanup after init fail
bcm2835_isp_remove is called on an initialisation failure, but at that
point the drvdata hasn't been set. This causes a crash when e.g. using
the cutdown firmware (gpu_mem=16).

Move platform_set_drvdata before the instance probing loop to avoid the
problem.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:16 +01:00
Dave Stevenson
c60a151c8d media: i2c: ov7251: Make the enable GPIO optional.
Not all implementations wire up the enable GPIO and may just tie
it to a supply rail.
Make it optional.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:16 +01:00
Dave Stevenson
c0e520eab2 media: i2c: ov5647: Add support for regulator control.
The driver supported using GPIOs to control the shutdown line,
but no regulator control.

Add regulator hooks.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:16 +01:00
Phil Elwell
0dd14a8174 rtc: pcf8523: Fix oscillator stop bit handling
See: https://github.com/raspberrypi/firmware/issues/1065

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:16 +01:00
Dave Stevenson
657c2c2c37 regulator/rpi-panel-attiny: Don't read the LCD power status
The I2C to the Atmel is very fussy, and locks up easily on
Pi0-3 particularly on reads.

The LCD power status is controlled solely by this driver, so
rather than reading it back from the Atmel, use the cached
status last set.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:16 +01:00
Naushir Patuck
65e154c25d drivers: bcm2835_unicam: Add logging message when a frame is dropped.
If a dummy buffer is still active on a frame start, it indicates that this frame
will be dropped. The explicit logging helps users identify performance issues.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:16 +01:00
Phil Elwell
e7ad75e85a spi: spidev: Restore loading from Device Tree
As happens occasionally, an upstream change has once again prevented
spidev from being loaded via Device Tree. We now need "spidev" to be
included in the new spi_device_id list, otherwise although the
spidev driver gets loaded no /dev/spidev*.* entries will appear.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:16 +01:00
Naushir Patuck
cfebb1263a drivers: bcm2835_isp: Fix div by 0 bug.
Fix a possible division by 0 bug when setting up the mmal port for the stats
port.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:16 +01:00
Naushir Patuck
b730f13249 drivers: bcm2835_isp: Allow multiple users for the ISP driver.
Add a second (identical) set of device nodes to allow concurrent use of the ISP
hardware by another user. This change effectively creates a second state
structure (struct bcm2835_isp_dev) to maintain independent state for the second
user. Node and media entity names are appened with the instance index
appropriately.

Further users can be added by changing the BCM2835_ISP_NUM_INSTANCES define.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:16 +01:00
David Plowman
b4a72e3902 media: i2c: ov5647: Support HFLIP and VFLIP
Add these missing V4L2 controls. Tested binned and full resolution
modes in all four orientations using Raspberry Pi running libcamera.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2024-08-05 11:15:16 +01:00
Phil Elwell
c64077ceb2 brcmfmac: Don't promote INFO logging to ERR
An unwanted side effect of enabling the BRCMDBG config setting is
redefining brcmf_info to be brcmf_err. This can be alarming to users
and makes it harder to spot real errors, so don't do it.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:16 +01:00
Gergo Koteles
576f148577 staging/bcm2835-camera: Add support for MPEG_VIDEO_FORCE_KEY_FRAME
Signed-off-by: Gergo Koteles <soyer@irl.hu>
2024-08-05 11:15:16 +01:00
soyer
5ce99d4b85 staging/bcm2835-camera: Add support for H264_MIN_QP, H264_MAX_QP
Signed-off-by: Gergo Koteles <soyer@irl.hu>
2024-08-05 11:15:15 +01:00
Dave Stevenson
c2e6221a59 media/bcm2835-unicam: Add support for configuration via MC API
Adds Media Controller API support for more complex pipelines.
libcamera is about to switch to using this mechanism for configuring
sensors.

This can be enabled by either a module parameter, or device tree.

Various functions have been moved to group video-centric and
mc-centric functions together.

Based on a similar conversion done to ti-vpe.

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

media: bcm2835-unicam: Fixup for 5.18 and new get_mbus_config struct

The number of active CSI2 data lanes has moved within the struct
v4l2_mbus_config used by the get_mbus_config API call.
Update the driver to match the changes in mainline.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:15 +01:00
Dave Stevenson
a8d4489ec1 media/bcm2835-unicam: Parse pad numbers correctly
The driver was making big assumptions about the source device
using pad 0 and 1, which doesn't follow for more complex
devices where Unicam's source device may be a sink device for
something else.

Read the pad numbers through media controller, and reference
them appropriately.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:15 +01:00
David Plowman
9552cceb2c vc04_services: isp: Report input node as wanting full range RAW color space
RAW color spaces are more usually reported as having full range
quantization.

Tested using libcamera.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2024-08-05 11:15:15 +01:00
David Plowman
de1b7207bf media: i2c: ov5647: Sensor should report RAW color space
Tested on Raspberry Pi running libcamera.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2024-08-05 11:15:15 +01:00
Dave Stevenson
f31d79ab7d drivers/gpio: Add a driver that wraps the PWM API as a GPIO controller
For cases where spare PWM outputs are available, but are desired
to be addressed a standard outputs instead.
Wraps a PWM channel as a new GPIO chip with the one output.

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

pwm: gpio-pwm: follow pwm_apply_might_sleep() rename

Fixes: 03286093be68("drivers/gpio: Add a driver that wraps the PWM API as a GPIO controller")
Signed-off-by: Ratchanan Srirattanamet <peathot@hotmail.com>
2024-08-05 11:15:15 +01:00
Phil Elwell
f0272de29a hwmon: (pwm-fan) Add fan speed register support
Some platforms include a fan-speed register that reports RPM directly
as an alternative to counting interrupts from the fan tachometer input.
Add support for reading a register at a given offset (rpm-offset) within
a block declared in another node (rpm-regmap). This indirection allows
the usual address mapping to be performed, and for address sharing with
another driver.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:15 +01:00
Dave Stevenson
88be0b5d8a staging: mmal-vchiq: Reset buffers_with_vpu on port_enable
Should we go through the timeout failure case with port_disable
not returning all buffers for whatever reason, the
buffers_with_vpu counter gets left at a non-zero value, which
will cause reference counting issues should the instance be
reused.

Reset the count when the port is enabled again, but before
any buffers have been sent to the VPU.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:15 +01:00
Dave Stevenson
63516d92a4 staging/mmal-vchiq: Add module parameter to enable logging.
Adds a module parameter "debug" to enable various logging levels.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:15 +01:00
Serge Schneider
ad46123ca7 Add Raspberry Pi PoE+ HAT support
Signed-off-by: Serge Schneider <serge@raspberrypi.com>
2024-08-05 11:15:15 +01:00
Dave Stevenson
4ba37b8333 staging/vchiq-mmal: Add the deinterlace image effects enums
As we're wanting to wrap the image_fx component for deinterlacing,
add the deinterlace algorithm values to enum mmal_parameter_imagefx

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:15 +01:00
Dave Stevenson
adef5f1be7 staging/vchiq-mmal: Add parameters for interlaced video support
Adds enum mmal_interlace_type and struct
mmal_parameter_video_interlace_type to allow for querying the
interlacing mode on decoders.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:15 +01:00
Dave Stevenson
e925c37841 staging/vchiq-mmal: Add buffer flags for interlaced video
Add the buffer flags that the firmware uses to identify fields
on interlaced video

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:15 +01:00
Timon Skerutsch
bc8818af6b dt-bindings: display: panel-dsi bindings
Bindings for the panel-dsi specific additions to panel-simple.
Allow for DSI specific bus settings and panel timing
to be define in devicetree. Very similar to panel-dpi.

Signed-off-by: Timon Skerutsch <kernel@diodes-delight.com>
2024-08-05 11:15:15 +01:00
Chris Morgan
e7dc830212 dt-bindings: display: simple: add Geekworm MZP280 Panel
The Geekworm MZP280 panel is a 480x640 (portrait) panel with a
capacitive touch interface and a 40 pin header meant to interface
directly with the Raspberry Pi. The screen is 2.8 inches diagonally,
and there appear to be at least 4 distinct versions all with the same
panel timings.

Timings were derived from drivers posted on the github located here:
https://github.com/tianyoujian/MZDPI/tree/master/vga

Additional details about this panel family can be found here:
https://wiki.geekworm.com/2.8_inch_Touch_Screen_for_Pi_zero

Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
2024-08-05 11:15:15 +01:00
Chris Morgan
1461697f2d dt-bindings: vendor-prefixes: Add Geekworm
Add vendor prefix for Geekworm (https://geekworm.com).

Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
2024-08-05 11:15:15 +01:00
Dave Stevenson
b589bafedd drm/panel: Add panel driver for Waveshare DSI touchscreens
Waveshare sell a range of DSI panels of varying sizes, all
using a common MCU to control the panel and backlight.

Add a panel driver that supports these panels.

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

drm/panel: waveshare: Fix up timings for 10.1" panel

The 10.1" panel doesn't work with the timings defined. vc4
will always have been fixing up the timing due to the limited
integer divider, so compute the fixed up mode and use it
directly.

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

drivers/gpu/drm/panel:fix waveshare panel software restart/shutdown display is abnormal
Fixed the screen stays white when the user restarts or shuts down

Signed-off-by: eng33 <eng33@waveshare.com>

 drivers/gpu/drm/panel:Modify the DSI mode to fix the problem that 7.9inch cannot be displayed

Signed-off-by: eng33 <eng33@waveshare.com>

 drivers/gpu/drm/panel:Modified the timing of 11.9inch to fix the issue that 11.9inch was displayed abnormally

Signed-off-by: eng33 <eng33@waveshare.com>

Driver:add waveshare 4inch dsi lcd (C) driver

Signed-off-by: Eng33 <eng33@waveshare.net>
2024-08-05 11:15:14 +01:00
Dave Stevenson
5f0357d908 drm/panel/panel-sitronix-st7701: Support SPI config and RGB data
The ST7701 supports numerous different interface mechanisms for
MIPI DSI, RGB, or SPI. The driver was only implementing DSI input,
so add RGB parallel input with SPI configuration.

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

panel-sitronix-st7701: Fix panel prepare over SPI

A DSI write is issued in st7701_prepare even when the probed panel
runs on SPI. In practice, this results in a panic with the
vc4-kms-dpi-hyperpixel2r overlay active.

Perform the equivalent write over SPI in this case.

Signed-off-by: Jack Andersen <jackoalan@gmail.com>
2024-08-05 11:15:14 +01:00
Dave Stevenson
1ce89dcf00 drm/panel: Add panel driver for TDO Y17B based panels
The Top DisplayOptoelectronics (TDO) T17B driver chip is used
in the TL040HDS20CT panel (found in the Pimoroni HyperPixel4
Square display) and potentially other displays.
The driver chip supports SPI for  configuration and DPI
video data.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:14 +01:00
Dave Stevenson
c2ea572b27 dt-bindings: ili9881c: add compatible string for new panels
This new panel uses the ILI9881C IC but needs an alternate
init sequence, and therefore requires a new compatible string.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:14 +01:00
Dom Cobley
a6b7a2804f Extending ili9881c driver support for nwe080 panel
Signed-off-by: Penk Chen <penk@cutiepi.io>

drm/panel: ilitek-ili9881c: Clean up on mipi_dsi_attach failure

mipi_dsi_attach is allowed to fail, and currently the probe
code doesn't clean up (mainly drm_panel_remove) if this happens.

Add cleanup code on failure.

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

drm/panel: panel-ilitek9881c: Add prepare_upstream_first flag

The panel sends MIPI DCS commands during prepare and is expecting
the bus to remain in LP-11 state in-between.

Set the prepare_upstream_first flag so that the upstream DSI host
is prepared / pre_enabled first, and therefore the bus is in a
defined state.

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

drm/panel: panel-ilitek9881c: Use cansleep methods

Use cansleep version of gpiod_set_value so external IO drivers (like
via I2C) can be used.

Signed-off-by: Mark Williams <mwp@mwp.id.au>

drm/panel: panel-ilitek9881c: Crystalfontz support

Add support for Crystalfontz CFAF7201280A0-050Tx panel.

Signed-off-by: Mark Williams <mwp@mwp.id.au>

drm/panel: ilitek-ili9881c: Allow configuration of the number of lanes

Not all panels use all 4 data lanes, so allow configuration based
on the compatible string.

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

drm/panel: ili9881: Add configuration for the new panels

Add configuration for the 5" and 7" Raspberry Pi 720x1280
DSI panels based on ili9881.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:14 +01:00
Dave Stevenson
3fed056250 drm/panel: jdi-lt070me05000: Use gpiod_set_value_cansleep
There is no reason why the control GPIOs for the panel can not
be connected to I2C or similar GPIO interfaces that may need to
sleep, therefore switch from gpiod_set_value to
gpiod_set_value_cansleep calls to configure them.
Without that you get complaints from gpiolib every time the state
is changed.

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

drm: panel: jdi-lt070me05000: Add prepare_upstream_first flag

The panel driver wants to send DCS commands from the prepare
hook, therefore the DSI host wants to be pre_enabled first.
Set the flag to achieve this.

https://forums.raspberrypi.com/viewtopic.php?t=354708

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:14 +01:00
Timon Skerutsch
4f94108b87 drm/panel: add panel-dsi
Equivalent to panel-dpi for configuring a simple DSI panel with
device tree side timings and bus settings.
Motiviation is the same as for panel-dpi of wanting to support
new simple panels without needing to patch the kernel.

Signed-off-by: Timon Skerutsch <kernel@diodes-delight.com>
2024-08-05 11:15:14 +01:00
Dave Stevenson
f54b1c24ed drm/panel: simple: Alter the timing for the Pi 7" DSI display
vc4 has always fixed up the timing, so the values defined have
never actually appeared on the wire.
The display appears to want a slightly longer HFP, so extend
the timings and recompute the clock to give the same frame rate.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:14 +01:00
Phil Elwell
f1cd8bfaaa drm/panel: simple: Add Innolux AT056tN53V1 5.6" VGA
Add support for the Innolux AT056tN53V1 5.6" VGA (640x480) TFT LCD
panel.

Signed-off-by: Joerg Quinten <aBUGSworstnightmare@gmail.com>
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:14 +01:00
Chris Morgan
1ed7c5eb48 drm/panel: simple: add Geekworm MZP280 Panel
Add support for the Geekworm MZP280 Panel

Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
Acked-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:14 +01:00
Dave Stevenson
9c398c2b05 drm/panel-simple: Allow the bus format to be read from DT for panel-dpi
The "panel-dpi" compatible string configures panel from device tree,
but it doesn't provide any way of configuring the bus format (colour
representation), nor does it populate it.

Add a DT parameter "bus-format" that allows the MEDIA_BUS_FMT_xxx value
to be specified from device tree.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:14 +01:00
Dave Stevenson
7c948ed757 drm/panel-simple: Populate bpc when using panel-dpi
panel-dpi doesn't know the bit depth, so in the same way that
DPI is guessed for the connector type, guess that it'll be 8bpc.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:14 +01:00
Dave Stevenson
4623a7bfde drm/panel-simple: Add a timing for the Raspberry Pi 7" panel
The Raspberry Pi 7" 800x480 panel uses a Toshiba TC358762 DSI
to DPI bridge chip, so there is a requirement for the timings
to be specified for the end panel. Add such a definition.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:14 +01:00
Dave Stevenson
c72c497f4e drm/panel/raspberrypi-touchscreen: Use independent I2C actions with delay.
We now have the hardware I2C controller pinmuxed to the drive the
display I2C, but this controller does not support clock stretching.
The Atmel micro-controller in the panel requires clock stretching
to allow it to prepare any data to be read.

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

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

drm/panel/raspberrypi-ts: Insert delay before polling for startup state

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

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

drm/panel/raspberrypi-touchscreen: Handle I2C errors.

rpi_touchscreen_i2c_read returns any errors from i2c_transfer,
or the 8 bit received value.
Check for error values before trying to process the data as
valid.

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

drm/panel/raspberrypi-touchscreen: Insert more delays.

This avoids failures in cases where the panel is enabled
or re-probed very soon after being disabled or probed.
These can occur because the Atmel device can mis-behave
over I2C for a few ms after any write to the POWERON register.
2024-08-05 11:15:14 +01:00
Dave Stevenson
897f589795 media: i2c: ov7251: Add fwnode properties controls
Add call to v4l2_ctrl_new_fwnode_properties to read and
create the fwnode based controls.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:14 +01:00
Jakub Vaněk
089a2b6f1d media: bcm2835-unicam: Forward input status from subdevice
The vidioc_enum_input() v4l2 ioctl is capable of returning
sensor/input status as well. This is used in current
GStreamer HEAD for signal detection [1].

bcm2835-unicam does handle this syscall, but it didn't ask
the subdevice driver about the input status. The input then
appeared as always present.

This commit adds the necessary query. There is a precedent for
this - the R-Car VIN V4L2 driver does a similar call [2].

[1]: ce0be27caf/sys/v4l2/gstv4l2src.c (L553)
[2]: 7fb9d006d3/drivers/media/platform/rcar-vin/rcar-v4l2.c (L548)

Signed-off-by: Jakub Vaněk <linuxtardis@gmail.com>
2024-08-05 11:15:14 +01:00
Naushir Patuck
7c119edfb9 staging: vc04_services: isp: Set the YUV420/YVU420 format stride to 64 bytes
The bcm2835 ISP requires the base address of all input/output planes to have 32
byte alignment. Using a Y stride of 32 bytes would not guarantee that the V
plane would fulfil this, e.g. a height of 650 lines would mean the V plane
buffer is not 32 byte aligned for YUV420 formats.

Having a Y stride of 64 bytes would ensure both U and V planes have a 32 byte
alignment, as the luma height will always be an even number of lines.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:13 +01:00
David Plowman
58a4160a52 media: i2c: ov5647: Fix v4l2-compliance failure subscribing to events
Fixes the following v4l2-compliance failure:

fail: v4l2-test-controls.cpp(871): subscribe event for control 'User Controls' failed test

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2024-08-05 11:15:13 +01:00
David Plowman
e2c3d22d34 media: i2c: ov5647: Correct minimum VBLANK value
Trial and error reveals that the minimum vblank value appears to be 24
(the OV5647 data sheet does not give any clues). This fixes streaming
lock-ups in full resolution mode.

Fixes: 9b5a5ebedc ("media: i2c: ov5647: Add support for V4L2_CID_VBLANK")
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2024-08-05 11:15:13 +01:00
David Plowman
8b177bb239 media: i2c: ov5647: Correct pixel array offset
The top offset in the pixel array is actually 6 (see page 3-1 of the
OV5647 data sheet).

Fixes: f2f7ad5ce5 ("media: i2c: ov5647: Selection compliance fixes")
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2024-08-05 11:15:13 +01:00
Phil Elwell
23aa1e8230 staging/bcm2835-isp: Fix compiler warning
The result of dividing a u32 by a size_t is an unsigned int on arm32
and a long unsigned int on arm64. Use "%zu" (the size_t format) to
remove the build warning for 64-bit builds.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:13 +01:00
Dave Stevenson
024e948a5f staging/bcm2835-camera: Add support for H264 levels 4.1 and 4.2
Whilst the hardware can't achieve the limits of level 4.2 under
all situations, it can exceed level 4.0.

Allow selection of levels 4.1 and 4.2.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:13 +01:00
Phil Elwell
7ab67ac1aa staging: fbtft: Add minipitft13 variant
The Adafruit Mini-PiTFT13 display needs offsets applying when rotated,
so use the "variant" mechanism to select a custom set_addr_win method
using a dedicated compatible string of "fbtft,minipitft13".

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:13 +01:00
Dave Stevenson
872fa3d712 staging/bcm2835-camera: Add support for DMABUFs
DMABUFs are all handled by videobuf2, so there is no reason not
to enable support for them.

Note that this driver is still using the vmalloc allocator, so
the buffers it allocates will not be compatible with the codec
or ISP driver that require contiguous buffers. However this
driver should be able to import the buffers allocated by them.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:13 +01:00
Laurent Pinchart
12eb0c35d3 media: i2c: ov5647: 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>
2024-08-05 11:15:13 +01:00
David Plowman
b6e1be13cb media: ov5647: Fix return codes from ov5647_write/ov5647_read functions.
Previously they were returning positive non-zero codes for success,
which were getting passed up the call stack. Since release 4.19,
do_dentry_open (fs/open.c) has been catching these and flagging an
error. (So this driver has been broken since that date.)

Fixes: 3c2472a [media] media: i2c: Add support for OV5647 sensor
Signed-off-by: David Plowman <david.plowman@raspberrypi.org>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:13 +01:00
Zefa Chen
22888b7f19 media: i2c: add ov9281 driver.
Change-Id: I7b77250bbc56d2f861450cf77271ad15f9b88ab1
Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>

media: i2c: ov9281: fix mclk issue when probe multiple camera.

Takes the ov9281 part only from the Rockchip's patch.

Change-Id: I30e833baf2c1bb07d6d87ddb3b00759ab45a90e4
Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>

media: i2c: ov9281: add enum_frame_interval function for iq tool 2.2 and hal3

Adds the ov9281 parts of the Rockchip patch adding enum_frame_interval to
a large number of drivers.

Change-Id: I03344cd6cf278dd7c18fce8e97479089ef185a5c
Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>

media: i2c: ov9281: Fixup for recent kernel releases, and remove custom code

The Rockchip driver was based on a 4.4 kernel, and had several custom
Rockchip parts.

Update to 5.4 kernel APIs, with the relevant controls required by
libcamera, and remove custom Rockchip parts.

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

media: i2c: ov9281: Read chip ID via 2 reads

Vision Components have made an OV9281 module which blocks reading
back the majority of registers to comply with NDAs, and in doing
so doesn't allow auto-increment register reading as used when
reading the chip ID.

Use two reads and manually combine the results.

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

media: i2c: ov9281: Add support for 8 bit readout

The sensor supports 8 bit mode as well as 10bit, so add the
relevant code to allow selection of this.

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

media: ov9281: Add 1280x720 and 640x480 modes

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

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

Fixed picture line bug in all ov9281 modes

Signed-off-by: Mathias Anhalt <mathiasanhalt@web.de>

Added hflip and vflip controls to ov9281

Signed-off-by: Mathias Anhalt <mathiasanhalt@web.de>

media: i2c: ov9281: Remove override of subdev name

From the original Rockchip driver, the subdev was renamed
from the default to being "mov9281 <dev_name>" whereas the
default would have been "ov9281 <dev_name>".

Remove the override to drop back to the default rather than
a vendor custom string.

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

media: v4l2-subdev: add subdev-wide state struct

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

media: i2c: ov9281: Add fwnode properties controls

Add call to v4l2_ctrl_new_fwnode_properties to read and
create the fwnode based controls.

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

media: i2c: ov9281: Sensor should report RAW color space

Tested on Raspberry Pi running libcamera.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>

Partial revert "media: i2c: add ov9281 driver."

This partially reverts commit 84e98e3a4f.

The commit had merged some changes to other drivers with adding the ov9281
driver. Only the ov9281 parts have been reverted.
2024-08-05 11:15:13 +01:00
Ben Avison
26d78aa803 Assign crypto aliases to different AES implementation modules
The kernel modules aes-neon-blk and aes-neon-bs perform poorly, at least on
Cortex-A72 without crypto extensions. In fact, aes-arm64 outperforms them
on benchmarks, despite it being a simpler implementation (only accelerating
the single-block AES cipher).

For modes of operation where multiple cipher blocks can be processed in
parallel, aes-neon-bs outperforms aes-neon-blk by around 60-70% and aes-arm64
is another 10-20% faster still. But the difference is even more marked with
modes of operation with dependencies between neighbouring blocks, such as
CBC encryption, which defeat parallelism: in these cases, aes-arm64 is
typically around 250% faster than either aes-neon-blk or aes-neon-bs.

The key trade-off with aes-arm64 is that the look-up tables are situated in
RAM. This leaves them potentially open to cache timing attacks. The two other
modules, by contrast, load the look-up tables into NEON registers and so are
able to perform in constant time.

This patch aims to load aes-arm64 more often.

If none of the currently-loaded crypto modules implement a given algorithm,
a new one is typically selected for loading using a platform-neutral alias
describing the required algorithm. To enable users to still
load aes-neon-blk or aes-neon-bs if they really want them, while still
ensuring that aes-arm64 is usually selected, remove the aliases from
aes-neonbs-glue.c and aes-glue.c and apply them to aes-cipher-glue.c, but
still build the two NEON modules.

Since aes-glue.c can also be used to build aes-ce-blk, leave them enabled
if USE_V8_CRYPTO_EXTENSIONS is defined, to ensure they are selected if we
in future use a CPU which has the crypto extensions enabled.

Note that the algorithm priority specifiers are unchanged, so if
aes-neon-bs is loaded at the same time as aes-arm64, the former will be
used in preference. However, aes-neon-blk and aes-arm64 have tied priority,
so whichever module was loaded first will be used (assuming aes-neon-bs is
not loaded).

Signed-off-by: Ben Avison <bavison@riscosopen.org>
2024-08-05 11:15:13 +01:00
Naushir Patuck
c5286d35c5 media: bcm2835-unicam: Fix bug in buffer swapping logic
If multiple sets of interrupts occur simultaneously, it may be unsafe
to swap buffers, as the hardware may already be re-using the current
buffers. In such cases, avoid swapping buffers, and wait for the next
opportunity at the Frame End interrupt to signal completion.

Additionally, check the packet compare status when watching for frame
end for buffers swaps, as this could also signify a frame end event.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:13 +01:00
David Plowman
bf4e518438 bcm2835-isp: Allow formats with different colour spaces.
Each supported format now includes a mask showing the allowed colour
spaces, as well as a default colour space for when one was not
specified.

Additionally we translate the colour space to mmal format and pass it
over to the VideoCore.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2024-08-05 11:15:13 +01:00
Phil Elwell
ab9f406bb9 spi: bcm2835: Workaround/fix for zero-length transfers
A relatively recent commit ([1]) contained optimisation for the PIO
SPI FIFO-filling functions. The commit message includes the phrase
"[t]he blind and counted loops are always called with nonzero count".
This is technically true, but it is still possible for count to become
zero before the loop is entered - if tfr->len is zero. Moving the loop
exit condition to the end of the loop saves a few cycles, but results
in a near-infinite loop should the revised count be zero on entry.

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

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

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

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

[1] 26751de25d ("spi: bcm2835: Micro-optimise FIFO loops")
2024-08-05 11:15:13 +01:00
Naushir Patuck
8f9983a2bc staging: vc04_services: ISP: Add colour denoise control
Add colour denoise control to the bcm2835 driver through a new v4l2
control: V4L2_CID_USER_BCM2835_ISP_CDN.

Add the accompanying MMAL configuration structure definitions as well.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:13 +01:00
Naushir Patuck
7595faef3e uapi: bcm2835-isp: Add colour denoise configuration
Add a configuration structure for colour denoise to the bcm2835_isp
driver.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:12 +01:00
Dave Stevenson
935a2a9dfc staging/bcm2835-isp: Log the number of excess supported formats
When logging that the firmware has provided more supported formats
than we had allocated storage for, log the number allocated and
returned.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:12 +01:00
Dave Stevenson
1f44d898c9 staging/bcm2835-isp: Add the unpacked (16bpp) raw formats
Now that the firmware supports the unpacked (16bpp) variants
of the MIPI raw formats, add the mappings.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:12 +01:00
Dave Stevenson
6afeadd545 staging/vc04_services: Add additional unpacked raw formats
Support has been added for the unpacked (16bpp) versions of
the MIPI raw 10, 12, and 14 formats, so add the 4CCs for them.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:12 +01:00
Phil Elwell
d551e53632 PCI: brcmstb: Add BCM2712 support
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>

PCI: brcmstb: Advertise MSI-X support

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

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

PCI: brcmstb: differing register offsets on 2712

pcie-brcmstb: Add 2712 bridge reset support

pcie: 2712 PORT_MASK and rescal support

pcie-brcmstb: don't alter the L1SS debug register

For reasons unknown, this disables the reference clock

pcie-brcmstb: fix BAR2 enable and window decode

Set UBUS ACCESS_EN to let inbound DMA work. Also BCM2712 has grown
an index in the inbound window size decode register.

PCIe: brcmstb: Enable support for 64 MSI-Xs

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

pcie-brcmstb: Suppress read error responses

If the link is down or the EP fails to return a read completion, the
RC's default behaviour is to return an AXI error. This causes fatal
exceptions on A76, so it's better to respond with all 1s instead.

pcie-brcmstb: increase UBUS timeout to cater for link retrain events

pcie-brcmstb: Handle additional inbound regions

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

pcie-brcmstb: Add support for external MSI controller

pcie-brcmstb: add a reasonable default traffic class to priority map

BCM2712 supports multiple traffic classes (TCs) with independent
maximally sized transfer queues for each TC. Traffic classes have no
transaction ordering requirements between them, which facilitates
out-of-order completions and arbitration between posted writes for
data streams that have no dependence on each other.

In addition to the above benefits of splitting endpoint traffic into
individual queues, priorities can be assigned to traffic classes by
a heuristic or deterministic mechanism. The heuristic elevates AXI
QOS priority in accordance with the number of pending transfers in
each TC's queue, but for true priority signalling a forwarding
mechanism using vendor-defined messages is implemented.

Receipt of a 3 DWORD VDM assigns a priority tag to a TC on-the-fly,
and this tag corresponds to a configurable AXI QOS value.

As a simple baseline, assign a linear map of AXI QOS to each tag.

pcie: brcmstb: set up the VDM forwarding interface when setting up QoS

pcie-brcmstb: clean up debug messages

pcie-brcmstb: fix BCM2712A0 PHY PM errata

The power management clock is 54MHz not 50MHz, so adjust the PM clock period
to suit. Powering off the PHY PLL in L1.2 is unsafe, so force it on.

pcie-brcmstb: set CLKREQ functionality according to link partner support

The RC supports either L1 with clock PM or L1 sub-state control, not both
at the same time. Examine the link partner's capabilities to determine
which is the most suitable scheme to use.

pcie: brcmstb: don't reset block bridges in suspend or removal cases

BCM2712 has a single rescal block for all three root complexes, and
holding PCIE1's bridge in reset will hang the chip if a different
RC wants to access any of the rescal registers.

pcie: brcmstb: guard 2712-specific setup with a RC type check

BCM2711 doesn't implement the UBUS control registers.

pcie: brcmstb: On 2712 keeping the PLL powered in L1.x is not required

A separate misconfiguration when enabling SSC (the MDIO registers no
longer do the same thing on BCM2712) had the side-effect of breaking
PLL powerdown and resume sequencing.

Allow entry into a true L1.2 state where analogue is depowered.

pcie: brcmstb: Fix reset warning on probe failure

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

bcm2712: pcie: adjust PHY PLL setup to use a 54MHz input refclk

Use canned MDIO writes from Broadcom that switch the ref_clk output
pair to run from the internal fractional PLL, and set the internal PLL
to expect a 54MHz input reference clock.

Gen3 operation is not guaranteed to be stable in this setup, so default
to gen2.

This only works if the LCPLL is bypassed (requires latest bootloader).

pcie: brcmstb: add missing register writes

drivers: pcie: brcmstb: cater for BCM2712C0 bug dropping QoS on the floor

The AXI QoS value extracted from the request fifo ends up as zero forever.
Disabling this means that "panic" signalling doesn't do anything useful,
but static priorites do work.

Also align the selected TC:QoS map with RP1's expectations of service.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

drivers: pcie: brcmstb: shuffle TC priorities up to 8

Use the range 8-11 which puts the highest below HVS but leaves space
below for other 2712 masters.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

drivers: pcie: brcmstb: optionally enable QoS features by DT for BCM2712

It's a bad idea to universally enable "realtime" priorities for TCs
across all the RC instances on the chip. Endpoints other than RP1 may
make use of these, so you don't want e.g. NVMe descriptor fetches getting
higher priority than your remote display.

Add two optional DT properties controlling the behaviour - FIFO-based
backpressure QoS or "message-based". Message-based signalling is
fundamentally broken due to a chip bug, so it collapses into a set of
static assignments that RP1 needs.

The default if neither property is specified is to assign everything a
QoS of 0.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

drivers: pcie: brcmstb: adjust completion timeouts for bcm2712

Setting the RC config retry timeout makes CRS auto-polling work, but
the UBUS timeout will override the config retry. Both need to be large.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

PCI: brcmstb: Change RCB_{MPS,64B}_MODE bits

Upstream commit [1] unconditionally sets the RCB_MPS and RCB_64B bits
that govern where packets are split. We think this is potentially
harmful, particularly on CM4 and Pi 5 where potentially any PCIe devices
could be attached.

Make RCB_MPS conditional on a DT property and never set RCB_64B.

[1] commit 602fb86094 ("PCI: brcmstb: Set RCB_{MPS,64B}_MODE bits")

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

drivers: pci: brcmstb: optionally extend Tperst_clk time during link-up

The RC has a feature that allows for manual control over the deassertion
of the PERST# output pin, which allows the time between refclk active
and reset deassert at the EP to be increased.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

PCI: brcmstb: fix broken brcm_pcie_mdio_write() polling

MDIO_WR_DONE() tests bit 31, which is always 0 (==done) as
readw_poll_timeout_atomic does a 16-bit read. Replace with the readl
variant.

Fixes: ca5dcc7631 ("PCI: brcmstb: Replace status loops with read_poll_timeout_atomic()")
Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

PCI: brcmstb: resolve conflicts with upstream CLKREQ# selection

This partially reverts commit 177baa7aeb ("Revert "PCI: brcmstb:
Configure HW CLKREQ# mode appropriate for downstream device"")

commit e2596dcf1e ("PCI: brcmstb: Configure HW CLKREQ# mode appropriate
for downstream device") upstream.

The upstream implementation should replace the downstream one.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

PCI: brcmstb: don't set bridge timeouts on BCM2712

BCM2712 has a slightly different architecture to most other STB chips.

Timeout values are internal to the core and are set in PCIE_MISC not
PCIE_RGR1.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

PCI: brcmstb: Enable CRS software visibility after linkup

It appears that bits in the Root Control Register are reset with
perst_n, which means the PCI layer's call to enable CRS prior to
adding/scanning the bus has no effect. Open-code the enable in
brcm_pcie_start_link as a workaround.

Without CRS visibility, configuration reads issued by the CPU don't
retire if the endpoint returns a CRS response - the RC will poll until a
(large) timeout is reached. This means the core can stall for a long
time during boot.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

PCI: brcmstb: Set new flags to avoid QOS "holes" on BCM2712D0

Set some flags present (and recommended) in 2712D0, but missing
(and harmless) in 2712C1. In particular, EN_QOS_UPDATE_TIMING_FIX
must be set to avoid spurious QOS=0 when the queue changes from
empty to non-empty, to make D0 match the existing C1 behaviour.

Not enabling "QOS forwarding", which still seems not to help.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
2024-08-05 11:15:12 +01:00
Naushir Patuck
8acbcba871 media: bcm2835-unicam: Clear clock state when stopping streaming
Commit 65e08c4650 failed to clear the
clock state when the device stopped streaming. Fix this, as it might
again cause the same problems when doing an unprepare.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:12 +01:00
Naushir Patuck
0b500311e0 media: bcm2835-unicam: Return early from stop_streaming() if stopped
clk_disable_unprepare() is called unconditionally in stop_streaming().
This is incorrect in the cases where start_streaming() fails, and
unprepares all clocks as part of the failure cleanup. To avoid this,
ensure that clk_disable_unprepare() is only called in stop_streaming()
if the clocks are in a prepared state.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:12 +01:00
Naushir Patuck
8e12122ae8 media: bcm2835-unicam: Correctly handle error propagation for stream on
On a failure in start_streaming(), the error code would not propagate to
the calling function on all conditions. This would cause the userland
caller to not know of the failure.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:12 +01:00
Dave Stevenson
e4b9721a1f dt-bindings: Add compatible for BCM2711 DSI1
DSI1 on BCM2711 doesn't require the DMA workaround that is used
on BCM2835/6/7, therefore it needs a new compatible string.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:12 +01:00
Dave Stevenson
11dfc00f4f Input: edt-ft5x06: Poll the device if no interrupt is configured.
Not all systems have the interrupt line wired up, so switch to
polling the touchscreen off a timer if no interrupt line is
configured.

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

input: edt-ft5x06: Handle unreliable TOUCH_UP events

The ft5x06 is unreliable in sending touch up events, so some
touch IDs can become stuck in the detected state.

Ensure that IDs that are unreported by the controller are
released.

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

input: edt-ft5x06: Only look at the number of points reported

Register 0x02 in the FT5x06 is TD_STATUS containing the number
of valid touch points being reported.

Iterate over that number of points rather than all that are
supported on the device.

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

input: edt-ft5x06: Only read data for number of points reported

Rather than always reading the maximum number of points supported
by the chip (which may be as high as 10), read the number of
active points first, and read data for just those.
In most cases this will result in less data on the I2C bus,
with only the maximum touch points taking more due to a second
read that has to configure the start address.

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

input: edt-ft5x06: Fix patch reading only the number of points reported

Fix bad conflict resolution from upstream updates. Need to read
from tsdata->tdata_offset bytes, not from tsdata->offset.
Also fix logging of i2c read errors to cover both transactions.

Fixes: 7216fcfe2e ("input: edt-ft5x06: Only read data for number of points reported")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>

Input: edt-ft54x6: Clean up timer and workqueue on remove

If no interrupt is defined then a timer and workqueue are used
to poll the controller.
On remove these were not being cleaned up correctly.

Fixes: ca61fdaba7 "Input: edt-ft5x06: Poll the device if no interrupt is
configured."

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

input: touchscreen: edt-ft5x06: Suppress bogus data on startup

When polled without the use of IRQ, FT5x06 registers may return
undefined initial data, causing unwanted touches or event spamming.
A simple way to filter this out is to suppress touches until the
TD_STATUS register changes for the first time.

Increase the delay before first polling to 300ms, to avoid
transient I2C read flakiness that seems to occur after reset.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>

input: edt-ft5x06: Include I2C details in names for the devices

libinput uses the input device name alone. If you have two
identical input devices, then there is no way to differentiate
between them, and in the case of touchscreens that means no
way to associate them with the appropriate display device.

Add the I2C bus and address to the start of the input device
name so that the name is always unique within the system.

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

input: edt-ft5x06: Correct prefix length in snprintf

snprintf takes the length of the array that we can print into,
and has to fit the NULL terminator in there too.
Printing the prefix is generally "12-3456 " which is 8 desired
characters (the length of EDT_NAME_PREFIX_LEN) and the NULL.
The space is therefore being truncated to fit the NULL in.

Increase the length snprintf is allowed to use.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:12 +01:00
Tim Gover
d1cbca0673 firmware: raspberrypi: Add support for tryonce reboot flag
Define a new mailbox (SET_REBOOT_FLAGS) which may be used to
pass optional flags to the Raspberry Pi firmware that changes
the behaviour of the bootloader and firmware during a reboot.

Currently this just defines the 'tryboot' flag which causes
the firmware to load tryboot.txt instead config.txt. This
alternate configuration file can be used to specify the
path of an alternate firmware and kernels allowing a fallback
mechanism to be implemented for OS upgrades.
2024-08-05 11:15:12 +01:00
Tim Gover
7d47c70fa6 watchdog: bcm2835: Ignore params after the partition number
Use sscanf to extract the partition number and ignore extra parameters
which are only relevant to other reboot notifiers.
2024-08-05 11:15:12 +01:00
Phil Elwell
371b73bdde gpio: Add gpio-fsm driver
The gpio-fsm driver implements simple state machines that allow GPIOs
to be controlled in response to inputs from other GPIOs - real and
soft/virtual - and time delays. It can:
+ create dummy GPIOs for drivers that demand them,
+ drive multiple GPIOs from a single input, with optional delays,
+ add a debounce circuit to an input,
+ drive pattern sequences onto LEDs
etc.

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

gpio-fsm: Fix a build warning

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

gpio-fsm: Rename 'num-soft-gpios' to avoid warning

As of 5.10, the Device Tree parser warns about properties that look
like references to "suppliers" of various services. "num-soft-gpios"
resembles a declaration of a GPIO called "num-soft", causing the value
to be interpreted as a phandle, the owner of which is checked for a
"#gpio-cells" property.

To avoid this warning, rename the gpio-fsm property to "num-swgpios".

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

gpio-fsm: Show state info in /sys/class/gpio-fsm

Add gpio-fsm sysfs entries under /sys/class/gpio-fsm. For each state
machine show the current state, which state (if any) will be entered
after a delay, and the current value of that delay.

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

gpio-fsm: Fix shutdown timeout handling

The driver is intended to jump directly to a shutdown state in the
event of a timeout during shutdown, but the sense of the test was
inverted.

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

gpio-fsm: Clamp the delay time to zero

The sysfs delay_ms value is calculated live, and it is possible for
the time left to appear to be negative briefly if the timer handling
hasn't completed. Ensure the displayed value never goes below zero,
for the sake of appearances.

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

gpio-fsm: Sort functions into a more logical order

Move some functions into a more logical ordering. This change causes
no functional change and is essentially cosmetic.

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

gpio_fsm: Rework the atomic-vs-non-atomic split

Partition the code to separate atomic and non-atomic methods so that
none of them have to handle both cases. The result avoids using deferred
work unless necessary, and should be easier to understand.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:12 +01:00
Naushir Patuck
1a5fc7546c staging: vc04_services: ISP: Add a more complex ISP processing component
Driver for the BCM2835 ISP hardware block.  This driver uses the MMAL
component to program the ISP hardware through the VC firmware.

The ISP component can produce two video stream outputs, and Bayer
image statistics. This can't be encompassed in a simple V4L2
M2M device, so create a new device that registers 4 video nodes.

This patch squashes all the development patches from the earlier
rpi-5.4.y branch into one

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:12 +01:00
Dave Stevenson
b2860e81db uapi: bcm2835-isp: Add bcm2835-isp uapi header file
This file defines the userland interface to the bcm2835-isp driver
that will follow in a separate commit.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:12 +01:00
Dave Stevenson
f5585c45a8 staging: vc04_services: Add a V4L2 M2M codec driver
This adds a V4L2 memory to memory device that wraps the MMAL
video decode and video_encode components for H264 and MJPEG encode
and decode, MPEG4, H263, and VP8 decode (and MPEG2 decode
if the appropriate licence has been purchased).

This patch squashes all the work done in developing the driver
on the Raspberry Pi rpi-5.4.y kernel branch.
Thanks to Kieran Bingham, Aman Gupta, Chen-Yu Tsai, and
Marek Behún for their contributions. Please refer to the
rpi-5.4.y branch for the full history.

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

staging/bcm2835-codec: Ensure OUTPUT timestamps are always forwarded

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

Disable the firmware option.

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

staging/vc04_services/codec: Add support for CID MPEG_HEADER_MODE

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

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

staging/vc04_services/codec: Clear last buf dequeued flag on START

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

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

staging/vc04-services/codec: Fix logical precedence issue

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

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

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

vc04_services: bcm2835-codec: Switch to s32fract

staging/bcm2835-codec: Add the unpacked (16bpp) raw formats

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

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

staging/bcm2835-codec: Log the number of excess supported formats

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

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

staging/bcm2835-codec: Add support for pixel aspect ratio

If the format is detected by the driver and a V4L2_EVENT_SOURCE_CHANGE
event is generated, then pass on the pixel aspect ratio as well.

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

staging/bcm2835-codec: Implement additional g_selection calls for decode

v4l_cropcap calls our vidioc_g_pixelaspect function to get the pixel
aspect ratio, but also calls g_selection for V4L2_SEL_TGT_CROP_BOUNDS
and V4L2_SEL_TGT_CROP_DEFAULT. Whilst it allows for vidioc_g_pixelaspect
not to be implemented, it doesn't allow for either of the other two.

Add in support for the additional selection targets.

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

staging/bcm2835-codec: Add VC-1 support.

Providing the relevant licence has been purchased, then Pi0-3
can decode VC-1.

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

staging/bcm2835-codec: Fix support for levels 4.1 and 4.2

The driver said it supported H264 levels 4.1 and 4.2, but
was missing the V4L2 to MMAL mappings.

Add in those mappings.

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

staging/bcm2835-codec: Set the colourspace appropriately for RGB formats

Video decode supports YUV and RGB formats. YUV needs to report SMPTE170M
or REC709 appropriately, whilst RGB should report SRGB.

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

staging/bcm2835-codec: Pass corrupt frame flag.

MMAL has the flag MMAL_BUFFER_HEADER_FLAG_CORRUPTED but that
wasn't being passed through, so add it.

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

staging/bcm2835-codec: Do not update crop from S_FMT after res change

During decode, setting the CAPTURE queue format was setting the crop
rectangle to the requested height before aligning up the format to
cater for simple clients that weren't expecting to deal with cropping
and the SELECTION API.
This caused problems on some resolution change events if the client
didn't also then use the selection API.

Disable the crop update after a resolution change.

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

bcm2835: Allow compressed frames to set sizeimage (#4386)

Allow the user to set sizeimage in TRY_FMT and S_FMT if the format
flags have V4L2_FMT_FLAG_COMPRESSED set

Signed-off-by: John Cox <jc@kynesim.co.uk>

staging/bcm2835-codec: Change the default codec res to 32x32

In order to effectively guarantee that a V4L2_EVENT_SOURCE_CHANGE
event occurs, adopt a default resolution of 32x32 so that it
is incredibly unlikely to be decoding a stream of that resolution
and therefore failing to note a "change" requiring the event.

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

staging/bcm2835-codec: Add support for decoding interlaced streams

The video decoder can support decoding interlaced streams, so add
the required plumbing to signal this correctly.

The encoder and ISP do NOT support interlaced data, so trying to
configure an interlaced format on those nodes will be rejected.

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

staging/bcm2835-codec: Correct ENUM_FRAMESIZES stepsize to 2

Being YUV420 formats, the step size is always 2 to avoid part
chroma subsampling.

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

staging/bcm2835-codec: Return buffers to QUEUED not ERROR state

Should start_streaming fail, or buffers be queued during
stop_streaming, they should be returned to the core as QUEUED
and not (as currently) as ERROR.

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

staging/bcm2835_codec: Log MMAL flags in hex

The flags is a bitmask, so it's far easier to interpret as hex
data instead of decimal.

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

staging: bcm2835-codec: Allow custom specified strides/bytesperline.

If the client provides a bytesperline value in try_fmt/s_fmt then
validate it and correct if necessary.

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

staging/bcm2835_codec: Add support for image_fx to deinterlace

Adds another /dev/video node wrapping image_fx doing deinterlace.

Co-developed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Dom Cobley <popcornmix@gmail.com>

staging/bcm2835-v4l2_codec: Fix for encode selection API

Matches correct behaviour from DECODE and DEINTERLACE

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

staging: bcm2835-codec: Allow decode res changed before STREAMON(CAPTURE)

The V4L2 stateful video decoder API requires that you can STREAMON
on only the OUTPUT queue, feed in buffers, and wait for the
SOURCE_CHANGE event.
This requires that we enable the MMAL output port at the same time
as the input port, because the output port is the one that creates
the SOURCE_CHANGED event.

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

staging/bcm2835-codec: Do not send buffers to the VPU unless streaming

With video decode we now enable both input and output ports on
the component. This means that buffers will get passed to the VPU
earlier than desired if they are queued befoer STREAMON.

Check that the queue is streaming before sending buffers to the VPU.

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

staging: bcm2835-codec: Format changed should trigger drain

When a format changed event occurs, the spec says that it
triggers an implicit drain, and that needs to be signalled
via -EPIPE.

For BCM2835, the format changed event happens at the point
the format change occurs, so no further buffers exist from
before the resolution changed point. We therefore signal the
last buffer immediately.
We don't have a V4L2 available to us at this point, so set
the videobuf2 queue last_buffer_dequeued flag directly.

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

staging: bcm2835-codec: Signal the firmware to stop on all changes

The firmware defaults to not stopping video decode if only the
pixel aspect ratio or colourspace change. V4L2 requires us
to stop decoding on any change, therefore tell the firmware
of the desire for this alternate behaviour.

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

staging: bcm2835-codec: Queue flushed buffers instead of completing

When a buffer is returned on a port that is disabled, return it
to the videobuf2 QUEUED state instead of DONE which returns it
to the client.

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

staging: bcm2835_codec: Correct flushing code for refcounting

Completions don't reference count, so setting the completion
on the first buffer returned and then not reinitialising it
means that the flush function doesn't behave as intended.

Signal the completion when the last buffer is returned.

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

staging: bcm2835-codec: Ensure all ctrls are set on streamon

Currently the code was only setting some controls from
bcm2835_codec_set_ctrls, but it's simpler to use
v4l2_ctrl_handler_setup to avoid forgetting to adding new
controls to the list.

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

staging: bcm2835-codec: Add support for H&V Flips to ISP

The ISP can do H & V flips whilst resizing or converting
the image, so expose that via V4L2_CID_[H|V]FLIP.

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

bcm2835-v4l2-codec: Remove advertised support of VP8

The support for this format by firmware is very limited
and won't be faster than the arm.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

Pass V4L2_CID_MPEG_VIDEO_H264_MIN_QP/MAX_QP to bcm2835-v4l2-codec

Following raspberrypi/linux#4704. This is necessary to set up
quantization for variable bitrate to avoid video flickering.

staging/bcm2835-codec: bytesperline for YUV420/YVU420 needs to be 64

Matching https://github.com/raspberrypi/linux/pull/4419, the ISP
block (which is also used on the input of the encoder, and output
of the decoder) needs the base address of all planes to be aligned
to multiples of 32. This includes the chroma planes of YUV420 and
YVU420.
If the height is only a multiple of 2 (not 4), then you get an odd
number of lines in the second plane, which means the 3rd plane
starts at a multiple of bytesperline/2.

Set the minimum bytesperline alignment to 64 for those formats
so that the plane alignment is always right.

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

staging/bcm2835-codec: Allow a different stride alignment per role

Deinterlace and decode aren't affected in the same way as encode
and ISP by the alignment requirement on 3 plane YUV420.
Decode would be affected, but it always aligns the height up to
a macroblock, and uses the selection API to reflect that.

Add in the facility to set the bytesperline alignment per role.

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

staging: vc04_services: codec: Add support for V4L2_PIX_FMT_RGBA32 format

We already support V4L2_PIX_FMT_BGR32 which is the same thing with red
and blue swapped, so it makes sense to include this variant as well.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>

bcm2835-codec: Return empty buffers to the VPU instead of queueing to vbuf2

The encoder can skip frames totally should rate control overshoot
the target bitrate too far. In this situation it generates an
output buffer of length 0.
V4L2 treats a buffer of length 0 as an end of stream flag, which is
not appropriate in this case, therefore we can not return that buffer
to the client.

The driver was returning the buffer to videobuf2 in the QUEUED state,
however that buffer was then not dequeued again, so the number of
buffers was reduced each time this happened. In the pathological
case of using GStreamer's videotestsrc in mode 1 for noise, this happens
sufficiently frequently to totally stall the pipeline.

If the port is still enabled then return the buffer straight back to
the VPU rather than to videobuf2.

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

vc04_services: bcm2835-codec: Add support for V4L2_PIX_FMT_NV12_COL128

V4L2_PIX_FMT_NV12_COL128 is supported by the ISP and the input of
video_encode, output of video_decode, and both input and output
of the ISP.

Add in the plumbing to support the format on those ports.

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

vc04_services: bcm2835-codec: Set crop_height for compressed formats

In particular for the encoder where the CAPTURE format dictates
the parameters given to the codec we need to be able to set the
value passed as the crop_height for the compressed format.
There's no crop available for cropped modes, so always set
crop_height to the requested height.

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

vc04_services: bcm2835-codec: Set port format from s_selection

s_selection allows the crop region of an uncompressed pixel
format to be specified, but it wasn't passing the setting on to
the firmware. Depending on call order this would potentially
mean that the crop wasn't actioned.

Set the port format on s_selection if we have a component created.

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

bcm2835-codec: /dev/video31 as interface to image_encode JPEG encoder

Signed-off-by: Maxim Devaev <mdevaev@gmail.com>

bcm2835-v4l2-codec: support H.264 5.0 and 5.1 levels

vc04_services: bcm2835-codec:  Remove redundant role check

vidioc_try_encoder_cmd checks the role, but the ioctl is disabled
for any roles in which it is invalid.

Remove the redundant check.

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

vc04_services: bcm2835-codec: Allow encoder_cmd on ISP and deinterlace

ISP and deinterlace also need a mechanism for passing effectively
an EOS through the pipeline to signal when all buffers have been
processed.

VIDIOC_ENCODER_CMD does exactly this for encoders, so reuse the same
function for ISP and deinterlace.
(VIDIOC_DECODER_CMD is slightly different in that it also passes
details of when and how to stop, so is not as relevant).

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

vc04_services: bcm2835_codec: Allow larger images through the ISP

Whilst the codecs are restricted to 1920x1080 / 1080x1920, the ISP
isn't, but the limits advertised via V4L2 was 1920x1920 for all
roles.

Increase the limit to 16k x 16k for the ISP.

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

media: bcm2835-v4l2-codec: Enable selection ioctl for ISP

The ISP cases do nothing. Remove the break that separates them from the
deinterlace case so they now do the same as deinterlace. This enables
simple width & height setting, but does not enable setting left and
top coordinates.

Signed-off-by: John Cox <jc@kynesim.co.uk>

media: bcm2835-v4l2-codec: Add profile & level ctrls to decode

In order to support discovery of what profile & levels are supported by
stateful decoders implement the profile and level controls where they
are defined by V4L2.

Signed-off-by: John Cox <jc@kynesim.co.uk>

vc04_services: bcm2835_codec: Ignore READ_ONLY ctrls in s_ctrl

In adding the MPEG2/MPEG4/H264 level and profile controls to
the decoder, they weren't declared as read-only, nor handlers
added to bcm2835_codec_s_ctrl. That resulted in an error message
"Invalid control" being logged every time v4l2_ctrl_handler_setup
was called from bcm2835_codec_create_component.

Define those controls as read only, and exit early from s_ctrl
on read only controls.

Fixes: "media: bcm2835-v4l2-codec: Add profile & level ctrls to decode"
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>

vc04_services: bcm2835_codec: Set MPEG2_LEVEL control to READ_ONLY

V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL  was missed from
"vc04_services: bcm2835_codec: Ignore READ_ONLY ctrls in s_ctrl"

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

staging: bcm2835-codec: Add V4L2_CID_MPEG_VIDEO_B_FRAMES control

FFmpeg insists on trying to set V4L2_CID_MPEG_VIDEO_B_FRAMES to
0, and generates an error should it fail.
As our encoder doesn't support B frames, add a stub handler for
it to silence FFmpeg.

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

staging: bcm2835-codec: Add support for V4L2_CID_MPEG_VIDEO_GOP_SIZE

For H264, V4L2_CID_MPEG_VIDEO_H264_I_PERIOD is meant to be the intra
I-frame period, whilst V4L2_CID_MPEG_VIDEO_GOP_SIZE is the intra IDR
frame period.
The firmware encoder doesn't produce I-frames that aren't IDR as well,
therefore V4L2_CID_MPEG_VIDEO_GOP_SIZE is technically the correct
control, however users may have adopted V4L2_CID_MPEG_VIDEO_H264_I_PERIOD.

Add support for V4L2_CID_MPEG_VIDEO_GOP_SIZE controlling the encoder,
and have VIDIOC_S_CTRL for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD update
the value for V4L2_CID_MPEG_VIDEO_GOP_SIZE (the reverse is not
implemented).

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

staging: bcm2835-codec: Add missing alignment for V4L2_PIX_FMT_RGBA32

The patch adding image encode (JPEG) to the driver missed adding
the alignment constraint for V4L2_PIX_FMT_RGBA32, which meant
it ended up giving a stride and size of 0.

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

staging: bcm2835-codec: Downgrade the level for a debug message

The debug message from bcm2835_codec_buf_prepare when the buffer
size is incorrect can be a little spammy if the application isn't
careful on how it drives it, therefore drop the priority of the
message.

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

vc04_services: bcm2835-codec: Correct alignment requirements for YUYV

The firmware wants the YUYV format stride alignment to be to a multiple
of 32pixels / 64 bytes. The kernel driver was configuring it to a multiple
of 16 pixels / 32 bytes, which then failed when it tried starting to
stream.

Correct the alignment requirements.

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

staging: bcm2835-codec: Fix up for 6.8 - use ignore_cap_streaming

Drops downstream patch to v4l2_mem2mem, and uses the new mainline
flag to achieve the same functionality

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

staging: bcm2835-codec: 32bpp RGB formats need a 64byte alignment

The firmware needs 16 pixel alignment on RGBx 32bpp formats, which
would be 64 byte. The driver was only setting 32byte alignment.

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

staging: bcm2835_codec: Pass framerate to the component if set late

For video encoding, if the framerate was set after the component
was created, then it wasn't set correctly on the port, and an
old value was encoded in the bitstream.

Update the port status when the framerate is set.

https://github.com/raspberrypi/rpicam-apps/issues/664

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:11 +01:00
Dave Stevenson
985f849eb2 staging: mmal-vchiq: Use vc-sm-cma to support zero copy
With the vc-sm-cma driver we can support zero copy of buffers between
the kernel and VPU. Add this support to mmal-vchiq.

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

vc-sm-cma: fixed kbuild problem

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

Tested-by: make ARCH=arm64 bcm2711_defconfig
Test platform: fedora 33
Branch: rpi-5.10.y
2024-08-05 11:15:11 +01:00
Dave Stevenson
4e511438ba staging: mmal-vchiq: Add monochrome image formats
Adds support for monochrome image formats in the various
MIPI packings.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:11 +01:00
Dave Stevenson
8369cc056c staging: vchiq-mmal: Add support for 14bit Bayer
Add in the missing defines.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:11 +01:00
Dave Stevenson
bdf9961dd9 staging: vc04_services: Add new vc-sm-cma driver
Add Broadcom VideoCore Shared Memory support.

This new driver allows contiguous memory blocks to be imported
into the VideoCore VPU memory map, and manages the lifetime of
those objects, only releasing the source dmabuf once the VPU has
confirmed it has finished with it.

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

staging: vcsm-cma: Fix memory leak from not detaching dmabuf

When importing there was a missing call to detach the buffer,
so each import leaked the sg table entry.

Actually the release process for both locally allocated and
imported buffers is identical, so fix them to both use the same
function.

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

staging/vc-sm-cma: Avoid log spamming on Pi0/1 over cache alias.

Pi 0/1 use the 0x80000000 cache alias as the ARM also sees the world
through the VPU L2 cache.
vc-sm-cma was trying to ensure it was in an uncached alias (0xc), and
complaining on every allocation if it weren't. Reduce this logging.

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

vc-sm-cma: Restore correct cache maintainance operations

We have been using the more expensive flush operations rather than
invalidate and clean since kernel rpi-5.9.y

These are exposed with:
52f1453513 Re-expose some dmi APIs for use in VCSM

But I believe that commit was dropped when (non-cma) vc-sm was dropped,
and didn't get updated when the commit was restored

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

staging: vc04_services: Fix clang14 warning

Insert a break to fix a fallthrough warning from clang14. Since the
fallthrough was to another break, this is a cosmetic change.

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

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

vc04_services/vc-sm-cma: Handle upstream require vchiq_instance to be passed around

vc04_services/vc-sm-cma: Switch one-bit bitfields to bool

Clang 16 warns:

../drivers/staging/vc04_services/vc-sm-cma/vc_sm.c:816:19: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
        buffer->imported = 1;
                         ^ ~
../drivers/staging/vc04_services/vc-sm-cma/vc_sm.c:822:17: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
        buffer->in_use = 1;
                       ^ ~
2 warnings generated.

Signed-off-by: Alexander Winkowski <dereference23@outlook.com>

vc04_services: vcsm-cma: Detach from the correct dmabuf

Commit d3292daee3 ("dma-buf: Make locking consistent in dma_buf_detach()")
added checking that the same dmabuf for which dma_buf_attach
was called is passed into dma_buf_detach, which flagged up
that vcsm-cma was passing in the wrong dmabuf.

Correct this so that we don't get the WARN on every dma_buf
release.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:11 +01:00
Dave Stevenson
30857d7f9d staging: bcm2835-camera: Replace deprecated V4L2_PIX_FMT_BGR32
V4L2_PIX_FMT_BGR32 is deprecated as it is ambiguous over where
the alpha byte is. Cheese/GStreamer appear to get it wrong for
one, and qv4l2 gets red and blue swapped.

Swap to the newer V4L2_PIX_FMT_BGRX32 format.

https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=267736&p=1738912

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:11 +01:00
Phil Elwell
18f28a3de2 brcmfmac: Increase power saving delay to 2s
Increase the delay before entering the lower power state to 2 seconds
(the maximum allowed) in order to reduce the packet latencies,
particularly for inbound packets.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:11 +01:00
Phil Elwell
cf61cf2a95 staging/fbtft: Add support for display variants
Display variants are intended as a replacement for the now-deleted
fbtft_device drivers. Drivers can register additional compatible
strings with a custom callback that can make the required changes
to the fbtft_display structure.

Start the ball rolling by adding adafruit18, adafruit18_green and
sainsmart18 displays.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:11 +01:00
David Plowman
a05b78f7e5 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>
2024-08-05 11:15:11 +01:00
Dave Stevenson
c940a6c40a 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>
2024-08-05 11:15:11 +01:00
Dave Stevenson
f59474e896 media: bcm2835-unicam: Fixup review comments from Hans.
Updates the driver based on the upstream review comments from
Hans Verkuil at https://patchwork.linuxtv.org/patch/63531/

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:11 +01:00
Jacko Dirks
0caf893c45 media: bcm2835: unicam: Fix uninitialized warning
Signed-off-by: Jacko Dirks <jdirks.linuxdev@gmail.com>
2024-08-05 11:15:11 +01:00
Dave Stevenson
6316f8578a 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>
2024-08-05 11:15:11 +01:00
Dave Stevenson
1b3989ac1c media: bcm2835-unicam: Drop WARN on uing direct cache alias
Pi 0&1 pass all ARM accesses through the VPU L2 cache, therefore
the dma-ranges property sets the cache alias bits to other
than the direct alias, hence this WARN was firing.

It was overprotective coding, so assume that everything is OK
with the dma-ranges, and remove the WARN.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:11 +01:00
Phil Elwell
5be6ec7bad leds: Add the actpwr trigger
The actpwr trigger is a meta trigger that cycles between an inverted
mmc0 and default-on. It is written in a way that could fairly easily
be generalised to support alternative sets of source triggers.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:11 +01:00
Naushir Patuck
c9ef9f815d dt-bindings: bcm2835-unicam: Update documentation with new clock params
Update the documentation to reflect the new "VPU" clock needed
by the bcm2835-unicam driver.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:11 +01:00
Naushir Patuck
7f3adcc7eb media: bcm2835: unicam: Set VPU min clock freq to 250Mhz.
When streaming with Unicam, the VPU must have a clock frequency of at
least 250Mhz.  Otherwise, the input fifos could overrun, causing
image corruption.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:11 +01:00
Dave Stevenson
76906829c1 media: bcm2835-unicam: Ensure type is VIDEO_CAPTURE in [g|s]_selection
[g|s]_selection pass in a buffer type that needs to be validated
before passing on to the sensor subdev.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:10 +01:00
Dave Stevenson
248f7ba93a media: bcm2835-unicam: Reinstate V4L2_CAP_READWRITE in the caps
v4l2-compliance throws a failure if the device doesn't advertise
V4L2_CAP_READWRITE but allows read or write operations.
We do support read, so reinstate the flag.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:10 +01:00
Phil Elwell
3ae20ab360 serial: 8250: bcm2835aux - defer if clock is zero
See: https://github.com/raspberrypi/linux/issues/3700

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:10 +01:00
Dave Stevenson
f5ccedf2cb media: bcm2835-unicam: Avoid gcc warning over {0} on endpoint
Older gcc versions object to = { 0 } initialisation if the first
elemtn in the structure is a substructure.

Use = { } to avoid this compiler warning.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:10 +01:00
Dave Stevenson
2d952e4808 media: bcm2835-unicam: Add support for get_mbus_config to set num lanes
Use the get_mbus_config pad subdev call to allow a source to use
fewer than the number of CSI2 lanes defined in device tree.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:10 +01:00
Naushir Patuck
2691843eab 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>
2024-08-05 11:15:10 +01:00
Phil Elwell
6f235981a9 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>
2024-08-05 11:15:10 +01:00
Phil Elwell
8008b7174e 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>
2024-08-05 11:15:10 +01:00
Dave Stevenson
b3f570bbe3 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>
2024-08-05 11:15:10 +01:00
Dave Stevenson
b5bd00d751 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>
2024-08-05 11:15:10 +01:00
Naushir Patuck
4894efe93d 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>
2024-08-05 11:15:10 +01:00
Naushir Patuck
6a351771e2 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>
2024-08-05 11:15:10 +01:00
Naushir Patuck
40dedad755 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>
2024-08-05 11:15:10 +01:00
Naushir Patuck
a86b2f49c9 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>
2024-08-05 11:15:10 +01:00
Phil Elwell
679a18ad63 spi: Force CS_HIGH if GPIO descriptors are used
Commit f3186dd876 ("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: 83b2a8fe43 ("spi: spidev: Fix CS polarity if GPIO descriptors are used")

Fixes: f3186dd876 ("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>
2024-08-05 11:15:10 +01:00
John Cox
bd61d9ed62 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: 25486f49bf
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>
2024-08-05 11:15:09 +01:00
Ezequiel Garcia
b7d2c94aa0 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>
2024-08-05 11:15:09 +01:00
Dave Stevenson
fce6805002 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>
2024-08-05 11:15:09 +01:00
Dave Stevenson
add48d5f47 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>
2024-08-05 11:15:09 +01:00
popcornmix
d3d3075cd5 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>
2024-08-05 11:15:09 +01:00
Jim Quinlan
3202eb9531 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>
2024-08-05 11:15:09 +01:00
Phil Elwell
b3e7481eb4 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: d1651b03c2 ("of: overlay: add overlay symbols to live device tree")

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:09 +01:00
Phil Elwell
2dbba4022f 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: 85ae9e512f ("pinctrl: bcm2835: switch to GPIOLIB_IRQCHIP")
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2024-08-05 11:15:09 +01:00
Naushir Patuck
f20b4755c7 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>
2024-08-05 11:15:09 +01:00
detule
55f7c1ce2e staging: vchiq_arm: Usa a DMA pool for small bulks
During a bulk transfer we request a DMA allocation to hold the
scatter-gather list.  Most of the time, this allocation is small
(<< PAGE_SIZE), however it can be requested at a high enough frequency
to cause fragmentation and/or stress the CMA allocator (think time
spent in compaction here, or during allocations elsewhere).

Implement a pool to serve up small DMA allocations, falling back
to a coherent allocation if the request is greater than
VCHIQ_DMA_POOL_SIZE.

Signed-off-by: Oliver Gjoneski <ogjoneski@gmail.com>
2024-08-05 11:15:09 +01:00
Dave Stevenson
b7adbc88c9 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>

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>

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>

staging: vchiq_arm: Add 36-bit address support

Conditional on a new compatible string, change the pagelist encoding
such that the top 24 bits are the pfn, leaving 8 bits for run length
(-1), giving a 36-bit address range.

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.

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

staging: vchiq_arm: children inherit DMA config

Although it is no longer necessary for vchiq's children to have a
different DMA configuration to the parent, they do still need to
explicitly to have their DMA configuration set - to be that of the
parent.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:09 +01:00
Phil Elwell
1272c6c90c net: phy: BCM54210PE does not support PTP
BCM54213PE is an Ethernet PHY that supports PTP hardware timestamping.
BCM54210PW ia another Ethernet PHY, but one without PTP support.
Unfortunately the two PHYs return the same ID when queried, so some
extra information is required to determine whether the PHY is PTP-
capable.

There are two Raspberry Pi products that use these PHYs - Pi 4B and
CM4 - and fortunately they use different PHY addresses, so use that as
a differentiator. Choose to treat a PHY with the same ID but another
address as a BCM54210PE, which seems more common.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:09 +01:00
Jonathan Bell
ff5ce3cf4c net: phy: broadcom: optionally enable link-down powersave based on DT
It's really a function of the board whether or not to use this feature
as it may require MAC compatibility as well as interop testing.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:09 +01:00
Phil Elwell
34a775eb85 phy: broadcom: Add bcm54213pe configuration
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:09 +01:00
Jonathan Bell
2ef5274574 phy: broadcom: split out the BCM54213PE from the BCM54210E IDs
The last nibble is a revision ID, and the 54213pe is a later rev
than the 54210e. Running the 54210e setup code on a 54213pe results
in a broken RGMII interface.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
2024-08-05 11:15:09 +01:00
James Hughes
039ee46c37 net: phy: broadcom: 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.

net: phy: broadcom: Make LEDs 3+4 shadow LEDs 1+2

CM4 uses BCM54210PE, which supports 2 additional LEDs, choosing LED3
for the amber LED because it shows activity by default (LED4 is not
connected). However, this makes it uncontrollable by the eth_led<n>
dtparams which target LEDs 1+2.

Solve the problem by making LEDs 3+4 mirror LEDs 1+2 (which is much
simpler than adding baseboard-specific overrides, but comes with a
risk of making one of the LEDs redundant).

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:09 +01:00
Dave Stevenson
b589b0b295 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>
2024-08-05 11:15:08 +01:00
Dave Stevenson
eb9fc255f3 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>
2024-08-05 11:15:08 +01:00
Phil Elwell
aceaed23da 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>
2024-08-05 11:15:08 +01:00
Markus Proeller
5f1f067340 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>

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>

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>

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>

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>

media: i2c: add ov9281 driver.

Change-Id: I7b77250bbc56d2f861450cf77271ad15f9b88ab1
Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>

media: i2c: ov9281: fix mclk issue when probe multiple camera.

Takes the ov9281 part only from the Rockchip's patch.

Change-Id: I30e833baf2c1bb07d6d87ddb3b00759ab45a90e4
Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>

media: i2c: ov9281: add enum_frame_interval function for iq tool 2.2 and hal3

Adds the ov9281 parts of the Rockchip patch adding enum_frame_interval to
a large number of drivers.

Change-Id: I03344cd6cf278dd7c18fce8e97479089ef185a5c
Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>

media: i2c: ov9281: Fixup for recent kernel releases, and remove custom code

The Rockchip driver was based on a 4.4 kernel, and had several custom
Rockchip parts.

Update to 5.4 kernel APIs, with the relevant controls required by
libcamera, and remove custom Rockchip parts.

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

media: i2c: ov9281: Read chip ID via 2 reads

Vision Components have made an OV9281 module which blocks reading
back the majority of registers to comply with NDAs, and in doing
so doesn't allow auto-increment register reading as used when
reading the chip ID.

Use two reads and manually combine the results.

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

media: i2c: ov9281: Add support for 8 bit readout

The sensor supports 8 bit mode as well as 10bit, so add the
relevant code to allow selection of this.

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

media: ov9281: Add 1280x720 and 640x480 modes

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

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

Fixed picture line bug in all ov9281 modes

Signed-off-by: Mathias Anhalt <mathiasanhalt@web.de>

Added hflip and vflip controls to ov9281

Signed-off-by: Mathias Anhalt <mathiasanhalt@web.de>

media: i2c: ov9281: Remove override of subdev name

From the original Rockchip driver, the subdev was renamed
from the default to being "mov9281 <dev_name>" whereas the
default would have been "ov9281 <dev_name>".

Remove the override to drop back to the default rather than
a vendor custom string.

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

media: v4l2-subdev: add subdev-wide state struct

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

media: i2c: ov9281: Add fwnode properties controls

Add call to v4l2_ctrl_new_fwnode_properties to read and
create the fwnode based controls.

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

media: i2c: ov9281: Sensor should report RAW color space

Tested on Raspberry Pi running libcamera.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>

Partial revert "media: i2c: add ov9281 driver."

This partially reverts commit 84e98e3a4f.

The commit had merged some changes to other drivers with adding the ov9281
driver. Only the ov9281 parts have been reverted.

media: i2c: Update irs1125 Kconfig entry

Bring the IRS1125 Kconfig declaration in line with upstream entries.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:08 +01:00
Markus Proeller
670afc8b2e 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>
2024-08-05 11:15:08 +01:00
John Cox
72acdf23cd 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>
2024-08-05 11:15:08 +01:00
Dave Stevenson
8aaf232d91 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>
2024-08-05 11:15:08 +01:00
Dave Stevenson
864d1bc67b 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>
2024-08-05 11:15:08 +01:00
David Plowman
450dfa882d 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>
2024-08-05 11:15:08 +01:00
Naushir Patuck
c55f8deb23 media: i2c: imx296: Adjust cropping limits
Through emperical testing, the sensor can crop upto a 96x88 window to
produce a valid Bayer frame. Adjust the ROIWH1_MIN ROIWV1_MIN
appropriately for this limit.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:08 +01:00
Naushir Patuck
6685af376d media: i2c: imx296: Add horizontal/vertical flip support
Add support for setting horizontal and/or vertial flips in the IMX296
sensor through the V4L2_CID_HFLIP and V4L2_CID_VFLIP controls.

Add a new helper function to return the media bus format code that
depends on the sensor flips.

Grab the V4L2_CID_HFLIP and V4L2_CID_VFLIP controls on stream on, and
release on stream off to ensure flips cannot be changed while the sensor
is streaming.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:08 +01:00
Naushir Patuck
966505a6ec media: i2c: imx296: Set a 1 frame gain delay
Set the gain delay to 1 frame in the sensor. This avoids any race
condition or ambiguity over when the setting is applied through
userland.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:08 +01:00
Naushir Patuck
57220c4733 media: i2c: imx296: Add helper for hblank control
Add a helper function to setup the horizontal blanking control. Update
the control limits on set_format as the horizontal blanking time must
remain constant regardless of sensor output width.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:08 +01:00
Naushir Patuck
4ec7b464d1 media: i2c: imx296: Get sensor crop working
Add a missing register write (MIPIC_AREA3W) when setting up a crop
window in the sensor to get this functionality working.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:08 +01:00
Nick Hollinghurst
358b5f723e media: i2c: imx296: Updated register setting to fix Fast Trigger
In Fast Trigger mode (external shutter control), FE packet was
not sent at end of frame. Sony recommend this change to fix it.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
2024-08-05 11:15:08 +01:00
Nick Hollinghurst
8a9ae6b5ba drivers: media: i2c: imx296,imx477: Configure tigger_mode every time
Don't assume the camera has been reset each time we start streaming,
but always write registers relating to trigger_mode, even in mode 0.

IMX477: Stop driving XVS on stop streaming, to avoid spurious pulses.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
2024-08-05 11:15:07 +01:00
Ben Benson
369c964339 drivers: media: imx296: Updated imx296 driver for external trigger
Updated imx296 driver to support external trigger mode via XTR pin.
Added module parameter to control this mode.

Signed-off-by: Ben Benson <ben.benson@raspberrypi.com>
2024-08-05 11:15:07 +01:00
Naushir Patuck
9e84a7efac drivers: media: imx296: Add standby delay during probe
Add a 2-5ms delay when coming out of standby and before reading the
sensor info register durning probe, as instructed by the datasheet. This
standby delay is already present when the sensor starts streaming.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:07 +01:00
Naushir Patuck
9901d4116a drivers: media: imx296: Disable 2x2 binned mode
Disable enumerating and setting of the 2x2 binned mode entirely as it
does not seem to work for either mono or colour sensor variants.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:07 +01:00
Lee Jackson
2fd5069533 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>

media: i2c: Add PDAF support for IMX519

Add PDAF support for IMX519, and reduce the pixel rate to 426666667,
link freq to 408000000.

Signed-off-by: Lee Jackson <lee.jackson@arducam.com>

drivers: media: imx519: Add V4L2_CID_LINK_FREQ control

Add V4L2_CID_LINK_FREQ as a read-only control with a value of 408 Mhz.
This will be used by the CFE driver to corretly setup the DPHY timing
parameters in the CSI-2 block.

Signed-off-by: Lee Jackson <lee.jackson@arducam.com>

media: i2c: imx519: Squash fixes
2024-08-05 11:15:07 +01:00
Naushir Patuck
78bcc6e12d 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 543790f777 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>

driver: media: i2c: imx477: Re-enable temperature sensor

The temperature sensor enable register write got lost at some point.
Re-enable it.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

media: i2c: imx477: Fix locking in imx477_init_controls()

The driver does not lock the imx477 mutex when calling
imx477_set_framing_limits(), leading to:

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

Fix this by taking the lock.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

drivers: media: imx477: Disable the scaler

The horizontal scaler was enabled for the 2028x1520 and 2028x1080 modes,
with a scale factor of 1. It caused a single column of bad pixels on the
right edge of the image. Since scaling is not needed for these modes,
disable it entirely.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

drivers: media: imx477: Set horizontal binning when disabling the scaler

The horizontal scaler has been disabled but actually the sensor is not
binning horizontally, resulting in images that are stretched 2x
horizontally (missing the right half of the field of view completely).

Therefore we must additionally set the horizontal binning mode. There
is only marginal change in output quality and noise levels.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Fixes: f075893e9b ("drivers: media: imx477: Disable the scaler")

drivers: media: imx477: Add V4L2_CID_LINK_FREQ control

Add V4L2_CID_LINK_FREQ as a read-only control with a value of 450 Mhz.
This will be used by the CFE driver to corretly setup the DPHY timing
parameters in the CSI-2 block.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

drivers: media: imx477: Correctly set IMX477_PIXEL_RATE as a r/o control

This control is meant to be read-only, mark it as such.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

drivers: media: i2c: imx296,imx477: Configure tigger_mode every time

Don't assume the camera has been reset each time we start streaming,
but always write registers relating to trigger_mode, even in mode 0.

IMX477: Stop driving XVS on stop streaming, to avoid spurious pulses.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>

media: i2c: imx477: Squash fixes

imx477: make trigger-mode more configurable

Allow trigger-mode to be overridden using device tree so that it can be
set per camera. Previously the mode could only be changed using a module
parameter, which would then affect all cameras.

Signed-off-by: Erik Botö <erik.boto@gmail.com>

drivers: media: imx477: Add V4L2_CID_LINK_FREQ control

Add V4L2_CID_LINK_FREQ as a read-only control with a value of 450 Mhz.
This will be used by the CFE driver to corretly setup the DPHY timing
parameters in the CSI-2 block.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2024-08-05 11:15:07 +01:00
Phil Elwell
02165e9796 arch/arm64: Add Revision, Serial, Model to cpuinfo
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2024-08-05 11:15:07 +01:00
Phil Elwell
851f3a2272 arch/arm: Add model string to cpuinfo
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2024-08-05 11:15:07 +01:00
Phil Elwell
aafb5622ae 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>
2024-08-05 11:15:07 +01:00
Jonathan Bell
3fd107fbdb 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>
2024-08-05 11:15:07 +01:00
Dom Cobley
493bfa3336 drm/v3d: Switch clock setting to new api
Signed-off-by: Dom Cobley <popcornmix@gmail.com>

drm/v3d: Convert to new clock range API

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:07 +01:00
Dom Cobley
d24475b8cc 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>

v3d_drv: Handle missing clock more gracefully

Signed-off-by: popcornmix <popcornmix@gmail.com>

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>
2024-08-05 11:15:07 +01:00
Phil Elwell
64366ff763 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>
2024-08-05 11:15:07 +01:00
Phil Elwell
4fc592fff5 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>
2024-08-05 11:15:07 +01:00
Jonathan Bell
87bdcf082d 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>
2024-08-05 11:15:07 +01:00
Jonathan Bell
6958c341f6 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>
2024-08-05 11:15:06 +01:00
Jonathan Bell
f1f72510e2 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>
2024-08-05 11:15:06 +01:00
Jonathan Bell
779428ec35 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>
2024-08-05 11:15:06 +01:00
Jonathan Bell
a89f317b16 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>
2024-08-05 11:15:06 +01:00
Phil Elwell
1d5b6d1460 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>
2024-08-05 11:15:06 +01:00
Jonathan Bell
e834e53b3d bcmgenet: constrain max DMA burst length 2024-08-05 11:15:06 +01:00
Stefan Wahren
f02ca908e9 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>
2024-08-05 11:15:06 +01:00
Phil Elwell
5a3e9096be 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>
2024-08-05 11:15:06 +01:00
Phil Elwell
c74c6cb640 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>
2024-08-05 11:15:06 +01:00
Phil Elwell
9d3402c9bf 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>

drivers: w1-gpio: add flag to force read-polling while delaying

On Pi 5, the link to RP1 will bounce in and out of L1 depending on
inactivity timers at both the RC and EP end. Unfortunately for
bitbashing 1-wire, this means that on an otherwise idle Pi 5 many of the
reads/writes to GPIO registers are delayed by up to 8us which causes
mis-sampling of read data and trashes write bits.

By issuing dummy reads at a rate greater than the link inactivity
timeout while spinning on a delay, PCIe stays in L0 which does not incur
additional latency.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

drivers: w1-gpio: Fixup uninitialised variable use in w1_gpio_probe

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:06 +01:00
Dave Stevenson
489018cc35 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>
2024-08-05 11:15:06 +01:00
Dave Stevenson
75863437e3 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>
2024-08-05 11:15:06 +01:00
Dave Stevenson
602aefe631 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>
2024-08-05 11:15:06 +01:00
Dave Stevenson
5dff20a45b 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>
2024-08-05 11:15:06 +01:00
Dave Stevenson
84d0559e2c 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>
2024-08-05 11:15:06 +01:00
Dave Stevenson
78b7409808 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>
2024-08-05 11:15:06 +01:00
Dave Stevenson
aaf1fd596d 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>
2024-08-05 11:15:06 +01:00
Dave Stevenson
203f37d376 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>
2024-08-05 11:15:05 +01:00
Dave Stevenson
405c38cb99 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>
2024-08-05 11:15:05 +01:00
Dave Stevenson
adf0a6c6da 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>

media: i2c: tc358743: Only allow supported pixel fmts in set_fmt

Fix commit "media: tc358743: Return an appropriate colorspace from
tc358743_set_fmt" to ensure that the format passed in to set_fmt
is checked to be valid, and reset to the current format if not.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:05 +01:00
Dave Stevenson
13a4cea30c 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>
2024-08-05 11:15:05 +01:00
Dave Stevenson
8070297fcf 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>
2024-08-05 11:15:05 +01:00
Dave Stevenson
3143ee6ed8 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>
2024-08-05 11:15:05 +01:00
Dave Stevenson
4e9a1cd17c 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>
2024-08-05 11:15:05 +01:00
Dave Stevenson
306bc889c0 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>
2024-08-05 11:15:05 +01:00
Dave Stevenson
49b58672b7 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>

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>

media: i2c: tc358743: Fix fallthrough warning

Signed-off-by: Jacko Dirks <jdirks.linuxdev@gmail.com>
2024-08-05 11:15:05 +01:00
Dave Stevenson
46b426b778 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>
2024-08-05 11:15:05 +01:00
Phil Elwell
fa66d6e808 lan78xx: Enable LEDs and auto-negotiation
For applications of the LAN78xx that don't have valid programmed
EEPROMs or OTPs, enabling both LEDs and auto-negotiation by default
seems reasonable.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2024-08-05 11:15:05 +01:00
tiagofreire-pt
153d1186b2 Patching lan78xx for SOF_TIMESTAMPING_TX_SOFTWARE support 2024-08-05 11:15:05 +01:00
Phil Elwell
07eb98d5f3 net: lan78xx: Ack pending PHY ints when resetting
lan78xx_link_reset explicitly clears the MAC's view of the PHY's IRQ
status. In doing so it potentially leaves the PHY with a pending
interrupt that will never be acknowledged, at which point no further
interrupts will be generated.

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

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:05 +01:00
Joshua Emele
a9e8ec1b7a 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
2024-08-05 11:15:05 +01:00
Phil Elwell
3278fd077c 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>
2024-08-05 11:15:05 +01:00
Dave Stevenson
ff2b375bbe 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>
2024-08-05 11:15:05 +01:00
Dave Stevenson
829c839777 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>
2024-08-05 11:15:04 +01:00
Stefan Wahren
2a74cdc55f 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>
2024-08-05 11:15:04 +01:00
popcornmix
f7f1341706 cxd2880: CXD2880_SPI_DRV should select DVB_CXD2880 with MEDIA_SUBDRV_AUTOSELECT 2024-08-05 11:15:04 +01:00
Phil Elwell
ddb5067dbd 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] dd91880117

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2024-08-05 11:15:04 +01:00
Phil Elwell
b13a7387b9 irqchip: irq-bcm2835: Calc. FIQ_START at boot-time
ad83c7cb2f ("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>
2024-08-05 11:15:04 +01:00
Phil Elwell
fb3cc01a6a 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>
2024-08-05 11:15:04 +01:00
popcornmix
ee68787efe hid: Reduce default mouse polling interval to 60Hz
Reduces overhead when using X

usbhid: call usb_fixup_endpoint after mangling intervals

Lets the mousepoll override mechanism work with xhci.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
2024-08-05 11:15:04 +01:00
hdoverobinson
5c756e20e1 added capture_clear option to pps-gpio via dtoverlay (#2433) 2024-08-05 11:15:04 +01:00
Phil Elwell
d5ff98175c i2c-gpio: Also set bus numbers from reg property
I2C busses can be assigned specific bus numbers using aliases in
Device Tree - string properties where the name is the alias and the
value is the path to the node. The current DT parameter mechanism
does not allow property names to be derived from a parameter value
in any way, so it isn't possible to generate unique or matching
aliases for nodes from an overlay that can generate multiple
instances, e.g. i2c-gpio.

Work around this limitation (at least temporarily) by allowing
the i2c adapter number to be initialised from the "reg" property
if present.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2024-08-05 11:15:04 +01:00
Phil Elwell
a53d6499db ARM: Activate FIQs to avoid __irq_startup warnings
There is a new test in __irq_startup that the IRQ is activated, which
hasn't been the case for FIQs since they bypass some of the usual setup.

Augment enable_fiq to include a call to irq_activate to avoid the
warning.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2024-08-05 11:15:04 +01:00
Phil Elwell
0e9377bb73 dwc-otg: FIQ: Fix "bad mode in data abort handler"
Create a semi-static mapping for the USB registers early in the boot
process, before additional kernel threads are started, so all threads
will have the mappings from the start. This avoids the need for
data aborts to lazily update them.

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

Signed-off-by: Floris Bos <bos@je-eigen-domein.nl>
2024-08-05 11:15:04 +01:00
Noralf Trønnes
ecd8c4c37c ARM: bcm2835: Set Serial number and Revision
The VideoCore bootloader passes in Serial number and
Revision number through Device Tree. Make these available to
userspace through /proc/cpuinfo.

Mainline status:

There is a commit in linux-next that standardize passing the serial
number through Device Tree (string: /serial-number):
ARM: 8355/1: arch: Show the serial number from devicetree in cpuinfo

There was an attempt to do the same with the revision number, but it
didn't get in:
[PATCH v2 1/2] arm: devtree: Set system_rev from DT revision

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
2024-08-05 11:15:04 +01:00
James Hughes
35dd61cd10 AXI performance monitor driver (#2222)
Uses the debugfs I/F to provide access to the AXI
bus performance monitors.

Requires the new mailbox peripheral access for access
to the VPU performance registers, system bus access
is done using direct register reads.

Signed-off-by: James Hughes <james.hughes@raspberrypi.org>

raspberrypi_axi_monitor: suppress warning

Suppress the following warning by casting the pointer to and uintptr_t
before to u32:

Signed-off-by: Matteo Croce <mcroce@redhat.com>

perf/raspberry: Add support for 2712 axi performance monitors

Also handle 2711 correctly which has a different configuration
from 2835.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:04 +01:00
Michael Zoran
6e06cdd945 ARM64: Force hardware emulation of deprecated instructions. 2024-08-05 11:15:04 +01:00
Michael Zoran
125d3b4029 ARM64: Round-Robin dispatch IRQs between CPUs.
IRQ-CPU mapping is round robined on ARM64 to increase
concurrency and allow multiple interrupts to be serviced
at a time.  This reduces the need for FIQ.

Signed-off-by: Michael Zoran <mzoran@crowfest.net>

drivers: irqchip: irq-bcm2835: Concurrency fix

The commit shown in Fixes: aims to improve interrupt throughput by
getting the handlers invoked on different CPU cores. It does so (*) by
using an irq_ack hook to change the interrupt routing.

Unfortunately, the IRQ status bits must be cleared at source, which only
happens once the interrupt handler has run - there is no easy way for
one core to claim one of the IRQs before sending the remainder to the
next core on the list, so waking another core immediately results in a
race with a chance of both cores handling the same IRQ. It is probably
for this reason that the routing change is deferred to irq_ack, but that
doesn't guarantee no clashes - after irq_ack is called, control returns
to bcm2836_chained_handler_irq which proceeds to check for other pending
IRQs at a time when the next core is probably doing the same thing.

Since the whole point of the original commit is to distribute the IRQ
handling, there is no reason to attempt to handle multiple IRQs in one
interrupt callback, so the problem can be solved (or at least made much
harder to reproduce) by changing a "while" into an "if", so that each
invocation only handles one IRQ.

(*) I'm not convinced it's as effective as claimed since irq_ack is
called _after_ the interrupt handler, but the author thought it made a
difference.

See: https://github.com/raspberrypi/linux/issues/5214
     https://github.com/raspberrypi/linux/pull/1794

Fixes: fd4c9785bd ("ARM64: Round-Robin dispatch IRQs between CPUs.")
Signed-off-by: Phil Elwell <phil@raspberrypi.com>

irqchip: irq-bcm2836: Avoid prototype warning

Declare bcm2836_arm_irqchip_spin_gpu_irq in irq-bcm2836.h to avoid a
compiler warning about a missing prototype.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:04 +01:00
Phil Elwell
6e640f0ada hci_h5: Don't send conf_req when ACTIVE
Without this patch, a modem and kernel can continuously bombard each
other with conf_req and conf_rsp messages, in a demented game of tag.
2024-08-05 11:15:04 +01:00
Cheong2K
49614d787a brcm: adds support for BCM43341 wifi
brcmfmac: Disable power management

Disable wireless power saving in the brcmfmac WLAN driver. This is a
temporary measure until the connectivity loss resulting from power
saving is resolved.

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

brcmfmac: Use original country code as a fallback

Commit 73345fd212:

    brcmfmac: Configure country code using device specific settings

prevents region codes from working on devices that lack a region code
translation table. In the event of an absent table, preserve the old
behaviour of using the provided code as-is.

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

brcmfmac: Plug memory leak in brcmf_fill_bss_param

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

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

brcmfmac: do not use internal roaming engine by default

Some evidence of curing disconnects with this disabled, so make it a default.
Can be overridden with module parameter roamoff=0
See: http://projectable.me/optimize-my-pi-wi-fi/

brcmfmac: Change stop_ap sequence

Patch from Broadcom/Cypress to resolve a customer error

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

Revert "brcmfmac: Disable power management"

Shortly after the release of the Pi 3B, a loss of SSH connectivity
over WiFi was traced to the power management handling, so power
management was disabled. And so it has remained ever since.

Enabling power management saves 55mA (~270mW) on a Pi 4B, so is very
much worth the minimal effort of reverting this patch, which was
squashed and rebased many times since then to the commit hash is
meaningless.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2024-08-05 11:15:03 +01:00
Pantelis Antoniou
c24df2b8de OF: DT-Overlay configfs interface
This is a port of Pantelis Antoniou's v3 port that makes use of the
new upstreamed configfs support for binary attributes.

Original commit message:

Add a runtime interface to using configfs for generic device tree overlay
usage. With it its possible to use device tree overlays without having
to use a per-platform overlay manager.

Please see Documentation/devicetree/configfs-overlays.txt for more info.

Changes since v2:
- Removed ifdef CONFIG_OF_OVERLAY (since for now it's required)
- Created a documentation entry
- Slight rewording in Kconfig

Changes since v1:
- of_resolve() -> of_resolve_phandles().

Originally-signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Phil Elwell <phil@raspberrypi.org>

DT configfs: Fix build errors on other platforms

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

DT configfs: fix build error

There is an error when compiling rpi-4.6.y branch:
  CC      drivers/of/configfs.o
drivers/of/configfs.c:291:21: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
   .default_groups = of_cfs_def_groups,
                     ^
drivers/of/configfs.c:291:21: note: (near initialization for 'of_cfs_subsys.su_group.default_groups.next')

The .default_groups is linked list since commit
1ae1602de0.
This commit uses configfs_add_default_group to fix this problem.

Signed-off-by: Slawomir Stepien <sst@poczta.fm>

configfs: New of_overlay API

of: configfs: Use of_overlay_fdt_apply API call

The published API to the dynamic overlay application mechanism now
takes a Flattened Device Tree blob as input so that it can manage the
lifetime of the unflattened tree. Conveniently, the new API call -
of_overlay_fdt_apply - is virtually a drop-in replacement for
create_overlay, which can now be deleted.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2024-08-05 11:15:03 +01:00
popcornmix
a1378db798 bcm2835-virtgpio: Virtual GPIO driver
Add a virtual GPIO driver that uses the firmware mailbox interface to
request that the VPU toggles LEDs.

gpio: bcm-virt: Fix the get() method

The get() method does not understand the on-the-wire encoding of the
remote GPIO states, thinking they are simple on/off bits when they are
really pairs of 16-bit counts. Rewrite the get() handler to return the
value last written, which will eventually match the actual GPIO state
if there are no other changes.

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

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

bcm2835-virtgpio: Update for Linux 6.6

The gpio subsystem is happier if the gpiochip is given a parent, and
if it doesn't have a fixed base gpio number. While we're in here,
use the fact that the firmware node is the parent to locate it,
and use the devm_ version of rpi_firmware_get.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:03 +01:00
P33M
dc245f23bc rpi_display: add backlight driver and overlay
Add a mailbox-driven backlight controller for the Raspberry Pi DSI
touchscreen display. Requires updated GPU firmware to recognise the
mailbox request.

Signed-off-by: Gordon Hollingworth <gordon@raspberrypi.org>

Add Raspberry Pi firmware driver to the dependencies of backlight driver

Otherwise the backlight driver fails to build if the firmware
loading driver is not in the kernel

Signed-off-by: Alex Riesen <alexander.riesen@cetitec.com>
2024-08-05 11:15:03 +01:00
Florian Meier
327e60644f ASoC: Add support for all the downstream rpi sound card drivers
ASoC: Add support for Rpi-DAC

ASoC: Add prompt for ICS43432 codec

Without a prompt string, a config setting can't be included in a
defconfig. Give CONFIG_SND_SOC_ICS43432 a prompt so that Pi soundcards
can use the driver.

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

Add IQaudIO Sound Card support for Raspberry Pi

Set a limit of 0dB on Digital Volume Control

The main volume control in the PCM512x DAC has a range up to
+24dB. This is dangerously loud and can potentially cause massive
clipping in the output stages. Therefore this sets a sensible
limit of 0dB for this control.

Allow up to 24dB digital gain to be applied when using IQAudIO DAC+

24db_digital_gain DT param can be used to specify that PCM512x
codec "Digital" volume control should not be limited to 0dB gain,
and if specified will allow the full 24dB gain.

Modify IQAudIO DAC+ ASoC driver to set card/dai config from dt

Add the ability to set the card name, dai name and dai stream name, from
dt config.

Signed-off-by: DigitalDreamtime <clive.messer@digitaldreamtime.co.uk>

IQaudIO: auto-mute for AMP+ and DigiAMP+

IQAudIO amplifier mute via GPIO22. Add dt params for "one-shot" unmute
and auto mute.

Revision 2, auto mute implementing HiassofT suggestion to mute/unmute
using set_bias_level, rather than startup/shutdown....
"By default DAPM waits 5 seconds (pmdown_time) before shutting down
playback streams so a close/stop immediately followed by open/start
doesn't trigger an amp mute+unmute."

Tested on both AMP+ (via DAC+) and DigiAMP+, with both options...

dtoverlay=iqaudio-dacplus,unmute_amp
 "one-shot" unmute when kernel module loads.

dtoverlay=iqaudio-dacplus,auto_mute_amp
 Unmute amp when ALSA device opened by a client. Mute, with 5 second delay
 when ALSA device closed. (Re-opening the device within the 5 second close
 window, will cancel mute.)

Revision 4, using gpiod.

Revision 5, clean-up formatting before adding mute code.
 - Convert tab plus 4 space formatting to 2x tab
 - Remove '// NOT USED' commented code

Revision 6, don't attempt to "one-shot" unmute amp, unless card is
successfully registered.

Signed-off-by: DigitalDreamtime <clive.messer@digitaldreamtime.co.uk>

ASoC: iqaudio-dac: fix S24_LE format

Remove set_bclk_ratio call so 24-bit data is transmitted in
24 bclk cycles.

Signed-off-by: Matthias Reichl <hias@horus.com>

ASoC: iqaudio-dac: use modern dai_link style

Signed-off-by: Matthias Reichl <hias@horus.com>

Added support for HiFiBerry DAC+

The driver is based on the HiFiBerry DAC driver. However HiFiBerry DAC+ uses
a different codec chip (PCM5122), therefore a new driver is necessary.

Add support for the HiFiBerry DAC+ Pro.

The HiFiBerry DAC+ and DAC+ Pro products both use the existing bcm sound driver with the DAC+ Pro having a special clock device driver representing the two high precision oscillators.

An addition bug fix is included for the PCM512x codec where by the physical size of the sample frame is used in the calculation of the LRCK divisor as it was found to be wrong when using 24-bit depth sample contained in a little endian 4-byte sample frame.

Limit PCM512x "Digital" gain to 0dB by default with HiFiBerry DAC+

24db_digital_gain DT param can be used to specify that PCM512x
codec "Digital" volume control should not be limited to 0dB gain,
and if specified will allow the full 24dB gain.

Add dt param to force HiFiBerry DAC+ Pro into slave mode

"dtoverlay=hifiberry-dacplus,slave"

Add 'slave' param to use HiFiBerry DAC+ Pro in slave mode,
with Pi as master for bit and frame clock.

Signed-off-by: DigitalDreamtime <clive.messer@digitaldreamtime.co.uk>

Fixed a bug when using 352.8kHz sample rate

Signed-off-by: Daniel Matuschek <daniel@hifiberry.com>

ASoC: pcm512x: revert downstream changes

This partially reverts commit 185ea05465
which was added by https://github.com/raspberrypi/linux/pull/1152

The downstream pcm512x changes caused a regression, it broke normal
use of the 24bit format with the codec, eg when using simple-audio-card.

The actual bug with 24bit playback is the incorrect usage
of physical_width in various drivers in the downstream tree
which causes 24bit data to be transmitted with 32 clock
cycles. So it's not the pcm512x that needs fixing, it's the
soundcard drivers.

Signed-off-by: Matthias Reichl <hias@horus.com>

ASoC: hifiberry_dacplus: fix S24_LE format

Remove set_bclk_ratio call so 24-bit data is transmitted in
24 bclk cycles.

Signed-off-by: Matthias Reichl <hias@horus.com>

ASoC: hifiberry_dacplus: transmit S24_LE with 64 BCLK cycles

Signed-off-by: Matthias Reichl <hias@horus.com>

hifiberry_dacplus: switch to snd_soc_dai_set_bclk_ratio

Signed-off-by: Matthias Reichl <hias@horus.com>

ASoC: hifiberry_dacplus: use modern dai_link style

Signed-off-by: Hui Wang <hui.wang@canonical.com>

Add driver for rpi-proto

Forward port of 3.10.x driver from https://github.com/koalo
We are using a custom board and would like to use rpi 3.18.x
kernel. Patch works fine for our embedded system.

URL to the audio chip:
http://www.mikroe.com/add-on-boards/audio-voice/audio-codec-proto/

Playback tested with devicetree enabled.

Signed-off-by: Waldemar Brodkorb <wbrodkorb@conet.de>

ASoC: rpi-proto: use modern dai_link style

Signed-off-by: Hui Wang <hui.wang@canonical.com>

Add Support for JustBoom Audio boards

justboom-dac: Adjust for ALSA API change

As of 4.4, snd_soc_limit_volume now takes a struct snd_soc_card *
rather than a struct snd_soc_codec *.

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

ASoC: justboom-dac: fix S24_LE format

Remove set_bclk_ratio call so 24-bit data is transmitted in
24 bclk cycles.

Also remove hw_params as it's no longer needed.

Signed-off-by: Matthias Reichl <hias@horus.com>

ASoC: justboom-dac: use modern dai_link style

Signed-off-by: Matthias Reichl <hias@horus.com>

New AudioInjector.net Pi soundcard with low jitter audio in and out.

Contains the sound/soc/bcm ALSA machine driver and necessary alterations to the Kconfig and Makefile.
Adds the dts overlay and updates the Makefile and README.
Updates the relevant defconfig files to enable building for the Raspberry Pi.
Thanks to Phil Elwell (pelwell) for the review, simple-card concepts and discussion. Thanks to Clive Messer for overlay naming suggestions.

Added support for headphones, microphone and bclk_ratio settings.

This patch adds headphone and microphone capability to the Audio Injector sound card. The patch also sets the bit clock ratio for use in the bcm2835-i2s driver. The bcm2835-i2s can't handle an 8 kHz sample rate when the bit clock is at 12 MHz because its register is only 10 bits wide which can't represent the ch2 offset of 1508. For that reason, the rate constraint is added.

ASoC: audioinjector-pi-soundcard: use modern dai_link style

Signed-off-by: Hui Wang <hui.wang@canonical.com>

New driver for RRA DigiDAC1 soundcard using WM8741 + WM8804

ASoC: digidac1-soundcard: use modern dai_link style

Signed-off-by: Hui Wang <hui.wang@canonical.com>

Add support for Dion Audio LOCO DAC-AMP HAT

Using dedicated machine driver and pcm5102a codec driver.

Signed-off-by: DigitalDreamtime <clive.messer@digitaldreamtime.co.uk>

ASoC: dionaudio_loco: use modern dai_link style

Signed-off-by: Hui Wang <hui.wang@canonical.com>

Allo Piano DAC boards: Initial 2 channel (stereo) support (#1645)

Add initial 2 channel (stereo) support for Allo Piano DAC (2.0/2.1) boards,
using allo-piano-dac-pcm512x-audio overlay and allo-piano-dac ALSA ASoC
machine driver.

NB. The initial support is 2 channel (stereo) ONLY!
(The Piano DAC 2.1 will only support 2 channel (stereo) left/right output,
 pending an update to the upstream pcm512x codec driver, which will have
 to be submitted via upstream. With the initial downstream support,
 provided by this patch, the Piano DAC 2.1 subwoofer outputs will
 not function.)

Signed-off-by: Baswaraj K <jaikumar@cem-solutions.net>
Signed-off-by: Clive Messer <clive.messer@digitaldreamtime.co.uk>
Tested-by: Clive Messer <clive.messer@digitaldreamtime.co.uk>

ASoC: allo-piano-dac: fix S24_LE format

Remove set_bclk_ratio call so 24-bit data is transmitted in
24 bclk cycles.

Also remove hw_params and ops as they are no longer needed.

Signed-off-by: Matthias Reichl <hias@horus.com>

ASoC: allo-piano-dac: use modern dai_link style

Signed-off-by: Hui Wang <hui.wang@canonical.com>

Add support for Allo Piano DAC 2.1 plus add-on board for Raspberry Pi.

The Piano DAC 2.1 has support for 4 channels with subwoofer.

Signed-off-by: Baswaraj K <jaikumar@cem-solutions.net>
Reviewed-by: Vijay Kumar B. <vijaykumar@zilogic.com>
Reviewed-by: Raashid Muhammed <raashidmuhammed@zilogic.com>

Add clock changes and mute gpios (#1938)

Also improve code style and adhere to ALSA coding conventions.

Signed-off-by: Baswaraj K <jaikumar@cem-solutions.net>
Reviewed-by: Vijay Kumar B. <vijaykumar@zilogic.com>
Reviewed-by: Raashid Muhammed <raashidmuhammed@zilogic.com>

PianoPlus: Dual Mono & Dual Stereo features added (#2069)

allo-piano-dac-plus: Master volume added + fixes

Master volume added, which controls both DACs volumes.

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

Also fix initial max volume, default mode value, and unmute.

Signed-off-by: allocom <sparky-dev@allo.com>

ASoC: allo-piano-dac-plus: fix S24_LE format

Remove set_bclk_ratio call so 24-bit data is transmitted in
24 bclk cycles.

Signed-off-by: Matthias Reichl <hias@horus.com>

sound: bcm: Fix memset dereference warning

This warning appears with GCC 6.4.0 from toolchains.bootlin.com:

../sound/soc/bcm/allo-piano-dac-plus.c: In function ‘snd_allo_piano_dac_init’:
../sound/soc/bcm/allo-piano-dac-plus.c:711:30: warning: argument to ‘sizeof’ in ‘memset’ call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
  memset(glb_ptr, 0x00, sizeof(glb_ptr));
                              ^

Suggested-by: Phil Elwell <phil@raspberrypi.org>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

ASoC: allo-piano-dac-plus: use modern dai_link style

Signed-off-by: Hui Wang <hui.wang@canonical.com>

Add support for Allo Boss DAC add-on board for Raspberry Pi. (#1924)

Signed-off-by: Baswaraj K <jaikumar@cem-solutions.net>
Reviewed-by: Deepak <deepak@zilogic.com>
Reviewed-by: BabuSubashChandar <babusubashchandar@zilogic.com>

Add support for new clock rate and mute gpios.

Signed-off-by: Baswaraj K <jaikumar@cem-solutions.net>
Reviewed-by: Deepak <deepak@zilogic.com>
Reviewed-by: BabuSubashChandar <babusubashchandar@zilogic.com>

ASoC: allo-boss-dac: fix S24_LE format

Remove set_bclk_ratio call so 24-bit data is transmitted in
24 bclk cycles.

Signed-off-by: Matthias Reichl <hias@horus.com>

ASoC: allo-boss-dac: transmit S24_LE with 64 BCLK cycles

Signed-off-by: Matthias Reichl <hias@horus.com>

allo-boss-dac: switch to snd_soc_dai_set_bclk_ratio

Signed-off-by: Matthias Reichl <hias@horus.com>

ASoC: allo-boss-dac: use modern dai_link style

Signed-off-by: Hui Wang <hui.wang@canonical.com>

Support for Blokas Labs pisound board

Pisound dynamic overlay (#1760)

Restructuring pisound-overlay.dts, so it can be loaded and unloaded dynamically using dtoverlay.

Print a logline when the kernel module is removed.

pisound improvements:

* Added a writable sysfs object to enable scripts / user space software
to blink MIDI activity LEDs for variable duration.
* Improved hw_param constraints setting.
* Added compatibility with S16_LE sample format.
* Exposed some simple placeholder volume controls, so the card appears
in volumealsa widget.

Add missing SND_PISOUND selects dependency to SND_RAWMIDI

Without it the Pisound module fails to compile.
See https://github.com/raspberrypi/linux/issues/2366

Updates for Pisound module code:

	* Merged 'Fix a warning in DEBUG builds' (1c8b82b).
	* Updating some strings and copyright information.
	* Fix for handling high load of MIDI input and output.
	* Use dual rate oversampling ratio for 96kHz instead of single
	  rate one.

Signed-off-by: Giedrius Trainavicius <giedrius@blokas.io>

Fixing memset call in pisound.c

Signed-off-by: Giedrius Trainavicius <giedrius@blokas.io>

Fix for Pisound's MIDI Input getting blocked for a while in rare cases.

There was a possible race condition which could lead to Input's FIFO queue
to be underflown, causing high amount of processing in the worker thread for
some period of time.

Signed-off-by: Giedrius Trainavicius <giedrius@blokas.io>

Fix for Pisound kernel module in Real Time kernel configuration.

When handler of data_available interrupt is fired, queue_work ends up
getting called and it can block on a spin lock which is not allowed in
interrupt context. The fix was to run the handler from a thread context
instead.

Pisound: Remove spinlock usage around spi_sync

ASoC: pisound: use modern dai_link style

Signed-off-by: Hui Wang <hui.wang@canonical.com>

ASoC: pisound: fix the parameter for spi_device_match

Signed-off-by: Hui Wang <hui.wang@canonical.com>

ASoC: Add driver for Cirrus Logic Audio Card

Note: due to problems with deferred probing of regulators
the following softdep should be added to a modprobe.d file

softdep arizona-spi pre: arizona-ldo1

Signed-off-by: Matthias Reichl <hias@horus.com>

ASoC: rpi-cirrus: use modern dai_link style

Signed-off-by: Matthias Reichl <hias@horus.com>

sound: Support for Dion Audio LOCO-V2 DAC-AMP HAT

Signed-off-by: Miquel Blauw <info@dionaudio.nl>

ASoC: dionaudio_loco-v2: fix S24_LE format

Remove set_bclk_ratio call so 24-bit data is transmitted in
24 bclk cycles.

Also remove hw_params and ops as they are no longer needed.

Signed-off-by: Matthias Reichl <hias@horus.com>

ASoC: dionaudio_loco-v2: use modern dai_link style

Signed-off-by: Hui Wang <hui.wang@canonical.com>

Add support for Fe-Pi audio sound card. (#1867)

Fe-Pi Audio Sound Card is based on NXP SGTL5000 codec.
Mechanical specification of the board is the same the Raspberry Pi Zero.
3.5mm jacks for Headphone/Mic, Line In, and Line Out.

Signed-off-by: Henry Kupis <fe-pi@cox.net>

ASoC: fe-pi-audio: use modern dai_link style

Signed-off-by: Hui Wang <hui.wang@canonical.com>

Add support for the AudioInjector.net Octo sound card

AudioInjector Octo: sample rates, regulators, reset

This patch adds new sample rates to the Audioinjector Octo sound card. The
new supported rates are (in kHz) :
96, 48, 32, 24, 16, 8, 88.2, 44.1, 29.4, 22.05, 14.7

Reference the bcm270x DT regulators in the overlay.

This patch adds a reset GPIO for the AudioInjector.net octo sound card.

Audioinjector octo : Make the playback and capture symmetric

This patch ensures that the sample rate and channel count of the audioinjector
octo sound card are symmetric.

audioinjector-octo: Add continuous clock feature

By user request, add a switch to prevent the clocks being stopped when
the stream is paused, stopped or shutdown. Provide access to the switch
by adding a 'non-stop-clocks' parameter to the audioinjector-addons
overlay.

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

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

sound: Fixes for audioinjector-octo under 4.19

1. Move the DT alias declaration to the I2C shim in the cases
where the shim is enabled. This works around a problem caused by a
4.19 commit [1] that generates DT/OF uevents for I2C drivers.

2. Fix the diagnostics in an error path of the soundcard driver to
correctly identify the reason for the failure to load.

3. Move the declaration of the clock node in the overlay outside
the I2C node to avoid warnings.

4. Sort the overlay nodes so that dependencies are only to earlier
fragments, in an attempt to get runtime dtoverlay application to
work (it still doesn't...)

See: https://github.com/Audio-Injector/Octo/issues/14
Signed-off-by: Phil Elwell <phil@raspberrypi.org>

[1] af503716ac ("i2c: core: report OF style module alias for devices registered via OF")

ASoC: audioinjector-octo-soundcard: use modern dai_link style

Signed-off-by: Hui Wang <hui.wang@canonical.com>

Driver support for Google voiceHAT soundcard.

ASoC: googlevoicehat-codec: Use correct device when grabbing GPIO

The fixup for the VoiceHAT in 4.18 incorrectly tried to find the
sdmode GPIO pin under the card device, not the codec device.
This failed, and therefore caused the device probe to fail.

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

ASoC: googlevoicehat-codec: Reformat for kernel coding standards

Fix all whitespace, indentation, and bracing errors.

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

ASoC: googlevoicehat-codec: Make driver function structure const

Make voicehat_component_driver a const structure.

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

ASoC: googlevoicehat-codec: Only convert from ms to jiffies once

Minor optimisation and allows to become checkpatch clean.
A msec value is read out of DT or from a define, and convert once to
jiffies, rather than every time that it is used.

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

Driver and overlay for Allo Katana DAC

Allo Katana DAC: Updated default values

Signed-off-by: Jaikumar <jaikumar@cem-solutions.com>

Added mute stream func

Signed-off-by: Jaikumar <jaikumar@cem-solutions.net>

codecs: Correct Katana minimum volume

Update Katana minimum volume to get the exact 0.5 dB value in each step.

Signed-off-by: Sudeep Kumar <sudeepkumar@cem-solutions.net>

ASoC: Add generic RPI driver for simple soundcards.

The RPI simple sound card driver provides a generic ALSA SOC card driver
supporting a variety of Pi HAT soundcards. The intention is to avoid
the duplication of code for cards that can't be fully supported by
the soc simple/graph cards but are otherwise almost identical.

This initial commit adds support for the ADAU1977 ADC, Google VoiceHat,
HifiBerry AMP, HifiBerry DAC and RPI DAC.

Signed-off-by: Tim Gover <tim.gover@raspberrypi.org>

ASoC: Use correct card name in rpi-simple driver

Use the specific card name from drvdata instead of the snd_rpi_simple

rpi-simple-soundcard: Use nicer driver name "RPi-simple"

Rename the driver from "RPI simple soundcard" to "RPi-simple" so that
the driver name won't be mangled allowing to be used unaltered as the
card conf filename.

ASoC: rpi-simple-soundcard: use modern dai_link style

Signed-off-by: Hui Wang <hui.wang@canonical.com>

ASoC: Add Kconfig and Makefile for sound/soc/bcm

Signed-off-by: popcornmix <popcornmix@gmail.com>

ASoC: Create a generic Pi Hat WM8804 driver

Reduce the amount of duplicated code by creating a generic driver for
Pi Hat digi cards using the WM8804 codec.

This replaces the
Allo DigiOne, Hifiberry Digi/Pro, JustBoom Digi and IQAudIO Digi
dedicate soundcard drivers with a generic driver.

There are no significant changes to the runtime behavior of the drivers
and end users should not have to change any configuration settings
after upgrading.

Minor changes
* Check the return value of snd_soc_component_update_bits
* Added some pr_debug tracing
* Various checkpatch tidyups
* Updated allodigi-one to use use 128FS at > 96 Khz. This appears to
  be an omission in the original driver code so followed the Hifiberry
  DAC driver approach.

ASoC: rpi-wm8804-soundcard: use modern dai_link style

Signed-off-by: Matthias Reichl <hias@horus.com>

rpi-wm8804-soundcard: drop PWRDN register writes

Since kernel 4.0 the PWRDN register bits are under DAPM
control from the wm8804 driver.

Drop code that modifies that register to avoid interfering
with DAPM.

Signed-off-by: Matthias Reichl <hias@horus.com>

rpi-wm8804-soundcard: configure wm8804 clocks only on rate change

This should avoid clicks when stopping and immediately afterwards
starting a stream with the same samplerate as before.

Signed-off-by: Matthias Reichl <hias@horus.com>

rpi-wm8804-soundcard: Fixed MCLKDIV for Allo Digione

The Allo Digione board wants a fixed MCLKDIV of 256.

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

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

ASoC: Add support for AudioSense-Pi add-on soundcard

AudioSense-Pi is a RPi HAT based on a TI's TLV320AIC32x4 stereo codec

This hardware provides multiple audio I/O capabilities to the RPi.
The codec connects to the RPi's SoC through the I2S Bus.

The following devices can be connected through a 3.5mm jack
	1. Line-In: Plain old audio in from mobile phones, PCs, etc.,
	2. Mic-In: Connect a microphone
	3. Line-Out: Connect the output to a speaker
	4. Headphones: Connect a Headphone w or w/o microphones

Multiple Inputs:
	It supports the following combinations
	1. Two stereo Line-Inputs and a microphone
	2. One stereo Line-Input and two microphones
	3. Two stereo Line-Inputs, a microphone and
		one mono line-input (with h/w hack)
	4. One stereo Line-Input, two microphones and
		one mono line-input (with h/w hack)

Multiple Outputs:
	Audio output can be routed to the headphones or
		speakers (with additional hardware)

Signed-off-by: b-ak <anur.bhargav@gmail.com>

ASoC: audiosense-pi: use modern dai_link style

Signed-off-by: Hui Wang <hui.wang@canonical.com>

Added driver for the HiFiBerry DAC+ ADC (#2694)

Signed-off-by: Daniel Matuschek <daniel@hifiberry.com>

hifiberry_dacplusadc: switch to snd_soc_dai_set_bclk_ratio

Signed-off-by: Matthias Reichl <hias@horus.com>

ASoC: hifiberry_dacplusadc: fix DAI link setup

The driver only defines a single DAI link and the code that tries
to setup the second (non-existent) DAI link looks wrong - using dmic
as a CPU/platform driver doesn't make any sense.

The DT overlay doesn't define a dmic property, so the code was never
executed (otherwise it would have resulted in a memory corruption).

So drop the offending code to prevent issues if a dmic property
should be added to the DT overlay.

Signed-off-by: Matthias Reichl <hias@horus.com>

ASoC: hifiberry_dacplusadc: use modern dai_link style

Signed-off-by: Matthias Reichl <hias@horus.com>

Audiophonics I-Sabre 9038Q2M DAC driver

Signed-off-by: Audiophonics <contact@audiophonics.fr>

ASoC: i-sabre-q2m: use modern dai_link style

Signed-off-by: Hui Wang <hui.wang@canonical.com>

Added IQaudIO Pi-Codec board support (#2969)

Add support for the IQaudIO Pi-Codec board.

Signed-off-by: Gordon <gordon@iqaudio.com>

Fixed 48k timing issue

ASoC: iqaudio-codec: use modern dai_link style

Signed-off-by: Hui Wang <hui.wang@canonical.com>

adds the Hifiberry DAC+ADC PRO version

This adds the driver for the DAC+ADC PRO version of the Hifiberry soundcard with software controlled PCM1863 ADC
Signed-off-by: Joerg Schambacher joerg@i2audio.com

Add Hifiberry DAC+DSP soundcard driver (#3224)

Adds the driver for the Hifiberry DAC+DSP. It supports capture and
playback depending on the DSP firmware.

Signed-off-by: Joerg Schambacher <joerg@i2audio.com>

Allow simultaneous use of JustBoom DAC and Digi

Signed-off-by: Johannes Krude <johannes@krude.de>

Pisound: MIDI communication fixes for scaled down CPU.

* Increased maximum SPI communication speed to avoid running too slow
  when the CPU is scaled down and losing MIDI data.

* Keep track of buffer usage in millibytes for higher precision.

Signed-off-by: Giedrius Trainavičius <giedrius@blokas.io>

sound: Add the HiFiBerry DAC+HD version

This adds the driver for the DAC+HD version supporting HiFiBerry's
PCM179x based DACs. It also adds PLL control for clock generation.

Signed-off-by: Joerg Schambacher <joerg@i2audio.com>

Fix master mode settings of HiFiBerry DAC+ADC PRO card (#3424)

This patch fixes the board DAI setting when in master-mode.
Wrong setting could have caused random pop noise.

Signed-off-by: Joerg Schambacher <joerg@i2audio.com>

adds LED OFF feature to HiFiBerry DAC+ADC PRO sound card

This adds a DT overlay parameter 'leds_off' which allows
to switch off the onboard activity LEDs at all times
which has been requested by some users.

Signed-off-by: Joerg Schambacher <joerg@i2audio.com>

adds LED OFF feature to HiFiBerry DAC+ADC sound card

This adds a DT overlay parameter 'leds_off' which allows
to switch off the onboard activity LEDs at all times
which has been requested by some users.

Signed-off-by: Joerg Schambacher <joerg@i2audio.com>

adds LED OFF feature to HiFiBerry DAC+/DAC+PRO sound cards

This adds a DT overlay parameter 'leds_off' which allows
to switch off the onboard activity LEDs at all times
which has been requested by some users.

Signed-off-by: Joerg Schambacher <joerg@i2audio.com>

pisound: Added reading Pisound board hardware revision and exposing it (#3425)

pisound: Added reading Pisound board hardware revision and exposing it in kernel log and sysfs file:

/sys/kernel/pisound/hw_version

Signed-off-by: Giedrius <giedrius@blokas.io>

Added driver for HiFiBerry Amp amplifier add-on board

The driver contains a low-level hardware driver for the TAS5713 and the
drivers for the Raspberry Pi I2S subsystem.

TAS5713: return error if initialisation fails

Existing TAS5713 driver logs errors during initialisation, but does not return
an error code. Therefore even if initialisation fails, the driver will still be
loaded, but won't work. This patch fixes this. I2C communication error will now
reported correctly by a non-zero return code.

HiFiBerry Amp: fix device-tree problems

Some code to load the driver based on device-tree-overlays was missing. This is added by this patch.

According to 5713 pdf doc CLOCK_CTRL is a readonly status register, and it behaves so. Remove useless setting

sound: pcm512x-codec: Adding 352.8kHz samplerate support

sound/soc: only first codec is master in multicodec setup

When using multiple codecs, at most one codec should generate the master
clock. All codecs except the first are therefore configured for slave
mode.

Signed-off-by: Johannes Krude <johannes@krude.de>

ASoC: Fix snd_soc_get_pcm_runtime usage

Commit [1] changed the snd_soc_get_pcm_runtime to take a dai_link
pointer instead of a string. Patch up the downstream drivers to use
the modified API.

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

[1] 4468189ff3 ("ASoC: soc-core: find rtd via dai_link pointer at snd_soc_get_pcm_runtime()")

Add support for the AudioInjector.net Isolated sound card

This patch adds support for the Audio Injector Isolated sound card.

Signed-off-by: Matt Flax <flatmax@flatmax.org>

Add support for merus-amp soundcard and ma120x0p codec

Add 96KHz rate support to MA120X0P codec and make enable and mute gpio
pins optional.

Signed-off-by: AMuszkat <ariel.muszkat@gmail.com>

Fixes a problem with clock settings of HiFiBerry DAC+ADC PRO (#3545)

This patch fixes a problem of the re-calculation of
i2s-clock and -parameter settings when only the ADC is activated.

Signed-off-by: Joerg Schambacher <joerg@i2audio.com>

configs: Enable the AD193x codecs

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

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

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>

Enhances the DAC+ driver to control the optional headphone amplifier

Probes on the I2C bus for TPA6130A2, if successful, it sets DT-parameter
'status' from 'disabled' to 'okay' using change_sets to enable
the headphone control.

Signed-off-by: Joerg Schambacher joerg@i2audio.com

Update Allo Piano Dac Driver

Add unique names to the individual dac coded drivers
Remove some of the codec controls that are not used.

Signed-off-by: Paul Hermann <paul@picoreplayer.org>

Fixes an onboard clock detection problem of the PRO versions

Increasing the sleep time after clock selection to 3-4ms
allows the correct detection of all combinations of DAC+ Pro
and DAC+ADC Pro sound cards and the various PI revisions.

Signed-off-by: Joerg Schambacher <joerg@hifiberry.com>

ASoC:ma120x0p: Increase maximum sample rate to 192KHz

Change the maximum sample rate for the amplifier to
192KHz as given in the Infineon specification.

Signed-off-by: Joerg Schambacher <joerg@hifiberry.com>

ASoC: ma120x0p: Remove unnecessary const specifier

Clang warns:

  sound/soc/codecs/ma120x0p.c:891:14: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
  static const SOC_VALUE_ENUM_SINGLE_DECL(pwr_mode_ctrl,
               ^
  ./include/sound/soc.h:362:2: note: expanded from macro 'SOC_VALUE_ENUM_SINGLE_DECL'
          SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues)
          ^
  ./include/sound/soc.h:359:2: note: expanded from macro 'SOC_VALUE_ENUM_DOUBLE_DECL'
          const struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \
          ^
  1 warning generated.

SOC_VALUE_ENUM_DOUBLE_DECL already has a const specifier. Remove the duplicate
const to clean up the warning.

Fixes: 42444979e7 ("Add support for all the downstream rpi sound card drivers")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>

ASoC: bcm: allo-piano-dac-plus: Remove unnecessary const specifiers

Clang warns:

  sound/soc/bcm/allo-piano-dac-plus.c:66:14: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
  static const SOC_ENUM_SINGLE_DECL(allo_piano_mode_enum,
               ^
  ./include/sound/soc.h:355:2: note: expanded from macro 'SOC_ENUM_SINGLE_DECL'
          SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts)
          ^
  ./include/sound/soc.h:352:2: note: expanded from macro 'SOC_ENUM_DOUBLE_DECL'
          const struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \
          ^
  sound/soc/bcm/allo-piano-dac-plus.c:75:14: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
  static const SOC_ENUM_SINGLE_DECL(allo_piano_dual_mode_enum,
               ^
  ./include/sound/soc.h:355:2: note: expanded from macro 'SOC_ENUM_SINGLE_DECL'
          SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts)
          ^
  ./include/sound/soc.h:352:2: note: expanded from macro 'SOC_ENUM_DOUBLE_DECL'
          const struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \
          ^
  sound/soc/bcm/allo-piano-dac-plus.c:96:14: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
  static const SOC_ENUM_SINGLE_DECL(allo_piano_enum,
               ^
  ./include/sound/soc.h:355:2: note: expanded from macro 'SOC_ENUM_SINGLE_DECL'
          SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts)
          ^
  ./include/sound/soc.h:352:2: note: expanded from macro 'SOC_ENUM_DOUBLE_DECL'
          const struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \
          ^
  3 warnings generated.

SOC_VALUE_ENUM_DOUBLE_DECL already has a const specifier. Remove the duplicate
const specifiers to clean up the warnings.

Fixes: 42444979e7 ("Add support for all the downstream rpi sound card drivers")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>

rpi-simple-soundcard: Add Dion Audio KIWI streamer

Signed-off-by: Miquel Blauw <miquelblauw@hotmail.com>

rpi-simple-soundcard: adds definitions for the HiFiBerry AMP3 card

Uses Infineon MA120x0 amplifier and supports full sample rate of 192ksps.

Signed-off-by: Joerg Schambacher <joerg@hifiberry.com>

sound: soc: bcm: Added Sound card driver for Dacberry400 Audio card for Raspberry Pi 400

Added Sound card driver for DACberry400 Audio card.

Signed-off-by: Ashish Vara <ashishhvara@gmail.com>

ASoC:ma120x0p: Corrects the volume level display

Fixes the wrongly changed 'limiter volume' display back to -50dB minimum
and sets the correct minimum volume level to -144dB to be aligned with
the controls and display in alsamixer etc.

Signed-off-by: Joerg Schambacher <joerg@hifiberry.com>

ASoC: bcm: Fix Rpi-PROTO and audioinjector.net Pi

As of kernel 5.19 the WM8731 driver has separate I2C and SPI support
modules. Change the Kconfig definitions for the audioinjector.net Pi
and Rpi-PROTO soundcards to select SND_SOC_WM8731_I2C.

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

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

ASoC: adau1977: Add correct compatible strings

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

ASoC: bcm2835-i2s: Use phys addresses for DAI DMA

Contrary to what struct snd_dmaengine_dai_dma_data suggests, the
configuration of addresses of DMA slave interfaces should be done in
CPU physical addresses.

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

rpi sound cards: Fix Codec Zero rate switching

The Raspberry Pi Codec Zero (and IQaudIO Codec) don't notify the DA7213
codec when it needs to change PLL frequencies. As a result, audio can
be played at the wrong rate - play a 48kHz sound immediately after a
44.1kHz sound to see the effect, but in some configurations the codec
can lock into the wrong state and always get some rates wrong.

Add the necessary notification to fix the issue.

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

ASoC: dwc: Support set_bclk_ratio

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

ASoC: dwc: Add DMACR handling

Add control of the DMACR register, which is required for paced DMA
(i.e. DREQ) support.

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

ASOC: dwc: Improve DMA shutdown

Disabling the I2S interface with outstanding transfers prevents the
DMAC from shutting down, so keep it partially active after a stop.

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

ASOC: dwc: Fix 16-bit audio handling

IMO the Synopsys datasheet could be clearer in this area, but it seems
that the DMA data ports (DMATX and DMARX) expect left and right samples
in alternate writes; if a stereo pair is pushed in a single 32-bit
write, the upper half is ignored, leading to double speed audio with a
confused stereo image. Make sure the necessary changes happen by
updating the DMA configuration data in the hw_params method.

The set_bclk_ratio change was made at a time when it looked like it
could be causing an error, but I think the division of responsibilities
is clearer this way (and the kernel log clearer without the info-level
message).

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

ASoC: bcm: Remove dependency on BCM2835 I2S

These soundcard drivers don't rely on a specific I2S interface, so
remove the dependency declarations.

See: https://github.com/raspberrypi/linux-2712/issues/111

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

ASoC: bcm: audioinjector_octo: Add soundcard "owner"

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

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

Pisound: Don't export the button GPIO via sysfs GPIO class.

Signed-off-by: Giedrius Trainavičius <giedrius@blokas.io>

Pisound: Read out the SPI speed to use from the Device Tree.

Signed-off-by: Giedrius Trainavičius <giedrius@blokas.io>

ASoC: DACplus - fix 16bit sample support in clock consumer mode

The former code did not adjust the physical sample width when
in clock consumer mode and has taken the fixed 32 bit default.
This has caused the audio to be played at half its frequency due to
the fixed bclk_ratio of 64.

Signed-off-by: Joerg Schambacher <joerg@hifiberry.com>

ASoC: adds support for AMP4 Pro to the DAC Plus driver

The AMP4 Pro is a I2S master mode capable amplifier with
clean onboard clock generators.
We can share the card driver between TAS575x amplifiers
and the PCM512x DACs as they are SW compatible.
From a HW perspective though we need to limit the sample
rates to the standard audio rates to avoid running the
onboard clocks through the PLL. Using the PLL would require
even a different HW.
DAI/stream name are also set accordingly to allow the user
a convenient identification of the soundcard

Needs the pcm512x driver with TAS575x support (already in
upstream kernel).

Signed-off-by: Joerg Schambacher <joerg@hifiberry.com>

ASoC: DACplusADCPro - fix 16bit sample support in clock consumer mode

The former code did not adjust the physical sample width when in
clock consumer mode and has taken the fixed 32 bit default. This
has caused the audio to be played at half its frequency due to
the fixed bclk_ratio of 64.

Problem appears only on PI5 as on the former PIs the I2S module
did simply run at fixed 64x rate.

Signed-off-by: Joerg Schambacher <joerg@hifiberry.com>

Impliment driver support for Interlude Audio Digital Hat

Implementing driver support for
Interlude audio's WM8805 based digital hat
by leveraging existing drivers

ASOc: Add HiFiBerry DAC8X to the simple card driver

Defines the settings for the 8 channel version of the standard
DAC by overwriting the number of channels in the DAI defs.
It can run in 8ch mode only on PI5 using the 4 lane data output
of the designware I2S0 module.

Signed-off-by: j-schambacher <joerg@hifiberry.com>

ASoC: bcm: Use the correct sample width value

ALSA's concept of the physical width of a sample is how much memory it
occupies, including any padding. This not the same as the count of bits
of actual sample content. In particular, S24_LE has a width of 24 bits
but a physical width of 32 bits because there is a byte of padding with
each sample.

When calculating bclk_ratio, etc., it is width that matters, not
physical width. Correct the error that has been replicated across the
drivers for many Raspberry Pi-compatible soundcards.

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

ASoC: dwc: Correct channel count reporting

The DWC I2S driver treats the channel count register values as if they
encode a power of two (2, 4, 8, 16), but they actually encode a
multiple of 2 (2, 4, 6, 8).

Also improve the error message when asked for an unsupported number
of channels.

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

ASoC: Fix 16bit sample support for Hifiberry DACplusADC

Same issue as #5919.
'width' needs to be set independent of clocking mode.

Signed-off-by: j-schambacher <joerg@hifiberry.com>

allo-boss-dac mute output when changing parameters

Since I noticed that sometimes changing sample rates causes some digital
quirks and noises, I've changed the function to mute the output before
performing the changes and then unmute it when an error occurs or the
parameters got set.

Signed-off-by: Alessandro Marcon <marconalessandro04@gmail.com>

ASoC: bcm: Use power-of-2 bclk_ratios

The soundcard drivers originally used snd_pcm_format_physical_width,
but a later commit changed that to snd_pcm_format_width because the
in-memory sample storage width should not be a factor in determining
the bclk_ratio. However, the physical width rounds the sample bits up
to the nearest power of 2, which makes it easier to find integer clock
divisors.

Restore the old behaviour, but with an implementation that makes it
clear what is going on.

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

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

ASoC: bcm: Add "owner" info for more soundcards

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

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

ASoC: da7213: Add a set_bclk_ratio method

Following [1], it becomes harder for the CPU DAI to know the correct
BCLK ratio. We can either bake the same knowledge into the sound card
driver, or implement and use set_bclk_ratio on the codec. This commit
does the latter.

[1] commit c89e652e84 ("ASoC: da7213: Add support for mono, set
frame width to 32 when possible")

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

iqaudio-codec: Use the codec's new set_bclk_ratio

To ensure that the CPU DAI and codec agree over the BCLK ratio, impose
a fixed value of 64 on both of them.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:03 +01:00
Phil Elwell
d45c830f1b mfd: Add Raspberry Pi Sense HAT core driver
mfd: Add rpi_sense_core of compatible string

rpisense-fb: Set pseudo_pallete to prevent crash on fbcon takeover

Signed-off-by: Serge Schneider <serge@raspberrypi.com>

rpisense-fb: Add explicit fb_deferred_io_mmap hook

As of commit [1], introduced in 5.18, fbdev drivers that use
deferred IO and need mmap support must include an explicit fb_mmap
pointer to the fb_deferred_io_mmap.

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

[1] 5905585103 ("fbdev: Put mmap for deferred I/O into drivers")
2024-08-05 11:15:03 +01:00
popcornmix
fdd9749e0d Improve __copy_to_user and __copy_from_user performance
Provide a __copy_from_user that uses memcpy. On BCM2708, use
optimised memcpy/memmove/memcmp/memset implementations.

arch/arm: Add mmiocpy/set aliases for memcpy/set

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

copy_from_user: CPU_SW_DOMAIN_PAN compatibility

The downstream copy_from_user acceleration must also play nice with
CONFIG_CPU_SW_DOMAIN_PAN.

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

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

Fix copy_from_user if BCM2835_FAST_MEMCPY=n

The change which introduced CONFIG_BCM2835_FAST_MEMCPY unconditionally
changed the behaviour of arm_copy_from_user. The page pinning code
is not safe on ARMv7 if LPAE & high memory is enabled and causes
crashes which look like PTE corruption.

Make __copy_from_user_memcpy conditional on CONFIG_2835_FAST_MEMCPY=y
which is really an ARMv6 / Pi1 optimization and not necessary on newer
ARM processors.

arm: fix mmap unlocks in uaccess_with_memcpy.c

This is a regression that was added with the commit 192a4e923e as of rpi-5.8.y, since that is when the move to the mmap locking API was introduced - d8ed45c5dc

The issue is that when the patch to improve performance for the __copy_to_user and __copy_from_user functions were added for the Raspberry Pi, some of the mmaps were incorrectly mapped to write instead of read. This would cause a verity of issues, and in my case, prevent the booting of a squashfs filesystem on rpi-5.8-y and above. An example of the panic you would see from this can be seen at https://pastebin.com/raw/jBz5xCzL

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Signed-off-by: Christopher Blake <chrisrblake93@gmail.com>

arch/arm: Add __memset alias to memset_rpi.S

memset_rpi.S is an optimised memset implementation, but doesn't define
__memset (which was just added to memset.S). As a result, building
for the BCM2835 platform causes a link failure.

Add __memset as yet another alias to our common implementation.

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

arm: Fix custom rpi __memset32 and __memset64

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

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

arm: Fix annoying .eh_frame section warnings

Replace the cfi directives with the UNWIND equivalents. This prevents
the .eh_frame section from being created, eliminating the warnings.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:03 +01:00
popcornmix
423b820f0a Added Device IDs for August DVB-T 205 2024-08-05 11:15:03 +01:00
Phil Elwell
abeb09ffa7 leds: Add the "input" trigger, for pwr_led
The "input" trigger makes the associated GPIO an input.  This is to support
the Raspberry Pi PWR LED, which is driven by external hardware in normal use.

N.B. pwr_led is not available on Model A or B boards.

leds-gpio: Implement the brightness_get method

The power LED uses some clever logic that means it is driven
by a voltage measuring circuit when configured as input, otherwise
it is driven by the GPIO output value. This patch wires up the
brightness_get method for leds-gpio so that user-space can monitor
the LED value via /sys/class/gpio/led1/brightness. Using the input
trigger this returns an indication of the system power health,
otherwise it is just whatever value the trigger has written most
recently.

See: https://github.com/raspberrypi/linux/issues/1064
2024-08-05 11:15:03 +01:00
Noralf Trønnes
cee48ebb9c firmware: bcm2835: Support ARCH_BCM270x
Support booting without Device Tree.
Turn on USB power.
Load driver early because of lacking support for deferred probing
in many drivers.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

firmware: bcm2835: Don't turn on USB power

The raspberrypi-power driver is now used to turn on USB power.

This partly reverts commit:
firmware: bcm2835: Support ARCH_BCM270x

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
2024-08-05 11:15:03 +01:00
Jonathan Bell
e2448bc9a5 drivers: char: add generic gpiomem driver
Based on bcm2835-gpiomem.

We allow export of the "GPIO registers" to userspace via a chardev as
this allows for finer access control (e.g. users must be group gpio, root
not required).

This driver allows access to either rp1-gpiomem or gpiomem, depending on
which nodes are populated in devicetree.

RP1 has a different look-and-feel to BCM283x SoCs as it has split ranges
for IO controls and the parallel registered OE/IN/OUT access. To handle
this, the driver concatenates the ranges for an IO bank and the
corresponding RIO instance into a contiguous buffer.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:03 +01:00
Noralf Trønnes
06408de80d char: broadcom: Add vcio module
Add module for accessing the mailbox property channel through
/dev/vcio. Was previously in bcm2708-vcio.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

char: vcio: Add compat ioctl handling

There was no compat ioctl handler, so 32 bit userspace on a
64 bit kernel failed as IOCTL_MBOX_PROPERTY used the size
of char*.

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

char: vcio: Fail probe if rpi_firmware is not found.

Device Tree is now the only supported config mechanism, therefore
uncomment the block of code that fails the probe if the
firmware node can't be found.

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

drivers: char: vcio: 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>

char: vcio: Rewrite as a firmware node child

The old vcio driver is a simple character device that manually locates
the firmware driver. Initialising it before the firmware driver causes
a failure, and no retries are attempted.

Rewrite vcio as a platform driver that depends on a DT node for its
instantiation and the location of the firmware driver, making use of
the miscdevice framework to reduce the code size.

N.B. Using miscdevice changes the udev SUBSYSTEM string, so a change
to the companion udev rule is required in order to continue to set
the correct device permissions, e.g.:

    KERNEL="vcio", GROUP="video", MODE="0660"

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:03 +01:00
popcornmix
c67c1c25a1 char: Add broadcom char drivers back to build files
See: https://github.com/raspberrypi/linux/issues/3875
Signed-off-by: popcornmix <popcornmix@gmail.com>
2024-08-05 11:15:03 +01:00
popcornmix
3dbccf64b5 Add Chris Boot's i2c driver
i2c-bcm2708: fixed baudrate

Fixed issue where the wrong CDIV value was set for baudrates below 3815 Hz (for 250MHz bus clock).
In that case the computed CDIV value was more than 0xffff. However the CDIV register width is only 16 bits.
This resulted in incorrect setting of CDIV and higher baudrate than intended.
Example: 3500Hz -> CDIV=0x11704 -> CDIV(16bit)=0x1704 -> 42430Hz
After correction: 3500Hz -> CDIV=0x11704 -> CDIV(16bit)=0xffff -> 3815Hz
The correct baudrate is shown in the log after the cdiv > 0xffff correction.

Perform I2C combined transactions when possible

Perform I2C combined transactions whenever possible, within the
restrictions of the Broadcomm Serial Controller.

Disable DONE interrupt during TA poll

Prevent interrupt from being triggered if poll is missed and transfer
starts and finishes.

i2c: Make combined transactions optional and disabled by default

i2c: bcm2708: add device tree support

Add DT support to driver and add to .dtsi file.
Setup pins in .dts file.
i2c is disabled by default.

Signed-off-by: Noralf Tronnes <notro@tronnes.org>

bcm2708: don't register i2c controllers when using DT

The devices for the i2c controllers are in the Device Tree.
Only register devices when not using DT.

Signed-off-by: Noralf Tronnes <notro@tronnes.org>

I2C: Only register the I2C device for the current board revision

i2c_bcm2708: Fix clock reference counting

Fix grabbing lock from atomic context in i2c driver

2 main changes:
- check for timeouts in the bcm2708_bsc_setup function as indicated by this comment:
      /* poll for transfer start bit (should only take 1-20 polls) */
  This implies that the setup function can now fail so account for this everywhere it's called
- Removed the clk_get_rate call from inside the setup function as it locks a mutex and that's not ok since we call it from under a spin lock.

i2c-bcm2708: When using DT, leave the GPIO setup to pinctrl

i2c-bcm2708: Increase timeouts to allow larger transfers

Use the timeout value provided by the I2C_TIMEOUT ioctl when waiting
for completion. The default timeout is 1 second.

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

i2c-bcm2708/BCM270X_DT: Add support for I2C2

The third I2C bus (I2C2) is normally reserved for HDMI use. Careless
use of this bus can break an attached display - use with caution.

It is recommended to disable accesses by VideoCore by setting
hdmi_ignore_edid=1 or hdmi_edid_file=1 in config.txt.

The interface is disabled by default - enable using the
i2c2_iknowwhatimdoing DT parameter.

bcm2708-spi: Don't use static pin configuration with DT

Also remove superfluous error checking - the SPI framework ensures the
validity of the chip_select value.

i2c-bcm2708: Remove non-DT support

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

Set the BSC_CLKT clock streching timeout to 35ms as per SMBus specs.

Fixes i2c_bcm2708: Write to FIFO correctly - v2 (#1574)

* i2c: fix i2c_bcm2708: Clear FIFO before sending data

Make sure FIFO gets cleared before trying to send
data in case of a repeated start (COMBINED=Y).

* i2c: fix i2c_bcm2708: Only write to FIFO when not full

Check if FIFO can accept data before writing.
To avoid a peripheral read on the last iteration of a loop,
both bcm2708_bsc_fifo_fill and ~drain are changed as well.
2024-08-05 11:15:03 +01:00
Luke Wren
c588f495dc Add SMI driver
Signed-off-by: Luke Wren <wren6991@gmail.com>

MISC: bcm2835: smi: use clock manager and fix reload issues

Use clock manager instead of self-made clockmanager.

Also fix some error paths that showd up during development
(especially missing release of dma resources on rmmod)

Signed-off-by: Martin Sperl <kernel@martin.sperl.org>

bcm2835_smi: re-add dereference to fix DMA transfers

bcm2835_smi_dev: Fix handling of word-odd lengths

The read and write functions did not use the correct pointer offset
when dealing with an odd number of bytes after a DMA transfer. Also,
only handle the remaining odd bytes if the DMA transfer completed
successfully.

Submitted-by: @madimario (GitHub)
Signed-off-by: Phil Elwell <phil@raspberrypi.com>

misc: bcm2835_smi: Use proper enum types for dma_{,un}map_single()

Clang warns:

  drivers/misc/bcm2835_smi.c:692:4: warning: implicit conversion from enumeration type 'enum dma_transfer_direction' to different enumeration type 'enum dma_data_direction' [-Wenum-conversion]
                          DMA_MEM_TO_DEV);
                          ^~~~~~~~~~~~~~~
  ./include/linux/dma-mapping.h:406:66: note: expanded from macro 'dma_map_single'
  #define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, 0)
                                     ~~~~~~~~~~~~~~~~~~~~          ^
  drivers/misc/bcm2835_smi.c:705:35: warning: implicit conversion from enumeration type 'enum dma_transfer_direction' to different enumeration type 'enum dma_data_direction' [-Wenum-conversion]
                          (inst->dev, phy_addr, n_bytes, DMA_MEM_TO_DEV);
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
  ./include/linux/dma-mapping.h:407:70: note: expanded from macro 'dma_unmap_single'
  #define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, 0)
                                       ~~~~~~~~~~~~~~~~~~~~~~          ^
  drivers/misc/bcm2835_smi.c:751:12: warning: implicit conversion from enumeration type 'enum dma_transfer_direction' to different enumeration type 'enum dma_data_direction' [-Wenum-conversion]
                                                       DMA_DEV_TO_MEM);
                                                       ^~~~~~~~~~~~~~~
  ./include/linux/dma-mapping.h:406:66: note: expanded from macro 'dma_map_single'
  #define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, 0)
                                     ~~~~~~~~~~~~~~~~~~~~          ^
  drivers/misc/bcm2835_smi.c:761:50: warning: implicit conversion from enumeration type 'enum dma_transfer_direction' to different enumeration type 'enum dma_data_direction' [-Wenum-conversion]
                  dma_unmap_single(inst->dev, phy_addr, n_bytes, DMA_DEV_TO_MEM);
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
  ./include/linux/dma-mapping.h:407:70: note: expanded from macro 'dma_unmap_single'
  #define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, 0)
                                       ~~~~~~~~~~~~~~~~~~~~~~          ^
  4 warnings generated.

Use the proper enumerated type to clear up the warning. There is not
actually a bug here because the enumerated types have the same integer
value:

DMA_MEM_TO_DEV = DMA_TO_DEVICE = 1
DMA_DEV_TO_MEM = DMA_FROM_DEVICE = 2

Fixes: 93254d0f7b ("Add SMI driver")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>

bcm2835-smi: Use phys addresses for slave DMA config

Contrary to what struct snd_dmaengine_dai_dma_data suggests, the
configuration of addresses of DMA slave interfaces should be done in
CPU physical addresses.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:03 +01:00
popcornmix
8c1ea940ed vc_mem: Add vc_mem driver for querying firmware memory addresses
Signed-off-by: popcornmix <popcornmix@gmail.com>

BCM270x: Move vc_mem

Make the vc_mem module available for ARCH_BCM2835 by moving it.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

char: vc_mem: Fix up compat ioctls for 64bit kernel

compat_ioctl wasn't defined, so 32bit user/64bit kernel
always failed.
VC_MEM_IOC_MEM_PHYS_ADDR was defined with parameter size
unsigned long, so the ioctl cmd changes between sizes.

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

char: vc_mem: Fix all coding style issues.

Cleans up all checkpatch errors in vc_mem.c and vc_mem.h
No functional change to the code.

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

char: vc_mem: Delete dead code

There are no error exists once device_create has succeeded, and
therefore no need to call device_destroy from vc_mem_init.

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

char: broadcom: vc_mem: Fix preprocessor conditional

Signed-off-by: Alexander Winkowski <dereference23@outlook.com>

vc_mem: Add the DMA memcpy support from bcm2708_fb

bcm2708_fb is disabled by the vc4-kms-v3d overlay, which means that the
DMA memcpy support it provides is not available to allow vclog to read
the VC logs from the top 16MB on Pi 2 and Pi 3. Add the code to the
vc_mem driver, which will still be enabled.

It ought to be possible to do a proper DMA_MEM_TO_MEM copy via the
generic DMA customer API, but that can be a later step.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:02 +01:00
Phil Elwell
f06531fb6c Adding bcm2835-sdhost driver, and an overlay to enable it
BCM2835 has two SD card interfaces. This driver uses the other one.

bcm2835-sdhost: Error handling fix, and code clarification

bcm2835-sdhost: Adding overclocking option

Allow a different clock speed to be substitued for a requested 50MHz.
This option is exposed using the "overclock_50" DT parameter.
Note that the sdhost interface is restricted to integer divisions of
core_freq, and the highest sensible option for a core_freq of 250MHz
is 84 (250/3 = 83.3MHz), the next being 125 (250/2) which is much too
high.

Use at your own risk.

bcm2835-sdhost: Round up the overclock, so 62 works for 62.5Mhz

Also only warn once for each overclock setting.

bcm2835-sdhost: Improve error handling and recovery

1) Expose the hw_reset method to the MMC framework, removing many
   internal calls by the driver.

2) Reduce overclock setting on error.

3) Increase timeout to cope with high capacity cards.

4) Add properties and parameters to control pio_limit and debug.

5) Reduce messages at probe time.

bcm2835-sdhost: Further improve overclock back-off

bcm2835-sdhost: Clear HBLC for PIO mode

Also update pio_limit default in overlay README.

bcm2835-sdhost: Add the ERASE capability

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

bcm2835-sdhost: Ignore CRC7 for MMC CMD1

It seems that the sdhost interface returns CRC7 errors for CMD1,
which is the MMC-specific SEND_OP_COND. Returning these errors to
the MMC layer causes a downward spiral, but ignoring them seems
to be harmless.

bcm2835-mmc/sdhost: Remove ARCH_BCM2835 differences

The bcm2835-mmc driver (and -sdhost driver that copied from it)
contains code to handle SDIO interrupts in a threaded interrupt
handler rather than waking the MMC framework thread. The change
follows a patch from Russell King that adds the facility as the
preferred way of working.

However, the new code path is only present in ARCH_BCM2835
builds, which I have taken to be a way of testing the waters
rather than making the change across the board; I can't see
any technical reason why it wouldn't be enabled for MACH_BCM270X
builds. So this patch standardises on the ARCH_BCM2835 code,
removing the old code paths.

bcm2835-sdhost: Don't log timeout errors unless debug=1

The MMC card-discovery process generates timeouts. This is
expected behaviour, so reporting it to the user serves no purpose.
Suppress the reporting of timeout errors unless the debug flag
is on.

bcm2835-sdhost: Add workaround for odd behaviour on some cards

For reasons not understood, the sdhost driver fails when reading
sectors very near the end of some SD cards. The problem could
be related to the similar issue that reading the final sector
of any card as part of a multiple read never completes, and the
workaround is an extension of the mechanism introduced to solve
that problem which ensures those sectors are always read singly.

bcm2835-sdhost: Major revision

This is a significant revision of the bcm2835-sdhost driver. It
improves on the original in a number of ways:

1) Through the use of CMD23 for reads it appears to avoid problems
   reading some sectors on certain high speed cards.
2) Better atomicity to prevent crashes.
3) Higher performance.
4) Activity logging included, for easier diagnosis in the event
   of a problem.

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

bcm2835-sdhost: Restore ATOMIC flag to PIO sg mapping

Allocation problems have been seen in a wireless driver, and
this is the only change which might have been responsible.

SQUASH: bcm2835-sdhost: Only claim one DMA channel

With both MMC controllers enabled there are few DMA channels left. The
bcm2835-sdhost driver only uses DMA in one direction at a time, so it
doesn't need to claim two channels.

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

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

bcm2835-sdhost: Workaround for "slow" sectors

Some cards have been seen to cause timeouts after certain sectors are
read. This workaround enforces a minimum delay between the stop after
reading one of those sectors and a subsequent data command.

Using CMD23 (SET_BLOCK_COUNT) avoids this problem, so good cards will
not be penalised by this workaround.

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

bcm2835-sdhost: Firmware manages the clock divisor

The bcm2835-sdhost driver hands control of the CDIV clock divisor
register to matching firmware, allowing it to adjust to a changing
core clock. This removes the need to use the performance governor or
to enable io_is_busy on the on-demand governor in order to get the
best SD performance.

N.B. As SD clocks must be an integer divisor of the core clock, it is
possible that the SD clock for "turbo" mode can be different (even
lower) than "normal" mode.

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

bcm2835-sdhost: Reset the clock in task context

Since reprogramming the clock can now involve a round-trip to the
firmware it must not be done at atomic context, and a tasklet
is not a task.

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

bcm2835-sdhost: Don't exit cmd wait loop on error

The FAIL flag can be set in the CMD register before command processing
is complete, leading to spurious "failed to complete" errors. This has
the effect of promoting harmless CRC7 errors during CMD1 processing
into errors that can delay and even prevent booting.

Also:
1) Convert the last KERN_ERROR message in the register dumping to
   KERN_INFO.
2) Remove an unnecessary reset call from  bcm2835_sdhost_add_host.

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

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

bcm2835-sdhost: mmc_card_blockaddr fix

Get the definition of mmc_card_blockaddr from drivers/mmc/core/card.h.

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

bcm2835-sdhost: New timer API

mmc: bcm2835-sdhost: Support underclocking

Support underclocking of the SD bus in two ways:
1. using the max-frequency DT property (which currently has no DT
   parameter), and
2. using the exiting sd_overclock parameter.

The two methods differ slightly - in the former the MMC subsystem is
aware of the underclocking, while in the latter it isn't - but the
end results should be the same.

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

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

mmc: bcm2835-sdhost: Add include

highmem.h (needed for kmap_atomic) is pulled in by one of the other
include files, but only with some CONFIG settings. Make the inclusion
explicit to cater for cases where the CONFIG setting is absent.

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

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

mmc/bcm2835-sdhost: Recover from MMC_SEND_EXT_CSD

If the user issues an "mmc extcsd read", the SD controller receives
what it thinks is a SEND_IF_COND command with an unexpected data block.
The resulting operations leave the FSM stuck in READWAIT, a state which
persists until the MMC framework resets the controller, by which point
the root filesystem is likely to have been unmounted.

A less heavyweight solution is to detect the condition and nudge the
FSM by asserting the (self-clearing) FORCE_DATA_MODE bit.

N.B. This workaround was essentially discovered by accident and without
a full understanding the inner workings of the controller, so it is
fortunate that the "fix" only modifies error paths.

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

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

mmc: bcm2835-sdhost: Fix warnings on arm64

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

bcm2835-sdhost: Allow for sg entries that cross pages

The dma_complete handling code calculates a virtual address for a page
then adds an offset, but if the offset is more than a page and HIGHMEM
is in use then the summed address could be in an unmapped (or just
incorrect) page.

The upstream SDHOST driver allows for this possibility - copy the code
that does so.

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

bcm2835-sdhost: Fix DMA channel leak on error/remove

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

mmc: bcm2835-sdhost: Support 64-bit physical addresses

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

bcm2835-sdhost: Replace obsolete struct timeval

struct timeval has been retired due to the impending linux 32-bit tv_sec
rollover (only 18 years to go) - timespec64 is the obvious replacement.

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

mmc: sdhost: Pass DT pointer to rpi_firmware_get

Using the rpi_firmware API as intended allows proper reference counting
of the firmware device and means we can remove a downstream patch to
the firmware driver.

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

bcm2835-sdhost: Use DT to configure logging

Retrieve the system timer base address directly from DT.

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

bcm2835-sdhost: Use phys addresses for slave DMA config

Contrary to what struct snd_dmaengine_dai_dma_data suggests, the
configuration of addresses of DMA slave interfaces should be done in
CPU physical addresses.

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

bcm2835-sdhost: Fail gracefully with bad dtb

The logging timestamps depend on the existence of a bcm2835-system-timer
node. If this node doesn't exist, leave the logging disabled rather than
crashing.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:02 +01:00
Jonathan Bell
214539ef02 mmc: block: Don't do single-sector reads during recovery
See https://github.com/raspberrypi/linux/issues/5019

If an SD card has degraded performance such that IO operations time out
then the MMC block layer will leak SG DMA mappings in the swiotlb during
recovery. It retries the same SG and this causes the leak, as it is
mapped twice - once in sdhci_pre_req() and again during single-block
reads in sdhci_prepare_data().

Resetting the card (including power-cycling if a regulator for vmmc is
present) ought to be enough to recover a stuck state, so for now don't
try single-block reads in the recovery path.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:02 +01:00
gellert
be587b3f24 MMC: added alternative MMC driver
mmc: Disable CMD23 transfers on all cards

Pending wire-level investigation of these types of transfers
and associated errors on bcm2835-mmc, disable for now. Fallback of
CMD18/CMD25 transfers will be used automatically by the MMC layer.

Reported/Tested-by: Gellert Weisz <gellert@raspberrypi.org>

mmc: bcm2835-mmc: enable DT support for all architectures

Both ARCH_BCM2835 and ARCH_BCM270x are built with OF now.
Enable Device Tree support for all architectures.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

mmc: bcm2835-mmc: fix probe error handling

Probe error handling is broken in several places.
Simplify error handling by using device managed functions.
Replace pr_{err,info} with dev_{err,info}.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

bcm2835-mmc: Add locks when accessing sdhost registers

bcm2835-mmc: Add range of debug options for slowing things down

bcm2835-mmc: Add option to disable some delays

bcm2835-mmc: Add option to disable MMC_QUIRK_BLK_NO_CMD23

bcm2835-mmc: Default to disabling MMC_QUIRK_BLK_NO_CMD23

bcm2835-mmc: Adding overclocking option

Allow a different clock speed to be substitued for a requested 50MHz.
This option is exposed using the "overclock_50" DT parameter.
Note that the mmc interface is restricted to EVEN integer divisions of
250MHz, and the highest sensible option is 63 (250/4 = 62.5), the
next being 125 (250/2) which is much too high.

Use at your own risk.

bcm2835-mmc: Round up the overclock, so 62 works for 62.5Mhz

Also only warn once for each overclock setting.

mmc: bcm2835-mmc: Make available on ARCH_BCM2835

Make the bcm2835-mmc driver available for use on ARCH_BCM2835.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

BCM270x_DT: add bcm2835-mmc entry

Add Device Tree entry for bcm2835-mmc.
In non-DT mode, don't add the device in the board file.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

bcm2835-mmc: Don't overwrite MMC capabilities from DT

bcm2835-mmc: Don't override bus width capabilities from devicetree

Take out the force setting of the MMC_CAP_4_BIT_DATA host capability
so that the result read from devicetree via mmc_of_parse() is
preserved.

bcm2835-mmc: Only claim one DMA channel

With both MMC controllers enabled there are few DMA channels left. The
bcm2835-mmc driver only uses DMA in one direction at a time, so it
doesn't need to claim two channels.

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

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

bcm2835-mmc: New timer API

mmc: bcm2835-mmc: Support underclocking

Support underclocking of the SD bus using the max-frequency DT property
(which currently has no DT parameter). The sd_overclock parameter
already provides another way to achieve the same thing which should be
equivalent in end result, but it is a bug not to support max-frequency
as well.

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

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

mmc/bcm2835: Recover from MMC_SEND_EXT_CSD

If the user issues an "mmc extcsd read", the SD controller receives
what it thinks is a SEND_IF_COND command with an unexpected data block.
The resulting operations leave the FSM stuck in READWAIT, a state which
persists until the MMC framework resets the controller, by which point
the root filesystem is likely to have been unmounted.

A less heavyweight solution is to detect the condition and nudge the
FSM by asserting the (self-clearing) FORCE_DATA_MODE bit.

N.B. This workaround was essentially discovered by accident and without
a full understanding the inner workings of the controller, so it is
fortunate that the "fix" only modifies error paths.

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

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

bcm2835-mmc: Fix DMA channel leak

The BCM2835 MMC host driver requests a DMA channel on probe but neglects
to release the channel in the probe error path and on driver unbind.

I'm seeing this happen on every boot of the Compute Module 3: On first
driver probe, DMA channel 2 is allocated and then leaked with a "could
not get clk, deferring probe" message. On second driver probe, channel 4
is allocated.

Fix it.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: Frank Pavlic <f.pavlic@kunbus.de>

bcm2835-mmc: Fix struct mmc_host leak on probe

The BCM2835 MMC host driver requests the bus address of the host's
register map on probe.  If that fails, the driver leaks the struct
mmc_host allocated earlier.

Fix it.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: Frank Pavlic <f.pavlic@kunbus.de>

bcm2835-mmc: Fix duplicate free_irq() on remove

The BCM2835 MMC host driver requests its interrupt as a device-managed
resource, so the interrupt is automatically freed after the driver is
unbound.

However on driver unbind, bcm2835_mmc_remove() frees the interrupt
explicitly to avoid invocation of the interrupt handler after driver
structures have been torn down.

The interrupt is thus freed twice, leading to a WARN splat in
__free_irq().  Fix by not requesting the interrupt as a device-managed
resource.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: Frank Pavlic <f.pavlic@kunbus.de>

bcm2835-mmc: Handle mmc_add_host() errors

The BCM2835 MMC host driver calls mmc_add_host() but doesn't check its
return value.  Errors occurring in that function are therefore not
handled.  Fix it.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: Frank Pavlic <f.pavlic@kunbus.de>

bcm2835-mmc: Deduplicate reset of driver data on remove

The BCM2835 MMC host driver sets the device's driver data pointer to
NULL on ->remove() even though the driver core subsequently does the
same in __device_release_driver().  Drop the duplicate assignment.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: Frank Pavlic <f.pavlic@kunbus.de>

bcm2835_mmc: Remove vestigial threaded IRQ

With SDIO processing now managed by the MMC framework with a
workqueue, the bcm2835_mmc driver no longer needs a threaded
IRQ.

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

Add missing dma_unmap_sg calls to free relevant swiotlb bounce buffers.
This prevents DMA leaks.

Signed-off-by: Yaroslav Rosomakho <yaroslavros@gmail.com>

Limit max_req_size under arm64 (or any other platform that uses swiotlb) to prevent potential buffer overflow due to bouncing.

Signed-off-by: Yaroslav Rosomakho <yaroslavros@gmail.com>

mmc: sdhci: Silence MMC warnings

When the MMC isn't plugged in, the driver will spam the console which is
pretty annoying when using NFS.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>

mmc: sdhci-iproc: Fix vmmc regulators on iProc

The Linux support for controlling card power via regulators appears to
be contentious. I would argue that the default behaviour is contrary to
the SDHCI spec - turning off the power writes a reserved value to the
SD Bus Voltage Select field of the Power Control Register, which
seems to kill the Arasan/iProc controller - but fortunately there is a
hook in sdhci_ops to override the behaviour. Borrow the implementation
from sdhci_arasan_set_power.

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

bcm2835-mmc: uninitialized_var is no more

Revert "mmc: sdhci-iproc: Fix vmmc regulators on iProc"

This reverts commit aed19399a0.

Commit 6c92ae1e45 ("mmc: sdhci: Introduce sdhci_set_power_and_bus_voltage()")
introduced a generic helper that does the same thing so use that instead in
the following commit.

Signed-off-by: Juerg Haefliger <juergh@canonical.com>

mmc: sdhci-iproc: Fix vmmc regulators (pre-bcm2711)

The Linux support for controlling card power via regulators appears to
be contentious. I would argue that the default behaviour is contrary to
the SDHCI spec - turning off the power writes a reserved value to the
SD Bus Voltage Select field of the Power Control Register, which
seems to kill the Arasan/iProc controller - but fortunately there is a
hook in sdhci_ops to override the behaviour.

Signed-off-by: Juerg Haefliger <juergh@canonical.com>
Signed-off-by: Phil Elwell <phil@raspberrypi.com>

bcm2835-mmc: Honor return value of mmc_of_parse()

bcm2835_mmc_probe() ignores errors returned by mmc_of_parse() and in
particular ignores -EPROBE_DEFER, which may be returned if the power
sequencing driver configured in the devicetree is compiled as a module.

The user-visible result is that access to the SDIO device fails because
its power sequencing requirements have not been observed.  Fix it.

Signed-off-by: Lukas Wunner <lukas@wunner.de>

bcm2835-mmc: Use phys addresses for slave DMA config

Contrary to what struct snd_dmaengine_dai_dma_data suggests, the
configuration of addresses of DMA slave interfaces should be done in
CPU physical addresses.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:02 +01:00
Florian Meier
05aee67a44 dmaengine: Add support for BCM2708
Add support for DMA controller of BCM2708 as used in the Raspberry Pi.
Currently it only supports cyclic DMA.

Signed-off-by: Florian Meier <florian.meier@koalo.de>

dmaengine: expand functionality by supporting scatter/gather transfers sdhci-bcm2708 and dma.c: fix for LITE channels

DMA: fix cyclic LITE length overflow bug

dmaengine: bcm2708: Remove chancnt affectations

Mirror bcm2835-dma.c commit 9eba5536a7:
chancnt is already filled by dma_async_device_register, which uses the channel
list to know how much channels there is.

Since it's already filled, we can safely remove it from the drivers' probe
function.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

dmaengine: bcm2708: overwrite dreq only if it is not set

dreq is set when the DMA channel is fetched from Device Tree.
slave_id is set using dmaengine_slave_config().
Only overwrite dreq with slave_id if it is not set.

dreq/slave_id in the cyclic DMA case is not touched, because I don't
have hardware to test with.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

dmaengine: bcm2708: do device registration in the board file

Don't register the device in the driver. Do it in the board file.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

dmaengine: bcm2708: don't restrict DT support to ARCH_BCM2835

Both ARCH_BCM2835 and ARCH_BCM270x are built with OF now.
Add Device Tree support to the non ARCH_BCM2835 case.
Use the same driver name regardless of architecture.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

BCM270x_DT: add bcm2835-dma entry

Add Device Tree entry for bcm2835-dma.
The entry doesn't contain any resources since they are handled
by the arch/arm/mach-bcm270x/dma.c driver.
In non-DT mode, don't add the device in the board file.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

bcm2708-dmaengine: Add debug options

BCM270x: Add memory and irq resources to dmaengine device and DT

Prepare for merging of the legacy DMA API arch driver dma.c
with bcm2708-dmaengine by adding memory and irq resources both
to platform file device and Device Tree node.
Don't use BCM_DMAMAN_DRIVER_NAME so we don't have to include mach/dma.h

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

dmaengine: bcm2708: Merge with arch dma.c driver and disable dma.c

Merge the legacy DMA API driver with bcm2708-dmaengine.
This is done so we can use bcm2708_fb on ARCH_BCM2835 (mailbox
driver is also needed).

Changes to the dma.c code:
- Use BIT() macro.
- Cutdown some comments to one line.
- Add mutex to vc_dmaman and use this, since the dev lock is locked
  during probing of the engine part.
- Add global g_dmaman variable since drvdata is used by the engine part.
- Restructure for readability:
  vc_dmaman_chan_alloc()
  vc_dmaman_chan_free()
  bcm_dma_chan_free()
- Restructure bcm_dma_chan_alloc() to simplify error handling.
- Use device irq resources instead of hardcoded bcm_dma_irqs table.
- Remove dev_dmaman_register() and code it directly.
- Remove dev_dmaman_deregister() and code it directly.
- Simplify bcm_dmaman_probe() using devm_* functions.
- Get dmachans from DT if available.
- Keep 'dma.dmachans' module argument name for backwards compatibility.

Make it available on ARCH_BCM2835 as well.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

dmaengine: bcm2708: set residue_granularity field

bcm2708-dmaengine supports residue reporting at burst level
but didn't report this via the residue_granularity field.

Without this field set properly we get playback issues with I2S cards.

dmaengine: bcm2708-dmaengine: Fix memory leak when stopping a running transfer

bcm2708-dmaengine: Use more DMA channels (but not 12)

1) Only the bcm2708_fb drivers uses the legacy DMA API, and
it requires a BULK-capable channel, so all other types
(FAST, NORMAL and LITE) can be made available to the regular
DMA API.

2) DMA channels 11-14 share an interrupt. The driver can't
handle this, so don't use channels 12-14 (12 was used, probably
because it appears to have an interrupt, but in reality that
interrupt is for activity on ANY channel). This may explain
a lockup encountered when running out of DMA channels.

The combined effect of this patch is to leave 7 DMA channels
available + channel 0 for bcm2708_fb via the legacy API.

See: https://github.com/raspberrypi/linux/issues/1110
     https://github.com/raspberrypi/linux/issues/1108

dmaengine: bcm2708: Make legacy API available for bcm2835-dma

bcm2708_fb uses the legacy DMA API, so in order to start using
bcm2835-dma, bcm2835-dma has to support the legacy API. Make this
possible by exporting bcm_dmaman_probe() and bcm_dmaman_remove().

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

dmaengine: bcm2708: Change DT compatible string

Both bcm2835-dma and bcm2708-dmaengine have the same compatible string.
So change compatible to "brcm,bcm2708-dma".

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

dmaengine: bcm2708: Remove driver but keep legacy API

Dropping non-DT support means we don't need this driver,
but we still need the legacy DMA API.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

bcm2708-dmaengine - Fix arm64 portability/build issues

dma-bcm2708: Fix module compilation of CONFIG_DMA_BCM2708

bcm2708-dmaengine.c defines functions like bcm_dma_start which are
defined as well in dma-bcm2708.h as inline versions when
CONFIG_DMA_BCM2708 is not defined. This works fine when
CONFIG_DMA_BCM2708 is built in, but when it is selected as module build
fails with redefinition errors because in the build system when
CONFIG_DMA_BCM2708 is selected as module, the macro becomes
CONFIG_DMA_BCM2708_MODULE.

This patch makes the header use CONFIG_DMA_BCM2708_MODULE too when
available.

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

Signed-off-by: Andrei Gherzan <andrei@gherzan.com>

bcm2708-dmaengine: Use platform_get_irq

The platform driver framework no longer creates IRQ resources for
platform devices because they are expected to use platform_get_irq.
This causes the bcm2808_fb acceleration to fail.

Fix the problem by calling platform_get_irq as intended.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:02 +01:00
popcornmix
70191f2a12 bcm2708_fb: Add framebuffer driver
Signed-off-by: popcornmix <popcornmix@gmail.com>

bcm2708_fb : Implement blanking support using the mailbox property interface

bcm2708_fb: Add pan and vsync controls

bcm2708_fb: DMA acceleration for fb_copyarea

Based on http://www.raspberrypi.org/phpBB3/viewtopic.php?p=62425#p62425
Also used Simon's dmaer_master module as a reference for tweaking DMA
settings for better performance.

For now busylooping only. IRQ support might be added later.
With non-overclocked Raspberry Pi, the performance is ~360 MB/s
for simple copy or ~260 MB/s for two-pass copy (used when dragging
windows to the right).

In the case of using DMA channel 0, the performance improves
to ~440 MB/s.

For comparison, VFP optimized CPU copy can only do ~114 MB/s in
the same conditions (hindered by reading uncached source buffer).

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>

bcm2708_fb: report number of dma copies

Add a counter (exported via debugfs) reporting the
number of dma copies that the framebuffer driver
has done, in order to help evaluate different
optimization strategies.

Signed-off-by: Luke Diamand <luked@broadcom.com>

bcm2708_fb: use IRQ for DMA copies

The copyarea ioctl() uses DMA to speed things along. This
was busy-waiting for completion. This change supports using
an interrupt instead for larger transfers. For small
transfers, busy-waiting is still likely to be faster.

Signed-off-by: Luke Diamand <luke@diamand.org>

bcm2708: Make ioctl logging quieter

video: fbdev: bcm2708_fb: Don't panic on error

No need to panic the kernel if the video driver fails.
Just print a message and return an error.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

fbdev: bcm2708_fb: Add ARCH_BCM2835 support

Add Device Tree support.
Pass the device to dma_alloc_coherent() in order to get the
correct bus address on ARCH_BCM2835.
Use the new DMA legacy API header file.
Including <mach/platform.h> is not necessary.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

BCM270x_DT: Add bcm2708-fb device

Add bcm2708-fb to Device Tree and don't add the
platform device when booting in DT mode.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

Cleanup of bcm2708_fb file to kernel coding standards

Some minor change to function - remove a use of
in_atomic, plus replacing various debug messages
that manually specify the function name with
("%s",.__func__)

Signed-off-by: James Hughes <james.hughes@raspberrypi.org>

video: bcm2708_fb: Try allocating on the ARM and passing to VPU

Currently the VPU allocates the contiguous buffer for the
framebuffer.
Try an alternate path first where we use dma_alloc_coherent
and pass the buffer to the VPU. Should the VPU firmware not
support that path, then free the buffer and revert to the
old behaviour of using the VPU allocation.

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

Pulled in the multi frame buffer support from the Pi3 repo

fbdev: add FBIOCOPYAREA ioctl

Based on the patch authored by Ali Gholami Rudi at
    https://lkml.org/lkml/2009/7/13/153

Provide an ioctl for userspace applications, but only if this operation
is hardware accelerated (otherwide it does not make any sense).

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>

bcm2708_fb: Add ioctl for reading gpu memory through dma

video: bcm2708_fb: Add compat_ioctl support.

When using a 64 bit kernel with 32 bit userspace we need
compat ioctl handling for FBIODMACOPY as one of the
parameters is a pointer.

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

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>

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>

bcm2708_fb: Fix a build warning

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:02 +01:00
popcornmix
9392b1acb8 Add dwc_otg driver
Signed-off-by: popcornmix <popcornmix@gmail.com>

usb: dwc: fix lockdep false positive

Signed-off-by: Kari Suvanto <karis79@gmail.com>

usb: dwc: fix inconsistent lock state

Signed-off-by: Kari Suvanto <karis79@gmail.com>

Add FIQ patch to dwc_otg driver. Enable with dwc_otg.fiq_fix_enable=1. Should give about 10% more ARM performance.
Thanks to Gordon and Costas

Avoid dynamic memory allocation for channel lock in USB driver. Thanks ddv2005.

Add NAK holdoff scheme. Enabled by default, disable with dwc_otg.nak_holdoff_enable=0. Thanks gsh

Make sure we wait for the reset to finish

dwc_otg: fix bug in dwc_otg_hcd.c resulting in silent kernel
	 memory corruption, escalating to OOPS under high USB load.

dwc_otg: Fix unsafe access of QTD during URB enqueue

In dwc_otg_hcd_urb_enqueue during qtd creation, it was possible that the
transaction could complete almost immediately after the qtd was assigned
to a host channel during URB enqueue, which meant the qtd pointer was no
longer valid having been completed and removed. Usually, this resulted in
an OOPS during URB submission. By predetermining whether transactions
need to be queued or not, this unsafe pointer access is avoided.

This bug was only evident on the Pi model A where a device was attached
that had no periodic endpoints (e.g. USB pendrive or some wlan devices).

dwc_otg: Fix incorrect URB allocation error handling

If the memory allocation for a dwc_otg_urb failed, the kernel would OOPS
because for some reason a member of the *unallocated* struct was set to
zero. Error handling changed to fail correctly.

dwc_otg: fix potential use-after-free case in interrupt handler

If a transaction had previously aborted, certain interrupts are
enabled to track error counts and reset where necessary. On IN
endpoints the host generates an ACK interrupt near-simultaneously
with completion of transfer. In the case where this transfer had
previously had an error, this results in a use-after-free on
the QTD memory space with a 1-byte length being overwritten to
0x00.

dwc_otg: add handling of SPLIT transaction data toggle errors

Previously a data toggle error on packets from a USB1.1 device behind
a TT would result in the Pi locking up as the driver never handled
the associated interrupt. Patch adds basic retry mechanism and
interrupt acknowledgement to cater for either a chance toggle error or
for devices that have a broken initial toggle state (FT8U232/FT232BM).

dwc_otg: implement tasklet for returning URBs to usbcore hcd layer

The dwc_otg driver interrupt handler for transfer completion will spend
a very long time with interrupts disabled when a URB is completed -
this is because usb_hcd_giveback_urb is called from within the handler
which for a USB device driver with complicated processing (e.g. webcam)
will take an exorbitant amount of time to complete. This results in
missed completion interrupts for other USB packets which lead to them
being dropped due to microframe overruns.

This patch splits returning the URB to the usb hcd layer into a
high-priority tasklet. This will have most benefit for isochronous IN
transfers but will also have incidental benefit where multiple periodic
devices are active at once.

dwc_otg: fix NAK holdoff and allow on split transactions only

This corrects a bug where if a single active non-periodic endpoint
had at least one transaction in its qh, on frnum == MAX_FRNUM the qh
would get skipped and never get queued again. This would result in
a silent device until error detection (automatic or otherwise) would
either reset the device or flush and requeue the URBs.

Additionally the NAK holdoff was enabled for all transactions - this
would potentially stall a HS endpoint for 1ms if a previous error state
enabled this interrupt and the next response was a NAK. Fix so that
only split transactions get held off.

dwc_otg: Call usb_hcd_unlink_urb_from_ep with lock held in completion handler

usb_hcd_unlink_urb_from_ep must be called with the HCD lock held.  Calling it
asynchronously in the tasklet was not safe (regression in
c4564d4a1a).

This change unlinks it from the endpoint prior to queueing it for handling in
the tasklet, and also adds a check to ensure the urb is OK to be unlinked
before doing so.

NULL pointer dereference kernel oopses had been observed in usb_hcd_giveback_urb
when a USB device was unplugged/replugged during data transfer.  This effect
was reproduced using automated USB port power control, hundreds of replug
events were performed during active transfers to confirm that the problem was
eliminated.

USB fix using a FIQ to implement split transactions

This commit adds a FIQ implementaion that schedules
the split transactions using a FIQ so we don't get
held off by the interrupt latency of Linux

dwc_otg: fix device attributes and avoid kernel warnings on boot

dcw_otg: avoid logging function that can cause panics

See: https://github.com/raspberrypi/firmware/issues/21
Thanks to cleverca22 for fix

dwc_otg: mask correct interrupts after transaction error recovery

The dwc_otg driver will unmask certain interrupts on a transaction
that previously halted in the error state in order to reset the
QTD error count. The various fine-grained interrupt handlers do not
consider that other interrupts besides themselves were unmasked.

By disabling the two other interrupts only ever enabled in DMA mode
for this purpose, we can avoid unnecessary function calls in the
IRQ handler. This will also prevent an unneccesary FIQ interrupt
from being generated if the FIQ is enabled.

dwc_otg: fiq: prevent FIQ thrash and incorrect state passing to IRQ

In the case of a transaction to a device that had previously aborted
due to an error, several interrupts are enabled to reset the error
count when a device responds. This has the side-effect of making the
FIQ thrash because the hardware will generate multiple instances of
a NAK on an IN bulk/interrupt endpoint and multiple instances of ACK
on an OUT bulk/interrupt endpoint. Make the FIQ mask and clear the
associated interrupts.

Additionally, on non-split transactions make sure that only unmasked
interrupts are cleared. This caused a hard-to-trigger but serious
race condition when you had the combination of an endpoint awaiting
error recovery and a transaction completed on an endpoint - due to
the sequencing and timing of interrupts generated by the dwc_otg core,
it was possible to confuse the IRQ handler.

Fix function tracing

dwc_otg: whitespace cleanup in dwc_otg_urb_enqueue

dwc_otg: prevent OOPSes during device disconnects

The dwc_otg_urb_enqueue function is thread-unsafe. In particular the
access of urb->hcpriv, usb_hcd_link_urb_to_ep, dwc_otg_urb->qtd and
friends does not occur within a critical section and so if a device
was unplugged during activity there was a high chance that the
usbcore hub_thread would try to disable the endpoint with partially-
formed entries in the URB queue. This would result in BUG() or null
pointer dereferences.

Fix so that access of urb->hcpriv, enqueuing to the hardware and
adding to usbcore endpoint URB lists is contained within a single
critical section.

dwc_otg: prevent BUG() in TT allocation if hub address is > 16

A fixed-size array is used to track TT allocation. This was
previously set to 16 which caused a crash because
dwc_otg_hcd_allocate_port would read past the end of the array.

This was hit if a hub was plugged in which enumerated as addr > 16,
due to previous device resets or unplugs.

Also add #ifdef FIQ_DEBUG around hcd->hub_port_alloc[], which grows
to a large size if 128 hub addresses are supported. This field is
for debug only for tracking which frame an allocate happened in.

dwc_otg: make channel halts with unknown state less damaging

If the IRQ received a channel halt interrupt through the FIQ
with no other bits set, the IRQ would not release the host
channel and never complete the URB.

Add catchall handling to treat as a transaction error and retry.

dwc_otg: fiq_split: use TTs with more granularity

This fixes certain issues with split transaction scheduling.

- Isochronous multi-packet OUT transactions now hog the TT until
  they are completed - this prevents hubs aborting transactions
  if they get a periodic start-split out-of-order
- Don't perform TT allocation on non-periodic endpoints - this
  allows simultaneous use of the TT's bulk/control and periodic
  transaction buffers

This commit will mainly affect USB audio playback.

dwc_otg: fix potential sleep while atomic during urb enqueue

Fixes a regression introduced with eb1b482a. Kmalloc called from
dwc_otg_hcd_qtd_add / dwc_otg_hcd_qtd_create did not always have
the GPF_ATOMIC flag set. Force this flag when inside the larger
critical section.

dwc_otg: make fiq_split_enable imply fiq_fix_enable

Failing to set up the FIQ correctly would result in
"IRQ 32: nobody cared" errors in dmesg.

dwc_otg: prevent crashes on host port disconnects

Fix several issues resulting in crashes or inconsistent state
if a Model A root port was disconnected.

- Clean up queue heads properly in kill_urbs_in_qh_list by
  removing the empty QHs from the schedule lists
- Set the halt status properly to prevent IRQ handlers from
  using freed memory
- Add fiq_split related cleanup for saved registers
- Make microframe scheduling reclaim host channels if
  active during a disconnect
- Abort URBs with -ESHUTDOWN status response, informing
  device drivers so they respond in a more correct fashion
  and don't try to resubmit URBs
- Prevent IRQ handlers from attempting to handle channel
  interrupts if the associated URB was dequeued (and the
  driver state was cleared)

dwc_otg: prevent leaking URBs during enqueue

A dwc_otg_urb would get leaked if the HCD enqueue function
failed for any reason. Free the URB at the appropriate points.

dwc_otg: Enable NAK holdoff for control split transactions

Certain low-speed devices take a very long time to complete a
data or status stage of a control transaction, producing NAK
responses until they complete internal processing - the USB2.0
spec limit is up to 500mS. This causes the same type of interrupt
storm as seen with USB-serial dongles prior to c8edb238.

In certain circumstances, usually while booting, this interrupt
storm could cause SD card timeouts.

dwc_otg: Fix for occasional lockup on boot when doing a USB reset

dwc_otg: Don't issue traffic to LS devices in FS mode

Issuing low-speed packets when the root port is in full-speed mode
causes the root port to stop responding. Explicitly fail when
enqueuing URBs to a LS endpoint on a FS bus.

Fix ARM architecture issue with local_irq_restore()

If local_fiq_enable() is called before a local_irq_restore(flags) where
the flags variable has the F bit set, the FIQ will be erroneously disabled.

Fixup arch_local_irq_restore to avoid trampling the F bit in CPSR.

Also fix some of the hacks previously implemented for previous dwc_otg
incarnations.

dwc_otg: fiq_fsm: Base commit for driver rewrite

This commit removes the previous FIQ fixes entirely and adds fiq_fsm.

This rewrite features much more complete support for split transactions
and takes into account several OTG hardware bugs. High-speed
isochronous transactions are also capable of being performed by fiq_fsm.

All driver options have been removed and replaced with:
  - dwc_otg.fiq_enable (bool)
  - dwc_otg.fiq_fsm_enable (bool)
  - dwc_otg.fiq_fsm_mask (bitmask)
  - dwc_otg.nak_holdoff (unsigned int)

Defaults are specified such that fiq_fsm behaves similarly to the
previously implemented FIQ fixes.

fiq_fsm: Push error recovery into the FIQ when fiq_fsm is used

If the transfer associated with a QTD failed due to a bus error, the HCD
would retry the transfer up to 3 times (implementing the USB2.0
three-strikes retry in software).

Due to the masking mechanism used by fiq_fsm, it is only possible to pass
a single interrupt through to the HCD per-transfer.

In this instance host channels would fall off the radar because the error
reset would function, but the subsequent channel halt would be lost.

Push the error count reset into the FIQ handler.

fiq_fsm: Implement timeout mechanism

For full-speed endpoints with a large packet size, interrupt latency
runs the risk of the FIQ starting a transaction too late in a full-speed
frame. If the device is still transmitting data when EOF2 for the
downstream frame occurs, the hub will disable the port. This change is
not reflected in the hub status endpoint and the device becomes
unresponsive.

Prevent high-bandwidth transactions from being started too late in a
frame. The mechanism is not guaranteed: a combination of bit stuffing
and hub latency may still result in a device overrunning.

fiq_fsm: fix bounce buffer utilisation for Isochronous OUT

Multi-packet isochronous OUT transactions were subject to a few bounday
bugs. Fix them.

Audio playback is now much more robust: however, an issue stands with
devices that have adaptive sinks - ALSA plays samples too fast.

dwc_otg: Return full-speed frame numbers in HS mode

The frame counter increments on every *microframe* in high-speed mode.
Most device drivers expect this number to be in full-speed frames - this
caused considerable confusion to e.g. snd_usb_audio which uses the
frame counter to estimate the number of samples played.

fiq_fsm: save PID on completion of interrupt OUT transfers

Also add edge case handling for interrupt transports.

Note that for periodic split IN, data toggles are unimplemented in the
OTG host hardware - it unconditionally accepts any PID.

fiq_fsm: add missing case for fiq_fsm_tt_in_use()

Certain combinations of bitrate and endpoint activity could
result in a periodic transaction erroneously getting started
while the previous Isochronous OUT was still active.

fiq_fsm: clear hcintmsk for aborted transactions

Prevents the FIQ from erroneously handling interrupts
on a timed out channel.

fiq_fsm: enable by default

fiq_fsm: fix dequeues for non-periodic split transactions

If a dequeue happened between the SSPLIT and CSPLIT phases of the
transaction, the HCD would never receive an interrupt.

fiq_fsm: Disable by default

fiq_fsm: Handle HC babble errors

The HCTSIZ transfer size field raises a babble interrupt if
the counter wraps. Handle the resulting interrupt in this case.

dwc_otg: fix interrupt registration for fiq_enable=0

Additionally make the module parameter conditional for wherever
hcd->fiq_state is touched.

fiq_fsm: Enable by default

dwc_otg: Fix various issues with root port and transaction errors

Process the host port interrupts correctly (and don't trample them).
Root port hotplug now functional again.

Fix a few thinkos with the transaction error passthrough for fiq_fsm.

fiq_fsm: Implement hack for Split Interrupt transactions

Hubs aren't too picky about which endpoint we send Control type split
transactions to. By treating Interrupt transfers as Control, it is
possible to use the non-periodic queue in the OTG core as well as the
non-periodic FIFOs in the hub itself. This massively reduces the
microframe exclusivity/contention that periodic split transactions
otherwise have to enforce.

It goes without saying that this is a fairly egregious USB specification
violation, but it works.

Original idea by Hans Petter Selasky @ FreeBSD.org.

dwc_otg: FIQ support on SMP. Set up FIQ stack and handler on Core 0 only.

dwc_otg: introduce fiq_fsm_spin(un|)lock()

SMP safety for the FIQ relies on register read-modify write cycles being
completed in the correct order. Several places in the DWC code modify
registers also touched by the FIQ. Protect these by a bare-bones lock
mechanism.

This also makes it possible to run the FIQ and IRQ handlers on different
cores.

fiq_fsm: fix build on bcm2708 and bcm2709 platforms

dwc_otg: put some barriers back where they should be for UP

bcm2709/dwc_otg: Setup FIQ on core 1 if >1 core active

dwc_otg: fixup read-modify-write in critical paths

Be more careful about read-modify-write on registers that the FIQ
also touches.

Guard fiq_fsm_spin_lock with fiq_enable check

fiq_fsm: Falling out of the state machine isn't fatal

This edge case can be hit if the port is disabled while the FIQ is
in the middle of a transaction. Make the effects less severe.

Also get rid of the useless return value.

squash: dwc_otg: Allow to build without SMP

usb: core: make overcurrent messages more prominent

Hub overcurrent messages are more serious than "debug". Increase loglevel.

usb: dwc_otg: Don't use dma_to_virt()

Commit 6ce0d20 changes dma_to_virt() which breaks this driver.
Open code the old dma_to_virt() implementation to work around this.

Limit the use of __bus_to_virt() to cases where transfer_buffer_length
is set and transfer_buffer is not set. This is done to increase the
chance that this driver will also work on ARCH_BCM2835.

transfer_buffer should not be NULL if the length is set, but the
comment in the code indicates that there are situations where this
might happen. drivers/usb/isp1760/isp1760-hcd.c also has a similar
comment pointing to a possible: 'usb storage / SCSI bug'.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

dwc_otg: Fix crash when fiq_enable=0

dwc_otg: fiq_fsm: Make high-speed isochronous strided transfers work properly

Certain low-bandwidth high-speed USB devices (specialist audio devices,
compressed-frame webcams) have packet intervals > 1 microframe.

Stride these transfers in the FIQ by using the start-of-frame interrupt
to restart the channel at the right time.

dwc_otg: Force host mode to fix incorrect compute module boards

dwc_otg: Add ARCH_BCM2835 support

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

dwc_otg: Simplify FIQ irq number code

Dropping ATAGS means we can simplify the FIQ irq number code.
Also add error checking on the returned irq number.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

dwc_otg: Remove duplicate gadget probe/unregister function

dwc_otg: Properly set the HFIR

Douglas Anderson reported:

According to the most up to date version of the dwc2 databook, the FRINT
field of the HFIR register should be programmed to:
* 125 us * (PHY clock freq for HS) - 1
* 1000 us * (PHY clock freq for FS/LS) - 1

This is opposed to older versions of the doc that claimed it should be:
* 125 us * (PHY clock freq for HS)
* 1000 us * (PHY clock freq for FS/LS)

and reported lower timing jitter on a USB analyser

dcw_otg: trim xfer length when buffer larger than allocated size is received

dwc_otg: Don't free qh align buffers in atomic context

dwc_otg: Enable the hack for Split Interrupt transactions by default

dwc_otg.fiq_fsm_mask=0xF has long been a suggestion for users with audio stutters or other USB bandwidth issues.
So far we are aware of many success stories but no failure caused by this setting.
Make it a default to learn more.

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

Signed-off-by: popcornmix <popcornmix@gmail.com>

dwc_otg: Use kzalloc when suitable

dwc_otg: Pass struct device to dma_alloc*()

This makes it possible to get the bus address from Device Tree.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

dwc_otg: fix summarize urb->actual_length for isochronous transfers

Kernel does not copy input data of ISO transfers to userspace
if actual_length is set only in ISO transfers and not summarized
in urb->actual_length. Fixes raspberrypi/linux#903

fiq_fsm: Use correct states when starting isoc OUT transfers

In fiq_fsm_start_next_periodic() if an isochronous OUT transfer
was selected, no regard was given as to whether this was a single-packet
transfer or a multi-packet staged transfer.

For single-packet transfers, this had the effect of repeatedly sending
OUT packets with bogus data and lengths.

Eventually if the channel was repeatedly enabled enough times, this
would lock up the OTG core and no further bus transfers would happen.

Set the FSM state up properly if we select a single-packet transfer.

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

dwc_otg: make nak_holdoff work as intended with empty queues

If URBs reading from non-periodic split endpoints were dequeued and
the last transfer from the endpoint was a NAK handshake, the resulting
qh->nak_frame value was stale which would result in unnecessarily long
polling intervals for the first subsequent transfer with a fresh URB.

Fixup qh->nak_frame in dwc_otg_hcd_urb_dequeue and also guard against
a case where a single URB is submitted to the endpoint, a NAK was
received on the transfer immediately prior to receiving data and the
device subsequently resubmits another URB past the qh->nak_frame interval.

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

dwc_otg: fix split transaction data toggle handling around dequeues

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

Fix several issues regarding endpoint state when URBs are dequeued
- If the HCD is disconnected, flush FIQ-enabled channels properly
- Save the data toggle state for bulk endpoints if the last transfer
  from an endpoint where URBs were dequeued returned a data packet
- Reset hc->start_pkt_count properly in assign_and_init_hc()

dwc_otg: fix several potential crash sources

On root port disconnect events, the host driver state is cleared and
in-progress host channels are forcibly stopped. This doesn't play
well with the FIQ running in the background, so:
- Guard the disconnect callback with both the host spinlock and FIQ
  spinlock
- Move qtd dereference in dwc_otg_handle_hc_fsm() after the early-out
  so we don't dereference a qtd that has gone away
- Turn catch-all BUG()s in dwc_otg_handle_hc_fsm() into warnings.

dwc_otg: delete hcd->channel_lock

The lock serves no purpose as it is only held while the HCD spinlock
is already being held.

dwc_otg: remove unnecessary dma-mode channel halts on disconnect interrupt

Host channels are already halted in kill_urbs_in_qh_list() with the
subsequent interrupt processing behaving as if the URB was dequeued
via HCD callback.

There's no need to clobber the host channel registers a second time
as this exposes races between the driver and host channel resulting
in hcd->free_hc_list becoming corrupted.

dwcotg: Allow to build without FIQ on ARM64

Signed-off-by: popcornmix <popcornmix@gmail.com>

dwc_otg: make periodic scheduling behave properly for FS buses

If the root port is in full-speed mode, transfer times at 12mbit/s
would be calculated but matched against high-speed quotas.

Reinitialise hcd->frame_usecs[i] on each port enable event so that
full-speed bandwidth can be tracked sensibly.

Also, don't bother using the FIQ for transfers when in full-speed
mode - at the slower bus speed, interrupt frequency is reduced by
an order of magnitude.

Related issue: https://github.com/raspberrypi/linux/issues/2020

dwc_otg: fiq_fsm: Make isochronous compatibility checks work properly

Get rid of the spammy printk and local pointer mangling.
Also, there is a nominal benefit for using fiq_fsm for isochronous
transfers in FS mode (~1.1k IRQs per second vs 2.1k IRQs per second)
so remove the root port speed check.

dwc_otg: add module parameter int_ep_interval_min

Add a module parameter (defaulting to ignored) that clamps the polling rate
of high-speed Interrupt endpoints to a minimum microframe interval.

The parameter is modifiable at runtime as it is used when activating new
endpoints (such as on device connect).

dwc_otg: fiq_fsm: Add non-periodic TT exclusivity constraints

Certain hub types do not discriminate between pipe direction (IN or OUT)
when considering non-periodic transfers. Therefore these hubs get confused
if multiple transfers are issued in different directions with the same
device address and endpoint number.

Constrain queuing non-periodic split transactions so they are performed
serially in such cases.

Related: https://github.com/raspberrypi/linux/issues/2024

dwc_otg: Fixup change to DRIVER_ATTR interface

dwc_otg: Fix compilation warnings

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

USB_DWCOTG: Disable building dwc_otg as a module (#2265)

When dwc_otg is built as a module, build will fail with the following
error:

ERROR: "DWC_TASK_HI_SCHEDULE" [drivers/usb/host/dwc_otg/dwc_otg.ko] undefined!
scripts/Makefile.modpost:91: recipe for target '__modpost' failed
make[1]: *** [__modpost] Error 1
Makefile:1199: recipe for target 'modules' failed
make: *** [modules] Error 2

Even if the error is solved by including the missing
DWC_TASK_HI_SCHEDULE function, the kernel will panic when loading
dwc_otg.

As a workaround, simply prevent user from building dwc_otg as a module
as the current kernel does not support it.

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

Signed-off-by: Malik Olivier Boussejra <malik@boussejra.com>

dwc_otg: New timer API

dwc_otg: Fix removed ACCESS_ONCE->READ_ONCE

dwc_otg: don't unconditionally force host mode in dwc_otg_cil_init()

Add the ability to disable force_host_mode for those that want to use
dwc_otg in both device and host modes.

dwc_otg: Fix a regression when dequeueing isochronous transfers

In 282bed95 (dwc_otg: make nak_holdoff work as intended with empty queues)
the dequeue mechanism was changed to leave FIQ-enabled transfers to run
to completion - to avoid leaving hub TT buffers with stale packets lying
around.

This broke FIQ-accelerated isochronous transfers, as this then meant that
dozens of transfers were performed after the dequeue function returned.

Restore the state machine fence for isochronous transfers.

fiq_fsm: rewind DMA pointer for OUT transactions that fail (#2288)

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

dwc_otg: add smp_mb() to prevent driver state corruption on boot

Occasional crashes have been seen where the FIQ code dereferences
invalid/random pointers immediately after being set up, leading to
panic on boot.

The crash occurs as the FIQ code races against hcd_init_fiq() and
the hcd_init_fiq() code races against the outstanding memory stores
from dwc_otg_hcd_init(). Use explicit barriers after touching
driver state.

usb: dwc_otg: fix memory corruption in dwc_otg driver

[Upstream commit 51b1b64917]

The move from the staging tree to the main tree exposed a
longstanding memory corruption bug in the dwc2 driver. The
reordering of the driver initialization caused the dwc2 driver
to corrupt the initialization data of the sdhci driver on the
Raspberry Pi platform, which made the bug show up.

The error is in calling to_usb_device(hsotg->dev), since ->dev
is not a member of struct usb_device. The easiest fix is to
just remove the offending code, since it is not really needed.

Thanks to Stephen Warren for tracking down the cause of this.

Reported-by: Andre Heider <a.heider@gmail.com>
Tested-by: Stephen Warren <swarren@wwwdotorg.org>
Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[lukas: port from upstream dwc2 to out-of-tree dwc_otg driver]
Signed-off-by: Lukas Wunner <lukas@wunner.de>

usb: dwb_otg: Fix unreachable switch statement warning

This warning appears with GCC 7.3.0 from toolchains.bootlin.com:

../drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.c: In function ‘fiq_fsm_update_hs_isoc’:
../drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.c:595:61: warning: statement will never be executed [-Wswitch-unreachable]
   st->hctsiz_copy.b.xfersize = nrpackets * st->hcchar_copy.b.mps;
                                            ~~~~~~~~~~~~~~~~~^~~~

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

dwc_otg: fiq_fsm: fix incorrect DMA register offset calculation

Rationalise the offset and update all call sites.

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

dwc_otg: fix bug with port_addr assignment for single-TT hubs

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

The "Hub Port" field in the split transaction packet was always set
to 1 for single-TT hubs. The majority of single-TT hub products
apparently ignore this field and broadcast to all downstream enabled
ports, which masked the issue. A subset of hub devices apparently
need the port number to be exact or split transactions will fail.

usb: dwc_otg: Clean up build warnings on 64bit kernels

No functional changes. Almost all are changes to logging lines.

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

usb: dwc_otg: Use dma allocation for mphi dummy_send buffer

The FIQ driver used a kzalloc'ed buffer for dummy_send,
passing a kernel virtual address to the hardware block.
The buffer is only ever used for a dummy read, so it
should be harmless, but there is the chance that it will
cause exceptions.

Use a dma allocation so that we have a genuine bus address,
and read from that.
Free the allocation when done for good measure.

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

dwc_otg: only do_split when we actually need to do a split

The previous test would fail if the root port was in fullspeed mode
and there was a hub between the FS device and the root port. While
the transfer worked, the schedule mangling performed for high-speed
split transfers would break leading to an 8ms polling interval.

dwc_otg: fix locking around dequeueing and killing URBs

kill_urbs_in_qh_list() is practically only ever called with the fiq lock
already held, so don't spinlock twice in the case where we need to cancel
an isochronous transfer.

Also fix up a case where the global interrupt register could be read with
the fiq lock not held.

Fixes the deadlock seen in https://github.com/raspberrypi/linux/issues/2907

ARM64/DWC_OTG: Port dwc_otg driver to ARM64

In ARM64, the FIQ mechanism used by this driver is not current
implemented.   As a workaround, reqular IRQ is used instead
of FIQ.

In a separate change, the IRQ-CPU mapping is round robined
on ARM64 to increase concurrency and allow multiple interrupts
to be serviced at a time.  This reduces the need for FIQ.

Tests Run:

This mechanism is most likely to break when multiple USB devices
are attached at the same time.  So the system was tested under
stress.

Devices:

1. USB Speakers playing back a FLAC audio through VLC
   at 96KHz.(Higher then typically, but supported on my speakers).

2. sftp transferring large files through the buildin ethernet
   connection which is connected through USB.

3. Keyboard and mouse attached and being used.

Although I do occasionally hear some glitches, the music seems to
play quite well.

Signed-off-by: Michael Zoran <mzoran@crowfest.net>

usb: dwc_otg: Clean up interrupt claiming code

The FIQ/IRQ interrupt number identification code is scattered through
the dwc_otg driver. Rationalise it, simplifying the code and solving
an existing issue.

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

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

dwc_otg: Choose appropriate IRQ handover strategy

2711 has no MPHI peripheral, but the ARM Control block can fake
interrupts. Use the size of the DTB "mphi" reg block to determine
which is required.

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

usb: host: dwc_otg: fix compiling in separate directory

The dwc_otg Makefile does not respect the O=path argument correctly:
include paths in CFLAGS are given relatively to object path, not source
path. Compiling in a separate directory yields #include errors.

Signed-off-by: Marek Behún <marek.behun@nic.cz>

dwc_otg: use align_buf for small IN control transfers (#3150)

The hardware will do a 4-byte write to memory on any IN packet received
that is between 1 and 3 bytes long. This tramples memory in the uvcvideo
driver, as it uses a sequence of 1- and 2-byte control transfers to
query the min/max/range/step of each individual camera control and
gives us buffers that are offsets into a struct.

Catch small control transfers in the data phase and use the align_buf
to bounce the correct number of bytes into the URB's buffer.

In general, short packets on non-control endpoints should be OK as URBs
should have enough buffer space for a wMaxPacket size transfer.

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

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>

dwc_otg: Declare DMA capability with HCD_DMA flag

Following [1], USB controllers have to declare DMA capabilities in
order for them to be used by adding the HCD_DMA flag to their hc_driver
struct.

[1] 7b81cb6bdd ("usb: add a HCD_DMA flag instead of guestimating DMA capabilities")

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

dwc_otg: checking the urb->transfer_buffer too early (#3332)

After enable the HIGHMEM and VMSPLIT_3G, the dwc_otg driver doesn't
work well on Pi2/3 boards with 1G physical ram. Users experience
the failure when copying a file of 600M size to the USB stick. And
at the same time, the dmesg shows:
usb 1-1.1.2: reset high-speed USB device number 8 using dwc_otg
sd 0:0:0:0: [sda] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK
blk_update_request: I/O error, dev sda, sector 3024048 op 0x1:(WRITE) flags 0x4000 phys_seg 15 prio class 0

When this happens, the sg_buf sent to the driver is located in the
highmem region, the usb_sg_init() in the core/message.c will leave
transfer_buffer to NULL if the sg_buf is in highmem, but in the
dwc_otg driver, it returns -EINVAL unconditionally if transfer_buffer
is NULL.

The driver can handle the situation of buffer to be NULL, if it is in
DMA mode, it will convert an address from transfer_dma.

But if the conversion fails or it is in the PIO mode, we should check
buffer and return -EINVAL if it is NULL.

BugLink: https://bugs.launchpad.net/bugs/1852510
Signed-off-by: Hui Wang <hui.wang@canonical.com>

dwc_otg: constrain endpoint max packet and transfer size on split IN

The hcd would unconditionally set the transfer length to the endpoint
packet size for non-isoc IN transfers. If the remaining buffer length
was less than the length of returned data, random memory would get
scribbled over, with bad effects if it crossed a page boundary.

Force a babble error if this happens by limiting the max transfer size
to the available buffer space. DMA will stop writing to memory on a
babble condition.

The hardware expects xfersize to be an integer multiple of maxpacket
size, so override hcchar.b.mps as well.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>

dwc_otg: fiq_fsm: pause when cancelling split transactions

Non-periodic splits will DMA to/from the driver-provided transfer_buffer,
which may be freed immediately after the dequeue call returns. Block until
we know the transfer is complete.

A similar delay is needed when cleaning up disconnects, as the FIQ could
have started a periodic transfer in the previous microframe to the one
that triggered a disconnect.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>

dwc_otg: fiq_fsm: add a barrier on entry into FIQ handler(s)

On BCM2835, there is no hardware guarantee that multiple outstanding
reads to different peripherals will complete in-order. The FIQ code
uses peripheral reads without barriers for performance, so in the case
where a read to a slow peripheral was issued immediately prior to FIQ
entry, the first peripheral read that the FIQ did could end up with
wrong read data returned.

Add dsb(sy) on entry so that all outstanding reads are retired.

The FIQ only issues reads to the dwc_otg core, so per-read barriers
in the handler itself are not required.

On BCM2836 and BCM2837 the barrier is not strictly required due to
differences in how the peripheral bus is implemented, but having
arch-specific handlers that introduce different latencies is risky.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>

dwc_otg: whitelist_table is now productlist_table

dwc_otg: initialise sched_frame for periodic QHs that were parked

If a periodic QH has no remaining QTDs, then it is removed from all
periodic schedules. When re-adding, initialise the sched_frame and
start_split_frame from the current value of the frame counter.

See https://bugs.launchpad.net/raspbian/+bug/1819560
and
 https://github.com/raspberrypi/linux/issues/3883

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

dwc_otg: Minimise header and fix build warnings

Delete a large amount of unused declaration from "usb.h", some of which
were causing build warnings, and get the module building cleanly.

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

dwc-otg: fix clang -Wignored-attributes warning

warning: attribute declaration must precede definition

dwc-otg: fix clang -Wsometimes-uninitialized warning

warning: variable 'retval' is used uninitialized whenever 'if' condition is false

dwc-otg: fix clang -Wpointer-bool-conversion warning

warning: address of array 'desc->wMaxPacketSize' will always evaluate to 'true'

The wMaxPacketSize field is actually a two element array which content should
be accessed via the UGETW macro.

dwc_otg: fix an undeclared variable
Replace an undeclared variable used by DWC_DEBUGPL with the real endpoint address. DWC_DEBUGPL does nothing with DEBUG undefined so it did not go wrong before.
Signed-off-by: Zixuan Wang <wangzixuan@sjtu.edu.cn>

dwc_otg: Update NetBSD usb.h header licence

NetBSD have changed their licensing requirements such that the 2-clause
licence is preferred. Update usb.h in the downstream dwc_otg code
accordingly.

See https://www.netbsd.org/about/redistribution.html for more
information.

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

dwc_otg: pay attention to qh->interval when rescheduling periodic queues

A regression introduced in https://github.com/raspberrypi/linux/pull/3887
meant that if the newly scheduled transfer immediately returned data, and
the driver resubmitted a single URB after every transfer, then the effective
polling interval would end up being approx 1ms.

Use the larger of SCHEDULE_SLOP or the configured endpoint interval.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

drivers: dwc_otg: Fix fallthrough warnings

Signed-off-by: Alexander Winkowski <dereference23@outlook.com>

drivers: usb: dwc_otg: fix reference passing when checking bandwidth

The pointer (struct usb_host_endpoint *)->hcpriv should contain a
reference to dwc_otg_qh_t if the driver has already seen a URB submitted
to this endpoint.

It then checks whether the qh exists and is already in a schedule in
order to decide whether to allocate periodic bandwidth or not. Passing a
pointer to an offset inside of struct usb_host_endpoint instead of just
the pointer means it dereferences bogus addresses.

Rationalise (delete) a variable while we're at it.

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

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

drivers: dwc_otg: stop GCC from patching FIQ functions

Configuring GCC to use task stack protector canaries means it will
insert calls to check functions in FIQ code. This is bad, as a) the
FIQ's stack is banked and b) the failure invokes __stack_chk_fail which
eventually tries to call printk(). Printing to the console inside the
FIQ is generally fatal.

Add CFLAGS to stop this happening in FIQ code.

Also catch one function where notrace wasn't specified.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>

dwc_otg: Avoid the use of align_buf for short packets

Recent kernels (from 6.5) fail to boot on Pi0-3.

This has been tracked down to the call to:
ret = usb_get_std_status(hdev, USB_RECIP_DEVICE, 0, &hubstatus);

returning garbage in hubstatus (it gets the uninitialised contents of
a kmalloc buffer that is not overwritten as expected).

As we don't have strong evidence that this code path has ever worked,
and it is causing a clear problem currently, lets disable it to
allow wider use of newer kernels.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

drivers: dwc_otg: use C11 style variable array declarations

The kernel C standard changed in 5.18.

Remove a layer of indirection around the FIQ bounce buffers, be consistent
with pointers to FIQ bounce buffers, and remove open-coded 32-bit clamping
of DMA addresses.

Also remove a pointless fiq_state initialisation loop.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-08-05 11:15:02 +01:00
popcornmix
d1b7d65268 Main bcm2708/bcm2709 linux port
Signed-off-by: popcornmix <popcornmix@gmail.com>
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

bcm2709: Drop platform smp and timer init code

irq-bcm2836 handles this through these functions:
bcm2835_init_local_timer_frequency()
bcm2836_arm_irqchip_smp_init()

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

bcm270x: Use watchdog for reboot/poweroff

The watchdog driver already has support for reboot/poweroff.
Make use of this and remove the code from the platform files.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

board_bcm2835: Remove coherent dma pool increase - API has gone
2024-08-05 11:15:02 +01:00
Phil Elwell
d33c8b2ae4 tty: amba-pl011: Avoid rare write-when-full error
Under some circumstances on BCM283x processors data loss can be
observed - a single byte missing from the TX output stream. These bytes
are always the last byte of a batch of 8 written from pl011_tx_chars
when from_irq is true, meaning that the FIFO full flag is not checked
before writing.

The transmit optimisation relies on the FIFO being half-empty when the
TX interrupt is raised. Instrumenting the driver further showed that
the failure case correlated with the TX FIFO full flag being set at the
point where the last byte was written to the data register, which
explains the data loss but not how the FIFO appeared to be prematurely
full. A possible explanation is that a FIFO write was in flight at the
time the interrupt was raised, but as yet there is no hypothesis as to
how this might occur.

In the absence of a clear understanding of the failure mechanism, avoid
the problem by checking the FIFO levels before writing the last byte of
the group, which will have minimal performance impact.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2024-08-05 11:15:02 +01:00
Phil Elwell
a915ba97f0 amba_pl011: Add cts-event-workaround DT property
The BCM2835 PL011 implementation seems to have a bug that can lead to a
transmission lockup if CTS changes frequently. A workaround was added to
the driver with a vendor-specific flag to enable it, but this flag is
currently not set for ARM implementations.

Add a "cts-event-workaround" property to Pi DTBs and use the presence
of that property to force the flag to be enabled in the driver.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2024-08-05 11:15:02 +01:00
Phil Elwell
8c40a750a0 amba_pl011: Insert mb() for correct FIFO handling
The pl011 register accessor functions use the _relaxed versions of the
standard readl() and writel() functions, meaning that there are no
automatic memory barriers. When polling a FIFO status register to check
for fullness, it is necessary to ensure that any outstanding writes have
completed; otherwise the flags are effectively stale, making it possible
that the next write is to a full FIFO.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2024-08-05 11:15:02 +01:00
Phil Elwell
c3a1c33fb7 irqchip: irq-bcm2836: Remove regmap and syscon use
The syscon node defines a register range that duplicates that used by
the local_intc node on bcm2836/7. Since irq-bcm2835 and irq-bcm2836 are
built in and always present together (both drivers are enabled by
CONFIG_ARCH_BCM2835), it is possible to replace the syscon usage with a
global variable that simplifies the code. Doing so does lose the
locking provided by regmap, but as only one side is using the regmap
interface (irq-bcm2835 uses readl and write) there is no loss of
atomicity.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2024-08-05 11:15:02 +01:00
Noralf Trønnes
59f8568fd6 i2c: bcm2835: Add debug support
This adds a debug module parameter to aid in debugging transfer issues
by printing info to the kernel log. When enabled, status values are
collected in the interrupt routine and msg info in
bcm2835_i2c_start_transfer(). This is done in a way that tries to avoid
affecting timing. Having printk in the isr can mask issues.

debug values (additive):
1: Print info on error
2: Print info on all transfers
3: Print messages before transfer is started

The value can be changed at runtime:
/sys/module/i2c_bcm2835/parameters/debug

Example output, debug=3:
[  747.114448] bcm2835_i2c_xfer: msg(1/2) write addr=0x54, len=2 flags= [i2c1]
[  747.114463] bcm2835_i2c_xfer: msg(2/2) read addr=0x54, len=32 flags= [i2c1]
[  747.117809] start_transfer: msg(1/2) write addr=0x54, len=2 flags= [i2c1]
[  747.117825] isr: remain=2, status=0x30000055 : TA TXW TXD TXE  [i2c1]
[  747.117839] start_transfer: msg(2/2) read addr=0x54, len=32 flags= [i2c1]
[  747.117849] isr: remain=32, status=0xd0000039 : TA RXR TXD RXD  [i2c1]
[  747.117861] isr: remain=20, status=0xd0000039 : TA RXR TXD RXD  [i2c1]
[  747.117870] isr: remain=8, status=0x32 : DONE TXD RXD  [i2c1]

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
2024-08-05 11:15:02 +01:00
Claggy3
7ff628d2c6 Update vfpmodule.c
Christopher Alexander Tobias Schulze - May 2, 2015, 11:57 a.m.
This patch fixes a problem with VFP state save and restore related
to exception handling (panic with message "BUG: unsupported FP
instruction in kernel mode") present on VFP11 floating point units
(as used with ARM1176JZF-S CPUs, e.g. on first generation Raspberry
Pi boards). This patch was developed and discussed on

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

A precondition to see the crashes is that floating point exception
traps are enabled. In this case, the VFP11 might determine that a FPU
operation needs to trap at a point in time when it is not possible to
signal this to the ARM11 core any more. The VFP11 will then set the
FPEXC.EX bit and store the trapped opcode in FPINST. (In some cases,
a second opcode might have been accepted by the VFP11 before the
exception was detected and could be reported to the ARM11 - in this
case, the VFP11 also sets FPEXC.FP2V and stores the second opcode in
FPINST2.)

If FPEXC.EX is set, the VFP11 will "bounce" the next FPU opcode issued
by the ARM11 CPU, which will be seen by the ARM11 as an undefined opcode
trap. The VFP support code examines the FPEXC.EX and FPEXC.FP2V bits
to decide what actions to take, i.e., whether to emulate the opcodes
found in FPINST and FPINST2, and whether to retry the bounced instruction.

If a user space application has left the VFP11 in this "pending trap"
state, the next FPU opcode issued to the VFP11 might actually be the
VSTMIA operation vfp_save_state() uses to store the FPU registers
to memory (in our test cases, when building the signal stack frame).
In this case, the kernel crashes as described above.

This patch fixes the problem by making sure that vfp_save_state() is
always entered with FPEXC.EX cleared. (The current value of FPEXC has
already been saved, so this does not corrupt the context. Clearing
FPEXC.EX has no effects on FPINST or FPINST2. Also note that many
callers already modify FPEXC by setting FPEXC.EN before invoking
vfp_save_state().)

This patch also addresses a second problem related to FPEXC.EX: After
returning from signal handling, the kernel reloads the VFP context
from the user mode stack. However, the current code explicitly clears
both FPEXC.EX and FPEXC.FP2V during reload. As VFP11 requires these
bits to be preserved, this patch disables clearing them for VFP
implementations belonging to architecture 1. There should be no
negative side effects: the user can set both bits by executing FPU
opcodes anyway, and while user code may now place arbitrary values
into FPINST and FPINST2 (e.g., non-VFP ARM opcodes) the VFP support
code knows which instructions can be emulated, and rejects other
opcodes with "unhandled bounce" messages, so there should be no
security impact from allowing reloading FPEXC.EX and FPEXC.FP2V.

Signed-off-by: Christopher Alexander Tobias Schulze <cat.schulze@alice-dsl.net>
2024-08-05 11:15:02 +01:00
popcornmix
c49212a80c bcm2835-rng: Avoid initialising if already enabled
Avoids the 0x40000 cycles of warmup again if firmware has already used it
2024-08-05 11:15:02 +01:00
popcornmix
848cda281d reboot: Use power off rather than busy spinning when halt is requested
reboot: Use power off rather than busy spinning when halt is requested

Busy spinning after halt is dumb
We've previously applied this patch to arch/arm
but it is currenltly missing in arch/arm64

Pi4 after "sudo halt" uses 520mA
Pi4 after "sudo shutdown now" uses 310mA

Make them both use the lower powered option

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:01 +01:00
Noralf Trønnes
d94e37b5be watchdog: bcm2835: Support setting reboot partition
The Raspberry Pi firmware looks at the RSTS register to know which
partition to boot from. The reboot syscall command
LINUX_REBOOT_CMD_RESTART2 supports passing in a string argument.

Add support for passing in a partition number 0..63 to boot from.
Partition 63 is a special partiton indicating halt.
If the partition doesn't exist, the firmware falls back to partition 0.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
2024-08-05 11:15:01 +01:00
Phil Elwell
e3935ce765 rtc: Add SPI alias for pcf2123 driver
Without this alias, Device Tree won't cause the driver
to be loaded.

See: https://github.com/raspberrypi/linux/pull/1510
2024-08-05 11:15:01 +01:00
Noralf Trønnes
9e0481fa58 dmaengine: bcm2835: Load driver early and support legacy API
Load driver early since at least bcm2708_fb doesn't support deferred
probing and even if it did, we don't want the video driver deferred.
Support the legacy DMA API which is needed by bcm2708_fb.
Don't mask out channel 2.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

bcm2835-dma: Add support for per-channel flags

Add the ability to interpret the high bits of the dreq specifier as
flags to be included in the DMA_CS register. The motivation for this
change is the ability to set the DISDEBUG flag for SD card transfers
to avoid corruption when using the VPU debugger.

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

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>

bcm2835-dma: Derive slave DMA addresses correctly

Slave addresses for DMA are meant to be supplied as physical addresses
(contrary to what struct snd_dmaengine_dai_dma_data does). It is up to
the DMA controller driver to perform the translation based on its own
view of the world, as described in Device Tree.

Now that the Pi Device Trees have the correct peripheral mappings,
replace the hacky address munging with phys_to_dma().

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

bcm2835-dma: Add NO_WAIT_RESP flag

Use bit 27 of the dreq value (the second cell of the DT DMA descriptor)
to request that the WAIT_RESP bit is not set.

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

bcm2835-dma: Advertise the full DMA range

Unless the DMA mask is set wider than 32 bits, DMA mapping will use a
bounce buffer.

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

bcm2835-dma: only reserve channel 0 if legacy dma driver is enabled

If CONFIG_DMA_BCM2708 isn't enabled there's no need to mask out
one of the already scarce DMA channels.

Signed-off-by: Matthias Reichl <hias@horus.com>

bcm2835-dma: Avoid losing CS flags after interrupt

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

bcm2835-dma: Add bcm2835-dma: Add DMA_WIDE_SOURCE and DMA_WIDE_DEST flags

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

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

dmaengine: bcm2835: Fix position reporting for 40 bits channels

For 40 bits channels, the position is reported by reading the upper byte
in the SRCI/DESTI registers. However the driver adds that upper byte
with an 8-bits left shift, while it should be 32.

Fixes: 9a52a99183 ("bcm2835-dma: Add proper 40-bit DMA support")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>

dmaengine: bcm2835: Use to_bcm2711_cbaddr where relevant

bcm2711_dma40_memcpy has some code strictly equivalent to the
to_bcm2711_cbaddr() function. Let's use it instead.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>

dmaengine: bcm2835: Fix descriptors usage for 40-bits channels

The bcm2835_dma_create_cb_chain() function is in charge of building up
the descriptors chain for a given transfer.

It was initially supporting only the BCM2835-style DMA controller, and
was later expanded to support controllers with 40-bits channels that use
a different descriptor layout.

However, some part of the function only use the old style descriptor,
even when building a chain of new-style descriptors, resulting in weird
bugs.

Fixes: 9a52a99183 ("bcm2835-dma: Add proper 40-bit DMA support")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>

bcm2835-dma: Fix WAIT_RESP on memcpy

It goes in info not extra

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

bcm2835-dma: Fix dma_abort for 40-bit channels

It wasn't aborting the transfer and caused stop/start
of hdmi audio dma to be unreliable.

New sequence approved by Broadcom.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

bcm2835-dma: Fix dma_abort for non-40bit channels

The sequence we were doing was not safe.

Clearing CS meant BCM2835_DMA_WAIT_FOR_WRITES was cleared
and so polling BCM2835_DMA_WAITING_FOR_WRITES has no benefit

Broadcom have provided a recommended sequence to abort
a dma lite channel, so switch to that.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

bcm2835-dma: Support dma flags for multi-beat burst

Add a control bit to enable a multi-beat burst on a DMA.
This improves DMA performance and is required for HDMI audio.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

bcm2835-dma: Need to keep PROT bits set in CS on 40bit controller

Resetting them to zero puts DMA channel into secure mode
which makes further accesses impossible

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

dmaengine: bcm2835: Delete vestigial code

The dedicated dma40 memcpy code is no longer used, and without a
prototype the kernel build fails. Delete it.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:01 +01:00
Dom Cobley
5430f6ef7d spi: spidev: Completely disable the spidev warning
An alternative strategy would be to use "rpi,spidev" instead, but that
would require many Raspberry Pi Device Tree changes.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2024-08-05 11:15:01 +01:00
Noralf Trønnes
3299fd358e irqchip: irq-bcm2835: Add 2836 FIQ support
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
2024-08-05 11:15:01 +01:00
Noralf Trønnes
f3013d3689 irqchip: bcm2835: Add FIQ support
Add a duplicate irq range with an offset on the hwirq's so the
driver can detect that enable_fiq() is used.
Tested with downstream dwc_otg USB controller driver.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Acked-by: Stephen Warren <swarren@wwwdotorg.org>
2024-08-05 11:15:01 +01:00
Phil Elwell
e4923fb05d irq-bcm2836: Avoid "Invalid trigger warning"
Initialise the level for each IRQ to avoid a warning from the
arm arch timer code.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2024-08-05 11:15:01 +01:00
Phil Elwell
1abdf29e6a Protect __release_resource against resources without parents
Without this patch, removing a device tree overlay can crash here.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2024-08-05 11:15:01 +01:00
Phil Elwell
a4ef09835f cgroup: Disable cgroup "memory" by default
Some Raspberry Pis have limited RAM and most users won't use the
cgroup memory support so it is disabled by default. Enable with:

    cgroup_enable=memory

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

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2024-08-05 11:15:01 +01:00
popcornmix
3840287636 Allow mac address to be set in smsc95xx
Signed-off-by: popcornmix <popcornmix@gmail.com>

SQUASH: smsc95xx: Use dev_mod_addr to set MAC addr

Since adeef3e321 ("net: constify netdev->dev_addr") it has been
illegal to write to the dev_addr MAC address field. Later commits
have added explicit checks that it hasn't been modified by nefarious
means. The dev_addr_mod helper function is the accepted way to change
the dev_addr field, so use it.

Squash with 96c1def63ee1 ("Allow mac address to be set in smsc95xx").

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:01 +01:00
Sam Nazarko
31d3c11697 smsc95xx: Experimental: Enable turbo_mode and packetsize=2560 by default
See: http://forum.kodi.tv/showthread.php?tid=285288
2024-08-05 11:15:01 +01:00
popcornmix
56d42898f8 cache: export clean and invalidate
hack: cache: Fix linker error
2024-08-05 11:15:01 +01:00
Dave Stevenson
b9f03a3fdc clk-bcm2835: Use PLLD for DSI0 HS clock
DSI0 can take the clock from either PLLA or PLLD. PLLA is
the default muxing, but PLLD is considered the more stable.

Switch to using PLLD.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:01 +01:00
popcornmix
c78989d6e8 clk-bcm2835: Disable v3d clock
This is controlled by firmware, see clk-raspberrypi.c

Signed-off-by: popcornmix <popcornmix@gmail.com>

clk-bcm2835: Remove VEC clock support

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:15:01 +01:00
popcornmix
0f6379a749 clk-bcm2835: Avoid null pointer exception
clk_desc_array[BCM2835_PLLB] doesn't exist so we dereference null when iterating

Signed-off-by: popcornmix <popcornmix@gmail.com>
2024-08-05 11:15:01 +01:00
Eric Anholt
a1323f9579 clk: bcm2835: Allow reparenting leaf clocks while they're running.
This falls under the same "we can reprogram glitch-free as long as we
pause generation" rule as updating the div/frac fields.  This can be
used for runtime reclocking of V3D to manage power leakage.

Signed-off-by: Eric Anholt <eric@anholt.net>
2024-08-05 11:15:00 +01:00
Eric Anholt
a04f807ee5 clk: bcm2835: Add support for setting leaf clock rates while running.
As long as you wait for !BUSY, you can do glitch-free updates of clock
rate while the clock is running.

Signed-off-by: Eric Anholt <eric@anholt.net>
2024-08-05 11:15:00 +01:00
Phil Elwell
25520ad0d0 clk-bcm2835: Don't wait for pllh lock
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2024-08-05 11:15:00 +01:00
Phil Elwell
ee3a3d8f3f clk-bcm2835: Read max core clock from firmware
The VPU is responsible for managing the core clock, usually under
direction from the bcm2835-cpufreq driver but not via the clk-bcm2835
driver. Since the core frequency can change without warning, it is
safer to report the maximum clock rate to users of the core clock -
I2C, SPI and the mini UART - to err on the safe side when calculating
clock divisors.

If the DT node for the clock driver includes a reference to the
firmware node, use the firmware API to query the maximum core clock
instead of reading the divider registers.

Prior to this patch, a "100KHz" I2C bus was sometimes clocked at about
160KHz. In particular, switching to the 4.9 kernel was likely to break
SenseHAT usage on a Pi3.

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

clk: bcm2835: Pass DT node to rpi_firmware_get

The fw_node pointer has already been retrieved, and using it allows
us to remove a downstream patch to the firmware driver.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:00 +01:00
Phil Elwell
badecc7a40 clk-bcm2835: Add claim-clocks property
The claim-clocks property can be used to prevent PLLs and dividers
from being marked as critical. It contains a vector of clock IDs,
as defined by dt-bindings/clock/bcm2835.h.

Use this mechanism to claim PLLD_DSI0, PLLD_DSI1, PLLH_AUX and
PLLH_PIX for the vc4_kms_v3d driver.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2024-08-05 11:15:00 +01:00
Phil Elwell
5360d2d1a8 clk-bcm2835: Mark used PLLs and dividers CRITICAL
The VPU configures and relies on several PLLs and dividers. Mark all
enabled dividers and their PLLs as CRITICAL to prevent the kernel from
switching them off.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2024-08-05 11:15:00 +01:00
Martin Sperl
2c80ee073f clk: clk-bcm2835: Register the clocks early during the boot process
so that special/critical clocks can get enabled early on in the
boot process avoiding the risk of disabling a clock, pll_divider
or pll when a claiming driver fails to install propperly - maybe it needs to defer.

Signed-off-by: Martin Sperl <kernel@martin.sperl.org>

clk: clk-bcm2835: Use %zd when printing size_t

The debug text for how many clocks have been registered
uses "%d" with a size_t. Correct it to "%zd".

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

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>

clk-bcm2835: use subsys_initcall for the clock driver when IMA is enabled

Co-authored-by: Davide Scovotto <scovottodavide@gmail.com>
Co-developed-by: Davide Scovotto <scovottodavide@gmail.com>
Signed-off-by: Davide Scovotto <scovottodavide@gmail.com>
Signed-off-by: Alberto Solavagione <albertosolavagione30@gmail.com>
2024-08-05 11:15:00 +01:00
Dom Cobley
3c33013975 clk-raspberrypi: Add ISP to exported clocks
Signed-off-by: Dom Cobley <popcornmix@gmail.com>

clk-raspberrypi: Enable minimize for all firmware clocks

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

clk: bcm: rpi: Add disp clock

BCM2712 has an extra clock exposed by the firmware called DISP, and used
by (at least) the HVS. Let's add it to the list of clocks to register in
Linux.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>

clk: bcm: rpi: Add the BCM283x pixel clock.

The clk-bcm2835 handling of the pixel clock does not function
correctly when the HDMI power domain is disabled.

The firmware supports it correctly, so add it to the
firmware clock driver.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:00 +01:00
Maxime Ripard
6f30a9372d clk: bcm: rpi: Create helper to retrieve private data
The RaspberryPi firmware clocks driver uses in several instances a
container_of to retrieve the struct raspberrypi_clk_data from a pointer
to struct clk_hw. Let's create a small function to avoid duplicating it
all over the place.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:00 +01:00
popcornmix
7a26c91c97 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>
2024-08-05 11:15:00 +01:00
popcornmix
c603529733 config: Add default configs 2024-08-05 11:15:00 +01:00
notro
21e1e48336 BCM2708: Add core Device Tree support
Add the bare minimum needed to boot BCM2708 from a Device Tree.

Signed-off-by: Noralf Tronnes <notro@tronnes.org>

BCM2708: DT: change 'axi' nodename to 'soc'

Change DT node named 'axi' to 'soc' so it matches ARCH_BCM2835.
The VC4 bootloader fills in certain properties in the 'axi' subtree,
but since this is part of an upstreaming effort, the name is changed.

Signed-off-by: Noralf Tronnes notro@tronnes.org

BCM2708_DT: Correct length of the peripheral space

Use dts-dirs feature for overlays.

The kernel makefiles have a dts-dirs target that is for vendor subdirectories.

Using this fixes the install_dtbs target, which previously did not install the overlays.

BCM270X_DT: configure I2S DMA channels

Signed-off-by: Matthias Reichl <hias@horus.com>

BCM270X_DT: switch to bcm2835-i2s

I2S soundcard drivers with proper devicetree support (i.e. not linking
to the cpu_dai/platform via name but to cpu/platform via of_node)
will work out of the box without any modifications.

When the kernel is compiled without devicetree support the platform
code will instantiate the bcm2708-i2s driver and I2S soundcard drivers
will link to it via name, as before.

Signed-off-by: Matthias Reichl <hias@horus.com>

SDIO-overlay: add poll_once-boolean parameter

Add paramter to toggle sdio-device-polling
done every second or once at boot-time.

Signed-off-by: Patrick Boettcher <patrick.boettcher@posteo.de>

BCM270X_DT: Make mmc overlay compatible with current firmware

The original DT overlay logic followed a merge-then-patch procedure,
i.e. parameters are applied to the loaded overlay before the overlay
is merged into the base DTB. This sequence has been changed to
patch-then-merge, in order to support parameterised node names, and
to protect against bad overlays. As a result, overrides (parameters)
must only target labels in the overlay, but the overlay can obviously target nodes in the base DTB.

mmc-overlay.dts (that switches back to the original mmc sdcard
driver) is the only overlay violating that rule, and this patch
fixes it.

bcm270x_dt: Use the sdhost MMC controller by default

The "mmc" overlay reverts to using the other controller.

squash: Add cprman to dt

BCM270X_DT: Use clk_core for I2C interfaces

BCM270X_DT: Use bcm283x.dtsi, bcm2835.dtsi and bcm2836.dtsi

The mainline Device Tree files are quite close to downstream now.
Let's use bcm283x.dtsi, bcm2835.dtsi and bcm2836.dtsi as base files
for our dts files.

Mainline dts files are based on these files:

          bcm2835-rpi.dtsi
  bcm2835.dtsi    bcm2836.dtsi
          bcm283x.dtsi

Current downstream are based on these:

  bcm2708.dtsi    bcm2709.dtsi    bcm2710.dtsi
             bcm2708_common.dtsi

This patch introduces this dependency:

  bcm2708.dtsi    bcm2709.dtsi
          bcm2708-rpi.dtsi
          bcm270x.dtsi
  bcm2835.dtsi    bcm2836.dtsi
          bcm283x.dtsi

And:
          bcm2710.dtsi
          bcm2708-rpi.dtsi
          bcm270x.dtsi
          bcm283x.dtsi

bcm270x.dtsi contains the downstream bcm283x.dtsi diff.
bcm2708-rpi.dtsi is the downstream version of bcm2835-rpi.dtsi.

Other changes:
- The led node has moved from /soc/leds to /leds. This is not a problem
  since the label is used to reference it.
- The clk_osc reg property changes from 6 to 3.
- The gpu nodes has their interrupt property set in the base file.
- the clocks label does not point to the /clocks node anymore, but
  points to the cprman node. This is not a problem since the overlays
  that use the clock node refer to it directly: target-path = "/clocks";
- some nodes now have 2 labels since mainline and downstream differs in
  this respect: cprman/clocks, spi0/spi, gpu/vc4.
- some nodes doesn't have an explicit status = "okay" since they're not
  disabled in the base file: watchdog and random.
- gpiomem doesn't need an explicit status = "okay".
- bcm2708-rpi-cm.dts got the hpd-gpios property from bcm2708_common.dtsi,
  it's now set directly in that file.
- bcm2709-rpi-2-b.dts has the timer node moved from /soc/timer to /timer.
- Removed clock-frequency property on the bcm{2709,2710}.dtsi timer nodes.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

BCM270X_DT: Use raspberrypi-power to turn on USB power

Use the raspberrypi-power driver to turn on USB power.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

BCM270X_DT: Add a .dtbo target, use for overlays

Change the filenames and extensions to keep the pre-DDT style of
overlay (<name>-overlay.dtb) distinct from new ones that use a
different style of local fixups (<name>.dtbo), and to match other
platforms.

The RPi firmware uses the DDTK trailer atom to choose which type of
overlay to use for each kernel.

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

BCM270X_DT: Don't generate "linux,phandle" props

The EPAPR standard says to use "phandle" properties to store phandles,
rather than the deprecated "linux,phandle" version. By default, dtc
generates both, but adding "-H epapr" causes it to only generate
"phandle"s, saving some space and clutter.

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

BCM270X_DT: Add overlay for enc28j60 on SPI2

Works on SPI2 for compute module

BCM270X_DT: Add midi-uart0 overlay

MIDI requires 31.25kbaud, a baudrate unsupported by Linux. The
midi-uart0 overlay configures uart0 (ttyAMA0) to use a fake clock
so that requesting 38.4kbaud actually gets 31.25kbaud.

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

BCM270X_DT: Add i2c-sensor overlay

The i2c-sensor overlay is a container for various pressure and
temperature sensors, currently bmp085 and bmp280. The standalone
bmp085_i2c-sensor overlay is now deprecated.

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

BCM270X_DT: overlays/*-overlay.dtb -> overlays/*.dtbo (#1752)

We now create overlays as .dtbo files.

build: support for .dtbo files for dtb overlays

Kernel 4.4.6+ on RaspberryPi support .dtbo files for overlays, instead of .dtb.
Patch the kernel, which has faulty rules to generate .dtbo the way yocto does

Signed-off-by: Herve Jourdain <herve.jourdain@neuf.fr>
Signed-off-by: Khem Raj <raj.khem@gmail.com>

BCM270X: Drop position requirement for CMA in VC4 overlay.

No longer necessary since 2aefcd5761,
and will probably let peeople that want to choose a larger CMA
allocation (particularly on pi0/1).

Signed-off-by: Eric Anholt <eric@anholt.net>

BCM270X_DT: RPi Device Tree tidy

Use the upstream sdhost node, add thermal-zones, and factor out some
common elements.

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

kbuild: Silence unhelpful DTC warnings

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

BCM270X_DT: DT build rules no longer arch-specific

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

kbuild: Silence unavoidable dtc overlay warnings

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

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

overlays: Suppress another dtc warning

I'm sure the dtc warnings mean well, but overlays don't have enough
context for the checkers to give meaningful results.

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

overlays: Use dtbs-list for overlay installation

Update the overlay build rules to use the dtbs-list mechanism. Also
include the README, and don't set the executable bits.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:15:00 +01:00
Maxime Ripard
587d7d15fa arm64: setup: Fix build warning
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:15:00 +01:00
Dave Stevenson
e6c5e24845 drm/vc4: Set AXI panic modes for the HVS
The HVS can change AXI request mode based on how full the COB
FIFOs are.
Until now the vc4 driver has been relying on the firmware to
have set these to sensible values.

With HVS channel 2 now being used for live video, change the
panic mode for all channels to be explicitly set by the driver,
and the same for all channels.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:15:00 +01:00
Dom Cobley
9b45554408 drm/vc4_plane: Add support for YUV444 formats
Support displaying DRM_FORMAT_YUV444 and DRM_FORMAT_YVU444 formats.
Tested with kmstest and kodi. e.g.

kmstest -r 1920x1080@60 -f 400x300-YU24

Note: without the shift of width, only half the chroma is fetched,
resulting in correct left half of image and corrupt colours on right half.

The increase in width shouldn't affect fetching of Y data,
as the hardware will clamp at dest width.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:14:59 +01:00
Maxime Ripard
4044c9a7e9 drm/vc4: hvs: Destroy dlist allocations immediately when running a test
When running a kunit test, the driver runs with a mock device. As such,
any attempt to read or write to a hardware register will fail the
current test immediately.

The dlist allocation management recently introduced will read the
current frame count from the HVS to defer its destruction until a
subsequent frame has been output. This obviously involves a register
read that fails the Kunit tests.

Change the destruction deferral function to destroy the allocation
immediately if we run under kunit. This is essentially harmless since
the main reason for that deferall is to prevent any access to the
hardware dlist while a frame described by that list is rendered. On our
mock driver, we have neither a hardware dlist nor a rendering, so it
doesn't matter.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:14:59 +01:00
Maxime Ripard
b9a15dc984 drm/vc4: hvs: Move the dlist allocation destruction to a function
We'll need to destroy a dlist allocation in multiple code paths, so
let's move it to a separate function.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:14:59 +01:00
Maxime Ripard
3d63a5d08b drm/vc4: hvs: Initialize the dlist allocation list entry
The vc4_hvs_dlist_allocation structure has a list that we don't
initialize when we allocate a new instance.

This makes any call reading the list structure (such as list_empty) fail
with a NULL pointer dereference.

Let's make sure our list is always initialized.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:14:59 +01:00
Maxime Ripard
74a7b3640e drm/vc4: hvs: Defer dlist slots deallocation
During normal operations, the cursor position update is done through an
asynchronous plane update, which on the vc4 driver basically just
modifies the right dlist word to move the plane to the new coordinates.

However, when we have the overscan margins setup, we fall back to a
regular commit when we are next to the edges. And since that commit
happens to be on a cursor plane, it's considered a legacy cursor update
by KMS.

The main difference it makes is that it won't wait for its completion
(ie, next vblank) before returning. This means if we have multiple
commits happening in rapid succession, we can have several of them
happening before the next vblank.

In parallel, our dlist allocation is tied to a CRTC state, and each time
we do a commit we end up with a new CRTC state, with the previous one
being freed. This means that we free our previous dlist entry (but don't
clear it though) every time a new one is being committed.

Now, if we were to have two commits happening before the next vblank, we
could end up freeing reusing the same dlist entries before the next
vblank.

Indeed, we would start from an initial state taking, for example, the
dlist entries 10 to 20, then start a commit taking the entries 20 to 30
and setting the dlist pointer to 20, and freeing the dlist entries 10 to
20. However, since we haven't reach vblank yet, the HVS is still using
the entries 10 to 20.

If we were to make a new commit now, chances are the allocator are going
to give the 10 to 20 entries back, and we would change their content to
match the new state. If vblank hasn't happened yet, we just corrupted
the active dlist entries.

A first attempt to solve this was made by creating an intermediate dlist
buffer to store the current (ie, as of the last commit) dlist content,
that we would update each time the HVS is done with a frame. However, if
the interrupt handler missed the vblank window, we would end up copying
our intermediate dlist to the hardware one during the composition,
essentially creating the same issue.

Since making sure that our interrupt handler runs within a fixed,
constrained, time window would require to make Linux a real-time kernel,
this seems a bit out of scope.

Instead, we can work around our original issue by keeping the dlist
slots allocation longer. That way, we won't reuse a dlist slot while
it's still in flight. In order to achieve this, instead of freeing the
dlist slot when its associated CRTC state is destroyed, we'll queue it
in a list.

A naive implementation would free the buffers in that queue when we get
our end of frame interrupt. However, there's still a race since, just
like in the shadow dlist case, we don't control when the handler for
that interrupt is going to run. Thus, we can end up with a commit adding
an old dlist allocation to our queue during the window between our
actual interrupt and when our handler will run. And since that buffer is
still being used for the composition of the current frame, we can't free
it right away, exposing us to the original bug.

Fortunately for us, the hardware provides a frame counter that is
increased each time the first line of a frame is being generated.
Associating the frame counter the image is supposed to go away to the
allocation, and then only deallocate buffers that have a counter below
or equal to the one we see when the deallocation code should prevent the
above race from occuring.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:14:59 +01:00
Dom Cobley
e3037c4bb0 vc4_hdmi: Avoid log spam for audio start failure
We regularly get dmesg error reports of:
[   18.184066] hdmi-audio-codec hdmi-audio-codec.3.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19
[   18.184098]  MAI: soc_pcm_open() failed (-19)

Currently I get 30 of these when booting to desktop.
We always say, ignore they are harmless, but removing them would be good.

A bit of investigation shows, for me, the errors are all generated by second, unused hdmi interface.

It shows as an alsa device, and pulseaudio attempts to open it (numerous times), generating a kernel
error message each time.

systemctl --user restart pulseaudio.service generates 6 additional error messages.

The error messages all come through:
a009a9c0d7/sound/soc/soc-pcm.c (L39)

which suggests returning ENOTSUPP, rather that ENODEV will be quiet. And indeed it is.

Note: earlier kernels do not have the quiet ENOTSUPP, so additional cherry-picks will be needed to backport
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:14:59 +01:00
Dom Cobley
5789e9ed63 drm/vc4_hdmi: Allow hotplug detect to be forced
See: https://forum.libreelec.tv/thread/24783-tv-avr-turns-back-on-right-after-turning-them-off

While the kernel provides a :D flag for assuming device is connected,
it doesn't stop this function from being called and generating a cec_phys_addr_invalidate
message when hotplug is deasserted.

That message provokes a flurry of CEC messages which for many users results in the TV
switching back on again and it's very hard to get it to stay switched off.

It seems to only occur with an AVR and TV connected but has been observed across a
number of manufacturers.

The issue started with https://github.com/raspberrypi/linux/pull/4371
and this provides an optional way of getting back the old behaviour

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:14:59 +01:00
Maxime Ripard
364a27c646 drm/vc4: hvs: Skip DebugFS Registration for FKMS
FKMS doesn't have an HVS and it's expected. Return from the debugfs init
function immediately if we're running with fkms.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:14:59 +01:00
Dave Stevenson
1d0a7a4a3a drm/atomic: If margins are updated, update all planes.
Margins may be implemented by scaling the planes, but as there
is no way of intercepting the set_property for a standard property,
and all planes are checked in drm_atomic_check_only before the
connectors, there's now way to add the planes into the state
from the driver.

If the margin properties change, add all corresponding planes to
the state.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:14:59 +01:00
Daniel Vetter
578cd82874 drm/atomic-helpers: remove legacy_cursor_update hacks
The stuff never really worked, and leads to lots of fun because it
out-of-order frees atomic states. Which upsets KASAN, among other
things.

For async updates we now have a more solid solution with the
->atomic_async_check and ->atomic_async_commit hooks. Support for that
for msm and vc4 landed. nouveau and i915 have their own commit
routines, doing something similar.

For everyone else it's probably better to remove the use-after-free
bug, and encourage folks to use the async support instead. The
affected drivers which register a legacy cursor plane and don't either
use the new async stuff or their own commit routine are: amdgpu,
atmel, mediatek, qxl, rockchip, sti, sun4i, tegra, virtio, and vmwgfx.

Inspired by an amdgpu bug report.

v2: Drop RFC, I think with amdgpu converted over to use
atomic_async_check/commit done in

commit 674e78acae
Author: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Date:   Wed Dec 5 14:59:07 2018 -0500

    drm/amd/display: Add fast path for cursor plane updates

we don't have any driver anymore where we have userspace expecting
solid legacy cursor support _and_ they are using the atomic helpers in
their fully glory. So we can retire this.

v3: Paper over msm and i915 regression. The complete_all is the only
thing missing afaict.

v4: Rebased on recent kernel, added extra link for vc4 bug.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=199425
Link: https://lore.kernel.org/all/20220221134155.125447-9-maxime@cerno.tech/
Cc: mikita.lipski@amd.com
Cc: Michel Dänzer <michel@daenzer.net>
Cc: harry.wentland@amd.com
Cc: Rob Clark <robdclark@gmail.com>
Cc: "Kazlauskas, Nicholas" <nicholas.kazlauskas@amd.com>
Tested-by: Maxime Ripard <maxime@cerno.tech>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:14:59 +01:00
Dave Stevenson
6abf7d4b78 drm/vc4: Force trigger of dlist update on margins change
When the margins are changed, the dlist needs to be regenerated
with the changed updated dest regions for each of the planes.

Setting the zpos_changed flag is sufficient to trigger that
without doing a full modeset, therefore set it should the
margins be changed.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:14:59 +01:00
Dom Cobley
05eb972da1 vc4/drm:plane: Make use of chroma siting parameter
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:14:59 +01:00
Dom Cobley
bd4cb4e07c drm: Add chroma siting properties
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:14:59 +01:00
Dom Cobley
5c174dcc30 vc4/drm: Handle fractional coordinates using the phase field
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:14:59 +01:00
Dom Cobley
3102839c23 vc4/drm: vc4_plane: Keep fractional source coords inside state
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:14:59 +01:00
Dave Stevenson
1b9f393eb3 drm/bridge: tc358762: Ignore EPROBE_DEFER when logging errors
mipi_dsi_attach can fail due to resources not being available
yet, therefore do not log error messages should they occur.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:14:59 +01:00
Dave Stevenson
2c54afcf39 drm/dsi: Document the meaning and spec references for MIPI_DSI_MODE_*
The MIPI_DSI_MODE_* flags have fairly terse descriptions and no reference
to the DSI specification as to their exact meaning. Usage has therefore
been rather fluid.

Extend the descriptions and provide references to the part of the
MIPI DSI specification regarding what they mean.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:14:58 +01:00
Dave Stevenson
28ebe0df48 drm/vc4: Disable Gamma control on HVS5 due to issues writing the table
Still under investigation, but the conditions under which the HVS
will accept values written to the gamma PWL are not straightforward.

Disable gamma on HVS5 again until it can be resolved to avoid
gamma being enabled with an incorrect table.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:14:58 +01:00
Dave Stevenson
50ba2bcc34 drm/vc4: Validate the size of the gamma_lut
Add a check to vc4_hvs_gamma_check to ensure a new non-empty
gamma LUT is of the correct length before accepting it.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:14:58 +01:00
Dave Stevenson
153ef83edb drm/vc4: Only add gamma properties once.
Two calls were made to drm_crtc_enable_color_mgmt to add gamma
and CTM, however they were both set to add the gamma properties,
so they ended up added twice.

Fixes: 766cc6b1f7 "drm/vc4: Add CTM support"
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:14:58 +01:00
Dave Stevenson
4046b8e879 drm/vc4: Enable gamma block only when required.
With HVS5 the gamma block is now only reprogrammed with
a disable/enable. Loading the table from vc4_hvs_init_channel
(called from vc4_hvs_atomic_enable) appears to be at an
invalid point in time and so isn't applied.

Switch to enabling and disabling the gamma table instead. This
isn't safe if the pipeline is running, but it isn't now.
For HVS4 it is safe to enable and disable dynamically, so
adopt that approach there too.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:14:58 +01:00
Dave Stevenson
da1599773d drm: Check whether the gamma lut has changed before updating
drm_crtc_legacy_gamma_set updates the gamma_lut blob unconditionally,
which leads to unnecessary reprogramming of hardware.

Check whether the blob contents has actually changed before
signalling that it has been updated.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:14:58 +01:00
Mateusz Kwiatkowski
f30cf98f85 drm/vc4: Make VEC progressive modes readily accessible
Add predefined modelines for the 240p (NTSC) and 288p (PAL) progressive
modes, and report them through vc4_vec_connector_get_modes().

Signed-off-by: Mateusz Kwiatkowski <kfyatek+publicgit@gmail.com>
2024-08-05 11:14:58 +01:00
Maxime Ripard
bb01ddb408 drm/vc4: hvs: Force modeset on gamma lut change
The HVS Gamma block can only be updated when idle, so we need to disable
the HVS channel when the gamma property is set in an atomic commit.

Since the pixelvalve cannot have its assigned channel halted without
stalling unless it's disabled as well, in our case that means forcing a
full disable / enable cycle on the pipeline.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:14:58 +01:00
Dave Stevenson
a666cc4fcb drm/vc4: Add debugfs node that dumps the vc5 gamma PWL entries
This helps with debugging the conversion from a 256 point gamma LUT to
16 point PWL entries as used by the BCM2711.

Co-developed-by: Juerg Haefliger <juergh@canonical.com>
Signed-off-by: Juerg Haefliger <juergh@canonical.com>
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:14:58 +01:00
Dave Stevenson
2e36f559b1 drm/vc4: Add support for gamma on BCM2711
BCM2711 changes from a 256 entry lookup table to a 16 point
piecewise linear function as the pipeline bitdepth has increased
to make a LUT unwieldy.

Implement a simple conversion from a 256 entry LUT that userspace
is likely to expect to 16 evenly spread points in the PWL. This
could be improved with curve fitting at a later date.

Co-developed-by: Juerg Haefliger <juergh@canonical.com>
Signed-off-by: Juerg Haefliger <juergh@canonical.com>
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2024-08-05 11:14:58 +01:00
Dave Stevenson
d4edf57457 drm/vc4: fkms: Add firmware-kms mode
This is a squash of all firmware-kms related patches from previous
branches, up to and including
"drm/vc4: Set the possible crtcs mask correctly for planes with FKMS"
plus a couple of minor fixups for the 5.9 branch.
Please refer to earlier branches for full history.

This patch includes work by Eric Anholt, James Hughes, Phil Elwell,
Dave Stevenson, Dom Cobley, and Jonathon Bell.

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

drm/vc4: Fixup firmware-kms after "drm/atomic: Pass the full state to CRTC atomic enable/disable"

Prototype for those calls changed, so amend fkms (which isn't
upstream) to match.

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

drm/vc4: Fixup fkms for API change

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

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

drm/vc4: Make normalize_zpos conditional on using fkms

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

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

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

drm/vc4: FKMS: Change of Broadcast RGB mode needs a mode change

The Broadcast RGB (aka HDMI limited/full range) property is only
notified to the firmware on mode change, so this needs to be
signalled when set.

https://github.com/raspberrypi/firmware/issues/1580

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

vc4/drv: Only notify firmware of display done with kms

fkms driver still wants firmware display to be active

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

ydrm/vc4: fkms: Fix margin calculations for the right/bottom edges

The calculations clipped the right/bottom edge of the clipped
range based on the left/top margins.

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

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

drm/vc4: fkms: Use new devm_rpi_firmware_get api

drm/kms: Add allow_fb_modifiers

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

drm/vc4: Add async update support for cursor planes

Now that cursors are implemented as regular planes, all cursor
movements result in atomic updates. As the firmware-kms driver
doesn't support asynchronous updates, these are synchronous, which
limits the update rate to the screen refresh rate. Xorg seems unaware
of this (or at least of the effect of this), because if the mouse is
configured with a higher update rate than the screen then continuous
mouse movement results in an increasing backlog of mouse events -
cue extreme lag.

Add minimal support for asynchronous updates - limited to cursor
planes - to eliminate the lag.

See: https://github.com/raspberrypi/linux/pull/4971
     https://github.com/raspberrypi/linux/issues/4988

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

drivers/gpu/drm/vc4: Add missing 32-bit RGB formats

The missing 32-bit per pixel ABGR and various "RGB with an X value"
formats are added. Change sent by Dave Stevenson.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>

drm: vc4: Fixup duplicated macro definition in vc4_firmware_kms

Both vc4_drv.h and vc4_firmware_kms.c had definitions for
to_vc4_crtc.

Rename the fkms one to make it unique, and drop the magic
define vc4_crtc vc4_kms_crtc
define to_vc4_crtc to_vc4_kms_crtc
that renamed half the variable and function names in a slightly
unexpected way.

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

drm/vc4: Fix FKMS for when the YUV chroma planes are different buffers

The code was assuming that it was a single buffer with offsets,
when kmstest uses separate buffers and 0 offsets for each plane.

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

drm/vc4: fkms: Rename plane related functions

The name collide with the Full KMS functions that are going to be made
public.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>

drm/vc4_fkms: Fix up interrupt handler for both 2835/2711 and 2712

2712 has switched from using the SMI peripheral to another interrupt
source for the vsync interrupt, so handle both sources cleanly.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:14:58 +01:00
Mateusz Kwiatkowski
f867c09894 drm/vc4: Allow setting the TV norm via module parameter
Similar to the ch7006 and nouveau drivers, introduce a "tv_mode" module
parameter that allow setting the TV norm by specifying vc4.tv_norm= on
the kernel command line.

If that is not specified, try inferring one of the most popular norms
(PAL or NTSC) from the video mode specified on the command line. On
Raspberry Pis, this causes the most common cases of the sdtv_mode
setting in config.txt to be respected.

Signed-off-by: Mateusz Kwiatkowski <kfyatek+publicgit@gmail.com>

drm/vc4: Do not reset tv mode as this is already handled by framework

In vc4_vec_connector_reset, the tv mode is already reset to the
property default by drm_atomic_helper_connector_tv_reset, so there
is no need for a local fixup to potentially some other default.

Fixes: 96922af144 ("drm/vc4: Allow setting the TV norm via module parameter")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:14:58 +01:00
Dave Stevenson
992880324a drm/atomic: Don't fixup modes that haven't been reset
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2024-08-05 11:14:58 +01:00
Dave Stevenson
6acc8b71fb 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>
2024-08-05 11:14:58 +01:00
Dom Cobley
c391add1b5 raspberrypi-firmware: Update mailbox commands
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2024-08-05 11:14:58 +01:00
Phil Elwell
1020679cee Revert "usb: phy: generic: Get the vbus supply"
This reverts commit 03e607cbb2.
2024-08-05 11:14:57 +01:00
Dom Cobley
e102fcbd3e Revert "ARM: dts: bcm2711: Add BCM2711 xHCI support"
This reverts commit 522c35e08b.
2024-08-05 11:14:57 +01:00
Dom Cobley
529d61d2d4 Revert "PCI: brcmstb: Configure HW CLKREQ# mode appropriate for downstream device"
This reverts commit e2596dcf1e.
2024-08-05 11:14:57 +01:00
Dom Cobley
60a73c39d3 Revert "Revert "xhci: add quirk for host controllers that don't update endpoint DCS""
This reverts commit 5bef4b3cb9.

We don't agree with upstream revert so undo it.
2024-08-05 11:14:57 +01:00
Phil Elwell
8dcdb0c9aa Revert "net: bcmgenet: Request APD, DLL disable and IDDQ-SR"
This reverts commit c3a4c69360, which
broke rebooting when network booting.

See: https://github.com/raspberrypi/rpi-eeprom/issues/417

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:14:57 +01:00
Phil Elwell
7e87412e34 Revert "Bluetooth: Always request for user confirmation for Just Works"
This reverts commit 92516cd97f.

Thi commit "Bluetooth: Always request for user confirmation for Just
Works" prevents BLE devices pairing in (at least) the Raspberry Pi OS
GUI. After reverting it, pairing works again.

If another solution to the problem is found then this reversion will
be removed.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:14:57 +01:00
Phil Elwell
81e4279674 Revert "Bluetooth: Always request for user confirmation for Just Works (LE SC)"
This reverts commit ffee202a78.

The commit "Bluetooth: Always request for user confirmation for Just
Works" prevents BLE devices pairing in (at least) the Raspberry Pi OS
GUI. After reverting it, pairing works again. Although this companion
commit ("... (LE SC)") has not been demonstrated to be problematic,
it follows the same logic and therefore could affect some use cases.

If another solution to the problem is found then this reversion will
be removed.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2024-08-05 11:14:57 +01:00
Phil Elwell
c121bde3bb Revert "spi: spidev: Fix CS polarity if GPIO descriptors are used"
This reverts commit 83b2a8fe43.
2024-08-05 11:14:57 +01:00
Andreas Blaesius
a27e085273 Use GitHubs issue form for bug reports
Use GitHubs issue form for bug reports.

- modern look
- user don't need to mess with given markdown parts while filling the issue template

Setup config.yml for general questions and problems with the Raspbian distribution packages.

Update issue templates (#2736)

Adding Pi 5 as a device to bug_report.yml
2024-08-05 11:14:57 +01:00
Dave Stevenson
44cb993115 README: Add README.md with CI kernel build status tags
This is a copy of README with the tags added.

You can not delete the file README as then checkpatch complains
you aren't in a kernel tree.

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

README: Show rpi-6.5.y build status

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

README: show rpi-6.6.y build status

Replace rpi-6.5.y with rpi-6.6.y in the build status list.
2024-08-05 11:14:57 +01:00
Dave Stevenson
c56b91fefe workflows: We all love checkpatch, so add it to the CI workflows
This is currently running on defaults, so the --strict desired
for media drivers and similar won't be observed. That may be
possible to add later.

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

.github: Add Github Workflow for KUnit

Now that we have some KUnit coverage, let's add a github actions file to
run them on each push or pull request.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>

.github/workflows: Add dtoverlaycheck workflow

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

.github/workflows: Create workflow to CI kernel builds

Builds the bcmrpi, bcm2709, bcm2711, and bcm2835 32 bit kernels,
and defconfig and bcm2711 64bit kernels, saving the artifacts for
7 days.

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

.github: Skip broken Generic DRM/KMS Unit Tests

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

.github/workflows: Set warnings-as-errors for builds

To avoid code with build warnings being introduced into the tree, force
CONFIG_WERROR=y in the build workflow.

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

.github/workflows: Correct kernel builds artifacts

Modify the kernel build workflow to create artifacts with the correct
names and structure, both as an example of what we expect and in case
anyone wants to use the output.

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

.github/workflows: Switch to a matrix build

Remove the per-build duplication by putting build parameters in a
matrix.

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

.github/workflows: Retain artifacts for 90 days

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

.github/workflows: Add a bcm2712 build configuration

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

Update kernel-build.yml to use node.js 20

Upgrade the actions to v4 to get rid of the warning about migrating from node.js 16.

Update kunit.yml to use node.js 20

Bump actions/checkout to v4.

Update dtoverlaycheck.yml to node.js 20
2024-08-05 11:14:57 +01:00
1142 changed files with 229975 additions and 3914 deletions

92
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@@ -0,0 +1,92 @@
name: "Bug report"
description: Create a report to help us fix your issue
body:
- type: markdown
attributes:
value: |
**Is this the right place for my bug report?**
This repository contains the Linux kernel used on the Raspberry Pi.
If you believe that the issue you are seeing is kernel-related, this is the right place.
If not, we have other repositories for the GPU firmware at [github.com/raspberrypi/firmware](https://github.com/raspberrypi/firmware) and Raspberry Pi userland applications at [github.com/raspberrypi/userland](https://github.com/raspberrypi/userland).
If you have problems with the Raspbian distribution packages, report them in the [github.com/RPi-Distro/repo](https://github.com/RPi-Distro/repo).
If you simply have a question, then [the Raspberry Pi forums](https://www.raspberrypi.org/forums) are the best place to ask it.
- type: textarea
id: description
attributes:
label: Describe the bug
description: |
Add a clear and concise description of what you think the bug is.
validations:
required: true
- type: textarea
id: reproduce
attributes:
label: Steps to reproduce the behaviour
description: |
List the steps required to reproduce the issue.
validations:
required: true
- type: dropdown
id: model
attributes:
label: Device (s)
description: On which device you are facing the bug?
multiple: true
options:
- Raspberry Pi Zero
- Raspberry Pi Zero W/WH
- Raspberry Pi Zero 2 W
- Raspberry Pi 1 Mod. A
- Raspberry Pi 1 Mod. A+
- Raspberry Pi 1 Mod. B
- Raspberry Pi 1 Mod. B+
- Raspberry Pi 2 Mod. B
- Raspberry Pi 2 Mod. B v1.2
- Raspberry Pi 3 Mod. A+
- Raspberry Pi 3 Mod. B
- Raspberry Pi 3 Mod. B+
- Raspberry Pi 4 Mod. B
- Raspberry Pi 400
- Raspberry Pi 5
- Raspberry Pi CM1
- Raspberry Pi CM3
- Raspberry Pi CM3 Lite
- Raspberry Pi CM3+
- Raspberry Pi CM3+ Lite
- Raspberry Pi CM4
- Raspberry Pi CM4 Lite
- Other
validations:
required: true
- type: textarea
id: system
attributes:
label: System
description: |
Copy and paste the results of the raspinfo command in to this section.
Alternatively, copy and paste a pastebin link, or add answers to the following questions:
* Which OS and version (`cat /etc/rpi-issue`)?
* Which firmware version (`vcgencmd version`)?
* Which kernel version (`uname -a`)?
validations:
required: true
- type: textarea
id: logs
attributes:
label: Logs
description: |
If applicable, add the relevant output from `dmesg` or similar.
- type: textarea
id: additional
attributes:
label: Additional context
description: |
Add any other relevant context for the problem.

9
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,9 @@
blank_issues_enabled: false
contact_links:
- name: "⛔ Question"
url: https://www.raspberrypi.org/forums
about: "Please do not use GitHub for asking questions. If you simply have a question, then the Raspberry Pi forums are the best place to ask it. Thanks in advance for helping us keep the issue tracker clean!"
- name: "⛔ Problems with the Raspbian distribution packages"
url: https://github.com/RPi-Distro/repo
about: "If you have problems with the Raspbian distribution packages, please report them in the github.com/RPi-Distro/repo."

18
.github/workflows/checkpatch.yml vendored Normal file
View File

@@ -0,0 +1,18 @@
name: Advisory checkpatch review
on: [pull_request]
jobs:
review:
name: checkpatch review
runs-on: ubuntu-latest
steps:
- name: 'Calculate PR commits + 1'
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ env.PR_FETCH_DEPTH }}
- name: Copy checkpatch.conf
run: cp ${{github.workspace}}/.github/workflows/ci_checkpatch.conf ${{github.workspace}}/.checkpatch.conf
- name: Run checkpatch review
uses: webispy/checkpatch-action@v9

4
.github/workflows/ci_checkpatch.conf vendored Normal file
View File

@@ -0,0 +1,4 @@
--no-tree
--ignore FILE_PATH_CHANGES
--ignore GIT_COMMIT_ID
--ignore SPDX_LICENSE_TAG

48
.github/workflows/dtoverlaycheck.yml vendored Normal file
View File

@@ -0,0 +1,48 @@
name: Pi dtoverlay checks
on:
pull_request:
paths-ignore:
- '.github/**'
branches: [ "rpi-*" ]
push:
paths-ignore:
- '.github/**'
branches: [ "rpi-*" ]
workflow_dispatch:
env:
UTILS_DIR: "${{github.workspace}}/utils"
jobs:
dtoverlaycheck:
runs-on: ubuntu-latest
steps:
- name: Install toolchain
run: |
sudo apt update
sudo apt-get install gcc-arm-linux-gnueabihf libfdt-dev device-tree-compiler
timeout-minutes: 10
- uses: actions/checkout@v4
with:
fetch-depth: 1
clean: true
- name: overlaycheck
run: |
git clone https://github.com/raspberrypi/utils ${{env.UTILS_DIR}}
cd ${{env.UTILS_DIR}}
pwd
mkdir build
cd build
pwd
cmake ..
make -j4
sudo make install
cd ${{github.workspace}}
pwd
make ARCH=arm KERNEL=kernel CROSS_COMPILE=arm-linux-gnueabihf- bcm2711_defconfig
make ARCH=arm KERNEL=kernel CROSS_COMPILE=arm-linux-gnueabihf- dtbs
${{env.UTILS_DIR}}/overlaycheck/overlaycheck

108
.github/workflows/kernel-build.yml vendored Normal file
View File

@@ -0,0 +1,108 @@
name: Pi kernel build tests
on:
pull_request:
paths-ignore:
- '.github/**'
branches: [ "rpi-*" ]
push:
paths-ignore:
- '.github/**'
branches: [ "rpi-*" ]
workflow_dispatch:
env:
NUM_JOBS: 6
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: bcm2835
arch: arm
defconfig: bcm2835_defconfig
kernel: kernel
- name: arm64
arch: arm64
defconfig: defconfig
kernel: kernel8
- name: bcmrpi
arch: arm
defconfig: bcmrpi_defconfig
kernel: kernel
- name: bcm2709
arch: arm
defconfig: bcm2709_defconfig
kernel: kernel7
- name: bcm2711
arch: arm
defconfig: bcm2711_defconfig
kernel: kernel7l
- name: bcm2711_arm64
arch: arm64
defconfig: bcm2711_defconfig
kernel: kernel8
- name: bcm2712
arch: arm64
defconfig: bcm2712_defconfig
kernel: kernel_2712
steps:
- name: Update install
run:
sudo apt-get update
- name: Install toolchain
run:
if [[ "${{matrix.arch}}" == "arm64" ]]; then
sudo apt-get install gcc-aarch64-linux-gnu;
else
sudo apt-get install gcc-arm-linux-gnueabihf;
fi
timeout-minutes: 5
- uses: actions/checkout@v4
with:
fetch-depth: 1
clean: true
- name: Build kernel ${{matrix.name}}
run: |
mkdir ${{github.workspace}}/build
export ARCH=${{matrix.arch}}
if [[ "$ARCH" == "arm64" ]]; then
export CROSS_COMPILE=aarch64-linux-gnu-
export DTS_SUBDIR=broadcom
export IMAGE=Image.gz
else
export CROSS_COMPILE=arm-linux-gnueabihf-
export DTS_SUBDIR=broadcom
export IMAGE=zImage
fi
make O=${{github.workspace}}/build ${{matrix.defconfig}}
scripts/config --file ${{github.workspace}}/build/.config --set-val CONFIG_WERROR y
make O=${{github.workspace}}/build -j ${{env.NUM_JOBS}} $IMAGE modules dtbs
mkdir -p ${{github.workspace}}/install/boot/overlays
make O=${{github.workspace}}/build INSTALL_MOD_PATH=${{github.workspace}}/install modules_install
cp ${{github.workspace}}/build/arch/${ARCH}/boot/dts/${DTS_SUBDIR}/*.dtb ${{github.workspace}}/install/boot/
cp ${{github.workspace}}/build/arch/${ARCH}/boot/dts/overlays/*.dtb* ${{github.workspace}}/install/boot/overlays/
cp ${{github.workspace}}/arch/${ARCH}/boot/dts/overlays/README ${{github.workspace}}/install/boot/overlays/
cp ${{github.workspace}}/build/arch/${ARCH}/boot/$IMAGE ${{github.workspace}}/install/boot/${{matrix.kernel}}.img
- name: Tar build
run: tar -cvf ${{matrix.name}}_build.tar -C ${{github.workspace}}/install .
- name: Upload results
uses: actions/upload-artifact@v4
with:
name: ${{matrix.name}}_build
path: ${{matrix.name}}_build.tar
retention-days: 90

57
.github/workflows/kunit.yml vendored Normal file
View File

@@ -0,0 +1,57 @@
name: KUnit Tests
on:
pull_request:
branches: [ "rpi-*"]
push:
branches: [ "rpi-*"]
jobs:
core:
name: Generic DRM/KMS Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Generic DRM Tests
run: |
echo Skipping ./tools/testing/kunit/kunit.py run \
--kunitconfig=drivers/gpu/drm/tests
vc4-arm:
name: VC4 Unit Tests on ARM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y gcc-arm-linux-gnueabihf qemu-system-arm
- name: Run VC4 Tests
run: |
./tools/testing/kunit/kunit.py run \
--kunitconfig=drivers/gpu/drm/vc4/tests \
--cross_compile=arm-linux-gnueabihf- --arch=arm
vc4-arm64:
name: VC4 Unit Tests on ARM64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu qemu-system-arm
- name: Run VC4 Tests
run: |
./tools/testing/kunit/kunit.py run \
--kunitconfig=drivers/gpu/drm/vc4/tests \
--cross_compile=aarch64-linux-gnu- --arch=arm64

View File

@@ -0,0 +1,127 @@
.. SPDX-License-Identifier: GPL-2.0
BCM2835 ISP Driver
==================
Introduction
------------
The BCM2835 Image Sensor Pipeline (ISP) is a fixed function hardware pipeline
for performing image processing operations. Images are fed to the input
of the ISP through memory frame buffers. These images may be in various YUV,
RGB, or Bayer formats. A typical use case would have Bayer images obtained from
an image sensor by the BCM2835 Unicam peripheral, written to a memory
frame buffer, and finally fed into the input of the ISP. Two concurrent output
images may be generated in YUV or RGB format at different resolutions.
Statistics output is also generated for Bayer input images.
The bcm2835-isp driver exposes the following media pads as V4L2 device nodes:
.. tabularcolumns:: |l|l|l|l|
.. cssclass: longtable
.. flat-table::
* - *Pad*
- *Direction*
- *Purpose*
- *Formats*
* - "bcm2835-isp0-output0"
- sink
- Accepts Bayer, RGB or YUV format frame buffers as input to the ISP HW
pipeline.
- :ref:`RAW8 <V4L2-PIX-FMT-SRGGB8>`,
:ref:`RAW10P <V4L2-PIX-FMT-SRGGB10P>`,
:ref:`RAW12P <V4L2-PIX-FMT-SRGGB12P>`,
:ref:`RAW14P <V4L2-PIX-FMT-SRGGB14P>`,
:ref:`RAW16 <V4L2-PIX-FMT-SRGGB16>`,
:ref:`RGB24/BGR24 <V4L2-PIX-FMT-RGB24>`,
:ref:`YUYV <V4L2-PIX-FMT-YUYV>`,
:ref:`YVYU <V4L2-PIX-FMT-YVYU>`,
:ref:`UYVY <V4L2-PIX-FMT-UYVY>`,
:ref:`VYUY <V4L2-PIX-FMT-VYUY>`,
:ref:`YUV420/YVU420 <V4L2-PIX-FMT-YUV420>`
* - "bcm2835-isp0-capture1"
- source
- High resolution YUV or RGB processed output from the ISP.
- :ref:`RGB565 <V4L2-PIX-FMT-RGB565>`,
:ref:`RGB24/BGR24 <V4L2-PIX-FMT-RGB24>`,
:ref:`ABGR32 <V4L2-PIX-FMT-ABGR32>`,
:ref:`YUYV <V4L2-PIX-FMT-YUYV>`,
:ref:`YVYU <V4L2-PIX-FMT-YVYU>`,
:ref:`UYVY <V4L2-PIX-FMT-UYVY>`,
:ref:`VYUY <V4L2-PIX-FMT-VYUY>`.
:ref:`YUV420/YVU420 <V4L2-PIX-FMT-YUV420>`,
:ref:`NV12/NV21 <V4L2-PIX-FMT-NV12>`,
* - "bcm2835-isp0-capture2"
- source
- Low resolution YUV processed output from the ISP. The output of
this pad cannot have a resolution larger than the "bcm2835-isp0-capture1" pad in any dimension.
- :ref:`YUYV <V4L2-PIX-FMT-YUYV>`,
:ref:`YVYU <V4L2-PIX-FMT-YVYU>`,
:ref:`UYVY <V4L2-PIX-FMT-UYVY>`,
:ref:`VYUY <V4L2-PIX-FMT-VYUY>`.
:ref:`YUV420/YVU420 <V4L2-PIX-FMT-YUV420>`,
:ref:`NV12/NV21 <V4L2-PIX-FMT-NV12>`,
* - "bcm2835-isp0-capture1"
- source
- Image statistics calculated from the input image provided on the
"bcm2835-isp0-output0" pad. Statistics are only available for Bayer
format input images.
- :ref:`v4l2-meta-fmt-bcm2835-isp-stats`.
Pipeline Configuration
----------------------
The ISP pipeline can be configure through user-space by calling
:ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` on the “bcm2835-isp0-output0”
node with the appropriate parameters as shown in the table below.
.. tabularcolumns:: |p{2cm}|p{5.0cm}|
.. cssclass: longtable
.. flat-table::
* - *id*
- *Parameter*
* - ``V4L2_CID_USER_BCM2835_ISP_CC_MATRIX``
- struct :c:type:`bcm2835_isp_custom_ccm`
* - ``V4L2_CID_USER_BCM2835_ISP_LENS_SHADING``
- struct :c:type:`bcm2835_isp_lens_shading`
* - ``V4L2_CID_USER_BCM2835_ISP_BLACK_LEVEL``
- struct :c:type:`bcm2835_isp_black_level`
* - ``V4L2_CID_USER_BCM2835_ISP_GEQ``
- struct :c:type:`bcm2835_isp_geq`
* - ``V4L2_CID_USER_BCM2835_ISP_GAMMA``
- struct :c:type:`bcm2835_isp_gamma`
* - ``V4L2_CID_USER_BCM2835_ISP_DENOISE``
- struct :c:type:`bcm2835_isp_denoise`
* - ``V4L2_CID_USER_BCM2835_ISP_SHARPEN``
- struct :c:type:`bcm2835_isp_sharpen`
* - ``V4L2_CID_USER_BCM2835_ISP_DPC``
- struct :c:type:`bcm2835_isp_dpc`
++++++++++++++++++++++++
Configuration Parameters
++++++++++++++++++++++++
.. kernel-doc:: include/uapi/linux/bcm2835-isp.h
:functions: bcm2835_isp_rational bcm2835_isp_ccm bcm2835_isp_custom_ccm
bcm2835_isp_gain_format bcm2835_isp_lens_shading
bcm2835_isp_black_level bcm2835_isp_geq bcm2835_isp_gamma
bcm2835_isp_denoise bcm2835_isp_sharpen
bcm2835_isp_dpc_mode bcm2835_isp_dpc

View File

@@ -14,6 +14,8 @@ properties:
enum:
- brcm,bcm2711-hdmi0
- brcm,bcm2711-hdmi1
- brcm,bcm2712-hdmi0
- brcm,bcm2712-hdmi1
reg:
items:

View File

@@ -21,6 +21,7 @@ properties:
- brcm,bcm2711-dsi1
- brcm,bcm2835-dsi0
- brcm,bcm2835-dsi1
- brcm,bcm2711-dsi1
reg:
maxItems: 1

View File

@@ -13,6 +13,7 @@ properties:
compatible:
enum:
- brcm,bcm2711-hvs
- brcm,bcm2712-hvs
- brcm,bcm2835-hvs
reg:
@@ -36,7 +37,9 @@ if:
properties:
compatible:
contains:
const: brcm,bcm2711-hvs
enum:
- brcm,bcm2711-hvs
- brcm,bcm2712-hvs
then:
required:

View File

@@ -20,6 +20,9 @@ properties:
- brcm,bcm2711-pixelvalve2
- brcm,bcm2711-pixelvalve3
- brcm,bcm2711-pixelvalve4
- brcm,bcm2712-pixelvalve0
- brcm,bcm2712-pixelvalve1
- brcm,bcm2712-pixelvalve2
reg:
maxItems: 1

View File

@@ -11,7 +11,10 @@ maintainers:
properties:
compatible:
const: brcm,bcm2835-txp
enum:
- brcm,bcm2712-mop
- brcm,bcm2712-moplet
- brcm,bcm2835-txp
reg:
maxItems: 1

View File

@@ -18,6 +18,7 @@ properties:
compatible:
enum:
- brcm,bcm2711-vc5
- brcm,bcm2712-vc6
- brcm,bcm2835-vc4
- brcm,cygnus-vc4

View File

@@ -22,6 +22,8 @@ properties:
- startek,kd050hdfia020
- tdo,tl050hdv35
- wanchanglong,w552946aba
- raspberrypi,dsi-5inch
- raspberrypi,dsi-7inch
- const: ilitek,ili9881c
reg:

View File

@@ -0,0 +1,118 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/display/panel/panel-dsi.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Generic MIPI DSI Panel
maintainers:
- Timon Skerutsch <kernel@diodes-delight.com>
allOf:
- $ref: panel-common.yaml#
properties:
compatible:
description:
Shall contain a panel specific compatible and "panel-dsi"
in that order.
items:
- {}
- const: panel-dsi
dsi-color-format:
description: |
The color format used by the panel. Only DSI supported formats are allowed.
enum:
- RGB888
- RGB666
- RGB666_PACKED
- RGB565
port:
$ref: /schemas/graph.yaml#/$defs/port-base
unevaluatedProperties: false
description:
Panel MIPI DSI input
properties:
endpoint:
$ref: /schemas/media/video-interfaces.yaml#
unevaluatedProperties: false
properties:
data-lanes: true
required:
- data-lanes
mode:
description: |
DSI mode flags. See DSI Specs for details.
These are driver independent features of the DSI bus.
items:
- const: MODE_VIDEO
- const: MODE_VIDEO_BURST
- const: MODE_VIDEO_SYNC_PULSE
- const: MODE_VIDEO_AUTO_VERT
- const: MODE_VIDEO_HSE
- const: MODE_VIDEO_NO_HFP
- const: MODE_VIDEO_NO_HBP
- const: MODE_VIDEO_NO_HSA
- const: MODE_VSYNC_FLUSH
- const: MODE_NO_EOT_PACKET
- const: CLOCK_NON_CONTINUOUS
- const: MODE_LPM
- const: HS_PKT_END_ALIGNED
reg: true
backlight: true
enable-gpios: true
width-mm: true
height-mm: true
panel-timing: true
power-supply: true
reset-gpios: true
ddc-i2c-bus: true
required:
- panel-timing
- reg
- power-supply
- dsi-color-format
- port
additionalProperties: false
examples:
- |
panel {
compatible = "panel-mfgr,generic-dsi-panel","panel-dsi";
power-supply = <&vcc_supply>;
backlight = <&backlight>;
dsi-color-format = "RGB888";
reg = <0>;
mode = "MODE_VIDEO", "MODE_VIDEO_BURST", "MODE_NO_EOT_PACKET";
port {
panel_dsi_port: endpoint {
data-lanes = <1 2>;
remote-endpoint = <&dsi_out>;
};
};
panel-timing {
clock-frequency = <9200000>;
hactive = <800>;
vactive = <480>;
hfront-porch = <8>;
hback-porch = <4>;
hsync-len = <41>;
vback-porch = <2>;
vfront-porch = <4>;
vsync-len = <10>;
};
};
...

View File

@@ -142,6 +142,8 @@ properties:
- frida,frd350h54004
# FriendlyELEC HD702E 800x1280 LCD panel
- friendlyarm,hd702e
# Geekworm MZP280 2.8" 480x640 LCD panel with capacitive touch
- geekworm,mzp280
# GiantPlus GPG48273QS5 4.3" (480x272) WQVGA TFT LCD panel
- giantplus,gpg48273qs5
# GiantPlus GPM940B0 3.0" QVGA TFT LCD panel
@@ -154,6 +156,8 @@ properties:
- hit,tx23d38vm0caa
# Innolux AT043TN24 4.3" WQVGA TFT LCD panel
- innolux,at043tn24
# Innolux AT056tN53V1 5.6" VGA (640x480) TFT LCD panel
- innolux,at056tn53v1
# Innolux AT070TN92 7.0" WQVGA TFT LCD panel
- innolux,at070tn92
# Innolux G070ACE-L01 7" WVGA (800x480) TFT LCD panel

View File

@@ -16,6 +16,7 @@ properties:
compatible:
enum:
- brcm,2712-v3d
- brcm,2711-v3d
- brcm,2712-v3d
- brcm,7268-v3d

View File

@@ -0,0 +1,54 @@
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/hwmon/emc2305.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Microchip EMC230[1|2|3|5] RPM-based PWM Fan Speed Controller
properties:
compatible:
enum:
- microchip,emc2305
- microchip,emc2301
emc2305,pwm-min:
description:
Min pwm of emc2305
maxItems: 1
emc2305,pwm-max:
description:
Max pwm of emc2305
maxItems: 1
emc2305,pwm-channel:
description:
Max number of pwm channels
maxItems: 1
emcs205,max-state:
description:
maxItems: 1
emc2305,cooling-levels:
description:
Quantity of cooling level state.
maxItems: 1
required:
- compatible
optional:
- emc2305,min-pwm
- emc2305,max-pwm
- emc2305,pwm-channels
- emc2305,cooling-levels
additionalProperties: false
examples:
- |
fan {
compatible = "microchip,emc2305";
emc2305,pwm-min = <0>;
emc2305,pwm-max = <255>;
emc2305,pwm-channel = <5>
emc2305,cooling-levels = <10>;
};

View File

@@ -0,0 +1,85 @@
Broadcom BCM283x Camera Interface (Unicam)
------------------------------------------
The Unicam block on BCM283x SoCs is the receiver for either
CSI-2 or CCP2 data from image sensors or similar devices.
The main platform using this SoC is the Raspberry Pi family of boards.
On the Pi the VideoCore firmware can also control this hardware block,
and driving it from two different processors will cause issues.
To avoid this, the firmware checks the device tree configuration
during boot. If it finds device tree nodes called csi0 or csi1 then
it will stop the firmware accessing the block, and it can then
safely be used via the device tree binding.
Required properties:
===================
- compatible : must be "brcm,bcm2835-unicam".
- reg : physical base address and length of the register sets for the
device.
- interrupts : should contain the IRQ line for this Unicam instance.
- clocks : list of clock specifiers, corresponding to entries in
clock-names property.
- clock-names : must contain "lp" and "vpu" entries, matching entries in the
clocks property.
Unicam supports a single port node. It should contain one 'port' child node
with child 'endpoint' node. Please refer to the bindings defined in
Documentation/devicetree/bindings/media/video-interfaces.txt.
Within the endpoint node the "remote-endpoint" and "data-lanes" properties
are mandatory.
Data lane reordering is not supported so the data lanes must be in order,
starting at 1. The number of data lanes should represent the number of
usable lanes for the hardware block. That may be limited by either the SoC or
how the platform presents the interface, and the lower value must be used.
Lane reordering is not supported on the clock lane either, so the optional
property "clock-lane" will implicitly be <0>.
Similarly lane inversion is not supported, therefore "lane-polarities" will
implicitly be <0 0 0 0 0>.
Neither of these values will be checked.
Example:
csi1: csi1@7e801000 {
compatible = "brcm,bcm2835-unicam";
reg = <0x7e801000 0x800>,
<0x7e802004 0x4>;
interrupts = <2 7>;
clocks = <&clocks BCM2835_CLOCK_CAM1>,
<&firmware_clocks 4>;
clock-names = "lp", "vpu";
port {
csi1_ep: endpoint {
remote-endpoint = <&tc358743_0>;
data-lanes = <1 2>;
};
};
};
i2c0: i2c@7e205000 {
tc358743: csi-hdmi-bridge@0f {
compatible = "toshiba,tc358743";
reg = <0x0f>;
clocks = <&tc358743_clk>;
clock-names = "refclk";
tc358743_clk: bridge-clk {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <27000000>;
};
port {
tc358743_0: endpoint {
remote-endpoint = <&csi1_ep>;
clock-lanes = <0>;
data-lanes = <1 2>;
clock-noncontinuous;
link-frequencies =
/bits/ 64 <297000000>;
};
};
};
};

View File

@@ -0,0 +1,20 @@
* Analog Devices AD5398 autofocus coil
Required Properties:
- compatible: Must contain one of:
- "adi,ad5398"
- reg: I2C slave address
- VANA-supply: supply of voltage for VANA pin
Example:
ad5398: coil@c {
compatible = "adi,ad5398";
reg = <0x0c>;
VANA-supply = <&vaux4>;
};

View File

@@ -0,0 +1,115 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/media/i2c/arducam,64mp.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Arducam 1/1.7-Inch 64Mpixel CMOS Digital Image Sensor
maintainers:
- Lee Jackson <info@arducam.com>
description: |-
The Arducam 1/1.7-Inch 64Mpixel CMOS active pixel digital image sensor
with an active array size of 9248 x 6944. It is programmable through
I2C interface. The I2C address is fixed to 0x1A as per sensor data sheet.
Image data is sent through MIPI CSI-2, which can be configured for operation
with either 2 or 4 data lanes.
properties:
compatible:
const: arducam,64mp
reg:
description: I2C device address
maxItems: 1
clocks:
maxItems: 1
VDIG-supply:
description:
Digital I/O voltage supply, 1.05 volts
VANA-supply:
description:
Analog voltage supply, 2.8 volts
VDDL-supply:
description:
Digital core voltage supply, 1.8 volts
reset-gpios:
description: |-
Reference to the GPIO connected to the xclr pin, if any.
Must be released (set high) after all supplies and INCK are applied.
# See ../video-interfaces.txt for more details
port:
type: object
properties:
endpoint:
type: object
properties:
data-lanes:
description: |-
The sensor supports either two-lane, or four-lane operation.
For two-lane operation the property must be set to <1 2>.
anyOf:
- items:
- const: 1
- const: 2
- items:
- const: 1
- const: 2
- const: 3
- const: 4
clock-noncontinuous: true
link-frequencies:
allOf:
- $ref: /schemas/types.yaml#/definitions/uint64-array
description:
Allowed data bus frequencies.
required:
- link-frequencies
required:
- compatible
- reg
- clocks
- VANA-supply
- VDIG-supply
- VDDL-supply
- port
additionalProperties: false
examples:
- |
i2c0 {
#address-cells = <1>;
#size-cells = <0>;
arducam_64mp: sensor@1a {
compatible = "arducam,64mp";
reg = <0x1a>;
clocks = <&arducam_64mp_clk>;
VANA-supply = <&arducam_64mp_vana>; /* 2.8v */
VDIG-supply = <&arducam_64mp_vdig>; /* 1.05v */
VDDL-supply = <&arducam_64mp_vddl>; /* 1.8v */
port {
arducam_64mp_0: endpoint {
remote-endpoint = <&csi1_ep>;
data-lanes = <1 2>;
clock-noncontinuous;
link-frequencies = /bits/ 64 <456000000>;
};
};
};
};
...

View File

@@ -0,0 +1,112 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/media/i2c/arducam-pivariety.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Arducam Pivariety Series CMOS Digital Image Sensor
maintainers:
- Lee Jackson <info@arducam.com>
description: |-
Arducam Pivariety series cameras make compatibility layers for various CMOS
sensors and provide a unified command interface. It is programmable through
I2C interface. The I2C address is fixed to 0x0C. Image data is sent through
MIPI CSI-2, which is configured as either 1, 2 or 4 data lanes.
properties:
compatible:
const: arducam,arducam-pivariety
reg:
description: I2C device address
maxItems: 1
clocks:
maxItems: 1
VDIG-supply:
description:
Digital I/O voltage supply, 1.05 volts
VANA-supply:
description:
Analog voltage supply, 2.8 volts
VDDL-supply:
description:
Digital core voltage supply, 1.8 volts
reset-gpios:
description: |-
Reference to the GPIO connected to the xclr pin, if any.
Must be released (set high) after all supplies and INCK are applied.
# See ../video-interfaces.txt for more details
port:
type: object
properties:
endpoint:
type: object
properties:
data-lanes:
description: |-
The sensor supports either two-lane, or four-lane operation.
For two-lane operation the property must be set to <1 2>.
items:
- const: 1
- const: 2
clock-noncontinuous:
type: boolean
description: |-
MIPI CSI-2 clock is non-continuous if this property is present,
otherwise it's continuous.
link-frequencies:
allOf:
- $ref: /schemas/types.yaml#/definitions/uint64-array
description:
Allowed data bus frequencies.
required:
- link-frequencies
required:
- compatible
- reg
- clocks
- VANA-supply
- VDIG-supply
- VDDL-supply
- port
additionalProperties: false
examples:
- |
i2c0 {
#address-cells = <1>;
#size-cells = <0>;
arducam_pivariety: sensor@0c {
compatible = "arducam,arducam-pivariety";
reg = <0x0c>;
clocks = <&arducam_pivariety_clk>;
VANA-supply = <&arducam_pivariety_vana>; /* 2.8v */
VDIG-supply = <&arducam_pivariety_vdig>; /* 1.05v */
VDDL-supply = <&arducam_pivariety_vddl>; /* 1.8v */
port {
arducam_pivariety_0: endpoint {
remote-endpoint = <&csi1_ep>;
data-lanes = <1 2>;
clock-noncontinuous;
link-frequencies = /bits/ 64 <493500000>;
};
};
};
};
...

View File

@@ -5,22 +5,32 @@
$id: http://devicetree.org/schemas/media/i2c/dongwoon,dw9807-vcm.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Dongwoon Anatech DW9807 voice coil lens driver
title: Dongwoon Anatech DW9807 and DW9817 voice coil lens driver
maintainers:
- Sakari Ailus <sakari.ailus@linux.intel.com>
description: |
DW9807 is a 10-bit DAC with current sink capability. It is intended for
controlling voice coil lenses.
controlling voice coil lenses. The output drive is 0-100mA.
DW9817 is very similar as a 10-bit DAC with current sink capability,
however the output drive is a bidirection -100 to +100mA.
properties:
compatible:
const: dongwoon,dw9807-vcm
items:
- enum:
- dongwoon,dw9807-vcm
- dongwoon,dw9817-vcm
reg:
maxItems: 1
VDD-supply:
description:
Definition of the regulator used as VDD power supply to the driver.
required:
- compatible
- reg

View File

@@ -0,0 +1,113 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/media/i2c/imx378.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Sony 1/2.3-Inch 12Mpixel CMOS Digital Image Sensor
maintainers:
- Naushir Patuck <naush@raspberypi.com>
description: |-
The Sony IMX378 is a 1/2.3-inch CMOS active pixel digital image sensor
with an active array size of 4056H x 3040V. It is programmable through
I2C interface. The I2C address is fixed to 0x1A as per sensor data sheet.
Image data is sent through MIPI CSI-2, which is configured as either 2 or
4 data lanes.
properties:
compatible:
const: sony,imx378
reg:
description: I2C device address
maxItems: 1
clocks:
maxItems: 1
VDIG-supply:
description:
Digital I/O voltage supply, 1.05 volts
VANA-supply:
description:
Analog voltage supply, 2.8 volts
VDDL-supply:
description:
Digital core voltage supply, 1.8 volts
reset-gpios:
description: |-
Reference to the GPIO connected to the xclr pin, if any.
Must be released (set high) after all supplies and INCK are applied.
# See ../video-interfaces.txt for more details
port:
type: object
properties:
endpoint:
type: object
properties:
data-lanes:
description: |-
The sensor supports either two-lane, or four-lane operation.
For two-lane operation the property must be set to <1 2>.
items:
- const: 1
- const: 2
clock-noncontinuous:
type: boolean
description: |-
MIPI CSI-2 clock is non-continuous if this property is present,
otherwise it's continuous.
link-frequencies:
allOf:
- $ref: /schemas/types.yaml#/definitions/uint64-array
description:
Allowed data bus frequencies.
required:
- link-frequencies
required:
- compatible
- reg
- clocks
- VANA-supply
- VDIG-supply
- VDDL-supply
- port
additionalProperties: false
examples:
- |
i2c0 {
#address-cells = <1>;
#size-cells = <0>;
imx378: sensor@10 {
compatible = "sony,imx378";
reg = <0x1a>;
clocks = <&imx378_clk>;
VANA-supply = <&imx378_vana>; /* 2.8v */
VDIG-supply = <&imx378_vdig>; /* 1.05v */
VDDL-supply = <&imx378_vddl>; /* 1.8v */
port {
imx378_0: endpoint {
remote-endpoint = <&csi1_ep>;
data-lanes = <1 2>;
clock-noncontinuous;
link-frequencies = /bits/ 64 <450000000>;
};
};
};
};
...

View File

@@ -0,0 +1,113 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/media/i2c/imx477.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Sony 1/2.3-Inch 12Mpixel CMOS Digital Image Sensor
maintainers:
- Naushir Patuck <naush@raspberypi.com>
description: |-
The Sony IMX477 is a 1/2.3-inch CMOS active pixel digital image sensor
with an active array size of 4056H x 3040V. It is programmable through
I2C interface. The I2C address is fixed to 0x1A as per sensor data sheet.
Image data is sent through MIPI CSI-2, which is configured as either 2 or
4 data lanes.
properties:
compatible:
const: sony,imx477
reg:
description: I2C device address
maxItems: 1
clocks:
maxItems: 1
VDIG-supply:
description:
Digital I/O voltage supply, 1.05 volts
VANA-supply:
description:
Analog voltage supply, 2.8 volts
VDDL-supply:
description:
Digital core voltage supply, 1.8 volts
reset-gpios:
description: |-
Reference to the GPIO connected to the xclr pin, if any.
Must be released (set high) after all all supplies and INCK are applied.
# See ../video-interfaces.txt for more details
port:
type: object
properties:
endpoint:
type: object
properties:
data-lanes:
description: |-
The sensor supports either two-lane, or four-lane operation.
For two-lane operation the property must be set to <1 2>.
items:
- const: 1
- const: 2
clock-noncontinuous:
type: boolean
description: |-
MIPI CSI-2 clock is non-continuous if this property is present,
otherwise it's continuous.
link-frequencies:
allOf:
- $ref: /schemas/types.yaml#/definitions/uint64-array
description:
Allowed data bus frequencies.
required:
- link-frequencies
required:
- compatible
- reg
- clocks
- VANA-supply
- VDIG-supply
- VDDL-supply
- port
additionalProperties: false
examples:
- |
i2c0 {
#address-cells = <1>;
#size-cells = <0>;
imx477: sensor@10 {
compatible = "sony,imx477";
reg = <0x1a>;
clocks = <&imx477_clk>;
VANA-supply = <&imx477_vana>; /* 2.8v */
VDIG-supply = <&imx477_vdig>; /* 1.05v */
VDDL-supply = <&imx477_vddl>; /* 1.8v */
port {
imx477_0: endpoint {
remote-endpoint = <&csi1_ep>;
data-lanes = <1 2>;
clock-noncontinuous;
link-frequencies = /bits/ 64 <450000000>;
};
};
};
};
...

View File

@@ -0,0 +1,113 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/media/i2c/imx519.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Sony 1/2.5-Inch 16Mpixel CMOS Digital Image Sensor
maintainers:
- Lee Jackson <info@arducam.com>
description: |-
The Sony IMX519 is a 1/2.5-inch CMOS active pixel digital image sensor
with an active array size of 4656H x 3496V. It is programmable through
I2C interface. The I2C address is fixed to 0x1A as per sensor data sheet.
Image data is sent through MIPI CSI-2, which is configured as either 2 or
4 data lanes.
properties:
compatible:
const: sony,imx519
reg:
description: I2C device address
maxItems: 1
clocks:
maxItems: 1
VDIG-supply:
description:
Digital I/O voltage supply, 1.05 volts
VANA-supply:
description:
Analog voltage supply, 2.8 volts
VDDL-supply:
description:
Digital core voltage supply, 1.8 volts
reset-gpios:
description: |-
Reference to the GPIO connected to the xclr pin, if any.
Must be released (set high) after all supplies and INCK are applied.
# See ../video-interfaces.txt for more details
port:
type: object
properties:
endpoint:
type: object
properties:
data-lanes:
description: |-
The sensor supports either two-lane, or four-lane operation.
For two-lane operation the property must be set to <1 2>.
items:
- const: 1
- const: 2
clock-noncontinuous:
type: boolean
description: |-
MIPI CSI-2 clock is non-continuous if this property is present,
otherwise it's continuous.
link-frequencies:
allOf:
- $ref: /schemas/types.yaml#/definitions/uint64-array
description:
Allowed data bus frequencies.
required:
- link-frequencies
required:
- compatible
- reg
- clocks
- VANA-supply
- VDIG-supply
- VDDL-supply
- port
additionalProperties: false
examples:
- |
i2c0 {
#address-cells = <1>;
#size-cells = <0>;
imx519: sensor@1a {
compatible = "sony,imx519";
reg = <0x1a>;
clocks = <&imx519_clk>;
VANA-supply = <&imx519_vana>; /* 2.8v */
VDIG-supply = <&imx519_vdig>; /* 1.05v */
VDDL-supply = <&imx519_vddl>; /* 1.8v */
port {
imx519_0: endpoint {
remote-endpoint = <&csi1_ep>;
data-lanes = <1 2>;
clock-noncontinuous;
link-frequencies = /bits/ 64 <493500000>;
};
};
};
};
...

View File

@@ -0,0 +1,48 @@
* Infineon irs1125 time of flight sensor
The Infineon irs1125 is a time of flight digital image sensor with
an active array size of 352H x 286V. It is programmable through I2C
interface. The I2C address defaults to 0x3D, but can be reconfigured
to address 0x3C or 0x41 via I2C commands. Image data is sent through
MIPI CSI-2, which is configured as either 1 or 2 data lanes.
Required Properties:
- compatible: value should be "infineon,irs1125" for irs1125 sensor
- reg: I2C bus address of the device
- clocks: reference to the xclk input clock.
- pwdn-gpios: reference to the GPIO connected to the reset pin.
This is an active low signal to the iirs1125.
The irs1125 device node should contain one 'port' child node with
an 'endpoint' subnode. For further reading on port node refer to
Documentation/devicetree/bindings/media/video-interfaces.txt.
Endpoint node required properties for CSI-2 connection are:
- remote-endpoint: a phandle to the bus receiver's endpoint node.
- clock-lanes: should be set to <0> (clock lane on hardware lane 0)
- data-lanes: should be set to <1> or <1 2> (one or two lane CSI-2
supported)
Example:
sensor@10 {
compatible = "infineon,irs1125";
reg = <0x3D>;
#address-cells = <1>;
#size-cells = <0>;
clocks = <&irs1125_clk>;
pwdn-gpios = <&gpio 5 0>;
irs1125_clk: camera-clk {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <26000000>;
};
port {
sensor_out: endpoint {
remote-endpoint = <&csiss_in>;
clock-lanes = <0>;
data-lanes = <1 2>;
};
};
};

View File

@@ -0,0 +1,48 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
# Copyright (C) 2023 Ideas on Board Oy.
%YAML 1.2
---
$id: http://devicetree.org/schemas/media/i2c/rohm,bu64754.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: ROHM BU64754 Actuator Driver for Camera Autofocus
maintainers:
- Kieran Bingham <kieran.bingham@ideasonboard.com>
description: |
The BU64754GWZ is an actuator driver IC which can control the actuator
position precisely using an internal Hall Sensor.
properties:
compatible:
items:
- enum:
- rohm,bu64754
reg:
maxItems: 1
vdd-supply:
description:
Definition of the regulator used as VDD power supply to the driver.
required:
- compatible
- reg
additionalProperties: false
examples:
- |
i2c {
#address-cells = <1>;
#size-cells = <0>;
lens@76 {
compatible = "rohm,bu64754";
reg = <0x76>;
vdd-supply = <&cam1_reg>;
};
};
...

View File

@@ -0,0 +1,128 @@
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/media/i2c/sony,imx708.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Sony 1/2.3-Inch 12Mpixel CMOS Digital Image Sensor
maintainers:
- Raspberry Pi Kernel Maintenance <kernel-list@raspberrypi.com>
description: |-
The Sony IMX708 is a 1/2.3-inch CMOS active pixel digital image sensor
with an active array size of 4608H x 2592V. It is programmable through
I2C interface. The I2C address is fixed to 0x1A as per sensor data sheet.
Image data is sent through MIPI CSI-2, which is configured as either 2 or
4 data lanes.
properties:
compatible:
const: sony,imx708
reg:
maxItems: 1
clocks:
maxItems: 1
clock-names:
description: Input clock (6 to 27 MHz)
items:
- const: inck
vdig-supply:
description:
Digital I/O voltage supply, 1.1 volts
vana1-supply:
description:
Analog1 voltage supply, 2.8 volts
vana2-supply:
description:
Analog2 voltage supply, 1.8 volts
vddl-supply:
description:
Digital core voltage supply, 1.8 volts
reset-gpios:
description: Sensor reset (XCLR) GPIO
maxItems: 1
port:
$ref: /schemas/graph.yaml#/$defs/port-base
description: |
Video output port
properties:
endpoint:
$ref: /schemas/media/video-interfaces.yaml#
unevaluatedProperties: false
properties:
data-lanes:
anyOf:
- items:
- const: 1
- const: 2
- items:
- const: 1
- const: 2
- const: 3
- const: 4
link-frequencies: true
required:
- data-lanes
- link-frequencies
additionalProperties: false
required:
- compatible
- reg
- clocks
- clock-names
- vdig-supply
- vana1-supply
- vana2-supply
- vddl-supply
- port
additionalProperties: false
examples:
- |
#include <dt-bindings/gpio/gpio.h>
i2c {
#address-cells = <1>;
#size-cells = <0>;
imx708: camera-sensor@1a {
compatible = "sony,imx708";
reg = <0x1a>;
clocks = <&clk 90>;
clock-names = "inck";
vdig-supply = <&camera_vdig>;
vana1-supply = <&camera_vana1>;
vana2-supply = <&camera_vana2>;
vddl-supply = <&camera_vddl>;
reset-gpios = <&gpio 35 GPIO_ACTIVE_LOW>;
port {
imx708_ep: endpoint {
data-lanes = <1 2>;
link-frequencies = /bits/ 64 <450000000>;
remote-endpoint = <&csi_ep>;
};
};
};
};
...

View File

@@ -0,0 +1,72 @@
# SPDX-License-Identifier: GPL-2.0-only
%YAML 1.2
---
$id: http://devicetree.org/schemas/media/rpivid_hevc.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Raspberry Pi HEVC Decoder
maintainers:
- Raspberry Pi <kernel-list@raspberrypi.com>
description: |-
The Camera Adaptation Layer (CAL) is a key component for image capture
applications. The capture module provides the system interface and the
processing capability to connect CSI2 image-sensor modules to the
DRA72x device.
properties:
compatible:
enum:
- raspberrypi,rpivid-vid-decoder
reg:
minItems: 2
items:
- description: The HEVC main register region
- description: The Interrupt controller register region
reg-names:
minItems: 2
items:
- const: hevc
- const: intc
interrupts:
maxItems: 1
clocks:
items:
- description: The HEVC block clock
clock-names:
items:
- const: hevc
required:
- compatible
- reg
- reg-names
- interrupts
- clocks
additionalProperties: false
examples:
- |
#include <dt-bindings/interrupt-controller/arm-gic.h>
video-codec@7eb10000 {
compatible = "raspberrypi,rpivid-vid-decoder";
reg = <0x0 0x7eb10000 0x1000>, /* INTC */
<0x0 0x7eb00000 0x10000>; /* HEVC */
reg-names = "intc",
"hevc";
interrupts = <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clk 0>;
clock-names = "hevc";
};
...

View File

@@ -0,0 +1,17 @@
* Broadcom BCM2835 SMI character device driver.
SMI or secondary memory interface is a peripheral specific to certain Broadcom
SOCs, and is helpful for talking to things like parallel-interface displays
and NAND flashes (in fact, most things with a parallel register interface).
This driver adds a character device which provides a user-space interface to
an instance of the SMI driver.
Required properties:
- compatible: "brcm,bcm2835-smi-dev"
- smi_handle: a phandle to the smi node.
Optional properties:
- None.

View File

@@ -0,0 +1,48 @@
* Broadcom BCM2835 SMI driver.
SMI or secondary memory interface is a peripheral specific to certain Broadcom
SOCs, and is helpful for talking to things like parallel-interface displays
and NAND flashes (in fact, most things with a parallel register interface).
Required properties:
- compatible: "brcm,bcm2835-smi"
- reg: Should contain location and length of SMI registers and SMI clkman regs
- interrupts: *the* SMI interrupt.
- pinctrl-names: should be "default".
- pinctrl-0: the phandle of the gpio pin node.
- brcm,smi-clock-source: the clock source for clkman
- brcm,smi-clock-divisor: the integer clock divisor for clkman
- dmas: the dma controller phandle and the DREQ number (4 on a 2835)
- dma-names: the name used by the driver to request its channel.
Should be "rx-tx".
Optional properties:
- None.
Examples:
8 data pin configuration:
smi: smi@7e600000 {
compatible = "brcm,bcm2835-smi";
reg = <0x7e600000 0x44>, <0x7e1010b0 0x8>;
interrupts = <2 16>;
pinctrl-names = "default";
pinctrl-0 = <&smi_pins>;
brcm,smi-clock-source = <6>;
brcm,smi-clock-divisor = <4>;
dmas = <&dma 4>;
dma-names = "rx-tx";
status = "okay";
};
smi_pins: smi_pins {
brcm,pins = <2 3 4 5 6 7 8 9 10 11 12 13 14 15>;
/* Alt 1: SMI */
brcm,function = <5 5 5 5 5 5 5 5 5 5 5 5 5 5>;
/* /CS, /WE and /OE are pulled high, as they are
generally active low signals */
brcm,pull = <2 2 2 2 2 2 0 0 0 0 0 0 0 0>;
};

View File

@@ -16,6 +16,7 @@ allOf:
properties:
compatible:
enum:
- raspberrypi,rp1-dwcmshc
- rockchip,rk3568-dwcmshc
- rockchip,rk3588-dwcmshc
- snps,dwcmshc-sdhci
@@ -37,6 +38,8 @@ properties:
- description: axi clock for rockchip specified
- description: block clock for rockchip specified
- description: timer clock for rockchip specified
- description: timeout clock for rp1 specified
- description: sdio clock generator for rp1 specified
clock-names:
@@ -47,6 +50,8 @@ properties:
- const: axi
- const: block
- const: timer
- const: timeout
- const: sdio
resets:
maxItems: 5

View File

@@ -136,6 +136,22 @@ properties:
Node containing PHY children. If this node is not present, then PHYs will
be direct children.
cdns,aw2w-max-pipe:
$ref: /schemas/types.yaml#/definitions/uint32
description:
Maximum number of outstanding AXI write requests
cdns,ar2r-max-pipe:
$ref: /schemas/types.yaml#/definitions/uint32
description:
Maximum number of outstanding AXI read requests
cdns,use-aw2b-fill:
type: boolean
description:
If set, the maximum number of outstanding write transactions operates
between the AW to B AXI channel, instead of the AW to W AXI channel.
patternProperties:
"^ethernet-phy@[0-9a-f]$":
type: object

View File

@@ -14,6 +14,9 @@ Optional properties of the embedded PHY:
- microchip,led-modes: a 0..4 element vector, with each element configuring
the operating mode of an LED. Omitted LEDs are turned off. Allowed values
are defined in "include/dt-bindings/net/microchip-lan78xx.h".
- microchip,downshift-after: sets the number of failed auto-negotiation
attempts after which the link is downgraded from 1000BASE-T. Should be one of
2, 3, 4, 5 or 0, where 0 means never downshift.
Example:

View File

@@ -95,6 +95,14 @@ properties:
minItems: 1
maxItems: 3
brcm,tperst-clk-ms:
category: optional
type: int
description: u32 giving the number of milliseconds to extend
the time between internal release of fundamental reset and
the deassertion of the external PERST# pin. This has the
effect of increasing the Tperst_clk phase of link init.
required:
- compatible
- reg

View File

@@ -0,0 +1,59 @@
Brcmstb PCIe Host Controller Device Tree Bindings
Required Properties:
- compatible
"brcm,bcm7425-pcie" -- for 7425 family MIPS-based SOCs.
"brcm,bcm7435-pcie" -- for 7435 family MIPS-based SOCs.
"brcm,bcm7445-pcie" -- for 7445 and later ARM based SOCs (not including
the 7278).
"brcm,bcm7278-pcie" -- for 7278 family ARM-based SOCs.
- reg -- the register start address and length for the PCIe reg block.
- interrupts -- two interrupts are specified; the first interrupt is for
the PCI host controller and the second is for MSI if the built-in
MSI controller is to be used.
- interrupt-names -- names of the interrupts (above): "pcie" and "msi".
- #address-cells -- set to <3>.
- #size-cells -- set to <2>.
- #interrupt-cells: set to <1>.
- interrupt-map-mask and interrupt-map, standard PCI properties to define the
mapping of the PCIe interface to interrupt numbers.
- ranges: ranges for the PCI memory and I/O regions.
- linux,pci-domain -- should be unique per host controller.
Optional Properties:
- clocks -- phandle of pcie clock.
- clock-names -- set to "sw_pcie" if clocks is used.
- dma-ranges -- Specifies the inbound memory mapping regions when
an "identity map" is not possible.
- msi-controller -- this property is typically specified to have the
PCIe controller use its internal MSI controller.
- msi-parent -- set to use an external MSI interrupt controller.
- brcm,enable-ssc -- (boolean) indicates usage of spread-spectrum clocking.
- max-link-speed -- (integer) indicates desired generation of link:
1 => 2.5 Gbps (gen1), 2 => 5.0 Gbps (gen2), 3 => 8.0 Gbps (gen3).
Example Node:
pcie0: pcie@f0460000 {
reg = <0x0 0xf0460000 0x0 0x9310>;
interrupts = <0x0 0x0 0x4>;
compatible = "brcm,bcm7445-pcie";
#address-cells = <3>;
#size-cells = <2>;
ranges = <0x02000000 0x00000000 0x00000000 0x00000000 0xc0000000 0x00000000 0x08000000
0x02000000 0x00000000 0x08000000 0x00000000 0xc8000000 0x00000000 0x08000000>;
#interrupt-cells = <1>;
interrupt-map-mask = <0 0 0 7>;
interrupt-map = <0 0 0 1 &intc 0 47 3
0 0 0 2 &intc 0 48 3
0 0 0 3 &intc 0 49 3
0 0 0 4 &intc 0 50 3>;
clocks = <&sw_pcie0>;
clock-names = "sw_pcie";
msi-parent = <&pcie0>; /* use PCIe's internal MSI controller */
msi-controller; /* use PCIe's internal MSI controller */
brcm,ssc;
max-link-speed = <1>;
linux,pci-domain = <0>;
};

View File

@@ -50,6 +50,10 @@ properties:
default: 3000
description: Time to wait before assuming the power off sequence failed.
export:
type: boolean
description: Export the GPIO line to the sysfs system
required:
- compatible
- gpios

View File

@@ -0,0 +1,38 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/pwm/pwm-rp1.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Raspberry Pi RP1 PWM controller
maintainers:
- Naushir Patuck <naush@raspberrypi.com>
properties:
compatible:
enum:
- raspberrypi,rp1-pwm
reg:
maxItems: 1
"#pwm-cells":
const: 3
required:
- compatible
- reg
- clocks
- "#pwm-cells"
additionalProperties: false
examples:
- |
pwm0: pwm@98000 {
compatible = "raspberrypi,rp1-pwm";
reg = <0x0 0x98000 0x0 0x100>;
clocks = <&rp1_sys>;
#pwm-cells = <3>;
};

View File

@@ -0,0 +1,22 @@
* Raspberry Pi RTC
This is a Linux interface to an RTC managed by firmware, hence it's
virtual from a Linux perspective.
The interface uses the firmware mailbox api to access the RTC registers.
Required properties:
compatible: should be "raspberrypi,rpi-rtc"
firmware: Reference to the RPi firmware device node.
Optional property:
trickle-charge-microvolt: specify a trickle charge voltage for the backup
battery in microvolts.
Example:
rpi_rtc: rpi_rtc {
compatible = "raspberrypi,rpi-rtc";
firmware = <&firmware>;
trickle-charge-microvolt = <3000000>;
};

View File

@@ -101,6 +101,12 @@ properties:
on the device.
enum: [1, 4]
cts-event-workaround:
description:
Enables the (otherwise vendor-specific) workaround for the
CTS-induced TX lockup.
type: boolean
required:
- compatible
- reg

View File

@@ -69,6 +69,10 @@ properties:
- description: RX DMA Channel
minItems: 1
dma-maxburst:
description: FIFO DMA burst threshold limit
maxItems: 1
dma-names:
items:
- const: tx

View File

@@ -0,0 +1,77 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/spi/raspberrypi,rp2040-gpio-bridge.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Raspberry Pi RP2040 GPIO Bridge
maintainers:
- Raspberry Pi <kernel-list@raspberrypi.com>
description: |-
The Raspberry Pi PR2040 GPIO bridge can be used as a GPIO expander and
Tx-only SPI master.
properties:
reg:
description: I2C slave address
const: 0x40
compatible:
const: raspberrypi,rp2040-gpio-bridge
power-supply:
description: Phandle to the regulator that powers the RP2040.
'#address-cells':
const: 1
'#size-cells':
const: 0
'#gpio-cells':
const: 2
gpio-controller: true
fast_xfer_requires_i2c_lock:
description: Set if I2C bus should be locked during fast transfer.
fast_xfer_recv_gpio_base:
description: RP2040 GPIO base for fast transfer pair.
fast_xfer-gpios:
description: RP1 GPIOs to use for fast transfer clock and data.
required:
- reg
- compatible
- power-supply
- '#gpio-cells'
- gpio-controller
additionalProperties: false
examples:
- |
i2c {
#address-cells = <1>;
#size-cells = <0>;
spi@40 {
reg = <0x40>;
compatible = "raspberrypi,rp2040-gpio-bridge";
status = "disabled";
#address-cells = <1>;
#size-cells = <0>;
power-supply = <&cam_dummy_reg>;
#gpio-cells = <2>;
gpio-controller;
};
};
...

View File

@@ -43,6 +43,10 @@ properties:
with no chip select is connected.
$ref: /schemas/types.yaml#/definitions/uint32
sck-idle-input:
description: Make SCK an input when inactive.
type: boolean
# Deprecated properties
gpio-sck: false
gpio-miso: false

View File

@@ -234,12 +234,17 @@ properties:
snps,parkmode-disable-ss-quirk:
description:
When set, all SuperSpeed bus instances in park mode are disabled.
When set, disable park mode for all Superspeed bus instances.
type: boolean
snps,parkmode-disable-hs-quirk:
description:
When set, all HighSpeed bus instances in park mode are disabled.
When set, disable park mode for all Highspeed bus instances.
type: boolean
snps,parkmode-disable-fsls-quirk:
description:
When set, disable park mode for all Full/Lowspeed bus instances.
type: boolean
snps,dis_metastability_quirk:

View File

@@ -0,0 +1,463 @@
Device tree binding vendor prefix registry. Keep list in alphabetical order.
This isn't an exhaustive list, but you should add new prefixes to it before
using them to avoid name-space collisions.
abilis Abilis Systems
abracon Abracon Corporation
actions Actions Semiconductor Co., Ltd.
active-semi Active-Semi International Inc
ad Avionic Design GmbH
adafruit Adafruit Industries, LLC
adapteva Adapteva, Inc.
adaptrum Adaptrum, Inc.
adh AD Holdings Plc.
adi Analog Devices, Inc.
advantech Advantech Corporation
aeroflexgaisler Aeroflex Gaisler AB
al Annapurna Labs
allo Allo.com
allwinner Allwinner Technology Co., Ltd.
alphascale AlphaScale Integrated Circuits Systems, Inc.
altr Altera Corp.
amarula Amarula Solutions
amazon Amazon.com, Inc.
amcc Applied Micro Circuits Corporation (APM, formally AMCC)
amd Advanced Micro Devices (AMD), Inc.
amediatech Shenzhen Amediatech Technology Co., Ltd
amlogic Amlogic, Inc.
ampire Ampire Co., Ltd.
ams AMS AG
amstaos AMS-Taos Inc.
analogix Analogix Semiconductor, Inc.
andestech Andes Technology Corporation
apm Applied Micro Circuits Corporation (APM)
aptina Aptina Imaging
arasan Arasan Chip Systems
archermind ArcherMind Technology (Nanjing) Co., Ltd.
arctic Arctic Sand
aries Aries Embedded GmbH
arm ARM Ltd.
armadeus ARMadeus Systems SARL
arrow Arrow Electronics
artesyn Artesyn Embedded Technologies Inc.
asahi-kasei Asahi Kasei Corp.
aspeed ASPEED Technology Inc.
asus AsusTek Computer Inc.
atlas Atlas Scientific LLC
atmel Atmel Corporation
auo AU Optronics Corporation
auvidea Auvidea GmbH
avago Avago Technologies
avia avia semiconductor
avic Shanghai AVIC Optoelectronics Co., Ltd.
avnet Avnet, Inc.
axentia Axentia Technologies AB
axis Axis Communications AB
bananapi BIPAI KEJI LIMITED
bhf Beckhoff Automation GmbH & Co. KG
bitmain Bitmain Technologies
blokaslabs Vilniaus Blokas UAB
boe BOE Technology Group Co., Ltd.
bosch Bosch Sensortec GmbH
boundary Boundary Devices Inc.
brcm Broadcom Corporation
buffalo Buffalo, Inc.
bticino Bticino International
calxeda Calxeda
capella Capella Microsystems, Inc
cascoda Cascoda, Ltd.
catalyst Catalyst Semiconductor, Inc.
cavium Cavium, Inc.
cdns Cadence Design Systems Inc.
cdtech CDTech(H.K.) Electronics Limited
ceva Ceva, Inc.
chipidea Chipidea, Inc
chipone ChipOne
chipspark ChipSPARK
chrp Common Hardware Reference Platform
chunghwa Chunghwa Picture Tubes Ltd.
ciaa Computadora Industrial Abierta Argentina
cirrus Cirrus Logic, Inc.
cloudengines Cloud Engines, Inc.
cnm Chips&Media, Inc.
cnxt Conexant Systems, Inc.
compulab CompuLab Ltd.
cortina Cortina Systems, Inc.
cosmic Cosmic Circuits
crane Crane Connectivity Solutions
creative Creative Technology Ltd
crystalfontz Crystalfontz America, Inc.
csky Hangzhou C-SKY Microsystems Co., Ltd
cubietech Cubietech, Ltd.
cypress Cypress Semiconductor Corporation
cznic CZ.NIC, z.s.p.o.
dallas Maxim Integrated Products (formerly Dallas Semiconductor)
dataimage DataImage, Inc.
davicom DAVICOM Semiconductor, Inc.
delta Delta Electronics, Inc.
denx Denx Software Engineering
devantech Devantech, Ltd.
dh DH electronics GmbH
digi Digi International Inc.
digilent Diglent, Inc.
dioo Dioo Microcircuit Co., Ltd
dlc DLC Display Co., Ltd.
dlg Dialog Semiconductor
dlink D-Link Corporation
dmo Data Modul AG
domintech Domintech Co., Ltd.
dongwoon Dongwoon Anatech
dptechnics DPTechnics
dragino Dragino Technology Co., Limited
ea Embedded Artists AB
ebs-systart EBS-SYSTART GmbH
ebv EBV Elektronik
eckelmann Eckelmann AG
edt Emerging Display Technologies
eeti eGalax_eMPIA Technology Inc
elan Elan Microelectronic Corp.
elgin Elgin S/A.
embest Shenzhen Embest Technology Co., Ltd.
emlid Emlid, Ltd.
emmicro EM Microelectronic
emtrion emtrion GmbH
endless Endless Mobile, Inc.
energymicro Silicon Laboratories (formerly Energy Micro AS)
engicam Engicam S.r.l.
epcos EPCOS AG
epfl Ecole Polytechnique Fédérale de Lausanne
epson Seiko Epson Corp.
est ESTeem Wireless Modems
ettus NI Ettus Research
eukrea Eukréa Electromatique
everest Everest Semiconductor Co. Ltd.
everspin Everspin Technologies, Inc.
exar Exar Corporation
excito Excito
ezchip EZchip Semiconductor
facebook Facebook
fairphone Fairphone B.V.
faraday Faraday Technology Corporation
fastrax Fastrax Oy
fcs Fairchild Semiconductor
feiyang Shenzhen Fly Young Technology Co.,LTD.
firefly Firefly
focaltech FocalTech Systems Co.,Ltd
friendlyarm Guangzhou FriendlyARM Computer Tech Co., Ltd
fsl Freescale Semiconductor
fujitsu Fujitsu Ltd.
gateworks Gateworks Corporation
gcw Game Consoles Worldwide
ge General Electric Company
geekbuying GeekBuying
gef GE Fanuc Intelligent Platforms Embedded Systems, Inc.
GEFanuc GE Fanuc Intelligent Platforms Embedded Systems, Inc.
geniatech Geniatech, Inc.
giantec Giantec Semiconductor, Inc.
giantplus Giantplus Technology Co., Ltd.
globalscale Globalscale Technologies, Inc.
globaltop GlobalTop Technology, Inc.
gmt Global Mixed-mode Technology, Inc.
goodix Shenzhen Huiding Technology Co., Ltd.
google Google, Inc.
grinn Grinn
grmn Garmin Limited
gumstix Gumstix, Inc.
gw Gateworks Corporation
hannstar HannStar Display Corporation
haoyu Haoyu Microelectronic Co. Ltd.
hardkernel Hardkernel Co., Ltd
hideep HiDeep Inc.
himax Himax Technologies, Inc.
hisilicon Hisilicon Limited.
hit Hitachi Ltd.
hitex Hitex Development Tools
holt Holt Integrated Circuits, Inc.
honeywell Honeywell
hp Hewlett Packard
holtek Holtek Semiconductor, Inc.
hwacom HwaCom Systems Inc.
i2se I2SE GmbH
ibm International Business Machines (IBM)
icplus IC Plus Corp.
idt Integrated Device Technologies, Inc.
ifi Ingenieurburo Fur Ic-Technologie (I/F/I)
ilitek ILI Technology Corporation (ILITEK)
img Imagination Technologies Ltd.
infineon Infineon Technologies
inforce Inforce Computing
ingenic Ingenic Semiconductor
innolux Innolux Corporation
inside-secure INSIDE Secure
intel Intel Corporation
intercontrol Inter Control Group
invensense InvenSense Inc.
inversepath Inverse Path
iom Iomega Corporation
isee ISEE 2007 S.L.
isil Intersil
issi Integrated Silicon Solutions Inc.
itead ITEAD Intelligent Systems Co.Ltd
iwave iWave Systems Technologies Pvt. Ltd.
jdi Japan Display Inc.
jedec JEDEC Solid State Technology Association
jianda Jiandangjing Technology Co., Ltd.
karo Ka-Ro electronics GmbH
keithkoep Keith & Koep GmbH
keymile Keymile GmbH
khadas Khadas
kiebackpeter Kieback & Peter GmbH
kinetic Kinetic Technologies
kingdisplay King & Display Technology Co., Ltd.
kingnovel Kingnovel Technology Co., Ltd.
koe Kaohsiung Opto-Electronics Inc.
kosagi Sutajio Ko-Usagi PTE Ltd.
kyo Kyocera Corporation
lacie LaCie
laird Laird PLC
lantiq Lantiq Semiconductor
lattice Lattice Semiconductor
lego LEGO Systems A/S
lemaker Shenzhen LeMaker Technology Co., Ltd.
lenovo Lenovo Group Ltd.
lg LG Corporation
libretech Shenzhen Libre Technology Co., Ltd
licheepi Lichee Pi
linaro Linaro Limited
linksys Belkin International, Inc. (Linksys)
linux Linux-specific binding
linx Linx Technologies
lltc Linear Technology Corporation
logicpd Logic PD, Inc.
lsi LSI Corp. (LSI Logic)
lwn Liebherr-Werk Nenzing GmbH
macnica Macnica Americas
marvell Marvell Technology Group Ltd.
maxim Maxim Integrated Products
mbvl Mobiveil Inc.
mcube mCube
meas Measurement Specialties
mediatek MediaTek Inc.
megachips MegaChips
mele Shenzhen MeLE Digital Technology Ltd.
melexis Melexis N.V.
melfas MELFAS Inc.
mellanox Mellanox Technologies
memsic MEMSIC Inc.
merrii Merrii Technology Co., Ltd.
micrel Micrel Inc.
microchip Microchip Technology Inc.
microcrystal Micro Crystal AG
micron Micron Technology Inc.
mikroe MikroElektronika d.o.o.
minix MINIX Technology Ltd.
miramems MiraMEMS Sensing Technology Co., Ltd.
mitsubishi Mitsubishi Electric Corporation
mosaixtech Mosaix Technologies, Inc.
motorola Motorola, Inc.
moxa Moxa Inc.
mpl MPL AG
mqmaker mqmaker Inc.
mscc Microsemi Corporation
msi Micro-Star International Co. Ltd.
mti Imagination Technologies Ltd. (formerly MIPS Technologies Inc.)
multi-inno Multi-Inno Technology Co.,Ltd
mundoreader Mundo Reader S.L.
murata Murata Manufacturing Co., Ltd.
mxicy Macronix International Co., Ltd.
myir MYIR Tech Limited
national National Semiconductor
nec NEC LCD Technologies, Ltd.
neonode Neonode Inc.
netgear NETGEAR
netlogic Broadcom Corporation (formerly NetLogic Microsystems)
netron-dy Netron DY
netxeon Shenzhen Netxeon Technology CO., LTD
nexbox Nexbox
nextthing Next Thing Co.
newhaven Newhaven Display International
ni National Instruments
nintendo Nintendo
nlt NLT Technologies, Ltd.
nokia Nokia
nordic Nordic Semiconductor
novtech NovTech, Inc.
nutsboard NutsBoard
nuvoton Nuvoton Technology Corporation
nvd New Vision Display
nvidia NVIDIA
nxp NXP Semiconductors
okaya Okaya Electric America, Inc.
oki Oki Electric Industry Co., Ltd.
olimex OLIMEX Ltd.
olpc One Laptop Per Child
onion Onion Corporation
onnn ON Semiconductor Corp.
ontat On Tat Industrial Company
opalkelly Opal Kelly Incorporated
opencores OpenCores.org
openrisc OpenRISC.io
option Option NV
oranth Shenzhen Oranth Technology Co., Ltd.
ORCL Oracle Corporation
orisetech Orise Technology
ortustech Ortus Technology Co., Ltd.
ovti OmniVision Technologies
oxsemi Oxford Semiconductor, Ltd.
panasonic Panasonic Corporation
parade Parade Technologies Inc.
pda Precision Design Associates, Inc.
pericom Pericom Technology Inc.
pervasive Pervasive Displays, Inc.
phicomm PHICOMM Co., Ltd.
phytec PHYTEC Messtechnik GmbH
picochip Picochip Ltd
pine64 Pine64
pixcir PIXCIR MICROELECTRONICS Co., Ltd
plantower Plantower Co., Ltd
plathome Plat'Home Co., Ltd.
plda PLDA
plx Broadcom Corporation (formerly PLX Technology)
pni PNI Sensor Corporation
portwell Portwell Inc.
poslab Poslab Technology Co., Ltd.
powervr PowerVR (deprecated, use img)
probox2 PROBOX2 (by W2COMP Co., Ltd.)
pulsedlight PulsedLight, Inc
qca Qualcomm Atheros, Inc.
qcom Qualcomm Technologies, Inc
qemu QEMU, a generic and open source machine emulator and virtualizer
qi Qi Hardware
qiaodian QiaoDian XianShi Corporation
qnap QNAP Systems, Inc.
radxa Radxa
raidsonic RaidSonic Technology GmbH
ralink Mediatek/Ralink Technology Corp.
ramtron Ramtron International
raspberrypi Raspberry Pi Foundation
raydium Raydium Semiconductor Corp.
rda Unisoc Communications, Inc.
realtek Realtek Semiconductor Corp.
renesas Renesas Electronics Corporation
richtek Richtek Technology Corporation
ricoh Ricoh Co. Ltd.
rikomagic Rikomagic Tech Corp. Ltd
riscv RISC-V Foundation
rockchip Fuzhou Rockchip Electronics Co., Ltd
rohm ROHM Semiconductor Co., Ltd
roofull Shenzhen Roofull Technology Co, Ltd
samsung Samsung Semiconductor
samtec Samtec/Softing company
sancloud Sancloud Ltd
sandisk Sandisk Corporation
sbs Smart Battery System
schindler Schindler
seagate Seagate Technology PLC
semtech Semtech Corporation
sensirion Sensirion AG
sff Small Form Factor Committee
sgd Solomon Goldentek Display Corporation
sgx SGX Sensortech
sharp Sharp Corporation
shimafuji Shimafuji Electric, Inc.
si-en Si-En Technology Ltd.
sifive SiFive, Inc.
sigma Sigma Designs, Inc.
sii Seiko Instruments, Inc.
sil Silicon Image
silabs Silicon Laboratories
silead Silead Inc.
silergy Silergy Corp.
siliconmitus Silicon Mitus, Inc.
simtek
sirf SiRF Technology, Inc.
sis Silicon Integrated Systems Corp.
sitronix Sitronix Technology Corporation
skyworks Skyworks Solutions, Inc.
smsc Standard Microsystems Corporation
snps Synopsys, Inc.
socionext Socionext Inc.
solidrun SolidRun
solomon Solomon Systech Limited
sony Sony Corporation
spansion Spansion Inc.
sprd Spreadtrum Communications Inc.
sst Silicon Storage Technology, Inc.
st STMicroelectronics
starry Starry Electronic Technology (ShenZhen) Co., LTD
startek Startek
ste ST-Ericsson
stericsson ST-Ericsson
summit Summit microelectronics
sunchip Shenzhen Sunchip Technology Co., Ltd
SUNW Sun Microsystems, Inc
swir Sierra Wireless
syna Synaptics Inc.
synology Synology, Inc.
tbs TBS Technologies
tbs-biometrics Touchless Biometric Systems AG
tcg Trusted Computing Group
tcl Toby Churchill Ltd.
technexion TechNexion
technologic Technologic Systems
tempo Tempo Semiconductor
techstar Shenzhen Techstar Electronics Co., Ltd.
terasic Terasic Inc.
thine THine Electronics, Inc.
ti Texas Instruments
tianma Tianma Micro-electronics Co., Ltd.
tlm Trusted Logic Mobility
tmt Tecon Microprocessor Technologies, LLC.
topeet Topeet
toradex Toradex AG
toshiba Toshiba Corporation
toumaz Toumaz
tpk TPK U.S.A. LLC
tplink TP-LINK Technologies Co., Ltd.
tpo TPO
tronfy Tronfy
tronsmart Tronsmart
truly Truly Semiconductors Limited
tsd Theobroma Systems Design und Consulting GmbH
tyan Tyan Computer Corporation
u-blox u-blox
ucrobotics uCRobotics
ubnt Ubiquiti Networks
udoo Udoo
uniwest United Western Technologies Corp (UniWest)
upisemi uPI Semiconductor Corp.
urt United Radiant Technology Corporation
usi Universal Scientific Industrial Co., Ltd.
v3 V3 Semiconductor
vamrs Vamrs Ltd.
variscite Variscite Ltd.
via VIA Technologies, Inc.
virtio Virtual I/O Device Specification, developed by the OASIS consortium
vishay Vishay Intertechnology, Inc
vitesse Vitesse Semiconductor Corporation
vivante Vivante Corporation
vocore VoCore Studio
voipac Voipac Technologies s.r.o.
vot Vision Optical Technology Co., Ltd.
wd Western Digital Corp.
wetek WeTek Electronics, limited.
wexler Wexler
whwave Shenzhen whwave Electronics, Inc.
wi2wi Wi2Wi, Inc.
winbond Winbond Electronics corp.
winstar Winstar Display Corp.
wlf Wolfson Microelectronics
wm Wondermedia Technologies, Inc.
x-powers X-Powers
xes Extreme Engineering Solutions (X-ES)
xillybus Xillybus Ltd.
xlnx Xilinx
xunlong Shenzhen Xunlong Software CO.,Limited
ysoft Y Soft Corporation a.s.
zarlink Zarlink Semiconductor
zeitec ZEITEC Semiconductor Co., LTD.
zidoo Shenzhen Zidoo Technology Co., Ltd.
zii Zodiac Inflight Innovations
zte ZTE Corp.
zyxel ZyXEL Communications Corp.

View File

@@ -147,6 +147,8 @@ patternProperties:
description: arcx Inc. / Archronix Inc.
"^aries,.*":
description: Aries Embedded GmbH
"^arducam,.*":
description: Arducam Technology co., Ltd.
"^arm,.*":
description: ARM Ltd.
"^armadeus,.*":
@@ -216,6 +218,8 @@ patternProperties:
description: Shenzhen BigTree Tech Co., LTD
"^bitmain,.*":
description: Bitmain Technologies
"^blokaslabs,.*":
description: Vilniaus Blokas UAB
"^blutek,.*":
description: BluTek Power
"^boe,.*":
@@ -555,6 +559,8 @@ patternProperties:
description: General Electric Company
"^geekbuying,.*":
description: GeekBuying
"^geekworm,.*":
description: Geekworm
"^gef,.*":
description: GE Fanuc Intelligent Platforms Embedded Systems, Inc.
"^GEFanuc,.*":

View File

@@ -0,0 +1,31 @@
Howto use the configfs overlay interface.
A device-tree configfs entry is created in /config/device-tree/overlays
and and it is manipulated using standard file system I/O.
Note that this is a debug level interface, for use by developers and
not necessarily something accessed by normal users due to the
security implications of having direct access to the kernel's device tree.
* To create an overlay you mkdir the directory:
# mkdir /config/device-tree/overlays/foo
* Either you echo the overlay firmware file to the path property file.
# echo foo.dtbo >/config/device-tree/overlays/foo/path
* Or you cat the contents of the overlay to the dtbo file
# cat foo.dtbo >/config/device-tree/overlays/foo/dtbo
The overlay file will be applied, and devices will be created/destroyed
as required.
To remove it simply rmdir the directory.
# rmdir /config/device-tree/overlays/foo
The rationalle of the dual interface (firmware & direct copy) is that each is
better suited to different use patterns. The firmware interface is what's
intended to be used by hardware managers in the kernel, while the copy interface
make sense for developers (since it avoids problems with namespaces).

View File

@@ -32,6 +32,7 @@ For more details see the file COPYING in the source distribution of Linux.
cx2341x-uapi
dw100
imx-uapi
bcm2835-isp
max2175
npcm-video
omap3isp-uapi

View File

@@ -12,11 +12,13 @@ These formats are used for the :ref:`metadata` interface only.
.. toctree::
:maxdepth: 1
metafmt-bcm2835-isp-stats
metafmt-d4xx
metafmt-generic
metafmt-intel-ipu3
metafmt-pisp-be
metafmt-rkisp1
metafmt-sensor-data
metafmt-uvc
metafmt-vivid
metafmt-vsp1-hgo

View File

@@ -0,0 +1,41 @@
.. Permission is granted to copy, distribute and/or modify this
.. document under the terms of the GNU Free Documentation License,
.. Version 1.1 or any later version published by the Free Software
.. Foundation, with no Invariant Sections, no Front-Cover Texts
.. and no Back-Cover Texts. A copy of the license is included at
.. Documentation/media/uapi/fdl-appendix.rst.
..
.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
.. _v4l2-meta-fmt-bcm2835-isp-stats:
*****************************************
V4L2_META_FMT_BCM2835_ISP_STATS ('BSTA')
*****************************************
BCM2835 ISP Statistics
Description
===========
The BCM2835 ISP hardware calculate image statistics for an input Bayer frame.
These statistics are obtained from the "bcm2835-isp0-capture3" device node
using the :c:type:`v4l2_meta_format` interface. They are formatted as described
by the :c:type:`bcm2835_isp_stats` structure below.
.. code-block:: c
#define DEFAULT_AWB_REGIONS_X 16
#define DEFAULT_AWB_REGIONS_Y 12
#define NUM_HISTOGRAMS 2
#define NUM_HISTOGRAM_BINS 128
#define AWB_REGIONS (DEFAULT_AWB_REGIONS_X * DEFAULT_AWB_REGIONS_Y)
#define FLOATING_REGIONS 16
#define AGC_REGIONS 16
#define FOCUS_REGIONS 12
.. kernel-doc:: include/uapi/linux/bcm2835-isp.h
:functions: bcm2835_isp_stats_hist bcm2835_isp_stats_region
bcm2835_isp_stats_focus bcm2835_isp_stats

View File

@@ -0,0 +1,32 @@
.. Permission is granted to copy, distribute and/or modify this
.. document under the terms of the GNU Free Documentation License,
.. Version 1.1 or any later version published by the Free Software
.. Foundation, with no Invariant Sections, no Front-Cover Texts
.. and no Back-Cover Texts. A copy of the license is included at
.. Documentation/media/uapi/fdl-appendix.rst.
..
.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
.. _v4l2-meta-fmt-sensor-data:
***********************************
V4L2_META_FMT_SENSOR_DATA ('SENS')
***********************************
Sensor Ancillary Metadata
Description
===========
This format describes ancillary data generated by a camera sensor and
transmitted over a stream on the camera bus. Sensor vendors generally have their
own custom format for this ancillary data. Some vendors follow a generic
CSI-2/SMIA embedded data format as described in the `CSI-2 specification.
<https://mipi.org/specifications/csi-2>`_
The size of the embedded buffer is defined as a single line with a pixel width
width specified in bytes. This is obtained by a call to the
:c:type:`VIDIOC_SUBDEV_G_FMT` ioctl on the sensor subdevice where the ``pad``
field in :c:type:`v4l2_subdev_format` is set to 1. Note that this size is fixed
and cannot be modified with a call to :c:type:`VIDIOC_SUBDEV_S_FMT`.

View File

@@ -0,0 +1,215 @@
.. Permission is granted to copy, distribute and/or modify this
.. document under the terms of the GNU Free Documentation License,
.. Version 1.1 or any later version published by the Free Software
.. Foundation, with no Invariant Sections, no Front-Cover Texts
.. and no Back-Cover Texts. A copy of the license is included at
.. Documentation/media/uapi/fdl-appendix.rst.
..
.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
.. _V4L2_PIX_FMT_NV12_COL128:
.. _V4L2_PIX_FMT_NV12_10_COL128:
********************************************************************************
V4L2_PIX_FMT_NV12_COL128, V4L2_PIX_FMT_NV12_10_COL128
********************************************************************************
V4L2_PIX_FMT_NV21_COL128
Formats with ½ horizontal and vertical chroma resolution. This format
has two planes - one for luminance and one for chrominance. Chroma
samples are interleaved. The difference to ``V4L2_PIX_FMT_NV12`` is the
memory layout. The image is split into columns of 128 bytes wide rather than
being in raster order.
V4L2_PIX_FMT_NV12_10_COL128
Follows the same pattern as ``V4L2_PIX_FMT_NV21_COL128`` with 128 byte, but is
a 10bit format with 3 10-bit samples being packed into 4 bytes. Each 128 byte
wide column therefore contains 96 samples.
Description
===========
This is the two-plane versions of the YUV 4:2:0 format where data is
grouped into 128 byte wide columns. The three components are separated into
two sub-images or planes. The Y plane has one byte per pixel and pixels
are grouped into 128 byte wide columns. The CbCr plane has the same width,
in bytes, as the Y plane (and the image), but is half as tall in pixels.
The chroma plane is also in 128 byte columns, reflecting 64 Cb and 64 Cr
samples.
The chroma samples for a column follow the luma samples. If there is any
paddding, then that will be reflected via the selection API.
The luma height must be a multiple of 2 lines.
The normal bytesperline is effectively fixed at 128. However the format
requires knowledge of the stride between columns, therefore the bytesperline
value has been repurposed to denote the number of 128 byte long lines between
the start of each column.
**Byte Order.**
.. flat-table::
:header-rows: 0
:stub-columns: 0
:widths: 12 12 12 12 12 4 12 12 12 12
* - start + 0:
- Y'\ :sub:`0,0`
- Y'\ :sub:`0,1`
- Y'\ :sub:`0,2`
- Y'\ :sub:`0,3`
- ...
- Y'\ :sub:`0,124`
- Y'\ :sub:`0,125`
- Y'\ :sub:`0,126`
- Y'\ :sub:`0,127`
* - start + 128:
- Y'\ :sub:`1,0`
- Y'\ :sub:`1,1`
- Y'\ :sub:`1,2`
- Y'\ :sub:`1,3`
- ...
- Y'\ :sub:`1,124`
- Y'\ :sub:`1,125`
- Y'\ :sub:`1,126`
- Y'\ :sub:`1,127`
* - start + 256:
- Y'\ :sub:`2,0`
- Y'\ :sub:`2,1`
- Y'\ :sub:`2,2`
- Y'\ :sub:`2,3`
- ...
- Y'\ :sub:`2,124`
- Y'\ :sub:`2,125`
- Y'\ :sub:`2,126`
- Y'\ :sub:`2,127`
* - ...
- ...
- ...
- ...
- ...
- ...
- ...
- ...
* - start + ((height-1) * 128):
- Y'\ :sub:`height-1,0`
- Y'\ :sub:`height-1,1`
- Y'\ :sub:`height-1,2`
- Y'\ :sub:`height-1,3`
- ...
- Y'\ :sub:`height-1,124`
- Y'\ :sub:`height-1,125`
- Y'\ :sub:`height-1,126`
- Y'\ :sub:`height-1,127`
* - start + ((height) * 128):
- Cb\ :sub:`0,0`
- Cr\ :sub:`0,0`
- Cb\ :sub:`0,1`
- Cr\ :sub:`0,1`
- ...
- Cb\ :sub:`0,62`
- Cr\ :sub:`0,62`
- Cb\ :sub:`0,63`
- Cr\ :sub:`0,63`
* - start + ((height+1) * 128):
- Cb\ :sub:`1,0`
- Cr\ :sub:`1,0`
- Cb\ :sub:`1,1`
- Cr\ :sub:`1,1`
- ...
- Cb\ :sub:`1,62`
- Cr\ :sub:`1,62`
- Cb\ :sub:`1,63`
- Cr\ :sub:`1,63`
* - ...
- ...
- ...
- ...
- ...
- ...
- ...
- ...
* - start + ((height+(height/2)-1) * 128):
- Cb\ :sub:`(height/2)-1,0`
- Cr\ :sub:`(height/2)-1,0`
- Cb\ :sub:`(height/2)-1,1`
- Cr\ :sub:`(height/2)-1,1`
- ...
- Cb\ :sub:`(height/2)-1,62`
- Cr\ :sub:`(height/2)-1,62`
- Cb\ :sub:`(height/2)-1,63`
- Cr\ :sub:`(height/2)-1,63`
* - start + (bytesperline * 128):
- Y'\ :sub:`0,128`
- Y'\ :sub:`0,129`
- Y'\ :sub:`0,130`
- Y'\ :sub:`0,131`
- ...
- Y'\ :sub:`0,252`
- Y'\ :sub:`0,253`
- Y'\ :sub:`0,254`
- Y'\ :sub:`0,255`
* - ...
- ...
- ...
- ...
- ...
- ...
- ...
- ...
V4L2_PIX_FMT_NV12_10_COL128 uses the same 128 byte column structure, but
encodes 10-bit YUV.
3 10-bit values are packed into 4 bytes as bits 9:0, 19:10, and 29:20, with
bits 30 & 31 unused. For the luma plane, bits 9:0 are Y0, 19:10 are Y1, and
29:20 are Y2. For the chroma plane the samples always come in pairs of Cr
and Cb, so it needs to be considered 6 values packed in 8 bytes.
Bit-packed representation.
.. raw:: latex
\small
.. tabularcolumns:: |p{1.2cm}||p{1.2cm}||p{1.2cm}||p{1.2cm}|p{3.2cm}|p{3.2cm}|
.. flat-table::
:header-rows: 0
:stub-columns: 0
:widths: 8 8 8 8
* - Y'\ :sub:`00[7:0]`
- Y'\ :sub:`01[5:0] (bits 7--2)` Y'\ :sub:`00[9:8]`\ (bits 1--0)
- Y'\ :sub:`02[3:0] (bits 7--4)` Y'\ :sub:`01[9:6]`\ (bits 3--0)
- unused (bits 7--6)` Y'\ :sub:`02[9:4]`\ (bits 5--0)
.. raw:: latex
\small
.. tabularcolumns:: |p{1.2cm}||p{1.2cm}||p{1.2cm}||p{1.2cm}|p{3.2cm}|p{3.2cm}|
.. flat-table::
:header-rows: 0
:stub-columns: 0
:widths: 12 12 12 12 12 12 12 12
* - Cb\ :sub:`00[7:0]`
- Cr\ :sub:`00[5:0]`\ (bits 7--2) Cb\ :sub:`00[9:8]`\ (bits 1--0)
- Cb\ :sub:`01[3:0]`\ (bits 7--4) Cr\ :sub:`00[9:6]`\ (bits 3--0)
- unused (bits 7--6) Cb\ :sub:`02[9:4]`\ (bits 5--0)
- Cr\ :sub:`01[7:0]`
- Cb\ :sub:`02[5:0]`\ (bits 7--2) Cr\ :sub:`01[9:8]`\ (bits 1--0)
- Cr\ :sub:`02[3:0]`\ (bits 7--4) Cb\ :sub:`02[9:6]`\ (bits 3--0)
- unused (bits 7--6) Cr\ :sub:`02[9:4]`\ (bits 5--0)
.. raw:: latex
\normalsize

View File

@@ -697,6 +697,18 @@ Data in the 12 high bits, zeros in the 4 low bits, arranged in little endian ord
- Cr\ :sub:`11`
V4L2_PIX_FMT_NV12_COL128
------------------------
``V4L2_PIX_FMT_NV12_COL128`` is the tiled version of
``V4L2_PIX_FMT_NV12`` with the image broken down into 128 pixel wide columns of
Y followed by the associated combined CbCr plane.
The normal bytesperline is effectively fixed at 128. However the format
requires knowledge of the stride between columns, therefore the bytesperline
value has been repurposed to denote the number of 128 byte long lines between
the start of each column.
Fully Planar YUV Formats
========================

View File

@@ -625,6 +625,43 @@ The following tables list existing packed RGB formats.
- b\ :sub:`2`
- b\ :sub:`1`
- b\ :sub:`0`
* .. _MEDIA_BUS_FMT_RGB565_1X24_CPADHI:
- MEDIA_BUS_FMT_RGB565_1X24_CPADHI
- 0x1022
-
-
-
-
-
-
-
-
-
- 0
- 0
- 0
- r\ :sub:`4`
- r\ :sub:`3`
- r\ :sub:`2`
- r\ :sub:`1`
- r\ :sub:`0`
- 0
- 0
- g\ :sub:`5`
- g\ :sub:`4`
- g\ :sub:`3`
- g\ :sub:`2`
- g\ :sub:`1`
- g\ :sub:`0`
- 0
- 0
- 0
- b\ :sub:`4`
- b\ :sub:`3`
- b\ :sub:`2`
- b\ :sub:`1`
- b\ :sub:`0`
* .. _MEDIA-BUS-FMT-BGR565-2X8-BE:
- MEDIA_BUS_FMT_BGR565_2X8_BE
@@ -913,6 +950,43 @@ The following tables list existing packed RGB formats.
- g\ :sub:`5`
- g\ :sub:`4`
- g\ :sub:`3`
* .. _MEDIA-BUS-FMT-BGR666-1X18:
- MEDIA_BUS_FMT-BGR666_1X18
- 0x1023
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- b\ :sub:`5`
- b\ :sub:`4`
- b\ :sub:`3`
- b\ :sub:`2`
- b\ :sub:`1`
- b\ :sub:`0`
- g\ :sub:`5`
- g\ :sub:`4`
- g\ :sub:`3`
- g\ :sub:`2`
- g\ :sub:`1`
- g\ :sub:`0`
- r\ :sub:`5`
- r\ :sub:`4`
- r\ :sub:`3`
- r\ :sub:`2`
- r\ :sub:`1`
- r\ :sub:`0`
* .. _MEDIA-BUS-FMT-RGB666-1X18:
- MEDIA_BUS_FMT_RGB666_1X18
@@ -1096,6 +1170,43 @@ The following tables list existing packed RGB formats.
- g\ :sub:`2`
- g\ :sub:`1`
- g\ :sub:`0`
* .. _MEDIA-BUS-FMT-BGR666-1X24_CPADHI:
- MEDIA_BUS_FMT_BGR666_1X24_CPADHI
- 0x1024
-
-
-
-
-
-
-
-
-
- 0
- 0
- b\ :sub:`5`
- b\ :sub:`4`
- b\ :sub:`3`
- b\ :sub:`2`
- b\ :sub:`1`
- b\ :sub:`0`
- 0
- 0
- g\ :sub:`5`
- g\ :sub:`4`
- g\ :sub:`3`
- g\ :sub:`2`
- g\ :sub:`1`
- g\ :sub:`0`
- 0
- 0
- r\ :sub:`5`
- r\ :sub:`4`
- r\ :sub:`3`
- r\ :sub:`2`
- r\ :sub:`1`
- r\ :sub:`0`
* .. _MEDIA-BUS-FMT-RGB666-1X24_CPADHI:
- MEDIA_BUS_FMT_RGB666_1X24_CPADHI
@@ -8561,3 +8672,33 @@ and finally the bit number in subscript. "x" indicates a padding bit.
- x
- x
- x
.. _v4l2-mbus-sensor-data:
Sensor Ancillary Metadata Formats
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This section lists ancillary data generated by a camera sensor and
transmitted over a stream on the camera bus.
The following table lists the existing sensor ancillary metadata formats:
.. _v4l2-mbus-pixelcode-sensor-metadata:
.. tabularcolumns:: |p{8.0cm}|p{1.4cm}|p{7.7cm}|
.. flat-table:: Sensor ancillary metadata formats
:header-rows: 1
:stub-columns: 0
* - Identifier
- Code
- Comments
* .. _MEDIA_BUS_FMT_SENSOR_DATA:
- MEDIA_BUS_FMT_SENSOR_DATA
- 0x7001
- Sensor vendor specific ancillary metadata. Some vendors follow a generic
CSI-2/SMIA embedded data format as described in the `CSI-2 specification.
<https://mipi.org/specifications/csi-2>`_

View File

@@ -270,4 +270,23 @@ image.
pixfmt-y8i
pixfmt-y12i
pixfmt-uv8
pixfmt-yuyv
pixfmt-uyvy
pixfmt-yvyu
pixfmt-vyuy
pixfmt-y41p
pixfmt-yuv420
pixfmt-yuv420m
pixfmt-yuv422m
pixfmt-yuv444m
pixfmt-yuv410
pixfmt-yuv422p
pixfmt-yuv411p
pixfmt-nv12
pixfmt-nv12m
pixfmt-nv12mt
pixfmt-nv12-col128
pixfmt-nv16
pixfmt-nv16m
pixfmt-nv24
pixfmt-m420

View File

@@ -1673,6 +1673,22 @@ S: Maintained
F: drivers/net/arcnet/
F: include/uapi/linux/if_arcnet.h
ARDUCAM 64MP SENSOR DRIVER
M: Arducam Kernel Maintenance <info@arducam.com>
L: linux-media@vger.kernel.org
S: Maintained
T: git git://linuxtv.org/media_tree.git
F: Documentation/devicetree/bindings/media/i2c/arducam,64mp.yaml
F: drivers/media/i2c/arducam_64mp.c
ARDUCAM PIVARIETY SENSOR DRIVER
M: Arducam Kernel Maintenance <info@arducam.com>
L: linux-media@vger.kernel.org
S: Maintained
T: git git://linuxtv.org/media_tree.git
F: Documentation/devicetree/bindings/media/i2c/arducam-pivariety.yaml
F: drivers/media/i2c/arducam-pivariety.c
ARM AND ARM64 SoC SUB-ARCHITECTURES (COMMON PARTS)
M: Arnd Bergmann <arnd@arndb.de>
M: Olof Johansson <olof@lixom.net>
@@ -4279,6 +4295,22 @@ S: Maintained
F: Documentation/devicetree/bindings/media/brcm,bcm2835-unicam.yaml
F: drivers/media/platform/broadcom/bcm2835-unicam*
BROADCOM BCM2835 ISP DRIVER
M: Raspberry Pi Kernel Maintenance <kernel-list@raspberrypi.com>
L: linux-media@vger.kernel.org
S: Maintained
F: Documentation/media/uapi/v4l/pixfmt-meta-bcm2835-isp-stats.rst
F: Documentation/media/v4l-drivers/bcm2835-isp.rst
F: drivers/staging/vc04_services/bcm2835-isp
F: include/uapi/linux/bcm2835-isp.h
BROADCOM BCM2711 HEVC DECODER
M: Raspberry Pi Kernel Maintenance <kernel-list@raspberrypi.com>
L: linux-media@vger.kernel.org
S: Maintained
F: Documentation/devicetree/bindings/media/rpivid_hevc.jaml
F: drivers/staging/media/rpivid
BROADCOM BCM47XX MIPS ARCHITECTURE
M: Hauke Mehrtens <hauke@hauke-m.de>
M: Rafał Miłecki <zajec5@gmail.com>
@@ -19108,6 +19140,12 @@ L: linux-edac@vger.kernel.org
S: Maintained
F: drivers/ras/amd/fmpm.c
RASPBERRY PI RP2040 GPIO BRIDGE DRIVER
M: Raspberry Pi Kernel Maintenance <kernel-list@raspberrypi.com>
S: Maintained
F: Documentation/devicetree/bindings/spi/raspberrypi,rp2040-gpio-bridge.yaml
F: drivers/spi/spi-rp2040-gpio-bridge.c
RASPBERRY PI PISP BACK END
M: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
L: Raspberry Pi Kernel Maintenance <kernel-list@raspberrypi.com>
@@ -19784,6 +19822,13 @@ S: Supported
F: drivers/iio/light/rohm-bu27008.c
F: drivers/iio/light/rohm-bu27034.c
ROHM BU64754 MOTOR DRIVER FOR CAMERA AUTOFOCUS
M: Kieran Bingham <kieran.bingham@ideasonboard.com>
L: linux-media@vger.kernel.org
S: Maintained
T: git git://linuxtv.org/media_tree.git
F: Documentation/devicetree/bindings/media/i2c/rohm,bu64754.yaml
ROHM MULTIFUNCTION BD9571MWV-M PMIC DEVICE DRIVERS
M: Marek Vasut <marek.vasut+renesas@gmail.com>
L: linux-kernel@vger.kernel.org
@@ -21251,6 +21296,31 @@ T: git git://linuxtv.org/media_tree.git
F: Documentation/devicetree/bindings/media/i2c/sony,imx415.yaml
F: drivers/media/i2c/imx415.c
SONY IMX477 SENSOR DRIVER
M: Raspberry Pi Kernel Maintenance <kernel-list@raspberrypi.com>
L: linux-media@vger.kernel.org
S: Maintained
T: git git://linuxtv.org/media_tree.git
F: Documentation/devicetree/bindings/media/i2c/imx378.yaml
F: Documentation/devicetree/bindings/media/i2c/imx477.yaml
F: drivers/media/i2c/imx477.c
SONY IMX519 SENSOR DRIVER
M: Arducam Kernel Maintenance <info@arducam.com>
L: linux-media@vger.kernel.org
S: Maintained
T: git git://linuxtv.org/media_tree.git
F: Documentation/devicetree/bindings/media/i2c/imx519.yaml
F: drivers/media/i2c/imx519.c
SONY IMX708 SENSOR DRIVER
M: Raspberry Pi Kernel Maintenance <kernel-list@raspberrypi.com>
L: linux-media@vger.kernel.org
S: Maintained
T: git git://linuxtv.org/media_tree.git
F: Documentation/devicetree/bindings/media/i2c/sony,imx708.yaml
F: drivers/media/i2c/imx708.c
SONY MEMORYSTICK SUBSYSTEM
M: Maxim Levitsky <maximlevitsky@gmail.com>
M: Alex Dubov <oakad@yahoo.com>

30
README.md Normal file
View File

@@ -0,0 +1,30 @@
Linux kernel
============
There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.
In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``. The formatted documentation can also be read online at:
https://www.kernel.org/doc/html/latest/
There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.
Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.
Build status for rpi-5.15.y:
[![Pi kernel build tests](https://github.com/raspberrypi/linux/actions/workflows/kernel-build.yml/badge.svg?branch=rpi-5.15.y)](https://github.com/raspberrypi/linux/actions/workflows/kernel-build.yml)
[![dtoverlaycheck](https://github.com/raspberrypi/linux/actions/workflows/dtoverlaycheck.yml/badge.svg?branch=rpi-5.15.y)](https://github.com/raspberrypi/linux/actions/workflows/dtoverlaycheck.yml)
Build status for rpi-6.1.y:
[![Pi kernel build tests](https://github.com/raspberrypi/linux/actions/workflows/kernel-build.yml/badge.svg?branch=rpi-6.1.y)](https://github.com/raspberrypi/linux/actions/workflows/kernel-build.yml)
[![dtoverlaycheck](https://github.com/raspberrypi/linux/actions/workflows/dtoverlaycheck.yml/badge.svg?branch=rpi-6.1.y)](https://github.com/raspberrypi/linux/actions/workflows/dtoverlaycheck.yml)
Build status for rpi-6.6.y:
[![Pi kernel build tests](https://github.com/raspberrypi/linux/actions/workflows/kernel-build.yml/badge.svg?branch=rpi-6.6.y)](https://github.com/raspberrypi/linux/actions/workflows/kernel-build.yml)
[![dtoverlaycheck](https://github.com/raspberrypi/linux/actions/workflows/dtoverlaycheck.yml/badge.svg?branch=rpi-6.6.y)](https://github.com/raspberrypi/linux/actions/workflows/dtoverlaycheck.yml)

View File

@@ -39,3 +39,8 @@ subdir-y += unisoc
subdir-y += vt8500
subdir-y += xen
subdir-y += xilinx
targets += dtbs dtbs_install
targets += $(dtb-y)
subdir-y += overlays

View File

@@ -35,6 +35,41 @@ dtb-$(CONFIG_ARCH_BCM2835) += \
bcm2711-rpi-cm4-io.dtb \
bcm2835-rpi-zero.dtb \
bcm2835-rpi-zero-w.dtb
DTC_FLAGS_bcm2708-rpi-b := -@
DTC_FLAGS_bcm2708-rpi-b-rev1 := -@
DTC_FLAGS_bcm2708-rpi-b-plus := -@
DTC_FLAGS_bcm2708-rpi-cm := -@
DTC_FLAGS_bcm2708-rpi-zero := -@
DTC_FLAGS_bcm2708-rpi-zero-w := -@
DTC_FLAGS_bcm2710-rpi-zero-2 := -@
DTC_FLAGS_bcm2710-rpi-zero-2-w := -@
DTC_FLAGS_bcm2709-rpi-2-b := -@
DTC_FLAGS_bcm2710-rpi-2-b := -@
DTC_FLAGS_bcm2710-rpi-3-b := -@
DTC_FLAGS_bcm2710-rpi-3-b-plus := -@
DTC_FLAGS_bcm2709-rpi-cm2 := -@
DTC_FLAGS_bcm2710-rpi-cm3 := -@
DTC_FLAGS_bcm2711-rpi-cm4 := -@
DTC_FLAGS_bcm2711-rpi-cm4s := -@
dtb-$(CONFIG_ARCH_BCM2835) += \
bcm2708-rpi-b.dtb \
bcm2708-rpi-b-rev1.dtb \
bcm2708-rpi-b-plus.dtb \
bcm2708-rpi-cm.dtb \
bcm2708-rpi-zero.dtb \
bcm2708-rpi-zero-w.dtb \
bcm2710-rpi-zero-2.dtb \
bcm2710-rpi-zero-2-w.dtb \
bcm2709-rpi-2-b.dtb \
bcm2710-rpi-2-b.dtb \
bcm2710-rpi-3-b.dtb \
bcm2710-rpi-3-b-plus.dtb \
bcm2709-rpi-cm2.dtb \
bcm2710-rpi-cm3.dtb \
bcm2711-rpi-cm4.dtb \
bcm2711-rpi-cm4s.dtb
dtb-$(CONFIG_ARCH_BCMBCA) += \
bcm947622.dtb \
bcm963138.dtb \

View File

@@ -0,0 +1,210 @@
/dts-v1/;
#include "bcm2708.dtsi"
#include "bcm2708-rpi.dtsi"
#include "bcm283x-rpi-smsc9514.dtsi"
#include "bcm283x-rpi-csi1-2lane.dtsi"
#include "bcm283x-rpi-i2c0mux_0_28.dtsi"
#include "bcm283x-rpi-led-deprecated.dtsi"
/ {
compatible = "raspberrypi,model-b-plus", "brcm,bcm2835";
model = "Raspberry Pi Model B+";
};
&gpio {
/*
* Taken from Raspberry-Pi-B-Plus-V1.2-Schematics.pdf
* RPI-BPLUS sheet 1
*
* Legend:
* "NC" = not connected (no rail from the SoC)
* "FOO" = GPIO line named "FOO" on the schematic
* "FOO_N" = GPIO line named "FOO" on schematic, active low
*/
gpio-line-names = "ID_SDA",
"ID_SCL",
"GPIO2",
"GPIO3",
"GPIO4",
"GPIO5",
"GPIO6",
"GPIO7",
"GPIO8",
"GPIO9",
"GPIO10",
"GPIO11",
"GPIO12",
"GPIO13",
"GPIO14",
"GPIO15",
"GPIO16",
"GPIO17",
"GPIO18",
"GPIO19",
"GPIO20",
"GPIO21",
"GPIO22",
"GPIO23",
"GPIO24",
"GPIO25",
"GPIO26",
"GPIO27",
"SDA0",
"SCL0",
"NC", /* GPIO30 */
"LAN_RUN", /* GPIO31 */
"CAM_GPIO1", /* GPIO32 */
"NC", /* GPIO33 */
"NC", /* GPIO34 */
"PWR_LOW_N", /* GPIO35 */
"NC", /* GPIO36 */
"NC", /* GPIO37 */
"USB_LIMIT", /* GPIO38 */
"NC", /* GPIO39 */
"PWM0_OUT", /* GPIO40 */
"CAM_GPIO0", /* GPIO41 */
"NC", /* GPIO42 */
"NC", /* GPIO43 */
"ETH_CLK", /* GPIO44 */
"PWM1_OUT", /* GPIO45 */
"HDMI_HPD_N",
"STATUS_LED",
/* Used by SD Card */
"SD_CLK_R",
"SD_CMD_R",
"SD_DATA0_R",
"SD_DATA1_R",
"SD_DATA2_R",
"SD_DATA3_R";
spi0_pins: spi0_pins {
brcm,pins = <9 10 11>;
brcm,function = <4>; /* alt0 */
};
spi0_cs_pins: spi0_cs_pins {
brcm,pins = <8 7>;
brcm,function = <1>; /* output */
};
i2c0_pins: i2c0 {
brcm,pins = <0 1>;
brcm,function = <4>;
};
i2c1_pins: i2c1 {
brcm,pins = <2 3>;
brcm,function = <4>;
};
i2s_pins: i2s {
brcm,pins = <18 19 20 21>;
brcm,function = <4>; /* alt0 */
};
audio_pins: audio_pins {
brcm,pins = <40 45>;
brcm,function = <4>;
brcm,pull = <0>;
};
};
&uart0 {
status = "okay";
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
spidev0: spidev@0{
compatible = "spidev";
reg = <0>; /* CE0 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
spidev1: spidev@1{
compatible = "spidev";
reg = <1>; /* CE1 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
};
&i2c0if {
clock-frequency = <100000>;
};
&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&i2c1_pins>;
clock-frequency = <100000>;
};
&i2c2 {
clock-frequency = <100000>;
};
&i2s {
pinctrl-names = "default";
pinctrl-0 = <&i2s_pins>;
};
&led_act {
gpios = <&gpio 47 GPIO_ACTIVE_HIGH>;
default-state = "off";
linux,default-trigger = "mmc0";
};
&leds {
led_pwr: led-pwr {
label = "PWR";
gpios = <&gpio 35 GPIO_ACTIVE_HIGH>;
default-state = "off";
linux,default-trigger = "input";
};
};
&hdmi {
hpd-gpios = <&gpio 46 GPIO_ACTIVE_LOW>;
};
&vchiq {
pinctrl-names = "default";
pinctrl-0 = <&audio_pins>;
};
&cam1_reg {
gpio = <&gpio 41 GPIO_ACTIVE_HIGH>;
};
cam0_reg: &cam_dummy_reg {
};
i2c_arm: &i2c1 {
};
i2c_vc: &i2c0 {
};
i2c_csi_dsi0: &i2c0 {
};
/ {
__overrides__ {
audio = <&chosen>,"bootargs{on='snd_bcm2835.enable_headphones=1 snd_bcm2835.enable_hdmi=1',off='snd_bcm2835.enable_headphones=0 snd_bcm2835.enable_hdmi=0'}";
act_led_gpio = <&led_act>,"gpios:4";
act_led_activelow = <&led_act>,"gpios:8";
act_led_trigger = <&led_act>,"linux,default-trigger";
pwr_led_gpio = <&led_pwr>,"gpios:4";
pwr_led_activelow = <&led_pwr>,"gpios:8";
pwr_led_trigger = <&led_pwr>,"linux,default-trigger";
};
};

View File

@@ -0,0 +1,223 @@
/dts-v1/;
#include "bcm2708.dtsi"
#include "bcm2708-rpi.dtsi"
#include "bcm283x-rpi-smsc9512.dtsi"
#include "bcm283x-rpi-csi1-2lane.dtsi"
#include "bcm283x-rpi-led-deprecated.dtsi"
/ {
compatible = "raspberrypi,model-b", "brcm,bcm2835";
model = "Raspberry Pi Model B";
};
&gpio {
/*
* Taken from Raspberry-Pi-Rev-1.0-Model-AB-Schematics.pdf
* RPI00021 sheet 02
*
* Legend:
* "NC" = not connected (no rail from the SoC)
* "FOO" = GPIO line named "FOO" on the schematic
* "FOO_N" = GPIO line named "FOO" on schematic, active low
*/
gpio-line-names = "SDA0",
"SCL0",
"SDA1",
"SCL1",
"GPIO_GCLK",
"CAM_GPIO1",
"LAN_RUN",
"SPI_CE1_N",
"SPI_CE0_N",
"SPI_MISO",
"SPI_MOSI",
"SPI_SCLK",
"NC", /* GPIO12 */
"NC", /* GPIO13 */
/* Serial port */
"TXD0",
"RXD0",
"STATUS_LED_N",
"GPIO17",
"GPIO18",
"NC", /* GPIO19 */
"NC", /* GPIO20 */
"GPIO21",
"GPIO22",
"GPIO23",
"GPIO24",
"GPIO25",
"NC", /* GPIO26 */
"CAM_GPIO0",
/* Binary number representing build/revision */
"CONFIG0",
"CONFIG1",
"CONFIG2",
"CONFIG3",
"NC", /* GPIO32 */
"NC", /* GPIO33 */
"NC", /* GPIO34 */
"NC", /* GPIO35 */
"NC", /* GPIO36 */
"NC", /* GPIO37 */
"NC", /* GPIO38 */
"NC", /* GPIO39 */
"PWM0_OUT",
"NC", /* GPIO41 */
"NC", /* GPIO42 */
"NC", /* GPIO43 */
"NC", /* GPIO44 */
"PWM1_OUT",
"HDMI_HPD_P",
"SD_CARD_DET",
/* Used by SD Card */
"SD_CLK_R",
"SD_CMD_R",
"SD_DATA0_R",
"SD_DATA1_R",
"SD_DATA2_R",
"SD_DATA3_R";
spi0_pins: spi0_pins {
brcm,pins = <9 10 11>;
brcm,function = <4>; /* alt0 */
};
spi0_cs_pins: spi0_cs_pins {
brcm,pins = <8 7>;
brcm,function = <1>; /* output */
};
i2c0_pins: i2c0 {
brcm,pins = <0 1>;
brcm,function = <4>;
};
i2c1_pins: i2c1 {
brcm,pins = <2 3>;
brcm,function = <4>;
};
i2s_pins: i2s {
brcm,pins = <28 29 30 31>;
brcm,function = <6>; /* alt2 */
};
audio_pins: audio_pins {
brcm,pins = <40 45>;
brcm,function = <4>;
brcm,pull = <0>;
};
};
&uart0 {
status = "okay";
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
spidev0: spidev@0{
compatible = "spidev";
reg = <0>; /* CE0 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
spidev1: spidev@1{
compatible = "spidev";
reg = <1>; /* CE1 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
};
/delete-node/ &i2c0mux;
i2c0: &i2c0if {
pinctrl-names = "default";
pinctrl-0 = <&i2c0_pins>;
clock-frequency = <100000>;
};
i2c_csi_dsi: &i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&i2c1_pins>;
clock-frequency = <100000>;
};
/ {
aliases {
i2c0 = &i2c0;
};
/* Provide an i2c0mux label to avoid undefined symbols in overlays */
i2c0mux: i2c0mux {
};
__overrides__ {
i2c0 = <&i2c0>, "status";
};
};
&i2c2 {
clock-frequency = <100000>;
};
&i2s {
pinctrl-names = "default";
pinctrl-0 = <&i2s_pins>;
};
&led_act {
gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
default-state = "off";
linux,default-trigger = "mmc0";
};
&hdmi {
hpd-gpios = <&gpio 46 GPIO_ACTIVE_HIGH>;
};
&vchiq {
pinctrl-names = "default";
pinctrl-0 = <&audio_pins>;
};
&cam1_reg {
gpio = <&gpio 27 GPIO_ACTIVE_HIGH>;
};
cam0_reg: &cam_dummy_reg {
};
i2c_arm: &i2c0 {
};
i2c_vc: &i2c1 {
};
i2c_csi_dsi0: &i2c0 {
};
/ {
__overrides__ {
audio = <&chosen>,"bootargs{on='snd_bcm2835.enable_headphones=1 snd_bcm2835.enable_hdmi=1',off='snd_bcm2835.enable_headphones=0 snd_bcm2835.enable_hdmi=0'}";
act_led_gpio = <&led_act>,"gpios:4";
act_led_activelow = <&led_act>,"gpios:8";
act_led_trigger = <&led_act>,"linux,default-trigger";
i2c = <&i2c0>,"status";
i2c_arm = <&i2c0>,"status";
i2c_vc = <&i2c1>,"status";
i2c_baudrate = <&i2c0>,"clock-frequency:0";
i2c_arm_baudrate = <&i2c0>,"clock-frequency:0";
i2c_vc_baudrate = <&i2c1>,"clock-frequency:0";
};
};

View File

@@ -0,0 +1,198 @@
/dts-v1/;
#include "bcm2708.dtsi"
#include "bcm2708-rpi.dtsi"
#include "bcm283x-rpi-smsc9512.dtsi"
#include "bcm283x-rpi-csi1-2lane.dtsi"
#include "bcm283x-rpi-i2c0mux_0_28.dtsi"
#include "bcm283x-rpi-led-deprecated.dtsi"
/ {
compatible = "raspberrypi,model-b", "brcm,bcm2835";
model = "Raspberry Pi Model B";
};
&gpio {
/*
* Taken from Raspberry-Pi-Rev-2.0-Model-AB-Schematics.pdf
* RPI00022 sheet 02
*
* Legend:
* "NC" = not connected (no rail from the SoC)
* "FOO" = GPIO line named "FOO" on the schematic
* "FOO_N" = GPIO line named "FOO" on schematic, active low
*/
gpio-line-names = "SDA0",
"SCL0",
"SDA1",
"SCL1",
"GPIO_GCLK",
"CAM_GPIO1",
"LAN_RUN",
"SPI_CE1_N",
"SPI_CE0_N",
"SPI_MISO",
"SPI_MOSI",
"SPI_SCLK",
"NC", /* GPIO12 */
"NC", /* GPIO13 */
/* Serial port */
"TXD0",
"RXD0",
"STATUS_LED_N",
"GPIO17",
"GPIO18",
"NC", /* GPIO19 */
"NC", /* GPIO20 */
"CAM_GPIO0",
"GPIO22",
"GPIO23",
"GPIO24",
"GPIO25",
"NC", /* GPIO26 */
"GPIO27",
"GPIO28",
"GPIO29",
"GPIO30",
"GPIO31",
"NC", /* GPIO32 */
"NC", /* GPIO33 */
"NC", /* GPIO34 */
"NC", /* GPIO35 */
"NC", /* GPIO36 */
"NC", /* GPIO37 */
"NC", /* GPIO38 */
"NC", /* GPIO39 */
"PWM0_OUT",
"NC", /* GPIO41 */
"NC", /* GPIO42 */
"NC", /* GPIO43 */
"NC", /* GPIO44 */
"PWM1_OUT",
"HDMI_HPD_P",
"SD_CARD_DET",
/* Used by SD Card */
"SD_CLK_R",
"SD_CMD_R",
"SD_DATA0_R",
"SD_DATA1_R",
"SD_DATA2_R",
"SD_DATA3_R";
spi0_pins: spi0_pins {
brcm,pins = <9 10 11>;
brcm,function = <4>; /* alt0 */
};
spi0_cs_pins: spi0_cs_pins {
brcm,pins = <8 7>;
brcm,function = <1>; /* output */
};
i2c0_pins: i2c0 {
brcm,pins = <0 1>;
brcm,function = <4>;
};
i2c1_pins: i2c1 {
brcm,pins = <2 3>;
brcm,function = <4>;
};
i2s_pins: i2s {
brcm,pins = <28 29 30 31>;
brcm,function = <6>; /* alt2 */
};
audio_pins: audio_pins {
brcm,pins = <40 45>;
brcm,function = <4>;
brcm,pull = <0>;
};
};
&uart0 {
status = "okay";
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
spidev0: spidev@0{
compatible = "spidev";
reg = <0>; /* CE0 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
spidev1: spidev@1{
compatible = "spidev";
reg = <1>; /* CE1 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
};
&i2c0if {
clock-frequency = <100000>;
};
&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&i2c1_pins>;
clock-frequency = <100000>;
};
&i2c2 {
clock-frequency = <100000>;
};
&i2s {
pinctrl-names = "default";
pinctrl-0 = <&i2s_pins>;
};
&led_act {
gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
default-state = "off";
linux,default-trigger = "mmc0";
};
&hdmi {
hpd-gpios = <&gpio 46 GPIO_ACTIVE_HIGH>;
};
&vchiq {
pinctrl-names = "default";
pinctrl-0 = <&audio_pins>;
};
&cam1_reg {
gpio = <&gpio 21 GPIO_ACTIVE_HIGH>;
};
cam0_reg: &cam_dummy_reg {
};
i2c_arm: &i2c1 {
};
i2c_vc: &i2c0 {
};
i2c_csi_dsi0: &i2c0 {
};
/ {
__overrides__ {
audio = <&chosen>,"bootargs{on='snd_bcm2835.enable_headphones=1 snd_bcm2835.enable_hdmi=1',off='snd_bcm2835.enable_headphones=0 snd_bcm2835.enable_hdmi=0'}";
act_led_gpio = <&led_act>,"gpios:4";
act_led_activelow = <&led_act>,"gpios:8";
act_led_trigger = <&led_act>,"linux,default-trigger";
};
};

View File

@@ -0,0 +1,38 @@
// SPDX-License-Identifier: GPL-2.0
&uart0 {
bt: bluetooth {
compatible = "brcm,bcm43438-bt";
max-speed = <3000000>;
shutdown-gpios = <&gpio 45 GPIO_ACTIVE_HIGH>;
local-bd-address = [ 00 00 00 00 00 00 ];
fallback-bd-address; // Don't override a valid address
status = "okay";
};
};
&uart1 {
minibt: bluetooth {
compatible = "brcm,bcm43438-bt";
max-speed = <230400>;
shutdown-gpios = <&gpio 45 GPIO_ACTIVE_HIGH>;
local-bd-address = [ 00 00 00 00 00 00 ];
fallback-bd-address; // Don't override a valid address
status = "disabled";
};
};
/ {
aliases {
bluetooth = &bt;
};
__overrides__ {
bdaddr = <&bt>,"local-bd-address[",
<&bt>,"fallback-bd-address?=0",
<&minibt>,"local-bd-address[",
<&minibt>,"fallback-bd-address?=0";
krnbt = <&bt>,"status";
krnbt_baudrate = <&bt>,"max-speed:0", <&minibt>,"max-speed:0";
};
};

View File

@@ -0,0 +1,174 @@
/dts-v1/;
#include "bcm2708-rpi-cm.dtsi"
#include "bcm283x-rpi-csi0-2lane.dtsi"
#include "bcm283x-rpi-csi1-4lane.dtsi"
#include "bcm283x-rpi-i2c0mux_0_28.dtsi"
/ {
compatible = "raspberrypi,compute-module", "brcm,bcm2835";
model = "Raspberry Pi Compute Module";
};
&cam1_reg {
gpio = <&gpio 3 GPIO_ACTIVE_HIGH>;
status = "disabled";
};
cam0_reg: &cam0_regulator {
gpio = <&gpio 31 GPIO_ACTIVE_HIGH>;
};
i2c_csi_dsi0: &i2c0 {
};
&uart0 {
status = "okay";
};
&gpio {
/*
* This is based on the official GPU firmware DT blob.
*
* Legend:
* "NC" = not connected (no rail from the SoC)
* "FOO" = GPIO line named "FOO" on the schematic
* "FOO_N" = GPIO line named "FOO" on schematic, active low
*/
gpio-line-names = "GPIO0",
"GPIO1",
"GPIO2",
"GPIO3",
"GPIO4",
"GPIO5",
"GPIO6",
"GPIO7",
"GPIO8",
"GPIO9",
"GPIO10",
"GPIO11",
"GPIO12",
"GPIO13",
"GPIO14",
"GPIO15",
"GPIO16",
"GPIO17",
"GPIO18",
"GPIO19",
"GPIO20",
"GPIO21",
"GPIO22",
"GPIO23",
"GPIO24",
"GPIO25",
"GPIO26",
"GPIO27",
"GPIO28",
"GPIO29",
"GPIO30",
"GPIO31",
"GPIO32",
"GPIO33",
"GPIO34",
"GPIO35",
"GPIO36",
"GPIO37",
"GPIO38",
"GPIO39",
"GPIO40",
"GPIO41",
"GPIO42",
"GPIO43",
"GPIO44",
"GPIO45",
"HDMI_HPD_N",
/* Also used as ACT LED */
"EMMC_EN_N",
/* Used by eMMC */
"SD_CLK_R",
"SD_CMD_R",
"SD_DATA0_R",
"SD_DATA1_R",
"SD_DATA2_R",
"SD_DATA3_R";
spi0_pins: spi0_pins {
brcm,pins = <9 10 11>;
brcm,function = <4>; /* alt0 */
};
spi0_cs_pins: spi0_cs_pins {
brcm,pins = <8 7>;
brcm,function = <1>; /* output */
};
i2c0_pins: i2c0 {
brcm,pins = <0 1>;
brcm,function = <4>;
};
i2c1_pins: i2c1 {
brcm,pins = <2 3>;
brcm,function = <4>;
};
i2s_pins: i2s {
brcm,pins = <18 19 20 21>;
brcm,function = <4>; /* alt0 */
};
audio_pins: audio_pins {
brcm,pins;
brcm,function;
};
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
spidev0: spidev@0{
compatible = "spidev";
reg = <0>; /* CE0 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
spidev1: spidev@1{
compatible = "spidev";
reg = <1>; /* CE1 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
};
&i2c0if {
clock-frequency = <100000>;
};
&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&i2c1_pins>;
clock-frequency = <100000>;
};
&i2c2 {
clock-frequency = <100000>;
};
&i2s {
pinctrl-names = "default";
pinctrl-0 = <&i2s_pins>;
};
&vchiq {
pinctrl-names = "default";
pinctrl-0 = <&audio_pins>;
};
&hdmi {
hpd-gpios = <&gpio 46 GPIO_ACTIVE_HIGH>;
};

View File

@@ -0,0 +1,23 @@
#include "bcm2708.dtsi"
#include "bcm2708-rpi.dtsi"
#include "bcm283x-rpi-led-deprecated.dtsi"
&led_act {
gpios = <&gpio 47 GPIO_ACTIVE_HIGH>;
default-state = "off";
linux,default-trigger = "mmc0";
};
i2c_arm: &i2c1 {
};
i2c_vc: &i2c0 {
};
/ {
__overrides__ {
act_led_gpio = <&led_act>,"gpios:4";
act_led_activelow = <&led_act>,"gpios:8";
act_led_trigger = <&led_act>,"linux,default-trigger";
};
};

View File

@@ -0,0 +1,254 @@
/dts-v1/;
#include "bcm2708.dtsi"
#include "bcm2708-rpi.dtsi"
#include "bcm283x-rpi-csi1-2lane.dtsi"
#include "bcm283x-rpi-i2c0mux_0_28.dtsi"
#include "bcm2708-rpi-bt.dtsi"
#include "bcm283x-rpi-led-deprecated.dtsi"
/ {
compatible = "raspberrypi,model-zero-w", "brcm,bcm2835";
model = "Raspberry Pi Zero W";
chosen {
bootargs = "coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_headphones=0";
};
aliases {
serial0 = &uart1;
serial1 = &uart0;
mmc1 = &mmcnr;
};
};
&gpio {
/*
* This is based on the official GPU firmware DT blob.
*
* Legend:
* "NC" = not connected (no rail from the SoC)
* "FOO" = GPIO line named "FOO" on the schematic
* "FOO_N" = GPIO line named "FOO" on schematic, active low
*/
gpio-line-names = "ID_SDA",
"ID_SCL",
"GPIO2",
"GPIO3",
"GPIO4",
"GPIO5",
"GPIO6",
"GPIO7",
"GPIO8",
"GPIO9",
"GPIO10",
"GPIO11",
"GPIO12",
"GPIO13",
"GPIO14",
"GPIO15",
"GPIO16",
"GPIO17",
"GPIO18",
"GPIO19",
"GPIO20",
"GPIO21",
"GPIO22",
"GPIO23",
"GPIO24",
"GPIO25",
"GPIO26",
"GPIO27",
"SDA0",
"SCL0",
/* Used by BT module */
"CTS0",
"RTS0",
"TXD0",
"RXD0",
/* Used by Wifi */
"SD1_CLK",
"SD1_CMD",
"SD1_DATA0",
"SD1_DATA1",
"SD1_DATA2",
"SD1_DATA3",
"CAM_GPIO1", /* GPIO40 */
"WL_ON", /* GPIO41 */
"NC", /* GPIO42 */
"WIFI_CLK", /* GPIO43 */
"CAM_GPIO0", /* GPIO44 */
"BT_ON", /* GPIO45 */
"HDMI_HPD_N",
"STATUS_LED_N",
/* Used by SD Card */
"SD_CLK_R",
"SD_CMD_R",
"SD_DATA0_R",
"SD_DATA1_R",
"SD_DATA2_R",
"SD_DATA3_R";
spi0_pins: spi0_pins {
brcm,pins = <9 10 11>;
brcm,function = <4>; /* alt0 */
};
spi0_cs_pins: spi0_cs_pins {
brcm,pins = <8 7>;
brcm,function = <1>; /* output */
};
i2c0_pins: i2c0 {
brcm,pins = <0 1>;
brcm,function = <4>;
};
i2c1_pins: i2c1 {
brcm,pins = <2 3>;
brcm,function = <4>;
};
i2s_pins: i2s {
brcm,pins = <18 19 20 21>;
brcm,function = <4>; /* alt0 */
};
sdio_pins: sdio_pins {
brcm,pins = <34 35 36 37 38 39>;
brcm,function = <7>; /* ALT3 = SD1 */
brcm,pull = <0 2 2 2 2 2>;
};
bt_pins: bt_pins {
brcm,pins = <43>;
brcm,function = <4>; /* alt0:GPCLK2 */
brcm,pull = <0>; /* none */
};
uart0_pins: uart0_pins {
brcm,pins = <30 31 32 33>;
brcm,function = <7>; /* alt3=UART0 */
brcm,pull = <2 0 0 2>; /* up none none up */
};
uart1_pins: uart1_pins {
brcm,pins;
brcm,function;
brcm,pull;
};
uart1_bt_pins: uart1_bt_pins {
brcm,pins = <32 33 30 31>;
brcm,function = <BCM2835_FSEL_ALT5>; /* alt5=UART1 */
brcm,pull = <0 2 2 0>;
};
audio_pins: audio_pins {
brcm,pins = <>;
brcm,function = <>;
};
};
&mmcnr {
pinctrl-names = "default";
pinctrl-0 = <&sdio_pins>;
bus-width = <4>;
status = "okay";
#address-cells = <1>;
#size-cells = <0>;
brcmf: wifi@1 {
reg = <1>;
compatible = "brcm,bcm4329-fmac";
};
};
&uart0 {
pinctrl-names = "default";
pinctrl-0 = <&uart0_pins &bt_pins>;
status = "okay";
};
&uart1 {
pinctrl-names = "default";
pinctrl-0 = <&uart1_pins>;
status = "okay";
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
spidev0: spidev@0{
compatible = "spidev";
reg = <0>; /* CE0 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
spidev1: spidev@1{
compatible = "spidev";
reg = <1>; /* CE1 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
};
&i2c0if {
clock-frequency = <100000>;
};
&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&i2c1_pins>;
clock-frequency = <100000>;
};
&i2c2 {
clock-frequency = <100000>;
};
&i2s {
pinctrl-names = "default";
pinctrl-0 = <&i2s_pins>;
};
&led_act {
gpios = <&gpio 47 GPIO_ACTIVE_LOW>;
default-state = "off";
linux,default-trigger = "actpwr";
};
&hdmi {
hpd-gpios = <&gpio 46 GPIO_ACTIVE_LOW>;
};
&vchiq {
pinctrl-names = "default";
pinctrl-0 = <&audio_pins>;
};
&cam1_reg {
gpio = <&gpio 44 GPIO_ACTIVE_HIGH>;
};
cam0_reg: &cam_dummy_reg {
};
i2c_arm: &i2c1 {};
i2c_vc: &i2c0 {};
i2c_csi_dsi0: &i2c0 {};
/ {
__overrides__ {
audio = <&chosen>,"bootargs{on='snd_bcm2835.enable_hdmi=1',off='snd_bcm2835.enable_hdmi=0'}";
act_led_gpio = <&led_act>,"gpios:4";
act_led_activelow = <&led_act>,"gpios:8";
act_led_trigger = <&led_act>,"linux,default-trigger";
};
};

View File

@@ -0,0 +1,189 @@
/dts-v1/;
#include "bcm2708.dtsi"
#include "bcm2708-rpi.dtsi"
#include "bcm283x-rpi-csi1-2lane.dtsi"
#include "bcm283x-rpi-i2c0mux_0_28.dtsi"
#include "bcm283x-rpi-led-deprecated.dtsi"
/ {
compatible = "raspberrypi,model-zero", "brcm,bcm2835";
model = "Raspberry Pi Zero";
};
&gpio {
/*
* This is based on the official GPU firmware DT blob.
*
* Legend:
* "NC" = not connected (no rail from the SoC)
* "FOO" = GPIO line named "FOO" on the schematic
* "FOO_N" = GPIO line named "FOO" on schematic, active low
*/
gpio-line-names = "ID_SDA",
"ID_SCL",
"GPIO2",
"GPIO3",
"GPIO4",
"GPIO5",
"GPIO6",
"GPIO7",
"GPIO8",
"GPIO9",
"GPIO10",
"GPIO11",
"GPIO12",
"GPIO13",
"GPIO14",
"GPIO15",
"GPIO16",
"GPIO17",
"GPIO18",
"GPIO19",
"GPIO20",
"GPIO21",
"GPIO22",
"GPIO23",
"GPIO24",
"GPIO25",
"GPIO26",
"GPIO27",
"SDA0",
"SCL0",
"NC", /* GPIO30 */
"NC", /* GPIO31 */
"CAM_GPIO1", /* GPIO32 */
"NC", /* GPIO33 */
"NC", /* GPIO34 */
"NC", /* GPIO35 */
"NC", /* GPIO36 */
"NC", /* GPIO37 */
"NC", /* GPIO38 */
"NC", /* GPIO39 */
"NC", /* GPIO40 */
"CAM_GPIO0", /* GPIO41 */
"NC", /* GPIO42 */
"NC", /* GPIO43 */
"NC", /* GPIO44 */
"NC", /* GPIO45 */
"HDMI_HPD_N",
"STATUS_LED_N",
/* Used by SD Card */
"SD_CLK_R",
"SD_CMD_R",
"SD_DATA0_R",
"SD_DATA1_R",
"SD_DATA2_R",
"SD_DATA3_R";
spi0_pins: spi0_pins {
brcm,pins = <9 10 11>;
brcm,function = <4>; /* alt0 */
};
spi0_cs_pins: spi0_cs_pins {
brcm,pins = <8 7>;
brcm,function = <1>; /* output */
};
i2c0_pins: i2c0 {
brcm,pins = <0 1>;
brcm,function = <4>;
};
i2c1_pins: i2c1 {
brcm,pins = <2 3>;
brcm,function = <4>;
};
i2s_pins: i2s {
brcm,pins = <18 19 20 21>;
brcm,function = <4>; /* alt0 */
};
audio_pins: audio_pins {
brcm,pins = <>;
brcm,function = <>;
};
};
&uart0 {
status = "okay";
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
spidev0: spidev@0{
compatible = "spidev";
reg = <0>; /* CE0 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
spidev1: spidev@1{
compatible = "spidev";
reg = <1>; /* CE1 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
};
&i2c0if {
clock-frequency = <100000>;
};
&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&i2c1_pins>;
clock-frequency = <100000>;
};
&i2c2 {
clock-frequency = <100000>;
};
&i2s {
pinctrl-names = "default";
pinctrl-0 = <&i2s_pins>;
};
&led_act {
gpios = <&gpio 47 GPIO_ACTIVE_LOW>;
default-state = "off";
linux,default-trigger = "actpwr";
};
&hdmi {
hpd-gpios = <&gpio 46 GPIO_ACTIVE_LOW>;
};
&vchiq {
pinctrl-names = "default";
pinctrl-0 = <&audio_pins>;
};
&cam1_reg {
gpio = <&gpio 41 GPIO_ACTIVE_HIGH>;
};
cam0_reg: &cam_dummy_reg {
};
i2c_arm: &i2c1 {};
i2c_vc: &i2c0 {};
i2c_csi_dsi0: &i2c0 {};
/ {
__overrides__ {
audio = <&chosen>,"bootargs{on='snd_bcm2835.enable_hdmi=1',off='snd_bcm2835.enable_hdmi=0'}";
act_led_gpio = <&led_act>,"gpios:4";
act_led_activelow = <&led_act>,"gpios:8";
act_led_trigger = <&led_act>,"linux,default-trigger";
};
};

View File

@@ -0,0 +1,63 @@
/* Downstream modifications common to bcm2835, bcm2836, bcm2837 */
#define i2c0 i2c0mux
#include "bcm2835-rpi.dtsi"
#undef i2c0
#include "bcm270x-rpi.dtsi"
/ {
memory@0 {
device_type = "memory";
reg = <0x0 0x0>;
};
aliases {
i2c2 = &i2c2;
};
__overrides__ {
hdmi = <&hdmi>,"status";
i2c2_iknowwhatimdoing = <&i2c2>,"status";
i2c2_baudrate = <&i2c2>,"clock-frequency:0";
nvmem_cust_rw = <&nvmem_cust>,"rw?";
sd = <&sdhost>,"status";
sd_poll_once = <&sdhost>,"non-removable?";
};
};
&soc {
nvmem {
compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
nvmem_otp: nvmem_otp {
compatible = "raspberrypi,rpi-otp";
firmware = <&firmware>;
reg = <0 192>;
status = "okay";
};
nvmem_cust: nvmem_cust {
compatible = "raspberrypi,rpi-otp";
firmware = <&firmware>;
reg = <1 8>;
status = "okay";
};
};
};
&sdhost {
pinctrl-names = "default";
pinctrl-0 = <&sdhost_gpio48>;
status = "okay";
};
&hdmi {
power-domains = <&power RPI_POWER_DOMAIN_HDMI>;
status = "disabled";
};
&i2c2 {
status = "disabled";
};

View File

@@ -0,0 +1,19 @@
#define i2c0 i2c0if
#include "bcm2835.dtsi"
#undef i2c0
#include "bcm270x.dtsi"
/ {
__overrides__ {
arm_freq;
};
};
&soc {
dma-ranges = <0x80000000 0x00000000 0x20000000>,
<0x7e000000 0x20000000 0x02000000>;
};
&vc4 {
status = "disabled";
};

View File

@@ -0,0 +1,204 @@
/dts-v1/;
#include "bcm2709.dtsi"
#include "bcm2709-rpi.dtsi"
#include "bcm283x-rpi-smsc9514.dtsi"
#include "bcm283x-rpi-csi1-2lane.dtsi"
#include "bcm283x-rpi-i2c0mux_0_28.dtsi"
#include "bcm283x-rpi-led-deprecated.dtsi"
/ {
compatible = "raspberrypi,2-model-b", "brcm,bcm2836";
model = "Raspberry Pi 2 Model B";
};
&gpio {
/*
* Taken from rpi_SCH_2b_1p2_reduced.pdf and
* the official GPU firmware DT blob.
*
* Legend:
* "NC" = not connected (no rail from the SoC)
* "FOO" = GPIO line named "FOO" on the schematic
* "FOO_N" = GPIO line named "FOO" on schematic, active low
*/
gpio-line-names = "ID_SDA",
"ID_SCL",
"GPIO2",
"GPIO3",
"GPIO4",
"GPIO5",
"GPIO6",
"GPIO7",
"GPIO8",
"GPIO9",
"GPIO10",
"GPIO11",
"GPIO12",
"GPIO13",
"GPIO14",
"GPIO15",
"GPIO16",
"GPIO17",
"GPIO18",
"GPIO19",
"GPIO20",
"GPIO21",
"GPIO22",
"GPIO23",
"GPIO24",
"GPIO25",
"GPIO26",
"GPIO27",
"SDA0",
"SCL0",
"NC", /* GPIO30 */
"LAN_RUN",
"CAM_GPIO1",
"NC", /* GPIO33 */
"NC", /* GPIO34 */
"PWR_LOW_N",
"NC", /* GPIO36 */
"NC", /* GPIO37 */
"USB_LIMIT",
"NC", /* GPIO39 */
"PWM0_OUT",
"CAM_GPIO0",
"SMPS_SCL",
"SMPS_SDA",
"ETH_CLK",
"PWM1_OUT",
"HDMI_HPD_N",
"STATUS_LED",
/* Used by SD Card */
"SD_CLK_R",
"SD_CMD_R",
"SD_DATA0_R",
"SD_DATA1_R",
"SD_DATA2_R",
"SD_DATA3_R";
spi0_pins: spi0_pins {
brcm,pins = <9 10 11>;
brcm,function = <4>; /* alt0 */
};
spi0_cs_pins: spi0_cs_pins {
brcm,pins = <8 7>;
brcm,function = <1>; /* output */
};
i2c0_pins: i2c0 {
brcm,pins = <0 1>;
brcm,function = <4>;
};
i2c1_pins: i2c1 {
brcm,pins = <2 3>;
brcm,function = <4>;
};
i2s_pins: i2s {
brcm,pins = <18 19 20 21>;
brcm,function = <4>; /* alt0 */
};
audio_pins: audio_pins {
brcm,pins = <40 45>;
brcm,function = <4>;
brcm,pull = <0>;
};
};
&uart0 {
status = "okay";
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
spidev0: spidev@0{
compatible = "spidev";
reg = <0>; /* CE0 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
spidev1: spidev@1{
compatible = "spidev";
reg = <1>; /* CE1 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
};
&i2c0if {
clock-frequency = <100000>;
};
&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&i2c1_pins>;
clock-frequency = <100000>;
};
&i2c2 {
clock-frequency = <100000>;
};
&i2s {
pinctrl-names = "default";
pinctrl-0 = <&i2s_pins>;
};
&led_act {
gpios = <&gpio 47 GPIO_ACTIVE_HIGH>;
default-state = "off";
linux,default-trigger = "mmc0";
};
&leds {
led_pwr: led-pwr {
label = "PWR";
gpios = <&gpio 35 GPIO_ACTIVE_HIGH>;
default-state = "off";
linux,default-trigger = "input";
};
};
&hdmi {
hpd-gpios = <&gpio 46 GPIO_ACTIVE_LOW>;
};
&vchiq {
pinctrl-names = "default";
pinctrl-0 = <&audio_pins>;
};
&cam1_reg {
gpio = <&gpio 41 GPIO_ACTIVE_HIGH>;
};
cam0_reg: &cam_dummy_reg {
};
i2c_csi_dsi0: &i2c0 {
};
/ {
__overrides__ {
audio = <&chosen>,"bootargs{on='snd_bcm2835.enable_headphones=1 snd_bcm2835.enable_hdmi=1',off='snd_bcm2835.enable_headphones=0 snd_bcm2835.enable_hdmi=0'}";
act_led_gpio = <&led_act>,"gpios:4";
act_led_activelow = <&led_act>,"gpios:8";
act_led_trigger = <&led_act>,"linux,default-trigger";
pwr_led_gpio = <&led_pwr>,"gpios:4";
pwr_led_activelow = <&led_pwr>,"gpios:8";
pwr_led_trigger = <&led_pwr>,"linux,default-trigger";
};
};

View File

@@ -0,0 +1,215 @@
/dts-v1/;
#include "bcm2709.dtsi"
#include "bcm2709-rpi.dtsi"
#include "bcm283x-rpi-csi0-2lane.dtsi"
#include "bcm283x-rpi-csi1-4lane.dtsi"
#include "bcm283x-rpi-i2c0mux_0_28.dtsi"
#include "bcm283x-rpi-led-deprecated.dtsi"
/ {
compatible = "raspberrypi,2-compute-module", "brcm,bcm2836";
model = "Raspberry Pi Compute Module 2";
};
&cam1_reg {
gpio = <&gpio 2 GPIO_ACTIVE_HIGH>;
status = "disabled";
};
cam0_reg: &cam0_regulator {
gpio = <&gpio 30 GPIO_ACTIVE_HIGH>;
};
i2c_csi_dsi0: &i2c0 {
};
&uart0 {
status = "okay";
};
&gpio {
/*
* This is based on the official GPU firmware DT blob.
*
* Legend:
* "NC" = not connected (no rail from the SoC)
* "FOO" = GPIO line named "FOO" on the schematic
* "FOO_N" = GPIO line named "FOO" on schematic, active low
*/
gpio-line-names = "GPIO0",
"GPIO1",
"GPIO2",
"GPIO3",
"GPIO4",
"GPIO5",
"GPIO6",
"GPIO7",
"GPIO8",
"GPIO9",
"GPIO10",
"GPIO11",
"GPIO12",
"GPIO13",
"GPIO14",
"GPIO15",
"GPIO16",
"GPIO17",
"GPIO18",
"GPIO19",
"GPIO20",
"GPIO21",
"GPIO22",
"GPIO23",
"GPIO24",
"GPIO25",
"GPIO26",
"GPIO27",
"GPIO28",
"GPIO29",
"GPIO30",
"GPIO31",
"GPIO32",
"GPIO33",
"GPIO34",
"GPIO35",
"GPIO36",
"GPIO37",
"GPIO38",
"GPIO39",
"GPIO40",
"GPIO41",
"GPIO42",
"GPIO43",
"GPIO44",
"GPIO45",
"SMPS_SCL",
"SMPS_SDA",
/* Used by eMMC */
"SD_CLK_R",
"SD_CMD_R",
"SD_DATA0_R",
"SD_DATA1_R",
"SD_DATA2_R",
"SD_DATA3_R";
spi0_pins: spi0_pins {
brcm,pins = <9 10 11>;
brcm,function = <4>; /* alt0 */
};
spi0_cs_pins: spi0_cs_pins {
brcm,pins = <8 7>;
brcm,function = <1>; /* output */
};
i2c0_pins: i2c0 {
brcm,pins = <0 1>;
brcm,function = <4>;
};
i2c1_pins: i2c1 {
brcm,pins = <2 3>;
brcm,function = <4>;
};
i2s_pins: i2s {
brcm,pins = <18 19 20 21>;
brcm,function = <4>; /* alt0 */
};
audio_pins: audio_pins {
brcm,pins;
brcm,function;
};
};
&firmware {
expgpio: expgpio {
compatible = "raspberrypi,firmware-gpio";
gpio-controller;
#gpio-cells = <2>;
gpio-line-names = "HDMI_HPD_N",
"EMMC_EN_N",
"NC",
"NC",
"NC",
"NC",
"NC",
"NC";
status = "okay";
};
virtgpio: virtgpio {
compatible = "brcm,bcm2835-virtgpio";
gpio-controller;
#gpio-cells = <2>;
status = "okay";
};
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
spidev0: spidev@0{
compatible = "spidev";
reg = <0>; /* CE0 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
spidev1: spidev@1{
compatible = "spidev";
reg = <1>; /* CE1 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
};
&i2c0if {
clock-frequency = <100000>;
};
&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&i2c1_pins>;
clock-frequency = <100000>;
};
&i2c2 {
clock-frequency = <100000>;
};
&i2s {
pinctrl-names = "default";
pinctrl-0 = <&i2s_pins>;
};
&led_act {
gpios = <&virtgpio 0 GPIO_ACTIVE_HIGH>;
default-state = "off";
linux,default-trigger = "mmc0";
};
&hdmi {
hpd-gpios = <&expgpio 0 GPIO_ACTIVE_LOW>;
};
&vchiq {
pinctrl-names = "default";
pinctrl-0 = <&audio_pins>;
};
/ {
__overrides__ {
audio = <&chosen>,"bootargs{on='snd_bcm2835.enable_hdmi=1',off='snd_bcm2835.enable_hdmi=0'}";
act_led_gpio = <&led_act>,"gpios:4";
act_led_activelow = <&led_act>,"gpios:8";
act_led_trigger = <&led_act>,"linux,default-trigger";
};
};

View File

@@ -0,0 +1,8 @@
#include "bcm2708-rpi.dtsi"
&vchiq {
compatible = "brcm,bcm2836-vchiq", "brcm,bcm2835-vchiq";
};
i2c_arm: &i2c1 {};
i2c_vc: &i2c0 {};

View File

@@ -0,0 +1,29 @@
#define i2c0 i2c0if
#include "bcm2836.dtsi"
#undef i2c0
#include "bcm270x.dtsi"
/ {
soc {
ranges = <0x7e000000 0x3f000000 0x01000000>,
<0x40000000 0x40000000 0x00040000>;
dma-ranges = <0xc0000000 0x00000000 0x3f000000>,
<0x7e000000 0x3f000000 0x01000000>;
};
__overrides__ {
arm_freq = <&v7_cpu0>, "clock-frequency:0",
<&v7_cpu1>, "clock-frequency:0",
<&v7_cpu2>, "clock-frequency:0",
<&v7_cpu3>, "clock-frequency:0";
};
};
&system_timer {
status = "disabled";
};
&vc4 {
status = "disabled";
};

View File

@@ -0,0 +1,201 @@
/* Downstream modifications to bcm2835-rpi.dtsi */
/ {
aliases: aliases {
aux = &aux;
sound = &sound;
soc = &soc;
dma = &dma;
intc = &intc;
watchdog = &watchdog;
random = &random;
mailbox = &mailbox;
gpio = &gpio;
uart0 = &uart0;
uart1 = &uart1;
sdhost = &sdhost;
mmc = &mmc;
mmc1 = &mmc;
mmc0 = &sdhost;
i2s = &i2s;
i2c0 = &i2c0;
i2c1 = &i2c1;
i2c10 = &i2c_csi_dsi;
i2c = &i2c_arm;
spi0 = &spi0;
spi1 = &spi1;
spi2 = &spi2;
usb = &usb;
leds = &leds;
fb = &fb;
thermal = &thermal;
axiperf = &axiperf;
};
/* Define these notional regulators for use by overlays */
vdd_3v3_reg: fixedregulator_3v3 {
compatible = "regulator-fixed";
regulator-always-on;
regulator-max-microvolt = <3300000>;
regulator-min-microvolt = <3300000>;
regulator-name = "3v3";
};
vdd_5v0_reg: fixedregulator_5v0 {
compatible = "regulator-fixed";
regulator-always-on;
regulator-max-microvolt = <5000000>;
regulator-min-microvolt = <5000000>;
regulator-name = "5v0";
};
soc {
gpiomem {
compatible = "brcm,bcm2835-gpiomem";
reg = <0x7e200000 0x1000>;
};
fb: fb {
compatible = "brcm,bcm2708-fb";
firmware = <&firmware>;
status = "okay";
};
/* External sound card */
sound: sound {
status = "disabled";
};
};
__overrides__ {
cache_line_size;
uart0 = <&uart0>,"status";
uart1 = <&uart1>,"status";
i2s = <&i2s>,"status";
spi = <&spi0>,"status";
i2c0 = <&i2c0if>,"status",<&i2c0mux>,"status";
i2c1 = <&i2c1>,"status";
i2c = <&i2c1>,"status";
i2c_arm = <&i2c1>,"status";
i2c_vc = <&i2c0if>,"status",<&i2c0mux>,"status";
i2c0_baudrate = <&i2c0if>,"clock-frequency:0";
i2c1_baudrate = <&i2c1>,"clock-frequency:0";
i2c_baudrate = <&i2c1>,"clock-frequency:0";
i2c_arm_baudrate = <&i2c1>,"clock-frequency:0";
i2c_vc_baudrate = <&i2c0if>,"clock-frequency:0";
watchdog = <&watchdog>,"status";
random = <&random>,"status";
sd_overclock = <&sdhost>,"brcm,overclock-50:0";
sd_force_pio = <&sdhost>,"brcm,force-pio?";
sd_pio_limit = <&sdhost>,"brcm,pio-limit:0";
sd_debug = <&sdhost>,"brcm,debug";
sdio_overclock = <&mmc>,"brcm,overclock-50:0",
<&mmcnr>,"brcm,overclock-50:0";
axiperf = <&axiperf>,"status";
drm_fb0_vc4 = <&aliases>, "drm-fb0=",&vc4;
drm_fb1_vc4 = <&aliases>, "drm-fb1=",&vc4;
drm_fb2_vc4 = <&aliases>, "drm-fb2=",&vc4;
cam1_sync = <&csi1>, "sync-gpios:0=", <&gpio>,
<&csi1>, "sync-gpios:4",
<&csi1>, "sync-gpios:8=", <GPIO_ACTIVE_HIGH>;
cam1_sync_inverted = <&csi1>, "sync-gpios:0=", <&gpio>,
<&csi1>, "sync-gpios:4",
<&csi1>, "sync-gpios:8=", <GPIO_ACTIVE_LOW>;
cam0_sync = <&csi0>, "sync-gpios:0=", <&gpio>,
<&csi0>, "sync-gpios:4",
<&csi0>, "sync-gpios:8=", <GPIO_ACTIVE_HIGH>;
cam0_sync_inverted = <&csi0>, "sync-gpios:0=", <&gpio>,
<&csi0>, "sync-gpios:4",
<&csi0>, "sync-gpios:8=", <GPIO_ACTIVE_LOW>;
cam0_reg = <&cam0_reg>,"status";
cam0_reg_gpio = <&cam0_reg>,"gpio:4",
<&cam0_reg>,"gpio:0=", <&gpio>;
cam1_reg = <&cam1_reg>,"status";
cam1_reg_gpio = <&cam1_reg>,"gpio:4",
<&cam1_reg>,"gpio:0=", <&gpio>;
strict_gpiod = <&chosen>, "bootargs=pinctrl_bcm2835.persist_gpio_outputs=n";
};
};
&uart0 {
skip-init;
};
&uart1 {
skip-init;
};
&txp {
status = "disabled";
};
&i2c0if {
status = "disabled";
};
&i2c0mux {
pinctrl-names = "i2c0", "i2c_csi_dsi";
/delete-property/ clock-frequency;
status = "disabled";
};
&i2c1 {
status = "disabled";
};
i2s_clk_producer: &i2s {};
i2s_clk_consumer: &i2s {};
&clocks {
firmware = <&firmware>;
};
&sdhci {
pinctrl-names = "default";
pinctrl-0 = <&emmc_gpio48>;
bus-width = <4>;
};
&cpu_thermal {
// Add some labels
thermal_trips: trips {
cpu-crit {
// Raise upstream limit of 90C
temperature = <110000>;
};
};
cooling_maps: cooling-maps {
};
};
&vec {
clocks = <&firmware_clocks 15>;
status = "disabled";
};
&firmware {
vcio: vcio {
compatible = "raspberrypi,vcio";
};
};
&vc4 {
raspberrypi,firmware = <&firmware>;
};
#ifndef BCM2711
&hdmi {
reg-names = "hdmi",
"hd";
clocks = <&firmware_clocks 9>,
<&firmware_clocks 13>;
dmas = <&dma (17|(1<<27)|(1<<24))>;
};
#endif

View File

@@ -0,0 +1,264 @@
/* Downstream bcm283x.dtsi diff */
#include <dt-bindings/power/raspberrypi-power.h>
/ {
chosen: chosen {
// Disable audio by default
bootargs = "coherent_pool=1M snd_bcm2835.enable_headphones=0";
stdout-path = "serial0:115200n8";
};
soc: soc {
watchdog: watchdog@7e100000 {
/* Add label */
};
random: rng@7e104000 {
/* Add label */
};
spi0: spi@7e204000 {
/* Add label */
};
#ifndef BCM2711
pixelvalve0: pixelvalve@7e206000 {
/* Add label */
status = "disabled";
};
pixelvalve1: pixelvalve@7e207000 {
/* Add label */
status = "disabled";
};
#endif
/delete-node/ mmc@7e300000;
sdhci: mmc: mmc@7e300000 {
compatible = "brcm,bcm2835-mmc", "brcm,bcm2835-sdhci";
reg = <0x7e300000 0x100>;
interrupts = <2 30>;
clocks = <&clocks BCM2835_CLOCK_EMMC>;
dmas = <&dma 11>;
dma-names = "rx-tx";
brcm,overclock-50 = <0>;
status = "disabled";
};
/* A clone of mmc but with non-removable set */
mmcnr: mmcnr@7e300000 {
compatible = "brcm,bcm2835-mmc", "brcm,bcm2835-sdhci";
reg = <0x7e300000 0x100>;
interrupts = <2 30>;
clocks = <&clocks BCM2835_CLOCK_EMMC>;
dmas = <&dma 11>;
dma-names = "rx-tx";
brcm,overclock-50 = <0>;
non-removable;
status = "disabled";
};
hvs: hvs@7e400000 {
/* Add label */
status = "disabled";
};
firmwarekms: firmwarekms@7e600000 {
compatible = "raspberrypi,rpi-firmware-kms";
/* SMI interrupt reg */
reg = <0x7e600000 0x100>;
interrupts = <2 16>;
brcm,firmware = <&firmware>;
status = "disabled";
};
smi: smi@7e600000 {
compatible = "brcm,bcm2835-smi";
reg = <0x7e600000 0x100>;
interrupts = <2 16>;
clocks = <&clocks BCM2835_CLOCK_SMI>;
assigned-clocks = <&clocks BCM2835_CLOCK_SMI>;
assigned-clock-rates = <125000000>;
dmas = <&dma 4>;
dma-names = "rx-tx";
status = "disabled";
};
#ifndef BCM2711
pixelvalve2: pixelvalve@7e807000 {
/* Add label */
status = "disabled";
};
#endif
hdmi@7e902000 { /* hdmi */
status = "disabled";
};
usb@7e980000 { /* usb */
compatible = "brcm,bcm2708-usb";
reg = <0x7e980000 0x10000>,
<0x7e006000 0x1000>;
interrupt-names = "usb",
"soft";
interrupts = <1 9>,
<2 0>;
};
#ifndef BCM2711
v3d@7ec00000 { /* vd3 */
compatible = "brcm,vc4-v3d";
power-domains = <&power RPI_POWER_DOMAIN_V3D>;
status = "disabled";
};
#endif
axiperf: axiperf {
compatible = "brcm,bcm2835-axiperf";
reg = <0x7e009800 0x100>,
<0x7ee08000 0x100>;
firmware = <&firmware>;
status = "disabled";
};
i2c0mux: i2c0mux {
compatible = "i2c-mux-pinctrl";
#address-cells = <1>;
#size-cells = <0>;
i2c-parent = <&i2c0if>;
status = "disabled";
i2c0: i2c@0 {
reg = <0>;
#address-cells = <1>;
#size-cells = <0>;
};
i2c_csi_dsi: i2c@1 {
reg = <1>;
#address-cells = <1>;
#size-cells = <0>;
};
};
};
cam1_reg: cam1_regulator {
compatible = "regulator-fixed";
regulator-name = "cam1-reg";
enable-active-high;
/* Needs to be enabled, as removing a regulator is very unsafe */
status = "okay";
};
cam1_clk: cam1_clk {
compatible = "fixed-clock";
#clock-cells = <0>;
status = "disabled";
};
cam0_regulator: cam0_regulator {
compatible = "regulator-fixed";
regulator-name = "cam0-reg";
enable-active-high;
status = "disabled";
};
cam0_clk: cam0_clk {
compatible = "fixed-clock";
#clock-cells = <0>;
status = "disabled";
};
cam_dummy_reg: cam_dummy_reg {
compatible = "regulator-fixed";
regulator-name = "cam-dummy-reg";
status = "okay";
};
__overrides__ {
cam0-pwdn-ctrl;
cam0-pwdn;
cam0-led-ctrl;
cam0-led;
};
};
&gpio {
interrupts = <2 17>, <2 18>;
dpi_18bit_cpadhi_gpio0: dpi_18bit_cpadhi_gpio0 {
brcm,pins = <0 1 2 3 4 5 6 7 8 9
12 13 14 15 16 17
20 21 22 23 24 25>;
brcm,function = <BCM2835_FSEL_ALT2>;
brcm,pull = <0>; /* no pull */
};
dpi_18bit_cpadhi_gpio2: dpi_18bit_cpadhi_gpio2 {
brcm,pins = <2 3 4 5 6 7 8 9
12 13 14 15 16 17
20 21 22 23 24 25>;
brcm,function = <BCM2835_FSEL_ALT2>;
};
dpi_18bit_gpio0: dpi_18bit_gpio0 {
brcm,pins = <0 1 2 3 4 5 6 7 8 9 10 11
12 13 14 15 16 17 18 19
20 21>;
brcm,function = <BCM2835_FSEL_ALT2>;
};
dpi_18bit_gpio2: dpi_18bit_gpio2 {
brcm,pins = <2 3 4 5 6 7 8 9 10 11
12 13 14 15 16 17 18 19
20 21>;
brcm,function = <BCM2835_FSEL_ALT2>;
};
dpi_16bit_gpio0: dpi_16bit_gpio0 {
brcm,pins = <0 1 2 3 4 5 6 7 8 9 10 11
12 13 14 15 16 17 18 19>;
brcm,function = <BCM2835_FSEL_ALT2>;
};
dpi_16bit_gpio2: dpi_16bit_gpio2 {
brcm,pins = <2 3 4 5 6 7 8 9 10 11
12 13 14 15 16 17 18 19>;
brcm,function = <BCM2835_FSEL_ALT2>;
};
dpi_16bit_cpadhi_gpio0: dpi_16bit_cpadhi_gpio0 {
brcm,pins = <0 1 2 3 4 5 6 7 8
12 13 14 15 16 17
20 21 22 23 24>;
brcm,function = <BCM2835_FSEL_ALT2>;
};
dpi_16bit_cpadhi_gpio2: dpi_16bit_cpadhi_gpio2 {
brcm,pins = <2 3 4 5 6 7 8
12 13 14 15 16 17
20 21 22 23 24>;
brcm,function = <BCM2835_FSEL_ALT2>;
};
};
&uart0 {
/* Enable CTS bug workaround */
cts-event-workaround;
};
&i2s {
#sound-dai-cells = <0>;
dmas = <&dma 2>, <&dma 3>;
dma-names = "tx", "rx";
};
&sdhost {
dmas = <&dma (13|(1<<29))>;
dma-names = "rx-tx";
bus-width = <4>;
brcm,overclock-50 = <0>;
brcm,pio-limit = <1>;
firmware = <&firmware>;
};
&spi0 {
dmas = <&dma 6>, <&dma 7>;
dma-names = "tx", "rx";
};

View File

@@ -0,0 +1,204 @@
/dts-v1/;
#include "bcm2710.dtsi"
#include "bcm2709-rpi.dtsi"
#include "bcm283x-rpi-smsc9514.dtsi"
#include "bcm283x-rpi-csi1-2lane.dtsi"
#include "bcm283x-rpi-i2c0mux_0_28.dtsi"
#include "bcm283x-rpi-led-deprecated.dtsi"
/ {
compatible = "raspberrypi,2-model-b-rev2", "brcm,bcm2837";
model = "Raspberry Pi 2 Model B rev 1.2";
};
&gpio {
/*
* Taken from rpi_SCH_2b_1p2_reduced.pdf and
* the official GPU firmware DT blob.
*
* Legend:
* "NC" = not connected (no rail from the SoC)
* "FOO" = GPIO line named "FOO" on the schematic
* "FOO_N" = GPIO line named "FOO" on schematic, active low
*/
gpio-line-names = "ID_SDA",
"ID_SCL",
"GPIO2",
"GPIO3",
"GPIO4",
"GPIO5",
"GPIO6",
"GPIO7",
"GPIO8",
"GPIO9",
"GPIO10",
"GPIO11",
"GPIO12",
"GPIO13",
"GPIO14",
"GPIO15",
"GPIO16",
"GPIO17",
"GPIO18",
"GPIO19",
"GPIO20",
"GPIO21",
"GPIO22",
"GPIO23",
"GPIO24",
"GPIO25",
"GPIO26",
"GPIO27",
"SDA0",
"SCL0",
"NC", /* GPIO30 */
"LAN_RUN",
"CAM_GPIO1",
"NC", /* GPIO33 */
"NC", /* GPIO34 */
"PWR_LOW_N",
"NC", /* GPIO36 */
"NC", /* GPIO37 */
"USB_LIMIT",
"NC", /* GPIO39 */
"PWM0_OUT",
"CAM_GPIO0",
"SMPS_SCL",
"SMPS_SDA",
"ETH_CLK",
"PWM1_OUT",
"HDMI_HPD_N",
"STATUS_LED",
/* Used by SD Card */
"SD_CLK_R",
"SD_CMD_R",
"SD_DATA0_R",
"SD_DATA1_R",
"SD_DATA2_R",
"SD_DATA3_R";
spi0_pins: spi0_pins {
brcm,pins = <9 10 11>;
brcm,function = <4>; /* alt0 */
};
spi0_cs_pins: spi0_cs_pins {
brcm,pins = <8 7>;
brcm,function = <1>; /* output */
};
i2c0_pins: i2c0 {
brcm,pins = <0 1>;
brcm,function = <4>;
};
i2c1_pins: i2c1 {
brcm,pins = <2 3>;
brcm,function = <4>;
};
i2s_pins: i2s {
brcm,pins = <18 19 20 21>;
brcm,function = <4>; /* alt0 */
};
audio_pins: audio_pins {
brcm,pins = <40 45>;
brcm,function = <4>;
brcm,pull = <0>;
};
};
&uart0 {
status = "okay";
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
spidev0: spidev@0{
compatible = "spidev";
reg = <0>; /* CE0 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
spidev1: spidev@1{
compatible = "spidev";
reg = <1>; /* CE1 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
};
&i2c0if {
clock-frequency = <100000>;
};
&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&i2c1_pins>;
clock-frequency = <100000>;
};
&i2c2 {
clock-frequency = <100000>;
};
&i2s {
pinctrl-names = "default";
pinctrl-0 = <&i2s_pins>;
};
&led_act {
gpios = <&gpio 47 GPIO_ACTIVE_HIGH>;
default-state = "off";
linux,default-trigger = "mmc0";
};
&leds {
led_pwr: led-pwr {
label = "PWR";
gpios = <&gpio 35 GPIO_ACTIVE_HIGH>;
default-state = "off";
linux,default-trigger = "input";
};
};
&hdmi {
hpd-gpios = <&gpio 46 GPIO_ACTIVE_LOW>;
};
&vchiq {
pinctrl-names = "default";
pinctrl-0 = <&audio_pins>;
};
&cam1_reg {
gpio = <&gpio 41 GPIO_ACTIVE_HIGH>;
};
cam0_reg: &cam_dummy_reg {
};
i2c_csi_dsi0: &i2c0 {
};
/ {
__overrides__ {
audio = <&chosen>,"bootargs{on='snd_bcm2835.enable_headphones=1 snd_bcm2835.enable_hdmi=1',off='snd_bcm2835.enable_headphones=0 snd_bcm2835.enable_hdmi=0'}";
act_led_gpio = <&led_act>,"gpios:4";
act_led_activelow = <&led_act>,"gpios:8";
act_led_trigger = <&led_act>,"linux,default-trigger";
pwr_led_gpio = <&led_pwr>,"gpios:4";
pwr_led_activelow = <&led_pwr>,"gpios:8";
pwr_led_trigger = <&led_pwr>,"linux,default-trigger";
};
};

View File

@@ -0,0 +1,299 @@
/dts-v1/;
#include "bcm2710.dtsi"
#include "bcm2709-rpi.dtsi"
#include "bcm283x-rpi-lan7515.dtsi"
#include "bcm283x-rpi-csi1-2lane.dtsi"
#include "bcm283x-rpi-i2c0mux_0_44.dtsi"
#include "bcm271x-rpi-bt.dtsi"
#include "bcm283x-rpi-led-deprecated.dtsi"
/ {
compatible = "raspberrypi,3-model-b-plus", "brcm,bcm2837";
model = "Raspberry Pi 3 Model B+";
chosen {
bootargs = "coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_headphones=0";
};
aliases {
serial0 = &uart1;
serial1 = &uart0;
mmc1 = &mmcnr;
};
};
&gpio {
/*
* Taken from rpi_SCH_3bplus_1p0_reduced.pdf and
* the official GPU firmware DT blob.
*
* Legend:
* "NC" = not connected (no rail from the SoC)
* "FOO" = GPIO line named "FOO" on the schematic
* "FOO_N" = GPIO line named "FOO" on schematic, active low
*/
gpio-line-names = "ID_SDA",
"ID_SCL",
"GPIO2",
"GPIO3",
"GPIO4",
"GPIO5",
"GPIO6",
"GPIO7",
"GPIO8",
"GPIO9",
"GPIO10",
"GPIO11",
"GPIO12",
"GPIO13",
"GPIO14",
"GPIO15",
"GPIO16",
"GPIO17",
"GPIO18",
"GPIO19",
"GPIO20",
"GPIO21",
"GPIO22",
"GPIO23",
"GPIO24",
"GPIO25",
"GPIO26",
"GPIO27",
"HDMI_HPD_N",
"STATUS_LED_G",
/* Used by BT module */
"CTS0",
"RTS0",
"TXD0",
"RXD0",
/* Used by Wifi */
"SD1_CLK",
"SD1_CMD",
"SD1_DATA0",
"SD1_DATA1",
"SD1_DATA2",
"SD1_DATA3",
"PWM0_OUT",
"PWM1_OUT",
"ETH_CLK",
"WIFI_CLK",
"SDA0",
"SCL0",
"SMPS_SCL",
"SMPS_SDA",
/* Used by SD Card */
"SD_CLK_R",
"SD_CMD_R",
"SD_DATA0_R",
"SD_DATA1_R",
"SD_DATA2_R",
"SD_DATA3_R";
spi0_pins: spi0_pins {
brcm,pins = <9 10 11>;
brcm,function = <4>; /* alt0 */
};
spi0_cs_pins: spi0_cs_pins {
brcm,pins = <8 7>;
brcm,function = <1>; /* output */
};
i2c0_pins: i2c0 {
brcm,pins = <0 1>;
brcm,function = <4>;
};
i2c1_pins: i2c1 {
brcm,pins = <2 3>;
brcm,function = <4>;
};
i2s_pins: i2s {
brcm,pins = <18 19 20 21>;
brcm,function = <4>; /* alt0 */
};
sdio_pins: sdio_pins {
brcm,pins = <34 35 36 37 38 39>;
brcm,function = <7>; // alt3 = SD1
brcm,pull = <0 2 2 2 2 2>;
};
bt_pins: bt_pins {
brcm,pins = <43>;
brcm,function = <4>; /* alt0:GPCLK2 */
brcm,pull = <0>;
};
uart0_pins: uart0_pins {
brcm,pins = <32 33>;
brcm,function = <7>; /* alt3=UART0 */
brcm,pull = <0 2>;
};
uart1_pins: uart1_pins {
brcm,pins;
brcm,function;
brcm,pull;
};
uart1_bt_pins: uart1_bt_pins {
brcm,pins = <32 33 30 31>;
brcm,function = <BCM2835_FSEL_ALT5>; /* alt5=UART1 */
brcm,pull = <0 2 2 0>;
};
audio_pins: audio_pins {
brcm,pins = <40 41>;
brcm,function = <4>;
brcm,pull = <0>;
};
};
&mmcnr {
pinctrl-names = "default";
pinctrl-0 = <&sdio_pins>;
bus-width = <4>;
status = "okay";
#address-cells = <1>;
#size-cells = <0>;
brcmf: wifi@1 {
reg = <1>;
compatible = "brcm,bcm4329-fmac";
};
};
&firmware {
expgpio: expgpio {
compatible = "raspberrypi,firmware-gpio";
gpio-controller;
#gpio-cells = <2>;
gpio-line-names = "BT_ON",
"WL_ON",
"PWR_LED_R",
"LAN_RUN",
"NC",
"CAM_GPIO0",
"CAM_GPIO1",
"NC";
status = "okay";
};
};
&uart0 {
pinctrl-names = "default";
pinctrl-0 = <&uart0_pins &bt_pins>;
status = "okay";
};
&uart1 {
pinctrl-names = "default";
pinctrl-0 = <&uart1_pins>;
status = "okay";
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
spidev0: spidev@0{
compatible = "spidev";
reg = <0>; /* CE0 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
spidev1: spidev@1{
compatible = "spidev";
reg = <1>; /* CE1 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
};
&i2c0if {
clock-frequency = <100000>;
};
&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&i2c1_pins>;
clock-frequency = <100000>;
};
&i2c2 {
clock-frequency = <100000>;
};
&i2s {
pinctrl-names = "default";
pinctrl-0 = <&i2s_pins>;
};
&led_act {
gpios = <&gpio 29 GPIO_ACTIVE_HIGH>;
default-state = "off";
linux,default-trigger = "mmc0";
};
&leds {
led_pwr: led-pwr {
label = "PWR";
gpios = <&expgpio 2 GPIO_ACTIVE_LOW>;
default-state = "off";
linux,default-trigger = "default-on";
};
};
&hdmi {
hpd-gpios = <&gpio 28 GPIO_ACTIVE_LOW>;
};
&vchiq {
pinctrl-names = "default";
pinctrl-0 = <&audio_pins>;
};
&eth_phy {
microchip,eee-enabled;
microchip,tx-lpi-timer = <600>; /* non-aggressive*/
microchip,downshift-after = <2>;
};
&cam1_reg {
gpio = <&expgpio 5 GPIO_ACTIVE_HIGH>;
};
cam0_reg: &cam_dummy_reg {
};
i2c_csi_dsi0: &i2c0 {
};
/ {
__overrides__ {
audio = <&chosen>,"bootargs{on='snd_bcm2835.enable_headphones=1 snd_bcm2835.enable_hdmi=1',off='snd_bcm2835.enable_headphones=0 snd_bcm2835.enable_hdmi=0'}";
act_led_gpio = <&led_act>,"gpios:4";
act_led_activelow = <&led_act>,"gpios:8";
act_led_trigger = <&led_act>,"linux,default-trigger";
pwr_led_gpio = <&led_pwr>,"gpios:4";
pwr_led_activelow = <&led_pwr>,"gpios:8";
pwr_led_trigger = <&led_pwr>,"linux,default-trigger";
eee = <&eth_phy>,"microchip,eee-enabled?";
tx_lpi_timer = <&eth_phy>,"microchip,tx-lpi-timer:0";
eth_led0 = <&eth_phy>,"microchip,led-modes:0";
eth_led1 = <&eth_phy>,"microchip,led-modes:4";
eth_downshift_after = <&eth_phy>,"microchip,downshift-after:0";
eth_max_speed = <&eth_phy>,"max-speed:0";
};
};

View File

@@ -0,0 +1,297 @@
/dts-v1/;
#include "bcm2710.dtsi"
#include "bcm2709-rpi.dtsi"
#include "bcm283x-rpi-smsc9514.dtsi"
#include "bcm283x-rpi-csi1-2lane.dtsi"
#include "bcm283x-rpi-i2c0mux_0_44.dtsi"
#include "bcm271x-rpi-bt.dtsi"
#include "bcm283x-rpi-led-deprecated.dtsi"
/ {
compatible = "raspberrypi,3-model-b", "brcm,bcm2837";
model = "Raspberry Pi 3 Model B";
chosen {
bootargs = "coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_headphones=0";
};
aliases {
serial0 = &uart1;
serial1 = &uart0;
mmc1 = &mmcnr;
};
};
&gpio {
/*
* Taken from rpi_SCH_3b_1p2_reduced.pdf and
* the official GPU firmware DT blob.
*
* Legend:
* "NC" = not connected (no rail from the SoC)
* "FOO" = GPIO line named "FOO" on the schematic
* "FOO_N" = GPIO line named "FOO" on schematic, active low
*/
gpio-line-names = "ID_SDA",
"ID_SCL",
"GPIO2",
"GPIO3",
"GPIO4",
"GPIO5",
"GPIO6",
"GPIO7",
"GPIO8",
"GPIO9",
"GPIO10",
"GPIO11",
"GPIO12",
"GPIO13",
"GPIO14",
"GPIO15",
"GPIO16",
"GPIO17",
"GPIO18",
"GPIO19",
"GPIO20",
"GPIO21",
"GPIO22",
"GPIO23",
"GPIO24",
"GPIO25",
"GPIO26",
"GPIO27",
"NC", /* GPIO 28 */
"LAN_RUN_BOOT",
/* Used by BT module */
"CTS0",
"RTS0",
"TXD0",
"RXD0",
/* Used by Wifi */
"SD1_CLK",
"SD1_CMD",
"SD1_DATA0",
"SD1_DATA1",
"SD1_DATA2",
"SD1_DATA3",
"PWM0_OUT",
"PWM1_OUT",
"ETH_CLK",
"WIFI_CLK",
"SDA0",
"SCL0",
"SMPS_SCL",
"SMPS_SDA",
/* Used by SD Card */
"SD_CLK_R",
"SD_CMD_R",
"SD_DATA0_R",
"SD_DATA1_R",
"SD_DATA2_R",
"SD_DATA3_R";
spi0_pins: spi0_pins {
brcm,pins = <9 10 11>;
brcm,function = <4>; /* alt0 */
};
spi0_cs_pins: spi0_cs_pins {
brcm,pins = <8 7>;
brcm,function = <1>; /* output */
};
i2c0_pins: i2c0 {
brcm,pins = <0 1>;
brcm,function = <4>;
};
i2c1_pins: i2c1 {
brcm,pins = <2 3>;
brcm,function = <4>;
};
i2s_pins: i2s {
brcm,pins = <18 19 20 21>;
brcm,function = <4>; /* alt0 */
};
sdio_pins: sdio_pins {
brcm,pins = <34 35 36 37 38 39>;
brcm,function = <7>; // alt3 = SD1
brcm,pull = <0 2 2 2 2 2>;
};
bt_pins: bt_pins {
brcm,pins = <43>;
brcm,function = <4>; /* alt0:GPCLK2 */
brcm,pull = <0>;
};
uart0_pins: uart0_pins {
brcm,pins = <32 33>;
brcm,function = <7>; /* alt3=UART0 */
brcm,pull = <0 2>;
};
uart1_pins: uart1_pins {
brcm,pins;
brcm,function;
brcm,pull;
};
uart1_bt_pins: uart1_bt_pins {
brcm,pins = <32 33>;
brcm,function = <BCM2835_FSEL_ALT5>; /* alt5=UART1 */
brcm,pull = <0 2>;
};
audio_pins: audio_pins {
brcm,pins = <40 41>;
brcm,function = <4>;
brcm,pull = <0>;
};
};
&mmcnr {
pinctrl-names = "default";
pinctrl-0 = <&sdio_pins>;
bus-width = <4>;
status = "okay";
#address-cells = <1>;
#size-cells = <0>;
brcmf: wifi@1 {
reg = <1>;
compatible = "brcm,bcm4329-fmac";
};
};
&firmware {
expgpio: expgpio {
compatible = "raspberrypi,firmware-gpio";
gpio-controller;
#gpio-cells = <2>;
gpio-line-names = "BT_ON",
"WL_ON",
"STATUS_LED",
"LAN_RUN",
"HDMI_HPD_N",
"CAM_GPIO0",
"CAM_GPIO1",
"PWR_LOW_N";
status = "okay";
};
virtgpio: virtgpio {
compatible = "brcm,bcm2835-virtgpio";
gpio-controller;
#gpio-cells = <2>;
status = "okay";
};
};
&uart0 {
pinctrl-names = "default";
pinctrl-0 = <&uart0_pins &bt_pins>;
status = "okay";
};
&uart1 {
pinctrl-names = "default";
pinctrl-0 = <&uart1_pins>;
status = "okay";
};
&bt {
max-speed = <921600>;
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
spidev0: spidev@0{
compatible = "spidev";
reg = <0>; /* CE0 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
spidev1: spidev@1{
compatible = "spidev";
reg = <1>; /* CE1 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
};
&i2c0if {
clock-frequency = <100000>;
};
&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&i2c1_pins>;
clock-frequency = <100000>;
};
&i2c2 {
clock-frequency = <100000>;
};
&i2s {
pinctrl-names = "default";
pinctrl-0 = <&i2s_pins>;
};
&led_act {
gpios = <&virtgpio 0 GPIO_ACTIVE_HIGH>;
default-state = "off";
linux,default-trigger = "mmc0";
};
&leds {
led_pwr: led-pwr {
label = "PWR";
gpios = <&expgpio 7 GPIO_ACTIVE_HIGH>;
default-state = "off";
linux,default-trigger = "input";
};
};
&hdmi {
hpd-gpios = <&expgpio 4 GPIO_ACTIVE_LOW>;
};
&vchiq {
pinctrl-names = "default";
pinctrl-0 = <&audio_pins>;
};
&cam1_reg {
gpio = <&expgpio 5 GPIO_ACTIVE_HIGH>;
};
cam0_reg: &cam_dummy_reg {
};
i2c_csi_dsi0: &i2c0 {
};
/ {
__overrides__ {
audio = <&chosen>,"bootargs{on='snd_bcm2835.enable_headphones=1 snd_bcm2835.enable_hdmi=1',off='snd_bcm2835.enable_headphones=0 snd_bcm2835.enable_hdmi=0'}";
act_led_gpio = <&led_act>,"gpios:4";
act_led_activelow = <&led_act>,"gpios:8";
act_led_trigger = <&led_act>,"linux,default-trigger";
pwr_led_gpio = <&led_pwr>,"gpios:4";
pwr_led_activelow = <&led_pwr>,"gpios:8";
pwr_led_trigger = <&led_pwr>,"linux,default-trigger";
};
};

View File

@@ -0,0 +1,215 @@
/dts-v1/;
#include "bcm2710.dtsi"
#include "bcm2709-rpi.dtsi"
#include "bcm283x-rpi-csi0-2lane.dtsi"
#include "bcm283x-rpi-csi1-4lane.dtsi"
#include "bcm283x-rpi-i2c0mux_0_28.dtsi"
#include "bcm283x-rpi-led-deprecated.dtsi"
/ {
compatible = "raspberrypi,3-compute-module", "brcm,bcm2837";
model = "Raspberry Pi Compute Module 3";
};
&cam1_reg {
gpio = <&gpio 3 GPIO_ACTIVE_HIGH>;
status = "disabled";
};
cam0_reg: &cam0_regulator {
gpio = <&gpio 31 GPIO_ACTIVE_HIGH>;
};
i2c_csi_dsi0: &i2c0 {
};
&uart0 {
status = "okay";
};
&gpio {
/*
* This is based on the official GPU firmware DT blob.
*
* Legend:
* "NC" = not connected (no rail from the SoC)
* "FOO" = GPIO line named "FOO" on the schematic
* "FOO_N" = GPIO line named "FOO" on schematic, active low
*/
gpio-line-names = "GPIO0",
"GPIO1",
"GPIO2",
"GPIO3",
"GPIO4",
"GPIO5",
"GPIO6",
"GPIO7",
"GPIO8",
"GPIO9",
"GPIO10",
"GPIO11",
"GPIO12",
"GPIO13",
"GPIO14",
"GPIO15",
"GPIO16",
"GPIO17",
"GPIO18",
"GPIO19",
"GPIO20",
"GPIO21",
"GPIO22",
"GPIO23",
"GPIO24",
"GPIO25",
"GPIO26",
"GPIO27",
"GPIO28",
"GPIO29",
"GPIO30",
"GPIO31",
"GPIO32",
"GPIO33",
"GPIO34",
"GPIO35",
"GPIO36",
"GPIO37",
"GPIO38",
"GPIO39",
"GPIO40",
"GPIO41",
"GPIO42",
"GPIO43",
"GPIO44",
"GPIO45",
"SMPS_SCL",
"SMPS_SDA",
/* Used by eMMC */
"SD_CLK_R",
"SD_CMD_R",
"SD_DATA0_R",
"SD_DATA1_R",
"SD_DATA2_R",
"SD_DATA3_R";
spi0_pins: spi0_pins {
brcm,pins = <9 10 11>;
brcm,function = <4>; /* alt0 */
};
spi0_cs_pins: spi0_cs_pins {
brcm,pins = <8 7>;
brcm,function = <1>; /* output */
};
i2c0_pins: i2c0 {
brcm,pins = <0 1>;
brcm,function = <4>;
};
i2c1_pins: i2c1 {
brcm,pins = <2 3>;
brcm,function = <4>;
};
i2s_pins: i2s {
brcm,pins = <18 19 20 21>;
brcm,function = <4>; /* alt0 */
};
audio_pins: audio_pins {
brcm,pins;
brcm,function;
};
};
&firmware {
expgpio: expgpio {
compatible = "raspberrypi,firmware-gpio";
gpio-controller;
#gpio-cells = <2>;
gpio-line-names = "HDMI_HPD_N",
"EMMC_EN_N",
"NC",
"NC",
"NC",
"NC",
"NC",
"NC";
status = "okay";
};
virtgpio: virtgpio {
compatible = "brcm,bcm2835-virtgpio";
gpio-controller;
#gpio-cells = <2>;
status = "okay";
};
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
spidev0: spidev@0{
compatible = "spidev";
reg = <0>; /* CE0 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
spidev1: spidev@1{
compatible = "spidev";
reg = <1>; /* CE1 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
};
&i2c0if {
clock-frequency = <100000>;
};
&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&i2c1_pins>;
clock-frequency = <100000>;
};
&i2c2 {
clock-frequency = <100000>;
};
&i2s {
pinctrl-names = "default";
pinctrl-0 = <&i2s_pins>;
};
&led_act {
gpios = <&virtgpio 0 GPIO_ACTIVE_HIGH>;
default-state = "off";
linux,default-trigger = "mmc0";
};
&hdmi {
hpd-gpios = <&expgpio 0 GPIO_ACTIVE_LOW>;
};
&vchiq {
pinctrl-names = "default";
pinctrl-0 = <&audio_pins>;
};
/ {
__overrides__ {
audio = <&chosen>,"bootargs{on='snd_bcm2835.enable_hdmi=1',off='snd_bcm2835.enable_hdmi=0'}";
act_led_gpio = <&led_act>,"gpios:4";
act_led_activelow = <&led_act>,"gpios:8";
act_led_trigger = <&led_act>,"linux,default-trigger";
};
};

View File

@@ -0,0 +1,261 @@
/dts-v1/;
#include "bcm2710.dtsi"
#include "bcm2709-rpi.dtsi"
#include "bcm283x-rpi-csi1-2lane.dtsi"
#include "bcm283x-rpi-i2c0mux_0_44.dtsi"
#include "bcm2708-rpi-bt.dtsi"
#include "bcm283x-rpi-led-deprecated.dtsi"
/ {
compatible = "raspberrypi,model-zero-2-w", "brcm,bcm2837";
model = "Raspberry Pi Zero 2 W";
chosen {
bootargs = "coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_headphones=0";
};
aliases {
serial0 = &uart1;
serial1 = &uart0;
mmc1 = &mmcnr;
};
};
&gpio {
/*
* This is based on the official GPU firmware DT blob.
*
* Legend:
* "NC" = not connected (no rail from the SoC)
* "FOO" = GPIO line named "FOO" on the schematic
* "FOO_N" = GPIO line named "FOO" on schematic, active low
*/
gpio-line-names = "ID_SDA",
"ID_SCL",
"GPIO2",
"GPIO3",
"GPIO4",
"GPIO5",
"GPIO6",
"GPIO7",
"GPIO8",
"GPIO9",
"GPIO10",
"GPIO11",
"GPIO12",
"GPIO13",
"GPIO14",
"GPIO15",
"GPIO16",
"GPIO17",
"GPIO18",
"GPIO19",
"GPIO20",
"GPIO21",
"GPIO22",
"GPIO23",
"GPIO24",
"GPIO25",
"GPIO26",
"GPIO27",
"HDMI_HPD_N",
"STATUS_LED_N",
/* Used by BT module */
"CTS0",
"RTS0",
"TXD0",
"RXD0",
/* Used by Wifi */
"SD1_CLK",
"SD1_CMD",
"SD1_DATA0",
"SD1_DATA1",
"SD1_DATA2",
"SD1_DATA3",
"CAM_GPIO1", /* GPIO40 */
"WL_ON", /* GPIO41 */
"BT_ON", /* GPIO42 */
"WIFI_CLK", /* GPIO43 */
"SDA0", /* GPIO44 */
"SCL0", /* GPIO45 */
"SMPS_SCL", /* GPIO46 */
"SMPS_SDA", /* GPIO47 */
/* Used by SD Card */
"SD_CLK_R",
"SD_CMD_R",
"SD_DATA0_R",
"SD_DATA1_R",
"SD_DATA2_R",
"SD_DATA3_R";
spi0_pins: spi0_pins {
brcm,pins = <9 10 11>;
brcm,function = <4>; /* alt0 */
};
spi0_cs_pins: spi0_cs_pins {
brcm,pins = <8 7>;
brcm,function = <1>; /* output */
};
i2c0_pins: i2c0 {
brcm,pins = <0 1>;
brcm,function = <4>;
};
i2c1_pins: i2c1 {
brcm,pins = <2 3>;
brcm,function = <4>;
};
i2s_pins: i2s {
brcm,pins = <18 19 20 21>;
brcm,function = <4>; /* alt0 */
};
sdio_pins: sdio_pins {
brcm,pins = <34 35 36 37 38 39>;
brcm,function = <7>; // alt3 = SD1
brcm,pull = <0 2 2 2 2 2>;
};
bt_pins: bt_pins {
brcm,pins = <43>;
brcm,function = <4>; /* alt0:GPCLK2 */
brcm,pull = <0>;
};
uart0_pins: uart0_pins {
brcm,pins = <30 31 32 33>;
brcm,function = <7>; /* alt3=UART0 */
brcm,pull = <2 0 0 2>; /* up none none up */
};
uart1_pins: uart1_pins {
brcm,pins;
brcm,function;
brcm,pull;
};
uart1_bt_pins: uart1_bt_pins {
brcm,pins = <32 33 30 31>;
brcm,function = <BCM2835_FSEL_ALT5>; /* alt5=UART1 */
brcm,pull = <0 2 2 0>;
};
audio_pins: audio_pins {
brcm,pins = <>;
brcm,function = <>;
};
};
&mmcnr {
pinctrl-names = "default";
pinctrl-0 = <&sdio_pins>;
bus-width = <4>;
status = "okay";
#address-cells = <1>;
#size-cells = <0>;
brcmf: wifi@1 {
reg = <1>;
compatible = "brcm,bcm4329-fmac";
};
};
&uart0 {
pinctrl-names = "default";
pinctrl-0 = <&uart0_pins &bt_pins>;
status = "okay";
};
&uart1 {
pinctrl-names = "default";
pinctrl-0 = <&uart1_pins>;
status = "okay";
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
spidev0: spidev@0{
compatible = "spidev";
reg = <0>; /* CE0 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
spidev1: spidev@1{
compatible = "spidev";
reg = <1>; /* CE1 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
};
&i2c0if {
clock-frequency = <100000>;
};
&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&i2c1_pins>;
clock-frequency = <100000>;
};
&i2c2 {
clock-frequency = <100000>;
};
&i2s {
pinctrl-names = "default";
pinctrl-0 = <&i2s_pins>;
};
&led_act {
gpios = <&gpio 29 GPIO_ACTIVE_LOW>;
default-state = "off";
linux,default-trigger = "actpwr";
};
&hdmi {
hpd-gpios = <&gpio 28 GPIO_ACTIVE_LOW>;
};
&vchiq {
pinctrl-names = "default";
pinctrl-0 = <&audio_pins>;
};
&bt {
shutdown-gpios = <&gpio 42 GPIO_ACTIVE_HIGH>;
};
&minibt {
shutdown-gpios = <&gpio 42 GPIO_ACTIVE_HIGH>;
};
&cam1_reg {
gpio = <&gpio 40 GPIO_ACTIVE_HIGH>;
};
cam0_reg: &cam_dummy_reg {
};
i2c_csi_dsi0: &i2c0 {
};
/ {
__overrides__ {
audio = <&chosen>,"bootargs{on='snd_bcm2835.enable_hdmi=1',off='snd_bcm2835.enable_hdmi=0'}";
act_led_gpio = <&led_act>,"gpios:4";
act_led_activelow = <&led_act>,"gpios:8";
act_led_trigger = <&led_act>,"linux,default-trigger";
};
};

View File

@@ -0,0 +1 @@
#include "bcm2710-rpi-zero-2-w.dts"

View File

@@ -0,0 +1,32 @@
#define i2c0 i2c0if
#include "bcm2837.dtsi"
#undef i2c0
#include "bcm270x.dtsi"
/ {
compatible = "brcm,bcm2837", "brcm,bcm2836";
arm-pmu {
compatible = "arm,cortex-a53-pmu", "arm,cortex-a7-pmu";
};
soc {
dma-ranges = <0xc0000000 0x00000000 0x3f000000>,
<0x7e000000 0x3f000000 0x01000000>;
};
__overrides__ {
arm_freq = <&cpu0>, "clock-frequency:0",
<&cpu1>, "clock-frequency:0",
<&cpu2>, "clock-frequency:0",
<&cpu3>, "clock-frequency:0";
};
};
&system_timer {
status = "disabled";
};
&vc4 {
status = "disabled";
};

View File

@@ -1,11 +1,19 @@
// SPDX-License-Identifier: GPL-2.0
/dts-v1/;
#define BCM2711
#define i2c0 i2c0if
#include "bcm2711.dtsi"
#include "bcm2711-rpi.dtsi"
/delete-node/&i2c0mux;
#include "bcm283x-rpi-led-deprecated.dtsi"
#include "bcm283x-rpi-usb-peripheral.dtsi"
#include "bcm283x-rpi-wifi-bt.dtsi"
#include <dt-bindings/leds/common.h>
#undef i2c0
#include "bcm270x.dtsi"
#define i2c0 i2c0mux
#undef i2c0
/delete-node/ &cam1_reg;
/ {
compatible = "raspberrypi,4-model-b", "brcm,bcm2711";
@@ -68,7 +76,7 @@
"VDD_SD_IO_SEL",
"CAM_GPIO", /* 5 */
"SD_PWR_ON",
"";
"SD_OC_N";
};
&gpio {
@@ -82,21 +90,21 @@
*/
gpio-line-names = "ID_SDA", /* 0 */
"ID_SCL",
"SDA1",
"SCL1",
"GPIO_GCLK",
"GPIO2",
"GPIO3",
"GPIO4",
"GPIO5", /* 5 */
"GPIO6",
"SPI_CE1_N",
"SPI_CE0_N",
"SPI_MISO",
"SPI_MOSI", /* 10 */
"SPI_SCLK",
"GPIO7",
"GPIO8",
"GPIO9",
"GPIO10", /* 10 */
"GPIO11",
"GPIO12",
"GPIO13",
/* Serial port */
"TXD1",
"RXD1", /* 15 */
"GPIO14",
"GPIO15", /* 15 */
"GPIO16",
"GPIO17",
"GPIO18",
@@ -214,7 +222,7 @@
led@0 {
reg = <0>;
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_LAN;
function = "lan";//LED_FUNCTION_LAN;
default-state = "keep";
};
@@ -222,7 +230,7 @@
led@1 {
reg = <1>;
color = <LED_COLOR_ID_AMBER>;
function = LED_FUNCTION_LAN;
function = "lan";//LED_FUNCTION_LAN;
default-state = "keep";
};
};
@@ -270,3 +278,237 @@
&wifi_pwrseq {
reset-gpios = <&expgpio 1 GPIO_ACTIVE_LOW>;
};
// =============================================
// Downstream rpi- changes
#include "bcm271x-rpi-bt.dtsi"
/ {
soc {
/delete-node/ pixelvalve@7e807000;
/delete-node/ hdmi@7e902000;
};
};
&phy1 {
/delete-node/ leds;
};
#include "bcm2711-rpi-ds.dtsi"
#include "bcm283x-rpi-csi1-2lane.dtsi"
#include "bcm283x-rpi-i2c0mux_0_44.dtsi"
/ {
chosen {
bootargs = "coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_headphones=0";
};
/delete-node/ wifi-pwrseq;
};
&mmcnr {
pinctrl-names = "default";
pinctrl-0 = <&sdio_pins>;
bus-width = <4>;
status = "okay";
};
&uart0 {
pinctrl-0 = <&uart0_pins &bt_pins>;
status = "okay";
};
&uart1 {
pinctrl-0 = <&uart1_pins>;
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
spidev0: spidev@0{
compatible = "spidev";
reg = <0>; /* CE0 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
spidev1: spidev@1{
compatible = "spidev";
reg = <1>; /* CE1 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
};
&gpio {
gpio-line-names = "ID_SDA",
"ID_SCL",
"GPIO2",
"GPIO3",
"GPIO4",
"GPIO5",
"GPIO6",
"GPIO7",
"GPIO8",
"GPIO9",
"GPIO10",
"GPIO11",
"GPIO12",
"GPIO13",
"GPIO14",
"GPIO15",
"GPIO16",
"GPIO17",
"GPIO18",
"GPIO19",
"GPIO20",
"GPIO21",
"GPIO22",
"GPIO23",
"GPIO24",
"GPIO25",
"GPIO26",
"GPIO27",
"RGMII_MDIO",
"RGMIO_MDC",
/* Used by BT module */
"CTS0", /* 30 */
"RTS0",
"TXD0",
"RXD0",
/* Used by Wifi */
"SD1_CLK",
"SD1_CMD", /* 35 */
"SD1_DATA0",
"SD1_DATA1",
"SD1_DATA2",
"SD1_DATA3",
/* Shared with SPI flash */
"PWM0_MISO", /* 40 */
"PWM1_MOSI",
"STATUS_LED_G_CLK",
"SPIFLASH_CE_N",
"SDA0",
"SCL0", /* 45 */
"RGMII_RXCLK",
"RGMII_RXCTL",
"RGMII_RXD0",
"RGMII_RXD1",
"RGMII_RXD2", /* 50 */
"RGMII_RXD3",
"RGMII_TXCLK",
"RGMII_TXCTL",
"RGMII_TXD0",
"RGMII_TXD1", /* 55 */
"RGMII_TXD2",
"RGMII_TXD3";
bt_pins: bt_pins {
brcm,pins = "-"; // non-empty to keep btuart happy, //4 = 0
// to fool pinctrl
brcm,function = <0>;
brcm,pull = <2>;
};
uart0_pins: uart0_pins {
brcm,pins = <32 33>;
brcm,function = <BCM2835_FSEL_ALT3>;
brcm,pull = <0 2>;
};
uart1_pins: uart1_pins {
brcm,pins;
brcm,function;
brcm,pull;
};
uart1_bt_pins: uart1_bt_pins {
brcm,pins = <32 33 30 31>;
brcm,function = <BCM2835_FSEL_ALT5>; /* alt5=UART1 */
brcm,pull = <0 2 2 0>;
};
};
&i2c0if {
clock-frequency = <100000>;
};
&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&i2c1_pins>;
clock-frequency = <100000>;
};
&i2s {
pinctrl-names = "default";
pinctrl-0 = <&i2s_pins>;
};
// =============================================
// Board specific stuff here
&sdhost {
status = "disabled";
};
&phy1 {
led-modes = <0x00 0x08>; /* link/activity link */
};
&gpio {
audio_pins: audio_pins {
brcm,pins = <40 41>;
brcm,function = <4>;
brcm,pull = <0>;
};
};
&led_act {
default-state = "off";
linux,default-trigger = "mmc0";
};
&led_pwr {
default-state = "off";
};
&pwm1 {
status = "disabled";
};
&vchiq {
pinctrl-names = "default";
pinctrl-0 = <&audio_pins>;
};
&cam1_reg {
gpio = <&expgpio 5 GPIO_ACTIVE_HIGH>;
};
cam0_reg: &cam_dummy_reg {
};
i2c_csi_dsi0: &i2c0 {
};
/ {
__overrides__ {
audio = <&chosen>,"bootargs{on='snd_bcm2835.enable_headphones=1 snd_bcm2835.enable_hdmi=1',off='snd_bcm2835.enable_headphones=0 snd_bcm2835.enable_hdmi=0'}";
act_led_gpio = <&led_act>,"gpios:4";
act_led_activelow = <&led_act>,"gpios:8";
act_led_trigger = <&led_act>,"linux,default-trigger";
pwr_led_gpio = <&led_pwr>,"gpios:4";
pwr_led_activelow = <&led_pwr>,"gpios:8";
pwr_led_trigger = <&led_pwr>,"linux,default-trigger";
eth_led0 = <&phy1>,"led-modes:0";
eth_led1 = <&phy1>,"led-modes:4";
};
};

View File

@@ -37,8 +37,53 @@
gpios = <&gpio 42 GPIO_ACTIVE_HIGH>;
};
/delete-node/ &led_act;
&pm {
/delete-property/ system-power-controller;
};
// =============================================
// Downstream rpi- changes
/ {
chosen {
stdout-path = "serial0:115200n8";
};
};
&audio_pins {
brcm,pins = <>;
brcm,function = <>;
};
// Declare the LED but leave it disabled, in case a user wants to map it
// to a GPIO on the header
&led_act {
default-state = "off";
gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
status = "disabled";
};
&led_pwr {
default-state = "off";
};
&cam1_reg {
/delete-property/ gpio;
};
cam0_reg: &cam_dummy_reg {
};
/ {
__overrides__ {
audio = <&chosen>,"bootargs{on='snd_bcm2835.enable_hdmi=1',off='snd_bcm2835.enable_hdmi=0'}";
act_led_gpio = <&led_act>,"gpios:4",
<&led_act>,"status=okay";
act_led_activelow = <&led_act>,"gpios:8";
act_led_trigger = <&led_act>,"linux,default-trigger";
pwr_led_gpio = <&led_pwr>,"gpios:4";
pwr_led_activelow = <&led_pwr>,"gpios:8";
pwr_led_trigger = <&led_pwr>,"linux,default-trigger";
};
};

View File

@@ -0,0 +1,503 @@
// SPDX-License-Identifier: GPL-2.0
/dts-v1/;
#define BCM2711
#define i2c0 i2c0if
#include "bcm2711.dtsi"
#include "bcm2711-rpi.dtsi"
/delete-node/&i2c0mux;
#include "bcm283x-rpi-led-deprecated.dtsi"
#include "bcm283x-rpi-wifi-bt.dtsi"
#undef i2c0
#include "bcm270x.dtsi"
#define i2c0 i2c0mux
#undef i2c0
/ {
compatible = "raspberrypi,4-compute-module", "brcm,bcm2711";
model = "Raspberry Pi Compute Module 4";
chosen {
/* 8250 auxiliary UART instead of pl011 */
stdout-path = "serial1:115200n8";
};
sd_io_1v8_reg: sd_io_1v8_reg {
compatible = "regulator-gpio";
regulator-name = "vdd-sd-io";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-boot-on;
regulator-always-on;
regulator-settling-time-us = <5000>;
gpios = <&expgpio 4 GPIO_ACTIVE_HIGH>;
states = <1800000 0x1>,
<3300000 0x0>;
status = "okay";
};
sd_vcc_reg: sd_vcc_reg {
compatible = "regulator-fixed";
regulator-name = "vcc-sd";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-boot-on;
enable-active-high;
gpio = <&expgpio 6 GPIO_ACTIVE_HIGH>;
};
};
&bt {
shutdown-gpios = <&expgpio 0 GPIO_ACTIVE_HIGH>;
};
&ddc0 {
status = "okay";
};
&ddc1 {
status = "okay";
};
&expgpio {
gpio-line-names = "BT_ON",
"WL_ON",
"PWR_LED_OFF",
"ANT1",
"VDD_SD_IO_SEL",
"CAM_GPIO",
"SD_PWR_ON",
"ANT2";
ant1: ant1 {
gpio-hog;
gpios = <3 GPIO_ACTIVE_HIGH>;
output-high;
};
ant2: ant2 {
gpio-hog;
gpios = <7 GPIO_ACTIVE_HIGH>;
output-low;
};
};
&gpio {
/*
* Parts taken from rpi_SCH_4b_4p0_reduced.pdf and
* the official GPU firmware DT blob.
*
* Legend:
* "FOO" = GPIO line named "FOO" on the schematic
* "FOO_N" = GPIO line named "FOO" on schematic, active low
*/
gpio-line-names = "ID_SDA",
"ID_SCL",
"SDA1",
"SCL1",
"GPIO_GCLK",
"GPIO5",
"GPIO6",
"SPI_CE1_N",
"SPI_CE0_N",
"SPI_MISO",
"SPI_MOSI",
"SPI_SCLK",
"GPIO12",
"GPIO13",
/* Serial port */
"TXD1",
"RXD1",
"GPIO16",
"GPIO17",
"GPIO18",
"GPIO19",
"GPIO20",
"GPIO21",
"GPIO22",
"GPIO23",
"GPIO24",
"GPIO25",
"GPIO26",
"GPIO27",
"RGMII_MDIO",
"RGMIO_MDC",
/* Used by BT module */
"CTS0",
"RTS0",
"TXD0",
"RXD0",
/* Used by Wifi */
"SD1_CLK",
"SD1_CMD",
"SD1_DATA0",
"SD1_DATA1",
"SD1_DATA2",
"SD1_DATA3",
/* Shared with SPI flash */
"PWM0_MISO",
"PWM1_MOSI",
"STATUS_LED_G_CLK",
"SPIFLASH_CE_N",
"SDA0",
"SCL0",
"RGMII_RXCLK",
"RGMII_RXCTL",
"RGMII_RXD0",
"RGMII_RXD1",
"RGMII_RXD2",
"RGMII_RXD3",
"RGMII_TXCLK",
"RGMII_TXCTL",
"RGMII_TXD0",
"RGMII_TXD1",
"RGMII_TXD2",
"RGMII_TXD3";
};
&hdmi0 {
status = "okay";
};
&hdmi1 {
status = "okay";
};
&led_act {
gpios = <&gpio 42 GPIO_ACTIVE_HIGH>;
};
&leds {
led_pwr: led-pwr {
label = "PWR";
gpios = <&expgpio 2 GPIO_ACTIVE_LOW>;
default-state = "keep";
linux,default-trigger = "default-on";
};
};
&pixelvalve0 {
status = "okay";
};
&pixelvalve1 {
status = "okay";
};
&pixelvalve2 {
status = "okay";
};
&pixelvalve4 {
status = "okay";
};
&pwm1 {
pinctrl-names = "default";
pinctrl-0 = <&pwm1_0_gpio40 &pwm1_1_gpio41>;
status = "okay";
};
/* EMMC2 is used to drive the EMMC card */
&emmc2 {
bus-width = <8>;
vqmmc-supply = <&sd_io_1v8_reg>;
vmmc-supply = <&sd_vcc_reg>;
broken-cd;
status = "okay";
};
&genet {
phy-handle = <&phy1>;
phy-mode = "rgmii-rxid";
status = "okay";
};
&genet_mdio {
phy1: ethernet-phy@0 {
/* No PHY interrupt */
reg = <0x0>;
};
};
&pcie0 {
pci@0,0 {
device_type = "pci";
#address-cells = <3>;
#size-cells = <2>;
ranges;
reg = <0 0 0 0 0>;
};
};
/* uart0 communicates with the BT module */
&uart0 {
pinctrl-names = "default";
pinctrl-0 = <&uart0_ctsrts_gpio30 &uart0_gpio32>;
uart-has-rtscts;
};
/* uart1 is mapped to the pin header */
&uart1 {
pinctrl-names = "default";
pinctrl-0 = <&uart1_gpio14>;
status = "okay";
};
&vc4 {
status = "okay";
};
&vec {
status = "disabled";
};
&wifi_pwrseq {
reset-gpios = <&expgpio 1 GPIO_ACTIVE_LOW>;
};
// =============================================
// Downstream rpi- changes
#include "bcm271x-rpi-bt.dtsi"
/ {
soc {
/delete-node/ pixelvalve@7e807000;
/delete-node/ hdmi@7e902000;
};
};
#include "bcm2711-rpi-ds.dtsi"
#include "bcm283x-rpi-csi0-2lane.dtsi"
#include "bcm283x-rpi-csi1-4lane.dtsi"
#include "bcm283x-rpi-i2c0mux_0_44.dtsi"
/ {
chosen {
bootargs = "coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_headphones=0";
};
/delete-node/ wifi-pwrseq;
};
&mmcnr {
pinctrl-names = "default";
pinctrl-0 = <&sdio_pins>;
bus-width = <4>;
status = "okay";
};
&uart0 {
pinctrl-0 = <&uart0_pins &bt_pins>;
status = "okay";
};
&uart1 {
pinctrl-0 = <&uart1_pins>;
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
spidev0: spidev@0{
compatible = "spidev";
reg = <0>; /* CE0 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
spidev1: spidev@1{
compatible = "spidev";
reg = <1>; /* CE1 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
};
&gpio {
gpio-line-names = "ID_SDA",
"ID_SCL",
"GPIO2",
"GPIO3",
"GPIO4",
"GPIO5",
"GPIO6",
"GPIO7",
"GPIO8",
"GPIO9",
"GPIO10",
"GPIO11",
"GPIO12",
"GPIO13",
"GPIO14",
"GPIO15",
"GPIO16",
"GPIO17",
"GPIO18",
"GPIO19",
"GPIO20",
"GPIO21",
"GPIO22",
"GPIO23",
"GPIO24",
"GPIO25",
"GPIO26",
"GPIO27",
"RGMII_MDIO",
"RGMIO_MDC",
/* Used by BT module */
"CTS0",
"RTS0",
"TXD0",
"RXD0",
/* Used by Wifi */
"SD1_CLK",
"SD1_CMD",
"SD1_DATA0",
"SD1_DATA1",
"SD1_DATA2",
"SD1_DATA3",
/* Shared with SPI flash */
"PWM0_MISO",
"PWM1_MOSI",
"STATUS_LED_G_CLK",
"SPIFLASH_CE_N",
"SDA0",
"SCL0",
"RGMII_RXCLK",
"RGMII_RXCTL",
"RGMII_RXD0",
"RGMII_RXD1",
"RGMII_RXD2",
"RGMII_RXD3",
"RGMII_TXCLK",
"RGMII_TXCTL",
"RGMII_TXD0",
"RGMII_TXD1",
"RGMII_TXD2",
"RGMII_TXD3";
bt_pins: bt_pins {
brcm,pins = "-"; // non-empty to keep btuart happy, //4 = 0
// to fool pinctrl
brcm,function = <0>;
brcm,pull = <2>;
};
uart0_pins: uart0_pins {
brcm,pins = <32 33>;
brcm,function = <BCM2835_FSEL_ALT3>;
brcm,pull = <0 2>;
};
uart1_pins: uart1_pins {
brcm,pins;
brcm,function;
brcm,pull;
};
uart1_bt_pins: uart1_bt_pins {
brcm,pins = <32 33 30 31>;
brcm,function = <BCM2835_FSEL_ALT5>; /* alt5=UART1 */
brcm,pull = <0 2 2 0>;
};
};
&i2c0if {
clock-frequency = <100000>;
};
&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&i2c1_pins>;
clock-frequency = <100000>;
};
&i2s {
pinctrl-names = "default";
pinctrl-0 = <&i2s_pins>;
};
// =============================================
// Board specific stuff here
&pcie0 {
brcm,enable-l1ss;
};
&sdhost {
status = "disabled";
};
&phy1 {
led-modes = <0x00 0x08>; /* link/activity link */
};
&gpio {
audio_pins: audio_pins {
brcm,pins = <>;
brcm,function = <>;
};
};
&led_act {
default-state = "off";
linux,default-trigger = "mmc0";
};
&led_pwr {
default-state = "off";
};
&pwm1 {
status = "disabled";
};
&vchiq {
pinctrl-names = "default";
pinctrl-0 = <&audio_pins>;
};
cam0_reg: &cam1_reg {
gpio = <&expgpio 5 GPIO_ACTIVE_HIGH>;
};
i2c_csi_dsi0: &i2c0 {
};
/ {
__overrides__ {
audio = <&chosen>,"bootargs{on='snd_bcm2835.enable_hdmi=1',off='snd_bcm2835.enable_hdmi=0'}";
act_led_gpio = <&led_act>,"gpios:4";
act_led_activelow = <&led_act>,"gpios:8";
act_led_trigger = <&led_act>,"linux,default-trigger";
pwr_led_gpio = <&led_pwr>,"gpios:4";
pwr_led_activelow = <&led_pwr>,"gpios:8";
pwr_led_trigger = <&led_pwr>,"linux,default-trigger";
eth_led0 = <&phy1>,"led-modes:0";
eth_led1 = <&phy1>,"led-modes:4";
ant1 = <&ant1>,"output-high?=on",
<&ant1>, "output-low?=off",
<&ant2>, "output-high?=off",
<&ant2>, "output-low?=on";
ant2 = <&ant1>,"output-high?=off",
<&ant1>, "output-low?=on",
<&ant2>, "output-high?=on",
<&ant2>, "output-low?=off";
noant = <&ant1>,"output-high?=off",
<&ant1>, "output-low?=on",
<&ant2>, "output-high?=off",
<&ant2>, "output-low?=on";
pcie_tperst_clk_ms = <&pcie0>,"brcm,tperst-clk-ms:0";
};
};

View File

@@ -0,0 +1,293 @@
// SPDX-License-Identifier: GPL-2.0
/dts-v1/;
#define BCM2711
#define i2c0 i2c0if
#include "bcm2711.dtsi"
#include "bcm2711-rpi.dtsi"
/delete-node/&i2c0mux;
#include "bcm283x-rpi-led-deprecated.dtsi"
#undef i2c0
#include "bcm270x.dtsi"
#define i2c0 i2c0mux
#undef i2c0
/ {
compatible = "raspberrypi,4-compute-module-s", "brcm,bcm2711";
model = "Raspberry Pi Compute Module 4S";
};
&ddc0 {
status = "okay";
};
&gpio {
/*
* Parts taken from rpi_SCH_4b_4p0_reduced.pdf and
* the official GPU firmware DT blob.
*
* Legend:
* "FOO" = GPIO line named "FOO" on the schematic
* "FOO_N" = GPIO line named "FOO" on schematic, active low
*/
gpio-line-names = "ID_SDA",
"ID_SCL",
"GPIO2",
"GPIO3",
"GPIO4",
"GPIO5",
"GPIO6",
"GPIO7",
"GPIO8",
"GPIO9",
"GPIO10",
"GPIO11",
"GPIO12",
"GPIO13",
"GPIO14",
"GPIO15",
"GPIO16",
"GPIO17",
"GPIO18",
"GPIO19",
"GPIO20",
"GPIO21",
"GPIO22",
"GPIO23",
"GPIO24",
"GPIO25",
"GPIO26",
"GPIO27",
"GPIO28",
"GPIO29",
"GPIO30",
"GPIO31",
"GPIO32",
"GPIO33",
"GPIO34",
"GPIO35",
"GPIO36",
"GPIO37",
"GPIO38",
"GPIO39",
"PWM0_MISO",
"PWM1_MOSI",
"GPIO42",
"GPIO43",
"GPIO44",
"GPIO45";
};
&hdmi0 {
status = "okay";
};
&led_act {
gpios = <&virtgpio 0 GPIO_ACTIVE_HIGH>;
};
&pixelvalve0 {
status = "okay";
};
&pixelvalve1 {
status = "okay";
};
&pixelvalve2 {
status = "okay";
};
&pixelvalve4 {
status = "okay";
};
&pwm1 {
pinctrl-names = "default";
pinctrl-0 = <&pwm1_0_gpio40 &pwm1_1_gpio41>;
status = "okay";
};
/* EMMC2 is used to drive the EMMC card */
&emmc2 {
bus-width = <8>;
broken-cd;
status = "okay";
};
&pcie0 {
status = "disabled";
};
&vchiq {
interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>;
};
&vc4 {
status = "okay";
};
&vec {
status = "disabled";
};
// =============================================
// Downstream rpi- changes
#include "bcm2711-rpi-ds.dtsi"
/ {
soc {
/delete-node/ pixelvalve@7e807000;
/delete-node/ hdmi@7e902000;
};
};
#include "bcm283x-rpi-csi0-2lane.dtsi"
#include "bcm283x-rpi-csi1-4lane.dtsi"
#include "bcm283x-rpi-i2c0mux_0_28.dtsi"
/ {
chosen {
bootargs = "coherent_pool=1M snd_bcm2835.enable_headphones=0";
};
aliases {
serial0 = &uart0;
serial1 = &uart1;
/delete-property/ i2c20;
/delete-property/ i2c21;
};
/delete-node/ wifi-pwrseq;
};
&firmware {
virtgpio: virtgpio {
compatible = "brcm,bcm2835-virtgpio";
gpio-controller;
#gpio-cells = <2>;
status = "okay";
};
};
&uart0 {
pinctrl-names = "default";
pinctrl-0 = <&uart0_pins>;
status = "okay";
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
spidev0: spidev@0{
compatible = "spidev";
reg = <0>; /* CE0 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
spidev1: spidev@1{
compatible = "spidev";
reg = <1>; /* CE1 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
};
&gpio {
uart0_pins: uart0_pins {
brcm,pins;
brcm,function;
brcm,pull;
};
};
&i2c0if {
clock-frequency = <100000>;
};
&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&i2c1_pins>;
clock-frequency = <100000>;
};
&i2s {
pinctrl-names = "default";
pinctrl-0 = <&i2s_pins>;
};
// =============================================
// Board specific stuff here
/* Enable USB in OTG-aware mode */
&usb {
compatible = "brcm,bcm2835-usb";
dr_mode = "otg";
g-np-tx-fifo-size = <32>;
g-rx-fifo-size = <558>;
g-tx-fifo-size = <512 512 512 512 512 256 256>;
status = "okay";
};
&sdhost {
status = "disabled";
};
&gpio {
audio_pins: audio_pins {
brcm,pins = <>;
brcm,function = <>;
};
};
/* Permanently disable HDMI1 */
&hdmi1 {
compatible = "disabled";
};
/* Permanently disable DDC1 */
&ddc1 {
compatible = "disabled";
};
&led_act {
default-state = "off";
linux,default-trigger = "mmc0";
};
&pwm1 {
status = "disabled";
};
&vchiq {
pinctrl-names = "default";
pinctrl-0 = <&audio_pins>;
};
&cam1_reg {
gpio = <&gpio 3 GPIO_ACTIVE_HIGH>;
status = "disabled";
};
cam0_reg: &cam0_regulator {
gpio = <&gpio 31 GPIO_ACTIVE_HIGH>;
status = "disabled";
};
i2c_csi_dsi0: &i2c0 {
};
/ {
__overrides__ {
audio = <&chosen>,"bootargs{on='snd_bcm2835.enable_hdmi=1',off='snd_bcm2835.enable_hdmi=0'}";
act_led_gpio = <&led_act>,"gpios:4";
act_led_activelow = <&led_act>,"gpios:8";
act_led_trigger = <&led_act>,"linux,default-trigger";
};
};

View File

@@ -0,0 +1,561 @@
// SPDX-License-Identifier: GPL-2.0
#include "bcm270x-rpi.dtsi"
/ {
chosen: chosen {
};
__overrides__ {
arm_freq;
eee = <&chosen>,"bootargs{on='',off='genet.eee=N'}";
hdmi = <&hdmi0>,"status",
<&hdmi1>,"status";
nvmem_cust_rw = <&nvmem_cust>,"rw?";
nvmem_priv_rw = <&nvmem_priv>,"rw?";
pcie = <&pcie0>,"status";
sd = <&emmc2>,"status";
sd_poll_once = <&emmc2>, "non-removable?";
spi_dma4 = <&spi0>, "dmas:0=", <&dma40>,
<&spi0>, "dmas:8=", <&dma40>;
i2s_dma4 = <&i2s>, "dmas:0=", <&dma40>,
<&i2s>, "dmas:8=", <&dma40>;
};
scb: scb {
/* Add a label */
};
soc: soc {
/* Add a label */
};
chosen {
stdout-path = "serial0:115200n8";
};
aliases {
uart2 = &uart2;
uart3 = &uart3;
uart4 = &uart4;
uart5 = &uart5;
serial0 = &uart1;
serial1 = &uart0;
serial2 = &uart2;
serial3 = &uart3;
serial4 = &uart4;
serial5 = &uart5;
mmc0 = &emmc2;
mmc1 = &mmcnr;
mmc2 = &sdhost;
i2c3 = &i2c3;
i2c4 = &i2c4;
i2c5 = &i2c5;
i2c6 = &i2c6;
i2c20 = &ddc0;
i2c21 = &ddc1;
spi3 = &spi3;
spi4 = &spi4;
spi5 = &spi5;
spi6 = &spi6;
/delete-property/ intc;
};
/*
* Add a node with a dma-ranges value that exists only to be found
* by of_dma_get_max_cpu_address, and hence limit the DMA zone.
*/
zone_dma {
#address-cells = <1>;
#size-cells = <1>;
dma-ranges = <0x0 0x0 0x0 0x40000000>;
};
};
&vc4 {
raspberrypi,firmware = <&firmware>;
};
&cma {
/* Limit cma to the lower 768MB to allow room for HIGHMEM on 32-bit */
alloc-ranges = <0x0 0x00000000 0x30000000>;
};
&soc {
/* Add the physical <-> DMA mapping for the I/O space */
dma-ranges = <0xc0000000 0x0 0x00000000 0x40000000>,
<0x7c000000 0x0 0xfc000000 0x03800000>;
nvmem {
compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
nvmem_otp: nvmem_otp {
compatible = "raspberrypi,rpi-otp";
firmware = <&firmware>;
reg = <0 166>;
status = "okay";
};
nvmem_cust: nvmem_cust {
compatible = "raspberrypi,rpi-otp";
firmware = <&firmware>;
reg = <1 8>;
status = "okay";
};
nvmem_priv: nvmem_priv {
compatible = "raspberrypi,rpi-otp";
firmware = <&firmware>;
reg = <3 8>;
status = "okay";
};
};
};
&scb {
#size-cells = <2>;
ranges = <0x0 0x7c000000 0x0 0xfc000000 0x0 0x03800000>,
<0x0 0x40000000 0x0 0xff800000 0x0 0x00800000>,
<0x6 0x00000000 0x6 0x00000000 0x0 0x40000000>,
<0x0 0x00000000 0x0 0x00000000 0x0 0xfc000000>;
dma-ranges = <0x4 0x7c000000 0x0 0xfc000000 0x0 0x03800000>,
<0x0 0x00000000 0x0 0x00000000 0x4 0x00000000>;
dma40: dma@7e007b00 {
compatible = "brcm,bcm2711-dma";
reg = <0x0 0x7e007b00 0x0 0x400>;
interrupts =
<GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>, /* dma4 11 */
<GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>, /* dma4 12 */
<GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH>, /* dma4 13 */
<GIC_SPI 92 IRQ_TYPE_LEVEL_HIGH>; /* dma4 14 */
interrupt-names = "dma11",
"dma12",
"dma13",
"dma14";
#dma-cells = <1>;
brcm,dma-channel-mask = <0x7800>;
};
xhci: xhci@7e9c0000 {
compatible = "generic-xhci";
status = "disabled";
reg = <0x0 0x7e9c0000 0x0 0x100000>;
interrupts = <GIC_SPI 176 IRQ_TYPE_LEVEL_HIGH>;
power-domains = <&power RPI_POWER_DOMAIN_USB>;
};
codec@7eb10000 {
compatible = "raspberrypi,rpivid-vid-decoder";
reg = <0x0 0x7eb10000 0x0 0x1000>, /* INTC */
<0x0 0x7eb00000 0x0 0x10000>; /* HEVC */
reg-names = "intc",
"hevc";
interrupts = <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&firmware_clocks 11>;
clock-names = "hevc";
};
};
&pcie0 {
reg = <0x0 0x7d500000 0x0 0x9310>;
ranges = <0x02000000 0x0 0xc0000000 0x6 0x00000000
0x0 0x40000000>;
};
&genet {
reg = <0x0 0x7d580000 0x0 0x10000>;
};
&dma40 {
/* The VPU firmware uses DMA channel 11 for VCHIQ */
brcm,dma-channel-mask = <0x7000>;
};
&vchiq {
compatible = "brcm,bcm2711-vchiq";
};
&firmwarekms {
compatible = "raspberrypi,rpi-firmware-kms-2711";
interrupts = <GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH>;
};
&smi {
interrupts = <GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH>;
};
&mmc {
interrupts = <GIC_SPI 126 IRQ_TYPE_LEVEL_HIGH>;
};
&mmcnr {
interrupts = <GIC_SPI 126 IRQ_TYPE_LEVEL_HIGH>;
};
&csi0 {
interrupts = <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>;
};
&csi1 {
interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>;
};
&random {
compatible = "brcm,bcm2711-rng200";
status = "okay";
};
&usb {
/* Enable the FIQ support */
reg = <0x7e980000 0x10000>,
<0x7e00b200 0x200>;
interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>,
<GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>;
status = "disabled";
};
&gpio {
interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH>,
<GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH>;
spi0_pins: spi0_pins {
brcm,pins = <9 10 11>;
brcm,function = <BCM2835_FSEL_ALT0>;
};
spi0_cs_pins: spi0_cs_pins {
brcm,pins = <8 7>;
brcm,function = <BCM2835_FSEL_GPIO_OUT>;
};
spi3_pins: spi3_pins {
brcm,pins = <1 2 3>;
brcm,function = <BCM2835_FSEL_ALT3>;
};
spi3_cs_pins: spi3_cs_pins {
brcm,pins = <0 24>;
brcm,function = <BCM2835_FSEL_GPIO_OUT>;
};
spi4_pins: spi4_pins {
brcm,pins = <5 6 7>;
brcm,function = <BCM2835_FSEL_ALT3>;
};
spi4_cs_pins: spi4_cs_pins {
brcm,pins = <4 25>;
brcm,function = <BCM2835_FSEL_GPIO_OUT>;
};
spi5_pins: spi5_pins {
brcm,pins = <13 14 15>;
brcm,function = <BCM2835_FSEL_ALT3>;
};
spi5_cs_pins: spi5_cs_pins {
brcm,pins = <12 26>;
brcm,function = <BCM2835_FSEL_GPIO_OUT>;
};
spi6_pins: spi6_pins {
brcm,pins = <19 20 21>;
brcm,function = <BCM2835_FSEL_ALT3>;
};
spi6_cs_pins: spi6_cs_pins {
brcm,pins = <18 27>;
brcm,function = <BCM2835_FSEL_GPIO_OUT>;
};
i2c0_pins: i2c0 {
brcm,pins = <0 1>;
brcm,function = <BCM2835_FSEL_ALT0>;
brcm,pull = <BCM2835_PUD_UP>;
};
i2c1_pins: i2c1 {
brcm,pins = <2 3>;
brcm,function = <BCM2835_FSEL_ALT0>;
brcm,pull = <BCM2835_PUD_UP>;
};
i2c3_pins: i2c3 {
brcm,pins = <4 5>;
brcm,function = <BCM2835_FSEL_ALT5>;
brcm,pull = <BCM2835_PUD_UP>;
};
i2c4_pins: i2c4 {
brcm,pins = <8 9>;
brcm,function = <BCM2835_FSEL_ALT5>;
brcm,pull = <BCM2835_PUD_UP>;
};
i2c5_pins: i2c5 {
brcm,pins = <12 13>;
brcm,function = <BCM2835_FSEL_ALT5>;
brcm,pull = <BCM2835_PUD_UP>;
};
i2c6_pins: i2c6 {
brcm,pins = <22 23>;
brcm,function = <BCM2835_FSEL_ALT5>;
brcm,pull = <BCM2835_PUD_UP>;
};
i2s_pins: i2s {
brcm,pins = <18 19 20 21>;
brcm,function = <BCM2835_FSEL_ALT0>;
};
sdio_pins: sdio_pins {
brcm,pins = <34 35 36 37 38 39>;
brcm,function = <BCM2835_FSEL_ALT3>; // alt3 = SD1
brcm,pull = <0 2 2 2 2 2>;
};
uart2_pins: uart2_pins {
brcm,pins = <0 1>;
brcm,function = <BCM2835_FSEL_ALT4>;
brcm,pull = <0 2>;
};
uart3_pins: uart3_pins {
brcm,pins = <4 5>;
brcm,function = <BCM2835_FSEL_ALT4>;
brcm,pull = <0 2>;
};
uart4_pins: uart4_pins {
brcm,pins = <8 9>;
brcm,function = <BCM2835_FSEL_ALT4>;
brcm,pull = <0 2>;
};
uart5_pins: uart5_pins {
brcm,pins = <12 13>;
brcm,function = <BCM2835_FSEL_ALT4>;
brcm,pull = <0 2>;
};
};
&emmc2 {
mmc-ddr-3_3v;
};
&vc4 {
status = "disabled";
};
&pixelvalve0 {
status = "disabled";
};
&pixelvalve1 {
status = "disabled";
};
&pixelvalve2 {
status = "disabled";
};
&pixelvalve3 {
status = "disabled";
};
&pixelvalve4 {
status = "disabled";
};
&hdmi0 {
reg = <0x7ef00700 0x300>,
<0x7ef00300 0x200>,
<0x7ef00f00 0x80>,
<0x7ef00f80 0x80>,
<0x7ef01b00 0x200>,
<0x7ef01f00 0x400>,
<0x7ef00200 0x80>,
<0x7ef04300 0x100>,
<0x7ef20000 0x100>,
<0x7ef00100 0x30>;
reg-names = "hdmi",
"dvp",
"phy",
"rm",
"packet",
"metadata",
"csc",
"cec",
"hd",
"intr2";
clocks = <&firmware_clocks 13>,
<&firmware_clocks 14>,
<&dvp 0>,
<&clk_27MHz>;
dmas = <&dma40 (10|(1<<30)|(1<<24)|(10<<16)|(15<<20))>;
status = "disabled";
};
&ddc0 {
status = "disabled";
};
&hdmi1 {
reg = <0x7ef05700 0x300>,
<0x7ef05300 0x200>,
<0x7ef05f00 0x80>,
<0x7ef05f80 0x80>,
<0x7ef06b00 0x200>,
<0x7ef06f00 0x400>,
<0x7ef00280 0x80>,
<0x7ef09300 0x100>,
<0x7ef20000 0x100>,
<0x7ef00100 0x30>;
reg-names = "hdmi",
"dvp",
"phy",
"rm",
"packet",
"metadata",
"csc",
"cec",
"hd",
"intr2";
clocks = <&firmware_clocks 13>,
<&firmware_clocks 14>,
<&dvp 1>,
<&clk_27MHz>;
dmas = <&dma40 (17|(1<<30)|(1<<24)|(10<<16)|(15<<20))>;
status = "disabled";
};
&ddc1 {
status = "disabled";
};
&dvp {
status = "disabled";
};
&vec {
clocks = <&firmware_clocks 15>;
};
&aon_intr {
interrupts = <GIC_SPI 96 IRQ_TYPE_EDGE_RISING>;
status = "disabled";
};
&system_timer {
status = "disabled";
};
&i2c0 {
/delete-property/ compatible;
/delete-property/ interrupts;
};
&i2c0if {
compatible = "brcm,bcm2711-i2c", "brcm,bcm2835-i2c";
interrupts = <GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>;
};
i2c_arm: &i2c1 {};
i2c_vc: &i2c0 {};
&i2c3 {
pinctrl-0 = <&i2c3_pins>;
pinctrl-names = "default";
};
&i2c4 {
pinctrl-0 = <&i2c4_pins>;
pinctrl-names = "default";
};
&i2c5 {
pinctrl-0 = <&i2c5_pins>;
pinctrl-names = "default";
};
&i2c6 {
pinctrl-0 = <&i2c6_pins>;
pinctrl-names = "default";
};
&spi3 {
pinctrl-0 = <&spi3_pins &spi3_cs_pins>;
pinctrl-names = "default";
};
&spi4 {
pinctrl-0 = <&spi4_pins &spi4_cs_pins>;
pinctrl-names = "default";
};
&spi5 {
pinctrl-0 = <&spi5_pins &spi5_cs_pins>;
pinctrl-names = "default";
};
&spi6 {
pinctrl-0 = <&spi6_pins &spi6_cs_pins>;
pinctrl-names = "default";
};
&uart2 {
pinctrl-0 = <&uart2_pins>;
pinctrl-names = "default";
};
&uart3 {
pinctrl-0 = <&uart3_pins>;
pinctrl-names = "default";
};
&uart4 {
pinctrl-0 = <&uart4_pins>;
pinctrl-names = "default";
};
&uart5 {
pinctrl-0 = <&uart5_pins>;
pinctrl-names = "default";
};
&axiperf {
compatible = "brcm,bcm2711-axiperf";
};
/delete-node/ &v3d;
/ {
v3dbus: v3dbus {
compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <2>;
ranges = <0x7c500000 0x0 0xfc500000 0x0 0x03300000>,
<0x40000000 0x0 0xff800000 0x0 0x00800000>;
dma-ranges = <0x00000000 0x0 0x00000000 0x4 0x00000000>;
v3d: v3d@7ec04000 {
compatible = "brcm,2711-v3d";
reg =
<0x7ec00000 0x0 0x4000>,
<0x7ec04000 0x0 0x4000>;
reg-names = "hub", "core0";
power-domains = <&pm BCM2835_POWER_DOMAIN_GRAFX_V3D>;
resets = <&pm BCM2835_RESET_V3D>;
clocks = <&firmware_clocks 5>;
clocks-names = "v3d";
interrupts = <GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>;
status = "disabled";
};
};
};

View File

@@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include "bcm2835-rpi.dtsi"
#include <dt-bindings/power/raspberrypi-power.h>
#include <dt-bindings/reset/raspberrypi,firmware-reset.h>
/ {
@@ -16,6 +15,7 @@
ethernet0 = &genet;
pcie0 = &pcie0;
blconfig = &blconfig;
blpubkey = &blpubkey;
};
i2c0mux: i2c-mux0 {
@@ -92,6 +92,18 @@
no-map;
status = "disabled";
};
/*
* RPi4 will copy the binary public key blob (if present) from the bootloader
* into memory for use by the OS.
*/
blpubkey: nvram@1 {
compatible = "raspberrypi,bootloader-public-key", "nvmem-rmem";
#address-cells = <1>;
#size-cells = <1>;
reg = <0x0 0x0 0x0>;
no-map;
status = "disabled";
};
};
&v3d {
@@ -101,7 +113,3 @@
&vchiq {
interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>;
};
&xhci {
power-domains = <&power RPI_POWER_DOMAIN_USB>;
};

View File

@@ -277,7 +277,7 @@
reg = <0x7e20c800 0x28>;
clocks = <&clocks BCM2835_CLOCK_PWM>;
assigned-clocks = <&clocks BCM2835_CLOCK_PWM>;
assigned-clock-rates = <10000000>;
assigned-clock-rates = <50000000>;
#pwm-cells = <3>;
status = "disabled";
};
@@ -604,20 +604,6 @@
};
};
xhci: usb@7e9c0000 {
compatible = "brcm,bcm2711-xhci", "brcm,xhci-brcm-v2";
reg = <0x0 0x7e9c0000 0x100000>;
#address-cells = <1>;
#size-cells = <0>;
interrupts = <GIC_SPI 176 IRQ_TYPE_LEVEL_HIGH>;
/* DWC2 and this IP block share the same USB PHY,
* enabling both at the same time results in lockups.
* So keep this node disabled and let the bootloader
* decide which interface should be enabled.
*/
status = "disabled";
};
v3d: gpu@7ec00000 {
compatible = "brcm,2711-v3d";
reg = <0x0 0x7ec00000 0x4000>,

View File

@@ -0,0 +1,38 @@
// SPDX-License-Identifier: GPL-2.0
&uart0 {
bt: bluetooth {
compatible = "brcm,bcm43438-bt";
max-speed = <3000000>;
shutdown-gpios = <&expgpio 0 GPIO_ACTIVE_HIGH>;
local-bd-address = [ 00 00 00 00 00 00 ];
fallback-bd-address; // Don't override a valid address
status = "okay";
};
};
&uart1 {
minibt: bluetooth {
compatible = "brcm,bcm43438-bt";
max-speed = <230400>;
shutdown-gpios = <&expgpio 0 GPIO_ACTIVE_HIGH>;
local-bd-address = [ 00 00 00 00 00 00 ];
fallback-bd-address; // Don't override a valid address
status = "disabled";
};
};
/ {
aliases {
bluetooth = &bt;
};
__overrides__ {
bdaddr = <&bt>,"local-bd-address[",
<&bt>,"fallback-bd-address?=0",
<&minibt>,"local-bd-address[",
<&minibt>,"fallback-bd-address?=0";
krnbt = <&bt>,"status";
krnbt_baudrate = <&bt>,"max-speed:0", <&minibt>,"max-speed:0";
};
};

View File

@@ -0,0 +1,4 @@
// SPDX-License-Identifier: GPL-2.0-only
&csi0 {
brcm,num-data-lanes = <2>;
};

View File

@@ -0,0 +1,4 @@
// SPDX-License-Identifier: GPL-2.0-only
&csi1 {
brcm,num-data-lanes = <2>;
};

View File

@@ -0,0 +1,4 @@
// SPDX-License-Identifier: GPL-2.0-only
&csi1 {
brcm,num-data-lanes = <4>;
};

View File

@@ -0,0 +1,4 @@
&i2c0mux {
pinctrl-0 = <&i2c0_gpio0>;
pinctrl-1 = <&i2c0_gpio28>;
};

View File

@@ -0,0 +1,4 @@
&i2c0mux {
pinctrl-0 = <&i2c0_gpio0>;
pinctrl-1 = <&i2c0_gpio44>;
};

View File

@@ -363,7 +363,7 @@
#size-cells = <0>;
#clock-cells = <1>;
clocks = <&clocks BCM2835_PLLA_DSI0>,
clocks = <&clocks BCM2835_PLLD_DSI0>,
<&clocks BCM2835_CLOCK_DSI0E>,
<&clocks BCM2835_CLOCK_DSI0P>;
clock-names = "phy", "escape", "pixel";
@@ -415,7 +415,7 @@
reg = <0x7e20c000 0x28>;
clocks = <&clocks BCM2835_CLOCK_PWM>;
assigned-clocks = <&clocks BCM2835_CLOCK_PWM>;
assigned-clock-rates = <10000000>;
assigned-clock-rates = <50000000>;
#pwm-cells = <3>;
status = "disabled";
};

View File

@@ -0,0 +1,341 @@
# Overlays for the Raspberry Pi platform
dtb-$(CONFIG_ARCH_BCM2835) += overlay_map.dtb hat_map.dtb README
dtbo-$(CONFIG_ARCH_BCM2835) += \
act-led.dtbo \
adafruit-st7735r.dtbo \
adafruit18.dtbo \
adau1977-adc.dtbo \
adau7002-simple.dtbo \
ads1015.dtbo \
ads1115.dtbo \
ads7846.dtbo \
adv7282m.dtbo \
adv728x-m.dtbo \
akkordion-iqdacplus.dtbo \
allo-boss-dac-pcm512x-audio.dtbo \
allo-boss2-dac-audio.dtbo \
allo-digione.dtbo \
allo-katana-dac-audio.dtbo \
allo-piano-dac-pcm512x-audio.dtbo \
allo-piano-dac-plus-pcm512x-audio.dtbo \
anyspi.dtbo \
apds9960.dtbo \
applepi-dac.dtbo \
arducam-64mp.dtbo \
arducam-pivariety.dtbo \
at86rf233.dtbo \
audioinjector-addons.dtbo \
audioinjector-bare-i2s.dtbo \
audioinjector-isolated-soundcard.dtbo \
audioinjector-ultra.dtbo \
audioinjector-wm8731-audio.dtbo \
audiosense-pi.dtbo \
audremap.dtbo \
balena-fin.dtbo \
bcm2712d0.dtbo \
camera-mux-2port.dtbo \
camera-mux-4port.dtbo \
cap1106.dtbo \
chipcap2.dtbo \
chipdip-dac.dtbo \
cirrus-wm5102.dtbo \
cm-swap-i2c0.dtbo \
cma.dtbo \
crystalfontz-cfa050_pi_m.dtbo \
cutiepi-panel.dtbo \
dacberry400.dtbo \
dht11.dtbo \
dionaudio-kiwi.dtbo \
dionaudio-loco.dtbo \
dionaudio-loco-v2.dtbo \
disable-bt.dtbo \
disable-bt-pi5.dtbo \
disable-emmc2.dtbo \
disable-wifi.dtbo \
disable-wifi-pi5.dtbo \
dpi18.dtbo \
dpi18cpadhi.dtbo \
dpi24.dtbo \
draws.dtbo \
dwc-otg.dtbo \
dwc2.dtbo \
edt-ft5406.dtbo \
enc28j60.dtbo \
enc28j60-spi2.dtbo \
exc3000.dtbo \
fbtft.dtbo \
fe-pi-audio.dtbo \
fsm-demo.dtbo \
gc9a01.dtbo \
ghost-amp.dtbo \
goodix.dtbo \
googlevoicehat-soundcard.dtbo \
gpio-charger.dtbo \
gpio-fan.dtbo \
gpio-hog.dtbo \
gpio-ir.dtbo \
gpio-ir-tx.dtbo \
gpio-key.dtbo \
gpio-led.dtbo \
gpio-no-bank0-irq.dtbo \
gpio-no-irq.dtbo \
gpio-poweroff.dtbo \
gpio-shutdown.dtbo \
hd44780-i2c-lcd.dtbo \
hd44780-lcd.dtbo \
hdmi-backlight-hwhack-gpio.dtbo \
hifiberry-amp.dtbo \
hifiberry-amp100.dtbo \
hifiberry-amp3.dtbo \
hifiberry-amp4pro.dtbo \
hifiberry-dac.dtbo \
hifiberry-dac8x.dtbo \
hifiberry-dacplus.dtbo \
hifiberry-dacplus-pro.dtbo \
hifiberry-dacplus-std.dtbo \
hifiberry-dacplusadc.dtbo \
hifiberry-dacplusadcpro.dtbo \
hifiberry-dacplusdsp.dtbo \
hifiberry-dacplushd.dtbo \
hifiberry-digi.dtbo \
hifiberry-digi-pro.dtbo \
highperi.dtbo \
hy28a.dtbo \
hy28b.dtbo \
hy28b-2017.dtbo \
i-sabre-q2m.dtbo \
i2c-bcm2708.dtbo \
i2c-fan.dtbo \
i2c-gpio.dtbo \
i2c-mux.dtbo \
i2c-pwm-pca9685a.dtbo \
i2c-rtc.dtbo \
i2c-rtc-gpio.dtbo \
i2c-sensor.dtbo \
i2c0.dtbo \
i2c0-pi5.dtbo \
i2c1.dtbo \
i2c1-pi5.dtbo \
i2c2-pi5.dtbo \
i2c3.dtbo \
i2c3-pi5.dtbo \
i2c4.dtbo \
i2c5.dtbo \
i2c6.dtbo \
i2s-dac.dtbo \
i2s-gpio28-31.dtbo \
ilitek251x.dtbo \
imx219.dtbo \
imx258.dtbo \
imx290.dtbo \
imx296.dtbo \
imx327.dtbo \
imx378.dtbo \
imx462.dtbo \
imx477.dtbo \
imx519.dtbo \
imx708.dtbo \
interludeaudio-analog.dtbo \
interludeaudio-digital.dtbo \
iqaudio-codec.dtbo \
iqaudio-dac.dtbo \
iqaudio-dacplus.dtbo \
iqaudio-digi-wm8804-audio.dtbo \
iqs550.dtbo \
irs1125.dtbo \
jedec-spi-nor.dtbo \
justboom-both.dtbo \
justboom-dac.dtbo \
justboom-digi.dtbo \
ltc294x.dtbo \
max98357a.dtbo \
maxtherm.dtbo \
mbed-dac.dtbo \
mcp23017.dtbo \
mcp23s17.dtbo \
mcp2515.dtbo \
mcp2515-can0.dtbo \
mcp2515-can1.dtbo \
mcp251xfd.dtbo \
mcp3008.dtbo \
mcp3202.dtbo \
mcp342x.dtbo \
media-center.dtbo \
merus-amp.dtbo \
midi-uart0.dtbo \
midi-uart0-pi5.dtbo \
midi-uart1.dtbo \
midi-uart1-pi5.dtbo \
midi-uart2.dtbo \
midi-uart2-pi5.dtbo \
midi-uart3.dtbo \
midi-uart3-pi5.dtbo \
midi-uart4.dtbo \
midi-uart4-pi5.dtbo \
midi-uart5.dtbo \
minipitft13.dtbo \
miniuart-bt.dtbo \
mipi-dbi-spi.dtbo \
mlx90640.dtbo \
mmc.dtbo \
mz61581.dtbo \
ov2311.dtbo \
ov5647.dtbo \
ov64a40.dtbo \
ov7251.dtbo \
ov9281.dtbo \
papirus.dtbo \
pca953x.dtbo \
pcf857x.dtbo \
pcie-32bit-dma.dtbo \
pcie-32bit-dma-pi5.dtbo \
pciex1-compat-pi5.dtbo \
pibell.dtbo \
pifacedigital.dtbo \
pifi-40.dtbo \
pifi-dac-hd.dtbo \
pifi-dac-zero.dtbo \
pifi-mini-210.dtbo \
piglow.dtbo \
pineboards-hat-ai.dtbo \
piscreen.dtbo \
piscreen2r.dtbo \
pisound.dtbo \
pisound-pi5.dtbo \
pitft22.dtbo \
pitft28-capacitive.dtbo \
pitft28-resistive.dtbo \
pitft35-resistive.dtbo \
pps-gpio.dtbo \
proto-codec.dtbo \
pwm.dtbo \
pwm-2chan.dtbo \
pwm-ir-tx.dtbo \
pwm1.dtbo \
qca7000.dtbo \
qca7000-uart0.dtbo \
ramoops.dtbo \
ramoops-pi4.dtbo \
rotary-encoder.dtbo \
rpi-backlight.dtbo \
rpi-codeczero.dtbo \
rpi-dacplus.dtbo \
rpi-dacpro.dtbo \
rpi-digiampplus.dtbo \
rpi-ft5406.dtbo \
rpi-poe.dtbo \
rpi-poe-plus.dtbo \
rpi-sense.dtbo \
rpi-sense-v2.dtbo \
rpi-tv.dtbo \
rra-digidac1-wm8741-audio.dtbo \
sainsmart18.dtbo \
sc16is750-i2c.dtbo \
sc16is750-spi0.dtbo \
sc16is752-i2c.dtbo \
sc16is752-spi0.dtbo \
sc16is752-spi1.dtbo \
sdhost.dtbo \
sdio.dtbo \
sdio-pi5.dtbo \
seeed-can-fd-hat-v1.dtbo \
seeed-can-fd-hat-v2.dtbo \
sh1106-spi.dtbo \
si446x-spi0.dtbo \
smi.dtbo \
smi-dev.dtbo \
smi-nand.dtbo \
spi-gpio35-39.dtbo \
spi-gpio40-45.dtbo \
spi-rtc.dtbo \
spi0-0cs.dtbo \
spi0-1cs.dtbo \
spi0-2cs.dtbo \
spi1-1cs.dtbo \
spi1-2cs.dtbo \
spi1-3cs.dtbo \
spi2-1cs.dtbo \
spi2-1cs-pi5.dtbo \
spi2-2cs.dtbo \
spi2-2cs-pi5.dtbo \
spi2-3cs.dtbo \
spi3-1cs.dtbo \
spi3-1cs-pi5.dtbo \
spi3-2cs.dtbo \
spi3-2cs-pi5.dtbo \
spi4-1cs.dtbo \
spi4-2cs.dtbo \
spi5-1cs.dtbo \
spi5-1cs-pi5.dtbo \
spi5-2cs.dtbo \
spi5-2cs-pi5.dtbo \
spi6-1cs.dtbo \
spi6-2cs.dtbo \
ssd1306.dtbo \
ssd1306-spi.dtbo \
ssd1327-spi.dtbo \
ssd1331-spi.dtbo \
ssd1351-spi.dtbo \
sunfounder-pipower3.dtbo \
sunfounder-pironman5.dtbo \
superaudioboard.dtbo \
sx150x.dtbo \
tc358743.dtbo \
tc358743-audio.dtbo \
tinylcd35.dtbo \
tpm-slb9670.dtbo \
tpm-slb9673.dtbo \
uart0.dtbo \
uart0-pi5.dtbo \
uart1.dtbo \
uart1-pi5.dtbo \
uart2.dtbo \
uart2-pi5.dtbo \
uart3.dtbo \
uart3-pi5.dtbo \
uart4.dtbo \
uart4-pi5.dtbo \
uart5.dtbo \
udrc.dtbo \
ugreen-dabboard.dtbo \
upstream.dtbo \
upstream-pi4.dtbo \
vc4-fkms-v3d.dtbo \
vc4-fkms-v3d-pi4.dtbo \
vc4-kms-dpi-generic.dtbo \
vc4-kms-dpi-hyperpixel2r.dtbo \
vc4-kms-dpi-hyperpixel4.dtbo \
vc4-kms-dpi-hyperpixel4sq.dtbo \
vc4-kms-dpi-panel.dtbo \
vc4-kms-dsi-7inch.dtbo \
vc4-kms-dsi-generic.dtbo \
vc4-kms-dsi-ili9881-5inch.dtbo \
vc4-kms-dsi-ili9881-7inch.dtbo \
vc4-kms-dsi-lt070me05000.dtbo \
vc4-kms-dsi-lt070me05000-v2.dtbo \
vc4-kms-dsi-waveshare-panel.dtbo \
vc4-kms-kippah-7inch.dtbo \
vc4-kms-v3d.dtbo \
vc4-kms-v3d-pi4.dtbo \
vc4-kms-v3d-pi5.dtbo \
vc4-kms-vga666.dtbo \
vga666.dtbo \
vl805.dtbo \
w1-gpio.dtbo \
w1-gpio-pi5.dtbo \
w1-gpio-pullup.dtbo \
w1-gpio-pullup-pi5.dtbo \
w5500.dtbo \
watterott-display.dtbo \
waveshare-can-fd-hat-mode-a.dtbo \
waveshare-can-fd-hat-mode-b.dtbo \
wittypi.dtbo \
wm8960-soundcard.dtbo
targets += dtbs dtbs_install
targets += $(dtbo-y)
always-y := $(dtbo-y)
clean-files := *.dtbo

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More