Commit Graph

1399127 Commits

Author SHA1 Message Date
Kurt Lee
c79bf51e74 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>
2025-12-01 12:27:54 +00:00
Praveen Babu C
d80655a8e0 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
2025-12-01 12:27:54 +00:00
Phil Elwell
42b5269595 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>
2025-12-01 12:27:54 +00:00
Phil Elwell
94465976eb 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>
2025-12-01 12:27:53 +00:00
Phil Elwell
b4ad79c33c 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>
2025-12-01 12:27:53 +00:00
Phil Elwell
3da25c2720 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>
2025-12-01 12:27:53 +00:00
Phil Elwell
9b6edb95a2 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>
2025-12-01 12:27:53 +00:00
Phil Elwell
55e701da16 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>
2025-12-01 12:27:53 +00:00
Jonathan Bell
5b64bf9aab 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>
2025-12-01 12:27:53 +00:00
Jonathan Bell
ccdf596fd6 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>
2025-12-01 12:27:53 +00:00
Phil Elwell
5d37db5313 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>
2025-12-01 12:27:53 +00:00
Dave Stevenson
874021d623 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>
2025-12-01 12:27:53 +00:00
Dave Stevenson
ac27e92230 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>
2025-12-01 12:27:53 +00:00
Phil Elwell
478d1cbda9 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>
2025-12-01 12:27:53 +00:00
Kieran Bingham
60c8ae36cd 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>
2025-12-01 12:27:53 +00:00
Kieran Bingham
78c523bc6c 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>
2025-12-01 12:27:53 +00:00
Phil Elwell
2d945da912 dtc update 2025-12-01 12:27:52 +00:00
Dave Stevenson
f782fde371 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>
2025-12-01 12:27:52 +00:00
Dave Stevenson
ac1b308c4a 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>
2025-12-01 12:27:52 +00:00
Jonathan Bell
fa82142db4 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>
2025-12-01 12:27:52 +00:00
Phil Elwell
6d27d9cf3b w1: Disable kernel log spam
See: https://forums.raspberrypi.com/viewtopic.php?p=2159344

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2025-12-01 12:27:52 +00:00
Phil Elwell
3b7bcca0d3 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>
2025-12-01 12:27:52 +00:00
Nick Bulleid
9bd0b71309 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>
2025-12-01 12:27:52 +00:00
Jonathan Bell
ff165b3d4d 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>
2025-12-01 12:27:52 +00:00
Jonathan Bell
55f891307c 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>
2025-12-01 12:27:52 +00:00
Dave Stevenson
49199ee79a 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>
2025-12-01 12:27:52 +00:00
Dave Stevenson
45f8341686 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>

Fixup c91c9f257d ("fbdev: Allow client to request a particular /dev/fbN node")

We lost a line in the forward port, which meant that it always used
/dev/fb0, and complained that the sysfs nodes already existed.

Fixes: c91c9f257d ("fbdev: Allow client to request a particular /dev/fbN node")

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2025-12-01 12:27:52 +00:00
Omer Faruk Edemen
5526ee14ca media: i2c: ov9282: Add external FSIN trigger snapshot mode
This patch adds support for external FSIN-triggered snapshot mode
to the OmniVision OV9282 sensor driver. It enables frame capture
synchronized with an external hardware trigger signal.

Signed-off-by: Omer Faruk Edemen <ofedemen@lectrontech.com>
2025-12-01 12:27:52 +00:00
Dave Stevenson
3c1835d0a2 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>
2025-12-01 12:27:51 +00:00
Dom Cobley
1581838895 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>
2025-12-01 12:27:51 +00:00
Dom Cobley
c2d158185c 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>
2025-12-01 12:27:51 +00:00
Dom Cobley
edd49bcc57 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>
2025-12-01 12:27:51 +00:00
Nick Hollinghurst
80b76deecd 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>

iommu: bcm2712-iommu: Add locking; fix address offset; tidy

- Now using spin_lock_irqsave in map, unmap, sync and iova_to_phys.
- Simplify bounds checks as all allocations should be in aperture.
- Use iommu_iotlb_gather_add_range(); NB gather range is inclusive.
- Fix missing address offset in bcm2712_iommu_sync_all.

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

iommu: bcm2712-iommu: Allocate tables on demand; add OF properties

Allocate space for level-2 IOMMU translation tables on demand.
This should save memory in most cases but means that map_pages()
can now fail with -ENOMEM. Unused pages are retained for re-use.

Move all dma_sync* calls into map and unmap functions rather than
batching them up. This makes it easier to ensure they are safely
balanced, now that the tables are held as separate pages.

