mirror of
https://github.com/NixOS/nixos-hardware.git
synced 2026-12-01 05:23:29 +01:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3f3e6aaaa |
No files matched your search
@@ -9,13 +9,13 @@ jobs:
|
|||||||
nixfmt:
|
nixfmt:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
- uses: cachix/install-nix-action@v31
|
- uses: cachix/install-nix-action@v31
|
||||||
- run: nix build .#checks.x86_64-linux.formatting
|
- run: nix build .#checks.x86_64-linux.formatting
|
||||||
tests:
|
tests:
|
||||||
needs: nixfmt
|
needs: nixfmt
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
- uses: cachix/install-nix-action@v31
|
- uses: cachix/install-nix-action@v31
|
||||||
- run: nix run .#run-tests
|
- run: nix run .#run-tests
|
||||||
@@ -8,7 +8,6 @@ pcengines/apu @yegortimoshenko
|
|||||||
pine64/rockpro64 @tomfitzhenry
|
pine64/rockpro64 @tomfitzhenry
|
||||||
pine64/star64 @fgaz
|
pine64/star64 @fgaz
|
||||||
purism/librem/13v3 @yegortimoshenko
|
purism/librem/13v3 @yegortimoshenko
|
||||||
raspberry-pi @doronbehar
|
|
||||||
system76/darp6 @khumba
|
system76/darp6 @khumba
|
||||||
framework @emiller88 @johnazoidberg
|
framework @emiller88 @johnazoidberg
|
||||||
tuxedo/pulse/15/gen2 @trueNAHO
|
tuxedo/pulse/15/gen2 @trueNAHO
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ See code for all available configurations.
|
|||||||
| Model | Path | Flake Module |
|
| Model | Path | Flake Module |
|
||||||
| --------------------------------------------------------------------------------- | ------------------------------------------------------- | -------------------------------------- |
|
| --------------------------------------------------------------------------------- | ------------------------------------------------------- | -------------------------------------- |
|
||||||
| [Acer Aspire 4810T](acer/aspire/4810t) | `<nixos-hardware/acer/aspire/4810t>` | `acer-aspire-4810t` |
|
| [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` |
|
| [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` |
|
| [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` |
|
| [Apple iMac 12,2](apple/imac/12-2) | `<nixos-hardware/apple/imac/12-2>` | `apple-imac-12-2` |
|
||||||
@@ -164,7 +163,6 @@ See code for all available configurations.
|
|||||||
| [Dell Inspiron 7559](dell/inspiron/7559) | `<nixos-hardware/dell/inspiron/7559>` | `dell-inspiron-7559` |
|
| [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 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 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 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 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` |
|
| [Dell Latitude 7280](dell/latitude/7280) | `<nixos-hardware/dell/latitude/7280>` | `dell-latitude-7280` |
|
||||||
@@ -184,7 +182,6 @@ See code for all available configurations.
|
|||||||
| [Dell Precision 5530](dell/precision/5530) | `<nixos-hardware/dell/precision/5530>` | `dell-precision-5530` |
|
| [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 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 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 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 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` |
|
| [Dell XPS 13 9300](dell/xps/13-9300) | `<nixos-hardware/dell/xps/13-9300>` | `dell-xps-13-9300` |
|
||||||
@@ -234,7 +231,6 @@ See code for all available configurations.
|
|||||||
| [Gigabyte B550](gigabyte/b550) | `<nixos-hardware/gigabyte/b550>` | `gigabyte-b550` |
|
| [Gigabyte B550](gigabyte/b550) | `<nixos-hardware/gigabyte/b550>` | `gigabyte-b550` |
|
||||||
| [Gigabyte B650](gigabyte/b650) | `<nixos-hardware/gigabyte/b650>` | `gigabyte-b650` |
|
| [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` |
|
| [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 MicroPC](gpd/micropc) | `<nixos-hardware/gpd/micropc>` | `gpd-micropc` |
|
||||||
| [GPD P2 Max](gpd/p2-max) | `<nixos-hardware/gpd/p2-max>` | `gpd-p2-max` |
|
| [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` |
|
| [GPD Pocket 3](gpd/pocket-3) | `<nixos-hardware/gpd/pocket-3>` | `gpd-pocket-3` |
|
||||||
@@ -309,8 +305,6 @@ 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 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 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 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 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 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` |
|
| [Lenovo ThinkPad P14s AMD Gen 3](lenovo/thinkpad/p14s/amd/gen3) | `<nixos-hardware/lenovo/thinkpad/p14s/amd/gen3>` | `lenovo-thinkpad-p14s-amd-gen3` |
|
||||||
@@ -366,7 +360,6 @@ 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](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 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](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 (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 (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` |
|
| [Lenovo ThinkPad X1 (7th Gen)](lenovo/thinkpad/x1/7th-gen) | `<nixos-hardware/lenovo/thinkpad/x1/7th-gen>` | `lenovo-thinkpad-x1-7th-gen` |
|
||||||
@@ -408,7 +401,6 @@ 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 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 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 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 GS60 2QE](msi/gs60) | `<nixos-hardware/msi/gs60>` | `msi-gs60` |
|
||||||
| [MSI GL62/CX62](msi/gl62) | `<nixos-hardware/msi/gl62>` | `msi-gl62` |
|
| [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` |
|
| [MSI GL65 10SDR-492](msi/gl65/10SDR-492) | `<nixos-hardware/msi/gl65/10SDR-492>` | `msi-gl65-10SDR-492` |
|
||||||
@@ -461,7 +453,6 @@ 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 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` |
|
| [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` |
|
| [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 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 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` |
|
| [Raspberry Pi 4](raspberry-pi/4) | `<nixos-hardware/raspberry-pi/4>` | `raspberry-pi-4` |
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
# 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.
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
{ 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";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
+34
-45
@@ -8,47 +8,34 @@
|
|||||||
let
|
let
|
||||||
inherit (lib) types;
|
inherit (lib) types;
|
||||||
|
|
||||||
t2bce-alsa-ucm = pkgs.stdenvNoCC.mkDerivation (_: {
|
audioFiles = pkgs.fetchFromGitHub {
|
||||||
name = "t2bce-alsa-ucm";
|
owner = "kekrby";
|
||||||
src = pkgs.fetchFromGitHub {
|
repo = "t2-better-audio";
|
||||||
owner = "deqrocks";
|
rev = "e46839a28963e2f7d364020518b9dac98236bcae";
|
||||||
repo = "t2bce";
|
hash = "sha256-x7K0qa++P1e1vuCGxnsFxL1d9+nwMtZUJ6Kd9e27TFs=";
|
||||||
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
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
patchedAudioAlsaEnv = lib.genAttrs [ "pipewire" "wireplumber" "pulseaudio" ] (_: {
|
audioFilesUdevRules = pkgs.runCommand "audio-files-udev-rules" { } ''
|
||||||
environment.ALSA_CONFIG_UCM2 = config.environment.variables.ALSA_CONFIG_UCM2;
|
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/";
|
||||||
|
|
||||||
t2Cfg = config.hardware.apple-t2;
|
t2Cfg = config.hardware.apple-t2;
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
@@ -98,7 +85,9 @@ in
|
|||||||
if t2Cfg.kernelChannel == "stable" then ./pkgs/linux-t2 else ./pkgs/linux-t2/latest.nix
|
if t2Cfg.kernelChannel == "stable" then ./pkgs/linux-t2 else ./pkgs/linux-t2/latest.nix
|
||||||
) { }
|
) { }
|
||||||
);
|
);
|
||||||
boot.initrd.kernelModules = [ "t2bce-vhci" ];
|
boot.initrd.kernelModules = [ "apple-bce" ];
|
||||||
|
|
||||||
|
services.udev.packages = [ audioFilesUdevRules ];
|
||||||
|
|
||||||
# For audio and suspend
|
# For audio and suspend
|
||||||
boot.kernelParams = [
|
boot.kernelParams = [
|
||||||
@@ -107,19 +96,19 @@ in
|
|||||||
"pm_async=off"
|
"pm_async=off"
|
||||||
];
|
];
|
||||||
|
|
||||||
# audio configuration
|
services.pipewire.package = pipewirePackage;
|
||||||
# https://github.com/nix-community/nixos-apple-silicon/blob/66d8dd2c27f99bd5420c99938b60695aac1785c4/apple-silicon-support/modules/sound/default.nix#L46
|
services.pipewire.wireplumber.package = pkgs.wireplumber.override {
|
||||||
environment.variables.ALSA_CONFIG_UCM2 = "${patched-alsa-ucm}/share/alsa/ucm2";
|
pipewire = pipewirePackage;
|
||||||
# setting systemd.globalEnvironment is likely going to have unexpected side effects
|
|
||||||
systemd = {
|
|
||||||
services = patchedAudioAlsaEnv;
|
|
||||||
user.services = patchedAudioAlsaEnv;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# Make sure post-resume.service exists
|
# Make sure post-resume.service exists
|
||||||
powerManagement.enable = true;
|
powerManagement.enable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
services.pulseaudio.package = overrideAudioFiles pkgs.pulseaudio "src/modules/";
|
||||||
|
}
|
||||||
|
|
||||||
(lib.mkIf t2Cfg.enableIGPU {
|
(lib.mkIf t2Cfg.enableIGPU {
|
||||||
# Enable the iGPU by default if present
|
# Enable the iGPU by default if present
|
||||||
environment.etc."modprobe.d/apple-gmux.conf".text = ''
|
environment.etc."modprobe.d/apple-gmux.conf".text = ''
|
||||||
|
|||||||
@@ -2,7 +2,10 @@
|
|||||||
lib,
|
lib,
|
||||||
stdenvNoCC,
|
stdenvNoCC,
|
||||||
callPackage,
|
callPackage,
|
||||||
_7zz,
|
vmTools,
|
||||||
|
util-linux,
|
||||||
|
linux,
|
||||||
|
kmod,
|
||||||
version,
|
version,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
@@ -35,44 +38,52 @@ let
|
|||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|
||||||
stdenvNoCC.mkDerivation {
|
vmTools.runInLinuxVM (
|
||||||
pname = "brcm-firmware";
|
stdenvNoCC.mkDerivation {
|
||||||
inherit version;
|
pname = "brcm-firmware";
|
||||||
|
inherit version;
|
||||||
|
|
||||||
src = fetchmacos {
|
src = fetchmacos {
|
||||||
name = version;
|
name = version;
|
||||||
inherit (boards.${version})
|
inherit (boards.${version})
|
||||||
boardId
|
boardId
|
||||||
mlb
|
mlb
|
||||||
osType
|
osType
|
||||||
hash
|
hash
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
dontUnpack = true;
|
dontUnpack = true;
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
_7zz
|
util-linux
|
||||||
get-firmware
|
get-firmware
|
||||||
];
|
];
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
7zz x -bd -bso0 -bsp0 $src \
|
ln -s ${linux}/lib /lib
|
||||||
"macOS Base System/usr/share/firmware/bluetooth/*" \
|
${kmod}/bin/modprobe loop
|
||||||
"macOS Base System/usr/share/firmware/wifi/*"
|
${kmod}/bin/modprobe hfsplus
|
||||||
|
|
||||||
get-bluetooth "macOS Base System/usr/share/firmware/bluetooth" bluetooth/
|
imgdir=$(mktemp -d)
|
||||||
get-wifi "macOS Base System/usr/share/firmware/wifi" wifi/
|
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
|
||||||
|
|
||||||
installPhase = ''
|
get-bluetooth $imgdir/usr/share/firmware/bluetooth bluetooth/
|
||||||
mkdir -p $out/lib/firmware/brcm
|
get-wifi $imgdir/usr/share/firmware/wifi wifi/
|
||||||
cp bluetooth/brcm/* $out/lib/firmware/brcm/
|
'';
|
||||||
cp wifi/brcm/* $out/lib/firmware/brcm/
|
|
||||||
'';
|
|
||||||
|
|
||||||
meta = with lib; {
|
installPhase = ''
|
||||||
description = "Wi-Fi and Bluetooth firmware for T2 Macs";
|
mkdir -p $out/lib/firmware/brcm
|
||||||
license = licenses.unfree;
|
cp bluetooth/brcm/* $out/lib/firmware/brcm/
|
||||||
maintainers = with maintainers; [ mkorje ];
|
cp wifi/brcm/* $out/lib/firmware/brcm/
|
||||||
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;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
{ callPackage, ... }@args:
|
{ callPackage, linux_6_18, ... }@args:
|
||||||
|
|
||||||
callPackage ./generic.nix args ./stable.json
|
callPackage ./generic.nix args {
|
||||||
|
kernel = linux_6_18;
|
||||||
|
patchesFile = ./stable.json;
|
||||||
|
}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
fetchurl, # fetchpatch does unnecessary normalization
|
fetchurl, # fetchpatch does unnecessary normalization
|
||||||
buildLinux,
|
|
||||||
linuxKernel,
|
|
||||||
...
|
...
|
||||||
}@args:
|
}@args:
|
||||||
|
|
||||||
patchesFile:
|
{
|
||||||
|
kernel,
|
||||||
|
patchesFile,
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
inherit (builtins) readFile fromJSON;
|
inherit (builtins) readFile fromJSON;
|
||||||
|
|
||||||
@@ -23,58 +23,33 @@ let
|
|||||||
}
|
}
|
||||||
) patchset.patches;
|
) patchset.patches;
|
||||||
in
|
in
|
||||||
buildLinux (
|
kernel.override (
|
||||||
{
|
args
|
||||||
|
// {
|
||||||
pname = "linux-t2";
|
pname = "linux-t2";
|
||||||
version = patchset.kernel.version;
|
|
||||||
|
|
||||||
src = fetchurl {
|
|
||||||
inherit (patchset.kernel) url hash;
|
|
||||||
};
|
|
||||||
|
|
||||||
structuredExtraConfig = with lib.kernel; {
|
structuredExtraConfig = with lib.kernel; {
|
||||||
T2BCE_CORE = module;
|
APPLE_BCE = module;
|
||||||
T2BCE_VHCI = module;
|
|
||||||
T2BCE_AUDIO = module;
|
|
||||||
T2BCE_AVE = module;
|
|
||||||
APPLE_GMUX = module;
|
APPLE_GMUX = module;
|
||||||
APFS_FS = module;
|
APFS_FS = module;
|
||||||
BRCMFMAC = module;
|
BRCMFMAC = module;
|
||||||
BT_BCM = module;
|
BT_BCM = module;
|
||||||
BT_HCIBCM4377 = module;
|
BT_HCIBCM4377 = module;
|
||||||
BT_HCIUART = module;
|
|
||||||
BT_HCIUART_BCM = yes;
|
BT_HCIUART_BCM = yes;
|
||||||
DRM_APPLETBDRM = module;
|
BT_HCIUART = module;
|
||||||
HID_APPLE = module;
|
|
||||||
HID_APPLETB_BL = module;
|
HID_APPLETB_BL = module;
|
||||||
HID_APPLETB_KBD = module;
|
HID_APPLETB_KBD = module;
|
||||||
|
HID_APPLE = module;
|
||||||
HID_MAGICMOUSE = module;
|
HID_MAGICMOUSE = module;
|
||||||
|
DRM_APPLETBDRM = module;
|
||||||
HID_SENSOR_ALS = module;
|
HID_SENSOR_ALS = module;
|
||||||
SENSORS_APPLESMC = module;
|
|
||||||
SND_PCM = module;
|
SND_PCM = module;
|
||||||
STAGING = yes;
|
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 = [
|
kernelPatches = t2-patches ++ (args.kernelPatches or [ ]);
|
||||||
# include default patches for good measure
|
|
||||||
linuxKernel.kernelPatches.request_key_helper
|
|
||||||
linuxKernel.kernelPatches.bridge_stp_helper
|
|
||||||
]
|
|
||||||
++ t2-patches
|
|
||||||
++ (args.kernelPatches or [ ]);
|
|
||||||
|
|
||||||
extraMeta = {
|
argsOverride.extraMeta = {
|
||||||
description = "The Linux kernel (with patches from the T2 Linux project)";
|
description = "The Linux kernel (with patches from the T2 Linux project)";
|
||||||
|
|
||||||
# take responsibility for the downstream kernel
|
# take responsibility for the downstream kernel
|
||||||
|
|||||||
@@ -1,30 +1,25 @@
|
|||||||
{
|
{
|
||||||
"base_url": "https://raw.githubusercontent.com/t2linux/linux-t2-patches/65fdd4d492d7e219a05742ce4768f16e5ba4f976/",
|
"base_url": "https://raw.githubusercontent.com/t2linux/linux-t2-patches/7ee7d19c38e5df31a386b2a0c35ca8f064003960/",
|
||||||
"kernel": {
|
|
||||||
"version": "7.2.9",
|
|
||||||
"url": "mirror://kernel/linux/kernel/v7.x/linux-7.2.9.tar.xz",
|
|
||||||
"hash": "sha256:1fnqp28vrikz9gqhb42k0dsggqf8i07j0s9qy33scr53a6zdzidl"
|
|
||||||
},
|
|
||||||
"patches": [
|
"patches": [
|
||||||
{
|
{
|
||||||
"name": "1001-Add-t2bce-driver-stack.patch",
|
"name": "1001-Add-apple-bce-driver.patch",
|
||||||
"hash": "sha256-QeAffMClzGsGdHC5Qce744X2WUcx6PI0CJ5BQ8txxQ8="
|
"hash": "sha256-v/P3Ws3x+OPnmX3vSFLxARON0HNjjDRe7QJ+KP9tVsc="
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "1002-Integrate-t2bce-driver-stack.patch",
|
"name": "1002-Put-apple-bce-in-drivers-staging.patch",
|
||||||
"hash": "sha256-nPAPGV9IROyxSQzSztwNS1fY0ziGQJ7evKBs1ZSHwiE="
|
"hash": "sha256-rK1lQ3fjHJH//50n37xgWrUs4CZ8lmFw0iDpbq5zoaY="
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "2008-i915-4-lane-quirk-for-mbp15-1.patch",
|
"name": "2008-i915-4-lane-quirk-for-mbp15-1.patch",
|
||||||
"hash": "sha256-gTYP7WHV/Qulobdi1nNdYsv1CWgkM8pGvsCFQ+rvhrw="
|
"hash": "sha256-S2osR1aSjqJiO7rNZP1sKt2+Uxyitwse/6BXMJvE9as="
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "2009-apple-gmux-allow-switching-to-igpu-at-probe.patch",
|
"name": "2009-apple-gmux-allow-switching-to-igpu-at-probe.patch",
|
||||||
"hash": "sha256-OczfcYSvkw2lBZQzZjCV4LHSe6CnaJ1J8GBkgEbiOXk="
|
"hash": "sha256-6i+fh/Ifle0di5/tMOdMm0NMkEmeUb17hYM/g2j2dfI="
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "3001-applesmc-convert-static-structures-to-drvdata.patch",
|
"name": "3001-applesmc-convert-static-structures-to-drvdata.patch",
|
||||||
"hash": "sha256-FVtOCXInI5OUqpTVDVsZ1taMwj3z+d3PeRgjnQQljG4="
|
"hash": "sha256-7KGC0pCos351wKNhwJI/Qoc7w+orOPpiTkdCN50G8nI="
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "3002-applesmc-make-io-port-base-addr-dynamic.patch",
|
"name": "3002-applesmc-make-io-port-base-addr-dynamic.patch",
|
||||||
@@ -60,55 +55,35 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "4001-asahi-trackpad.patch",
|
"name": "4001-asahi-trackpad.patch",
|
||||||
"hash": "sha256-RuYI0t+rMu29wSkVT4suYJgGzS1ZruN/HBZWkLivlDw="
|
"hash": "sha256-ANHSNoy5nK2b+rSAG0bJ8j6ZBmNqgeCddHXVS31KyDw="
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "4003-HID-apple-ignore-the-trackpad-on-T2-Macs.patch",
|
"name": "4003-HID-apple-ignore-the-trackpad-on-T2-Macs.patch",
|
||||||
"hash": "sha256-LLZzcysLTuQrSXWXbdq7AASxfMInQoqpWzRNZAKws9k="
|
"hash": "sha256-T2tYcFLeWUdx6QawANe3ZNVSRxmo1IdPiSpGLQk4IDY="
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "4004-HID-magicmouse-Add-support-for-trackpads-found-on-T2.patch",
|
"name": "4004-HID-magicmouse-Add-support-for-trackpads-found-on-T2.patch",
|
||||||
"hash": "sha256-kUnbtl/54cihscirl9kP0Gsot7bdP0rYKlj6gQ10hk0="
|
"hash": "sha256-ubchCEv1BZ7t/zkI9DpHA4gUln9cdu4yHzVJI2TNlS0="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "4005-HID-magicmouse-fix-regression-breaking-support-for-M.patch",
|
||||||
|
"hash": "sha256-oT+3AeETnKfzblxtcTD18c61BKoD9yAsga0AL3R8u7k="
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "5001-HID-appletb-kbd-add-option-to-switch-default-layer-o.patch",
|
"name": "5001-HID-appletb-kbd-add-option-to-switch-default-layer-o.patch",
|
||||||
"hash": "sha256-KV5DTjALzNugs92Jum6VUt0wgblK/6PG1KorovHcIX0="
|
"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",
|
"name": "7001-drm-i915-fbdev-Discard-BIOS-framebuffers-exceeding-h.patch",
|
||||||
"hash": "sha256-/EKN7JsAxcpAgfJFtPp2NLYaGqQ0kl8wjJEXifSzJpY="
|
"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",
|
"name": "8001-Add-APFS-driver.patch",
|
||||||
"hash": "sha256-DU/jX8wuM6Y/5iZztg05GjWlzVlo8DfVpCJ3BxFoTJo="
|
"hash": "sha256-EbIbfkncp5Jax2suny/jlFt+cD9MyYMV2rWFJIbgbg4="
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "8002-Necessary-modifications-to-build-APFS-with-the-kerne.patch",
|
"name": "8002-Necessary-modifications-to-build-APFS-with-the-kerne.patch",
|
||||||
"hash": "sha256-zCTetF2NPhMH2BknPumhPz2sf26X9Lcra7xCA3R2WMY="
|
"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="
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
{ callPackage, ... }@args:
|
{ callPackage, linux_7_0, ... }@args:
|
||||||
|
|
||||||
callPackage ./generic.nix args ./latest.json
|
callPackage ./generic.nix args {
|
||||||
|
kernel = linux_7_0;
|
||||||
|
patchesFile = ./latest.json;
|
||||||
|
}
|
||||||
@@ -1,26 +1,17 @@
|
|||||||
{
|
{
|
||||||
"base_url": "https://raw.githubusercontent.com/t2linux/linux-t2-patches/2eed0f6c812e8f36cb7a7f7bcde69f6f87074bdf/",
|
"base_url": "https://raw.githubusercontent.com/t2linux/linux-t2-patches/facf1c778667c3ef62104949ef64c75ce7e43b0a/",
|
||||||
"kernel": {
|
|
||||||
"version": "6.18.55",
|
|
||||||
"url": "mirror://kernel/linux/kernel/v6.x/linux-6.18.55.tar.xz",
|
|
||||||
"hash": "sha256:1yadaa2gz74nh3pawpwv6lamalnd7wpiv1xb88pw2rd1c606647l"
|
|
||||||
},
|
|
||||||
"patches": [
|
"patches": [
|
||||||
{
|
{
|
||||||
"name": "1001-Add-t2bce-driver-stack.patch",
|
"name": "1001-Add-apple-bce-driver.patch",
|
||||||
"hash": "sha256-OG4Y7cN75pHWF7huV+2Fqtq0ik2aITMWtF43mD+RFCU="
|
"hash": "sha256-rrL3oVkYeq5ZslnjCQw4hcEK6knsm6U/wp1XnJmQTSA="
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "1002-Integrate-t2bce-driver-stack.patch",
|
"name": "1002-Put-apple-bce-in-drivers-staging.patch",
|
||||||
"hash": "sha256-z3g3IOAL+Nze88oKDSYpLHVtFnhz2kP1Udap5J64WmM="
|
"hash": "sha256-deWROYcncl51sOmtvUHM61e5FM1beHbOJVp4iI31LHM="
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "1003-Fix-for-6.18.patch",
|
|
||||||
"hash": "sha256-ozJkJFm11oGDW1Gwrp4AR4Ifv9X8Yix6uF9ZBFJ76+M="
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "2008-i915-4-lane-quirk-for-mbp15-1.patch",
|
"name": "2008-i915-4-lane-quirk-for-mbp15-1.patch",
|
||||||
"hash": "sha256-gTYP7WHV/Qulobdi1nNdYsv1CWgkM8pGvsCFQ+rvhrw="
|
"hash": "sha256-S2osR1aSjqJiO7rNZP1sKt2+Uxyitwse/6BXMJvE9as="
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "2009-apple-gmux-allow-switching-to-igpu-at-probe.patch",
|
"name": "2009-apple-gmux-allow-switching-to-igpu-at-probe.patch",
|
||||||
@@ -28,7 +19,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "3001-applesmc-convert-static-structures-to-drvdata.patch",
|
"name": "3001-applesmc-convert-static-structures-to-drvdata.patch",
|
||||||
"hash": "sha256-c/d+c5eKzhbtfUKtLC7AB+6vMXge4ZzPJAUbNENWH7g="
|
"hash": "sha256-7KGC0pCos351wKNhwJI/Qoc7w+orOPpiTkdCN50G8nI="
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "3002-applesmc-make-io-port-base-addr-dynamic.patch",
|
"name": "3002-applesmc-make-io-port-base-addr-dynamic.patch",
|
||||||
@@ -64,35 +55,31 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "4001-asahi-trackpad.patch",
|
"name": "4001-asahi-trackpad.patch",
|
||||||
"hash": "sha256-2h3TdPsX9HBXx5jkZ2S2GJkjFcdL8vKD1G69iqd9IWg="
|
"hash": "sha256-+YXyIjtlVrLo8allTO3M1A+xold5FUXaZ8dwD2j5HDc="
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "4003-HID-apple-ignore-the-trackpad-on-T2-Macs.patch",
|
"name": "4003-HID-apple-ignore-the-trackpad-on-T2-Macs.patch",
|
||||||
"hash": "sha256-LLZzcysLTuQrSXWXbdq7AASxfMInQoqpWzRNZAKws9k="
|
"hash": "sha256-T2tYcFLeWUdx6QawANe3ZNVSRxmo1IdPiSpGLQk4IDY="
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "4004-HID-magicmouse-Add-support-for-trackpads-found-on-T2.patch",
|
"name": "4004-HID-magicmouse-Add-support-for-trackpads-found-on-T2.patch",
|
||||||
"hash": "sha256-kUnbtl/54cihscirl9kP0Gsot7bdP0rYKlj6gQ10hk0="
|
"hash": "sha256-ubchCEv1BZ7t/zkI9DpHA4gUln9cdu4yHzVJI2TNlS0="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "4005-HID-magicmouse-fix-regression-breaking-support-for-M.patch",
|
||||||
|
"hash": "sha256-oT+3AeETnKfzblxtcTD18c61BKoD9yAsga0AL3R8u7k="
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "5001-HID-appletb-kbd-add-option-to-switch-default-layer-o.patch",
|
"name": "5001-HID-appletb-kbd-add-option-to-switch-default-layer-o.patch",
|
||||||
"hash": "sha256-KV5DTjALzNugs92Jum6VUt0wgblK/6PG1KorovHcIX0="
|
"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",
|
"name": "7001-drm-i915-fbdev-Discard-BIOS-framebuffers-exceeding-h.patch",
|
||||||
"hash": "sha256-/EKN7JsAxcpAgfJFtPp2NLYaGqQ0kl8wjJEXifSzJpY="
|
"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",
|
"name": "8001-Add-APFS-driver.patch",
|
||||||
"hash": "sha256-fL9TftzTd5PurxIDrzaPsysGExrMySGOsm6H8NFd7JY="
|
"hash": "sha256-2By3Zlg/i5rUUJDlWc6JoiqapUnbVplk2lHzDhvAhzI="
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "8002-Necessary-modifications-to-build-APFS-with-the-kerne.patch",
|
"name": "8002-Necessary-modifications-to-build-APFS-with-the-kerne.patch",
|
||||||
|
|||||||
@@ -15,26 +15,21 @@ API_BASE = "https://api.github.com"
|
|||||||
PATCH_PATTERN = re.compile(r"^\d{4}-.*\.patch$")
|
PATCH_PATTERN = re.compile(r"^\d{4}-.*\.patch$")
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(
|
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("filename", help="the output filename")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--repository",
|
"--repository",
|
||||||
help="the source github repository (default: %(default)s)",
|
help="the source github repository",
|
||||||
default="t2linux/linux-t2-patches",
|
default="t2linux/linux-t2-patches",
|
||||||
nargs="?",
|
nargs="?",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
ref_group = parser.add_mutually_exclusive_group()
|
||||||
|
ref_group.add_argument(
|
||||||
"--reference", help="the git reference for the patches", default=None, nargs="?"
|
"--reference", help="the git reference for the patches", default=None, nargs="?"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
ref_group.add_argument(
|
||||||
"--branch", help="the kernel branch to fetch (default: latest, example: 6.18)", default=None, nargs="?"
|
"--branch", help="the git branch to fetch", default=None, nargs="?"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -67,27 +62,6 @@ def main():
|
|||||||
reference = args.reference
|
reference = args.reference
|
||||||
branch = args.branch
|
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 reference is None:
|
||||||
if branch is None:
|
if branch is None:
|
||||||
print("Branch and reference not provided, fetching default branch")
|
print("Branch and reference not provided, fetching default branch")
|
||||||
@@ -111,7 +85,7 @@ def main():
|
|||||||
for future in as_completed(futures):
|
for future in as_completed(futures):
|
||||||
patches_with_hash.append(future.result())
|
patches_with_hash.append(future.result())
|
||||||
|
|
||||||
result = {"base_url": base_url, "kernel": kernel, "patches": sorted(patches_with_hash, key=lambda p: p["name"])}
|
result = {"base_url": base_url, "patches": sorted(patches_with_hash, key=lambda p: p["name"])}
|
||||||
|
|
||||||
with open(args.filename, "w+") as f:
|
with open(args.filename, "w+") as f:
|
||||||
json.dump(result, f, indent=2)
|
json.dump(result, f, indent=2)
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
{ 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;
|
|
||||||
}
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
{
|
|
||||||
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"
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
{
|
|
||||||
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" ];
|
|
||||||
};
|
|
||||||
})
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
# 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" } }]
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
SectionDevice."Mic" {
|
|
||||||
Comment "Digital Microphone"
|
|
||||||
|
|
||||||
Value {
|
|
||||||
CapturePriority 100
|
|
||||||
CapturePCM "hw:${CardId},4"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,206 +0,0 @@
|
|||||||
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'"
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
# 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}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,6 +4,6 @@
|
|||||||
boot.kernelParams = [
|
boot.kernelParams = [
|
||||||
"i915.enable_dpcd_backlight=1"
|
"i915.enable_dpcd_backlight=1"
|
||||||
"nvidia.NVreg_EnableBacklightHandler=0"
|
"nvidia.NVreg_EnableBacklightHandler=0"
|
||||||
"nvidia.NVreg_RegistryDwords=EnableBrightnessControl=0"
|
"nvidia.NVReg_RegistryDwords=EnableBrightnessControl=0"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
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";
|
|
||||||
}
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
{
|
|
||||||
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
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
# 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}" ];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
{ lib, ... }:
|
{ lib, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [ ./dc-debug-mask.nix ];
|
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
services.xserver.videoDrivers = lib.mkDefault [ "modesetting" ];
|
services.xserver.videoDrivers = lib.mkDefault [ "modesetting" ];
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,5 @@
|
|||||||
{
|
{
|
||||||
imports = [ ../. ];
|
imports = [ ../. ];
|
||||||
|
|
||||||
services.tlp.enable = lib.mkDefault (
|
services.tlp.enable = lib.mkDefault (!config.services.power-profiles-daemon.enable);
|
||||||
!config.services.power-profiles-daemon.enable && !config.services.tuned.enable
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
# 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
|
|
||||||
```
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{ ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
../../../common/cpu/intel/alder-lake
|
|
||||||
../../../common/pc/laptop
|
|
||||||
../../../common/pc/ssd
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
{
|
|
||||||
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
@@ -2,11 +2,11 @@
|
|||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1789546076,
|
"lastModified": 1767892417,
|
||||||
"narHash": "sha256-vWkSk5bbfTqdtMoSgD9FshACO8JCvXTFi+3cqEp0mH0=",
|
"narHash": "sha256-8bW3q88CEg2u4hSP66Vf4lpbLonHz7hqDNBMcCY7E9U=",
|
||||||
"rev": "b1b875982b17dabde9b4a37f3e229e74913e6db3",
|
"rev": "3497aa5c9457a9d88d71fa93a4a8368816fbeeba",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://releases.nixos.org/nixos/unstable/nixos-26.11pre1074753.b1b875982b17/nixexprs.tar.xz"
|
"url": "https://releases.nixos.org/nixos/unstable/nixos-26.05pre924538.3497aa5c9457/nixexprs.tar.xz"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
|
|||||||
@@ -43,7 +43,6 @@
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
acer-aspire-4810t = import ./acer/aspire/4810t;
|
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;
|
acer-predator-helios-300-ph315-51 = import ./acer/predator/helios/300/ph315-51;
|
||||||
airis-n990 = import ./airis/n990;
|
airis-n990 = import ./airis/n990;
|
||||||
aoostar-r1-n100 = import ./aoostar/r1/n100;
|
aoostar-r1-n100 = import ./aoostar/r1/n100;
|
||||||
@@ -78,8 +77,6 @@
|
|||||||
asus-flow-gv302x-amdgpu = import ./asus/flow/gv302x/amdgpu;
|
asus-flow-gv302x-amdgpu = import ./asus/flow/gv302x/amdgpu;
|
||||||
asus-flow-gv302x-nvidia = import ./asus/flow/gv302x/nvidia;
|
asus-flow-gv302x-nvidia = import ./asus/flow/gv302x/nvidia;
|
||||||
asus-flow-gz301vu = import ./asus/flow/gz301vu;
|
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-pro-ws-x570-ace = import ./asus/pro-ws-x570-ace;
|
||||||
asus-rog-gl552vw = import ./asus/rog-gl552vw;
|
asus-rog-gl552vw = import ./asus/rog-gl552vw;
|
||||||
asus-rog-strix-g513im = import ./asus/rog-strix/g513im;
|
asus-rog-strix-g513im = import ./asus/rog-strix/g513im;
|
||||||
@@ -104,7 +101,6 @@
|
|||||||
asus-zephyrus-gu603h = import ./asus/zephyrus/gu603h;
|
asus-zephyrus-gu603h = import ./asus/zephyrus/gu603h;
|
||||||
asus-zephyrus-gu605cw = import ./asus/zephyrus/gu605cw;
|
asus-zephyrus-gu605cw = import ./asus/zephyrus/gu605cw;
|
||||||
asus-zephyrus-gu605my = import ./asus/zephyrus/gu605my;
|
asus-zephyrus-gu605my = import ./asus/zephyrus/gu605my;
|
||||||
bananapi-bpi-sm10 = import ./bananapi/bpi-sm10;
|
|
||||||
beagleboard-pocketbeagle = import ./beagleboard/pocketbeagle;
|
beagleboard-pocketbeagle = import ./beagleboard/pocketbeagle;
|
||||||
chuwi-minibook-x = import ./chuwi/minibook-x;
|
chuwi-minibook-x = import ./chuwi/minibook-x;
|
||||||
deciso-dec = import ./deciso/dec;
|
deciso-dec = import ./deciso/dec;
|
||||||
@@ -120,7 +116,6 @@
|
|||||||
dell-inspiron-7559 = import ./dell/inspiron/7559;
|
dell-inspiron-7559 = import ./dell/inspiron/7559;
|
||||||
dell-latitude-3340 = import ./dell/latitude/3340;
|
dell-latitude-3340 = import ./dell/latitude/3340;
|
||||||
dell-latitude-3480 = import ./dell/latitude/3480;
|
dell-latitude-3480 = import ./dell/latitude/3480;
|
||||||
dell-latitude-3530 = import ./dell/latitude/3530;
|
|
||||||
dell-latitude-5490 = import ./dell/latitude/5490;
|
dell-latitude-5490 = import ./dell/latitude/5490;
|
||||||
dell-latitude-5520 = import ./dell/latitude/5520;
|
dell-latitude-5520 = import ./dell/latitude/5520;
|
||||||
dell-latitude-7280 = import ./dell/latitude/7280;
|
dell-latitude-7280 = import ./dell/latitude/7280;
|
||||||
@@ -141,7 +136,6 @@
|
|||||||
dell-precision-5530 = import ./dell/precision/5530;
|
dell-precision-5530 = import ./dell/precision/5530;
|
||||||
dell-precision-5560 = import ./dell/precision/5560;
|
dell-precision-5560 = import ./dell/precision/5560;
|
||||||
dell-precision-5570 = import ./dell/precision/5570;
|
dell-precision-5570 = import ./dell/precision/5570;
|
||||||
dell-precision-5820 = import ./dell/precision/5820;
|
|
||||||
dell-precision-7520 = import ./dell/precision/7520;
|
dell-precision-7520 = import ./dell/precision/7520;
|
||||||
dell-xps-13-7390 = import ./dell/xps/13-7390;
|
dell-xps-13-7390 = import ./dell/xps/13-7390;
|
||||||
dell-xps-13-9300 = import ./dell/xps/13-9300;
|
dell-xps-13-9300 = import ./dell/xps/13-9300;
|
||||||
@@ -197,7 +191,6 @@
|
|||||||
google-pixelbook = import ./google/pixelbook;
|
google-pixelbook = import ./google/pixelbook;
|
||||||
google-brya = import ./google/brya;
|
google-brya = import ./google/brya;
|
||||||
google-rex = import ./google/rex;
|
google-rex = import ./google/rex;
|
||||||
gpd-duo = import ./gpd/duo;
|
|
||||||
gpd-micropc = import ./gpd/micropc;
|
gpd-micropc = import ./gpd/micropc;
|
||||||
gpd-p2-max = import ./gpd/p2-max;
|
gpd-p2-max = import ./gpd/p2-max;
|
||||||
gpd-pocket-3 = import ./gpd/pocket-3;
|
gpd-pocket-3 = import ./gpd/pocket-3;
|
||||||
@@ -269,8 +262,6 @@
|
|||||||
lenovo-thinkpad-l480 = import ./lenovo/thinkpad/l480;
|
lenovo-thinkpad-l480 = import ./lenovo/thinkpad/l480;
|
||||||
lenovo-thinkpad-p1 = import ./lenovo/thinkpad/p1;
|
lenovo-thinkpad-p1 = import ./lenovo/thinkpad/p1;
|
||||||
lenovo-thinkpad-p1-gen3 = import ./lenovo/thinkpad/p1/3th-gen;
|
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-gen1 = import ./lenovo/thinkpad/p14s/amd/gen1;
|
||||||
lenovo-thinkpad-p14s-amd-gen2 = import ./lenovo/thinkpad/p14s/amd/gen2;
|
lenovo-thinkpad-p14s-amd-gen2 = import ./lenovo/thinkpad/p14s/amd/gen2;
|
||||||
lenovo-thinkpad-p14s-amd-gen3 = import ./lenovo/thinkpad/p14s/amd/gen3;
|
lenovo-thinkpad-p14s-amd-gen3 = import ./lenovo/thinkpad/p14s/amd/gen3;
|
||||||
@@ -326,7 +317,6 @@
|
|||||||
lenovo-thinkpad-x1-yoga = import ./lenovo/thinkpad/x1/yoga;
|
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-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 = 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-2nd-gen = import ./lenovo/thinkpad/x1/2nd-gen;
|
||||||
lenovo-thinkpad-x1-6th-gen = import ./lenovo/thinkpad/x1/6th-gen;
|
lenovo-thinkpad-x1-6th-gen = import ./lenovo/thinkpad/x1/6th-gen;
|
||||||
lenovo-thinkpad-x1-7th-gen = import ./lenovo/thinkpad/x1/7th-gen;
|
lenovo-thinkpad-x1-7th-gen = import ./lenovo/thinkpad/x1/7th-gen;
|
||||||
@@ -388,7 +378,6 @@
|
|||||||
msi-b350-tomahawk = import ./msi/b350-tomahawk;
|
msi-b350-tomahawk = import ./msi/b350-tomahawk;
|
||||||
msi-b550-a-pro = import ./msi/b550-a-pro;
|
msi-b550-a-pro = import ./msi/b550-a-pro;
|
||||||
msi-b550-tomahawk = import ./msi/b550-tomahawk;
|
msi-b550-tomahawk = import ./msi/b550-tomahawk;
|
||||||
msi-gf63 = import ./msi/gf63;
|
|
||||||
msi-gs60 = import ./msi/gs60;
|
msi-gs60 = import ./msi/gs60;
|
||||||
msi-gl62 = import ./msi/gl62;
|
msi-gl62 = import ./msi/gl62;
|
||||||
msi-gl65-10SDR-492 = import ./msi/gl65/10SDR-492;
|
msi-gl65-10SDR-492 = import ./msi/gl65/10SDR-492;
|
||||||
@@ -421,7 +410,6 @@
|
|||||||
purism-librem-15v3 = import ./purism/librem/15v3;
|
purism-librem-15v3 = import ./purism/librem/15v3;
|
||||||
purism-librem-5r4 = import ./purism/librem/5r4;
|
purism-librem-5r4 = import ./purism/librem/5r4;
|
||||||
razer-blade-14-RZ09-0530 = import ./razer/blade/14/RZ09-0530;
|
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-2 = import ./raspberry-pi/2;
|
||||||
raspberry-pi-3 = import ./raspberry-pi/3;
|
raspberry-pi-3 = import ./raspberry-pi/3;
|
||||||
raspberry-pi-4 = import ./raspberry-pi/4;
|
raspberry-pi-4 = import ./raspberry-pi/4;
|
||||||
@@ -434,7 +422,6 @@
|
|||||||
kobol-helios4 = import ./kobol/helios4;
|
kobol-helios4 = import ./kobol/helios4;
|
||||||
samsung-np900x3c = import ./samsung/np900x3c;
|
samsung-np900x3c = import ./samsung/np900x3c;
|
||||||
slimbook-hero-rpl-rtx = import ./slimbook/hero/rpl-rtx;
|
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-v1 = import ./starfive/visionfive/v1;
|
||||||
starfive-visionfive-2 = import ./starfive/visionfive/v2;
|
starfive-visionfive-2 = import ./starfive/visionfive/v2;
|
||||||
starlabs-starlite-i5 = import ./starlabs/starlite/i5;
|
starlabs-starlite-i5 = import ./starlabs/starlite/i5;
|
||||||
@@ -561,9 +548,6 @@
|
|||||||
pkgs.lib.optionalAttrs (self.formatter ? ${system}) {
|
pkgs.lib.optionalAttrs (self.formatter ? ${system}) {
|
||||||
formatting = treefmtEval.config.build.check self;
|
formatting = treefmtEval.config.build.check self;
|
||||||
}
|
}
|
||||||
// {
|
|
||||||
raspberry-pi-config-txt = pkgs.callPackage ./tests/config-txt-tests.nix { };
|
|
||||||
}
|
|
||||||
// nixosTests
|
// nixosTests
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,18 +6,18 @@
|
|||||||
../../../common/gpu/amd
|
../../../common/gpu/amd
|
||||||
];
|
];
|
||||||
|
|
||||||
# There seems to be an issue with panel self-refresh (PSR) that
|
boot.kernelParams = [
|
||||||
# causes hangs for users.
|
# 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
|
# https://community.frame.work/t/fedora-kde-becomes-suddenly-slow/58459
|
||||||
hardware.amdgpu.dcDebugMask.disablePsr = lib.mkDefault true;
|
# https://gitlab.freedesktop.org/drm/amd/-/issues/3647
|
||||||
|
"amdgpu.dcdebugmask=0x10"
|
||||||
boot.kernelParams =
|
]
|
||||||
# Workaround for SuspendThenHibernate: https://lore.kernel.org/linux-kernel/20231106162310.85711-1-mario.limonciello@amd.com/
|
# 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") [
|
++ lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") [
|
||||||
"rtc_cmos.use_acpi_alarm=1"
|
"rtc_cmos.use_acpi_alarm=1"
|
||||||
];
|
];
|
||||||
|
|
||||||
# AMD has better battery life with PPD over TLP:
|
# AMD has better battery life with PPD over TLP:
|
||||||
# https://community.frame.work/t/responded-amd-7040-sleep-states/38101/13
|
# https://community.frame.work/t/responded-amd-7040-sleep-states/38101/13
|
||||||
|
|||||||
@@ -315,11 +315,12 @@ in
|
|||||||
"device.api" = "dsp";
|
"device.api" = "dsp";
|
||||||
"node.virtual" = "false";
|
"node.virtual" = "false";
|
||||||
|
|
||||||
# 1009 is the default priority of the "first" analog audio device.
|
# Lower seems to mean "more preferred",
|
||||||
# Higher priorities (e.g., 1010 for bluetooth and 1100 for usb audio)
|
# bluetooth devices seem to be ~1000, speakers seem to be ~2000
|
||||||
# are preferred.
|
# since this is between the two, bluetooth devices take over when they connect,
|
||||||
"priority.session" = 1009;
|
# and hand over to this instead of the speakers when they disconnect.
|
||||||
"priority.driver" = 1009;
|
"priority.session" = 1500;
|
||||||
|
"priority.driver" = 1500;
|
||||||
"state.default-volume" = 0.343;
|
"state.default-volume" = 0.343;
|
||||||
"device.icon-name" = "audio-card-analog-pci";
|
"device.icon-name" = "audio-card-analog-pci";
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,9 +21,8 @@
|
|||||||
|
|
||||||
# The following mitigations fix various graphics issues
|
# 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
|
# 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 = [
|
boot.kernelParams = [
|
||||||
|
"amdgpu.dcdebugmask=0x410"
|
||||||
"amdgpu.sg_display=0"
|
"amdgpu.sg_display=0"
|
||||||
"amdgpu.abmlevel=0"
|
"amdgpu.abmlevel=0"
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -6,18 +6,18 @@
|
|||||||
../../../common/gpu/amd
|
../../../common/gpu/amd
|
||||||
];
|
];
|
||||||
|
|
||||||
# There seems to be an issue with panel self-refresh (PSR) that
|
boot.kernelParams = [
|
||||||
# causes hangs for users.
|
# 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
|
# https://community.frame.work/t/fedora-kde-becomes-suddenly-slow/58459
|
||||||
hardware.amdgpu.dcDebugMask.disablePsr = lib.mkDefault true;
|
# https://gitlab.freedesktop.org/drm/amd/-/issues/3647
|
||||||
|
"amdgpu.dcdebugmask=0x10"
|
||||||
boot.kernelParams =
|
]
|
||||||
# Workaround for SuspendThenHibernate: https://lore.kernel.org/linux-kernel/20231106162310.85711-1-mario.limonciello@amd.com/
|
# 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") [
|
++ lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") [
|
||||||
"rtc_cmos.use_acpi_alarm=1"
|
"rtc_cmos.use_acpi_alarm=1"
|
||||||
];
|
];
|
||||||
|
|
||||||
# AMD has better battery life with PPD over TLP:
|
# AMD has better battery life with PPD over TLP:
|
||||||
# https://community.frame.work/t/responded-amd-7040-sleep-states/38101/13
|
# https://community.frame.work/t/responded-amd-7040-sleep-states/38101/13
|
||||||
|
|||||||
@@ -28,6 +28,22 @@
|
|||||||
# Enable keyboard customization
|
# Enable keyboard customization
|
||||||
hardware.keyboard.qmk.enable = lib.mkDefault true;
|
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
|
# Everything is updateable through fwupd
|
||||||
services.fwupd.enable = true;
|
services.fwupd.enable = true;
|
||||||
}
|
}
|
||||||
@@ -14,8 +14,5 @@ linuxPackagesFor (linuxManualConfig rec {
|
|||||||
};
|
};
|
||||||
configfile = ./config;
|
configfile = ./config;
|
||||||
config = import ./config.nix;
|
config = import ./config.nix;
|
||||||
features = {
|
features.netfilterRPFilter = true;
|
||||||
efiBootStub = true;
|
|
||||||
netfilterRPFilter = true;
|
|
||||||
};
|
|
||||||
})
|
})
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
{
|
|
||||||
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";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
{ 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;
|
|
||||||
}
|
|
||||||
@@ -1,391 +0,0 @@
|
|||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
# 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"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
{ 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;
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
imports = [
|
|
||||||
../../../ppt.nix
|
|
||||||
./power-saving.nix
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
{ 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;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,6 @@ in
|
|||||||
../../common/cpu/amd/pstate.nix
|
../../common/cpu/amd/pstate.nix
|
||||||
../../common/gpu/amd
|
../../common/gpu/amd
|
||||||
../../common/hidpi.nix
|
../../common/hidpi.nix
|
||||||
../ppt.nix
|
|
||||||
];
|
];
|
||||||
|
|
||||||
boot = {
|
boot = {
|
||||||
|
|||||||
-66
@@ -1,66 +0,0 @@
|
|||||||
{
|
|
||||||
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}"
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,72 @@
|
|||||||
{ ... }: {
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
cfg = config.hardware.gpd.ppt;
|
||||||
|
in
|
||||||
|
{
|
||||||
imports = [
|
imports = [
|
||||||
../../common/pc/laptop
|
../../common/pc/laptop
|
||||||
../../common/pc/ssd
|
../../common/pc/ssd
|
||||||
../../common/hidpi.nix
|
../../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}"
|
||||||
|
'';
|
||||||
|
};
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,6 @@ with lib;
|
|||||||
../../../common/cpu/amd
|
../../../common/cpu/amd
|
||||||
../../../common/cpu/amd/pstate.nix
|
../../../common/cpu/amd/pstate.nix
|
||||||
../../../common/gpu/amd
|
../../../common/gpu/amd
|
||||||
../../ppt.nix
|
|
||||||
];
|
];
|
||||||
|
|
||||||
hardware.bluetooth.enable = lib.mkDefault true;
|
hardware.bluetooth.enable = lib.mkDefault true;
|
||||||
|
|||||||
@@ -2,9 +2,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
../../../common/cpu/intel/coffee-lake
|
../../../common/cpu/intel
|
||||||
../../../common/pc
|
|
||||||
../../../common/pc/ssd
|
|
||||||
];
|
];
|
||||||
|
|
||||||
services.thermald.enable = lib.mkDefault true;
|
services.thermald.enable = lib.mkDefault true;
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
../../../common/cpu/intel
|
../../../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
|
../../../common/pc/ssd
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
# 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`
|
|
||||||
```
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
{ ... }:
|
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
../.
|
|
||||||
../../../../common/cpu/intel/alder-lake # P1 Gen 5 is 12th-gen Alder Lake
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
{ 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";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
../../../../../common/cpu/amd/pstate.nix
|
../../../../../common/cpu/amd/pstate.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
# Prevent the integrated RGB camera from dying during suspend.
|
# Embedded controller wake-ups drain battery in s2idle on this device
|
||||||
# This issue was observed on Linux 6.18.38.
|
# See https://lore.kernel.org/all/ZnFYpWHJ5Ml724Nv@ohnotp/
|
||||||
boot.kernelParams = [ "usbcore.quirks=30c9:00f4:b" ];
|
boot.kernelParams = [ "acpi.ec_no_wakeup=1" ];
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,6 @@ with lib;
|
|||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
../.
|
../.
|
||||||
../../../../common/cpu/intel/coffee-lake
|
|
||||||
];
|
];
|
||||||
|
|
||||||
# Fixes an issue with incorrect battery reporting. See
|
# Fixes an issue with incorrect battery reporting. See
|
||||||
@@ -16,9 +15,6 @@ with lib;
|
|||||||
# See also https://certification.ubuntu.com/catalog/component/input/5313/input%3ATPPS/2ElanTrackPoint/
|
# See also https://certification.ubuntu.com/catalog/component/input/5313/input%3ATPPS/2ElanTrackPoint/
|
||||||
hardware.trackpoint.device = "TPPS/2 Elan TrackPoint";
|
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.
|
# Since the HDMI port is connected to the NVIDIA card.
|
||||||
hardware.bumblebee.connectDisplay = true;
|
hardware.bumblebee.connectDisplay = true;
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
# 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.
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{ lib, ... }:
|
|
||||||
{
|
|
||||||
imports = [ ../. ];
|
|
||||||
|
|
||||||
hardware.ipu6 = {
|
|
||||||
enable = lib.mkDefault true;
|
|
||||||
platform = lib.mkDefault "ipu6ep";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -20,18 +20,14 @@ let
|
|||||||
supportedKernels =
|
supportedKernels =
|
||||||
let
|
let
|
||||||
lts-kernel = {
|
lts-kernel = {
|
||||||
version = "6.18.60";
|
version = "6.19.8";
|
||||||
hash = "sha256-PC9E72rMAhp61ETZoubsHvSI/wk2h5PQAEpggPadYh4=";
|
hash = "sha256-qtpHItuLz6C5cyhRhW1AUIK2pPouOrBnvo2xfN0RWzg=";
|
||||||
};
|
|
||||||
stable-kernel = {
|
|
||||||
version = "7.3.1";
|
|
||||||
hash = "sha256-+llarZNzT4KcljwqkO98NnMiT9f9rntJQG45fN4t4jE=";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
"longterm" = lts-kernel;
|
"longterm" = lts-kernel;
|
||||||
"stable" = stable-kernel;
|
"stable" = lts-kernel;
|
||||||
};
|
};
|
||||||
|
|
||||||
# Set the version and hash for the kernel sources
|
# Set the version and hash for the kernel sources
|
||||||
@@ -42,8 +38,8 @@ let
|
|||||||
linux-surface = pkgs.fetchFromGitHub {
|
linux-surface = pkgs.fetchFromGitHub {
|
||||||
owner = "linux-surface";
|
owner = "linux-surface";
|
||||||
repo = "linux-surface";
|
repo = "linux-surface";
|
||||||
rev = "668a0208b4a713641f7f04a73631008b1f522257";
|
rev = "bf1921fc63f33d03a007fb38c4f88ff7e7bc1a55";
|
||||||
hash = "sha256-RnlQMpIPTE+QbFlMMwq5Qj95tlVkyRkR8WqaPlivMXM=";
|
hash = "sha256-AV+J1iKpA4PEsX9oVUTGlzGerTWTermia3aJSZxuu/w=";
|
||||||
};
|
};
|
||||||
|
|
||||||
# Fetch and build the kernel
|
# Fetch and build the kernel
|
||||||
|
|||||||
@@ -162,4 +162,8 @@
|
|||||||
name = "ms-surface/0016-hid-surface";
|
name = "ms-surface/0016-hid-surface";
|
||||||
patch = patchSrc + "/0016-hid-surface.patch";
|
patch = patchSrc + "/0016-hid-surface.patch";
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
name = "ms-surface/0017-powercap";
|
||||||
|
patch = patchSrc + "/0017-powercap.patch";
|
||||||
|
}
|
||||||
]
|
]
|
||||||
@@ -1,155 +0,0 @@
|
|||||||
{
|
|
||||||
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";
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
runCommand,
|
|
||||||
lib,
|
lib,
|
||||||
fetchFromGitLab,
|
fetchFromGitLab,
|
||||||
}:
|
}:
|
||||||
@@ -8,8 +7,6 @@ let
|
|||||||
sources = lib.importJSON ./sources.json;
|
sources = lib.importJSON ./sources.json;
|
||||||
reformDebianPackages = fetchFromGitLab sources.reformDebianPackages;
|
reformDebianPackages = fetchFromGitLab sources.reformDebianPackages;
|
||||||
in
|
in
|
||||||
runCommand "mnt-reform-kernel-patches" { } ''
|
map (lib.removePrefix "${reformDebianPackages}/") (
|
||||||
shopt -s globstar
|
lib.filesystem.listFilesRecursive "${reformDebianPackages}/linux/patches${lib.versions.majorMinor sources.modDirVersion}"
|
||||||
cd ${reformDebianPackages}
|
)
|
||||||
echo -e "[\n$(printf ' "%s"\n' linux/patches${lib.versions.majorMinor sources.modDirVersion}/**/*.patch)\n]"> $out
|
|
||||||
''
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
nix build .#mnt-reform-kernel-patches
|
nix eval .#mnt-reform-kernel-patches > kernelPatches.nix
|
||||||
cp result kernelPatches.nix
|
nix fmt kernelPatches.nix
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
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).
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
{ 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";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
{ 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;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{ modulesPath, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
"${modulesPath}/profiles/installation-device.nix"
|
|
||||||
./sd-image.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
# The installation media is also the installation target.
|
|
||||||
installer.cloneConfig = false;
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
# 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
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
** 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).
|
||||||
@@ -35,5 +35,4 @@
|
|||||||
"console=tty0"
|
"console=tty0"
|
||||||
];
|
];
|
||||||
|
|
||||||
hardware.firmware = [ (pkgs.callPackage ../common/raspberry-pi-wireless-firmware.nix { }) ];
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,50 @@
|
|||||||
{ lib, ... }:
|
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
config,
|
||||||
../common
|
lib,
|
||||||
(lib.mkRenamedOptionModule
|
pkgs,
|
||||||
[ "hardware" "raspberry-pi" "4" "audio" "enable" ]
|
...
|
||||||
[ "hardware" "raspberry-pi" "audio" "enable" ]
|
}:
|
||||||
)
|
|
||||||
];
|
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
|
||||||
|
''
|
||||||
|
);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
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>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
./audio.nix
|
./audio.nix
|
||||||
./backlight.nix
|
./backlight.nix
|
||||||
./bluetooth.nix
|
./bluetooth.nix
|
||||||
|
./cpu-revision.nix
|
||||||
./digi-amp-plus.nix
|
./digi-amp-plus.nix
|
||||||
./dwc2.nix
|
./dwc2.nix
|
||||||
./gpio.nix
|
./gpio.nix
|
||||||
|
|||||||
@@ -1,42 +1,91 @@
|
|||||||
{ lib, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.hardware.raspberry-pi."4".digi-amp-plus;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
options.hardware = {
|
||||||
(lib.mkRemovedOptionModule
|
raspberry-pi."4".digi-amp-plus = {
|
||||||
[
|
enable = lib.mkEnableOption "support for the IQaudIO DigiAMP+ Hat";
|
||||||
"hardware"
|
|
||||||
"raspberry-pi"
|
|
||||||
"4"
|
|
||||||
"digi-amp-plus"
|
|
||||||
]
|
|
||||||
''
|
|
||||||
Use the stock iqaudio-dacplus firmware overlay instead:
|
|
||||||
|
|
||||||
{
|
unmuteAmp = lib.mkOption {
|
||||||
boot.loader.generic-extlinux-compatible.useGenerationDeviceTree =
|
type = lib.types.bool;
|
||||||
false;
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Whether to "one-shot" unmute when kernel module first loads.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
hardware.raspberry-pi.configtxt.deviceTreeOverlays.pi4 = [
|
autoMuteAmp = lib.mkOption {
|
||||||
{
|
type = lib.types.bool;
|
||||||
iqaudio-dacplus = {
|
default = true;
|
||||||
auto_mute_amp = true;
|
description = ''
|
||||||
unmute_amp = false;
|
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";
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
Keep the old boolean values. Map autoMuteAmp to auto_mute_amp and
|
fragment@1 {
|
||||||
unmuteAmp to unmute_amp.
|
target = <&i2c1>;
|
||||||
|
__overlay__ {
|
||||||
|
#address-cells = <1>;
|
||||||
|
#size-cells = <0>;
|
||||||
|
status = "okay";
|
||||||
|
|
||||||
On a running system, set hardware.raspberry-pi.firmware.enable to true.
|
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";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
For NixOS-Hardware specific firmware setup, read:
|
fragment@2 {
|
||||||
raspberry-pi/README.md.
|
target = <&sound>;
|
||||||
|
iqaudio_dac: __overlay__ {
|
||||||
For digiamp specific details, see:
|
compatible = "iqaudio,iqaudio-dac";
|
||||||
https://www.raspberrypi.com/documentation/accessories/audio.html#raspberry-pi-digiamp
|
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;"}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
+78
-26
@@ -1,34 +1,86 @@
|
|||||||
{ lib, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.hardware.raspberry-pi."4".dwc2;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
options.hardware = {
|
||||||
(lib.mkRemovedOptionModule
|
raspberry-pi."4".dwc2 = {
|
||||||
[
|
enable = lib.mkOption {
|
||||||
"hardware"
|
type = lib.types.bool;
|
||||||
"raspberry-pi"
|
default = false;
|
||||||
"4"
|
example = true;
|
||||||
"dwc2"
|
description = ''
|
||||||
]
|
Enable the UDC controller to support USB OTG gadget functions.
|
||||||
''
|
|
||||||
Use the stock dwc2 firmware overlay instead:
|
|
||||||
|
|
||||||
{
|
In order to verify that this works, connect the Raspberry Pi with
|
||||||
boot.loader.generic-extlinux-compatible.useGenerationDeviceTree =
|
another computer via the USB C cable, and then do one of:
|
||||||
false;
|
|
||||||
|
|
||||||
hardware.raspberry-pi.configtxt.deviceTreeOverlays.pi4 = [
|
- `modprobe g_serial`
|
||||||
{ dwc2 = { }; }
|
- `modprobe g_mass_storage file=/path/to/some/iso-file.iso`
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
If you set dr_mode on the old option, add it to the overlay. For
|
On the Raspberry Pi, `dmesg` should then show success-indicating output
|
||||||
example:
|
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.
|
||||||
|
|
||||||
{ dwc2.dr_mode = "host"; }
|
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.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
For CM4 and firmware-partition setup, see "DWC2 USB controller" in
|
config = lib.mkIf cfg.enable {
|
||||||
raspberry-pi/README.md.
|
# 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>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
+226
-29
@@ -1,35 +1,232 @@
|
|||||||
{ lib, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.hardware.raspberry-pi."4".poe-hat;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
options.hardware = {
|
||||||
(lib.mkRemovedOptionModule
|
raspberry-pi."4".poe-hat = {
|
||||||
[
|
enable = lib.mkEnableOption "support for the Raspberry Pi POE Hat";
|
||||||
"hardware"
|
fan = lib.mkOption {
|
||||||
"raspberry-pi"
|
type = lib.types.submodule {
|
||||||
"4"
|
options = {
|
||||||
"poe-hat"
|
temperature0 = lib.mkOption {
|
||||||
]
|
type = lib.types.int;
|
||||||
''
|
default = 40000;
|
||||||
Use the stock rpi-poe firmware overlay instead:
|
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.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
hardware.raspberry-pi.configtxt.deviceTreeOverlays."board-type=0x11" = [
|
default = { };
|
||||||
{
|
description = "Fan configuration.";
|
||||||
rpi-poe = {
|
};
|
||||||
poe_fan_temp0 = 40000;
|
};
|
||||||
poe_fan_temp0_hyst = 2000;
|
};
|
||||||
poe_fan_temp1 = 45000;
|
|
||||||
poe_fan_temp1_hyst = 2000;
|
config = lib.mkIf cfg.enable {
|
||||||
poe_fan_temp2 = 50000;
|
hardware.raspberry-pi."4".apply-overlays-dtmerge.enable = lib.mkDefault true;
|
||||||
poe_fan_temp2_hyst = 2000;
|
# doesn't work for the CM module, so we exclude e.g. bcm2711-rpi-cm4.dts
|
||||||
poe_fan_temp3 = 55000;
|
hardware.deviceTree.filter = "bcm2711-rpi-4*.dtb";
|
||||||
poe_fan_temp3_hyst = 5000;
|
|
||||||
|
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>;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
These are the overlay defaults. Parameters that were not customized can
|
fragment@1 {
|
||||||
be omitted.
|
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>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
+276
-29
@@ -1,35 +1,282 @@
|
|||||||
{ lib, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.hardware.raspberry-pi."4".poe-plus-hat;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
options.hardware = {
|
||||||
(lib.mkRemovedOptionModule
|
raspberry-pi."4".poe-plus-hat = {
|
||||||
[
|
enable = lib.mkEnableOption "support for the Raspberry Pi PoE+ HAT";
|
||||||
"hardware"
|
fan = lib.mkOption {
|
||||||
"raspberry-pi"
|
type = lib.types.submodule {
|
||||||
"4"
|
options = {
|
||||||
"poe-plus-hat"
|
temperature0 = lib.mkOption {
|
||||||
]
|
type = lib.types.int;
|
||||||
''
|
default = 40000;
|
||||||
Use the stock rpi-poe-plus firmware overlay instead:
|
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.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
hardware.raspberry-pi.configtxt.deviceTreeOverlays."board-type=0x11" = [
|
default = { };
|
||||||
{
|
description = "Fan configuration.";
|
||||||
rpi-poe-plus = {
|
};
|
||||||
poe_fan_temp0 = 40000;
|
};
|
||||||
poe_fan_temp0_hyst = 2000;
|
};
|
||||||
poe_fan_temp1 = 45000;
|
|
||||||
poe_fan_temp1_hyst = 2000;
|
config = lib.mkIf cfg.enable {
|
||||||
poe_fan_temp2 = 50000;
|
hardware.raspberry-pi."4".apply-overlays-dtmerge.enable = lib.mkDefault true;
|
||||||
poe_fan_temp2_hyst = 2000;
|
# doesn't work for the CM module, so we exclude e.g. bcm2711-rpi-cm4.dts
|
||||||
poe_fan_temp3 = 55000;
|
hardware.deviceTree.filter = "bcm2711-rpi-4*.dtb";
|
||||||
poe_fan_temp3_hyst = 5000;
|
|
||||||
|
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>;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
These are the overlay defaults. Parameters that were not customized can
|
fragment@1 {
|
||||||
be omitted.
|
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>;
|
||||||
|
};
|
||||||
|
|
||||||
|
¶ms {
|
||||||
|
poe_fan_i2c = <&fwpwm>,"status=disabled",
|
||||||
|
<&rpi_poe_power_supply>,"status=disabled",
|
||||||
|
<&poe_mfd>,"status=okay",
|
||||||
|
<&fan>,"pwms:0=",<&poe_mfd_pwm>;
|
||||||
|
};
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
+43
-31
@@ -1,38 +1,50 @@
|
|||||||
{ lib, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.hardware.raspberry-pi."4".pwm0;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
options.hardware = {
|
||||||
(lib.mkRemovedOptionModule
|
raspberry-pi."4".pwm0 = {
|
||||||
[
|
enable = lib.mkEnableOption "support for the hardware pwm0 channel on GPIO_18";
|
||||||
"hardware"
|
};
|
||||||
"raspberry-pi"
|
};
|
||||||
"4"
|
|
||||||
"pwm0"
|
|
||||||
]
|
|
||||||
''
|
|
||||||
To enable PWM0 on GPIO18, use the pwm firmware overlay:
|
|
||||||
|
|
||||||
{
|
config = lib.mkIf cfg.enable {
|
||||||
boot.loader.generic-extlinux-compatible.useGenerationDeviceTree = false;
|
hardware.deviceTree = {
|
||||||
hardware.raspberry-pi.configtxt.deviceTreeOverlays.pi4 = [
|
overlays = [
|
||||||
{
|
{
|
||||||
pwm = {
|
name = "pwm-overlay";
|
||||||
pin = 18;
|
dtsText = ''
|
||||||
func = 2;
|
/dts-v1/;
|
||||||
clock = 100000000;
|
/plugin/;
|
||||||
|
/ {
|
||||||
|
compatible = "brcm,bcm2711";
|
||||||
|
|
||||||
|
fragment@0 {
|
||||||
|
target = <&gpio>;
|
||||||
|
__overlay__ {
|
||||||
|
pwm_pins: pwm_pins {
|
||||||
|
brcm,pins = <18>;
|
||||||
|
brcm,function = <2>; /* Alt5 */
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
The removed pwm0 module explicitly assigned a 100 MHz clock.
|
fragment@1 {
|
||||||
Keep clock = 100000000 to preserve that assignment.
|
target = <&pwm>;
|
||||||
Without clock, the pwm overlay leaves the base clock configuration unchanged:
|
__overlay__ {
|
||||||
https://github.com/raspberrypi/linux/blob/rpi-6.18.y/arch/arm/boot/dts/overlays/pwm-overlay.dts
|
pinctrl-names = "default";
|
||||||
|
assigned-clock-rates = <100000000>;
|
||||||
|
status = "okay";
|
||||||
|
pinctrl-0 = <&pwm_pins>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
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.
|
'';
|
||||||
''
|
}
|
||||||
)
|
];
|
||||||
];
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
@@ -49,6 +49,4 @@ in
|
|||||||
message = "The Raspberry Pi 5 requires a newer kernel version (>=6.1.54). Please upgrade nixpkgs for this system.";
|
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 { }) ];
|
|
||||||
}
|
}
|
||||||
+17
-172
@@ -4,12 +4,9 @@ NixOS profiles and modules for Raspberry Pi boards.
|
|||||||
|
|
||||||
## What's here
|
## What's here
|
||||||
|
|
||||||
- `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.
|
- `common/` has the shared bits: the `linux-rpi` kernel build (vendor defconfig, matching firmware), the `config.txt` generation module, and a pinned wireless firmware.
|
||||||
- `1/`, `2/`, `3/`, `4/`, `5/` are the board profiles.
|
- `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.
|
||||||
They select vendor kernels and configure board-specific boot and hardware settings.
|
- 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.
|
||||||
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
|
## Using a board profile
|
||||||
|
|
||||||
@@ -21,53 +18,21 @@ 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.
|
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).
|
||||||
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`
|
## `config.txt`
|
||||||
|
|
||||||
Board profiles import `hardware.raspberry-pi.configtxt`, which renders `config.txt` from Nix options.
|
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`.
|
||||||
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
|
```nix
|
||||||
{
|
{
|
||||||
hardware.raspberry-pi.configtxt.settings = {
|
hardware.raspberry-pi.configtxt.settings = {
|
||||||
all = {
|
all = {
|
||||||
dtparam = [
|
dtparam = [ "audio=on" ];
|
||||||
"audio=on"
|
dtoverlay = [
|
||||||
"i2c_arm=on"
|
"vc4-kms-v3d"
|
||||||
|
"disable-bt"
|
||||||
];
|
];
|
||||||
disable_overscan = true;
|
|
||||||
};
|
};
|
||||||
pi5.arm_freq = 2400;
|
pi5.arm_freq = 2400;
|
||||||
cm4.otg_mode = true;
|
cm4.otg_mode = true;
|
||||||
@@ -75,137 +40,17 @@ The Pi 2–5 profiles also import `common/config-txt-defaults.nix`, which tracks
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
List values become repeated keys in the rendered file, so the `dtparam` above expands to:
|
List values become repeated keys in the rendered file, so the `dtoverlay` above expands to:
|
||||||
|
|
||||||
```ini
|
```
|
||||||
dtparam=audio=on
|
dtoverlay=vc4-kms-v3d
|
||||||
dtparam=i2c_arm=on
|
dtoverlay=disable-bt
|
||||||
```
|
```
|
||||||
|
|
||||||
Top-level attrs are conditional sections (`all`, `pi4`, `pi5`, `cm4`, and so 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`.
|
||||||
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
|
## Current limits
|
||||||
|
|
||||||
- No bootloader module: There's no `boot.loader.raspberry-pi` here.
|
- 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.
|
||||||
Boards rely on `generic-extlinux-compatible` plus U-Boot.
|
- 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.
|
||||||
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.
|
- 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/...>`.
|
||||||
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.
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
{
|
|
||||||
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)
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -8,37 +8,22 @@
|
|||||||
{ lib, ... }:
|
{ lib, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
hardware.raspberry-pi.configtxt = {
|
hardware.raspberry-pi.configtxt.settings = {
|
||||||
settings = {
|
all = {
|
||||||
all = {
|
camera_auto_detect = lib.mkDefault true;
|
||||||
camera_auto_detect = lib.mkDefault true;
|
display_auto_detect = lib.mkDefault true;
|
||||||
display_auto_detect = lib.mkDefault true;
|
max_framebuffers = lib.mkDefault 2;
|
||||||
max_framebuffers = lib.mkDefault 2;
|
disable_fw_kms_setup = lib.mkDefault true;
|
||||||
disable_fw_kms_setup = lib.mkDefault true;
|
disable_overscan = lib.mkDefault true;
|
||||||
disable_overscan = lib.mkDefault true;
|
arm_boost = lib.mkDefault true;
|
||||||
arm_boost = lib.mkDefault true;
|
dtparam = lib.mkDefault [ "audio=on" ];
|
||||||
# A base DTB parameter rather than an overlay one, so it stays here. It
|
dtoverlay = lib.mkDefault [ "vc4-kms-v3d" ];
|
||||||
# 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 = {
|
||||||
deviceTreeOverlays = {
|
otg_mode = lib.mkDefault true;
|
||||||
all = lib.mkDefault [ { vc4-kms-v3d = { }; } ];
|
};
|
||||||
cm5 = lib.mkDefault [ { dwc2.dr_mode = "host"; } ];
|
cm5 = {
|
||||||
|
dtoverlay = lib.mkDefault [ "dwc2,dr_mode=host" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,9 @@
|
|||||||
# config.txt generation module for Raspberry Pi
|
# config.txt generation module for Raspberry Pi
|
||||||
#
|
#
|
||||||
# This module renders config.txt from structured Nix options. The type models
|
# Generates config.txt from structured Nix options. The type system models
|
||||||
# config.txt as nested attrs: each level of nesting adds a conditional filter,
|
# config.txt as nested attrs: each nesting level adds a conditional filter,
|
||||||
# and the leaves are config values. Lists produce repeated keys for dtparam,
|
# and leaves are config values. Repeated keys (dtparam, dtoverlay, gpio)
|
||||||
# dtoverlay and gpio.
|
# are supported via lists.
|
||||||
#
|
|
||||||
# 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
|
# Based on work from nvmd/nixos-raspberrypi (MIT License) and rendering
|
||||||
# approach suggested by @quentinmit. Follows RFC 42.
|
# approach suggested by @quentinmit. Follows RFC 42.
|
||||||
@@ -35,175 +31,59 @@ let
|
|||||||
else if false == v then
|
else if false == v then
|
||||||
"0"
|
"0"
|
||||||
else
|
else
|
||||||
abort "config.txt: unsupported value type: ${builtins.typeOf v}";
|
builtins.abort "config.txt: unsupported value type: ${builtins.typeOf v}";
|
||||||
|
|
||||||
mkKeyValue = lib.generators.mkKeyValueDefault { inherit mkValueString; } "=";
|
mkKeyValue = lib.generators.mkKeyValueDefault { inherit mkValueString; } "=";
|
||||||
|
|
||||||
# Overlay parameters use on/off for booleans. This follows the Raspberry Pi
|
# Recursively flatten nested attrs into a list of { conditionals, name, value } records.
|
||||||
# documentation and the overlay README. Plain settings keep 1/0.
|
# Each nesting level (except the leaf) is a conditional filter.
|
||||||
mkParamValue = v: if builtins.isBool v then (if v then "on" else "off") else mkValueString v;
|
# "all" filters are omitted from the conditionals list since they reset state.
|
||||||
|
# null values are filtered out, allowing `mkForce null` to remove defaults.
|
||||||
# An "all" filter resets state rather than narrowing it, so it never has to be
|
recurse =
|
||||||
# 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:
|
path: value:
|
||||||
if value == null then
|
if value == null then
|
||||||
[ ]
|
[ ]
|
||||||
else if !(builtins.isAttrs value) then
|
else if builtins.isAttrs value && !(builtins.isList value) && !(value ? _type) then
|
||||||
[
|
lib.flatten (lib.mapAttrsToList (name: recurse ([ name ] ++ path)) value)
|
||||||
{
|
|
||||||
conditionals = mkConditionals (lib.init path);
|
|
||||||
items = [
|
|
||||||
{
|
|
||||||
name = lib.last path;
|
|
||||||
inherit value;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
]
|
|
||||||
else
|
else
|
||||||
lib.pipe value [
|
{
|
||||||
(lib.mapAttrsToList (name: recurseSettings (path ++ [ name ])))
|
conditionals = lib.sort builtins.lessThan (lib.filter (k: k != "all") (lib.tail path));
|
||||||
lib.concatLists
|
name = lib.head path;
|
||||||
];
|
inherit value;
|
||||||
|
};
|
||||||
|
|
||||||
# The same flattening for overlays. Here the leaf is already the ordered
|
# Group flattened items by their conditional filter set, then render.
|
||||||
# overlay list for that filter set, so every level of nesting is a filter.
|
groupItems =
|
||||||
recurseOverlays =
|
items:
|
||||||
path: value:
|
lib.mapAttrsToList (groupJSON: groupItems: {
|
||||||
if value == null then
|
conditionals = builtins.fromJSON groupJSON;
|
||||||
[ ]
|
items = builtins.listToAttrs groupItems;
|
||||||
else if builtins.isList value then
|
}) (builtins.groupBy (x: builtins.toJSON x.conditionals) items);
|
||||||
[
|
|
||||||
{
|
|
||||||
conditionals = mkConditionals path;
|
|
||||||
items = value;
|
|
||||||
}
|
|
||||||
]
|
|
||||||
else
|
|
||||||
lib.pipe value [
|
|
||||||
(lib.mapAttrsToList (name: recurseOverlays (path ++ [ name ])))
|
|
||||||
lib.concatLists
|
|
||||||
];
|
|
||||||
|
|
||||||
# Merge groups that share a filter set. Two paths can reduce to the same set
|
mkGroup =
|
||||||
# (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:
|
group:
|
||||||
mkFilterHeader group.conditionals
|
lib.concatMapStrings (k: "[${k}]\n") group.conditionals
|
||||||
+ lib.pipe group.items [
|
+ lib.generators.toKeyValue {
|
||||||
builtins.listToAttrs
|
inherit mkKeyValue;
|
||||||
(lib.generators.toKeyValue {
|
listsAsDuplicateKeys = true;
|
||||||
inherit mkKeyValue;
|
} group.items;
|
||||||
listsAsDuplicateKeys = true;
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
# Each entry ends with a bare `dtoverlay=`. This terminator closes the parameter
|
toConfigTxt =
|
||||||
# scope of that overlay, so a later dtparam applies to the base DTB instead. A
|
attrs:
|
||||||
# terminator must never come first in the file, where it means "load no HAT
|
let
|
||||||
# overlay". Settings render first, and every terminator here follows a
|
groups = lib.sort (a: b: a.conditionals < b.conditionals) (
|
||||||
# dtoverlay=<name>, so no terminator comes first today. A change to the section
|
groupItems (lib.flatten (recurse [ ] attrs))
|
||||||
# order can break this guarantee.
|
);
|
||||||
renderOverlayGroup =
|
in
|
||||||
group:
|
lib.concatMapStringsSep "\n[all]\n" mkGroup groups;
|
||||||
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
|
in
|
||||||
{
|
{
|
||||||
options.hardware.raspberry-pi.configtxt = {
|
options.hardware.raspberry-pi.configtxt = {
|
||||||
settings = lib.mkOption {
|
settings = lib.mkOption {
|
||||||
type =
|
type =
|
||||||
|
with lib.types;
|
||||||
let
|
let
|
||||||
inherit (lib.types)
|
|
||||||
attrsOf
|
|
||||||
bool
|
|
||||||
int
|
|
||||||
listOf
|
|
||||||
nullOr
|
|
||||||
oneOf
|
|
||||||
str
|
|
||||||
;
|
|
||||||
atom = nullOr (oneOf [
|
atom = nullOr (oneOf [
|
||||||
str
|
str
|
||||||
int
|
int
|
||||||
@@ -227,10 +107,6 @@ in
|
|||||||
Booleans render as `0`/`1`. Use `null` with `mkForce` to remove a
|
Booleans render as `0`/`1`. Use `null` with `mkForce` to remove a
|
||||||
default.
|
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>
|
See <https://www.raspberrypi.com/documentation/computers/config_txt.html>
|
||||||
'';
|
'';
|
||||||
example = lib.literalExpression ''
|
example = lib.literalExpression ''
|
||||||
@@ -247,95 +123,13 @@ 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 {
|
file = lib.mkOption {
|
||||||
type = lib.types.path;
|
type = lib.types.path;
|
||||||
default = pkgs.writeText "config.txt" generatedConfig;
|
default = pkgs.writeText "config.txt" (toConfigTxt cfg.settings);
|
||||||
defaultText = lib.literalExpression ''pkgs.writeText "config.txt" (generated from settings and deviceTreeOverlays)'';
|
defaultText = lib.literalExpression ''pkgs.writeText "config.txt" (generated from settings)'';
|
||||||
description = ''
|
description = ''
|
||||||
Path to the config.txt file to install. Defaults to the rendered output
|
Path to the generated config.txt file. Defaults to the rendered output
|
||||||
of {option}`settings` and {option}`deviceTreeOverlays`. A custom file
|
of `settings`, but can be overridden to supply a custom config.txt.
|
||||||
replaces that output, so the module then ignores both options.
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./audio.nix
|
|
||||||
./config-txt.nix
|
./config-txt.nix
|
||||||
./config-txt-defaults.nix
|
./config-txt-defaults.nix
|
||||||
./firmware.nix
|
|
||||||
];
|
];
|
||||||
|
|
||||||
boot.initrd.availableKernelModules = [
|
boot.initrd.availableKernelModules = [
|
||||||
|
|||||||
@@ -1,228 +0,0 @@
|
|||||||
# 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
|
|
||||||
'';
|
|
||||||
})
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -10,9 +10,9 @@
|
|||||||
|
|
||||||
let
|
let
|
||||||
# NOTE: raspberryPiWirelessFirmware should be updated with this
|
# NOTE: raspberryPiWirelessFirmware should be updated with this
|
||||||
modDirVersion = "6.18.65";
|
modDirVersion = "6.18.34";
|
||||||
tag = "stable_20261127";
|
tag = "stable_20260609";
|
||||||
hash = "sha256-VbyXdyMxhWvNv3GGJvs0D330xzc1pwP6IpXpe2Q/o4g=";
|
hash = "sha256-ok++36dh9o4e7AC5RErW00/r23rGxufe0PYXz5Dzy5U=";
|
||||||
inherit (lib.kernel) freeform yes no;
|
inherit (lib.kernel) freeform yes no;
|
||||||
in
|
in
|
||||||
(buildLinux (
|
(buildLinux (
|
||||||
@@ -83,18 +83,6 @@ in
|
|||||||
PREEMPT = lib.mkForce no;
|
PREEMPT = lib.mkForce no;
|
||||||
PREEMPT_LAZY = lib.mkForce no;
|
PREEMPT_LAZY = lib.mkForce no;
|
||||||
PREEMPT_VOLUNTARY = lib.mkForce yes;
|
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 =
|
extraMeta =
|
||||||
|
|||||||
@@ -6,22 +6,22 @@
|
|||||||
|
|
||||||
stdenvNoCC.mkDerivation {
|
stdenvNoCC.mkDerivation {
|
||||||
pname = "raspberrypi-wireless-firmware";
|
pname = "raspberrypi-wireless-firmware";
|
||||||
version = "0-unstable-2026-11-23";
|
version = "0-unstable-2026-03-21";
|
||||||
|
|
||||||
srcs = [
|
srcs = [
|
||||||
(fetchFromGitHub {
|
(fetchFromGitHub {
|
||||||
name = "bluez-firmware";
|
name = "bluez-firmware";
|
||||||
owner = "RPi-Distro";
|
owner = "RPi-Distro";
|
||||||
repo = "bluez-firmware";
|
repo = "bluez-firmware";
|
||||||
rev = "924fde7d1f0613d796e4512ac44ac33e4b91c4e3";
|
rev = "cdf61dc691a49ff01a124752bd04194907f0f9cd";
|
||||||
hash = "sha256-Ff0pzWidPgoEXpBqh81jmQWcpW90J1hH+gY61Wb8TEk=";
|
hash = "sha256-35pnbQV/zcikz9Vic+2a1QAS72riruKklV8JHboL9NY=";
|
||||||
})
|
})
|
||||||
(fetchFromGitHub {
|
(fetchFromGitHub {
|
||||||
name = "firmware-nonfree";
|
name = "firmware-nonfree";
|
||||||
owner = "RPi-Distro";
|
owner = "RPi-Distro";
|
||||||
repo = "firmware-nonfree";
|
repo = "firmware-nonfree";
|
||||||
rev = "b1833f18a816cf8fd73ca86e27f9eecea11bf991";
|
rev = "9794282eb9f4a2de1f23b41a738926740e975d83";
|
||||||
hash = "sha256-fe2oZV/qPBkemtG34cx9s2+4RhMn5XF0zl3EkmFDiZg=";
|
hash = "sha256-OtA8yHvfusGP/ucf8Exzi+nSUmNoYp10u+luC2gbNZc=";
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -36,8 +36,7 @@ stdenvNoCC.mkDerivation {
|
|||||||
mkdir -p "$out/lib/firmware/brcm"
|
mkdir -p "$out/lib/firmware/brcm"
|
||||||
|
|
||||||
# Wifi firmware
|
# Wifi firmware
|
||||||
cp -r "firmware-nonfree/debian/added-firmware/brcm" "$out/lib/firmware/"
|
cp -r "firmware-nonfree/debian/config/brcm80211/." "$out/lib/firmware/"
|
||||||
cp -r "firmware-nonfree/debian/added-firmware/cypress" "$out/lib/firmware/"
|
|
||||||
|
|
||||||
# Bluetooth firmware
|
# Bluetooth firmware
|
||||||
cp -r "bluez-firmware/debian/firmware/broadcom/." "$out/lib/firmware/brcm"
|
cp -r "bluez-firmware/debian/firmware/broadcom/." "$out/lib/firmware/brcm"
|
||||||
|
|||||||
@@ -1,117 +0,0 @@
|
|||||||
# 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)
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
{
|
|
||||||
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";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
{
|
|
||||||
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
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
{
|
|
||||||
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
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
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"
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -1,222 +0,0 @@
|
|||||||
{
|
|
||||||
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 { })
|
|
||||||
)
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
{
|
|
||||||
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
|
|
||||||
'';
|
|
||||||
})
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
||||||
@@ -1,758 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
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
|
|
||||||
@@ -1,156 +0,0 @@
|
|||||||
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
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
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
|
|
||||||
Loaded 100 of 129 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user