Compare commits

...
Author SHA1 Message Date
Doron Behar ea392e9593 Merge pull request #2137 from JamieMagee/raspberry-pi-kernel-6.18.65
raspberry-pi/common/kernel: 6.18.60-stable_20261103 -> 6.18.65-stable_20261127
2026-11-29 13:17:06 +00:00
Jamie Magee 05f938961e raspberry-pi/common/kernel: 6.18.60-stable_20261103 -> 6.18.65-stable_20261127 2026-11-28 21:16:03 -08:00
Jörg Thalheim ec39df522f Merge pull request #2134 from JamieMagee/spacemit-k3-initrd
spacemit/k3-pico-itx: remove obsolete initrd option
2026-11-26 10:58:14 +00:00
Jamie Magee 9f495b5440 spacemit/k3-pico-itx: remove obsolete initrd option 2026-11-25 20:14:52 -08:00
Jörg Thalheim 97a30ee097 Merge pull request #1934 from soopyc/apple-t2-updates
apple/t2: 7.0 -> 7.2; replace t2-better-audio with ucm config
2026-11-24 19:49:42 +00:00
Doron Behar ff49dbf395 Merge pull request #2118 from JamieMagee/raspberry-pi-split/docs
raspberry-pi: remove generic overlay documentation
2026-11-24 07:26:35 +00:00
Jamie Magee 7e9d8b97c5 raspberry-pi: warn before switching to firmware device trees 2026-11-23 14:14:58 -08:00
Jamie Magee 5c1804b403 raspberry-pi: explain config.txt default overrides 2026-11-23 14:14:58 -08:00
Jamie Magee 428be44435 raspberry-pi: avoid USB setup and serial-console pins in overlay examples 2026-11-22 14:46:16 -08:00
Jamie Magee 54987e6989 raspberry-pi: remove generic PoE HAT documentation 2026-11-20 13:47:33 -08:00
Doron Behar 3347596611 Merge pull request #2119 from doronbehar/1line1sentence
raspberry-pi/README.md: adhere to the 1 line per sentence rule used in Nixpkgs
2026-11-18 16:19:06 +00:00
Doron Behar fb63a8c3c8 raspberry-pi/README.md: adhere to the 1 line per sentence rule used in Nixpkgs 2026-11-18 11:00:34 +02:00
Doron Behar d9da8426d8 Merge pull request #2083 from JamieMagee/raspberry-pi-split/audio
raspberry-pi: migrate audio to firmware configuration
2026-11-17 09:08:41 +00:00
Jamie Magee e2035d2e51 raspberry-pi: migrate audio to firmware configuration 2026-11-16 12:18:18 -08:00
Sandro eb3c90bd71 Merge pull request #2038 from 920anish/acer-nitro-5-an515-55
Add configuration for Acer Nitro 5 (AN515-55)
2026-11-13 19:17:31 +00:00
Jörg Thalheim 75206a855c Merge pull request #1983 from rtucek/gate-yt6801-for-older-kernels
TUXEDO: load Motorcomm YT6801 driver only if kernel is below v7.0
2026-11-13 10:54:27 +00:00
Doron Behar b6ca87f78e Merge pull request #2106 from JamieMagee/raspberry-pi-fix-u128
raspberry-pi: fix kernel build with Linux 7.3 headers
2026-11-11 19:36:45 +00:00
Jamie Magee 73ff92fe11 raspberry-pi: fix kernel build with Linux 7.3 headers 2026-11-11 11:19:26 -08:00
Doron Behar 37ba750aba Merge pull request #2105 from JamieMagee/raspberry-pi-kernel-6.18.60
raspberry-pi: update kernel to 6.18.60
2026-11-11 12:28:01 +00:00
Jamie Magee 4f3084df4c raspberry-pi/common/kernel: 6.18.50-stable_20260911 -> 6.18.60-stable_20261103 2026-11-10 10:46:50 -08:00
Jörg Thalheim 919c16cf46 Merge pull request #2091 from Alexthemediocre/surface-7.3
[microsoft/surface] Add linux-surface 7.3 kernel
2026-11-09 11:12:03 +00:00
Alexthemediocre ecdce73e8e Make surface "longterm" kernel actually LTS
Downgrades surface "longterm" from 6.19.8 (not LTS) to 6.18.60 (LTS)
2026-11-08 11:17:00 -05:00
Alexthemediocre f196c3a339 Add linux-surface 7.3 kernel 2026-11-08 10:47:05 -05:00
Jörg Thalheim 1a8ff4f57f Merge pull request #2086 from BerriJ/master
tuxedo/infinitybook: fix conditional tuxedo-drivers.enable=true;
2026-11-07 11:36:55 +00:00
Jörg Thalheim d645c71a58 Merge pull request #2081 from ScatteredCognition/dell-latitude-3530
dell/latitude/3530: init
2026-11-05 09:42:57 +00:00
Jörg Thalheim f73e0ac5c7 Merge pull request #2005 from toastal/HN7306EA-7.2
asus/proart/px13/hn7306eac: drop patches @ Linux 7.2
2026-11-05 09:42:33 +00:00
Dr. Jonathan Berrisch 11922fe5cc tuxedo/infinitybook: fix conditional tuxedo-drivers.enable=true; 2026-10-30 11:47:26 +01:00
Doron Behar 04c6b94fa1 Merge pull request #2073 from Cryolitia-Forks/rpi1-support
raspberry-pi/1: Add Raspberry Pi 1 support
2026-10-30 10:18:29 +00:00
Sandro b6754c901c Merge pull request #2067 from dmfrpro/fix-typo
asus/zephyrus/shared: fix param typo
2026-10-29 01:07:43 +00:00
920anish d256d94d78 Add configuration for Acer Nitro 5 (AN515-55) 2026-10-27 20:07:25 +05:45
Doron Behar 8ba09466dc Merge pull request #2084 from JamieMagee/raspberry-pi-split/pwm0
raspberry-pi: migrate PWM0 to its firmware overlay
2026-10-26 22:47:27 +00:00
Jamie Magee 6075dd2edd raspberry-pi: clarify PWM0 migration guidance 2026-10-25 15:18:55 -07:00
Jamie Magee 5d01b9f343 raspberry-pi: migrate PWM0 to its firmware overlay 2026-10-24 17:08:22 -07:00
Faeiz Mahrus 0cc5d9231c dell/latitude/3530: added README.md 2026-10-23 02:55:30 +06:00
Faeiz Mahrus 2dd7f53e50 dell/latitude/3530: init 2026-10-23 02:41:23 +06:00
Jörg Thalheim 1b418b8f20 Merge pull request #1926 from liberodark/bpi-sm10
bananapi/bpi-sm10: init
2026-10-22 19:28:46 +00:00
liberodark 4188fc24f4 bananapi/bpi-sm10: init 2026-10-22 19:05:01 +02:00
Rudolf Tucek c63b8f1c8c Merge remote-tracking branch 'upstream/master' into gate-yt6801-for-older-kernels
# By Jamie Magee (9) and others
# Via GitHub (29) and liberodark (1)
* upstream/master: (41 commits)
  spacemit/k3-pico-itx: Bump to kernel 7.3
  lenovo/thinkpad/x1/yoga/8th-gen: add ipu6 camera variant
  mnt/reform: output formatted nix code
  framework/16-inch: Remove libinput quirk
  raspberry-pi/firmware: stage vendor overlays independent of dtbSrc
  feat(gpd): enable ryzenadj PPT control on pocket-4 and win-mini 2024
  fix(gpd): de-dupe hardware.gpd.ppt module between duo and win-max-2
  thinkpad/x1-extreme/gen2: fix trackpad press events
  thinkpad/x1-extreme/gen2: improve CPU configuration
  build(deps): bump nixos-stable from `8eeec93` to `4c78701` in /tests
  build(deps): bump nixos-unstable-small in /tests
  build(deps): bump nixpkgs from `3497aa5` to `b1b8759`
  codeowners: add doronbehar to raspberry-pi
  raspberrypiWirelessFirmware: 0-unstable-2026-03-21 -> 0-unstable-2026-07-10
  raspberry-pi/common/kernel: 6.18.39-stable_20260724 -> 6.18.50-stable_20260911
  pc/laptop: do not enable tlp if tuned is enabled
  raspberry-pi: remove DigiAMP+ module
  raspberry-pi/2: Remove outdated README.org
  mnt/reform: convert update patches to derivation
  raspberry-pi: remove DWC2 module
  ...
2026-10-21 22:43:29 +02:00
Jörg Thalheim efb6d0d5e2 Merge pull request #2046 from liberodark/k73
spacemit/k3-pico-itx: Bump to kernel 7.3
2026-10-20 10:10:56 +00:00
liberodark 2736ebd70c spacemit/k3-pico-itx: Bump to kernel 7.3 2026-10-19 10:43:34 +02:00
Cryolitia PukNgae 11cefffd51 raspberry-pi/1: Add Raspberry Pi 1 support
The Raspberry Pi SD installer remains in nixpkgs, but its
sd-image-raspberrypi.nix configuration still selects
linuxKernel.packages.linux_rpi1. Commit b1c58b82b98f ("linux-rpi*: remove")
removed that kernel from nixpkgs, leaving the installer unable to
evaluate. Move the Pi 1 image configuration to nixos-hardware alongside
the vendor kernel.

The shared vendor kernel builder accepts rpiVersion = 1, but there is no
corresponding board profile. Add an ARMv6 profile with 32-bit U-Boot and
the shared firmware installer. Use the legacy boot and initrd settings
without the graphics defaults for newer boards. Provide SD-image and
installer modules adapted from the nixpkgs image, and exclude the
profile from checks without ARMv6 coverage.

The image has been cross-compiled but has not been tested on a board, as
no Pi 1 hardware was available.

Link: https://github.com/NixOS/nixpkgs/blob/b1c58b82b98ff287751c78ee2b96dc5c4384e3b3/nixos/modules/installer/sd-card/sd-image-raspberrypi.nix#L20
Link: https://github.com/NixOS/nixpkgs/commit/b1c58b82b98ff287751c78ee2b96dc5c4384e3b3
Signed-off-by: Cryolitia PukNgae <cryolitia@mercallure.com>
2026-10-19 16:01:58 +08:00
Cryolitia PukNgae 9d17af9966 raspberry-pi: Disable unused Pi 1 kernel modules
Nixpkgs enables optional kernel modules by default, including the RP1 PWM
and camera drivers and the DesignWare I2C driver. The ARM32 build fails in
modpost when these drivers reference __aeabi_uldivmod and __aeabi_ldivmod,
which are unavailable to kernel modules.

Disable the affected drivers when rpiVersion is 1. The Pi 1 uses BCM2835
peripherals and has no RP1 or DesignWare I2C controller, so these drivers
are not needed. The BCM2835 PWM and camera drivers remain enabled.

OpenWrt excludes the DesignWare I2C core on its older 32-bit Raspberry Pi
targets for the same reason.

Link: https://github.com/openwrt/openwrt/commit/11de7145c95259899d8880f4d53f933c591fbd00
Link: https://github.com/NixOS/nixpkgs/issues/464515
Signed-off-by: Cryolitia PukNgae <cryolitia@mercallure.com>
2026-10-19 16:01:18 +08:00
dmfrpro 2e1a5e1d39 asus/zephyrus/shared: fix param typo
Signed-off-by: dmfrpro <dmfr2021y@gmail.com>
2026-10-12 03:23:44 +03:00
Sandro 60a624466c Merge pull request #2057 from bittner/lenovo-x1-yoga-8th-gen-ipu6
lenovo/thinkpad/x1/yoga/8th-gen: add ipu6 camera variant
2026-10-11 12:32:43 +00:00
Peter Bittner a82e8dfe53 lenovo/thinkpad/x1/yoga/8th-gen: add ipu6 camera variant
The X1 Yoga Gen 8 ships with either a USB camera or a MIPI sensor behind
Intel's IPU6. The MIPI camera only exposes raw Bayer nodes, so
applications that speak plain V4L2, such as Zoom, find no camera. The
new ipu6 profile enables hardware.ipu6 for the Raptor Lake platform, and
a README explains how to tell the two cameras apart. The base profile
stays as it is, because enabling IPU6 there would pull Intel's
proprietary camera stack onto machines with the USB camera.
2026-10-10 01:10:49 +02:00
·𐑑𐑴𐑕𐑑𐑩𐑤 dcb92f1820 asus/proart/px13/hn7306eac: drop patches @ Linux 7.2
tas2783 patches appear to be upstreamed finally. Move assertion to the
top-level for Linux 7.0 at minimum.
2026-10-08 00:14:17 +07:00
Sophie Cheung 7082b48443 apple/t2: replace t2-better-audio with alsa ucm config
Signed-off-by: Sophie Cheung <git@soopy.moe>
2026-10-07 20:05:22 +08:00
Sophie Cheung bd9987b748 apple/t2: sort and add missing kernel configs
Signed-off-by: Sophie Cheung <git@soopy.moe>
2026-10-07 20:05:20 +08:00
Sophie Cheung 701eb9f269 apple/t2: pin kernel releases; upgrade version and patches
disconnect kernel versions from nixpkgs, which should avoid breaking users'
config when nixpkgs has a new version and some patches are incompatible,
and when a PR updating the patches are still waiting to be merged, like
in #2027.

Signed-off-by: Sophie Cheung <git@soopy.moe>
2026-10-07 20:05:18 +08:00
Adam Dinwoodie 4bc63156b1 Merge pull request #2056 from FrameworkComputer/framework-laptop16-removelibinput
framework/16-inch: Remove libinput quirk
2026-10-07 11:49:48 +00:00
Doron Behar 31cc5f4d9b Merge pull request #2044 from hatch01/fix-vendor-overlays
raspberry-pi/firmware: stage vendor overlays independent of dtbSrc
2026-10-04 15:36:41 +00:00
Doron Behar fd402c5c9f Merge pull request #2017 from leifhelm/fix-search
mnt/reform: convert update patches to derivation
2026-10-04 15:28:51 +00:00
Jakob Leifhelm bc8333d8ed mnt/reform: output formatted nix code 2026-10-04 15:53:14 +02:00
Ramses 0953bb1a60 Merge pull request #1992 from r-vdp/amdgpu-dcdebugmask-options
common/gpu/amd: add hardware.amdgpu.dcDebugMask options
2026-10-02 13:35:22 +00:00
Sandro 06f9ecaea5 Merge pull request #2054 from shymega/shymega-fix/de-dupe-gpd-ppt-duo
gpd: de-dupe hardware.gpd.ppt module across AMD devices
2026-09-29 23:00:12 +00:00
Daniel Schaefer 319435ef08 framework/16-inch: Remove libinput quirk
We have been on the libinput version that has this for two years now
858867aea9ad9c4b097948a97a147354185700d5

Signed-off-by: Daniel Schaefer <dhs@frame.work>
2026-09-27 17:34:58 +02:00
eymeric 34fef44f65 raspberry-pi/firmware: stage vendor overlays independent of dtbSrc
install-rpi-firmware picks a single $dtbSrc for both the base .dtb
files and the overlays/ directory staged onto the firmware partition.
When useGenerationDeviceTree = true, $dtbSrc becomes
/run/current-system/dtbs, the NixOS generation's device-tree output.
That directory never has an overlays/ subdirectory unless the
generation was itself built with hardware.deviceTree.overlays, so the
"stage overlays from $dtbSrc/overlays" step silently does nothing, and
the stale-file prune then deletes any vendor .dtbo already sitting in
the firmware partition's overlays/ from a previous run.

In practice this makes
hardware.raspberry-pi.configtxt.deviceTreeOverlays
non-functional whenever useGenerationDeviceTree = true is also set - a
combination that legitimately occurs, e.g. a Pi 4 profile needing
apply-overlays-dtmerge/tc358743 (which requires the generation's
dtmerge-produced dtb as the base, since
boot.loader.generic-extlinux-compatible.useGenerationDeviceTree is
usually false with U-Boot enabled) together with a stock overlay like
dwc2 applied by the firmware from config.txt.

Stage vendor overlays from $firmwareBoot/overlays unconditionally,
since hardware.raspberry-pi.configtxt.deviceTreeOverlays entries are
matched against that vendor filename set regardless of where the base
dtb comes from. Additionally stage $dtbSrc/overlays when it differs
from $firmwareBoot and exists, so overlays produced by
hardware.deviceTree.overlays on the generation side still take
precedence over same-named vendor ones.

Related: #1946