Add OF properties to override the default aperture size (2GB)
and base address (40GB); this doesn't include any dma-iova-offset.

Various tidy-ups. The internal representation of aperture limits
*does* include dma_iova_offset, as that is more commonly useful.
Clarify the distinction between Linux pages and IOMMU table pages.
Fix wrong definition of MMMU_CTRL_PT_INVALID_EN flag.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
2025-12-01 12:27:51 +00:00
Dom Cobley
ff1c471d44 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>
2025-12-01 12:27:51 +00:00
Maxime Ripard
d2df241c9c 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>
2025-12-01 12:27:51 +00:00
Phil Elwell
e1709f8ba7 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>
2025-12-01 12:27:51 +00:00
Iago Toral Quiroga
58548f5a9e dt-bindings: gpu: v3d: Add BCM2712 to compatibility list 2025-12-01 12:27:51 +00:00
Nick Hollinghurst
4f7f6ba8b9 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>
2025-12-01 12:27:51 +00:00
Nick Hollinghurst
869c93c56d 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>
2025-12-01 12:27:51 +00:00
Phil Elwell
f713bcde6a 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>
2025-12-01 12:27:51 +00:00
Phil Elwell
6fb964cc5c 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>
2025-12-01 12:27:51 +00:00
Phil Elwell
f176198aa6 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>
2025-12-01 12:27:50 +00:00
Phil Elwell
a67b7bcf85 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>
2025-12-01 12:27:50 +00:00
Dom Cobley
55c848b503 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>
2025-12-01 12:27:50 +00:00
Nick Hollinghurst
2d56bebc24 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>

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>

drm: rp1: rp1-vec: Add DRM_FORMAT_ARGB8888 and DRM_FORMAT_ABGR8888

Android requires this.
As the underlying hardware doesn't support alpha blending,
we ignore the alpha value.

Signed-off-by: Jan Kehren <jan.kehren@emteria.com>

drivers: drm: rp1-vec: Increase width limit, for PAL 16:9 @ 18MHz

There was no technical reason for the DRM mode's width limit of 848;
increase it to 960 (720*18MHz/13.5MHz) to support ~square pixels on
16:9 screens. Tweak the PAL active window to start slightly earlier.
(The maximum number of visible columns at 18MHz is about 942.)

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

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>

drm/rp1-vec: Run DRM default client setup

Call drm_client_setup() to run the kernel's default client setup
for DRM. Set fbdev_probe in struct drm_driver, so that the client
setup can start the common fbdev client.

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

drm: rp1: Enable VEC->GPIO output; cosmetic change to registers

In the VEC driver, enable mapping VEC (not DPI) to DPI GPIOs.
This is to support VEC output over GPIO on Raspberry Pi CM5.
It is harmless as DPI and VEC could not be used concurrently,
and the output is anyway conditional on pinctrl.

Also, tweak the style of VIDEO_OUT_CFG register definitions
(in both DPI and VEC drivers) to be more Linux-friendly.

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

drm: rp1: rp1-vec: Support 60fps in interlaced modes; other tweaks

To work around the 30fps buffer-flip rate limit when using VEC's
"native" interlaced modes, switch to sending individual fields
to the VEC BE, using an ISR to flip between fields.

When the TV mode is NTSC, change advertised progressive modes to
have 263 total lines; this ameliorates colour artifacts, although
it reduces the frame rate slightly from 60.05Hz to 59.83Hz.
Progressive modes with 262 lines remain supported.

Fix an error in equalising pulse configuration for PAL-M/PAL60.

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

Fixup rp1-vec Kconfig
2025-12-01 12:27:50 +00:00
Nick Hollinghurst
138f50bc53 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>

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>

drm: rp1: rp1-dpi: Add DRM_FORMAT_ARGB8888 and DRM_FORMAT_ABGR8888

Android requires this.
As the underlying hardware doesn't support alpha blending,
we ignore the alpha value.

Signed-off-by: Jan Kehren <jan.kehren@emteria.com>

drm: rp1: rp1-dpi: Add interlaced modes and PIO program to fix VSYNC

Implement interlaced modes by wobbling the base pointer and VFP width
for every field. This results in correct pixels but incorrect VSYNC.

Now use PIO to generate a fixed-up VSYNC by sampling DE and HSYNC.
This requires DPI's DE output to be mapped to GPIO1, which we check.

When DE is not exposed, the internal fixup is disabled. VSYNC/GPIO2
becomes a modified signal, designed to help an external device or
PIO program synthesize CSYNC or VSYNC.

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