Assisted-by: Claude sonnet 5 high
2026-09-27 11:00:58 +02:00
Dom Rodriguez d55480c9ac feat(gpd): enable ryzenadj PPT control on pocket-4 and win-mini 2024
Both are AMD-based GPD devices that didn't wire up the shared
hardware.gpd.ppt module.
2026-09-26 20:46:19 +01:00
Dom Rodriguez c21024523e fix(gpd): de-dupe hardware.gpd.ppt module between duo and win-max-2
Both devices defined their own copy of options.hardware.gpd.ppt, which
collides when every module is imported together (breaks
search.nuschtos.de). Move the shared module to gpd/ppt.nix and have
both devices import it.
2026-09-26 20:46:14 +01:00
Jörg Thalheim 30d48a0ec6 Merge pull request #1524 from shymega/add-gpd-duo
gpd/duo: init GPD Duo profile
2026-09-25 07:39:08 +00:00
Robert Helgesson 9ebcb77667 Merge pull request #1905 from kraker/lenovo-thinkpad-p1-nvidia
Add support for ThinkPad P1 Gen 5 with Intel and Nvidia GPUs
2026-09-21 08:09:32 +00:00
Robert Helgesson ee23a4a68a Merge pull request #1933 from mkorje/improve
apple/t2: improve firmware extraction
2026-09-21 06:53:39 +00:00
Robert Helgesson f426ed6c7a Merge pull request #2000 from panchoh/fix/nuc8
intel/nuc/8i7beh: add coffee-lake intel gpu, pc, sdd imports
2026-09-21 06:52:46 +00:00
Robert Helgesson 416ac5449a Merge pull request #1720 from rycee/x1-extreme-gen2-fixes
Minor Lenovo X1 Extreme Gen2 fixes
2026-09-21 06:51:56 +00:00
Robert Helgesson 2326b904ef thinkpad/x1-extreme/gen2: fix trackpad press events 2026-09-20 10:51:46 +02:00
Robert Helgesson 8ff87fffcf thinkpad/x1-extreme/gen2: improve CPU configuration
Specifically, explicitly configure for coffee-lake CPU.
2026-09-20 10:51:45 +02:00
Jörg Thalheim b2d7d02644 Merge pull request #2039 from NixOS/dependabot/nix/nixpkgs-b1b8759
build(deps): bump nixpkgs from `3497aa5` to `b1b8759`
2026-09-18 17:24:10 +00:00
Jörg Thalheim 5470f16efe Merge pull request #2040 from NixOS/dependabot/nix/tests/nixos-unstable-small-bc071da
build(deps): bump nixos-unstable-small from `d4a57f1` to `bc071da` in /tests
2026-09-18 17:24:03 +00:00
Jörg Thalheim 51c23b5c14 Merge pull request #2041 from NixOS/dependabot/nix/tests/nixos-stable-4c78701
build(deps): bump nixos-stable from `8eeec93` to `4c78701` in /tests
2026-09-18 17:23:57 +00:00
dependabot[bot] 0d5773cd29 build(deps): bump nixos-stable from 8eeec93 to 4c78701 in /tests
Bumps [nixos-stable](https://github.com/NixOS/nixpkgs) from `8eeec93` to `4c78701`.
- [Commits](https://github.com/NixOS/nixpkgs/commits)

---
updated-dependencies:
- dependency-name: nixos-stable
  dependency-version: 4c7870105e7f1fdf9c48688c8d7efc21abf0688a
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-17 02:06:43 +00:00
dependabot[bot] a6a3926fb0 build(deps): bump nixos-unstable-small in /tests
Bumps [nixos-unstable-small](https://github.com/NixOS/nixpkgs) from `d4a57f1` to `bc071da`.
- [Commits](https://github.com/NixOS/nixpkgs/commits)

---
updated-dependencies:
- dependency-name: nixos-unstable-small
  dependency-version: bc071daf4c377dd821398672fafe269d5c654ce8
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-17 02:06:28 +00:00
dependabot[bot] 8d1085c662 build(deps): bump nixpkgs from 3497aa5 to b1b8759
Bumps [nixpkgs](https://github.com/NixOS/nixpkgs) from `3497aa5` to `b1b8759`.
- [Commits](https://github.com/NixOS/nixpkgs/commits)

---
updated-dependencies:
- dependency-name: nixpkgs
  dependency-version: b1b875982b17dabde9b4a37f3e229e74913e6db3
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-17 02:06:10 +00:00
Robert Helgesson c9b56a2497 Merge pull request #1858 from Stebalien/steb/fix-framework-audio-priorities
framework/13-inch: fix enhanced audio device priority
2026-09-16 18:35:20 +00:00
Doron Behar 9b881d7df9 Merge pull request #2035 from JamieMagee/raspberry-pi/stable-20260911
raspberry-pi: update kernel and wireless firmware
2026-09-16 10:08:36 +00:00
Doron Behar d40fd26f32 Merge pull request #2018 from JamieMagee/codeowners-raspberry-pi
codeowners: add doronbehar to raspberry-pi
2026-09-14 20:30:14 +00:00
Jamie Magee a2da909d03 codeowners: add doronbehar to raspberry-pi 2026-09-14 10:54:48 -07:00
Jamie Magee 9e57f21b40 raspberrypiWirelessFirmware: 0-unstable-2026-03-21 -> 0-unstable-2026-07-10 2026-09-11 15:10:39 -07:00
Jamie Magee d9d31dfb5e raspberry-pi/common/kernel: 6.18.39-stable_20260724 -> 6.18.50-stable_20260911 2026-09-11 15:10:39 -07:00
Sandro 24cfdc1f93 Merge pull request #2030 from thiagokokada/support-tuned
pc/laptop: do not enable tlp if tuned is enabled
2026-09-11 11:47:51 +00:00
Thiago Kenji Okada ed7ca8ec97 pc/laptop: do not enable tlp if tuned is enabled
TuneD is a maintained alternative for power-profile-daemon. If the user
manually enables it we should not try to enable TLP, otherwise they will
conflict with each other.
2026-09-09 20:37:12 +01:00
Doron Behar 83bbc89512 Merge pull request #2028 from doronbehar/no-RPI2-README.org
raspberry-pi/2: Remove outdated README.org
2026-09-09 08:33:16 +00:00
Doron Behar 62173785b9 Merge pull request #2019 from JamieMagee/raspberry-pi-digiamp-configtxt
raspberry-pi: remove DigiAMP+ module
2026-09-08 09:35:36 +00:00
Jamie Magee db65e8d432 raspberry-pi: remove DigiAMP+ module 2026-09-07 20:48:46 -07:00
Doron Behar dd2543c4eb raspberry-pi/2: Remove outdated README.org
Incorrect since #1947
2026-09-06 01:25:46 +03:00
Jakob Leifhelm 5ad14a9e0c mnt/reform: convert update patches to derivation 2026-09-02 18:08:05 +02:00
Doron Behar 44d95795ee Merge pull request #2012 from JamieMagee/raspberry-pi-dwc2-configtxt
raspberry-pi: remove DWC2 module
2026-09-02 07:47:42 +00:00
Jamie Magee 02545c60be raspberry-pi: remove DWC2 module 2026-09-01 16:17:21 -07:00
Doron Behar dc3f0cfde2 Merge pull request #1991 from JamieMagee/raspberry-pi-poe-overlays
raspberry-pi: migrate PoE HATs to config.txt overlays
2026-08-29 23:00:18 +00:00
Jamie Magee 7fcbbc78c2 raspberry-pi: migrate PoE HATs to config.txt overlays 2026-08-30 01:41:17 +03:00
pancho horrillo 7f0552abed intel/nuc/8i7beh: add pc ssd imports 2026-08-20 21:14:23 +02:00
pancho horrillo f5cda04f93 intel/nuc/8i7beh: use coffee-lake cpu config 2026-08-20 21:14:10 +02:00
figsoda 0471accf8d Merge pull request #1995 from lmb/p14s-camera
lenovo p14s amd gen6: add camera suspend quirk
2026-08-19 13:01:06 +00:00
Jörg Thalheim e8a8bfbbfa Merge pull request #1956 from liberodark/k3_mainline
spacemit/k3-pico-itx: move to mainline kernel
2026-08-19 07:56:10 +00:00
Lorenz Bauer 308e4f4c0d lenovo p14s amd gen6: add camera suspend quirk 2026-08-18 14:14:15 +00:00
liberodark 8ad652f9c9 spacemit/k3-pico-itx: move to mainline kernel 2026-08-17 12:51:44 +02:00
r-vdp 9408ef97db common/gpu/amd: add hardware.amdgpu.dcDebugMask options
This allows to combine several such options to get the right
hex value without any repeated kernel params.
Before this, the framework AI 300 got both 0x10 and 0x410 on
the cmdline with the order depending on the module system eval
order.

This also allows users to re-enable PSR on framework machines.
2026-08-17 10:48:17 +02:00
Doron Behar ff17823245 Merge pull request #1947 from JamieMagee/raspberry-pi-configtxt-overlays
raspberry-pi: add ordered config.txt overlays
2026-08-16 08:07:12 +00:00
Sandro 2dda192987 Merge pull request #1964 from colemickens/colemickens/k3-cross
k3-pico-itx: fix sdcard cross-build
2026-08-14 14:21:38 +00:00
Doron Behar 3e7edd9afe Merge pull request #1963 from JamieMagee/raspberry-pi/wireless-firmware
raspberry-pi: add wireless firmware to Pi 3 and 5
2026-08-12 10:02:55 +00:00
Doron Behar 6ed13b1d88 Merge pull request #1986 from JamieMagee/raspberry-pi-kernel
raspberry-pi/common/kernel: 6.18.34-stable_20260609 -> 6.18.39-stable_20260724
2026-08-11 08:30:54 +00:00
Jamie Magee b99aca5913 raspberry-pi/common/kernel: 6.18.34-stable_20260609 -> 6.18.39-stable_20260724 2026-08-10 16:25:50 -07:00
Rudolf Tucek a77eb1da40 Apply conditional kernel loading to other devices too 2026-08-09 01:30:25 +02:00
Rudolf Tucek a8e9cb2bc3 Load Motorcomm YT6801 only if kernel is below v7.0
TUXEDO used to recommend to install the Motorcomm YT6801 driver
manually, unless using one of their WebFAI-supported distributions.[^1]

However, starting with version v7.0[^2], the kernel has first-class
supported for the driver.

It's worth pointing out, that users may still manually apply
`linuxKernel.packages.*.yt6801` in order to apply the external kernel
module, supplied by the vendor directly.[^3]

[^1] https://www.tuxedocomputers.com/en/Motorcomm-YT6801-txtmotorcomm-yt6801-paket.tuxedo
[^2] https://github.com/torvalds/linux/commit/02ff155ea2812ea25a086665522fd4fa196ef0ce
[^3] https://github.com/NixOS/nixpkgs/blob/nixos-26.05/pkgs/os-specific/linux/yt6801/default.nix
2026-08-09 00:35:05 +02:00
Jamie Magee 7aefd9ab01 raspberry-pi/common: add ordered config.txt device tree overlays 2026-08-07 10:28:35 +03:00
Doron Behar 89c9653dcf raspberry-pi/common: remove builtins. redundent prelude to abort 2026-08-07 10:24:16 +03:00
Doron Behar 6ca00f6509 raspberry-pi/common: simplify a bit the recurse function 2026-08-07 10:23:28 +03:00
Doron Behar 5fbc0ff5d2 raspberry-pi/common: avoid with lib.types; in settings definition 2026-08-07 10:20:47 +03:00
Jamie Magee a5d06b9c82 raspberry-pi: add wireless firmware to Pi 3 and 5 2026-08-05 21:38:09 -07:00
Logan RawlinsandDom Rodriguez cf3de37ade gpd/duo: init GPD Duo profile
- Fix boot screen invertion.
- Add audio fixes for the Framework 13, given a shared chipset.
- Add Bluetooth fixes.
- Import AMD 7000-series GPU fix (Raphael).
- Add GPD PPT (TDP) control from GPD Win Max 2
- Set `panel_orientation` kernel parameter.
- Add AC wakeup fix as a config option; disabled by default.
- Enable `power-profiles-daemon` by default, and disable TLP - can be
  configured.
- Disable both PSR and PSR-SU on amdgpu module.
- Fix touchscreen properties - upside down rotation
- Update README.md for GPD Duo.

Co-authored-by: Dom Rodriguez <shymega@shymega.org.uk>
2026-07-28 16:52:47 +01:00
Doron Behar 2e790b0a6b Merge pull request #1821 from Stunkymonkey/dell-precision-5820
dell/precision/5820: init
2026-07-28 09:54:56 +00:00
Felix Buehler a969eee084 dell/precision/5820: init 2026-07-26 13:34:14 +02:00
Cole Mickens e37920a635 k3-pico-itx: fix sdcard cross-build 2026-07-25 15:13:52 -05:00
Jörg Thalheim a017f5b722 Merge pull request #1898 from liberodark/spacemit-k3
spacemit/k3-pico-itx: init
2026-07-22 12:39:14 +00:00
Jörg Thalheim 779c32a001 Merge pull request #1950 from NixOS/dependabot/nix/tests/nixos-stable-8eeec93
build(deps): bump nixos-stable from `a037402` to `8eeec93` in /tests
2026-07-17 17:56:08 +00:00
Jörg Thalheim 79ecfa27f2 Merge pull request #1951 from NixOS/dependabot/nix/tests/nixos-unstable-small-d4a57f1
build(deps): bump nixos-unstable-small from `51effaf` to `d4a57f1` in /tests
2026-07-17 17:19:33 +00:00
dependabot[bot] e8b0dcdc2d build(deps): bump nixos-unstable-small in /tests
Bumps [nixos-unstable-small](https://github.com/NixOS/nixpkgs) from `51effaf` to `d4a57f1`.
- [Commits](https://github.com/NixOS/nixpkgs/commits)

---
updated-dependencies:
- dependency-name: nixos-unstable-small
  dependency-version: d4a57f162b50db6d7e49580a772ccbdb3a1605a4
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-16 02:06:31 +00:00
dependabot[bot] 4bff7ce522 build(deps): bump nixos-stable from a037402 to 8eeec93 in /tests
Bumps [nixos-stable](https://github.com/NixOS/nixpkgs) from `a037402` to `8eeec93`.
- [Commits](https://github.com/NixOS/nixpkgs/commits)

---
updated-dependencies:
- dependency-name: nixos-stable
  dependency-version: 8eeec934ae0dbeca3d7868c059568a65c08b2fc3
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-16 02:06:11 +00:00
Doron Behar fccfa9031a Merge pull request #1945 from JamieMagee/fix/raspberry-pi-firmware-cross
raspberry-pi: fix cross-compiled SD images
2026-07-15 07:31:06 +00:00
Jamie Magee f185edb4e9 raspberry-pi/common: fix firmware install when cross-compiling 2026-07-14 15:33:54 -07:00
Doron Behar 8efb4337e8 Merge pull request #1932 from JamieMagee/raspberry-pi-4-dtmerge-default
raspberry-pi/4: enable apply-overlays-dtmerge by default
2026-07-11 17:58:54 +00:00
Jamie Magee a886e41b8e raspberry-pi/4: remove hard-coded CPU revision overlay 2026-07-10 23:03:29 -07:00
Tristan Ross 4471c6a218 Merge pull request #1941 from JamieMagee/fix/fydetab-duo-efi-boot-stub
fydetab-duo: declare efiBootStub kernel feature
2026-07-10 14:11:16 +00:00
Doron Behar 0b655af52b Merge pull request #1894 from JamieMagee/raspberry-pi-firmware-install
raspberry-pi: add firmware-partition install module
2026-07-10 08:54:40 +00:00
Jamie Magee f54c3bcb65 raspberry-pi/common: add firmware-partition install module
Adds hardware.raspberry-pi.firmware to stage the Pi's pre-Linux boot files (GPU boot code, DTBs, overlays, config.txt, optionally U-Boot) onto the firmware partition. Boards still boot via generic-extlinux-compatible; this only supplies the files it needs, through populateCmd for image builders or an opt-in activation script.

DTB/overlay copy adapted from nvmd/nixos-raspberrypi.
2026-07-09 23:03:00 -07:00
Jamie Magee f2dfc37f5b fydetab-duo: declare efiBootStub kernel feature 2026-07-09 14:43:25 -07:00
Doron Behar 968980fba2 Merge pull request #1938 from JamieMagee/raspberry-pi-enable-uart
raspberry-pi/common: enable UART by default for U-Boot
2026-07-09 07:29:17 +00:00
Jamie Magee cd78713bfd raspberry-pi/common: enable UART by default for U-Boot 2026-07-09 01:38:01 -05:00
Winter 662bd6e312 Merge pull request #1915 from lmb/p14s-acpi-ec
lenovo/p14s: remove acpi.ec_no_wakeup=1 on gen 6 amd
2026-07-06 20:45:51 +00:00
mkorje 48c8b5e0bd apple/t2: improve firmware extraction 2026-07-03 14:51:40 +10:00
Jörg Thalheim a9cf7546a9 Merge pull request #1787 from glyxambi/gf63
msi/gf63: init
2026-06-27 12:09:17 +00:00
Jörg Thalheim 603d3afd1b Merge pull request #1865 from toastal/asus-px13
asus/proart/px13/hn7306eac: init
2026-06-25 09:25:05 +00:00
·𐑑𐑴𐑕𐑑𐑩𐑤 3de9124f07 asus/proart/px13/hn7306eac: init
• fetching audio firmware
• providing a default pipewire config

Hopefully in the future, both of these can be kernel version gated as
everything is mainlined.
2026-06-24 16:07:50 +07:00
·𐑑𐑴𐑕𐑑𐑩𐑤 4c996be103 asus/proart/px13: init 2026-06-24 00:07:02 +07:00
liberodark 57abfe19b2 spacemit/k3-pico-itx: init 2026-06-18 21:08:28 +02:00
Steven Allen e7358cddb9 framework/13-inch: fix enhanced audio device priority
On framework laptops, ensure that the "enhanced audio" sink for the
laptop speakers has a lower priority than bluetooth speakers (by giving
it the same priority as the laptop speakers, 1009 [1]). Bluetooth
speakers have a priority of 1010 [2] by default.

NOTE: the existing comment in the code claiming that higher values mean
lower priority is incorrect; lower priorities values mean lower priority.

[1] https://gitlab.freedesktop.org/pipewire/wireplumber/-/blob/7fa44ef8d0b2f603bd826d399718cef8cf6a800a/src/scripts/monitors/alsa.lua#L218
[2] https://gitlab.freedesktop.org/pipewire/wireplumber/-/blob/7fa44ef8d0b2f603bd826d399718cef8cf6a800a/src/scripts/monitors/bluez.lua#L275
2026-06-16 09:37:55 -07:00
Lorenz Bauer e2c926a044 lenovo/p14s: remove acpi.ec_no_wakeup=1 on gen 6 amd
The referenced lore.kernel.org thread refers to a T14 Gen 5 and
I am unable to reproduce the problem on my machine as measured
by amd-s2idle:

    BIOS R2XET37W (1.17, 2025-11-07)   EC firmware 1.9

    config              duration   hw sleep   wake interrupt
    ec_no_wakeup=1      0:00:22    77.27%     ACPI SCI
    ec_no_wakeup=0      0:00:23    73.91%     ACPI SCI

The original report shows a difference of 60 percentage points.
2026-06-15 12:13:36 +01:00
Alex Kraker d9e50dd040 Add note about Wayland KMS requirement 2026-06-08 20:15:12 -05:00
Alex Kraker d765d66fd5 lenovo/thinkpad/p1: document finegrained power management in gen5
readme
2026-06-08 13:55:50 -05:00
Alex Kraker 0e5b1ce394 Add P1 Gen 5 module README 2026-06-08 12:27:13 -05:00
Alex Kraker d35f12f895 Add ThinkPad P1 Gen 5 base
Add support for P1 Gen 5 intel cpu architecture at `lenovo/thinkpad/p1/gen5`.
The `gen5/nvidia` opt-in GPU imports from there. Add p1-gen5 to flake
and README.
2026-06-08 12:17:25 -05:00
Alex Kraker f9fbbd15c3 Add support for ThinkPad Gen 5 Nvidia
Add support for ThinkPad Gen 5 with optional Nvidia GPU. This gen uses _ampere_
microarchitecture, so we import that module. We set defaults for the
Intel and Nvidia hardware bus ID's based on my own system which is this
hardware configuration.
2026-06-08 11:47:27 -05:00
glyxambi 6a447e6e87 msi/gf63: init 2026-03-08 23:42:25 +05:30
128 changed files with 9705 additions and 1173 deletions

No files matched your search

+1
View File
@@ -8,6 +8,7 @@ pcengines/apu @yegortimoshenko
pine64/rockpro64 @tomfitzhenry
pine64/star64 @fgaz
purism/librem/13v3 @yegortimoshenko
raspberry-pi @doronbehar
system76/darp6 @khumba
framework @emiller88 @johnazoidberg
tuxedo/pulse/15/gen2 @trueNAHO
+9
View File
@@ -94,6 +94,7 @@ See code for all available configurations.
| Model | Path | Flake Module |
| --------------------------------------------------------------------------------- | ------------------------------------------------------- | -------------------------------------- |
| [Acer Aspire 4810T](acer/aspire/4810t) | `<nixos-hardware/acer/aspire/4810t>` | `acer-aspire-4810t` |
| [Acer Nitro 5 (AN515-55)](acer/nitro/5/an515-55) | `<nixos-hardware/acer/nitro/5/an515-55>` | `acer-nitro-5-an515-55` |
| [Acer Predator Helios 300 (PH315-51)](acer/predator/helios/300/ph315-51/) | `<nixos-hardware/acer/predator/helios/300/ph315-51/>` | `acer-predator-helios-300-ph315-51` |
| [Airis N990](airis/n990) | `<nixos-hardware/airis/n990>` | `airis-n990` |
| [Apple iMac 12,2](apple/imac/12-2) | `<nixos-hardware/apple/imac/12-2>` | `apple-imac-12-2` |
@@ -163,6 +164,7 @@ See code for all available configurations.
| [Dell Inspiron 7559](dell/inspiron/7559) | `<nixos-hardware/dell/inspiron/7559>` | `dell-inspiron-7559` |
| [Dell Latitude 3340](dell/latitude/3340) | `<nixos-hardware/dell/latitude/3340>` | `dell-latitude-3340` |
| [Dell Latitude 3480](dell/latitude/3480) | `<nixos-hardware/dell/latitude/3480>` | `dell-latitude-3480` |
| [Dell Latitude 3530](dell/latitude/3530) | `<nixos-hardware/dell/latitude/3530>` | `dell-latitude-3530` |
| [Dell Latitude 5490](dell/latitude/5490) | `<nixos-hardware/dell/latitude/5490>` | `dell-latitude-5490` |
| [Dell Latitude 5520](dell/latitude/5520) | `<nixos-hardware/dell/latitude/5520>` | `dell-latitude-5520` |
| [Dell Latitude 7280](dell/latitude/7280) | `<nixos-hardware/dell/latitude/7280>` | `dell-latitude-7280` |
@@ -182,6 +184,7 @@ See code for all available configurations.
| [Dell Precision 5530](dell/precision/5530) | `<nixos-hardware/dell/precision/5530>` | `dell-precision-5530` |
| [Dell Precision 5560](dell/precision/5560) | `<nixos-hardware/dell/precision/5560>` | `dell-precision-5560` |
| [Dell Precision 5570](dell/precision/5570) | `<nixos-hardware/dell/precision/5570>` | `dell-precision-5570` |
| [Dell Precision 5820](dell/precision/5820) | `<nixos-hardware/dell/precision/5820>` | `dell-precision-5820` |
| [Dell Precision 7520](dell/precision/7520) | `<nixos-hardware/dell/precision/7520>` | `dell-precision-7520` |
| [Dell XPS 13 7390](dell/xps/13-7390) | `<nixos-hardware/dell/xps/13-7390>` | `dell-xps-13-7390` |
| [Dell XPS 13 9300](dell/xps/13-9300) | `<nixos-hardware/dell/xps/13-9300>` | `dell-xps-13-9300` |
@@ -231,6 +234,7 @@ See code for all available configurations.
| [Gigabyte B550](gigabyte/b550) | `<nixos-hardware/gigabyte/b550>` | `gigabyte-b550` |
| [Gigabyte B650](gigabyte/b650) | `<nixos-hardware/gigabyte/b650>` | `gigabyte-b650` |
| [GMKtec NucBox G3 Plus](gmktec/nucbox/g3-plus) | `<nixos-hardware/gmktec/nucbox/g3-plus>` | `gmktec-nucbox-g3-plus` |
| [GPD Duo](gpd/duo) | `<nixos-hardware/gpd/duo>` | `gpd-duo` |
| [GPD MicroPC](gpd/micropc) | `<nixos-hardware/gpd/micropc>` | `gpd-micropc` |
| [GPD P2 Max](gpd/p2-max) | `<nixos-hardware/gpd/p2-max>` | `gpd-p2-max` |
| [GPD Pocket 3](gpd/pocket-3) | `<nixos-hardware/gpd/pocket-3>` | `gpd-pocket-3` |
@@ -305,6 +309,8 @@ See code for all available configurations.
| [Lenovo ThinkPad L14 (Intel)](lenovo/thinkpad/l14/intel) | `<nixos-hardware/lenovo/thinkpad/l14/intel>` | `lenovo-thinkpad-l14-intel` |
| [Lenovo ThinkPad L480](lenovo/thinkpad/l480) | `<nixos-hardware/lenovo/thinkpad/l480>` | `lenovo-thinkpad-l480` |
| [Lenovo ThinkPad P1 Gen 3](lenovo/thinkpad/p1/3th-gen) | `<nixos-hardware/lenovo/thinkpad/p1/3th-gen>` | `lenovo-thinkpad-p1-gen3` |
| [Lenovo ThinkPad P1 Gen 5](lenovo/thinkpad/p1/gen5) | `<nixos-hardware/lenovo/thinkpad/p1/gen5>` | `lenovo-thinkpad-p1-gen5` |
| [Lenovo ThinkPad P1 Gen 5 (Nvidia)](lenovo/thinkpad/p1/gen5/nvidia) | `<nixos-hardware/lenovo/thinkpad/p1/gen5/nvidia>` | `lenovo-thinkpad-p1-gen5-nvidia` |
| [Lenovo ThinkPad P14s AMD Gen 1](lenovo/thinkpad/p14s/amd/gen1) | `<nixos-hardware/lenovo/thinkpad/p14s/amd/gen1>` | `lenovo-thinkpad-p14s-amd-gen1` |
| [Lenovo ThinkPad P14s AMD Gen 2](lenovo/thinkpad/p14s/amd/gen2) | `<nixos-hardware/lenovo/thinkpad/p14s/amd/gen2>` | `lenovo-thinkpad-p14s-amd-gen2` |
| [Lenovo ThinkPad P14s AMD Gen 3](lenovo/thinkpad/p14s/amd/gen3) | `<nixos-hardware/lenovo/thinkpad/p14s/amd/gen3>` | `lenovo-thinkpad-p14s-amd-gen3` |
@@ -360,6 +366,7 @@ See code for all available configurations.
| [Lenovo ThinkPad X1 Yoga](lenovo/thinkpad/x1/yoga) | `<nixos-hardware/lenovo/thinkpad/x1/yoga>` | `lenovo-thinkpad-x1-yoga` |
| [Lenovo ThinkPad X1 Yoga Gen 7](lenovo/thinkpad/x1/yoga/7th-gen/) | `<nixos-hardware/lenovo/thinkpad/x1/yoga/7th-gen>` | `lenovo-thinkpad-x1-yoga-7th-gen` |
| [Lenovo ThinkPad X1 Yoga Gen 8](lenovo/thinkpad/x1/yoga/8th-gen/) | `<nixos-hardware/lenovo/thinkpad/x1/yoga/8th-gen>` | `lenovo-thinkpad-x1-yoga-8th-gen` |
| [Lenovo ThinkPad X1 Yoga Gen 8 (IPU6)](lenovo/thinkpad/x1/yoga/8th-gen/ipu6) | `<nixos-hardware/lenovo/thinkpad/x1/yoga/8th-gen/ipu6>` | `lenovo-thinkpad-x1-yoga-8th-gen-ipu6` |
| [Lenovo ThinkPad X1 (2nd Gen)](lenovo/thinkpad/x1/2nd-gen) | `<nixos-hardware/lenovo/thinkpad/x1/2nd-gen>` | `lenovo-thinkpad-x1-2nd-gen` |
| [Lenovo ThinkPad X1 (6th Gen)](lenovo/thinkpad/x1/6th-gen) | `<nixos-hardware/lenovo/thinkpad/x1/6th-gen>` | `lenovo-thinkpad-x1-6th-gen` |
| [Lenovo ThinkPad X1 (7th Gen)](lenovo/thinkpad/x1/7th-gen) | `<nixos-hardware/lenovo/thinkpad/x1/7th-gen>` | `lenovo-thinkpad-x1-7th-gen` |
@@ -401,6 +408,7 @@ See code for all available configurations.
| [MSI B550-A PRO](msi/b550-a-pro) | `<nixos-hardware/msi/b550-a-pro>` | `msi-b550-a-pro` |
| [MSI B350 TOMAHAWK](msi/b350-tomahawk) | `<nixos-hardware/msi/b350-tomahawk>` | `msi-b350-tomahawk` |
| [MSI B550 TOMAHAWK](msi/b550-tomahawk) | `<nixos-hardware/msi/b550-tomahawk>` | `msi-b550-tomahawk` |
| [MSI GF63 Thin](msi/gf63) | `<nixos-hardware/msi/gf63>` | `msi-gf63` |
| [MSI GS60 2QE](msi/gs60) | `<nixos-hardware/msi/gs60>` | `msi-gs60` |
| [MSI GL62/CX62](msi/gl62) | `<nixos-hardware/msi/gl62>` | `msi-gl62` |
| [MSI GL65 10SDR-492](msi/gl65/10SDR-492) | `<nixos-hardware/msi/gl65/10SDR-492>` | `msi-gl65-10SDR-492` |
@@ -453,6 +461,7 @@ See code for all available configurations.
| [Radxa ROCK Pi 4](radxa/rock-pi-4) | `<nixos-hardware/radxa/rock-pi-4>` | `rock-pi-4` |
| [Radxa ROCK Pi E](radxa/rock-pi-e) | `<nixos-hardware/radxa/rock-pi-e>` | `rock-pi-e` |
| [Razer Blade 14 (RZ09-0530)](razer/blade/14/RZ09-0530) | `<nixos-hardware/razer/blade/14/RZ09-0530>` | `razer-blade-14-RZ09-0530` |
| [Raspberry Pi 1](raspberry-pi/1) | `<nixos-hardware/raspberry-pi/1>` | `raspberry-pi-1` |
| [Raspberry Pi 2](raspberry-pi/2) | `<nixos-hardware/raspberry-pi/2>` | `raspberry-pi-2` |
| [Raspberry Pi 3](raspberry-pi/3) | `<nixos-hardware/raspberry-pi/3>` | `raspberry-pi-3` |
| [Raspberry Pi 4](raspberry-pi/4) | `<nixos-hardware/raspberry-pi/4>` | `raspberry-pi-4` |
+22
View File
@@ -0,0 +1,22 @@
# Acer Nitro 5 (AN515-55)
## Hardware Configuration
- Intel Core i5-10500H
- Intel UHD Graphics + NVIDIA GeForce GTX 1650 Mobile (Turing, TU117M)
- M.2 NVMe SSD
## Notes
- PRIME offload works via `nvidia-offload <cmd>` (enabled by default
via `common/gpu/nvidia/prime.nix`). GPU runtime D3 is not supported
on this chassis — the discrete GPU stays powered on at all times,
even when idle.
- NVIDIA open kernel modules work on this Turing GPU (enabled by
default via `common/gpu/nvidia/turing`), tested with the 595 series.
- `acer_wmi` loads and registers the `platform_profile` driver, but
no sysfs interface is exposed (`/sys/firmware/acpi/platform_profile`
does not exist). Fan/performance modes are only reachable through
Acer's proprietary WMI methods (NitroSense on Windows).
- Keyboard backlight is not exposed via the standard LED class
(`/sys/class/leds`) — `brightnessctl` only controls panel brightness.
+21
View File
@@ -0,0 +1,21 @@
{ lib, ... }:
{
imports = [
../../../../common/cpu/intel
../../../../common/gpu/nvidia/prime.nix
../../../../common/gpu/nvidia/turing
../../../../common/pc/laptop
../../../../common/pc/ssd
];
hardware.nvidia = {
modesetting.enable = lib.mkDefault true;
powerManagement.enable = lib.mkDefault true;
prime = {
intelBusId = "PCI:0@0:2:0";
nvidiaBusId = "PCI:1@0:0:0";
};
};
}
+45 -34
View File
@@ -8,34 +8,47 @@
let
inherit (lib) types;
audioFiles = pkgs.fetchFromGitHub {
owner = "kekrby";
repo = "t2-better-audio";
rev = "e46839a28963e2f7d364020518b9dac98236bcae";
hash = "sha256-x7K0qa++P1e1vuCGxnsFxL1d9+nwMtZUJ6Kd9e27TFs=";
t2bce-alsa-ucm = pkgs.stdenvNoCC.mkDerivation (_: {
name = "t2bce-alsa-ucm";
src = pkgs.fetchFromGitHub {
owner = "deqrocks";
repo = "t2bce";
rev = "967465dc67d3a9b1e48dea620f7258baa526f4f2";
hash = "sha256-EVUvNg30bFhJCtcyPAGbWjGX0+CORs4nWG5Bpvbr590=";
};
meta = {
description = "ALSA Usage Configuration Manager configuration for T2 Macs";
license = lib.licenses.mit;
};
dontBuild = true;
installPhase = ''
runHook preInstall
cd ./t2bce_audio-alsa-ucm-conf
mkdir -p "$out/share/alsa/"
cp -vR ./ucm2 "$out/share/alsa/"
runHook postInstall
'';
});
patched-alsa-ucm = pkgs.symlinkJoin {
inherit (t2bce-alsa-ucm) src meta;
name = "t2bce-alsa-ucm-patched";
paths = [
pkgs.alsa-ucm-conf
t2bce-alsa-ucm
];
};
audioFilesUdevRules = pkgs.runCommand "audio-files-udev-rules" { } ''
mkdir -p $out/lib/udev/rules.d
cp ${audioFiles}/files/*.rules $out/lib/udev/rules.d
substituteInPlace $out/lib/udev/rules.d/*.rules --replace "/usr/bin/sed" "${pkgs.gnused}/bin/sed"
'';
overrideAudioFiles =
package: pluginsPath:
package.overrideAttrs (
_new: old: {
preConfigurePhases = old.preConfigurePhases or [ ] ++ [ "postPatchPhase" ];
postPatchPhase = ''
cp -r ${audioFiles}/files/{profile-sets,paths} ${pluginsPath}/alsa/mixer/
'';
}
);
pipewirePackage = overrideAudioFiles pkgs.pipewire "spa/plugins/";
patchedAudioAlsaEnv = lib.genAttrs [ "pipewire" "wireplumber" "pulseaudio" ] (_: {
environment.ALSA_CONFIG_UCM2 = config.environment.variables.ALSA_CONFIG_UCM2;
});
t2Cfg = config.hardware.apple-t2;
in
{
imports = [
@@ -85,9 +98,7 @@ in
if t2Cfg.kernelChannel == "stable" then ./pkgs/linux-t2 else ./pkgs/linux-t2/latest.nix
) { }
);
boot.initrd.kernelModules = [ "apple-bce" ];
services.udev.packages = [ audioFilesUdevRules ];
boot.initrd.kernelModules = [ "t2bce-vhci" ];
# For audio and suspend
boot.kernelParams = [
@@ -96,19 +107,19 @@ in
"pm_async=off"
];
services.pipewire.package = pipewirePackage;
services.pipewire.wireplumber.package = pkgs.wireplumber.override {
pipewire = pipewirePackage;
# audio configuration
# https://github.com/nix-community/nixos-apple-silicon/blob/66d8dd2c27f99bd5420c99938b60695aac1785c4/apple-silicon-support/modules/sound/default.nix#L46
environment.variables.ALSA_CONFIG_UCM2 = "${patched-alsa-ucm}/share/alsa/ucm2";
# setting systemd.globalEnvironment is likely going to have unexpected side effects
systemd = {
services = patchedAudioAlsaEnv;
user.services = patchedAudioAlsaEnv;
};
# Make sure post-resume.service exists
powerManagement.enable = true;
}
{
services.pulseaudio.package = overrideAudioFiles pkgs.pulseaudio "src/modules/";
}
(lib.mkIf t2Cfg.enableIGPU {
# Enable the iGPU by default if present
environment.etc."modprobe.d/apple-gmux.conf".text = ''
+37 -48
View File
@@ -2,10 +2,7 @@
lib,
stdenvNoCC,
callPackage,
vmTools,
util-linux,
linux,
kmod,
_7zz,
version,
}:
@@ -38,52 +35,44 @@ let
};
in
vmTools.runInLinuxVM (
stdenvNoCC.mkDerivation {
pname = "brcm-firmware";
inherit version;
stdenvNoCC.mkDerivation {
pname = "brcm-firmware";
inherit version;
src = fetchmacos {
name = version;
inherit (boards.${version})
boardId
mlb
osType
hash
;
};
dontUnpack = true;
src = fetchmacos {
name = version;
inherit (boards.${version})
boardId
mlb
osType
hash
;
};
dontUnpack = true;
nativeBuildInputs = [
util-linux
get-firmware
];
buildPhase = ''
ln -s ${linux}/lib /lib
${kmod}/bin/modprobe loop
${kmod}/bin/modprobe hfsplus
nativeBuildInputs = [
_7zz
get-firmware
];
buildPhase = ''
7zz x -bd -bso0 -bsp0 $src \
"macOS Base System/usr/share/firmware/bluetooth/*" \
"macOS Base System/usr/share/firmware/wifi/*"
imgdir=$(mktemp -d)
loopdev=$(losetup -f | cut -d "/" -f 3)
losetup -P $loopdev $src
loopdev_partition=/dev/$(lsblk -o KNAME,TYPE,MOUNTPOINT -n | grep $loopdev | tail -1 | awk '{print $1}')
mount $loopdev_partition $imgdir
get-bluetooth "macOS Base System/usr/share/firmware/bluetooth" bluetooth/
get-wifi "macOS Base System/usr/share/firmware/wifi" wifi/
'';
get-bluetooth $imgdir/usr/share/firmware/bluetooth bluetooth/
get-wifi $imgdir/usr/share/firmware/wifi wifi/
'';
installPhase = ''
mkdir -p $out/lib/firmware/brcm
cp bluetooth/brcm/* $out/lib/firmware/brcm/
cp wifi/brcm/* $out/lib/firmware/brcm/
'';
installPhase = ''
mkdir -p $out/lib/firmware/brcm
cp bluetooth/brcm/* $out/lib/firmware/brcm/
cp wifi/brcm/* $out/lib/firmware/brcm/
'';
meta = with lib; {
description = "Wi-Fi and Bluetooth firmware for T2 Macs";
license = licenses.unfree;
maintainers = with maintainers; [ mkorje ];
platforms = platforms.linux;
};
}
)
meta = with lib; {
description = "Wi-Fi and Bluetooth firmware for T2 Macs";
license = licenses.unfree;
maintainers = with maintainers; [ mkorje ];
platforms = platforms.linux;
};
}
+2 -5
View File
@@ -1,6 +1,3 @@
{ callPackage, linux_6_18, ... }@args:
{ callPackage, ... }@args:
callPackage ./generic.nix args {
kernel = linux_6_18;
patchesFile = ./stable.json;
}
callPackage ./generic.nix args ./stable.json
+38 -13
View File
@@ -1,13 +1,13 @@
{
lib,
fetchurl, # fetchpatch does unnecessary normalization
buildLinux,
linuxKernel,
...
}@args:
{
kernel,
patchesFile,
}:
patchesFile:
let
inherit (builtins) readFile fromJSON;
@@ -23,33 +23,58 @@ let
}
) patchset.patches;
in
kernel.override (
args
// {
buildLinux (
{
pname = "linux-t2";
version = patchset.kernel.version;
src = fetchurl {
inherit (patchset.kernel) url hash;
};
structuredExtraConfig = with lib.kernel; {
APPLE_BCE = module;
T2BCE_CORE = module;
T2BCE_VHCI = module;
T2BCE_AUDIO = module;
T2BCE_AVE = module;
APPLE_GMUX = module;
APFS_FS = module;
BRCMFMAC = module;
BT_BCM = module;
BT_HCIBCM4377 = module;
BT_HCIUART_BCM = yes;
BT_HCIUART = module;
BT_HCIUART_BCM = yes;
DRM_APPLETBDRM = module;
HID_APPLE = module;
HID_APPLETB_BL = module;
HID_APPLETB_KBD = module;
HID_APPLE = module;
HID_MAGICMOUSE = module;
DRM_APPLETBDRM = module;
HID_SENSOR_ALS = module;
SENSORS_APPLESMC = module;
SND_PCM = module;
STAGING = yes;
# required for t2bce_ave
I2C = yes;
MEDIA_SUPPORT = yes;
MEDIA_CAMERA_SUPPORT = yes;
MEDIA_ANALOG_TV_SUPPORT = yes;
MEDIA_DIGITAL_TV_SUPPORT = yes;
MEDIA_RADIO_SUPPORT = yes;
MEDIA_SDR_SUPPORT = yes;
MEDIA_PLATFORM_SUPPORT = yes;
MEDIA_TEST_SUPPORT = yes;
};
kernelPatches = t2-patches ++ (args.kernelPatches or [ ]);
kernelPatches = [
# include default patches for good measure
linuxKernel.kernelPatches.request_key_helper
linuxKernel.kernelPatches.bridge_stp_helper
]
++ t2-patches
++ (args.kernelPatches or [ ]);
argsOverride.extraMeta = {
extraMeta = {
description = "The Linux kernel (with patches from the T2 Linux project)";
# take responsibility for the downstream kernel
+41 -16
View File
@@ -1,25 +1,30 @@
{
"base_url": "https://raw.githubusercontent.com/t2linux/linux-t2-patches/7ee7d19c38e5df31a386b2a0c35ca8f064003960/",
"base_url": "https://raw.githubusercontent.com/t2linux/linux-t2-patches/65fdd4d492d7e219a05742ce4768f16e5ba4f976/",
"kernel": {
"version": "7.2.9",
"url": "mirror://kernel/linux/kernel/v7.x/linux-7.2.9.tar.xz",
"hash": "sha256:1fnqp28vrikz9gqhb42k0dsggqf8i07j0s9qy33scr53a6zdzidl"
},
"patches": [
{
"name": "1001-Add-apple-bce-driver.patch",
"hash": "sha256-v/P3Ws3x+OPnmX3vSFLxARON0HNjjDRe7QJ+KP9tVsc="
"name": "1001-Add-t2bce-driver-stack.patch",
"hash": "sha256-QeAffMClzGsGdHC5Qce744X2WUcx6PI0CJ5BQ8txxQ8="
},
{
"name": "1002-Put-apple-bce-in-drivers-staging.patch",
"hash": "sha256-rK1lQ3fjHJH//50n37xgWrUs4CZ8lmFw0iDpbq5zoaY="
"name": "1002-Integrate-t2bce-driver-stack.patch",
"hash": "sha256-nPAPGV9IROyxSQzSztwNS1fY0ziGQJ7evKBs1ZSHwiE="
},
{
"name": "2008-i915-4-lane-quirk-for-mbp15-1.patch",
"hash": "sha256-S2osR1aSjqJiO7rNZP1sKt2+Uxyitwse/6BXMJvE9as="
"hash": "sha256-gTYP7WHV/Qulobdi1nNdYsv1CWgkM8pGvsCFQ+rvhrw="
},
{
"name": "2009-apple-gmux-allow-switching-to-igpu-at-probe.patch",
"hash": "sha256-6i+fh/Ifle0di5/tMOdMm0NMkEmeUb17hYM/g2j2dfI="
"hash": "sha256-OczfcYSvkw2lBZQzZjCV4LHSe6CnaJ1J8GBkgEbiOXk="
},
{
"name": "3001-applesmc-convert-static-structures-to-drvdata.patch",
"hash": "sha256-7KGC0pCos351wKNhwJI/Qoc7w+orOPpiTkdCN50G8nI="
"hash": "sha256-FVtOCXInI5OUqpTVDVsZ1taMwj3z+d3PeRgjnQQljG4="
},
{
"name": "3002-applesmc-make-io-port-base-addr-dynamic.patch",
@@ -55,35 +60,55 @@
},
{
"name": "4001-asahi-trackpad.patch",
"hash": "sha256-ANHSNoy5nK2b+rSAG0bJ8j6ZBmNqgeCddHXVS31KyDw="
"hash": "sha256-RuYI0t+rMu29wSkVT4suYJgGzS1ZruN/HBZWkLivlDw="
},
{
"name": "4003-HID-apple-ignore-the-trackpad-on-T2-Macs.patch",
"hash": "sha256-T2tYcFLeWUdx6QawANe3ZNVSRxmo1IdPiSpGLQk4IDY="
"hash": "sha256-LLZzcysLTuQrSXWXbdq7AASxfMInQoqpWzRNZAKws9k="
},
{
"name": "4004-HID-magicmouse-Add-support-for-trackpads-found-on-T2.patch",
"hash": "sha256-ubchCEv1BZ7t/zkI9DpHA4gUln9cdu4yHzVJI2TNlS0="
},
{
"name": "4005-HID-magicmouse-fix-regression-breaking-support-for-M.patch",
"hash": "sha256-oT+3AeETnKfzblxtcTD18c61BKoD9yAsga0AL3R8u7k="
"hash": "sha256-kUnbtl/54cihscirl9kP0Gsot7bdP0rYKlj6gQ10hk0="
},
{
"name": "5001-HID-appletb-kbd-add-option-to-switch-default-layer-o.patch",
"hash": "sha256-KV5DTjALzNugs92Jum6VUt0wgblK/6PG1KorovHcIX0="
},
{
"name": "5002-drm-appletbdrm-Add-suspend-and-resume-support.patch",
"hash": "sha256-NFa5ZpNguUC9ELfphvCrVHEh59tN/ZA9vQl6YD1avbI="
},
{
"name": "6001-drm-amd-pm-Fix-boot-problems-in-5300.patch",
"hash": "sha256-l6pyVkpumURgoQ/f1kGfw47YhMuuMjpiHgjP6QN8dNE="
},
{
"name": "7001-drm-i915-fbdev-Discard-BIOS-framebuffers-exceeding-h.patch",
"hash": "sha256-/EKN7JsAxcpAgfJFtPp2NLYaGqQ0kl8wjJEXifSzJpY="
},
{
"name": "7002-drm-amdgpu-reset-VI-ASIC-on-MacBookPro15-1.patch",
"hash": "sha256-lLruG4lJAI6fI94w2LzHmrbspXArrq+rbI/SJmhwXqo="
},
{
"name": "7003-amdgpu-add-support-for-5K.patch",
"hash": "sha256-RX3tiju4gNFlrrYWOMdUr0HAdSN5RliliiPAQw5I6/M="
},
{
"name": "8001-Add-APFS-driver.patch",
"hash": "sha256-EbIbfkncp5Jax2suny/jlFt+cD9MyYMV2rWFJIbgbg4="
"hash": "sha256-DU/jX8wuM6Y/5iZztg05GjWlzVlo8DfVpCJ3BxFoTJo="
},
{
"name": "8002-Necessary-modifications-to-build-APFS-with-the-kerne.patch",
"hash": "sha256-zCTetF2NPhMH2BknPumhPz2sf26X9Lcra7xCA3R2WMY="
},
{
"name": "9001-ACPI-x86-Apple-T2-systems-need-early-CPU-offlining.patch",
"hash": "sha256-camFPvnBQMErjVrbsdPPfsbyy59w0e0iPkVR1Juzv8o="
},
{
"name": "9002-Bluetooth-hci_event-strip-Broadcom-vendor-bits-from-adv-type.patch",
"hash": "sha256-oikMBjD4gyqTs351q7nTz6lI6rJqOe1/LfxpHAieEOs="
}
]
}
+2 -5
View File
@@ -1,6 +1,3 @@
{ callPackage, linux_7_0, ... }@args:
{ callPackage, ... }@args:
callPackage ./generic.nix args {
kernel = linux_7_0;
patchesFile = ./latest.json;
}
callPackage ./generic.nix args ./latest.json
+28 -15
View File
@@ -1,17 +1,26 @@
{
"base_url": "https://raw.githubusercontent.com/t2linux/linux-t2-patches/facf1c778667c3ef62104949ef64c75ce7e43b0a/",
"base_url": "https://raw.githubusercontent.com/t2linux/linux-t2-patches/2eed0f6c812e8f36cb7a7f7bcde69f6f87074bdf/",
"kernel": {
"version": "6.18.55",
"url": "mirror://kernel/linux/kernel/v6.x/linux-6.18.55.tar.xz",
"hash": "sha256:1yadaa2gz74nh3pawpwv6lamalnd7wpiv1xb88pw2rd1c606647l"
},
"patches": [
{
"name": "1001-Add-apple-bce-driver.patch",
"hash": "sha256-rrL3oVkYeq5ZslnjCQw4hcEK6knsm6U/wp1XnJmQTSA="
"name": "1001-Add-t2bce-driver-stack.patch",
"hash": "sha256-OG4Y7cN75pHWF7huV+2Fqtq0ik2aITMWtF43mD+RFCU="
},
{
"name": "1002-Put-apple-bce-in-drivers-staging.patch",
"hash": "sha256-deWROYcncl51sOmtvUHM61e5FM1beHbOJVp4iI31LHM="
"name": "1002-Integrate-t2bce-driver-stack.patch",
"hash": "sha256-z3g3IOAL+Nze88oKDSYpLHVtFnhz2kP1Udap5J64WmM="
},
{
"name": "1003-Fix-for-6.18.patch",
"hash": "sha256-ozJkJFm11oGDW1Gwrp4AR4Ifv9X8Yix6uF9ZBFJ76+M="
},
{
"name": "2008-i915-4-lane-quirk-for-mbp15-1.patch",
"hash": "sha256-S2osR1aSjqJiO7rNZP1sKt2+Uxyitwse/6BXMJvE9as="
"hash": "sha256-gTYP7WHV/Qulobdi1nNdYsv1CWgkM8pGvsCFQ+rvhrw="
},
{
"name": "2009-apple-gmux-allow-switching-to-igpu-at-probe.patch",
@@ -19,7 +28,7 @@
},
{
"name": "3001-applesmc-convert-static-structures-to-drvdata.patch",
"hash": "sha256-7KGC0pCos351wKNhwJI/Qoc7w+orOPpiTkdCN50G8nI="
"hash": "sha256-c/d+c5eKzhbtfUKtLC7AB+6vMXge4ZzPJAUbNENWH7g="
},
{
"name": "3002-applesmc-make-io-port-base-addr-dynamic.patch",
@@ -55,31 +64,35 @@
},
{
"name": "4001-asahi-trackpad.patch",
"hash": "sha256-+YXyIjtlVrLo8allTO3M1A+xold5FUXaZ8dwD2j5HDc="
"hash": "sha256-2h3TdPsX9HBXx5jkZ2S2GJkjFcdL8vKD1G69iqd9IWg="
},
{
"name": "4003-HID-apple-ignore-the-trackpad-on-T2-Macs.patch",
"hash": "sha256-T2tYcFLeWUdx6QawANe3ZNVSRxmo1IdPiSpGLQk4IDY="
"hash": "sha256-LLZzcysLTuQrSXWXbdq7AASxfMInQoqpWzRNZAKws9k="
},
{
"name": "4004-HID-magicmouse-Add-support-for-trackpads-found-on-T2.patch",
"hash": "sha256-ubchCEv1BZ7t/zkI9DpHA4gUln9cdu4yHzVJI2TNlS0="
},
{
"name": "4005-HID-magicmouse-fix-regression-breaking-support-for-M.patch",
"hash": "sha256-oT+3AeETnKfzblxtcTD18c61BKoD9yAsga0AL3R8u7k="
"hash": "sha256-kUnbtl/54cihscirl9kP0Gsot7bdP0rYKlj6gQ10hk0="
},
{
"name": "5001-HID-appletb-kbd-add-option-to-switch-default-layer-o.patch",
"hash": "sha256-KV5DTjALzNugs92Jum6VUt0wgblK/6PG1KorovHcIX0="
},
{
"name": "5002-drm-appletbdrm-Add-suspend-and-resume-support.patch",
"hash": "sha256-NFa5ZpNguUC9ELfphvCrVHEh59tN/ZA9vQl6YD1avbI="
},
{
"name": "7001-drm-i915-fbdev-Discard-BIOS-framebuffers-exceeding-h.patch",
"hash": "sha256-/EKN7JsAxcpAgfJFtPp2NLYaGqQ0kl8wjJEXifSzJpY="
},
{
"name": "7002-drm-amdgpu-reset-VI-ASIC-on-MacBookPro15-1.patch",
"hash": "sha256-lLruG4lJAI6fI94w2LzHmrbspXArrq+rbI/SJmhwXqo="
},
{
"name": "8001-Add-APFS-driver.patch",
"hash": "sha256-2By3Zlg/i5rUUJDlWc6JoiqapUnbVplk2lHzDhvAhzI="
"hash": "sha256-fL9TftzTd5PurxIDrzaPsysGExrMySGOsm6H8NFd7JY="
},
{
"name": "8002-Necessary-modifications-to-build-APFS-with-the-kerne.patch",
+33 -7
View File
@@ -15,21 +15,26 @@ API_BASE = "https://api.github.com"
PATCH_PATTERN = re.compile(r"^\d{4}-.*\.patch$")
parser = argparse.ArgumentParser(
description="Update linux-t2 patches from a GitHub repository."
description="Update linux-t2 patches from a GitHub repository.",
epilog='''
If both --branch and --reference flags are given, the argument of --reference will be used to fetch the Git
revision for patches and --branch as the kernel branch.
If only --branch is given, the argument will be used for both resolving the Git ref and the kernel branch.
''',
)
parser.add_argument("filename", help="the output filename")
parser.add_argument(
"--repository",
help="the source github repository",
help="the source github repository (default: %(default)s)",
default="t2linux/linux-t2-patches",
nargs="?",
)
ref_group = parser.add_mutually_exclusive_group()
ref_group.add_argument(
parser.add_argument(
"--reference", help="the git reference for the patches", default=None, nargs="?"
)
ref_group.add_argument(
"--branch", help="the git branch to fetch", default=None, nargs="?"
parser.add_argument(
"--branch", help="the kernel branch to fetch (default: latest, example: 6.18)", default=None, nargs="?"
)
@@ -62,6 +67,27 @@ def main():
reference = args.reference
branch = args.branch
print("Fetching kernel releases")
releases = requests.get("https://kernel.org/releases.json").json()['releases']
match = None
patched_url = ""
if not branch:
print("Branch not provided, fetching latest non-mainline kernel version")
# if the json schema changes this script would break, hopefully won't happen
match = next(filter(lambda x: x["moniker"] != "mainline", releases), None)
else:
match = next(filter(lambda x: x["version"].startswith(branch), releases), None)
if not match:
print(f"ERROR: could not find a kernel release for branch {branch}.")
return 1
patched_url = match['source'].replace('https://cdn.kernel.org/pub', 'mirror://kernel')
release_hash = subprocess.check_output(["nix-prefetch-url", "--type", "sha256", patched_url]).decode().strip()
print(f" Kernel: {match['version']}")
print(f" URL: {patched_url}")
print(f" Hash: sha256:{release_hash}")
kernel = {"version": match["version"], "url": patched_url, "hash": f"sha256:{release_hash}"}
if reference is None:
if branch is None:
print("Branch and reference not provided, fetching default branch")
@@ -85,7 +111,7 @@ def main():
for future in as_completed(futures):
patches_with_hash.append(future.result())
result = {"base_url": base_url, "patches": sorted(patches_with_hash, key=lambda p: p["name"])}
result = {"base_url": base_url, "kernel": kernel, "patches": sorted(patches_with_hash, key=lambda p: p["name"])}
with open(args.filename, "w+") as f:
json.dump(result, f, indent=2)
+17
View File
@@ -0,0 +1,17 @@
{ lib, ... }:
{
imports = [
../../../common/cpu/amd
../../../common/cpu/amd/pstate.nix
../../../common/gpu/amd
../../../common/pc/laptop
../../../common/pc/ssd
../../../common/hidpi.nix
../../battery.nix
];
hardware.enableRedistributableFirmware = lib.mkDefault true;
security.tpm2.enable = lib.mkDefault true;
hardware.sensor.iio.enable = lib.mkDefault true;
}
+77
View File
@@ -0,0 +1,77 @@
{
config,
pkgs,
lib,
...
}:
{
imports = [
../default.nix
# no effect at Linux 7.2 as patches are merged
./tas2783-kernel-patches.nix
];
assertions = [
{
assertion = lib.versionAtLeast config.boot.kernelPackages.kernel.version "7.0";
message = "ASUS ProArt PX13 (HN7306EAC) hardware requires Linux ≥ 7.0 (current ${config.boot.kernelPackages.kernel.version})";
}
];
hardware = {
alsa.enablePersistence = lib.mkDefault true;
firmware = lib.optional (lib.versionOlder pkgs.linux-firmware.version "20260519") (
pkgs.callPackage ./tas2783-firmware.nix { }
);
};
environment.etc = {
"alsa/ucm2/codecs/tas2783/init.conf".source = ./ucm2/codecs/tas2783/init.conf;
"alsa/ucm2/sof-soundwire/acp-dmic.conf".source = ./ucm2/sof-soundwire/acp-dmic.conf;
"alsa/ucm2/sof-soundwire/tas2783.conf".source = ./ucm2/sof-soundwire/tas2783.conf;
"alsa/ucm2/sof-soundwire/sof-soundwire.conf".source = ./ucm2/sof-soundwire/sof-soundwire.conf;
};
# WirePlumber config for TAS2783 smart amp speakers.
# UCM doesn’t expose a Speakers port for this card, so force pro-audio and
# prevent the speaker sink from suspending (prevents desync on idle).
# Firmware extraction recipe and original config:
# https://gist.github.com/cryptob1/f62aaf8517df2e540f447347f42c7a03
services.pipewire.wireplumber.extraConfig."51-strix-halo-audio" = {
"monitor.alsa.rules" = [
{
matches = [
{ "device.name" = "alsa_card.pci-0000_c4_00.5-platform-amd_sdw"; }
];
actions."update-props" = {
"device.profile" = "pro-audio";
};
}
{
matches = [
{ "node.name" = "alsa_output.pci-0000_c4_00.5-platform-amd_sdw.pro-output-2"; }
];
actions."update-props" = {
"session.suspend-timeout-seconds" = 0;
"node.description" = "Internal Speakers (TAS2783)";
"priority.session" = 2300;
};
}
];
};
# Unmute the TAS2783 once detected.
services.udev.extraRules =
let
amixer = "${lib.getBin pkgs.alsa-utils}/bin/amixer";
in
/* udev */ ''
ACTION=="add", SUBSYSTEM=="sound", ATTR{id}=="sofsoundwire", RUN+="${amixer} -c $attr{number} set 'tas2783-1 Amp Playback Switch' 1"
ACTION=="add", SUBSYSTEM=="sound", ATTR{id}=="amdsoundwire", RUN+="${amixer} -c $attr{number} set 'tas2783-1 Amp' on"
ACTION=="add", SUBSYSTEM=="sound", ATTR{id}=="amdsoundwire", RUN+="${amixer} -c $attr{number} set 'tas2783-2 Amp' on"
ACTION=="add", SUBSYSTEM=="sound", ATTR{id}=="amdsoundwire", RUN+="${amixer} -c $attr{number} set 'tas2783-1 Speaker' on"
ACTION=="add", SUBSYSTEM=="sound", ATTR{id}=="amdsoundwire", RUN+="${amixer} -c $attr{number} set 'tas2783-2 Speaker' on"
'';
}
@@ -0,0 +1,21 @@
diff --git a/sound/soc/codecs/tas2783-sdw.c b/sound/soc/codecs/tas2783-sdw.c
--- a/sound/soc/codecs/tas2783-sdw.c
+++ b/sound/soc/codecs/tas2783-sdw.c
@@ -1120,7 +1120,7 @@ static void tas_generate_fw_name(struct sdw_slave *slave, char *name, size_t siz
for (; dev; dev = dev->parent) {
if (dev->bus == &pci_bus_type) {
pci = to_pci_dev(dev);
- scnprintf(name, size, "%04X-%1X-%1X.bin",
+ scnprintf(name, size, "%04X-%1X-0x%X.bin",
pci->subsystem_device, bus->link_id, unique_id);
pci_found = true;
break;
@@ -1129,7 +1129,7 @@ static void tas_generate_fw_name(struct sdw_slave *slave, char *name, size_t siz
#endif
if (!pci_found)
- scnprintf(name, size, "tas2783-%1X-%1X.bin",
+ scnprintf(name, size, "tas2783-%1X-0x%X.bin",
bus->link_id, unique_id);
}
@@ -0,0 +1,40 @@
{
lib,
stdenvNoCC,
fetchurl,
icoutils,
p7zip,
}:
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "asus-px13-tas2783-firmware";
version = "6.3.1.15";
src = fetchurl {
url = "https://dlcdnets.asus.com/pub/ASUS/nb/Image/Driver/Audio/47519/SmartAMP_TI_DCH_TexasInstruments_Z_V${finalAttrs.version}_47519.exe?model=HN7306EAC";
hash = "sha256-hyiDV5W+Rn05xyG2JF5uA41E/L8NDklxjvRctE64o84=";
};
nativeBuildInputs = [
icoutils
p7zip
];
unpackPhase = ''
wrestool -x --raw -t ZIP -n 103 "$src" > driver.7z 2>/dev/null
7z x driver.7z -ozip_out -y >/dev/null 2>&1
'';
installPhase = ''
install -D -m 644 $(find zip_out -name "1714-1-0x8.bin" | head -1) $out/lib/firmware/1714-1-0x8.bin
install -D -m 644 $(find zip_out -name "1714-1-0xB.bin" | head -1) $out/lib/firmware/1714-1-0xB.bin
'';
meta = {
description = "TAS2783 Smart Amp firmware for ASUS ProArt PX13 HN7306EAC";
homepage = "https://www.asus.com/support/download/HN7306EAC/";
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
license = with lib.licenses; [ unfreeRedistributableFirmware ];
platforms = [ "x86_64-linux" ];
};
})
@@ -0,0 +1,46 @@
{
config,
pkgs,
lib,
...
}:
# See CachyOS’s discussion:
# https://github.com/CachyOS/linux-cachyos/issues/737
let
mkPatch = name: hash: {
inherit name;
patch = pkgs.fetchpatch {
inherit name;
url = "https://aur.archlinux.org/cgit/aur.git/plain/${name}.patch?h=linux-cachyos-px13";
inherit hash;
};
};
in
{
boot.kernelPatches =
lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "7.2")
[
(mkPatch "0001-ALSA-tas2783-sdw-add-Playback-to-volume-control" "sha512-IdIy81PXtmQAQ+MVChYDYkoa5RDhQwP2L5efN8cz+tST3nM0Oc0x4SJ4sBnVL7QDJc/WBB0OEnFfTkEt9Id+cQ==")
(mkPatch "0002-Names-to-match-snd_soc_dai_driver-playback-capturest" "sha512-SrCgzceh3rhyYz5tNWHY2jNWyG/qgmU7ZVLtV71iir8HwOrSES7JsunV2E7mb8R66dShY+loV8ovNeMkyuDB7w==")
(mkPatch "0003-removed-unused-fields" "sha512-mWKqFg8AG00TE3oPy5usPPxWf6aIvhxMLDGI+/0+vvjBIFwWv6qh9jSUeid6CAKgAcluPSA8Sag4ESguCeinyw==")
(mkPatch "0004-SOC_SINGLE_RANGE_TLV-uses-snd_soc_get_volsw-snd_soc_" "sha512-G51v725q17UHvfPg4H8V92eSbZ5lcuiF97Zt1EbAtuwrhXefeaZy+hl79sSpVlzzY8pvzIwf6wodAuvp44M01A==")
(mkPatch "0005-dev_set_drvdata-already-called-intas_sdw_probe" "sha512-zk+rKZ/l0oB7JdABtb89x6tUzggP99TSy+3cr+q6QjZFdjGsLPXHxre0YACuKBNx6+JazZE/zEilIvahS4wOLQ==")
(mkPatch "0006-refactor-setting-sa_func_data" "sha512-8djgIJV1LCzDhFLFn/PNfDkE+U0mh2h4Rm2LJMeLUYKQlwzgPMbICh5B3HhCgEVTaUd54OGOSFEf0i6AIm2SIQ==")
(mkPatch "0007-check-AF01-for-init-data" "sha512-gjpdnJDzve37MnyVE52+E9sRkXF9+HtA4XTrBZQiV8ozFwWgIzhO2ZDKSpWbE/kd23PdaUcKX/fPj3J7ZD5YqA==")
(mkPatch "0008-setup-ports" "sha512-uuDa92VXlCsszswv8PHcDbbyfseL6Jt7DWPc5ajG1WSM/FGojRIbbl/2smQyGfE2jPquy5GQfJps7k1cRfpl8w==")
(mkPatch "0009-Already-set-by-SOC_SINGLE_RANGE_TLV-Speaker-Playback" "sha512-qBveCsmwezD13oWF5jBlUybdns5OsDDZji0y0smaKWi9GPAvhw/v66WUnEyC77UF1mvq+OyrWpA4yXwxAFza3Q==")
(mkPatch "0010-control-to-set-channel" "sha512-pL8Ol1ml2QhyKnzZvD+oTaVUPyqOO49uuiEUzyKdnskFwVH+jIluY3IDsmzWv5wTg/9D+CTGC4J8gW55xKwWfg==")
(mkPatch "0011-mute-unmute-using-SND_SOC_DAPM_SWITCH" "sha512-6aB8mBACTIQxU7CTrpR3UXJFdR4KbUOT9/AymyGiuV/9PfWdXZoW/0A09SHFptxRwCv4FG5tZSDZRtKvvYNQdQ==")
(mkPatch "0012-use-SND_SOC_DAPM_REG-to-power-on-off" "sha512-mJ93TxZQ1GuDGar0/6tBd/dlJ3B/41AVhRsViuSaEhykPC4NlIAOWaN9eJj4bxjEEyEQ3REfjHXVnJ3wdCRK9w==")
(mkPatch "0013-reattach-after-resume" "sha512-OdkYPzRDkd4FCd1OTOAfRrQW6JQ9D3Opic/X+sg+pLNGoEEXfph/sLXVYGo9u6DGPJndQZNrXyS4qhJMGPWVMw==")
(mkPatch "0014-defer-check" "sha512-ABSrwsOB+KU39LMxh3N47Ji+edhu5rDQMKMi5rEVXtCU8W56qANpU+ui+bJmOLYyq8c9H1qme+b5nQ6u9zv01w==")
(mkPatch "0015-to-help-alsa-find-them" "sha512-gVJ+0ZO9Oz15/rC08moVSlVglbishJctjH5SnDdI8m3s9hkEY56o8v+R/PlRS3rL+mOa9q3VuO5J40+LrcxDKw==")
(mkPatch "0016-cleanup-controls" "sha512-Jkp7kdi0FmVMlBL/VVzq7hYkCmKoELO0epnExP7ggQuopCzRbVpUQ3giMlj10O69aUBZJ4z3gaMkb1HTYjIXmA==")
# Upstream linux-firmware took a different naming approach to the original patches
{
name = "0017-fix-tas2783-fw-name-0x";
patch = ./fix-tas2783-fw-name-0x.patch;
}
];
}
@@ -0,0 +1,42 @@
# TAS2783 specific switch control settings
Define.SpeakerMixerElem "tas2783-1 Speaker Playback"
If.twoAmpsStereoToOne {
Condition {
Type RegexMatch
Regex "2"
String "${var:SpeakerAmps}"
}
True {
Define.SpeakerMixerElem "tas2783 Speaker"
LibraryConfig.remap.Config {
ctl.default.map {
"name='tas2783 Speaker Playback Switch'" {
"name='tas2783-1 Speaker Playback Switch'".vindex.0 0
"name='tas2783-2 Speaker Playback Switch'".vindex.1 0
}
"name='tas2783 Speaker Playback Volume'" {
"name='tas2783-1 Speaker Playback Volume'".vindex.0 0
"name='tas2783-2 Speaker Playback Volume'".vindex.1 0
}
}
}
}
}
If.oneAmp {
Condition {
Type ControlExists
Control "name='tas2783-1 Speaker Playback Switch'"
}
True.Macro[{ SetLED { LED="speaker" Action="attach" CtlId="tas2783-1 Speaker Playback Switch" } }]
}
If.twoAmps {
Condition {
Type ControlExists
Control "name='tas2783-2 Speaker Playback Switch'"
}
True.Macro[{ SetLED { LED="speaker" Action="attach" CtlId="tas2783-2 Speaker Playback Switch" } }]
}
@@ -0,0 +1,8 @@
SectionDevice."Mic" {
Comment "Digital Microphone"
Value {
CapturePriority 100
CapturePCM "hw:${CardId},4"
}
}
@@ -0,0 +1,206 @@
Syntax 7
SectionUseCase."HiFi" {
File "/sof-soundwire/HiFi.conf"
Comment "Play HiFi quality Music"
}
Include.led.File "/common/ctl/led.conf"
Include.card-init.File "/lib/card-init.conf"
Include.ctl-remap.File "/lib/ctl-remap.conf"
Define {
SpeakerCodec1 ""
SpeakerChannels1 "2"
SpeakerAmps1 "0"
HeadsetCodec1 ""
MicCodec1 ""
Mics1 "0"
Iec61937Pcms1 ""
MultiCodec1 ""
}
DefineRegex {
SpeakerCodec {
Regex " spk:([a-z0-9]+((-sdca)|(-spk)|(-bridge))?(\\+[a-z0-9]+)?)"
String "${CardComponents}"
}
SpeakerChannels {
Regex " cfg-spk:([0-9]+)"
String "${CardComponents}"
}
SpeakerAmps {
Regex " cfg-amp:([0-9]+)"
String "${CardComponents}"
}
HeadsetCodec {
Regex " hs:([a-z0-9]+(-sdca)?)"
String "${CardComponents}"
}
MicCodec {
Regex " mic:([a-z0-9]+(-dmic)?+(-sdca)?)"
String "${CardComponents}"
}
Mics {
Regex " cfg-mics:([1-9][0-9]*)"
String "${CardComponents}"
}
Iec61937Pcms {
Regex "iec61937-pcm:(([0-9]+(,))*[0-9]+)"
String "${CardComponents}"
}
MultiCodec {
Regex "(rt712|rt713|rt721|rt722)"
String "${var:SpeakerCodec1} ${var:HeadsetCodec1} ${var:MicCodec1}"
}
}
If.multi_init {
Condition {
Type String
Empty "${var:MultiCodec1}"
}
False {
Define {
MultiSpeakerShadow "${var:SpeakerCodec1}"
MultiMicShadow "${var:MicCodec1}"
}
Include.multi_init.File "/codecs/${var:MultiCodec1}/init.conf"
}
}
If.multi_speaker {
Condition {
Type RegexMatch
# guard with "=" to avoid empty string matching
Regex "=(${var:MultiCodec1}(-sdca)?)="
String "=${var:SpeakerCodec1}="
}
True {
Define.SpeakerCodec1 ""
}
}
If.multi_mic {
Condition {
Type RegexMatch
# guard with "=" to avoid empty string matching
Regex "=(${var:MultiCodec1}(-sdca)?)="
String "=${var:MicCodec1}="
}
True {
Define.MicCodec1 ""
}
}
If.multi_headset {
Condition {
Type RegexMatch
# guard with "=" to avoid empty string matching
Regex "=(${var:MultiCodec1}(-sdca)?)="
String "=${var:HeadsetCodec1}="
}
True {
Define.HeadsetCodec1 ""
}
}
If.spk_init {
Condition {
Type RegexMatch
Regex "(rt1318(-1)?|cs35l56(-bridge)?|tas2783(-1)?)"
String "${var:SpeakerCodec1}"
}
True.Include.spk_init.File "/codecs/${var:SpeakerCodec1}/init.conf"
}
If.hs_init {
Condition {
Type RegexMatch
Regex "(cs42l43|cs42l45|rt5682|rt700|rt711|rt713(-sdca)?)"
String "${var:HeadsetCodec1}"
}
True.Include.hs_init.File "/codecs/${var:HeadsetCodec1}/init.conf"
}
If.mic_init {
Condition {
Type RegexMatch
Regex "(cs42l43-dmic|cs42l45-dmic|rt712-dmic|rt713-dmic|rt715(-sdca)?)"
String "${var:MicCodec1}"
}
True.Include.mic_init.File "/codecs/${var:MicCodec1}/init.conf"
}
If.mic_init_rt715 {
Condition {
Type String
Needle "rt715"
Haystack "${var:MicCodec1}"
}
True.Macro [{ SetLED { LED="mic" Action="detach" CtlId="PGA5.0 5 Master Capture Switch" } }]
}
If.pga_init_pga2 {
Condition {
Type ControlExists
Control "name='PGA2.0 2 Master Capture Switch'"
}
True.BootSequence [
cset "name='PGA2.0 2 Master Capture Switch' 1"
]
}
If.pga_init_pga5 {
Condition {
Type ControlExists
Control "name='PGA5.0 5 Master Capture Switch'"
}
True.BootSequence [
cset "name='PGA5.0 5 Master Capture Switch' 1"
]
}
If.mics-array {
Condition {
Type String
Empty "${var:Mics1}"
}
False.FixedBootSequence [
# dmic array info
exec "-nhlt-dmic-info -o ${var:LibDir}/dmics-nhlt.json"
]
}
Include.hdmi-pcm.File "/common/pcm/hdmi.conf"
Macro.0.HdmiDevice { Iec61937Devices "${var:Iec61937Pcms1}" Dev 5 Idx 0 }
Macro.1.HdmiDevice { Iec61937Devices "${var:Iec61937Pcms1}" Dev 6 Idx 1 }
Macro.2.HdmiDevice { Iec61937Devices "${var:Iec61937Pcms1}" Dev 7 Idx 2 }
If.HdmiIec61937 {
Condition {
Type RegexMatch
Regex "((^|,)[567](,|$))"
String "${var:Iec61937Pcms1}"
}
True.Macro.save_hdmi_cfg.HdmiPCMSave { Name "42-sof-hdmi" }
}
# Define macros to set up processing controls
Include.dsp-variables.File "/Intel/sof-hda-dsp/dsp.conf"
# Set BootSequence and FixedBootSequence for drc, eqiir, eqfir
Macro.SpeakerDrc.SofDrcBootSetup "endpoint='PostMixerSpeaker' direction='Playback'"
Macro.SpeakerIir.SofEqBootSetup "endpoint='PostMixerSpeaker' direction='Playback' eqtype='Iir'"
Macro.SpeakerFir.SofEqBootSetup "endpoint='PostMixerSpeaker' direction='Playback' eqtype='Fir'"
# Set BootSequence and FixedBootSequence for Mic array eqiir, tdfb, drc
Macro.MicArrayIir.SofEqBootSetup "endpoint='MicArray' direction='Capture' eqtype='Iir'"
Macro.MicArrayDrc.SofDrcBootSetup "endpoint='MicArray' direction='Capture'"
Macro.MicarrayTdfb.SofBeamformerBootSetup "endpoint='MicArray' direction='Capture'"
# For SoundWire PC with PCH-DMIC set BootSequence and FixedBootSequence for eqiir, tdfb, drc
Macro.Dmic0ArrayIir.SofEqBootSetup "endpoint='Dmic0' direction='Capture' eqtype='Iir'"
Macro.Dmic0ArrayDrc.SofDrcBootSetup "endpoint='Dmic0' direction='Capture'"
Macro.Dmic0ArrayTdfb.SofBeamformerBootSetup "endpoint='Dmic0' direction='Capture'"
@@ -0,0 +1,43 @@
# TAS2783 Use case Configuration for sof-soundwire card
#
# Arguments:
# ForAmps - regex filter for var:SpeakerAmps
# Amp - amplifier number (1,2 etc.)
#
DefineMacro.tas2783spk.If.0 {
Condition {
Type RegexMatch
Regex "${var:__ForAmps}"
String "${var:SpeakerAmps}"
}
True {
EnableSequence [
cset "name='tas2783-${var:__Amp} Amp Playback Switch' 1"
cset "name='tas2783-${var:__Amp} Speaker Playback Switch' 1"
]
DisableSequence [
cset "name='tas2783-${var:__Amp} Amp Playback Switch' 0"
cset "name='tas2783-${var:__Amp} Speaker Playback Switch' 0"
]
}
}
SectionDevice."Speaker" {
Comment "Speaker"
EnableSequence [
# cset "name='tas2783 Speaker Playback Switch' on"
]
DisableSequence [
# cset "name='tas2783 Speaker Playback Switch' off"
]
Value {
PlaybackPriority 100
PlaybackPCM "hw:${CardId},2"
PlaybackMixer "default:${CardId}"
PlaybackMixerElem "${var:SpeakerMixerElem}"
}
}
+1 -1
View File
@@ -4,6 +4,6 @@
boot.kernelParams = [
"i915.enable_dpcd_backlight=1"
"nvidia.NVreg_EnableBacklightHandler=0"
"nvidia.NVReg_RegistryDwords=EnableBrightnessControl=0"
"nvidia.NVreg_RegistryDwords=EnableBrightnessControl=0"
];
}
+12
View File
@@ -0,0 +1,12 @@
{
lib,
...
}:
{
# The BPI-SM10 (K3-CoM260) shares the same SoC, firmware and boot flow as the
# K3 Pico-ITX. Only the device tree differs.
imports = [ ../../spacemit/k3-pico-itx ];
hardware.deviceTree.name = lib.mkForce "spacemit/k3-com260-ifx.dtb";
}
+114
View File
@@ -0,0 +1,114 @@
{
config,
lib,
modulesPath,
pkgs,
...
}:
{
imports = [
"${modulesPath}/profiles/base.nix"
"${modulesPath}/installer/sd-card/sd-image.nix"
./default.nix
];
hardware.enableAllHardware = lib.mkForce false;
fileSystems."/" = lib.mkForce {
device = "/dev/disk/by-partlabel/nixos-rootfs";
fsType = "ext4";
};
fileSystems."/boot" = {
device = "/dev/disk/by-label/ESP";
fsType = "vfat";
options = [
"fmask=0077"
"dmask=0077"
];
};
image.fileName = "${config.image.baseName}-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}-bpi-sm10.img";
sdImage = {
expandOnBoot = true;
firmwarePartitionOffset = 12;
firmwarePartitionName = "ESP";
firmwareSize = 256;
populateFirmwareCommands =
let
systemdBoot = "${pkgs.systemd}/lib/systemd/boot/efi/systemd-bootriscv64.efi";
kernel = "${config.system.build.kernel}/${config.system.boot.loader.kernelFile}";
initrd = "${config.system.build.initialRamdisk}/${config.system.boot.loader.initrdFile}";
dtb = "${config.hardware.deviceTree.package}/${config.hardware.deviceTree.name}";
kernelParams = lib.concatStringsSep " " config.boot.kernelParams;
in
''
mkdir -p firmware/EFI/BOOT firmware/EFI/systemd firmware/EFI/nixos
mkdir -p firmware/loader/entries
cp ${systemdBoot} firmware/EFI/BOOT/BOOTRISCV64.EFI
cp ${systemdBoot} firmware/EFI/systemd/systemd-bootriscv64.efi
cp ${kernel} firmware/EFI/nixos/kernel.efi
cp ${initrd} firmware/EFI/nixos/initrd
cp ${dtb} firmware/EFI/nixos/k3_com260_ifx.dtb
cat > firmware/loader/loader.conf <<EOF
default nixos
timeout 3
console-mode auto
EOF
cat > firmware/loader/entries/nixos.conf <<EOF
title NixOS
linux /EFI/nixos/kernel.efi
initrd /EFI/nixos/initrd
devicetree /EFI/nixos/k3_com260_ifx.dtb
options init=${config.system.build.toplevel}/init ${kernelParams}
EOF
cat > firmware/startup.nsh <<EOF
@echo -off
echo Booting NixOS...
for %i in 0 1 2 3 4 5
if exist FS%i:\EFI\BOOT\BOOTRISCV64.EFI then
FS%i:\EFI\BOOT\BOOTRISCV64.EFI
endif
endfor
EOF
'';
populateRootCommands = "";
postBuildCommands = ''
eval $(${pkgs.util-linux}/bin/partx $img -o START,SECTORS --nr 2 --pairs)
ROOTFS_START=$START
ROOTFS_SECTORS=$SECTORS
truncate -s '+2M' $img
${pkgs.util-linux}/bin/sfdisk $img <<EOF
label: gpt
unit: sectors
sector-size: 512
first-lba: 256
start=1280, size=128, name="env", type=0FC63DAF-8483-4772-8E79-3D69D8477DE4
start=2048, size=256, name="bootinfo", type=0FC63DAF-8483-4772-8E79-3D69D8477DE4
start=3072, size=1024, name="fsbl", type=0FC63DAF-8483-4772-8E79-3D69D8477DE4
start=8192, size=6144, name="esos", type=0FC63DAF-8483-4772-8E79-3D69D8477DE4
start=14336, size=2048, name="opensbi", type=0FC63DAF-8483-4772-8E79-3D69D8477DE4
start=16384, size=8192, name="uboot", type=0FC63DAF-8483-4772-8E79-3D69D8477DE4
start=24576, size=524288, name="ESP", type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B
start=$ROOTFS_START, size=$ROOTFS_SECTORS, name="nixos-rootfs", type=0FC63DAF-8483-4772-8E79-3D69D8477DE4
EOF
dd if=${config.system.build.fsbl}/bootinfo_block.bin of=$img conv=notrunc bs=1M seek=1
dd if=${config.system.build.fsbl}/FSBL.bin of=$img conv=notrunc bs=1024 seek=1536
dd if=${config.system.build.opensbi}/share/opensbi/lp64/generic/firmware/fw_dynamic.itb of=$img conv=notrunc bs=1M seek=7
dd if=${config.system.build.edk2}/edk2.itb of=$img conv=notrunc bs=1M seek=8
'';
};
}
+36
View File
@@ -0,0 +1,36 @@
# Flag values from drivers/gpu/drm/amd/include/amd_shared.h
{ config, lib, ... }:
let
flags = {
disablePipeSplit = 1;
disableStutter = 2;
disableDsc = 4;
disableClockGating = 8;
disablePsr = 16;
disableMpo = 64;
disablePsrSu = 512;
disableReplay = 1024;
disableIps = 2048;
};
cfg = config.hardware.amdgpu.dcDebugMask;
mask = lib.foldlAttrs (
acc: name: bit:
if cfg.${name} then lib.bitOr acc bit else acc
) 0 flags;
in
{
options.hardware.amdgpu.dcDebugMask = lib.mapAttrs (
_name: bit:
lib.mkOption {
type = lib.types.bool;
default = false;
description = "Set flag 0x${lib.toHexString bit} in amdgpu.dcdebugmask.";
}
) flags;
config = lib.mkIf (mask != 0) {
boot.kernelParams = [ "amdgpu.dcdebugmask=0x${lib.toHexString mask}" ];
};
}
+2
View File
@@ -1,6 +1,8 @@
{ lib, ... }:
{
imports = [ ./dc-debug-mask.nix ];
config = {
services.xserver.videoDrivers = lib.mkDefault [ "modesetting" ];
+3 -1
View File
@@ -3,5 +3,7 @@
{
imports = [ ../. ];
services.tlp.enable = lib.mkDefault (!config.services.power-profiles-daemon.enable);
services.tlp.enable = lib.mkDefault (
!config.services.power-profiles-daemon.enable && !config.services.tuned.enable
);
}
+95
View File
@@ -0,0 +1,95 @@
# Dell Latitude 3530
Laptop was release in 2022, Has official Ubuntu Certification: https://ubuntu.com/certified/202205-30271
Every hardware in this laptop works with/is supported by upstream Linux Kernel 6.18 LTS as of 23-10-2026
The UEFI firmware of this laptop has an issue where it will cause random system hangs if Hyperthreading is turned off, behavior observed under both Windows and various Linux distros.
`lspci` output and product name confirmation :
```bash
❯ cat /sys/class/dmi/id/product_name
Latitude 3530
❯ lspci -nnk
00:00.0 Host bridge [0600]: Intel Corporation Device [8086:4609] (rev 04)
Subsystem: Dell Device [1028:0bc3]
00:02.0 VGA compatible controller [0300]: Intel Corporation Alder Lake-UP3 GT1 [UHD Graphics] [8086:46b3] (rev 0c)
Subsystem: Dell Device [1028:0bc3]
Kernel driver in use: i915
Kernel modules: i915, xe
00:04.0 Signal processing controller [1180]: Intel Corporation Alder Lake Innovation Platform Framework Processor Participant [8086:461d] (rev 04)
Subsystem: Dell Device [1028:0bc3]
Kernel driver in use: proc_thermal_pci
Kernel modules: processor_thermal_device_pci
00:06.0 PCI bridge [0604]: Intel Corporation 12th Gen Core Processor PCI Express x4 Controller #0 [8086:464d] (rev 04)
Subsystem: Dell Device [1028:0bc3]
Kernel driver in use: pcieport
00:07.0 PCI bridge [0604]: Intel Corporation Alder Lake-P Thunderbolt 4 PCI Express Root Port #0 [8086:466e] (rev 04)
Subsystem: Dell Device [1028:0bc3]
Kernel driver in use: pcieport
00:08.0 System peripheral [0880]: Intel Corporation 12th Gen Core Processor Gaussian & Neural Accelerator [8086:464f] (rev 04)
Subsystem: Dell Device [1028:0bc3]
00:0d.0 USB controller [0c03]: Intel Corporation Alder Lake-P Thunderbolt 4 USB Controller [8086:461e] (rev 04)
Subsystem: Dell Device [1028:0bc3]
Kernel driver in use: xhci_hcd
Kernel modules: xhci_pci
00:0d.2 USB controller [0c03]: Intel Corporation Alder Lake-P Thunderbolt 4 NHI #0 [8086:463e] (rev 04)
Subsystem: Dell Device [1028:0bc3]
Kernel driver in use: thunderbolt
Kernel modules: thunderbolt
00:12.0 Serial controller [0700]: Intel Corporation Alder Lake-P Integrated Sensor Hub [8086:51fc] (rev 01)
Subsystem: Dell Device [1028:0bc3]
Kernel driver in use: intel_ish_ipc
Kernel modules: 8250_pci, intel_ish_ipc
00:14.0 USB controller [0c03]: Intel Corporation Alder Lake PCH USB 3.2 xHCI Host Controller [8086:51ed] (rev 01)
Subsystem: Dell Device [1028:0bc3]
Kernel driver in use: xhci_hcd
Kernel modules: xhci_pci
00:14.2 RAM memory [0500]: Intel Corporation Alder Lake PCH Shared SRAM [8086:51ef] (rev 01)
Subsystem: Dell Device [1028:0bc3]
00:14.3 Network controller [0280]: Intel Corporation Alder Lake-P PCH CNVi WiFi [8086:51f0] (rev 01)
Subsystem: Intel Corporation Dual Band Wi-Fi 6(802.11ax) AX201 160MHz 2x2 [Harrison Peak] [8086:4070]
Kernel driver in use: iwlwifi
Kernel modules: iwlwifi
00:15.0 Serial bus controller [0c80]: Intel Corporation Alder Lake PCH Serial IO I2C Controller #0 [8086:51e8] (rev 01)
Subsystem: Dell Device [1028:0bc3]
Kernel driver in use: intel-lpss
Kernel modules: intel_lpss_pci
00:15.1 Serial bus controller [0c80]: Intel Corporation Alder Lake PCH Serial IO I2C Controller #1 [8086:51e9] (rev 01)
Subsystem: Dell Device [1028:0bc3]
Kernel driver in use: intel-lpss
Kernel modules: intel_lpss_pci
00:16.0 Communication controller [0780]: Intel Corporation Alder Lake PCH HECI Controller [8086:51e0] (rev 01)
Subsystem: Dell Device [1028:0bc3]
Kernel driver in use: mei_me
Kernel modules: mei_me
00:17.0 SATA controller [0106]: Intel Corporation Alder Lake-P SATA AHCI Controller [8086:51d3] (rev 01)
Subsystem: Dell Device [1028:0bc3]
Kernel driver in use: ahci
Kernel modules: ahci
00:1d.0 PCI bridge [0604]: Intel Corporation Alder Lake PCI Express Root Port #9 [8086:51b0] (rev 01)
Subsystem: Dell Device [1028:0bc3]
Kernel driver in use: pcieport
00:1f.0 ISA bridge [0601]: Intel Corporation Alder Lake PCH eSPI Controller [8086:5182] (rev 01)
Subsystem: Dell Device [1028:0bc3]
00:1f.3 Multimedia audio controller [0401]: Intel Corporation Alder Lake PCH-P High Definition Audio Controller [8086:51c8] (rev 01)
Subsystem: Dell Device [1028:0bc3]
Kernel driver in use: sof-audio-pci-intel-tgl
Kernel modules: snd_soc_avs, snd_sof_pci_intel_tgl, snd_hda_intel
00:1f.4 SMBus [0c05]: Intel Corporation Alder Lake PCH-P SMBus Host Controller [8086:51a3] (rev 01)
Subsystem: Dell Device [1028:0bc3]
Kernel driver in use: i801_smbus
Kernel modules: i2c_i801
00:1f.5 Serial bus controller [0c80]: Intel Corporation Alder Lake-P PCH SPI Controller [8086:51a4] (rev 01)
Subsystem: Dell Device [1028:0bc3]
Kernel driver in use: intel-spi
Kernel modules: spi_intel_pci
01:00.0 Non-Volatile memory controller [0108]: SK hynix BC901 NVMe Solid State Drive (DRAM-less) [1c5c:1d59] (rev 03)
Subsystem: SK hynix BC901 NVMe Solid State Drive (DRAM-less) [1c5c:1d59]
Kernel driver in use: nvme
Kernel modules: nvme
2c:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8211/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 15)
Subsystem: Dell Device [1028:0bc3]
Kernel driver in use: r8169
Kernel modules: r8169
```
+9
View File
@@ -0,0 +1,9 @@
{ ... }:
{
imports = [
../../../common/cpu/intel/alder-lake
../../../common/pc/laptop
../../../common/pc/ssd
];
}
+31
View File
@@ -0,0 +1,31 @@
{
config,
lib,
...
}:
{
imports = [
../../../common/cpu/intel
../../../common/pc
../../../common/pc/ssd
../../../common/gpu/nvidia
];
hardware.enableRedistributableFirmware = lib.mkDefault true;
boot.initrd.availableKernelModules = [
"xhci_pci"
"ahci"
"vmd"
"nvme"
];
hardware = {
nvidia = {
nvidiaSettings = lib.mkDefault true;
package = lib.mkDefault config.boot.kernelPackages.nvidiaPackages.legacy_580;
open = lib.mkDefault false;
};
};
powerManagement.cpuFreqGovernor = lib.mkDefault "performance";
}
Generated
+4 -4
View File
@@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1767892417,
"narHash": "sha256-8bW3q88CEg2u4hSP66Vf4lpbLonHz7hqDNBMcCY7E9U=",
"rev": "3497aa5c9457a9d88d71fa93a4a8368816fbeeba",
"lastModified": 1789546076,
"narHash": "sha256-vWkSk5bbfTqdtMoSgD9FshACO8JCvXTFi+3cqEp0mH0=",
"rev": "b1b875982b17dabde9b4a37f3e229e74913e6db3",
"type": "tarball",
"url": "https://releases.nixos.org/nixos/unstable/nixos-26.05pre924538.3497aa5c9457/nixexprs.tar.xz"
"url": "https://releases.nixos.org/nixos/unstable/nixos-26.11pre1074753.b1b875982b17/nixexprs.tar.xz"
},
"original": {
"type": "tarball",
+16
View File
@@ -43,6 +43,7 @@
in
{
acer-aspire-4810t = import ./acer/aspire/4810t;
acer-nitro-5-an515-55 = import ./acer/nitro/5/an515-55;
acer-predator-helios-300-ph315-51 = import ./acer/predator/helios/300/ph315-51;
airis-n990 = import ./airis/n990;
aoostar-r1-n100 = import ./aoostar/r1/n100;
@@ -77,6 +78,8 @@
asus-flow-gv302x-amdgpu = import ./asus/flow/gv302x/amdgpu;
asus-flow-gv302x-nvidia = import ./asus/flow/gv302x/nvidia;
asus-flow-gz301vu = import ./asus/flow/gz301vu;
asus-proart-px13 = import ./asus/proart/px13;
asus-proart-px13-hn7306eac = import ./asus/proart/px13/hn7306eac;
asus-pro-ws-x570-ace = import ./asus/pro-ws-x570-ace;
asus-rog-gl552vw = import ./asus/rog-gl552vw;
asus-rog-strix-g513im = import ./asus/rog-strix/g513im;
@@ -101,6 +104,7 @@
asus-zephyrus-gu603h = import ./asus/zephyrus/gu603h;
asus-zephyrus-gu605cw = import ./asus/zephyrus/gu605cw;
asus-zephyrus-gu605my = import ./asus/zephyrus/gu605my;
bananapi-bpi-sm10 = import ./bananapi/bpi-sm10;
beagleboard-pocketbeagle = import ./beagleboard/pocketbeagle;
chuwi-minibook-x = import ./chuwi/minibook-x;
deciso-dec = import ./deciso/dec;
@@ -116,6 +120,7 @@
dell-inspiron-7559 = import ./dell/inspiron/7559;
dell-latitude-3340 = import ./dell/latitude/3340;
dell-latitude-3480 = import ./dell/latitude/3480;
dell-latitude-3530 = import ./dell/latitude/3530;
dell-latitude-5490 = import ./dell/latitude/5490;
dell-latitude-5520 = import ./dell/latitude/5520;
dell-latitude-7280 = import ./dell/latitude/7280;
@@ -136,6 +141,7 @@
dell-precision-5530 = import ./dell/precision/5530;
dell-precision-5560 = import ./dell/precision/5560;
dell-precision-5570 = import ./dell/precision/5570;
dell-precision-5820 = import ./dell/precision/5820;
dell-precision-7520 = import ./dell/precision/7520;
dell-xps-13-7390 = import ./dell/xps/13-7390;
dell-xps-13-9300 = import ./dell/xps/13-9300;
@@ -191,6 +197,7 @@
google-pixelbook = import ./google/pixelbook;
google-brya = import ./google/brya;
google-rex = import ./google/rex;
gpd-duo = import ./gpd/duo;
gpd-micropc = import ./gpd/micropc;
gpd-p2-max = import ./gpd/p2-max;
gpd-pocket-3 = import ./gpd/pocket-3;
@@ -262,6 +269,8 @@
lenovo-thinkpad-l480 = import ./lenovo/thinkpad/l480;
lenovo-thinkpad-p1 = import ./lenovo/thinkpad/p1;
lenovo-thinkpad-p1-gen3 = import ./lenovo/thinkpad/p1/3th-gen;
lenovo-thinkpad-p1-gen5 = import ./lenovo/thinkpad/p1/gen5;
lenovo-thinkpad-p1-gen5-nvidia = import ./lenovo/thinkpad/p1/gen5/nvidia;
lenovo-thinkpad-p14s-amd-gen1 = import ./lenovo/thinkpad/p14s/amd/gen1;
lenovo-thinkpad-p14s-amd-gen2 = import ./lenovo/thinkpad/p14s/amd/gen2;
lenovo-thinkpad-p14s-amd-gen3 = import ./lenovo/thinkpad/p14s/amd/gen3;
@@ -317,6 +326,7 @@
lenovo-thinkpad-x1-yoga = import ./lenovo/thinkpad/x1/yoga;
lenovo-thinkpad-x1-yoga-7th-gen = import ./lenovo/thinkpad/x1/yoga/7th-gen;
lenovo-thinkpad-x1-yoga-8th-gen = import ./lenovo/thinkpad/x1/yoga/8th-gen;
lenovo-thinkpad-x1-yoga-8th-gen-ipu6 = import ./lenovo/thinkpad/x1/yoga/8th-gen/ipu6;
lenovo-thinkpad-x1-2nd-gen = import ./lenovo/thinkpad/x1/2nd-gen;
lenovo-thinkpad-x1-6th-gen = import ./lenovo/thinkpad/x1/6th-gen;
lenovo-thinkpad-x1-7th-gen = import ./lenovo/thinkpad/x1/7th-gen;
@@ -378,6 +388,7 @@
msi-b350-tomahawk = import ./msi/b350-tomahawk;
msi-b550-a-pro = import ./msi/b550-a-pro;
msi-b550-tomahawk = import ./msi/b550-tomahawk;
msi-gf63 = import ./msi/gf63;
msi-gs60 = import ./msi/gs60;
msi-gl62 = import ./msi/gl62;
msi-gl65-10SDR-492 = import ./msi/gl65/10SDR-492;
@@ -410,6 +421,7 @@
purism-librem-15v3 = import ./purism/librem/15v3;
purism-librem-5r4 = import ./purism/librem/5r4;
razer-blade-14-RZ09-0530 = import ./razer/blade/14/RZ09-0530;
raspberry-pi-1 = import ./raspberry-pi/1;
raspberry-pi-2 = import ./raspberry-pi/2;
raspberry-pi-3 = import ./raspberry-pi/3;
raspberry-pi-4 = import ./raspberry-pi/4;
@@ -422,6 +434,7 @@
kobol-helios4 = import ./kobol/helios4;
samsung-np900x3c = import ./samsung/np900x3c;
slimbook-hero-rpl-rtx = import ./slimbook/hero/rpl-rtx;
spacemit-k3-pico-itx = import ./spacemit/k3-pico-itx;
starfive-visionfive-v1 = import ./starfive/visionfive/v1;
starfive-visionfive-2 = import ./starfive/visionfive/v2;
starlabs-starlite-i5 = import ./starlabs/starlite/i5;
@@ -548,6 +561,9 @@
pkgs.lib.optionalAttrs (self.formatter ? ${system}) {
formatting = treefmtEval.config.build.check self;
}
// {
raspberry-pi-config-txt = pkgs.callPackage ./tests/config-txt-tests.nix { };
}
// nixosTests
);
};
+12 -12
View File
@@ -6,18 +6,18 @@
../../../common/gpu/amd
];
boot.kernelParams = [
# There seems to be an issue with panel self-refresh (PSR) that
# causes hangs for users.
#
# https://community.frame.work/t/fedora-kde-becomes-suddenly-slow/58459
# https://gitlab.freedesktop.org/drm/amd/-/issues/3647
"amdgpu.dcdebugmask=0x10"
]
# Workaround for SuspendThenHibernate: https://lore.kernel.org/linux-kernel/20231106162310.85711-1-mario.limonciello@amd.com/
++ lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") [
"rtc_cmos.use_acpi_alarm=1"
];
# There seems to be an issue with panel self-refresh (PSR) that
# causes hangs for users.
#
# https://community.frame.work/t/fedora-kde-becomes-suddenly-slow/58459
# https://gitlab.freedesktop.org/drm/amd/-/issues/3647
hardware.amdgpu.dcDebugMask.disablePsr = lib.mkDefault true;
boot.kernelParams =
# Workaround for SuspendThenHibernate: https://lore.kernel.org/linux-kernel/20231106162310.85711-1-mario.limonciello@amd.com/
lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") [
"rtc_cmos.use_acpi_alarm=1"
];
# AMD has better battery life with PPD over TLP:
# https://community.frame.work/t/responded-amd-7040-sleep-states/38101/13
+5 -6
View File
@@ -315,12 +315,11 @@ in
"device.api" = "dsp";
"node.virtual" = "false";
# Lower seems to mean "more preferred",
# bluetooth devices seem to be ~1000, speakers seem to be ~2000
# since this is between the two, bluetooth devices take over when they connect,
# and hand over to this instead of the speakers when they disconnect.
"priority.session" = 1500;
"priority.driver" = 1500;
# 1009 is the default priority of the "first" analog audio device.
# Higher priorities (e.g., 1010 for bluetooth and 1100 for usb audio)
# are preferred.
"priority.session" = 1009;
"priority.driver" = 1009;
"state.default-volume" = 0.343;
"device.icon-name" = "audio-card-analog-pci";
};
@@ -21,8 +21,9 @@
# The following mitigations fix various graphics issues
# See https://gist.github.com/lbrame/f9034b1a9fe4fc2d2835c5542acb170a#user-content-quick-version-apply-the-mitigations-i-am-personally-using
hardware.amdgpu.dcDebugMask.disableReplay = lib.mkDefault true;
boot.kernelParams = [
"amdgpu.dcdebugmask=0x410"
"amdgpu.sg_display=0"
"amdgpu.abmlevel=0"
];
+12 -12
View File
@@ -6,18 +6,18 @@
../../../common/gpu/amd
];
boot.kernelParams = [
# There seems to be an issue with panel self-refresh (PSR) that
# causes hangs for users.
#
# https://community.frame.work/t/fedora-kde-becomes-suddenly-slow/58459
# https://gitlab.freedesktop.org/drm/amd/-/issues/3647
"amdgpu.dcdebugmask=0x10"
]
# Workaround for SuspendThenHibernate: https://lore.kernel.org/linux-kernel/20231106162310.85711-1-mario.limonciello@amd.com/
++ lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") [
"rtc_cmos.use_acpi_alarm=1"
];
# There seems to be an issue with panel self-refresh (PSR) that
# causes hangs for users.
#
# https://community.frame.work/t/fedora-kde-becomes-suddenly-slow/58459
# https://gitlab.freedesktop.org/drm/amd/-/issues/3647
hardware.amdgpu.dcDebugMask.disablePsr = lib.mkDefault true;
boot.kernelParams =
# Workaround for SuspendThenHibernate: https://lore.kernel.org/linux-kernel/20231106162310.85711-1-mario.limonciello@amd.com/
lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") [
"rtc_cmos.use_acpi_alarm=1"
];
# AMD has better battery life with PPD over TLP:
# https://community.frame.work/t/responded-amd-7040-sleep-states/38101/13
-16
View File
@@ -28,22 +28,6 @@
# Enable keyboard customization
hardware.keyboard.qmk.enable = lib.mkDefault true;
# Allow `services.libinput.touchpad.disableWhileTyping` to work correctly.
# Set unconditionally because libinput can also be configured dynamically via
# gsettings.
#
# This is extracted from the quirks file that is in the upstream libinput
# source. Once we can assume everyone is on at least libinput 1.26.0, this
# local override file can be removed.
# https://gitlab.freedesktop.org/libinput/libinput/-/commit/566857bd98131009699c9ab6efc7af37afd43fd0
environment.etc."libinput/local-overrides.quirks".text = ''
[Framework Laptop 16 Keyboard Module]
MatchName=Framework Laptop 16 Keyboard Module*
MatchUdevType=keyboard
MatchDMIModalias=dmi:*svnFramework:pnLaptop16*
AttrKeyboardIntegration=internal
'';
# Everything is updateable through fwupd
services.fwupd.enable = true;
}
+4 -1
View File
@@ -14,5 +14,8 @@ linuxPackagesFor (linuxManualConfig rec {
};
configfile = ./config;
config = import ./config.nix;
features.netfilterRPFilter = true;
features = {
efiBootStub = true;
netfilterRPFilter = true;
};
})
+60
View File
@@ -0,0 +1,60 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.hardware.gpd.duo;
in
with lib;
{
imports = [
./duo-specific
../../common/pc/laptop
../../common/pc/ssd
../../common/hidpi.nix
];
options = {
hardware.gpd.duo.preventWakeOnAC = mkOption {
type = types.bool;
default = false;
description = ''
Stop the system waking from suspend when the AC is plugged
in. The catch: it also disables waking from the keyboard.
See:
https://community.frame.work/t/tracking-framework-amd-ryzen-7040-series-lid-wakeup-behavior-feedback/39128/45
'';
};
};
config = {
# Workaround applied upstream in Linux >=6.7 (on BIOS 03.03)
# https://github.com/torvalds/linux/commit/a55bdad5dfd1efd4ed9ffe518897a21ca8e4e193
services.udev.extraRules =
mkIf (versionOlder config.boot.kernelPackages.kernel.version "6.7" && cfg.preventWakeOnAC)
''
# Prevent wake when plugging in AC during suspend. Trade-off: keyboard wake disabled. See:
# https://community.frame.work/t/tracking-framework-amd-ryzen-7040-series-lid-wakeup-behavior-feedback/39128/45
ACTION=="add", SUBSYSTEM=="serio", DRIVERS=="atkbd", ATTR{power/wakeup}="disabled"
'';
# Replace 'left' with 'right' or 'inverted' as needed
# Fixes DUO stupid inverted display at boot
# Enable kernel module for your graphics (adjust if needed)
boot.kernelModules = [ "amdgpu" ];
# Set the eDP-1 panel video parameters for display rotation
boot.kernelParams = mkBefore [
"video=eDP-1:2880x1800,panel_orientation=upside_down"
"video=DP-3:2880x1800,panel_orientation=normal"
"i2c_touchscreen_props=GXTP7380:touchscreen-inverted-x:touchscreen-inverted-y"
];
hardware.gpd.duo.audioEnhancement.rawDeviceName =
mkDefault "alsa_output.pci-0000_c1_00.6.analog-stereo";
};
}
+27
View File
@@ -0,0 +1,27 @@
{ lib, config, ... }:
with lib;
{
imports = [
../../../common/cpu/amd
../../../common/cpu/amd/pstate.nix
../../../common/gpu/amd
];
boot.kernelParams = [
# There seems to be an issue with panel self-refresh (PSR) that
# causes hangs for users.
#
# https://community.frame.work/t/fedora-kde-becomes-suddenly-slow/58459
# https://gitlab.freedesktop.org/drm/amd/-/issues/3647
"amdgpu.dcdebugmask=0x210"
]
# Workaround for SuspendThenHibernate: https://lore.kernel.org/linux-kernel/20231106162310.85711-1-mario.limonciello@amd.com/
++ optionals (versionOlder config.boot.kernelPackages.kernel.version "6.8") [
"rtc_cmos.use_acpi_alarm=1"
];
# AMD has better battery life with PPD over TLP:
# https://community.frame.work/t/responded-amd-7040-sleep-states/38101/13
services.power-profiles-daemon.enable = mkDefault true;
services.tlp.enable = mkDefault false;
}
+391
View File
@@ -0,0 +1,391 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.hardware.gpd.duo.audioEnhancement;
in
with lib;
{
options = {
hardware.gpd.duo.audioEnhancement = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
Create a new audio device called "DUO Speakers",
which applies sound tuning before sending the audio out to the speakers.
This option requires PipeWire and WirePlumber.
The filter chain includes the following:
- Pyschoacoustic bass enhancement
- Loudness compensation
- Equalizer
- Slight compression
This option has been optimised for the Framework Laptop 13 AMD 7040 series, but should work on all models.
Before applying, ensure the speakers are set to 100%,
because the volumes compound and the raw speaker device will be hidden by default.
You might also need to re-select the default output device.
In some cases, the added bass will vibrate the keyboard cable leading to a rattling sound,
a piece of foam can be used to mitigate this.
'';
};
hideRawDevice = mkOption {
type = types.bool;
default = true;
description = ''
Hide the raw speaker device.
This option is enabled by default, because keeping the raw speaker device can lead to volume conflicts.
'';
};
rawDeviceName = mkOption {
type = types.str;
example = "alsa_output.pci-0000_c1_00.6.analog-stereo";
description = ''
The name of the raw speaker device. This will vary by device.
You can get this by running `pw-dump | grep -C 20 pci-0000`.
'';
};
};
};
config = mkIf cfg.enable (
let
outputName = cfg.rawDeviceName;
prettyName = "Duo Speakers";
# These are pre-made decibel to linear value conversions, since Nix doesn't have pow().
# Use the formula `10 ** (db / 20)` to calculate.
db = {
"-18.1" = 0.1244514611771385;
"-5.48" = 0.5321082592667942;
"-4.76" = 0.5780960474057181;
"8.1" = 2.5409727055493048;
"-36" = 1.5848931924611134e-2;
};
json = pkgs.formats.json { };
# The filter chain, heavily inspired by the asahi-audio project: https://github.com/AsahiLinux/asahi-audio
filter-chain = json.generate "filter-chain.json" {
"node.description" = prettyName;
"media.name" = prettyName;
"filter.graph" = {
nodes = [
# Psychoacoustic bass extension,
# it creates harmonics of the missing bass to fool our ears into hearing it.
{
type = "lv2";
plugin = "https://chadmed.au/bankstown";
name = "bassex";
control = {
bypass = 0;
amt = 1.2;
sat_second = 1.3;
sat_third = 2.5;
blend = 1.0;
ceil = 200.0;
floor = 20.0;
};
}
# Loudness compensation,
# it ensures that the sound profile stays consistent across different volumes.
{
type = "lv2";
plugin = "http://lsp-plug.in/plugins/lv2/loud_comp_stereo";
name = "el";
control = {
enabled = 1;
input = 1.0;
fft = 4;
};
}
# 8-band equalizer,
# it tries to lessen frequencies where the laptop might resonate,
# and tries to make the frequency curve more pleasing;
# this is the "Lappy McTopface" profile (https://github.com/ceiphr/ee-framework-presets)
# further tuned for the Framework Laptop 13 AMD 7040 series
# and might need some tuning on other models.
{
type = "lv2";
plugin = "http://lsp-plug.in/plugins/lv2/para_equalizer_x8_lr";
name = "fw13eq";
control = {
mode = 0;
react = 0.2;
zoom = db."-36";
fl_0 = 101.0;
fml_0 = 0;
ftl_0 = 5;
gl_0 = db."-18.1";
huel_0 = 0.0;
ql_0 = 4.36;
sl_0 = 0;
wl_0 = 4.0;
fl_1 = 451.0;
fml_1 = 0;
ftl_1 = 1;
gl_1 = db."-5.48";
huel_1 = 3.125e-2;
ql_1 = 2.46;
sl_1 = 0;
wl_1 = 4.0;
fl_2 = 918.0;
fml_2 = 0;
ftl_2 = 1;
gl_2 = db."-4.76";
huel_2 = 6.25e-2;
ql_2 = 2.44;
sl_2 = 0;
wl_2 = 4.0;
fl_3 = 9700.0;
fml_3 = 0;
ftl_3 = 1;
gl_3 = db."8.1";
huel_3 = 9.375e-2;
ql_3 = 2.0;
sl_3 = 0;
wl_3 = 4.0;
fr_0 = 101.0;
fmr_0 = 0;
ftr_0 = 5;
gr_0 = db."-18.1";
huer_0 = 0.0;
qr_0 = 4.36;
sr_0 = 0;
wr_0 = 4.0;
fr_1 = 451.0;
fmr_1 = 0;
ftr_1 = 1;
gr_1 = db."-5.48";
huer_1 = 3.125e-2;
qr_1 = 2.46;
sr_1 = 0;
wr_1 = 4.0;
fr_2 = 918.0;
fmr_2 = 0;
ftr_2 = 1;
gr_2 = db."-4.76";
huer_2 = 6.25e-2;
qr_2 = 2.44;
sr_2 = 0;
wr_2 = 4.0;
fr_3 = 9700.0;
fmr_3 = 0;
ftr_3 = 1;
gr_3 = db."8.1";
huer_3 = 9.375e-2;
qr_3 = 2.0;
sr_3 = 0;
wr_3 = 4.0;
};
}
# Compressors. The settings were taken from the asahi-audio project.
{
type = "lv2";
plugin = "http://lsp-plug.in/plugins/lv2/mb_compressor_stereo";
name = "woofer_bp";
control = {
mode = 0;
ce_0 = 1;
sla_0 = 5.0;
cr_0 = 1.75;
al_0 = 0.725;
at_0 = 1.0;
rt_0 = 100;
kn_0 = 0.125;
cbe_1 = 1;
sf_1 = 200.0;
ce_1 = 0;
cbe_2 = 0;
ce_2 = 0;
cbe_3 = 0;
ce_3 = 0;
cbe_4 = 0;
ce_4 = 0;
cbe_5 = 0;
ce_5 = 0;
cbe_6 = 0;
ce_6 = 0;
};
}
{
type = "lv2";
plugin = "http://lsp-plug.in/plugins/lv2/compressor_stereo";
name = "woofer_lim";
control = {
sla = 5.0;
al = 1.0;
at = 1.0;
rt = 100.0;
cr = 15.0;
kn = 0.5;
};
}
];
# Now, we're chaining together the modules instantiated above.
links = [
{
output = "bassex:out_l";
input = "el:in_l";
}
{
output = "bassex:out_r";
input = "el:in_r";
}
{
output = "el:out_l";
input = "fw13eq:in_l";
}
{
output = "el:out_r";
input = "fw13eq:in_r";
}
{
output = "fw13eq:out_l";
input = "woofer_bp:in_l";
}
{
output = "fw13eq:out_r";
input = "woofer_bp:in_r";
}
{
output = "woofer_bp:out_l";
input = "woofer_lim:in_l";
}
{
output = "woofer_bp:out_r";
input = "woofer_lim:in_r";
}
];
inputs = [
"bassex:in_l"
"bassex:in_r"
];
outputs = [
"woofer_lim:out_l"
"woofer_lim:out_r"
];
# This makes pipewire's volume control actually control the loudness comp module
"capture.volumes" = [
{
control = "el:volume";
min = -47.5;
max = 0.0;
scale = "cubic";
}
];
};
"capture.props" = {
"node.name" = "audio_effect.laptop-convolver";
"media.class" = "Audio/Sink";
"audio.channels" = "2";
"audio.position" = [
"FL"
"FR"
];
"audio.allowed-rates" = [
44100
48000
88200
96000
176400
192000
];
"device.api" = "dsp";
"node.virtual" = "false";
# Lower seems to mean "more preferred",
# bluetooth devices seem to be ~1000, speakers seem to be ~2000
# since this is between the two, bluetooth devices take over when they connect,
# and hand over to this instead of the speakers when they disconnect.
"priority.session" = 1500;
"priority.driver" = 1500;
"state.default-volume" = 0.343;
"device.icon-name" = "audio-card-analog-pci";
};
"playback.props" = {
"node.name" = "audio_effect.laptop-convolver";
"target.object" = outputName;
"node.passive" = "true";
"audio.channels" = "2";
"audio.allowed-rates" = [
44100
48000
88200
96000
176400
192000
];
"audio.position" = [
"FL"
"FR"
];
"device.icon-name" = "audio-card-analog-pci";
};
};
configPackage =
(pkgs.writeTextDir "share/wireplumber/wireplumber.conf.d/99-laptop.conf" ''
monitor.alsa.rules = [
{
matches = [{ node.name = "${outputName}" }]
actions = {
update-props = {
audio.allowed-rates = [44100, 48000, 88200, 96000, 176400, 192000]
}
}
}
]
node.software-dsp.rules = [
{
matches = [{ node.name = "${outputName}" }]
actions = {
create-filter = {
filter-path = "${filter-chain}"
hide-parent = ${boolToString cfg.hideRawDevice}
}
}
}
]
wireplumber.profiles = {
main = { node.software-dsp = "required" }
}
'')
// {
passthru.requiredLv2Packages = with pkgs; [
lsp-plugins
bankstown-lv2
];
};
in
{
services.pipewire.wireplumber.configPackages = [ configPackage ];
# Pipewire is needed for this.
services.pipewire.enable = mkDefault true;
}
);
}
+56
View File
@@ -0,0 +1,56 @@
# There is apparently a bug that affects Framework computers that causes black
# screen on resume from sleep or hibernate with kernel version 6.11. Framework
# have published a workaround; this applies that workaround.
#
# https://fosstodon.org/@frameworkcomputer/113406887743149089
# https://github.com/FrameworkComputer/linux-docs/blob/main/hibernation/kernel-6-11-workarounds/suspend-hibernate-bluetooth-workaround.md#workaround-for-suspendhibernate-black-screen-on-resume-kernel-611
{
config,
lib,
pkgs,
...
# TODO: drop this if linux 6.11 goes EOL
}:
with lib;
mkIf
(
(config.boot.kernelPackages.kernelAtLeast "6.11") && (config.boot.kernelPackages.kernelOlder "6.12")
)
{
systemd.services = {
bluetooth-rfkill-suspend = {
description = "Soft block Bluetooth on suspend/hibernate";
before = [ "sleep.target" ];
unitConfig.StopWhenUnneeded = true;
serviceConfig = {
Type = "oneshot";
ExecStart = "${pkgs.util-linux}/bin/rfkill block bluetooth";
ExecStartPost = "${pkgs.coreutils}/bin/sleep 3";
RemainAfterExit = true;
};
wantedBy = [
"suspend.target"
"hibernate.target"
"suspend-then-hibernate.target"
];
};
bluetooth-rfkill-resume = {
description = "Unblock Bluetooth on resume";
after = [
"suspend.target"
"hibernate.target"
"suspend-then-hibernate.target"
];
serviceConfig = {
Type = "oneshot";
ExecStart = "${pkgs.util-linux}/bin/rfkill unblock bluetooth";
};
wantedBy = [
"suspend.target"
"hibernate.target"
"suspend-then-hibernate.target"
];
};
};
}
+20
View File
@@ -0,0 +1,20 @@
{ lib, pkgs, ... }:
with lib;
{
imports = [
../../../common/cpu/amd/raphael/igpu.nix
./bluetooth.nix
./amd.nix
./audio.nix
./power
];
# Fix TRRS headphones missing a mic
# https://community.frame.work/t/headset-microphone-on-linux/12387/3
boot.extraModprobeConfig = mkIf (versionOlder pkgs.linux.version "6.6.8") ''
options snd-hda-intel model=dell-headset-multi
'';
# Needed for desktop environments to detect/manage display brightness
hardware.sensor.iio.enable = mkDefault true;
}
+6
View File
@@ -0,0 +1,6 @@
{
imports = [
../../../ppt.nix
./power-saving.nix
];
}
@@ -0,0 +1,18 @@
{ lib, config, ... }:
with lib;
let
cfg = config.hardware.gpd.duo.powerManagement;
in
{
options.hardware.gpd.duo.powerManagement = {
enable = mkEnableOption "Enable power-profiles-daemon and disable TLP for the GPD Duo" // {
# Default increase PPT to the BIOS default when power adapter plugin to increase performance.
default = true;
};
};
config = mkIf cfg.enable {
services.power-profiles-daemon.enable = mkDefault true;
services.tlp.enable = mkForce false;
};
}
+1
View File
@@ -10,6 +10,7 @@ in
../../common/cpu/amd/pstate.nix
../../common/gpu/amd
../../common/hidpi.nix
../ppt.nix
];
boot = {
+66
View File
@@ -0,0 +1,66 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.hardware.gpd.ppt;
in
{
# Linux default PPT is 24-22-22, BIOS default PPT is 35-32-28. It can be controlled by ryzenadj.
# NOTICE: Whenever you can limit PPT to 15W by pressing Fn + Shift to enter quiet mode.
options.hardware.gpd.ppt = {
enable = mkEnableOption "Enable PPT control for device by ryzenadj." // {
# Default increase PPT to the BIOS default when power adapter plugin to increase performance.
default = true;
};
adapter = {
fast-limit = mkOption {
description = "Fast PTT Limit(milliwatt) when power adapter plugin.";
default = 35000;
type = types.ints.unsigned;
};
slow-limit = mkOption {
description = "Slow PTT Limit(milliwatt) when power adapter plugin.";
default = 32000;
type = types.ints.unsigned;
};
stapm-limit = mkOption {
description = "Stapm PTT Limit(milliwatt) when power adapter plugin.";
default = 28000;
type = types.ints.unsigned;
};
};
battery = {
fast-limit = mkOption {
description = "Fast PTT Limit(milliwatt) when using battery.";
default = 24000;
type = types.ints.unsigned;
};
slow-limit = mkOption {
description = "Slow PTT Limit(milliwatt) when using battery.";
default = 22000;
type = types.ints.unsigned;
};
stapm-limit = mkOption {
description = "Stapm PTT Limit(milliwatt) when using battery.";
default = 22000;
type = types.ints.unsigned;
};
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.ryzenadj ];
services.udev.extraRules = ''
SUBSYSTEM=="power_supply", KERNEL=="ADP1", ATTR{online}=="1", RUN+="${getExe pkgs.ryzenadj} --stapm-limit ${toString cfg.adapter.stapm-limit} --fast-limit ${toString cfg.adapter.fast-limit} --slow-limit ${toString cfg.adapter.slow-limit}"
SUBSYSTEM=="power_supply", KERNEL=="ADP1", ATTR{online}=="0", RUN+="${getExe pkgs.ryzenadj} --stapm-limit ${toString cfg.battery.stapm-limit} --fast-limit ${toString cfg.battery.fast-limit} --slow-limit ${toString cfg.battery.slow-limit}"
'';
};
}
+2 -66
View File
@@ -1,72 +1,8 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.hardware.gpd.ppt;
in
{
{ ... }: {
imports = [
../../common/pc/laptop
../../common/pc/ssd
../../common/hidpi.nix
../ppt.nix
];
# Linux default PPT is 24-22-22, BIOS default PPT is 35-32-28. It can be controlled by ryzenadj.
# NOTICE: Whenever you can limit PPT to 15W by pressing Fn + Shift to enter quiet mode.
options.hardware.gpd.ppt = {
enable = mkEnableOption "Enable PPT control for device by ryzenadj." // {
# Default increase PPT to the BIOS default when power adapter plugin to increase performance.
default = true;
};
adapter = {
fast-limit = mkOption {
description = "Fast PTT Limit(milliwatt) when power adapter plugin.";
default = 35000;
type = types.ints.unsigned;
};
slow-limit = mkOption {
description = "Slow PTT Limit(milliwatt) when power adapter plugin.";
default = 32000;
type = types.ints.unsigned;
};
stapm-limit = mkOption {
description = "Stapm PTT Limit(milliwatt) when power adapter plugin.";
default = 28000;
type = types.ints.unsigned;
};
};
battery = {
fast-limit = mkOption {
description = "Fast PTT Limit(milliwatt) when using battery.";
default = 24000;
type = types.ints.unsigned;
};
slow-limit = mkOption {
description = "Slow PTT Limit(milliwatt) when using battery.";
default = 22000;
type = types.ints.unsigned;
};
stapm-limit = mkOption {
description = "Stapm PTT Limit(milliwatt) when using battery.";
default = 22000;
type = types.ints.unsigned;
};
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.ryzenadj ];
services.udev.extraRules = ''
SUBSYSTEM=="power_supply", KERNEL=="ADP1", ATTR{online}=="1", RUN+="${pkgs.ryzenadj}/bin/ryzenadj --stapm-limit ${toString cfg.adapter.stapm-limit} --fast-limit ${toString cfg.adapter.fast-limit} --slow-limit ${toString cfg.adapter.slow-limit}"
SUBSYSTEM=="power_supply", KERNEL=="ADP1", ATTR{online}=="0", RUN+="${pkgs.ryzenadj}/bin/ryzenadj --stapm-limit ${toString cfg.battery.stapm-limit} --fast-limit ${toString cfg.battery.fast-limit} --slow-limit ${toString cfg.battery.slow-limit}"
'';
};
}
+1
View File
@@ -6,6 +6,7 @@ with lib;
../../../common/cpu/amd
../../../common/cpu/amd/pstate.nix
../../../common/gpu/amd
../../ppt.nix
];
hardware.bluetooth.enable = lib.mkDefault true;
+3 -1
View File
@@ -2,7 +2,9 @@
{
imports = [
../../../common/cpu/intel
../../../common/cpu/intel/coffee-lake
../../../common/pc
../../../common/pc/ssd
];
services.thermald.enable = lib.mkDefault true;
-3
View File
@@ -1,9 +1,6 @@
{
imports = [
../../../common/cpu/intel
# might need nvidia module but we don't know the PCI ids:
# https://github.com/NixOS/nixos-hardware/pull/274#discussion_r650483740
#../../../common/gpu/nvidia/prime.nix
../../../common/pc/ssd
];
+68
View File
@@ -0,0 +1,68 @@
# Lenovo ThinkPad P1 Gen 5
https://www.lenovo.com/us/en/p/laptops/thinkpad/thinkpadp/thinkpad-p1-gen-5-16-inch-intel/len101t0033
Tested on a P1 Gen 5 with Intel Iris Xe (Alder Lake) graphics and an
NVIDIA GeForce RTX 3080 Ti Mobile (Ampere) discrete GPU.
- `lenovo-thinkpad-p1-gen5` — Alder Lake base; use on iGPU-only units.
- `lenovo-thinkpad-p1-gen5-nvidia` — adds NVIDIA PRIME **offload**. Run a
program on the discrete GPU with `nvidia-offload <command>`.
## Power management
The `-nvidia` profile enables PRIME **offload** but does not turn on fine-grained
runtime power management, so the discrete GPU stays powered even when idle —
noticeable battery drain on a laptop. That setting is experimental and depends on
the GPU + firmware supporting PCIe Runtime D3 (RTD3), so it is left to the user.
If your unit supports it, let the dGPU suspend when unused by adding to your own
configuration:
```nix
hardware.nvidia.powerManagement.finegrained = true;
```
## Tested Hardware
```shell
lspci -nn
00:00.0 Host bridge [0600]: Intel Corporation 12th Gen Core Processor Host Bridge/DRAM Registers [8086:4641] (rev 02)
00:01.0 PCI bridge [0604]: Intel Corporation 12th Gen Core Processor PCI Express x16 Controller #1 [8086:460d] (rev 02)
00:02.0 VGA compatible controller [0300]: Intel Corporation Alder Lake-P GT2 [Iris Xe Graphics] [8086:46a6] (rev 0c)
00:04.0 Signal processing controller [1180]: Intel Corporation Alder Lake Innovation Platform Framework Processor Participant [8086:461d] (rev 02)
00:06.0 PCI bridge [0604]: Intel Corporation 12th Gen Core Processor PCI Express x4 Controller #0 [8086:464d] (rev 02)
00:08.0 System peripheral [0880]: Intel Corporation 12th Gen Core Processor Gaussian & Neural Accelerator [8086:464f] (rev 02)
00:0a.0 Signal processing controller [1180]: Intel Corporation Platform Monitoring Technology [8086:467d] (rev 01)
00:14.0 USB controller [0c03]: Intel Corporation Alder Lake PCH USB 3.2 xHCI Host Controller [8086:51ed] (rev 01)
00:14.2 RAM memory [0500]: Intel Corporation Alder Lake PCH Shared SRAM [8086:51ef] (rev 01)
00:14.3 Network controller [0280]: Intel Corporation Alder Lake-P PCH CNVi WiFi [8086:51f0] (rev 01)
00:15.0 Serial bus controller [0c80]: Intel Corporation Alder Lake PCH Serial IO I2C Controller #0 [8086:51e8] (rev 01)
00:16.0 Communication controller [0780]: Intel Corporation Alder Lake PCH HECI Controller [8086:51e0] (rev 01)
00:16.3 Serial controller [0700]: Intel Corporation Alder Lake AMT SOL Redirection [8086:51e3] (rev 01)
00:1c.0 PCI bridge [0604]: Intel Corporation Device [8086:51b8] (rev 01)
00:1c.7 PCI bridge [0604]: Intel Corporation Alder Lake PCH-P PCI Express Root Port #9 [8086:51bf] (rev 01)
00:1d.0 PCI bridge [0604]: Intel Corporation Alder Lake PCI Express Root Port #9 [8086:51b0] (rev 01)
00:1f.0 ISA bridge [0601]: Intel Corporation Alder Lake PCH eSPI Controller [8086:5182] (rev 01)
00:1f.3 Multimedia audio controller [0401]: Intel Corporation Alder Lake PCH-P High Definition Audio Controller [8086:51c8] (rev 01)
00:1f.4 SMBus [0c05]: Intel Corporation Alder Lake PCH-P SMBus Host Controller [8086:51a3] (rev 01)
00:1f.5 Serial bus controller [0c80]: Intel Corporation Alder Lake-P PCH SPI Controller [8086:51a4] (rev 01)
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GA103M [GeForce RTX 3080 Ti Mobile] [10de:2420] (rev a1)
01:00.1 Audio device [0403]: NVIDIA Corporation Device [10de:2288] (rev a1)
04:00.0 Non-Volatile memory controller [0108]: SK hynix Gold P31/BC711/PC711 NVMe Solid State Drive [1c5c:174a]
0a:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS5261 PCIe SD Express Card Reader controller [10ec:5261] (rev 01)
20:00.0 PCI bridge [0604]: Intel Corporation Thunderbolt 4 Bridge [Maple Ridge 4C 2020] [8086:1136] (rev 02)
21:00.0 PCI bridge [0604]: Intel Corporation Thunderbolt 4 Bridge [Maple Ridge 4C 2020] [8086:1136] (rev 02)
21:01.0 PCI bridge [0604]: Intel Corporation Thunderbolt 4 Bridge [Maple Ridge 4C 2020] [8086:1136] (rev 02)
21:02.0 PCI bridge [0604]: Intel Corporation Thunderbolt 4 Bridge [Maple Ridge 4C 2020] [8086:1136] (rev 02)
21:03.0 PCI bridge [0604]: Intel Corporation Thunderbolt 4 Bridge [Maple Ridge 4C 2020] [8086:1136] (rev 02)
22:00.0 USB controller [0c03]: Intel Corporation Thunderbolt 4 NHI [Maple Ridge 4C 2020] [8086:1137]
56:00.0 USB controller [0c03]: Intel Corporation Thunderbolt 4 USB Controller [Maple Ridge 4C 2020] [8086:1138]
nix-info -m
- system: `"x86_64-linux"`
- host os: `Linux 7.0.11, NixOS, 26.05 (Yarara), 26.05.20260603.6b31628`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.34.7`
- nixpkgs: `/nix/store/snzg7swkp0vsd2qch9izsbmxnyb13ca0-source`
```
+7
View File
@@ -0,0 +1,7 @@
{ ... }:
{
imports = [
../.
../../../../common/cpu/intel/alder-lake # P1 Gen 5 is 12th-gen Alder Lake
];
}
@@ -0,0 +1,26 @@
{ lib, ... }:
{
imports = [
../.
../../../../../common/gpu/nvidia/ampere
../../../../../common/gpu/nvidia/prime.nix
];
hardware = {
graphics = {
enable = lib.mkDefault true;
enable32Bit = lib.mkDefault true;
};
nvidia = {
# "Wayland requires kernel mode setting (KMS) to be enabled (Highly
# Recommended)" per https://wiki.nixos.org/wiki/NVIDIA#Requirements.
modesetting.enable = lib.mkDefault true;
prime = {
# Bus ID of the Intel GPU.
intelBusId = lib.mkDefault "PCI:0:2:0";
# Bus ID of the NVIDIA GPU.
nvidiaBusId = lib.mkDefault "PCI:1:0:0";
};
};
};
}
+3 -3
View File
@@ -6,7 +6,7 @@
../../../../../common/cpu/amd/pstate.nix
];
# Embedded controller wake-ups drain battery in s2idle on this device
# See https://lore.kernel.org/all/ZnFYpWHJ5Ml724Nv@ohnotp/
boot.kernelParams = [ "acpi.ec_no_wakeup=1" ];
# Prevent the integrated RGB camera from dying during suspend.
# This issue was observed on Linux 6.18.38.
boot.kernelParams = [ "usbcore.quirks=30c9:00f4:b" ];
}
@@ -5,6 +5,7 @@ with lib;
{
imports = [
../.
../../../../common/cpu/intel/coffee-lake
];
# Fixes an issue with incorrect battery reporting. See
@@ -15,6 +16,9 @@ with lib;
# See also https://certification.ubuntu.com/catalog/component/input/5313/input%3ATPPS/2ElanTrackPoint/
hardware.trackpoint.device = "TPPS/2 Elan TrackPoint";
# Fix clickpad (clicking by depressing the touchpad).
boot.kernelParams = [ "psmouse.synaptics_intertouch=0" ];
# Since the HDMI port is connected to the NVIDIA card.
hardware.bumblebee.connectDisplay = true;
+20
View File
@@ -0,0 +1,20 @@
# Lenovo ThinkPad X1 Yoga Gen 8
## Camera
The X1 Yoga Gen 8 ships with one of two cameras, and each needs a
different profile.
| Camera | Check | Profile |
|-------------------------|-----------------------------------|----------------------------------------|
| USB (UVC) | `lsusb` lists "Integrated Camera" | `lenovo-thinkpad-x1-yoga-8th-gen` |
| MIPI sensor behind IPU6 | `lsmod` lists `intel_ipu6` | `lenovo-thinkpad-x1-yoga-8th-gen-ipu6` |
The USB camera works out of the box.
The MIPI camera works through libcamera without any extra configuration,
so browsers and GNOME can already use it through PipeWire. Applications
that speak plain V4L2, such as Zoom, can only see raw Bayer nodes and
report that there's no camera. The `ipu6` profile enables
`hardware.ipu6`, which relays the sensor to a regular V4L2 device. That
pulls in Intel's proprietary camera HAL and firmware.
@@ -0,0 +1,9 @@
{ lib, ... }:
{
imports = [ ../. ];
hardware.ipu6 = {
enable = lib.mkDefault true;
platform = lib.mkDefault "ipu6ep";
};
}
+9 -5
View File
@@ -20,14 +20,18 @@ let
supportedKernels =
let
lts-kernel = {
version = "6.19.8";
hash = "sha256-qtpHItuLz6C5cyhRhW1AUIK2pPouOrBnvo2xfN0RWzg=";
version = "6.18.60";
hash = "sha256-PC9E72rMAhp61ETZoubsHvSI/wk2h5PQAEpggPadYh4=";
};
stable-kernel = {
version = "7.3.1";
hash = "sha256-+llarZNzT4KcljwqkO98NnMiT9f9rntJQG45fN4t4jE=";
};
in
{
"longterm" = lts-kernel;
"stable" = lts-kernel;
"stable" = stable-kernel;
};
# Set the version and hash for the kernel sources
@@ -38,8 +42,8 @@ let
linux-surface = pkgs.fetchFromGitHub {
owner = "linux-surface";
repo = "linux-surface";
rev = "bf1921fc63f33d03a007fb38c4f88ff7e7bc1a55";
hash = "sha256-AV+J1iKpA4PEsX9oVUTGlzGerTWTermia3aJSZxuu/w=";
rev = "668a0208b4a713641f7f04a73631008b1f522257";
hash = "sha256-RnlQMpIPTE+QbFlMMwq5Qj95tlVkyRkR8WqaPlivMXM=";
};
# Fetch and build the kernel
@@ -162,8 +162,4 @@
name = "ms-surface/0016-hid-surface";
patch = patchSrc + "/0016-hid-surface.patch";
}
{
name = "ms-surface/0017-powercap";
patch = patchSrc + "/0017-powercap.patch";
}
]
@@ -0,0 +1,155 @@
{
lib,
kernel ? lib.kernel,
patchSrc,
version,
}:
[
{
name = "microsoft-surface-patches-linux-${version}";
patch = null;
structuredExtraConfig = with kernel; {
##
## Surface Aggregator Module
##
CONFIG_SURFACE_AGGREGATOR = module;
# CONFIG_SURFACE_AGGREGATOR_ERROR_INJECTION is not set
CONFIG_SURFACE_AGGREGATOR_BUS = yes;
CONFIG_SURFACE_AGGREGATOR_CDEV = module;
CONFIG_SURFACE_AGGREGATOR_HUB = module;
CONFIG_SURFACE_AGGREGATOR_REGISTRY = module;
CONFIG_SURFACE_AGGREGATOR_TABLET_SWITCH = module;
CONFIG_SURFACE_ACPI_NOTIFY = module;
CONFIG_SURFACE_DTX = module;
CONFIG_SURFACE_PLATFORM_PROFILE = module;
CONFIG_SURFACE_HID = module;
CONFIG_SURFACE_KBD = module;
CONFIG_BATTERY_SURFACE = module;
CONFIG_CHARGER_SURFACE = module;
CONFIG_SENSORS_SURFACE_TEMP = module;
CONFIG_SENSORS_SURFACE_FAN = module;
CONFIG_RTC_DRV_SURFACE = module;
##
## Surface Hotplug
##
CONFIG_SURFACE_HOTPLUG = module;
##
## IPTS and ITHC touchscreen
##
## This only enables the user interface for IPTS/ITHC data.
## For the touchscreen to work, you need to install iptsd.
##
CONFIG_HID_IPTS = module;
CONFIG_HID_ITHC = module;
CONFIG_INTEL_THC_HID = module;
CONFIG_INTEL_QUICKSPI = module;
##
## Cameras: IPU3
##
CONFIG_VIDEO_DW9719 = module;
CONFIG_VIDEO_IPU3_IMGU = module;
CONFIG_VIDEO_IPU3_CIO2 = module;
CONFIG_IPU_BRIDGE = module;
CONFIG_INTEL_SKL_INT3472 = module;
CONFIG_REGULATOR_TPS68470 = module;
CONFIG_COMMON_CLK_TPS68470 = module;
CONFIG_LEDS_TPS68470 = module;
##
## Cameras: Sensor drivers
##
CONFIG_VIDEO_OV5693 = module;
CONFIG_VIDEO_OV7251 = module;
CONFIG_VIDEO_OV8865 = module;
##
## Surface 3: atomisp causes problems (see issue #1095). Disable it for now.
##
# CONFIG_INTEL_ATOMISP is not set
##
## ALS Sensor for Surface Book 3, Surface Laptop 3, Surface Pro 7
##
CONFIG_APDS9960 = module;
##
## Other Drivers
##
CONFIG_INPUT_SOC_BUTTON_ARRAY = module;
CONFIG_SURFACE_3_POWER_OPREGION = module;
CONFIG_SURFACE_PRO3_BUTTON = module;
CONFIG_SURFACE_GPE = module;
CONFIG_SURFACE_BOOK1_DGPU_SWITCH = module;
CONFIG_HID_SURFACE = module;
};
}
{
name = "ms-surface/0001-secureboot";
patch = patchSrc + "/0001-secureboot.patch";
}
{
name = "ms-surface/0002-surface3";
patch = patchSrc + "/0002-surface3.patch";
}
{
name = "ms-surface/0003-mwifiex";
patch = patchSrc + "/0003-mwifiex.patch";
}
{
name = "ms-surface/0004-ath10k";
patch = patchSrc + "/0004-ath10k.patch";
}
{
name = "ms-surface/0005-ipts";
patch = patchSrc + "/0005-ipts.patch";
}
{
name = "ms-surface/0006-ithc";
patch = patchSrc + "/0006-ithc.patch";
}
{
name = "ms-surface/0007-surface-sam";
patch = patchSrc + "/0007-surface-sam.patch";
}
{
name = "ms-surface/0008-surface-sam-over-hid";
patch = patchSrc + "/0008-surface-sam-over-hid.patch";
}
{
name = "ms-surface/0009-surface-button";
patch = patchSrc + "/0009-surface-button.patch";
}
{
name = "ms-surface/0010-surface-typecover";
patch = patchSrc + "/0010-surface-typecover.patch";
}
{
name = "ms-surface/0011-surface-shutdown";
patch = patchSrc + "/0011-surface-shutdown.patch";
}
{
name = "ms-surface/0012-surface-gpe";
patch = patchSrc + "/0012-surface-gpe.patch";
}
{
name = "ms-surface/0013-cameras";
patch = patchSrc + "/0013-cameras.patch";
}
{
name = "ms-surface/0014-amd-gpio";
patch = patchSrc + "/0014-amd-gpio.patch";
}
{
name = "ms-surface/0015-hid-surface";
patch = patchSrc + "/0015-hid-surface.patch";
}
]
+6 -3
View File
@@ -1,4 +1,5 @@
{
runCommand,
lib,
fetchFromGitLab,
}:
@@ -7,6 +8,8 @@ let
sources = lib.importJSON ./sources.json;
reformDebianPackages = fetchFromGitLab sources.reformDebianPackages;
in
map (lib.removePrefix "${reformDebianPackages}/") (
lib.filesystem.listFilesRecursive "${reformDebianPackages}/linux/patches${lib.versions.majorMinor sources.modDirVersion}"
)
runCommand "mnt-reform-kernel-patches" { } ''
shopt -s globstar
cd ${reformDebianPackages}
echo -e "[\n$(printf ' "%s"\n' linux/patches${lib.versions.majorMinor sources.modDirVersion}/**/*.patch)\n]"> $out
''
+2 -2
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
nix eval .#mnt-reform-kernel-patches > kernelPatches.nix
nix fmt kernelPatches.nix
nix build .#mnt-reform-kernel-patches
cp result kernelPatches.nix
+9
View File
@@ -0,0 +1,9 @@
This module supports the following laptop models:
- MSI GF63 Thin 9SC
- MSI GF63 Thin 9SCX
- MSI GF63 Thin 9SCXR
- MSI GF63 Thin 9SCSR
For specifications, visit MSI's
[product page](https://www.msi.com/Laptop/GF63-Thin-9SX-GTX/Specification).
+28
View File
@@ -0,0 +1,28 @@
{ lib, ... }:
{
imports = [
../../common/pc/laptop
../../common/pc/ssd
../../common/cpu/intel
../../common/gpu/nvidia/turing
../../common/gpu/nvidia/prime.nix
];
boot.kernelParams = [
# For Power consumption in case of NVME SSD
# was installed.
"nvme.noacpi=1"
# For fixing interferences with Fn- action keys
"video.report_key_events=0"
];
hardware.nvidia.prime = {
# Bus ID of the Intel GPU.
intelBusId = lib.mkDefault "PCI:0:2:0";
# Bus ID of the NVIDIA GPU.
nvidiaBusId = lib.mkDefault "PCI:1:0:0";
};
}
+46
View File
@@ -0,0 +1,46 @@
{ lib, pkgs, ... }:
{
# Preserve the legacy ARMv6 boot configuration rather than opting into the
# graphics and camera defaults used by the newer Raspberry Pi profiles.
imports = [
../common/config-txt.nix
../common/firmware.nix
];
nixpkgs.hostPlatform = lib.mkDefault "armv6l-linux";
boot = {
consoleLogLevel = lib.mkDefault 7;
kernelPackages = lib.mkDefault (
pkgs.linuxPackagesFor (pkgs.callPackage ../common/kernel.nix { rpiVersion = 1; })
);
# The vendor defconfig does not provide the generic PCI storage drivers.
initrd = {
includeDefaultModules = lib.mkDefault false;
systemd.tpm2.enable = lib.mkDefault false;
availableKernelModules = {
mmc_block = true;
usb_storage = true;
usbhid = true;
# EFI variable access is not needed for the U-Boot boot path.
efivarfs = lib.mkForce false;
};
};
loader = {
grub.enable = lib.mkDefault false;
generic-extlinux-compatible.enable = lib.mkDefault true;
};
};
hardware.raspberry-pi = {
configtxt.settings.all = {
enable_uart = lib.mkDefault true;
avoid_warnings = lib.mkDefault 1;
};
firmware.uboot = {
enable = lib.mkDefault true;
package = lib.mkDefault pkgs.ubootRaspberryPi;
};
};
}
+11
View File
@@ -0,0 +1,11 @@
{ modulesPath, ... }:
{
imports = [
"${modulesPath}/profiles/installation-device.nix"
./sd-image.nix
];
# The installation media is also the installation target.
installer.cloneConfig = false;
}
+28
View File
@@ -0,0 +1,28 @@
# Adapted from nixpkgs' installer/sd-card/sd-image-raspberrypi.nix.
{
config,
lib,
modulesPath,
...
}:
{
imports = [
# The generic installer utilities include EFI tools broken on 32-bit ARM.
"${modulesPath}/profiles/minimal.nix"
"${modulesPath}/installer/sd-card/sd-image.nix"
./default.nix
];
# This image targets the Pi 1, whose vendor kernel lacks generic PCI drivers.
hardware.enableAllHardware = lib.mkForce false;
sdImage = {
# The shared firmware installer also copies the device-tree overlays.
firmwareSize = lib.mkDefault 128;
populateRootCommands = ''
mkdir -p ./files/boot
${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot
'';
};
}
-10
View File
@@ -1,10 +0,0 @@
** Status
The code in master as of June 2015 should be able to prepare a bootable NixOS
for Raspberry PI 2.
There are still some drawbacks:
NixOS does not provide a /boot/config.txt (the FAT32 partition). Making NixOS
work in the Raspberry PI 2 is mainly the result of the recent work of ambro718,
Dezgeg and viric (#nixos@irc.freenode.net).
+1
View File
@@ -35,4 +35,5 @@
"console=tty0"
];
hardware.firmware = [ (pkgs.callPackage ../common/raspberry-pi-wireless-firmware.nix { }) ];
}
+9 -48
View File
@@ -1,50 +1,11 @@
{ lib, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.hardware.raspberry-pi."4".audio;
in
{
options.hardware = {
raspberry-pi."4".audio = {
enable = lib.mkEnableOption "configuration for audio";
};
};
config = lib.mkIf cfg.enable {
hardware.deviceTree = {
overlays = [
# Equivalent to dtparam=audio=on
{
name = "audio-on-overlay";
dtsText = ''
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2711";
fragment@0 {
target = <&audio>;
__overlay__ {
status = "okay";
};
};
};
'';
}
];
};
# set tsched=0 in pulseaudio config to avoid audio glitches
# see https://wiki.archlinux.org/title/PulseAudio/Troubleshooting#Glitches,_skips_or_crackling
hardware.pulseaudio.configFile = lib.mkOverride 990 (
pkgs.runCommand "default.pa" { } ''
sed 's/module-udev-detect$/module-udev-detect tsched=0/' ${config.hardware.pulseaudio.package}/etc/pulse/default.pa > $out
''
);
};
imports = [
../common
(lib.mkRenamedOptionModule
[ "hardware" "raspberry-pi" "4" "audio" "enable" ]
[ "hardware" "raspberry-pi" "audio" "enable" ]
)
];
}
-24
View File
@@ -1,24 +0,0 @@
{
hardware.deviceTree.overlays = [
{
name = "rpi4-cpu-revision";
dtsText = ''
/dts-v1/;
/plugin/;
/ {
compatible = "raspberrypi,4-model-b";
fragment@0 {
target-path = "/";
__overlay__ {
system {
linux,revision = <0x00d03114>;
};
};
};
};
'';
}
];
}
-1
View File
@@ -11,7 +11,6 @@
./audio.nix
./backlight.nix
./bluetooth.nix
./cpu-revision.nix
./digi-amp-plus.nix
./dwc2.nix
./gpio.nix
+33 -82
View File
@@ -1,91 +1,42 @@
{ config, lib, ... }:
{ lib, ... }:
let
cfg = config.hardware.raspberry-pi."4".digi-amp-plus;
in
{
options.hardware = {
raspberry-pi."4".digi-amp-plus = {
enable = lib.mkEnableOption "support for the IQaudIO DigiAMP+ Hat";
imports = [
(lib.mkRemovedOptionModule
[
"hardware"
"raspberry-pi"
"4"
"digi-amp-plus"
]
''
Use the stock iqaudio-dacplus firmware overlay instead:
unmuteAmp = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to "one-shot" unmute when kernel module first loads.
'';
};
{
boot.loader.generic-extlinux-compatible.useGenerationDeviceTree =
false;
autoMuteAmp = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Unmute the amp when an ALSA device is opened by a client. Mute, with a five-second delay when the ALSA device is closed.
(Reopening the device within the five-second close window will cancel mute.)
'';
};
};
};
config = lib.mkIf cfg.enable {
hardware.raspberry-pi."4".apply-overlays-dtmerge.enable = lib.mkDefault true;
hardware.deviceTree = {
overlays = [
# Adapted from to: https://github.com/raspberrypi/linux/blob/3ed6d34d53e94ecbebc64c8fa3d1b6d3c41db8fb/arch/arm/boot/dts/overlays/iqaudio-dacplus-overlay.dts
# changes:
# - modified top-level "compatible" field from bcm2835 to bcm2711
# - s/i2s_clk_producer/i2s/ (name on bcm2711 platform)
{
name = "iqaudio-digiampplus-overlay";
dtsText = ''
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2711";
fragment@0 {
target = <&i2s>;
__overlay__ {
status = "okay";
hardware.raspberry-pi.configtxt.deviceTreeOverlays.pi4 = [
{
iqaudio-dacplus = {
auto_mute_amp = true;
unmute_amp = false;
};
};
}
];
}
fragment@1 {
target = <&i2c1>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
Keep the old boolean values. Map autoMuteAmp to auto_mute_amp and
unmuteAmp to unmute_amp.
pcm5122@4c {
#sound-dai-cells = <0>;
compatible = "ti,pcm5122";
reg = <0x4c>;
AVDD-supply = <&vdd_3v3_reg>;
DVDD-supply = <&vdd_3v3_reg>;
CPVDD-supply = <&vdd_3v3_reg>;
status = "okay";
};
};
};
On a running system, set hardware.raspberry-pi.firmware.enable to true.
fragment@2 {
target = <&sound>;
iqaudio_dac: __overlay__ {
compatible = "iqaudio,iqaudio-dac";
i2s-controller = <&i2s>;
mute-gpios = <&gpio 22 0>;
status = "okay";
${lib.optionalString cfg.unmuteAmp "iqaudio-dac,unmute-amp;"}
${lib.optionalString cfg.autoMuteAmp "iqaudio-dac,auto-mute-amp;"}
};
};
};
'';
}
];
};
};
For NixOS-Hardware specific firmware setup, read:
raspberry-pi/README.md.
For digiamp specific details, see:
https://www.raspberrypi.com/documentation/accessories/audio.html#raspberry-pi-digiamp
''
)
];
}
+26 -78
View File
@@ -1,86 +1,34 @@
{ config, lib, ... }:
{ lib, ... }:
let
cfg = config.hardware.raspberry-pi."4".dwc2;
in
{
options.hardware = {
raspberry-pi."4".dwc2 = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
description = ''
Enable the UDC controller to support USB OTG gadget functions.
imports = [
(lib.mkRemovedOptionModule
[
"hardware"
"raspberry-pi"
"4"
"dwc2"
]
''
Use the stock dwc2 firmware overlay instead:
In order to verify that this works, connect the Raspberry Pi with
another computer via the USB C cable, and then do one of:
{
boot.loader.generic-extlinux-compatible.useGenerationDeviceTree =
false;
- `modprobe g_serial`
- `modprobe g_mass_storage file=/path/to/some/iso-file.iso`
hardware.raspberry-pi.configtxt.deviceTreeOverlays.pi4 = [
{ dwc2 = { }; }
];
}
On the Raspberry Pi, `dmesg` should then show success-indicating output
that is related to the dwc2 and g_serial/g_mass_storage modules.
On the other computer, a serial/mass-storage device should pop up in
the system logs.
If you set dr_mode on the old option, add it to the overlay. For
example:
For more information about what gadget functions exist along with handy
guides on how to test them, please refer to:
https://www.kernel.org/doc/Documentation/usb/gadget-testing.txt
'';
};
dr_mode = lib.mkOption {
type = lib.types.enum [
"host"
"peripheral"
"otg"
];
default = "otg";
description = ''
Dual role mode setting for the dwc2 USB controller driver.
'';
};
};
};
{ dwc2.dr_mode = "host"; }
config = lib.mkIf cfg.enable {
# Configure for modesetting in the device tree
hardware.deviceTree = {
overlays = [
# this *should* be equivalent to (which doesn't work):
# https://github.com/raspberrypi/linux/blob/rpi-5.10.y/arch/arm/boot/dts/overlays/dwc2-overlay.dts
# but actually it's obtained using
# dtc -I dtb -O dts ${config.hardware.deviceTree.kernelPackage}/dtbs/overlays/dwc2.dtbo
# (changes: modified top-level "compatible" field)
# which is slightly different and works
{
name = "dwc2-overlay";
dtsText = ''
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2711";
fragment@0 {
target = <&usb>;
#address-cells = <0x01>;
#size-cells = <0x01>;
__overlay__ {
compatible = "brcm,bcm2835-usb";
dr_mode = "${cfg.dr_mode}";
g-np-tx-fifo-size = <0x20>;
g-rx-fifo-size = <0x22e>;
g-tx-fifo-size = <0x200 0x200 0x200 0x200 0x200 0x100 0x100>;
status = "okay";
phandle = <0x01>;
};
};
};
'';
}
];
};
};
For CM4 and firmware-partition setup, see "DWC2 USB controller" in
raspberry-pi/README.md.
''
)
];
}
+29 -226
View File
@@ -1,232 +1,35 @@
{ config, lib, ... }:
{ lib, ... }:
let
cfg = config.hardware.raspberry-pi."4".poe-hat;
in
{
options.hardware = {
raspberry-pi."4".poe-hat = {
enable = lib.mkEnableOption "support for the Raspberry Pi POE Hat";
fan = lib.mkOption {
type = lib.types.submodule {
options = {
temperature0 = lib.mkOption {
type = lib.types.int;
default = 40000;
description = "Temperature threshold 0.";
};
hysteresis0 = lib.mkOption {
type = lib.types.int;
default = 2000;
description = "Temperature hysteresis 0.";
};
temperature1 = lib.mkOption {
type = lib.types.int;
default = 45000;
description = "Temperature threshold 1.";
};
hysteresis1 = lib.mkOption {
type = lib.types.int;
default = 2000;
description = "Temperature hysteresis 1.";
};
temperature2 = lib.mkOption {
type = lib.types.int;
default = 50000;
description = "Temperature threshold 2.";
};
hysteresis2 = lib.mkOption {
type = lib.types.int;
default = 2000;
description = "Temperature hysteresis 2.";
};
temperature3 = lib.mkOption {
type = lib.types.int;
default = 55000;
description = "Temperature threshold 3.";
};
hysteresis3 = lib.mkOption {
type = lib.types.int;
default = 5000;
description = "Temperature hysteresis 3.";
};
};
};
imports = [
(lib.mkRemovedOptionModule
[
"hardware"
"raspberry-pi"
"4"
"poe-hat"
]
''
Use the stock rpi-poe firmware overlay instead:
default = { };
description = "Fan configuration.";
};
};
};
config = lib.mkIf cfg.enable {
hardware.raspberry-pi."4".apply-overlays-dtmerge.enable = lib.mkDefault true;
# doesn't work for the CM module, so we exclude e.g. bcm2711-rpi-cm4.dts
hardware.deviceTree.filter = "bcm2711-rpi-4*.dtb";
hardware.deviceTree = {
overlays = [
# Equivalent to: https://github.com/raspberrypi/linux/blob/rpi-6.6.y/arch/arm/boot/dts/overlays/rpi-poe-overlay.dts
{
name = "rpi-poe-overlay";
dtsText = ''
/*
* Overlay for the Raspberry Pi POE HAT.
*/
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2711";
fragment@0 {
target-path = "/";
__overlay__ {
fan: pwm-fan {
compatible = "pwm-fan";
cooling-levels = <0 1 10 100 255>;
#cooling-cells = <2>;
pwms = <&fwpwm 0 80000 0>;
};
};
hardware.raspberry-pi.configtxt.deviceTreeOverlays."board-type=0x11" = [
{
rpi-poe = {
poe_fan_temp0 = 40000;
poe_fan_temp0_hyst = 2000;
poe_fan_temp1 = 45000;
poe_fan_temp1_hyst = 2000;
poe_fan_temp2 = 50000;
poe_fan_temp2_hyst = 2000;
poe_fan_temp3 = 55000;
poe_fan_temp3_hyst = 5000;
};
}
];
fragment@1 {
target = <&cpu_thermal>;
__overlay__ {
polling-delay = <2000>; /* milliseconds */
};
};
fragment@2 {
target = <&thermal_trips>;
__overlay__ {
trip0: trip0 {
temperature = <${toString cfg.fan.temperature0}>;
hysteresis = <${toString cfg.fan.hysteresis0}>;
type = "active";
};
trip1: trip1 {
temperature = <${toString cfg.fan.temperature1}>;
hysteresis = <${toString cfg.fan.hysteresis1}>;
type = "active";
};
trip2: trip2 {
temperature = <${toString cfg.fan.temperature2}>;
hysteresis = <${toString cfg.fan.hysteresis2}>;
type = "active";
};
trip3: trip3 {
temperature = <${toString cfg.fan.temperature3}>;
hysteresis = <${toString cfg.fan.hysteresis3}>;
type = "active";
};
};
};
fragment@3 {
target = <&cooling_maps>;
__overlay__ {
map0 {
trip = <&trip0>;
cooling-device = <&fan 0 1>;
};
map1 {
trip = <&trip1>;
cooling-device = <&fan 1 2>;
};
map2 {
trip = <&trip2>;
cooling-device = <&fan 2 3>;
};
map3 {
trip = <&trip3>;
cooling-device = <&fan 3 4>;
};
};
};
fragment@4 {
target-path = "/__overrides__";
params: __overlay__ {
poe_fan_temp0 = <&trip0>,"temperature:0";
poe_fan_temp0_hyst = <&trip0>,"hysteresis:0";
poe_fan_temp1 = <&trip1>,"temperature:0";
poe_fan_temp1_hyst = <&trip1>,"hysteresis:0";
poe_fan_temp2 = <&trip2>,"temperature:0";
poe_fan_temp2_hyst = <&trip2>,"hysteresis:0";
poe_fan_temp3 = <&trip3>,"temperature:0";
poe_fan_temp3_hyst = <&trip3>,"hysteresis:0";
poe_fan_i2c = <&fwpwm>,"status=disabled",
<&poe_mfd>,"status=okay",
<&fan>,"pwms:0=",<&poe_mfd_pwm>;
};
};
fragment@5 {
target = <&firmware>;
__overlay__ {
fwpwm: pwm {
compatible = "raspberrypi,firmware-poe-pwm";
#pwm-cells = <2>;
};
};
};
fragment@6 {
target = <&i2c0>;
i2c_bus: __overlay__ {
#address-cells = <1>;
#size-cells = <0>;
poe_mfd: poe@51 {
compatible = "raspberrypi,poe-core";
reg = <0x51>;
status = "disabled";
poe_mfd_pwm: poe_pwm@f0 {
compatible = "raspberrypi,poe-pwm";
reg = <0xf0>;
status = "okay";
#pwm-cells = <2>;
};
};
};
};
fragment@7 {
target = <&i2c0if>;
__dormant__ {
status = "okay";
};
};
fragment@8 {
target = <&i2c0mux>;
__dormant__ {
status = "okay";
};
};
__overrides__ {
poe_fan_temp0 = <&trip0>,"temperature:0";
poe_fan_temp0_hyst = <&trip0>,"hysteresis:0";
poe_fan_temp1 = <&trip1>,"temperature:0";
poe_fan_temp1_hyst = <&trip1>,"hysteresis:0";
poe_fan_temp2 = <&trip2>,"temperature:0";
poe_fan_temp2_hyst = <&trip2>,"hysteresis:0";
poe_fan_temp3 = <&trip3>,"temperature:0";
poe_fan_temp3_hyst = <&trip3>,"hysteresis:0";
i2c = <0>, "+5+6",
<&fwpwm>,"status=disabled",
<&i2c_bus>,"status=okay",
<&poe_mfd>,"status=okay",
<&fan>,"pwms:0=",<&poe_mfd_pwm>;
};
};
'';
}
];
};
};
These are the overlay defaults. Parameters that were not customized can
be omitted.
''
)
];
}
+29 -276
View File
@@ -1,282 +1,35 @@
{ config, lib, ... }:
{ lib, ... }:
let
cfg = config.hardware.raspberry-pi."4".poe-plus-hat;
in
{
options.hardware = {
raspberry-pi."4".poe-plus-hat = {
enable = lib.mkEnableOption "support for the Raspberry Pi PoE+ HAT";
fan = lib.mkOption {
type = lib.types.submodule {
options = {
temperature0 = lib.mkOption {
type = lib.types.int;
default = 40000;
description = "Temperature threshold 0.";
};
hysteresis0 = lib.mkOption {
type = lib.types.int;
default = 2000;
description = "Temperature hysteresis 0.";
};
temperature1 = lib.mkOption {
type = lib.types.int;
default = 45000;
description = "Temperature threshold 1.";
};
hysteresis1 = lib.mkOption {
type = lib.types.int;
default = 2000;
description = "Temperature hysteresis 1.";
};
temperature2 = lib.mkOption {
type = lib.types.int;
default = 50000;
description = "Temperature threshold 2.";
};
hysteresis2 = lib.mkOption {
type = lib.types.int;
default = 2000;
description = "Temperature hysteresis 2.";
};
temperature3 = lib.mkOption {
type = lib.types.int;
default = 55000;
description = "Temperature threshold 3.";
};
hysteresis3 = lib.mkOption {
type = lib.types.int;
default = 5000;
description = "Temperature hysteresis 3.";
};
};
};
imports = [
(lib.mkRemovedOptionModule
[
"hardware"
"raspberry-pi"
"4"
"poe-plus-hat"
]
''
Use the stock rpi-poe-plus firmware overlay instead:
default = { };
description = "Fan configuration.";
};
};
};
config = lib.mkIf cfg.enable {
hardware.raspberry-pi."4".apply-overlays-dtmerge.enable = lib.mkDefault true;
# doesn't work for the CM module, so we exclude e.g. bcm2711-rpi-cm4.dts
hardware.deviceTree.filter = "bcm2711-rpi-4*.dtb";
hardware.deviceTree = {
overlays = [
# Combined equivalent to:
# * https://github.com/raspberrypi/linux/blob/rpi-6.6.y/arch/arm/boot/dts/overlays/rpi-poe-overlay.dts
# * https://github.com/raspberrypi/linux/blob/rpi-6.6.y/arch/arm/boot/dts/overlays/rpi-poe-plus-overlay.dts
{
name = "rpi-poe-plus-overlay";
dtsText = ''
/*
* Overlay for the Raspberry Pi POE HAT.
*/
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2711";
fragment@0 {
target-path = "/";
__overlay__ {
fan: pwm-fan {
compatible = "pwm-fan";
cooling-levels = <0 1 10 100 255>;
#cooling-cells = <2>;
pwms = <&fwpwm 0 80000 0>;
};
};
hardware.raspberry-pi.configtxt.deviceTreeOverlays."board-type=0x11" = [
{
rpi-poe-plus = {
poe_fan_temp0 = 40000;
poe_fan_temp0_hyst = 2000;
poe_fan_temp1 = 45000;
poe_fan_temp1_hyst = 2000;
poe_fan_temp2 = 50000;
poe_fan_temp2_hyst = 2000;
poe_fan_temp3 = 55000;
poe_fan_temp3_hyst = 5000;
};
}
];
fragment@1 {
target = <&cpu_thermal>;
__overlay__ {
polling-delay = <2000>; /* milliseconds */
};
};
fragment@2 {
target = <&thermal_trips>;
__overlay__ {
trip0: trip0 {
temperature = <${toString cfg.fan.temperature0}>;
hysteresis = <${toString cfg.fan.hysteresis0}>;
type = "active";
};
trip1: trip1 {
temperature = <${toString cfg.fan.temperature1}>;
hysteresis = <${toString cfg.fan.hysteresis1}>;
type = "active";
};
trip2: trip2 {
temperature = <${toString cfg.fan.temperature2}>;
hysteresis = <${toString cfg.fan.hysteresis2}>;
type = "active";
};
trip3: trip3 {
temperature = <${toString cfg.fan.temperature3}>;
hysteresis = <${toString cfg.fan.hysteresis3}>;
type = "active";
};
};
};
fragment@3 {
target = <&cooling_maps>;
__overlay__ {
map0 {
trip = <&trip0>;
cooling-device = <&fan 0 1>;
};
map1 {
trip = <&trip1>;
cooling-device = <&fan 1 2>;
};
map2 {
trip = <&trip2>;
cooling-device = <&fan 2 3>;
};
map3 {
trip = <&trip3>;
cooling-device = <&fan 3 4>;
};
};
};
fragment@4 {
target-path = "/__overrides__";
params: __overlay__ {
poe_fan_temp0 = <&trip0>,"temperature:0";
poe_fan_temp0_hyst = <&trip0>,"hysteresis:0";
poe_fan_temp1 = <&trip1>,"temperature:0";
poe_fan_temp1_hyst = <&trip1>,"hysteresis:0";
poe_fan_temp2 = <&trip2>,"temperature:0";
poe_fan_temp2_hyst = <&trip2>,"hysteresis:0";
poe_fan_temp3 = <&trip3>,"temperature:0";
poe_fan_temp3_hyst = <&trip3>,"hysteresis:0";
poe_fan_i2c = <&fwpwm>,"status=disabled",
<&poe_mfd>,"status=okay",
<&fan>,"pwms:0=",<&poe_mfd_pwm>;
};
};
fragment@5 {
target = <&firmware>;
__overlay__ {
fwpwm: pwm {
compatible = "raspberrypi,firmware-poe-pwm";
#pwm-cells = <2>;
};
};
};
fragment@6 {
target = <&i2c0>;
i2c_bus: __overlay__ {
#address-cells = <1>;
#size-cells = <0>;
poe_mfd: poe@51 {
compatible = "raspberrypi,poe-core";
reg = <0x51>;
status = "disabled";
poe_mfd_pwm: poe_pwm@f0 {
compatible = "raspberrypi,poe-pwm";
reg = <0xf0>;
status = "okay";
#pwm-cells = <2>;
};
};
};
};
fragment@7 {
target = <&i2c0if>;
__dormant__ {
status = "okay";
};
};
fragment@8 {
target = <&i2c0mux>;
__dormant__ {
status = "okay";
};
};
__overrides__ {
poe_fan_temp0 = <&trip0>,"temperature:0";
poe_fan_temp0_hyst = <&trip0>,"hysteresis:0";
poe_fan_temp1 = <&trip1>,"temperature:0";
poe_fan_temp1_hyst = <&trip1>,"hysteresis:0";
poe_fan_temp2 = <&trip2>,"temperature:0";
poe_fan_temp2_hyst = <&trip2>,"hysteresis:0";
poe_fan_temp3 = <&trip3>,"temperature:0";
poe_fan_temp3_hyst = <&trip3>,"hysteresis:0";
i2c = <0>, "+5+6",
<&fwpwm>,"status=disabled",
<&i2c_bus>,"status=okay",
<&poe_mfd>,"status=okay",
<&fan>,"pwms:0=",<&poe_mfd_pwm>;
};
};
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
// Overlay for the Raspberry Pi PoE+ HAT.
/ {
compatible = "brcm,bcm2711";
fragment@10 {
target-path = "/";
__overlay__ {
rpi_poe_power_supply: rpi-poe-power-supply {
compatible = "raspberrypi,rpi-poe-power-supply";
firmware = <&firmware>;
status = "okay";
};
};
};
fragment@11 {
target = <&poe_mfd>;
__overlay__ {
rpi-poe-power-supply@f2 {
compatible = "raspberrypi,rpi-poe-power-supply";
reg = <0xf2>;
status = "okay";
};
};
};
__overrides__ {
i2c = <0>, "+5+6",
<&fwpwm>,"status=disabled",
<&rpi_poe_power_supply>,"status=disabled",
<&i2c_bus>,"status=okay",
<&poe_mfd>,"status=okay",
<&fan>,"pwms:0=",<&poe_mfd_pwm>;
};
};
&fan {
cooling-levels = <0 32 64 128 255>;
};
&params {
poe_fan_i2c = <&fwpwm>,"status=disabled",
<&rpi_poe_power_supply>,"status=disabled",
<&poe_mfd>,"status=okay",
<&fan>,"pwms:0=",<&poe_mfd_pwm>;
};
'';
}
];
};
};
These are the overlay defaults. Parameters that were not customized can
be omitted.
''
)
];
}
+31 -43
View File
@@ -1,50 +1,38 @@
{ config, lib, ... }:
{ lib, ... }:
let
cfg = config.hardware.raspberry-pi."4".pwm0;
in
{
options.hardware = {
raspberry-pi."4".pwm0 = {
enable = lib.mkEnableOption "support for the hardware pwm0 channel on GPIO_18";
};
};
imports = [
(lib.mkRemovedOptionModule
[
"hardware"
"raspberry-pi"
"4"
"pwm0"
]
''
To enable PWM0 on GPIO18, use the pwm firmware overlay:
config = lib.mkIf cfg.enable {
hardware.deviceTree = {
overlays = [
{
name = "pwm-overlay";
dtsText = ''
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2711";
fragment@0 {
target = <&gpio>;
__overlay__ {
pwm_pins: pwm_pins {
brcm,pins = <18>;
brcm,function = <2>; /* Alt5 */
};
{
boot.loader.generic-extlinux-compatible.useGenerationDeviceTree = false;
hardware.raspberry-pi.configtxt.deviceTreeOverlays.pi4 = [
{
pwm = {
pin = 18;
func = 2;
clock = 100000000;
};
};
}
];
}
fragment@1 {
target = <&pwm>;
__overlay__ {
pinctrl-names = "default";
assigned-clock-rates = <100000000>;
status = "okay";
pinctrl-0 = <&pwm_pins>;
};
};
The removed pwm0 module explicitly assigned a 100 MHz clock.
Keep clock = 100000000 to preserve that assignment.
Without clock, the pwm overlay leaves the base clock configuration unchanged:
https://github.com/raspberrypi/linux/blob/rpi-6.18.y/arch/arm/boot/dts/overlays/pwm-overlay.dts
};
'';
}
];
};
};
Before switching, migrate any remaining hardware.deviceTree.overlays used only in generation DTBs.
For firmware installation, read "Device tree overlays" in raspberry-pi/README.md.
''
)
];
}
+2
View File
@@ -49,4 +49,6 @@ in
message = "The Raspberry Pi 5 requires a newer kernel version (>=6.1.54). Please upgrade nixpkgs for this system.";
}
];
hardware.firmware = [ (pkgs.callPackage ../common/raspberry-pi-wireless-firmware.nix { }) ];
}
+172 -17
View File
@@ -4,9 +4,12 @@ NixOS profiles and modules for Raspberry Pi boards.
## What's here
- `common/` has the shared bits: the `linux-rpi` kernel build (vendor defconfig, matching firmware), the `config.txt` generation module, and a pinned wireless firmware.
- `2/`, `3/`, `4/`, `5/` are the board profiles. Each one picks the right kernel and kernel params. Pi 4 and 5 also set DT filters and the initrd modules they need.
- The extra files under `4/` are opt-in toggles for Pi 4 hardware: audio, dwc2, GPIO, I2C, LEDs, the PoE HATs, touchscreens, and so on.
- `common/` has the shared bits: the `linux-rpi` kernel build (vendor defconfig, matching firmware), the `config.txt` generation module, a pinned wireless firmware, and the firmware-partition install module.
- `1/`, `2/`, `3/`, `4/`, `5/` are the board profiles.
They select vendor kernels and configure board-specific boot and hardware settings.
Pi 4 and 5 also set DT filters and the initrd modules they need.
- The extra files under `4/` are opt-in toggles for Pi 4 hardware: audio, GPIO, I2C, LEDs, touchscreens, and so on.
- Where provided, `sd-image.nix` and `sd-image-installer.nix` combine a board profile with nixpkgs' SD-image builder, optionally adding the NixOS installation environment.
## Using a board profile
@@ -18,21 +21,53 @@ NixOS profiles and modules for Raspberry Pi boards.
}
```
These profiles assume the `generic-extlinux-compatible` bootloader (the NixOS module that writes an `extlinux.conf` for U-Boot to read), which is what aarch64 NixOS SD images use by default. There is no `boot.loader.raspberry-pi` module here. U-Boot itself still has to land on the boot partition somehow. Either your image builder does it, or you do. Nothing in here writes to `/boot/firmware/`. See [Current limits](#current-limits).
These profiles assume the `generic-extlinux-compatible` bootloader (the NixOS module that writes an `extlinux.conf` for U-Boot to read), which is what aarch64 NixOS SD images use by default.
There is no `boot.loader.raspberry-pi` module here.
U-Boot and the GPU boot code still have to land on the firmware partition somehow: either your image builder does it, or you use the firmware install module below.
## Firmware install
`hardware.raspberry-pi.firmware` stages the files the Pi firmware needs before Linux starts onto the firmware partition (default `/boot/firmware`): GPU boot code (`bootcode.bin`, `start*.elf`, `fixup*.dat`), vendor device trees and overlays, the rendered `config.txt`, and optionally U-Boot.
It is not a new boot method; it just supplies the files the existing `generic-extlinux-compatible` + U-Boot path needs.
When you build an SD image, the module sets `sdImage.populateFirmwareCommands` itself, so the firmware partition is populated at build time with no extra configuration.
For cross-compilation, set `nixpkgs.buildPlatform` to the build machine's architecture and `nixpkgs.hostPlatform` to the target board's architecture, unless the profile already selects it.
For a running system, set `hardware.raspberry-pi.firmware.enable = true`.
An activation script then repopulates the firmware partition on every `nixos-rebuild switch`.
It is off by default.
To chainload U-Boot from the firmware, enable `uboot.enable`.
It copies `u-boot.bin` to the firmware partition and sets `config.txt`'s `kernel` line for you:
```nix
{
hardware.raspberry-pi.firmware = {
enable = true;
uboot.enable = true;
};
}
```
The shared firmware module defaults `uboot.package` to `pkgs.ubootRaspberryPiAarch64`, built from `rpi_arm64_defconfig` for 64-bit Pi 3/4/5 systems.
Board profiles can override this default.
For 32-bit systems, use the package matching the board: `pkgs.ubootRaspberryPi` for Pi 1, `pkgs.ubootRaspberryPi2` for Pi 2, or `pkgs.ubootRaspberryPi3_32bit` for Pi 3.
On the Pi 5 this boots from SD, but U-Boot can't drive USB/PCIe/RP1 yet, so USB boot, NVMe boot, and a USB keyboard at the U-Boot prompt don't work until Linux takes over.
## `config.txt`
Board profiles import `hardware.raspberry-pi.configtxt`, which renders `config.txt` from Nix options. The defaults track the Raspberry Pi OS pi-gen image: camera and display autodetect, KMS, audio on, `arm_boost`.
Board profiles import `hardware.raspberry-pi.configtxt`, which renders `config.txt` from Nix options.
The Pi 2–5 profiles also import `common/config-txt-defaults.nix`, which tracks the Raspberry Pi OS pi-gen image: camera and display autodetect, KMS, audio on, `arm_boost`.
```nix
{
hardware.raspberry-pi.configtxt.settings = {
all = {
dtparam = [ "audio=on" ];
dtoverlay = [
"vc4-kms-v3d"
"disable-bt"
dtparam = [
"audio=on"
"i2c_arm=on"
];
disable_overscan = true;
};
pi5.arm_freq = 2400;
cm4.otg_mode = true;
@@ -40,17 +75,137 @@ Board profiles import `hardware.raspberry-pi.configtxt`, which renders `config.t
}
```
List values become repeated keys in the rendered file, so the `dtoverlay` above expands to:
List values become repeated keys in the rendered file, so the `dtparam` above expands to:
```
dtoverlay=vc4-kms-v3d
dtoverlay=disable-bt
```ini
dtparam=audio=on
dtparam=i2c_arm=on
```
Top-level attrs are conditional sections (`all`, `pi4`, `pi5`, `cm4`, and so on). Nesting stacks filters. To drop a default, set the key to `null` with `mkForce`.
Top-level attrs are conditional sections (`all`, `pi4`, `pi5`, `cm4`, and so on).
Nesting stacks filters.
Set a board profile's `mkDefault` value to `null` to remove it.
Use `mkForce null` when overriding a value with normal priority.
Every rendered group opens with `[all]` and then its own filters.
Filters of different types stack rather than replace, so `[all]` is what clears the previous group before the next one starts.
The firmware applies these filters at boot, not Nix at evaluation time.
This matters in two cases.
One image can boot on more than one board, such as a CM4 and a CM5 swapped into the same carrier.
Filters like `[EDID=...]`, `[gpio4=1]`, `[tryboot]` and `[bootvar0=42]` also depend on state that Nix cannot see: the attached monitor, a jumper, an EEPROM value.
### Device tree overlays
Before switching to the firmware-provided device tree, migrate other `hardware.deviceTree.overlays` to `hardware.raspberry-pi.configtxt`.
Overlays go in `configtxt.deviceTreeOverlays`, not in a `dtoverlay` key under `settings`.
Filters nest the same way, and the leaf is an ordered list where each element names one overlay and its parameters:
```nix
{
boot.loader.generic-extlinux-compatible.useGenerationDeviceTree = false;
hardware.raspberry-pi.configtxt.deviceTreeOverlays.pi4 = [
{
gpio-fan = {
gpiopin = 12;
temp = 80000;
};
}
{
gpio-led = {
gpio = 16;
label = "status";
};
}
];
}
```
This renders after `configtxt.settings` as:
```ini
[all]
[pi4]
dtoverlay=gpio-fan
dtparam=gpiopin=12
dtparam=temp=80000
dtoverlay=
dtoverlay=gpio-led
dtparam=gpio=16
dtparam=label=status
dtoverlay=
```
A separate option is necessary because `settings` groups values by key.
That grouping cannot keep an overlay next to the `dtparam` lines that belong to it.
The order is functional.
A `dtparam` applies to the overlay that loaded last, and the parameters of an overlay stay in scope only until the next overlay loads.
The bare `dtoverlay=` line closes that scope, so later parameters apply to the base device tree.
The order between overlays can also matter, because one overlay can build on another.
Overlays render after `settings`.
This order keeps base parameters such as `dtparam=audio=on` out of the scope of an overlay.
An overlay can export a parameter with the same name as a base parameter.
While that overlay is in scope, the firmware uses the parameter of the overlay.
Each parameter becomes its own `dtparam` line rather than an addition to the `dtoverlay` line, which keeps them clear of the 98-character line limit.
Booleans render as `on` or `off`.
Use `null` with `mkForce` to remove a parameter.
The module concatenates lists from separate modules, but the order is not the order of definition.
If one overlay must load before another, set the order with `mkBefore` or `mkAfter`.
For overlay names and hardware-specific parameters, use the [Raspberry Pi overlay reference](https://github.com/raspberrypi/linux/blob/rpi-6.18.y/arch/arm/boot/dts/overlays/README).
The Raspberry Pi firmware applies these overlays before U-Boot starts.
Set `boot.loader.generic-extlinux-compatible.useGenerationDeviceTree = false` so U-Boot keeps that device tree instead of loading one from the NixOS generation.
Enabling `hardware.raspberry-pi.firmware.uboot.enable` sets this automatically.
The firmware partition must contain the generated `config.txt` and stock overlays.
SD image builds populate it automatically.
On a running system, set `hardware.raspberry-pi.firmware.enable = true`.
To supply your own file, set `configtxt.file`.
The module then ignores `settings` and `deviceTreeOverlays`.
#### Overriding board defaults
The shared board defaults are defined in [`common/config-txt-defaults.nix`](./common/config-txt-defaults.nix) with `lib.mkDefault`.
Set a `hardware.raspberry-pi.configtxt.settings` value to `null` to omit that default from the generated `config.txt`.
For example, to remove the default `otg_mode` setting before loading `dwc2` on CM4, use:
```nix
{
hardware.raspberry-pi.configtxt = {
settings.cm4.otg_mode = null;
deviceTreeOverlays.cm4 = [
{ dwc2 = { }; }
];
};
}
```
## Audio
To enable the headphone jack on Raspberry Pi 2, 3, or 4:
```nix
{
hardware.raspberry-pi.audio.enable = true;
}
```
The audio module loads the [`snd_bcm2835` kernel module](https://github.com/raspberrypi/linux/blob/rpi-6.18.y/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c) to enable headphone audio.
If you use PulseAudio, the module also provides a default configuration to avoid audio glitches.
## Current limits
- No firmware install: Nothing writes `start*.elf`, `bootcode.bin`, `fixup*.dat`, vendor DTBs, overlays, or `config.txt` to `/boot/firmware/`. The rendered config.txt is exposed at `hardware.raspberry-pi.configtxt.file`, but nothing on disk reads it yet. You either rely on the SD-image populate step or stage those files yourself.
- No bootloader module: There's no `boot.loader.raspberry-pi` here. Boards rely on `generic-extlinux-compatible` plus U-Boot. Pi 5 boots from SD via U-Boot, but USB, PCIe, and the RP1 don't come up until Linux takes over. So a USB keyboard at the U-Boot prompt won't work on Pi 5 today.
- No Pi 0/02/1 board profiles: `common/kernel.nix` accepts `rpiVersion = 1`, but there's no `0/`, `02/`, or `1/` directory wiring that kernel up into a profile you can import via `<nixos-hardware/raspberry-pi/...>`.
- No bootloader module: There's no `boot.loader.raspberry-pi` here.
Boards rely on `generic-extlinux-compatible` plus U-Boot.
Raspberry Pi OS has the GPU firmware load the kernel directly; we go through U-Boot so it reads `extlinux.conf`, which is what gives you the NixOS boot-generation menu and rollbacks.
The firmware install module just stages the boot code and (optionally) U-Boot; it doesn't add a firmware-level direct-boot path.
Pi 5 boots from SD via U-Boot, but USB, PCIe, and the RP1 don't come up until Linux takes over, so a USB keyboard at the U-Boot prompt won't work on Pi 5 today.
- Single pinned kernel: `common/kernel.nix` pins one `linux-rpi` version rather than matching each kernel to its firmware release.
- No Pi Zero or Zero 2 board profiles.
+71
View File
@@ -0,0 +1,71 @@
{
config,
lib,
options,
pkgs,
...
}:
let
cfg = config.hardware.raspberry-pi.audio;
in
{
options.hardware.raspberry-pi.audio = {
enable = lib.mkEnableOption "onboard audio through snd_bcm2835 on Raspberry Pi 2, 3, and 4";
};
config = lib.mkIf cfg.enable {
assertions = [
{
assertion = config.hardware.deviceTree.overlays == [ ];
message = ''
hardware.raspberry-pi.audio.enable uses the firmware-provided device tree
and cannot be combined with hardware.deviceTree.overlays.
Migrate those overlays to hardware.raspberry-pi.configtxt.deviceTreeOverlays.
See "Device tree overlays" in raspberry-pi/README.md for migration and
firmware installation.
'';
}
{
assertion = !config.boot.loader.generic-extlinux-compatible.useGenerationDeviceTree;
message = ''
hardware.raspberry-pi.audio.enable requires
boot.loader.generic-extlinux-compatible.useGenerationDeviceTree = false
so U-Boot keeps the firmware's audio configuration.
Remove the conflicting override or set it to false.
'';
}
{
assertion = config.hardware.raspberry-pi.firmware.enable || (options ? sdImage);
message = ''
Outside SD-image builds, hardware.raspberry-pi.audio.enable requires
hardware.raspberry-pi.firmware.enable = true to install the firmware configuration.
Enable automatic firmware installation as described in "Firmware install" in raspberry-pi/README.md.
'';
}
];
# Omit FDT/FDTDIR so U-Boot keeps the firmware's audio=on change.
boot.loader.generic-extlinux-compatible.useGenerationDeviceTree = lib.mkDefault false;
# The board profiles use KMS for HDMI audio. Leave firmware-driven HDMI
# kernel parameters to users.
boot.kernelModules = [ "snd_bcm2835" ];
services.pulseaudio.configFile =
lib.pipe
{
name = "default.pa";
src = "${lib.getBin config.services.pulseaudio.package}/etc/pulse/default.pa";
substitutions = [
"--replace-fail"
"load-module module-udev-detect"
"load-module module-udev-detect tsched=0"
];
}
[
pkgs.substitute
# Override NixOS's mkDefault (1000), but let explicit user configuration win.
(lib.mkOverride 990)
];
};
}
+30 -15
View File
@@ -8,22 +8,37 @@
{ lib, ... }:
{
hardware.raspberry-pi.configtxt.settings = {
all = {
camera_auto_detect = lib.mkDefault true;
display_auto_detect = lib.mkDefault true;
max_framebuffers = lib.mkDefault 2;
disable_fw_kms_setup = lib.mkDefault true;
disable_overscan = lib.mkDefault true;
arm_boost = lib.mkDefault true;
dtparam = lib.mkDefault [ "audio=on" ];
dtoverlay = lib.mkDefault [ "vc4-kms-v3d" ];
hardware.raspberry-pi.configtxt = {
settings = {
all = {
camera_auto_detect = lib.mkDefault true;
display_auto_detect = lib.mkDefault true;
max_framebuffers = lib.mkDefault 2;
disable_fw_kms_setup = lib.mkDefault true;
disable_overscan = lib.mkDefault true;
arm_boost = lib.mkDefault true;
# A base DTB parameter rather than an overlay one, so it stays here. It
# has to apply before any overlay loads: vc4-kms-v3d exports its own
# `audio` parameter, which would otherwise capture this line and set
# HDMI audio instead of enabling the onboard audio.
dtparam = lib.mkDefault [ "audio=on" ];
# U-Boot needs the UART enabled to boot (see arch/arm/mach-bcm283x/Kconfig
# in the U-Boot tree). Without it U-Boot hangs on the Pi 4.
enable_uart = lib.mkDefault true;
};
# The Pi 5 has a dedicated debug UART. Leaving the mini UART on feeds ghost
# input into boot, so turn it back off.
pi5 = {
enable_uart = lib.mkDefault false;
};
cm4 = {
otg_mode = lib.mkDefault true;
};
};
cm4 = {
otg_mode = lib.mkDefault true;
};
cm5 = {
dtoverlay = lib.mkDefault [ "dwc2,dr_mode=host" ];
deviceTreeOverlays = {
all = lib.mkDefault [ { vc4-kms-v3d = { }; } ];
cm5 = lib.mkDefault [ { dwc2.dr_mode = "host"; } ];
};
};
}
+249 -43
View File
@@ -1,9 +1,13 @@
# config.txt generation module for Raspberry Pi
#
# Generates config.txt from structured Nix options. The type system models
# config.txt as nested attrs: each nesting level adds a conditional filter,
# and leaves are config values. Repeated keys (dtparam, dtoverlay, gpio)
# are supported via lists.
# This module renders config.txt from structured Nix options. The type models
# config.txt as nested attrs: each level of nesting adds a conditional filter,
# and the leaves are config values. Lists produce repeated keys for dtparam,
# dtoverlay and gpio.
#
# Device tree overlays have their own option. A dtparam applies to the overlay
# that loaded last, and values grouped by key cannot express that order.
# Overlays render after settings, so base parameters apply first.
#
# Based on work from nvmd/nixos-raspberrypi (MIT License) and rendering
# approach suggested by @quentinmit. Follows RFC 42.
@@ -31,59 +35,175 @@ let
else if false == v then
"0"
else
builtins.abort "config.txt: unsupported value type: ${builtins.typeOf v}";
abort "config.txt: unsupported value type: ${builtins.typeOf v}";
mkKeyValue = lib.generators.mkKeyValueDefault { inherit mkValueString; } "=";
# Recursively flatten nested attrs into a list of { conditionals, name, value } records.
# Each nesting level (except the leaf) is a conditional filter.
# "all" filters are omitted from the conditionals list since they reset state.
# null values are filtered out, allowing `mkForce null` to remove defaults.
recurse =
# Overlay parameters use on/off for booleans. This follows the Raspberry Pi
# documentation and the overlay README. Plain settings keep 1/0.
mkParamValue = v: if builtins.isBool v then (if v then "on" else "off") else mkValueString v;
# An "all" filter resets state rather than narrowing it, so it never has to be
# recorded. The rest are sorted, which makes two paths that stack the same
# filters in a different order compare equal.
mkConditionals =
path:
lib.pipe path [
(lib.filter (k: k != "all"))
(lib.sort builtins.lessThan)
];
# Flatten settings into { conditionals, items } groups, one group per leaf.
# Every level above the leaf is a conditional filter. A null value drops out,
# so `mkForce null` removes a default.
recurseSettings =
path: value:
if value == null then
[ ]
else if builtins.isAttrs value && !(builtins.isList value) && !(value ? _type) then
lib.flatten (lib.mapAttrsToList (name: recurse ([ name ] ++ path)) value)
else if !(builtins.isAttrs value) then
[
{
conditionals = mkConditionals (lib.init path);
items = [
{
name = lib.last path;
inherit value;
}
];
}
]
else
{
conditionals = lib.sort builtins.lessThan (lib.filter (k: k != "all") (lib.tail path));
name = lib.head path;
inherit value;
};
lib.pipe value [
(lib.mapAttrsToList (name: recurseSettings (path ++ [ name ])))
lib.concatLists
];
# Group flattened items by their conditional filter set, then render.
groupItems =
items:
lib.mapAttrsToList (groupJSON: groupItems: {
conditionals = builtins.fromJSON groupJSON;
items = builtins.listToAttrs groupItems;
}) (builtins.groupBy (x: builtins.toJSON x.conditionals) items);
# The same flattening for overlays. Here the leaf is already the ordered
# overlay list for that filter set, so every level of nesting is a filter.
recurseOverlays =
path: value:
if value == null then
[ ]
else if builtins.isList value then
[
{
conditionals = mkConditionals path;
items = value;
}
]
else
lib.pipe value [
(lib.mapAttrsToList (name: recurseOverlays (path ++ [ name ])))
lib.concatLists
];
mkGroup =
# Merge groups that share a filter set. Two paths can reduce to the same set
# (all.pi4 and pi4.all both yield [ "pi4" ]), so merging is needed even though
# each recursion returns one group per leaf.
#
# Sorting first puts equal sets next to each other, so a single pass coalesces
# them. Folding from the right lets each step prepend, which keeps the result
# in order without a second pass. builtins.sort is stable, so items keep their
# original relative order, which overlays depend on.
#
# The sort is not redundant with mkConditionals, which only orders the filters
# within one group. Groups arrive in attrs walk order, driven by the raw names
# before "all" is stripped, so all.z.foo walks before b.bar.
groupByConditionals =
groups:
lib.pipe groups [
(lib.sort (a: b: a.conditionals < b.conditionals))
(lib.foldr (
group: merged:
let
next = lib.head merged;
in
if merged != [ ] && next.conditionals == group.conditionals then
[ (group // { items = group.items ++ next.items; }) ] ++ lib.tail merged
else
[ group ] ++ merged
) [ ])
];
# Every group opens with [all] plus its own filters. For settings that leading
# [all] is only a reset. For overlays it is required: a bare `dtoverlay=` ends
# overlay scope but leaves the conditional filters set, and only [all] clears
# them.
mkFilterHeader = conditionals: lib.concatMapStrings (f: "[${f}]\n") ([ "all" ] ++ conditionals);
renderSettingsGroup =
group:
lib.concatMapStrings (k: "[${k}]\n") group.conditionals
+ lib.generators.toKeyValue {
inherit mkKeyValue;
listsAsDuplicateKeys = true;
} group.items;
mkFilterHeader group.conditionals
+ lib.pipe group.items [
builtins.listToAttrs
(lib.generators.toKeyValue {
inherit mkKeyValue;
listsAsDuplicateKeys = true;
})
];
toConfigTxt =
attrs:
let
groups = lib.sort (a: b: a.conditionals < b.conditionals) (
groupItems (lib.flatten (recurse [ ] attrs))
);
in
lib.concatMapStringsSep "\n[all]\n" mkGroup groups;
# Each entry ends with a bare `dtoverlay=`. This terminator closes the parameter
# scope of that overlay, so a later dtparam applies to the base DTB instead. A
# terminator must never come first in the file, where it means "load no HAT
# overlay". Settings render first, and every terminator here follows a
# dtoverlay=<name>, so no terminator comes first today. A change to the section
# order can break this guarantee.
renderOverlayGroup =
group:
mkFilterHeader group.conditionals
+ lib.concatMapStrings (
entry:
let
name = lib.head (lib.attrNames entry);
in
lib.concatMapStrings (line: line + "\n") (
[ "dtoverlay=${name}" ]
++ lib.pipe entry.${name} [
(lib.filterAttrs (_: v: v != null))
(lib.mapAttrsToList (p: v: "dtparam=${p}=${mkParamValue v}"))
]
++ [ "dtoverlay=" ]
)
) group.items;
render =
conf: renderSectionFunc: recurseFunc:
lib.pipe conf [
(recurseFunc [ ])
groupByConditionals
(map renderSectionFunc)
(lib.concatStringsSep "\n")
];
# Settings render first, so base DT parameters apply before any overlay loads.
# The overlay groups follow. A blank line separates the two sections, and the
# filter keeps that separator from becoming a stray leading or trailing line
# when one of the two is empty.
generatedConfig =
lib.pipe
[
(render cfg.settings renderSettingsGroup recurseSettings)
(render cfg.deviceTreeOverlays renderOverlayGroup recurseOverlays)
]
[
(lib.filter (section: section != ""))
(lib.concatStringsSep "\n")
];
in
{
options.hardware.raspberry-pi.configtxt = {
settings = lib.mkOption {
type =
with lib.types;
let
inherit (lib.types)
attrsOf
bool
int
listOf
nullOr
oneOf
str
;
atom = nullOr (oneOf [
str
int
@@ -107,6 +227,10 @@ in
Booleans render as `0`/`1`. Use `null` with `mkForce` to remove a
default.
Set device tree overlays through {option}`deviceTreeOverlays` rather
than a `dtoverlay` key here. A `dtoverlay` written here gets no
terminator, so it captures every `dtparam` that follows it.
See <https://www.raspberrypi.com/documentation/computers/config_txt.html>
'';
example = lib.literalExpression ''
@@ -123,13 +247,95 @@ in
'';
};
deviceTreeOverlays = lib.mkOption {
type =
let
inherit (lib.types)
addCheck
attrsOf
bool
int
listOf
nullOr
oneOf
str
;
params = attrsOf (
nullOr (oneOf [
str
int
bool
])
);
# Each list element names one overlay. Without this check one element
# can name two overlays, as in [ { a = { }; b = { }; } ]. Nix sorts
# attribute names, so the order between them is lost.
entry = addCheck (attrsOf params) (e: builtins.length (builtins.attrNames e) == 1) // {
description = "attribute set naming exactly one overlay, mapped to its parameters";
};
node = oneOf [
(listOf entry)
(attrsOf node)
];
in
attrsOf node // { description = "config.txt device tree overlay type"; };
default = { };
description = ''
Device tree overlays for the Raspberry Pi firmware, rendered in list
order.
Keys are conditional filter sections and nest exactly like
{option}`settings`. The leaf is an ordered list, and each element names
one overlay mapped to its parameters.
Use this instead of a `dtoverlay` key in {option}`settings` when an
overlay has parameters. `settings` groups values by key and cannot keep
an overlay next to the `dtparam` lines that belong to it. A parameter
stays in scope only until the next overlay loads.
Each parameter becomes its own `dtparam` line rather than an addition to
the `dtoverlay` line, which keeps them clear of the 98-character limit
on `config.txt` lines. Booleans render as `on` or `off`. Use `null` with
`mkForce` to remove a default.
Overlays render after {option}`settings`, so base device tree parameters
set there apply before any overlay loads. The example renders as:
```ini
[all]
[pi4]
dtoverlay=dwc2
dtparam=dr_mode=host
dtoverlay=
dtoverlay=gpio-fan
dtparam=gpiopin=14
dtparam=temp=80000
dtoverlay=
```
'';
example = lib.literalExpression ''
{
pi4 = [
{ dwc2.dr_mode = "host"; }
{
gpio-fan = {
gpiopin = 14;
temp = 80000;
};
}
];
}
'';
};
file = lib.mkOption {
type = lib.types.path;
default = pkgs.writeText "config.txt" (toConfigTxt cfg.settings);
defaultText = lib.literalExpression ''pkgs.writeText "config.txt" (generated from settings)'';
default = pkgs.writeText "config.txt" generatedConfig;
defaultText = lib.literalExpression ''pkgs.writeText "config.txt" (generated from settings and deviceTreeOverlays)'';
description = ''
Path to the generated config.txt file. Defaults to the rendered output
of `settings`, but can be overridden to supply a custom config.txt.
Path to the config.txt file to install. Defaults to the rendered output
of {option}`settings` and {option}`deviceTreeOverlays`. A custom file
replaces that output, so the module then ignores both options.
'';
};
};
+2
View File
@@ -1,7 +1,9 @@
{
imports = [
./audio.nix
./config-txt.nix
./config-txt-defaults.nix
./firmware.nix
];
boot.initrd.availableKernelModules = [
+228
View File
@@ -0,0 +1,228 @@
# Firmware-partition install for Raspberry Pi.
#
# Stages the files the Pi needs before Linux starts onto the firmware partition
# (default /boot/firmware): GPU boot code (bootcode.bin, start*.elf, fixup*.dat),
# vendor device trees and overlays, the rendered config.txt, and optionally
# U-Boot. Not a new boot method: boards still use
# boot.loader.generic-extlinux-compatible (U-Boot reads extlinux.conf); this just
# provides the files that path needs, either at SD-image build time
# (sdImage.populateFirmwareCommands, wired automatically) or on a running system
# (the opt-in activation script).
#
# DTB/overlay copy adapted from nvmd/nixos-raspberrypi (MIT).
{
lib,
config,
options,
pkgs,
...
}:
let
cfg = config.hardware.raspberry-pi.firmware;
# install-rpi-firmware <target-dir>
# Idempotent: copies via temp file + rename, and prunes stale DTBs/overlays.
mkInstallScript =
scriptPkgs:
scriptPkgs.writeShellApplication {
name = "install-rpi-firmware";
runtimeInputs = [ scriptPkgs.coreutils ];
text = ''
target="$1"
shopt -s nullglob
firmwareBoot=${cfg.package}/share/raspberrypi/boot
${
if cfg.useGenerationDeviceTree then
''
# Prefer the booted generation's device trees over the vendor ones.
dtbSrc=/run/current-system/dtbs
[ -d "$dtbSrc" ] || dtbSrc=$firmwareBoot
''
else
''
dtbSrc=$firmwareBoot
''
}
mkdir -p "$target/overlays"
# Copy via a temp file then rename so an interrupted run can't leave a
# half-written file behind. The firmware partition is FAT, so the rename
# isn't truly atomic, but it still beats a partial copy when the
# activation script rewrites the partition on a live system.
copyForced() {
cp "$1" "$2.tmp"
mv "$2.tmp" "$2"
}
# Track every file we copy this run, keyed by destination path, so the
# prune step below can delete stale device trees / overlays left behind
# by a previous generation.
declare -A kept
echo "rpi-firmware: copying device trees from $dtbSrc"
for dtb in "$dtbSrc"/*.dtb "$dtbSrc"/broadcom/*.dtb; do
dst="$target/$(basename "$dtb")"
copyForced "$dtb" "$dst"
kept[$dst]=1
done
# hardware.raspberry-pi.configtxt.deviceTreeOverlays entries are
# matched by filename against the vendor .dtbo set the Raspberry Pi
# firmware ships, regardless of whether the *base* dtb above came
# from the generation or from firmwareBoot. Stage those
# unconditionally so config.txt's "dtoverlay=" lines have a target
# to apply, even when useGenerationDeviceTree = true.
if [ -d "$firmwareBoot/overlays" ]; then
for ovr in "$firmwareBoot"/overlays/*; do
dst="$target/overlays/$(basename "$ovr")"
copyForced "$ovr" "$dst"
kept[$dst]=1
done
fi
# When useGenerationDeviceTree also produced its own overlays
# (built via hardware.deviceTree.overlays), stage those too,
# letting them take precedence over same-named vendor overlays.
if [ "$dtbSrc" != "$firmwareBoot" ] && [ -d "$dtbSrc/overlays" ]; then
for ovr in "$dtbSrc"/overlays/*; do
dst="$target/overlays/$(basename "$ovr")"
copyForced "$ovr" "$dst"
kept[$dst]=1
done
fi
# Prune stale device trees / overlays.
for fn in "$target"/*.dtb "$target"/overlays/*; do
if [ "''${kept[$fn]:-}" != 1 ]; then
rm -v -- "$fn"
fi
done
echo "rpi-firmware: copying GPU boot code"
for src in "$firmwareBoot"/bootcode.bin "$firmwareBoot"/start*.elf "$firmwareBoot"/fixup*.dat; do
copyForced "$src" "$target/$(basename "$src")"
done
${lib.optionalString cfg.uboot.enable ''
echo "rpi-firmware: copying U-Boot"
copyForced ${cfg.uboot.package}/u-boot.bin "$target/u-boot.bin"
''}
echo "rpi-firmware: copying config.txt"
copyForced ${config.hardware.raspberry-pi.configtxt.file} "$target/config.txt"
echo "rpi-firmware: done ($target)"
'';
};
# Target tools for activation, build tools for images.
installScript = mkInstallScript pkgs;
imageInstallScript = mkInstallScript pkgs.buildPackages;
in
{
options.hardware.raspberry-pi.firmware = {
enable = lib.mkEnableOption ''
installation of the Raspberry Pi firmware partition on a running system.
An activation script repopulates {option}`hardware.raspberry-pi.firmware.path`
on every system switch
'';
path = lib.mkOption {
type = lib.types.str;
default = "/boot/firmware";
description = ''
Mount point of the Raspberry Pi firmware (FAT) partition.
`/boot/firmware` matches the NixOS aarch64 SD-image layout, and most
configurations should leave it there. The activation script writes here
only when it is a mounted partition (checked with `mountpoint`);
otherwise it logs a warning and skips.
'';
};
package = lib.mkOption {
type = lib.types.package;
default = pkgs.raspberrypifw;
defaultText = lib.literalExpression "pkgs.raspberrypifw";
description = ''
Package providing the Raspberry Pi GPU boot code, vendor device trees,
and overlays under `''${package}/share/raspberrypi/boot`.
'';
};
uboot = {
enable = lib.mkEnableOption ''
chainloading U-Boot from the Raspberry Pi firmware.
Copies `u-boot.bin` from
{option}`hardware.raspberry-pi.firmware.uboot.package` to the firmware
partition and points `config.txt`'s `kernel` at it, so the GPU firmware
loads U-Boot, which then reads `extlinux.conf`
'';
package = lib.mkOption {
type = lib.types.package;
default = pkgs.ubootRaspberryPiAarch64;
defaultText = lib.literalExpression "pkgs.ubootRaspberryPiAarch64";
description = ''
U-Boot package whose `u-boot.bin` is copied to the firmware
partition when {option}`hardware.raspberry-pi.firmware.uboot.enable`
is enabled.
The default, nixpkgs' `pkgs.ubootRaspberryPiAarch64`, covers the
64-bit boards (Pi 3/4/5). For a 32-bit board, override this with the
matching U-Boot package.
'';
};
};
useGenerationDeviceTree = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Copy device trees from the booted NixOS generation
(`/run/current-system/dtbs`) instead of the vendor firmware package.
Irrelevant when generating an SD image.
'';
};
};
config = lib.mkMerge [
(lib.mkIf cfg.uboot.enable {
# Chainload U-Boot: the GPU firmware loads u-boot.bin, which then reads
# extlinux.conf. mkDefault so an explicit kernel setting still wins.
hardware.raspberry-pi.configtxt.settings.all = {
kernel = lib.mkDefault "u-boot.bin";
# Default U-Boot is 64-bit, but the firmware loads kernel= in 32-bit
# mode unless arm_64bit=1.
arm_64bit = lib.mkDefault pkgs.stdenv.hostPlatform.isAarch64;
};
# The GPU firmware merges config.txt dtoverlays into the DTB it hands to
# U-Boot. The default (true) adds an FDTDIR line to extlinux.conf, so
# U-Boot reloads bare dtbs and drops the overlays.
boot.loader.generic-extlinux-compatible.useGenerationDeviceTree = lib.mkDefault false;
})
# Stage the firmware partition at SD-image build time, only when an
# sd-image module is imported. mkForce so we override (not merge with)
# sd-image-aarch64.nix, which also sets this and would clobber config.txt.
(lib.optionalAttrs (options ? sdImage) {
sdImage.populateFirmwareCommands = lib.mkForce "${lib.getExe imageInstallScript} ./firmware\n";
})
(lib.mkIf cfg.enable {
system.activationScripts.raspberry-pi-firmware = lib.stringAfter [ "specialfs" ] ''
if mountpoint -q ${lib.escapeShellArg cfg.path}; then
${lib.getExe installScript} ${lib.escapeShellArg cfg.path}
else
echo "rpi-firmware: ${cfg.path} is not a mounted partition, skipping firmware install" >&2
fi
'';
})
];
}
+15 -3
View File
@@ -10,9 +10,9 @@
let
# NOTE: raspberryPiWirelessFirmware should be updated with this
modDirVersion = "6.18.34";
tag = "stable_20260609";
hash = "sha256-ok++36dh9o4e7AC5RErW00/r23rGxufe0PYXz5Dzy5U=";
modDirVersion = "6.18.65";
tag = "stable_20261127";
hash = "sha256-VbyXdyMxhWvNv3GGJvs0D330xzc1pwP6IpXpe2Q/o4g=";
inherit (lib.kernel) freeform yes no;
in
(buildLinux (
@@ -83,6 +83,18 @@ in
PREEMPT = lib.mkForce no;
PREEMPT_LAZY = lib.mkForce no;
PREEMPT_VOLUNTARY = lib.mkForce yes;
}
# These controllers are absent on Pi 1. Nixpkgs' automatic module selection
# enables them, but they use division helpers unavailable to 32-bit modules.
# https://github.com/NixOS/nixpkgs/issues/464515
// lib.optionalAttrs (rpiVersion == 1) {
PWM_RP1 = no;
I2C_DESIGNWARE_CORE = no;
I2C_DESIGNWARE_SLAVE = no;
I2C_DESIGNWARE_PLATFORM = no;
I2C_DESIGNWARE_PCI = no;
VIDEO_RP1_CFE = no;
VIDEO_RP1_CFE_DOWNSTREAM = no;
};
extraMeta =
@@ -6,22 +6,22 @@
stdenvNoCC.mkDerivation {
pname = "raspberrypi-wireless-firmware";
version = "0-unstable-2026-03-21";
version = "0-unstable-2026-11-23";
srcs = [
(fetchFromGitHub {
name = "bluez-firmware";
owner = "RPi-Distro";
repo = "bluez-firmware";
rev = "cdf61dc691a49ff01a124752bd04194907f0f9cd";
hash = "sha256-35pnbQV/zcikz9Vic+2a1QAS72riruKklV8JHboL9NY=";
rev = "924fde7d1f0613d796e4512ac44ac33e4b91c4e3";
hash = "sha256-Ff0pzWidPgoEXpBqh81jmQWcpW90J1hH+gY61Wb8TEk=";
})
(fetchFromGitHub {
name = "firmware-nonfree";
owner = "RPi-Distro";
repo = "firmware-nonfree";
rev = "9794282eb9f4a2de1f23b41a738926740e975d83";
hash = "sha256-OtA8yHvfusGP/ucf8Exzi+nSUmNoYp10u+luC2gbNZc=";
rev = "b1833f18a816cf8fd73ca86e27f9eecea11bf991";
hash = "sha256-fe2oZV/qPBkemtG34cx9s2+4RhMn5XF0zl3EkmFDiZg=";
})
];
@@ -36,7 +36,8 @@ stdenvNoCC.mkDerivation {
mkdir -p "$out/lib/firmware/brcm"
# Wifi firmware
cp -r "firmware-nonfree/debian/config/brcm80211/." "$out/lib/firmware/"
cp -r "firmware-nonfree/debian/added-firmware/brcm" "$out/lib/firmware/"
cp -r "firmware-nonfree/debian/added-firmware/cypress" "$out/lib/firmware/"
# Bluetooth firmware
cp -r "bluez-firmware/debian/firmware/broadcom/." "$out/lib/firmware/brcm"
+117
View File
@@ -0,0 +1,117 @@
# SpacemiT K3 Pico-ITX
NixOS support for the [SpacemiT K3 Pico-ITX](https://www.spacemit.com/community/document/info?nodepath=hardware%2Feco%2Fk3_pico%2Fpico_user_guide.md&lang=en) single-board
computer, built around the SpacemiT K3 SoC (RVA23 RISC-V).
## Hardware
| Component | Detail |
| --------- | ------ |
| SoC | SpacemiT K3 (RVA23, 64-bit RISC-V) |
| CPU | 16 cores: 8× X100 @ 2.4 GHz + 8× A100 @ 2.0 GHz |
| Memory | LPDDR5, up to 32 GB |
| Storage | PCIe Gen3 ×4 (NVMe), internal UFS, microSD |
| Network | RTL8211F 1GbE (`end0`), RTL8127 10GbE (PCIe), RTL8852BE Wi-Fi 6 (PCIe) |
| Firmware | EDK2 UEFI + U-Boot + OpenSBI |
## Usage
Add the module to your configuration:
```nix
{
imports = [
"${nixos-hardware}/spacemit/k3-pico-itx"
];
}
```
This gives you the base setup with the vendor `linux-6.18` kernel and
EDK2/U-Boot/OpenSBI. I plan to move to the mainline kernel.
### Building an SD-image
```nix
{
imports = [
"${nixos-hardware}/spacemit/k3-pico-itx/sd-image.nix"
];
# Set a password or add an SSH key so you can log in
# users.users.nixos.password = "changeme";
# users.users.nixos.openssh.authorizedKeys.keys = [ "ssh-ed25519 ..." ];
}
```
```sh
nix build .#sd-image
```
## Cache
To install and update your system I set up a binary cache:
`build05.ynh.ovh`
This saves you from compiling everything locally.
Here is how to add it to your configuration:
```nix
nix.settings = {
substituters = [ "https://build05.ynh.ovh" ];
trusted-public-keys = [
"build05.ynh.ovh:bLxWKPjbKYOFxqrjOxv+cdwS3kFLuHEf1k6j8fAxbzM="
];
};
```
Here is how to use it without adding it to your configuration:
```sh
sudo nix-channel --add https://channels.nixos.org/nixos-26.05 nixos
sudo nix-channel --update
nix build \
--substituters https://build05.ynh.ovh \
--trusted-public-keys "build05.ynh.ovh:bLxWKPjbKYOFxqrjOxv+cdwS3kFLuHEf1k6j8fAxbzM="
```
PS: This is a cache maintained on a voluntary basis for the K3 and riscv64
hardware. I can't guarantee its availability, nor that everything is already
built on it. The Hydra infrastructure is still being deployed, so please be
lenient in that regard.
## X100 vs A100
Here are the notable differences between the X100 and the A100.
| | X100 (cpu 0-7) | A100 (cpu 8-15) |
|---|---|---|
| Hypervisor extension (`h`) | yes (`rv64imafdcvh`) | no (`rv64imafdcv`) |
| Vector width | `VLENB=32` (VLEN 256-bit) | `VLENB=128` (VLEN 1024-bit) |
| L2 cache | 4 MB per cluster (8 MB total) | 1 MB per cluster (2 MB total) |
| L1 cache | 64 KB I + 64 KB D per core | identical |
## UEFI
To get UEFI I made a small script, to be run from Bianbu:
https://github.com/liberodark/k3-uefi-flash
## Status
Working:
- Boot to NixOS, SSH reachable
- NVMe root (PCIe Gen3 ×4), 1GbE (`end0`)
- All 16 cores usable (see HMP notes above)
Known issues:
- I noticed a reboot issue, so I force it with `reboot -ff`.
## Upstream status
- [Kernel](https://github.com/spacemit-com/linux/wiki)
- [OpenSBI](https://github.com/spacemit-com/opensbi-upstream/wiki)
- [U-Boot](https://github.com/spacemit-com/u-boot/wiki)
- [LLVM/GCC](https://github.com/spacemit-com/.github/blob/main/upstream-status/toolchain.md)
- [llama.cpp](https://github.com/spacemit-com/llama.cpp/wiki)
+80
View File
@@ -0,0 +1,80 @@
{
config,
lib,
pkgs,
...
}:
{
imports = [ ./firmware.nix ];
boot = {
consoleLogLevel = lib.mkDefault 7;
kernelPackages = lib.mkDefault (
pkgs.linuxPackagesFor (
pkgs.callPackage ./linux.nix {
inherit (config.boot) kernelPatches;
}
)
);
kernelParams = [
"earlycon=sbi"
"console=ttyS0,115200"
"keep_bootcon"
"systemd.journald.forward_to_console=1"
"systemd.log_target=kmsg"
"systemd.log_level=info"
"clk_ignore_unused"
"pd_ignore_unused"
"regulator_ignore_unused"
"root=PARTLABEL=nixos-rootfs"
"rootwait"
"rootfstype=ext4"
];
initrd = {
availableKernelModules = [
"usb_storage"
"uas"
"nvme"
"nvme_core"
];
kernelModules = [
"erofs"
"loop"
];
};
loader = {
systemd-boot.enable = lib.mkDefault true;
systemd-boot.consoleMode = lib.mkDefault "auto";
timeout = lib.mkDefault 3;
efi.canTouchEfiVariables = lib.mkDefault false;
efi.efiSysMountPoint = lib.mkDefault "/boot";
generic-extlinux-compatible.enable = lib.mkDefault false;
};
zfs.forceImportRoot = lib.mkDefault false;
};
hardware.deviceTree = {
enable = lib.mkDefault true;
name = lib.mkDefault "spacemit/k3-pico-itx.dtb";
};
boot.supportedFilesystems = lib.mkForce [
"ext4"
"vfat"
];
system.nixos-init.enable = lib.mkDefault true;
system.etc.overlay.enable = lib.mkDefault true;
services.userborn.enable = lib.mkDefault true;
systemd.services."serial-getty@ttyS0" = {
enable = true;
wantedBy = [ "getty.target" ];
serviceConfig.Restart = "always";
};
}
+28
View File
@@ -0,0 +1,28 @@
{
stdenvNoCC,
fetchFromGitHub,
}:
stdenvNoCC.mkDerivation {
pname = "edk2-spacemit-k3";
version = "ubuntu26.04-20260509";
src = fetchFromGitHub {
owner = "spacemit-com";
repo = "K3-Ubuntu-Images";
tag = "ubuntu26.04-20260509";
hash = "sha256-J0T3T/gOhKmld1du7J2z+DimZXShb+zoON3DHIz4Hy0=";
};
dontConfigure = true;
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out
cp gadget.in/edk2.itb $out/
runHook postInstall
'';
}
+103
View File
@@ -0,0 +1,103 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.hardware.k3-pico-itx;
in
{
options.hardware.k3-pico-itx = {
opensbi = {
src = lib.mkOption {
description = "K3 Pico-ITX OpenSBI source override.";
type = lib.types.nullOr lib.types.package;
default = null;
};
patches = lib.mkOption {
description = "Additional patches to apply to K3 Pico-ITX OpenSBI.";
type = lib.types.nullOr (lib.types.listOf lib.types.package);
default = null;
};
};
uboot = {
src = lib.mkOption {
description = "K3 Pico-ITX U-Boot source override.";
type = lib.types.nullOr lib.types.package;
default = null;
};
patches = lib.mkOption {
description = "Additional patches to apply to K3 Pico-ITX U-Boot.";
type = lib.types.nullOr (lib.types.listOf lib.types.package);
default = null;
};
};
fsbl = {
src = lib.mkOption {
description = "K3 Pico-ITX FSBL source override.";
type = lib.types.nullOr lib.types.package;
default = null;
};
patches = lib.mkOption {
description = "Additional patches to apply to K3 Pico-ITX FSBL.";
type = lib.types.nullOr (lib.types.listOf lib.types.package);
default = null;
};
};
edk2 = {
src = lib.mkOption {
description = "K3 Pico-ITX EDK2 (UEFI) source override.";
type = lib.types.nullOr lib.types.package;
default = null;
};
};
};
config = {
system.build = {
opensbi = (pkgs.callPackage ./opensbi.nix { }).overrideAttrs (
_final: prev: {
src = if cfg.opensbi.src != null then cfg.opensbi.src else prev.src;
patches = if cfg.opensbi.patches != null then cfg.opensbi.patches else (prev.patches or [ ]);
}
);
uboot = (pkgs.callPackage ./uboot.nix { }).overrideAttrs (
_final: prev: {
src = if cfg.uboot.src != null then cfg.uboot.src else prev.src;
patches = if cfg.uboot.patches != null then cfg.uboot.patches else (prev.patches or [ ]);
}
);
fsbl = (pkgs.callPackage ./fsbl.nix { }).overrideAttrs (
_final: prev: {
src = if cfg.fsbl.src != null then cfg.fsbl.src else prev.src;
patches = if cfg.fsbl.patches != null then cfg.fsbl.patches else (prev.patches or [ ]);
}
);
edk2 = (pkgs.callPackage ./edk2.nix { }).overrideAttrs (
_final: prev: {
src = if cfg.edk2.src != null then cfg.edk2.src else prev.src;
}
);
updater-sd = pkgs.writeShellApplication {
name = "k3-pico-itx-firmware-update-sd";
runtimeInputs = [ pkgs.coreutils ];
text = ''
dev=''${1:-/dev/mmcblk0}
dd if=${config.system.build.fsbl}/FSBL.bin of=''${dev}p3 conv=fsync,notrunc
dd if=${config.system.build.opensbi}/share/opensbi/lp64/generic/firmware/fw_dynamic.itb of=''${dev}p5 conv=fsync,notrunc
dd if=${config.system.build.edk2}/edk2.itb of=''${dev}p6 conv=fsync,notrunc
'';
};
};
};
}
+24
View File
@@ -0,0 +1,24 @@
{
buildUBoot,
fetchFromGitHub,
}:
buildUBoot {
version = "2022.10-k3-br-v1.0.y";
src = fetchFromGitHub {
owner = "liberodark";
repo = "spacemit-uboot-2022.10";
rev = "368953aa0b648528ddafa5b6baa73507448ab94d";
hash = "sha256-LTtxHzL5aoMLlv8DsgEoyIM0JrwYYzNlHCAmXzixScI=";
};
defconfig = "k3_defconfig";
filesToInstall = [
"FSBL.bin"
"bootinfo_block.bin"
"bootinfo_spinor.bin"
"bootinfo_spinand.bin"
];
}
+222
View File
@@ -0,0 +1,222 @@
{
buildLinux,
fetchFromGitHub,
lib,
...
}@args:
let
modDirVersion = "7.3.0";
in
buildLinux (
args
// {
inherit modDirVersion;
version = "7.3-spacemit-k3";
src = fetchFromGitHub {
owner = "torvalds";
repo = "linux";
tag = "v7.3";
hash = "sha256-ca8CMAWKe1yzkQIn8sasUQxMLqdtfvC+wBFtX3819Zk=";
};
defconfig = "defconfig";
kernelPatches = [
{
name = "k3-pcie-03-pci-k1-device-data";
patch = ./patches/0003-pci-k1-device-data.patch;
}
{
name = "k3-pcie-04-pci-k1-multiple-phy-handles";
patch = ./patches/0004-pci-k1-multiple-phy-handles.patch;
}
{
name = "k3-pcie-04b-pci-k1-device-id-helper";
patch = ./patches/0004b-pci-k1-device-id-helper.patch;
}
{
name = "k3-pcie-05-dt-bindings-dw-pcie-msi-parent";
patch = ./patches/0005-dt-bindings-dw-pcie-msi-parent.patch;
}
{
name = "k3-pcie-06-dt-bindings-k3-pcie-host";
patch = ./patches/0006-dt-bindings-k3-pcie-host.patch;
}
{
name = "k3-pcie-07-pci-k3-host-controller";
patch = ./patches/0007-pci-k3-host-controller.patch;
}
{
name = "k3-08-serial-8250-gate-clock";
patch = ./patches/0008-serial-8250_of-gate-clock.patch;
}
{
name = "k3-09-dts-uart0-gate-clock";
patch = ./patches/0009-dts-k3-uart0-gate-clock.patch;
}
{
name = "k3-10-dts-k3-add-pcie";
patch = ./patches/0010-dts-k3-add-pcie-combphy.patch;
}
{
name = "k3-11-dts-reserved-memory";
patch = ./patches/0011-dts-k3-reserved-memory.patch;
}
{
name = "k3-12-thermal-spacemit-k3";
patch = ./patches/0012-thermal-spacemit-k3.patch;
}
{
name = "k3-13-riscv-cpuinfo-model-name";
patch = ./patches/0013-riscv-cpuinfo-model-name.patch;
}
{
name = "k3-14-cpufreq-spacemit-k3";
patch = ./patches/0014-cpufreq-spacemit-k3.patch;
}
{
name = "k3-15-dts-com260-pcie";
patch = ./patches/0015-dts-k3-com260-pcie.patch;
}
{
name = "k3-15-dt-bindings-vendor-prefixes-sensylink";
patch = ./patches/0015-dt-bindings-vendor-prefixes-sensylink.patch;
}
{
name = "k3-16-dt-bindings-hwmon-lm63-family";
patch = ./patches/0016-dt-bindings-hwmon-lm63-family.patch;
}
{
name = "k3-17-dt-bindings-hwmon-ctf2301";
patch = ./patches/0017-dt-bindings-hwmon-ctf2301.patch;
}
{
name = "k3-18-hwmon-lm63-ctf2301";
patch = ./patches/0018-hwmon-lm63-ctf2301.patch;
}
{
name = "k3-19-dts-i2c6-pinctrl";
patch = ./patches/0019-dts-k3-i2c6-pinctrl.patch;
}
{
name = "k3-20-dts-com260-ctf2301";
patch = ./patches/0020-dts-k3-com260-ctf2301.patch;
}
{
name = "k3-21-dts-com260-fan-cooling";
patch = ./patches/0021-dts-k3-com260-fan-cooling.patch;
}
{
name = "k3-22-dts-com260-qspi-nor";
patch = ./patches/0022-dts-k3-com260-qspi-nor.patch;
}
];
structuredExtraConfig = with lib.kernel; {
ARCH_SPACEMIT = option yes;
CPU_FREQ = option yes;
CPU_FREQ_GOV_PERFORMANCE = option yes;
CPU_FREQ_GOV_SCHEDUTIL = option yes;
CPU_FREQ_DEFAULT_GOV_SCHEDUTIL = option yes;
CPUFREQ_DT = option yes;
CPUFREQ_DT_PLATDEV = option yes;
SPACEMIT_K3_CPUFREQ = option yes;
PM_OPP = option yes;
SPACEMIT_K3_THERMAL = option yes;
THERMAL = option yes;
THERMAL_HWMON = option yes;
HWMON = option yes;
SENSORS_LM63 = option yes;
SMP = option yes;
SPACEMIT_K3_CCU = option yes;
GPIO_SPACEMIT_K1 = option yes;
CMA = option yes;
DMA_CMA = option yes;
SPARSEMEM_MANUAL = option yes;
PCI = option yes;
PCIE_DW = option yes;
PCIE_DW_HOST = option yes;
PCIE_SPACEMIT_K1 = option yes;
PHY_SPACEMIT_K3_COMBO_PHY = option yes;
PHY_SPACEMIT_K3_COMMON_OPS = option yes;
NVME_CORE = option yes;
BLK_DEV_NVME = option yes;
MMC = option yes;
MMC_SDHCI = option yes;
MMC_SDHCI_PLTFM = option yes;
MMC_SDHCI_OF_K1 = option yes;
SCSI = option yes;
STMMAC_ETH = option module;
USB = option yes;
USB_XHCI_HCD = option yes;
USB_EHCI_HCD = option yes;
SERIAL_8250 = option yes;
SERIAL_8250_CONSOLE = option yes;
SERIAL_OF_PLATFORM = option yes;
EFI = option yes;
EFI_STUB = option yes;
EFIVAR_FS = option yes;
CGROUPS = option yes;
MEMCG = option yes;
CGROUP_BPF = option yes;
BPF = option yes;
BPF_SYSCALL = option yes;
BPF_JIT = option yes;
NAMESPACES = option yes;
USER_NS = option yes;
SECCOMP = option yes;
SECCOMP_FILTER = option yes;
DEVTMPFS = option yes;
DEVTMPFS_MOUNT = option yes;
AUTOFS_FS = option yes;
FANOTIFY = option yes;
TMPFS_POSIX_ACL = option yes;
TMPFS_XATTR = option yes;
MODULES = option yes;
MODULE_UNLOAD = option yes;
RD_GZIP = option yes;
RD_BZIP2 = option yes;
RD_LZMA = option yes;
RD_XZ = option yes;
RD_LZO = option yes;
RD_LZ4 = option yes;
RD_ZSTD = option yes;
# Disable
PSTORE_BLK = no;
PSTORE_BLK_BLKDEV = no;
RTL8852BS = no;
CORESIGHT = no;
ETHERCAT = no;
HWSPINLOCK_SPACEMIT = no;
DRM_AMDGPU = no;
DRM_RADEON = no;
DRM_NOUVEAU = no;
SPACEMIT_K1_CCU = no;
NVMEM_LAYOUT_ONIE_TLV = no;
DEBUG_VM = no;
DEBUG_VM_PGFLAGS = no;
DEBUG_VM_PGTABLE = no;
DEBUG_PAGEALLOC = no;
DEBUG_PAGEALLOC_ENABLE_DEFAULT = no;
PAGE_EXTENSION = lib.mkForce no;
PAGE_OWNER = no;
KASAN = no;
KMEMLEAK = no;
DEBUG_KMEMLEAK = no;
SLUB_DEBUG_ON = no;
MEM_ALLOC_PROFILING = lib.mkForce no;
MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT = lib.mkForce no;
NO_HZ_FULL = lib.mkForce no;
SLAB_FREELIST_HARDENED = lib.mkForce no;
SLAB_FREELIST_RANDOM = lib.mkForce no;
KFENCE = lib.mkForce no;
DEBUG_INFO_BTF = lib.mkForce no;
DEBUG_INFO_BTF_MODULES = lib.mkForce no;
};
extraMeta.branch = "7.3";
}
// (args.argsOverride or { })
)
+31
View File
@@ -0,0 +1,31 @@
{
opensbi,
fetchFromGitHub,
buildPackages,
}:
opensbi.overrideAttrs (old: {
version = "k3-br-v1.0.y";
src = fetchFromGitHub {
owner = "liberodark";
repo = "spacemit-openspi";
rev = "3e2f9efc9660b8d5fcae4e0b6495f306d5c64078";
hash = "sha256-pJ9izkJ3eNwF1km335ZjCezWhOSYxOMm1fo/19BoG+I=";
};
postPatch = ''
patchShebangs scripts/
cp platform/generic/configs/k3_defconfig platform/generic/configs/defconfig
'';
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [
buildPackages.ubootTools
buildPackages.dtc
];
postInstall = ''
cp build/platform/generic/firmware/fw_dynamic.itb \
$out/share/opensbi/lp64/generic/firmware/fw_dynamic.itb
'';
})
@@ -0,0 +1,92 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH 1/2] dt-bindings: phy: Add Spacemit K3 USB3/PCIe comb phy
support
From: Inochi Amaoto <inochiama@gmail.com>
Date: Thu, 30 Apr 2026 10:28:40 +0800
Message-Id: <20260430022843.1090138-2-inochiama@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
The USB3/PCIe comb PHY on the K3 is a complex PHY group that
can provide multiple phy for both PCIe and USB controller.
Its mux configuration is controlled by the APMU syscon device.
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
---
.../bindings/phy/spacemit,k3-comb-phy.yaml | 63 +++++++++++++++++++
1 file changed, 63 insertions(+)
create mode 100644 Documentation/devicetree/bindings/phy/spacemit,k3-comb-phy.yaml
diff --git a/Documentation/devicetree/bindings/phy/spacemit,k3-comb-phy.yaml b/Documentation/devicetree/bindings/phy/spacemit,k3-comb-phy.yaml
new file mode 100644
index 000000000000..7aa2cf9301b7
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/spacemit,k3-comb-phy.yaml
@@ -0,0 +1,63 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/phy/spacemit,k3-comb-phy.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Spacemit K3 PCIE/USB3 Comb PHY
+
+maintainers:
+ - Inochi Amaoto <inochiama@gmail.com>
+
+properties:
+ compatible:
+ const: spacemit,k3-comb-phy
+
+ reg:
+ maxItems: 1
+
+ "#phy-cells":
+ const: 2
+ description:
+ The first one is phy id, the second one is phy type.
+
+ spacemit,apb-spare:
+ $ref: /schemas/types.yaml#/definitions/phandle
+ description:
+ Phandle to APB SPARE system controller interface, used for
+ PHY calibration.
+
+ spacemit,apmu:
+ $ref: /schemas/types.yaml#/definitions/phandle-array
+ items:
+ - items:
+ - description: phandle of APMU syscon
+ - description: configuration of the PHY lanes
+ description: |
+ Phandle to control PHY mux configuration. The configuration
+ is described as follows:
+ bit 4: 0 - PCIe A x8 mode, 1 - PCIe lane share mode
+ bit 3: 0 - PCIe A x4 mode, 1 - PCIe A x2 and PCIe B x2 mode
+ bit 2: 0 - PCIe C lane 0 is PCIe mode , 1 - USB mode
+ bit 1: 0 - PCIe C lane 1 is PCIe mode , 1 - USB mode
+ bit 0: 0 - PCIe D lane is PCIe mode , 1 - USB mode
+
+ The bit[3:0] is only valid when bit 4 is 1.
+
+required:
+ - compatible
+ - "#phy-cells"
+ - spacemit,apb-spare
+ - spacemit,apmu
+
+additionalProperties: false
+
+examples:
+ - |
+ phy@81d00000 {
+ compatible = "spacemit,k3-comb-phy";
+ reg = <0x81d00000 0x600000>;
+ #phy-cells = <2>;
+ spacemit,apb-spare = <&apb_spare>;
+ spacemit,apmu = <&apmu 0x00>;
+ };
--
2.54.0
@@ -0,0 +1,758 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH 2/2] phy: spacemit: Add USB3/PCIe comb PHY driver for
Spacemit K3
From: Inochi Amaoto <inochiama@gmail.com>
Date: Thu, 30 Apr 2026 10:28:41 +0800
Message-Id: <20260430022843.1090138-3-inochiama@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
The comb PHY on K3 requires to configure a syscon device for the
right mux configuration. And it requires calibration before any
usage.
Add USB3/PCIe comb PHY driver for Spacemit K3.
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
---
drivers/phy/spacemit/Kconfig | 16 ++
drivers/phy/spacemit/Makefile | 2 +
drivers/phy/spacemit/phy-k3-combphy.c | 250 ++++++++++++++++
drivers/phy/spacemit/phy-k3-common.c | 398 ++++++++++++++++++++++++++
drivers/phy/spacemit/phy-k3-common.h | 27 ++
5 files changed, 693 insertions(+)
create mode 100644 drivers/phy/spacemit/phy-k3-combphy.c
create mode 100644 drivers/phy/spacemit/phy-k3-common.c
create mode 100644 drivers/phy/spacemit/phy-k3-common.h
diff --git a/drivers/phy/spacemit/Kconfig b/drivers/phy/spacemit/Kconfig
index 50b0005acf66..5fdf18fce499 100644
--- a/drivers/phy/spacemit/Kconfig
+++ b/drivers/phy/spacemit/Kconfig
@@ -23,3 +23,19 @@ config PHY_SPACEMIT_K1_USB2
help
Enable this to support K1 USB 2.0 PHY driver. This driver takes care of
enabling and clock setup and will be used by K1 udc/ehci/otg/xhci driver.
+
+config PHY_SPACEMIT_K3_COMMON_OPS
+ tristate
+ select MFD_SYSCON
+ select GENERIC_PHY
+
+config PHY_SPACEMIT_K3_COMBO_PHY
+ tristate "SpacemiT K3 USB3/PCIe PHY support"
+ depends on (ARCH_SPACEMIT || COMPILE_TEST) && OF
+ depends on COMMON_CLK
+ select PHY_SPACEMIT_K3_COMMON_OPS
+ help
+ Enable this to support K3 USB3/PCIe combo PHY driver. This
+ driver takes care of enabling and clock setup and will be used
+ by K3 dwc3 driver.
+ If unsure, say N.
diff --git a/drivers/phy/spacemit/Makefile b/drivers/phy/spacemit/Makefile
index a821a21d6142..41be7b0388da 100644
--- a/drivers/phy/spacemit/Makefile
+++ b/drivers/phy/spacemit/Makefile
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-$(CONFIG_PHY_SPACEMIT_K1_PCIE) += phy-k1-pcie.o
obj-$(CONFIG_PHY_SPACEMIT_K1_USB2) += phy-k1-usb2.o
+obj-$(CONFIG_PHY_SPACEMIT_K3_COMBO_PHY) += phy-k3-combphy.o
+obj-$(CONFIG_PHY_SPACEMIT_K3_COMMON_OPS) += phy-k3-common.o
diff --git a/drivers/phy/spacemit/phy-k3-combphy.c b/drivers/phy/spacemit/phy-k3-combphy.c
new file mode 100644
index 000000000000..66fa6330ad6e
--- /dev/null
+++ b/drivers/phy/spacemit/phy-k3-combphy.c
@@ -0,0 +1,250 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * phy-k3-usb3.c - SpacemiT K3 Type-C Orientation Switch Driver
+ *
+ * Copyright (c) 2025 SpacemiT Technology Co. Ltd
+ */
+
+#include <linux/bitfield.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/mfd/syscon.h>
+#include <linux/iopoll.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/phy/phy.h>
+
+#include <dt-bindings/phy/phy.h>
+
+#include "phy-k3-common.h"
+
+/*
+ * The PCIE/USB Subsystem on SpacemiT K3 have 3 single lane PIPE3 PHYs
+ * (PHY2/3/4) shared by PCIE PortC/D and USB3 PortB/C/D.
+ *
+ * PMUA_PCIE_SUBSYS_MGMT[4:0]
+ *
+ * bit4 = 0 : PCIe A X8 mode, all 8 lanes dedicated to PCIe Port A
+ * 1 : PHY lanes shared between PCIe or USB according to [3:0]
+ *
+ * All PHY matrix combinations according to [4:0]:
+ *
+ * 0x0X : PCIe-A X8
+ * 0x10 : PCIe-C x2 (PHY2+PHY3) + PCIe-D x1 (PHY4)
+ * 0x11 : PCIe-C x2 (PHY2+PHY3) + USB-D (PHY4)
+ * 0x12 : PCIe-C x1 (PHY2) + USB-C (PHY3)
+ * 0x13 : PCIe-C x1 (PHY2) + USB-C (PHY3) + USB-D (PHY4)
+ * 0x14 : PCIe-C x1 (PHY3) + USB-B (PHY2)
+ * 0x15 : PCIe-C x1 (PHY3) + USB-B (PHY2) + USB-D (PHY4)
+ * 0x16 : USB-B (PHY2) + USB-C (PHY3) + PCIe D x1 (PHY4)
+ * 0x17 : USB-B (PHY2) + USB-C (PHY3) + USB-D (PHY4)
+ *
+ * So any USB Port B/C/D operation requires PCIe A X8 mode to be disabled.
+ */
+#define PMUA_PCIE_SUBSYS_MGMT 0x1d8
+#define PU_MATRIX_CONF_MASK GENMASK(4, 0)
+
+#define COMBPHY_MAX_SUBPHYS 6
+
+struct k3_comb_phy {
+ struct device *dev;
+ struct k3_lane_group groups[COMBPHY_MAX_SUBPHYS];
+ void __iomem *base;
+ struct regmap *apb_spare;
+};
+
+static const struct k3_phy_lane_group_data k3_combphy_lane_group0 = {
+ .lanes = 2,
+ .config = 0x00,
+ .mask = 0xff,
+ .offsets = {
+ 0x0, 0x400
+ },
+};
+
+static const struct k3_phy_lane_group_data k3_combphy_lane_group1 = {
+ .lanes = 2,
+ .config = 0x00,
+ .mask = 0xff,
+ .offsets = {
+ 0x100000, 0x100400
+ },
+};
+
+static const struct k3_phy_lane_group_data k3_combphy_lane_group2 = {
+ .lanes = 1,
+ .config = 0x14,
+ .mask = 0x14,
+ .offsets = {
+ 0x200000
+ },
+};
+
+static const struct k3_phy_lane_group_data k3_combphy_lane_group3 = {
+ .lanes = 1,
+ .config = 0x12,
+ .mask = 0x12,
+ .offsets = {
+ 0x300000
+ },
+};
+
+static const struct k3_phy_lane_group_data k3_combphy_lane_group4 = {
+ .lanes = 1,
+ .config = 0x11,
+ .mask = 0x11,
+ .offsets = {
+ 0x400000
+ },
+};
+
+static const struct k3_phy_lane_group_data k3_combphy_lane_group5 = {
+ .lanes = 1,
+ .config = 0x00,
+ .mask = 0xff,
+ .offsets = {
+ 0x500000
+ },
+};
+
+static const struct k3_phy_lane_group_data *k3_combphy_lane_datas[] = {
+ &k3_combphy_lane_group0,
+ &k3_combphy_lane_group1,
+ &k3_combphy_lane_group2,
+ &k3_combphy_lane_group3,
+ &k3_combphy_lane_group4,
+ &k3_combphy_lane_group5,
+};
+
+static int k3_comb_phy_init_lanes(struct k3_comb_phy *phy, unsigned int config)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(k3_combphy_lane_datas); i++) {
+ const struct k3_phy_lane_group_data *data = k3_combphy_lane_datas[i];
+ struct k3_lane_group *lg = &phy->groups[i];
+ const struct phy_ops *ops;
+ bool is_usb;
+
+ is_usb = (data->mask & config) == data->config;
+ if (is_usb)
+ ops = &k3_usb3_phy_ops;
+ else
+ ops = &k3_pcie_phy_ops;
+
+ lg->phy = devm_phy_create(phy->dev, NULL, ops);
+ if (IS_ERR(lg->phy))
+ return PTR_ERR(lg->phy);
+
+ lg->is_pcie = !is_usb;
+ lg->data = data;
+ lg->base = phy->base;
+ phy_set_drvdata(lg->phy, lg);
+ }
+
+ return 0;
+}
+
+static int k3_comb_phy_update_config(struct regmap *apmu, unsigned int config)
+{
+ if (config & ~PU_MATRIX_CONF_MASK)
+ return -EINVAL;
+
+ return regmap_update_bits(apmu, PMUA_PCIE_SUBSYS_MGMT, PU_MATRIX_CONF_MASK, config);
+}
+
+static struct phy *k3_comb_phy_xlate(struct device *dev, const struct of_phandle_args *args)
+{
+ struct k3_comb_phy *phy = dev_get_drvdata(dev);
+ struct k3_lane_group *lg;
+
+ if (args->args_count != 2) {
+ dev_err(dev, "Invalid number of arguments\n");
+ return ERR_PTR(-EINVAL);
+ }
+
+ if (args->args[0] >= ARRAY_SIZE(k3_combphy_lane_datas)) {
+ dev_err(dev, "Invalid PHY id\n");
+ return ERR_PTR(-EINVAL);
+ }
+
+ lg = &phy->groups[args->args[0]];
+
+ if ((lg->is_pcie && args->args[1] != PHY_TYPE_PCIE) ||
+ (!lg->is_pcie && args->args[1] != PHY_TYPE_USB3)) {
+ dev_err(dev, "Invalid PHY mode\n");
+ return ERR_PTR(-EINVAL);
+ }
+
+ return lg->phy;
+}
+
+static int k3_comb_phy_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct device_node *node = dev->of_node;
+ struct phy_provider *provider;
+ struct k3_comb_phy *phy;
+ struct regmap *apmu;
+ u32 config = 0;
+ int ret;
+
+ phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
+ if (!phy)
+ return -ENOMEM;
+
+ phy->base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(phy->base))
+ return PTR_ERR(phy->base);
+
+ phy->apb_spare = syscon_regmap_lookup_by_phandle(node, "spacemit,apb-spare");
+ if (IS_ERR(phy->apb_spare))
+ return dev_err_probe(dev, PTR_ERR(phy->apb_spare),
+ "Failed to fine APB SPARE syscon");
+
+ apmu = syscon_regmap_lookup_by_phandle_args(node, "spacemit,apmu", 1, &config);
+ if (IS_ERR(apmu))
+ return dev_err_probe(dev, PTR_ERR(phy->apb_spare),
+ "Failed to fine APMU syscon");
+
+ ret = k3_comb_phy_update_config(apmu, config);
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "Failed to set lane configuration");
+
+ phy->dev = dev;
+ platform_set_drvdata(pdev, phy);
+
+ ret = k3_phy_calibrate(phy->apb_spare);
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "Failed to calibrate phy");
+
+ ret = k3_comb_phy_init_lanes(phy, config);
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "Failed to init lanes");
+
+ provider = devm_of_phy_provider_register(dev, k3_comb_phy_xlate);
+ if (IS_ERR(provider))
+ return dev_err_probe(dev, PTR_ERR(provider),
+ "Failed to register provider\n");
+
+ return 0;
+}
+
+static const struct of_device_id k3_comb_phy_of_match[] = {
+ { .compatible = "spacemit,k3-comb-phy" },
+ { },
+};
+MODULE_DEVICE_TABLE(of, k3_comb_phy_of_match);
+
+static struct platform_driver k3_comb_phy_driver = {
+ .probe = k3_comb_phy_probe,
+ .driver = {
+ .name = "spacemit,k3-comb-phy",
+ .of_match_table = k3_comb_phy_of_match,
+ },
+};
+module_platform_driver(k3_comb_phy_driver);
+
+MODULE_DESCRIPTION("SpacemiT K3 USB3/PCIe comb PHY driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/phy/spacemit/phy-k3-common.c b/drivers/phy/spacemit/phy-k3-common.c
new file mode 100644
index 000000000000..77c4b4073b96
--- /dev/null
+++ b/drivers/phy/spacemit/phy-k3-common.c
@@ -0,0 +1,398 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/bitfield.h>
+#include <linux/cleanup.h>
+#include <linux/io.h>
+#include <linux/iopoll.h>
+#include <linux/module.h>
+#include <linux/regmap.h>
+#include <linux/usb.h>
+
+#include <dt-bindings/phy/phy.h>
+
+#include "phy-k3-common.h"
+
+/* PHY Registers */
+#define PHY_VERSION 0x0
+
+#define PHY_RESET_CFG 0x04
+
+#define PHY_RESET_RXBUF_RST BIT(0)
+#define PHY_RESET_SOFT_RST_PCS BIT(1)
+#define PHY_RESET_SOFT_RST_AHB BIT(2)
+#define PHY_RESET_EN_SD_AFTER_LOCK BIT(6)
+
+#define PHY_CLK_CFG 0x08
+
+#define PHY_CLK_PLL_READY BIT(0)
+#define PHY_CLK_TXCLK_INV BIT(2)
+#define PHY_CLK_RXCLK_EN BIT(3)
+#define PHY_CLK_TXCLK_EN BIT(4)
+#define PHY_CLK_PCLK_EN BIT(5)
+#define PHY_CLK_PIPE_PCLK_EN BIT(6)
+#define PHY_CLK_REFCLK_FREQ GENMASK(10, 7)
+#define PHY_CLK_REFCLK_24M 2
+#define PHY_CLK_SW_INIT_DONE BIT(11)
+#define PHY_CLK_PU_SSC_OUT BIT(23)
+
+#define PHY_MODE_CFG 0x0C
+
+#define PHY_MODE_PCIE_INT_EN BIT(0)
+#define PHY_MODE_LFPS_TPERIOD GENMASK(9, 8)
+#define PHY_MODE_LFPS_TPERIOD_USB 3
+
+#define PHY_PU_SEL 0x40
+
+#define PHY_PU_CFG_STATUS BIT(9)
+#define PHY_PU_OVRD_STATUS BIT(10)
+
+#define PHY_PU_CK_REG 0x54
+
+#define PHY_PU_REFCLK_100 BIT(25)
+
+#define PHY_PLL_REG1 0x58
+
+#define PHY_PLL_FREF_SEL GENMASK(15, 13)
+#define PHY_PLL_FREF_24M 0x1
+#define PHY_PLL_SSC_DEP_SEL GENMASK(27, 24)
+#define PHY_PLL_SSC_5000PPM 0xa
+#define PHY_PLL_SSC_MODE GENMASK(29, 28)
+#define PHY_PLL_SSC_MODE_CENTER_SPREAD 0
+#define PHY_PLL_SSC_MODE_UP_SPREAD 1
+#define PHY_PLL_SSC_MODE_DOWN_SPREAD 2
+#define PHY_PLL_SSC_MODE_DOWN_SPREAD1 3
+
+#define PHY_PLL_REG2 0x5c
+
+#define PHY_PLL_SEL_REF100 BIT(21)
+
+/* PHY RX Register Definitions */
+#define PHY_RX_REG_A 0x60
+
+#define PHY_RX_REG0_RLOAD BIT(4)
+#define PHY_RX_REG1_RTERM GENMASK(11, 8)
+#define PHY_RX_REG1_RC_CALI GENMASK(15, 12)
+#define PHY_RX_REG2_CSEL GENMASK(19, 16)
+#define PHY_RX_REG2_FORCE_CSEL BIT(20)
+#define PHY_RX_REG2_PSEL GENMASK(23, 21)
+#define PHY_RX_REG3_I_LOAD GENMASK(26, 24)
+#define PHY_RX_REG3_SEL_CBOOST_CODE BIT(27)
+#define PHY_RX_REG3_ADJ_BIAS GENMASK(29, 28)
+#define PHY_RX_REG3_RDEG1 GENMASK(31, 30)
+
+#define PHY_RX_REG_B 0x64
+
+#define PHY_RX_REGB_MASK GENMASK(23, 0)
+
+#define PHY_RX_REG4_RDEG2 GENMASK(2, 1)
+#define PHY_RX_REG4_ENVOS BIT(4)
+#define PHY_RX_REG4_RTERM_SEL BIT(5)
+#define PHY_RX_REG4_MANUAL_CFG BIT(7)
+#define PHY_RX_REG5_RCELL_VCM GENMASK(11, 8)
+#define PHY_RX_REG5_RCELL_BIAS GENMASK(15, 12)
+#define PHY_RX_REG6_H1_REG GENMASK(19, 16)
+#define PHY_RX_REG6_ADAPT_GAIN GENMASK(21, 20)
+#define PHY_RX_REG6_BYPASS_ADPT BIT(22)
+
+#define PHY_ADPT_CFG0 0x140
+#define PHY_ADPT_AFE_RST_OVRD_EN BIT(1)
+#define PHY_ADPT_AFE_RST_OVRD_VAL BIT(4)
+
+#define PHY_RXEQ_TIME 0xb4
+#define PHY_RXEQ_TIME_OVRD_POST_C_SOC BIT(21)
+#define PHY_RXEQ_TIME_CFG_AMP_SOC GENMASK(23, 22)
+#define PHY_RXEQ_TIME_AMP_SOC_650M 0
+#define PHY_RXEQ_TIME_AMP_SOC_800M 1
+#define PHY_RXEQ_TIME_AMP_SOC_870M 2
+#define PHY_RXEQ_TIME_AMP_SOC_900M 3
+#define PHY_RXEQ_TIME_OVRD_AMP_SOC BIT(24)
+
+#define PCIE_PU_ADDR_CLK_CFG 0x0008
+#define PHY_CLK_PLL_READY BIT(0)
+#define PCIE_INITAL_TIMER GENMASK(6, 3)
+#define CFG_INTERNAL_TIMER_ADJ GENMASK(10, 7)
+#define CFG_SW_PHY_INIT_DONE BIT(11)
+
+/* Lane RX/TX configuration (per‑lane, at lane_base) */
+#define PCIE_RX_REG1 0x050
+#define PCIE_TX_REG1 0x064
+
+#define PCIE_PLL_TIMEOUT 500000
+#define PCIE_POLL_DELAY 500
+
+static int k3_usb3phy_init_single(struct k3_lane_group *lg, void __iomem *base)
+{
+ struct phy *phy = lg->phy;
+ u32 val, tmp;
+ int ret;
+
+ val = readl(base + PHY_PU_SEL);
+ val = u32_replace_bits(val, 0, PHY_PU_CFG_STATUS);
+ val |= PHY_PU_OVRD_STATUS;
+ writel(val, base + PHY_PU_SEL);
+
+ udelay(200);
+
+ /* Do not wait CDR lock before sampling data */
+ val = readl(base + PHY_RESET_CFG);
+ val = u32_replace_bits(val, 0, PHY_RESET_EN_SD_AFTER_LOCK);
+ writel(val, base + PHY_RESET_CFG);
+
+ /* Power down 100MHz refclk buffer */
+ val = readl(base + PHY_PU_CK_REG);
+ val = u32_replace_bits(val, 0, PHY_PU_REFCLK_100);
+ writel(val, base + PHY_PU_CK_REG);
+
+ /* Program PLL REG1 configure the SSC */
+ val = FIELD_PREP(PHY_PLL_SSC_MODE, PHY_PLL_SSC_MODE_DOWN_SPREAD1) |
+ FIELD_PREP(PHY_PLL_SSC_DEP_SEL, PHY_PLL_SSC_5000PPM) |
+ FIELD_PREP(PHY_PLL_FREF_SEL, PHY_PLL_FREF_24M);
+ writel(val, base + PHY_PLL_REG1);
+
+ /* Un-select 100MHz PLL reference */
+ val = readl(base + PHY_PLL_REG2);
+ val = u32_replace_bits(val, 0, PHY_PLL_SEL_REF100);
+ writel(val, base + PHY_PLL_REG2);
+
+ /* USB LFPS period configuration */
+ val = readl(base + PHY_MODE_CFG);
+ val = u32_replace_bits(val, PHY_MODE_LFPS_TPERIOD_USB, PHY_MODE_LFPS_TPERIOD);
+ writel(val, base + PHY_MODE_CFG);
+
+ /* Force AFE adaptation reset */
+ val = readl(base + PHY_ADPT_CFG0);
+ val |= PHY_ADPT_AFE_RST_OVRD_EN | PHY_ADPT_AFE_RST_OVRD_VAL;
+ writel(val, base + PHY_ADPT_CFG0);
+
+ /* Override driver amplitude value to 900m */
+ val = readl(base + PHY_RXEQ_TIME);
+ val |= PHY_RXEQ_TIME_OVRD_AMP_SOC;
+ val = u32_replace_bits(val, PHY_RXEQ_TIME_AMP_SOC_900M, PHY_RXEQ_TIME_CFG_AMP_SOC);
+ writel(val, base + PHY_RXEQ_TIME);
+
+ /* Configure RX parameters */
+ val = PHY_RX_REG0_RLOAD |
+ FIELD_PREP(PHY_RX_REG1_RTERM, 0x8) |
+ FIELD_PREP(PHY_RX_REG1_RC_CALI, 0x7) |
+ FIELD_PREP(PHY_RX_REG2_CSEL, 0x8) |
+ PHY_RX_REG2_FORCE_CSEL |
+ FIELD_PREP(PHY_RX_REG2_PSEL, 0x4) |
+ FIELD_PREP(PHY_RX_REG3_I_LOAD, 0x7) |
+ PHY_RX_REG3_SEL_CBOOST_CODE |
+ FIELD_PREP(PHY_RX_REG3_ADJ_BIAS, 0x1) |
+ FIELD_PREP(PHY_RX_REG3_RDEG1, 0x3);
+ writel(val, base + PHY_RX_REG_A);
+
+ val = readl(base + PHY_RX_REG_B);
+ tmp = FIELD_PREP(PHY_RX_REG4_RDEG2, 0x2) |
+ PHY_RX_REG4_ENVOS | PHY_RX_REG4_RTERM_SEL | PHY_RX_REG4_MANUAL_CFG |
+ FIELD_PREP(PHY_RX_REG5_RCELL_VCM, 0x8) |
+ FIELD_PREP(PHY_RX_REG5_RCELL_BIAS, 0x8) |
+ FIELD_PREP(PHY_RX_REG6_H1_REG, 0x8) |
+ FIELD_PREP(PHY_RX_REG6_ADAPT_GAIN, 0x2);
+ val = u32_replace_bits(val, tmp, PHY_RX_REGB_MASK);
+ writel(val, base + PHY_RX_REG_B);
+
+ /*
+ * Inform PHY that all PLL-related configuration is done.
+ * PLL will not start locking until PHY_CLK_SW_INIT_DONE is set.
+ */
+ val = PHY_CLK_SW_INIT_DONE | PHY_CLK_PU_SSC_OUT |
+ FIELD_PREP(PHY_CLK_REFCLK_FREQ, PHY_CLK_REFCLK_24M) |
+ PHY_CLK_RXCLK_EN | PHY_CLK_TXCLK_EN |
+ PHY_CLK_PCLK_EN | PHY_CLK_PIPE_PCLK_EN;
+ writel(val, base + PHY_CLK_CFG);
+
+ ret = readl_poll_timeout(base + PHY_CLK_CFG, val,
+ (val & PHY_CLK_PLL_READY),
+ PCIE_POLL_DELAY, PCIE_PLL_TIMEOUT);
+ if (ret) {
+ dev_err(&phy->dev, "PHY PLL polling timeout\n");
+ return ret;
+ }
+
+ return 0;
+}
+
+static int k3_usb3phy_init(struct phy *phy)
+{
+ struct k3_lane_group *lg = phy_get_drvdata(phy);
+ int ret, i;
+
+ for (i = 0; i < lg->data->lanes; i++) {
+ ret = k3_usb3phy_init_single(lg, lg->base + lg->data->offsets[i]);
+ if (ret < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
+static int k3_usb3phy_set_speed(struct phy *phy, int speed)
+{
+ struct k3_lane_group *lg = phy_get_drvdata(phy);
+ void __iomem *base = lg->base + lg->data->offsets[0];
+ u32 val;
+
+ if (speed == USB_SPEED_HIGH) {
+ val = readl(base + PHY_PU_SEL);
+ val = u32_replace_bits(val, 0, PHY_PU_CFG_STATUS);
+ val |= PHY_PU_OVRD_STATUS;
+ writel(val, base + PHY_PU_SEL);
+
+ udelay(200);
+ }
+
+ return 0;
+}
+
+const struct phy_ops k3_usb3_phy_ops = {
+ .init = k3_usb3phy_init,
+ .set_speed = k3_usb3phy_set_speed,
+ .owner = THIS_MODULE,
+};
+EXPORT_SYMBOL_GPL(k3_usb3_phy_ops);
+
+static int k3_pcie_phy_init(struct phy *phy)
+{
+ struct k3_lane_group *lg = phy_get_drvdata(phy);
+ void __iomem *phy_base = lg->base + lg->data->offsets[0];
+ u32 val;
+ int ret;
+ int i;
+
+ val = readl(phy_base + PHY_PLL_REG1);
+ val = u32_replace_bits(val, 0x2, GENMASK(15, 12));
+ writel(val, phy_base + PHY_PLL_REG1);
+
+ val = readl(phy_base + PHY_PLL_REG2);
+ val = u32_replace_bits(val, 0, BIT(21));
+ writel(val, phy_base + PHY_PLL_REG2);
+
+ for (i = 0; i < lg->data->lanes; i++) {
+ void __iomem *lane_base = lg->base + lg->data->offsets[i];
+
+ val = readl(lane_base + PCIE_RX_REG1);
+ val = u32_replace_bits(val, 0, 0x3);
+ writel(val, phy_base + PCIE_RX_REG1);
+ }
+
+ val = readl(phy_base + PHY_PLL_REG2);
+ val |= BIT(20);
+ writel(val, phy_base + PHY_PLL_REG2);
+
+ writel(0x00006505, phy_base + PCIE_RX_REG1);
+
+ /* pll_reg1 of lane0, disable SSC: pll_reg4[3:0] = 0 */
+ val = readl(phy_base + PHY_PLL_REG1);
+ val = u32_replace_bits(val, 0, GENMASK(27, 24));
+ writel(val, phy_base + PHY_PLL_REG1);
+
+ for (i = 0; i < lg->data->lanes; i++) {
+ void __iomem *lane_base = lg->base + lg->data->offsets[i];
+
+ /* set cfg_tx_send_dummy_data to be 1'b1 for disable dash data */
+ val = readl(lane_base + PHY_PU_SEL);
+ val = u32_replace_bits(val, 1, BIT(13));
+ writel(val, lane_base + PHY_PU_SEL);
+
+ /* disable en_sample_data_after_cdr_locked */
+ val = readl(lane_base + PHY_RESET_CFG);
+ val = u32_replace_bits(val, 0, BIT(6));
+ writel(val, lane_base + PHY_RESET_CFG);
+
+ /* Dynamic Lock */
+ val = readl(lane_base + PHY_MODE_CFG);
+ val = u32_replace_bits(val, 1, BIT(2));
+ writel(val, lane_base + PHY_MODE_CFG);
+
+ val = FIELD_PREP(GENMASK(7, 0), 0x10) |
+ FIELD_PREP(GENMASK(15, 8), 0x78) |
+ FIELD_PREP(GENMASK(23, 16), 0x98) |
+ FIELD_PREP(GENMASK(31, 24), 0xdf);
+ writel(val, lane_base + PHY_RX_REG_A);
+
+ val = readl(lane_base + PHY_RX_REG_B);
+ val &= ~PHY_RX_REGB_MASK;
+ val |= FIELD_PREP(GENMASK(7, 0), 0xb4) |
+ FIELD_PREP(GENMASK(15, 8), 0x88) |
+ FIELD_PREP(GENMASK(23, 16), 0x28);
+ writel(val, lane_base + PHY_RX_REG_B);
+
+ /* Set init done */
+ val = readl(lane_base + PCIE_PU_ADDR_CLK_CFG);
+ val = u32_replace_bits(val, 1, CFG_SW_PHY_INIT_DONE);
+ writel(val, lane_base + PCIE_PU_ADDR_CLK_CFG);
+ }
+
+ ret = readl_poll_timeout(phy_base + PCIE_PU_ADDR_CLK_CFG, val,
+ (val & PHY_CLK_PLL_READY), PCIE_POLL_DELAY,
+ PCIE_PLL_TIMEOUT);
+ if (ret) {
+ dev_err(&lg->phy->dev, "PHY PLL lock timeout\n");
+ return ret;
+ }
+
+ return 0;
+}
+
+const struct phy_ops k3_pcie_phy_ops = {
+ .init = k3_pcie_phy_init,
+ .owner = THIS_MODULE,
+};
+EXPORT_SYMBOL_GPL(k3_pcie_phy_ops);
+
+/* PHY rcal init requires APB_SPARE regmap access */
+
+#define APB_SPARE_PU_CAL 0x178
+#define PU_CAL BIT(17)
+
+#define APB_SPARE_RCAL_HSIO 0x17c
+#define APB_SPARE_PU_CAL_DONE BIT(8)
+#define RCAL_OVRD_PTRIM GENMASK(23, 20)
+#define RCAL_OVRD_NTRIM GENMASK(27, 24)
+#define RCAL_OVRD_PTRIM_EN BIT(28)
+#define RCAL_OVRD_NTRIM_EN BIT(29)
+#define RCAL_OVRD_STABLE_VAL BIT(30)
+#define RCAL_OVRD_STABLE_EN BIT(31)
+
+#define RCAL_OVRD_TRIM_EN (RCAL_OVRD_NTRIM_EN | RCAL_OVRD_PTRIM_EN)
+#define RCAL_OVRD_TRIM_MASK (RCAL_OVRD_NTRIM | RCAL_OVRD_PTRIM)
+
+#define PU_CAL_TIMEOUT 2000000
+
+static DEFINE_MUTEX(calibrate_lock);
+
+int k3_phy_calibrate(struct regmap *apb_spare)
+{
+ unsigned int val;
+ int ret;
+
+ guard(mutex)(&calibrate_lock);
+
+ regmap_read(apb_spare, APB_SPARE_RCAL_HSIO, &val);
+ if (val & APB_SPARE_PU_CAL_DONE)
+ return 0;
+
+ regmap_update_bits(apb_spare, APB_SPARE_PU_CAL, PU_CAL,
+ PU_CAL);
+
+ ret = regmap_read_poll_timeout(apb_spare, APB_SPARE_RCAL_HSIO,
+ val, (val & APB_SPARE_PU_CAL_DONE), PCIE_POLL_DELAY,
+ PU_CAL_TIMEOUT);
+
+ if (ret)
+ regmap_update_bits(apb_spare, APB_SPARE_RCAL_HSIO,
+ RCAL_OVRD_TRIM_EN | RCAL_OVRD_STABLE_VAL |
+ RCAL_OVRD_TRIM_MASK | RCAL_OVRD_STABLE_EN,
+ RCAL_OVRD_TRIM_EN | RCAL_OVRD_STABLE_VAL |
+ FIELD_PREP(RCAL_OVRD_NTRIM, 0x6) |
+ FIELD_PREP(RCAL_OVRD_PTRIM, 0xa) |
+ RCAL_OVRD_STABLE_EN);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(k3_phy_calibrate);
+
+MODULE_DESCRIPTION("SpacemiT K3 PHY common ops");
+MODULE_LICENSE("GPL");
diff --git a/drivers/phy/spacemit/phy-k3-common.h b/drivers/phy/spacemit/phy-k3-common.h
new file mode 100644
index 000000000000..49009c3c313a
--- /dev/null
+++ b/drivers/phy/spacemit/phy-k3-common.h
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _PHY_K3_COMMON_H
+#define _PHY_K3_COMMON_H
+
+#include <linux/phy/phy.h>
+
+struct k3_phy_lane_group_data {
+ u32 lanes;
+ u8 config;
+ u8 mask;
+ u32 offsets[] __counted_by(lanes);
+};
+
+struct k3_lane_group {
+ const struct k3_phy_lane_group_data *data;
+ void __iomem *base;
+ struct phy *phy;
+ bool is_pcie;
+};
+
+extern const struct phy_ops k3_pcie_phy_ops;
+extern const struct phy_ops k3_usb3_phy_ops;
+
+int k3_phy_calibrate(struct regmap *apb_spare);
+
+#endif
--
2.54.0
@@ -0,0 +1,105 @@
From From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH v4 1/6] PCI: spacemit-k1: Add device data support
From: Inochi Amaoto <inochiama@gmail.com>
Date: Thu, 09 Jul 2026 12:00:21 +0800
Message-Id: <20260709040027.958400-2-inochiama@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
To reuse the K1 PCIe driver logic for K3 PCIe controller, add device
data to handle the K1 specific logic and make room for the incoming
logic for K3.
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Reviewed-by: Alex Elder <elder@riscstar.com>
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
---
drivers/pci/controller/dwc/pcie-spacemit-k1.c | 30 ++++++++++++++++---
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-spacemit-k1.c b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
index be20a520255b..f6ae8ff3589a 100644
--- a/drivers/pci/controller/dwc/pcie-spacemit-k1.c
+++ b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
@@ -49,8 +49,17 @@
#define PCIE_CONTROL_LOGIC 0x0004
#define PCIE_SOFT_RESET BIT(0)
+struct k1_pcie;
+
+struct k1_pcie_device_data {
+ const struct dw_pcie_host_ops *host_ops;
+ const struct dw_pcie_ops *ops;
+ int (*parse_port)(struct k1_pcie *k1);
+};
+
struct k1_pcie {
struct dw_pcie pci;
+ const struct k1_pcie_device_data *data;
struct phy *phy;
void __iomem *link;
struct regmap *pmu; /* Errors ignored; MMIO-backed regmap */
@@ -278,14 +287,21 @@ static int k1_pcie_parse_port(struct k1_pcie *k1)
static int k1_pcie_probe(struct platform_device *pdev)
{
+ const struct k1_pcie_device_data *data;
struct device *dev = &pdev->dev;
struct k1_pcie *k1;
int ret;
+ data = device_get_match_data(dev);
+ if (!data)
+ return -ENODEV;
+
k1 = devm_kzalloc(dev, sizeof(*k1), GFP_KERNEL);
if (!k1)
return -ENOMEM;
+ k1->data = data;
+
k1->pmu = syscon_regmap_lookup_by_phandle_args(dev_of_node(dev),
SYSCON_APMU, 1,
&k1->pmu_off);
@@ -299,11 +315,11 @@ static int k1_pcie_probe(struct platform_device *pdev)
"failed to map \"link\" registers\n");
k1->pci.dev = dev;
- k1->pci.ops = &k1_pcie_ops;
+ k1->pci.ops = data->ops;
k1->pci.pp.num_vectors = MAX_MSI_IRQS;
dw_pcie_cap_set(&k1->pci, REQ_RES);
- k1->pci.pp.ops = &k1_pcie_host_ops;
+ k1->pci.pp.ops = data->host_ops;
/* Hold the PHY in reset until we start the link */
regmap_set_bits(k1->pmu, k1->pmu_off + PCIE_CLK_RESET_CONTROL,
@@ -320,7 +336,7 @@ static int k1_pcie_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, k1);
- ret = k1_pcie_parse_port(k1);
+ ret = data->parse_port(k1);
if (ret)
return dev_err_probe(dev, ret, "failed to parse root port\n");
@@ -338,8 +354,14 @@ static void k1_pcie_remove(struct platform_device *pdev)
dw_pcie_host_deinit(&k1->pci.pp);
}
+static const struct k1_pcie_device_data k1_pcie_device_data = {
+ .host_ops = &k1_pcie_host_ops,
+ .ops = &k1_pcie_ops,
+ .parse_port = k1_pcie_parse_port,
+};
+
static const struct of_device_id k1_pcie_of_match_table[] = {
- { .compatible = "spacemit,k1-pcie", },
+ { .compatible = "spacemit,k1-pcie", .data = &k1_pcie_device_data},
{ }
};
--
2.55.0
@@ -0,0 +1,156 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH v4 2/6] PCI: spacemit-k1: Add multiple PHY handles support
From: Inochi Amaoto <inochiama@gmail.com>
Date: Thu, 09 Jul 2026 12:00:22 +0800
Message-Id: <20260709040027.958400-3-inochiama@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
The PCIe controller on Spacemit K3 may use multiple PHYs at the
same time. The feature is not support by the current driver.
So extend the PHY definition to support multiple PHY handles.
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
---
drivers/pci/controller/dwc/pcie-spacemit-k1.c | 70 ++++++++++++++++---
1 file changed, 59 insertions(+), 11 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-spacemit-k1.c b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
index f6ae8ff3589a..e22ecbd09579 100644
--- a/drivers/pci/controller/dwc/pcie-spacemit-k1.c
+++ b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
@@ -55,12 +55,14 @@ struct k1_pcie_device_data {
const struct dw_pcie_host_ops *host_ops;
const struct dw_pcie_ops *ops;
int (*parse_port)(struct k1_pcie *k1);
+ unsigned int max_phy_count;
};
struct k1_pcie {
struct dw_pcie pci;
const struct k1_pcie_device_data *data;
- struct phy *phy;
+ struct phy **phy;
+ unsigned int phy_count;
void __iomem *link;
struct regmap *pmu; /* Errors ignored; MMIO-backed regmap */
u32 pmu_off;
@@ -119,6 +121,54 @@ static void k1_pcie_disable_resources(struct k1_pcie *k1)
clk_bulk_disable_unprepare(ARRAY_SIZE(pci->app_clks), pci->app_clks);
}
+static int k1_pcie_get_phy_handle(struct k1_pcie *k1, struct device_node *node)
+{
+ const struct k1_pcie_device_data *data = k1->data;
+ struct device *dev = k1->pci.dev;
+ unsigned int i;
+
+ k1->phy = devm_kmalloc_array(dev, data->max_phy_count,
+ sizeof(*k1->phy), GFP_KERNEL);
+ if (!k1->phy)
+ return -ENOMEM;
+
+ for (i = 0; i < data->max_phy_count; i++) {
+ k1->phy[i] = devm_of_phy_get_by_index(dev, node, i);
+ if (IS_ERR(k1->phy[i])) {
+ if (PTR_ERR(k1->phy[i]) == -ENODEV)
+ break;
+
+ return PTR_ERR(k1->phy[i]);
+ }
+ }
+
+ k1->phy_count = i;
+ if (k1->phy_count == 0)
+ return -EINVAL;
+
+ return 0;
+}
+
+static int k1_pcie_enable_phy(struct k1_pcie *k1)
+{
+ unsigned int i;
+ int ret;
+
+ for (i = 0; i < k1->phy_count; i++) {
+ ret = phy_init(k1->phy[i]);
+ if (ret)
+ goto err_phy;
+ }
+
+ return 0;
+
+err_phy:
+ while (i--)
+ phy_exit(k1->phy[i]);
+
+ return ret;
+}
+
/* FIXME: Disable ASPM L1 to avoid errors reported on some NVMe drives */
static void k1_pcie_disable_aspm_l1(struct k1_pcie *k1)
{
@@ -174,7 +224,7 @@ static int k1_pcie_init(struct dw_pcie_rp *pp)
*/
regmap_set_bits(k1->pmu, reset_ctrl, DEVICE_TYPE_RC | PCIE_AUX_PWR_DET);
- ret = phy_init(k1->phy);
+ ret = k1_pcie_enable_phy(k1);
if (ret) {
k1_pcie_disable_resources(k1);
@@ -194,12 +244,14 @@ static void k1_pcie_deinit(struct dw_pcie_rp *pp)
{
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
struct k1_pcie *k1 = to_k1_pcie(pci);
+ int i;
/* Assert fundamental reset (drive PERST# low) */
regmap_set_bits(k1->pmu, k1->pmu_off + PCIE_CLK_RESET_CONTROL,
PCIE_RC_PERST);
- phy_exit(k1->phy);
+ for (i = 0; i < k1->phy_count; i++)
+ phy_exit(k1->phy[i]);
k1_pcie_disable_resources(k1);
}
@@ -266,23 +318,18 @@ static int k1_pcie_parse_port(struct k1_pcie *k1)
{
struct device *dev = k1->pci.dev;
struct device_node *root_port;
- struct phy *phy;
+ int ret;
/* We assume only one root port */
root_port = of_get_next_available_child(dev_of_node(dev), NULL);
if (!root_port)
return -EINVAL;
- phy = devm_of_phy_get(dev, root_port, NULL);
+ ret = k1_pcie_get_phy_handle(k1, root_port);
of_node_put(root_port);
- if (IS_ERR(phy))
- return PTR_ERR(phy);
-
- k1->phy = phy;
-
- return 0;
+ return ret;
}
static int k1_pcie_probe(struct platform_device *pdev)
@@ -358,6 +405,7 @@ static const struct k1_pcie_device_data k1_pcie_device_data = {
.host_ops = &k1_pcie_host_ops,
.ops = &k1_pcie_ops,
.parse_port = k1_pcie_parse_port,
+ .max_phy_count = 1,
};
static const struct of_device_id k1_pcie_of_match_table[] = {
--
2.55.0
@@ -0,0 +1,70 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH v4 3/6] PCI: spacemit-k1: Add device id update helper
From: Inochi Amaoto <inochiama@gmail.com>
Date: Thu, 09 Jul 2026 12:00:23 +0800
Message-Id: <20260709040027.958400-4-inochiama@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Both K1 and K3 needs to set vendor id and device id, add a helper function
to simplify this.
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Reviewed-by: Alex Elder <elder@riscstar.com>
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
---
drivers/pci/controller/dwc/pcie-spacemit-k1.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-spacemit-k1.c b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
index e22ecbd09579..31aac056b68e 100644
--- a/drivers/pci/controller/dwc/pcie-spacemit-k1.c
+++ b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
@@ -56,6 +56,7 @@ struct k1_pcie_device_data {
const struct dw_pcie_ops *ops;
int (*parse_port)(struct k1_pcie *k1);
unsigned int max_phy_count;
+ unsigned int device_id;
};
struct k1_pcie {
@@ -186,6 +187,16 @@ static void k1_pcie_disable_aspm_l1(struct k1_pcie *k1)
dw_pcie_dbi_ro_wr_dis(pci);
}
+static void k1_pcie_set_device_id(struct k1_pcie *k1)
+{
+ struct dw_pcie *pci = &k1->pci;
+
+ dw_pcie_dbi_ro_wr_en(pci);
+ dw_pcie_writew_dbi(pci, PCI_VENDOR_ID, PCI_VENDOR_ID_SPACEMIT);
+ dw_pcie_writew_dbi(pci, PCI_DEVICE_ID, k1->data->device_id);
+ dw_pcie_dbi_ro_wr_dis(pci);
+}
+
static int k1_pcie_init(struct dw_pcie_rp *pp)
{
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
@@ -201,10 +212,7 @@ static int k1_pcie_init(struct dw_pcie_rp *pp)
return ret;
/* Set the PCI vendor and device ID */
- dw_pcie_dbi_ro_wr_en(pci);
- dw_pcie_writew_dbi(pci, PCI_VENDOR_ID, PCI_VENDOR_ID_SPACEMIT);
- dw_pcie_writew_dbi(pci, PCI_DEVICE_ID, PCI_DEVICE_ID_SPACEMIT_K1);
- dw_pcie_dbi_ro_wr_dis(pci);
+ k1_pcie_set_device_id(k1);
/*
* Start by asserting fundamental reset (drive PERST# low). The
@@ -406,6 +414,7 @@ static const struct k1_pcie_device_data k1_pcie_device_data = {
.ops = &k1_pcie_ops,
.parse_port = k1_pcie_parse_port,
.max_phy_count = 1,
+ .device_id = PCI_DEVICE_ID_SPACEMIT_K1,
};
static const struct of_device_id k1_pcie_of_match_table[] = {
--
2.55.0
@@ -0,0 +1,44 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH v4 4/6] dt-bindings: PCI: snps,dw-pcie: Add msi-parent for
MSI handle check
From: Inochi Amaoto <inochiama@gmail.com>
Date: Thu, 09 Jul 2026 12:00:24 +0800
Message-Id: <20260709040027.958400-5-inochiama@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
The IMSIC device on RISC-V based system does not require ID
remapping for MSI. So this device only needs "msi-parent"
property for IMSIC-based SoC, and the "msi-map" is not a
necessary property.
Add new condition for MSI handling on IMSIC based SoC.
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
---
Documentation/devicetree/bindings/pci/snps,dw-pcie.yaml | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/pci/snps,dw-pcie.yaml b/Documentation/devicetree/bindings/pci/snps,dw-pcie.yaml
index b3216141881c..91bbbc8924f6 100644
--- a/Documentation/devicetree/bindings/pci/snps,dw-pcie.yaml
+++ b/Documentation/devicetree/bindings/pci/snps,dw-pcie.yaml
@@ -27,8 +27,11 @@ allOf:
- $ref: /schemas/pci/snps,dw-pcie-common.yaml#
- if:
not:
- required:
- - msi-map
+ anyOf:
+ - required:
+ - msi-map
+ - required:
+ - msi-parent
then:
properties:
interrupt-names:
--
2.55.0
Loaded 100 of 128 files, more files were not shown because too many files have changed in this diff. Show more