drm: rp1: rp1-dpi: Fix optional dependency on RP1_PIO

Add optional dependency to Kconfig, and conditionally compile
PIO-dependent code. Add a mode validation function to reject
interlaced modes when RP1_PIO is not present.

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

drm: rp1: rp1-dpi: Add "rgb_order" property (to match VC4 DPI)

As on VC4, the OF property overrides the order implied by media
bus format. Only 4 of the 6 possible orders are supported. New
add-on hardware designs should not rely on this "legacy" feature.

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

drm/rp1: DPI interlace: Improve precision of PIO-generated VSYNC

Instead of trying to minimize the delay between seeing HSYNC edge
and asserting VSYNC, try to predict the next HSYNC edge precisely.
This eliminates the round-trip delay but introduces mode-dependent
rounding error. HSYNC->VSYNC lag reduced from ~30ns to -5ns..+10ns
(plus up to 5ns synchronization jitter as before).

This may benefit e.g. SCART HATs, particularly those that generate
Composite Sync using a XNOR gate.

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

drm/rp1-dpi: Run DRM default client setup

Call drm_client_setup() to run the kernel's default client setup
for DRM. Set fbdev_probe in struct drm_driver, so that the client
setup can start the common fbdev client.

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

drm/rp1/rp1_dpi: Move Composite Sync generation into the kernel

Move RP1 DPI's PIO-assisted Composite Sync generation code,
previously released as a separate utility, into the kernel driver.
There are 3 variants for progressive, generic interlaced and TV-
style interlaced CSync, alongside the existing VSync fixup.

Check that all of GPIOs 1-3 are mapped to DPI, so PIO won't try
to snoop on a missing output, or override another device's pins.

Add "force_csync" module parameter, for convenience of testing,
as few tools can set DRM_MODE_FLAG_CSYNC.

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

drm: rp1: Enable VEC->GPIO output; cosmetic change to registers

In the VEC driver, enable mapping VEC (not DPI) to DPI GPIOs.
This is to support VEC output over GPIO on Raspberry Pi CM5.
It is harmless as DPI and VEC could not be used concurrently,
and the output is anyway conditional on pinctrl.

Also, tweak the style of VIDEO_OUT_CFG register definitions
(in both DPI and VEC drivers) to be more Linux-friendly.

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

Fixup rp1-dpi Kconfig
2025-12-01 12:27:50 +00:00
Nick Hollinghurst
15e5e41a48 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>

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>

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>

drm: rp1: rp1-dsi: Add DRM_FORMAT_ARGB8888 and DRM_FORMAT_ABGR8888

Android requires this.
As the underlying hardware doesn't support alpha blending,
we ignore the alpha value.

Signed-off-by: Jan Kehren <jan.kehren@emteria.com>

drivers: drm: rp1-dsi: Implement more DSI options and flags

Now implementing:
- Per-command selection of LP or HS for commands (previously LP)
- EoTp transmission option (previously EoTp was always disabled)
- Non-continuous clock option (previously always continuous)
- Per-command enabling of ACK request (in command mode only)

Make a plausible (and possibly correct) attempt to measure the
longest LP command that will fit into vertical blanking lines.

DON'T set both "Burst Mode" and "Sync Events" flags together.
This is redundant in the standard IP; in this RP1 variant it
would enable Sync Pulses but may break with some video timings.

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

drm/rp1-dsi: Run DRM default client setup

Call drm_client_setup() to run the kernel's default client setup
for DRM. Set fbdev_probe in struct drm_driver, so that the client
setup can start the common fbdev client.

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

drm/rp1: rp1-dsi: Put all register defines into order

Put particularly the PHY registers into order, bitmasks
defined alongside the registers, and Use tabs for indentation.

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

drm/rp1: rp1-dsi: Remove all the unused boilerplate register defines

There was lots of register definition information dumped from
the some source into the driver but unused. Remove it, and
format the remaining lines according to the Linux kernel coding
style.

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

drm/rp1: rp1-dsi: Add support for inverting lane polarities

The D-PHY on RP1 support lane polarity swapping, and there
is a standard device tree mechanism for configuring this,
so tie the two together.

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

Fixup rp1-dsi driver
2025-12-01 12:27:50 +00:00
Phil Elwell
294e80ba56 pwm: Add support for RP1 PWM
Add a driver for the RP1 PWM block.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2025-12-01 12:27:50 +00:00
Phil Elwell
5599a4ac41 spi: dw: Handle combined tx and rx messages
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2025-12-01 12:27:50 +00:00
Phil Elwell
1b69e3a440 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>
2025-12-01 12:27:50 +00:00