From 595a50fd07e6a3ea5ad907e65c527c89bc2d45d6 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Mon, 19 Apr 2021 16:23:11 -0400 Subject: [PATCH 01/14] linux/common-config.nix: Enable FB_SIMPLE on AArch64 --- pkgs/os-specific/linux/kernel/common-config.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/os-specific/linux/kernel/common-config.nix b/pkgs/os-specific/linux/kernel/common-config.nix index 5cece836b73e..20f3ce1a00a1 100644 --- a/pkgs/os-specific/linux/kernel/common-config.nix +++ b/pkgs/os-specific/linux/kernel/common-config.nix @@ -871,6 +871,11 @@ let # The kernel command line will override a platform-specific configuration from its device tree. # https://github.com/torvalds/linux/blob/856deb866d16e29bd65952e0289066f6078af773/kernel/dma/contiguous.c#L35-L44 CMA_SIZE_MBYTES = freeform "32"; + + # Many ARM SBCs hand off a pre-configured framebuffer. + # This always can can be replaced by the actual native driver. + # Keeping it a built-in ensures it will be used if possible. + FB_SIMPLE = yes; }; }; in From 7264c049c73b433a3f6eebfe8f02bb3e4c903e69 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Sat, 1 May 2021 16:59:15 -0400 Subject: [PATCH 02/14] linux/common-config.nix: Configure for armv7l-linux too --- pkgs/os-specific/linux/kernel/common-config.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/os-specific/linux/kernel/common-config.nix b/pkgs/os-specific/linux/kernel/common-config.nix index 20f3ce1a00a1..776a422df735 100644 --- a/pkgs/os-specific/linux/kernel/common-config.nix +++ b/pkgs/os-specific/linux/kernel/common-config.nix @@ -859,7 +859,7 @@ let # Bump the maximum number of CPUs to support systems like EC2 x1.* # instances and Xeon Phi. NR_CPUS = freeform "384"; - } // optionalAttrs (stdenv.hostPlatform.system == "aarch64-linux") { + } // optionalAttrs (stdenv.hostPlatform.system == "armv7l-linux" || stdenv.hostPlatform.system == "aarch64-linux") { # Enables support for the Allwinner Display Engine 2.0 SUN8I_DE2_CCU = whenAtLeast "4.13" yes; @@ -876,6 +876,9 @@ let # This always can can be replaced by the actual native driver. # Keeping it a built-in ensures it will be used if possible. FB_SIMPLE = yes; + + } // optionalAttrs (stdenv.hostPlatform.system == "armv7l-linux") { + ARM_LPAE = yes; }; }; in From c60de9291772c4186dda97da576039e6c7037b4d Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Mon, 19 Apr 2021 16:20:37 -0400 Subject: [PATCH 03/14] profiles/all-hardware.nix: Add simplefb for AArch64 --- nixos/modules/profiles/all-hardware.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nixos/modules/profiles/all-hardware.nix b/nixos/modules/profiles/all-hardware.nix index d460c52dbefd..b2dd488908a7 100644 --- a/nixos/modules/profiles/all-hardware.nix +++ b/nixos/modules/profiles/all-hardware.nix @@ -51,6 +51,13 @@ in # Hyper-V support. "hv_storvsc" + ] ++ lib.optionals pkgs.stdenv.isAarch64 [ + # Most of the following falls into two categories: + # - early KMS / early display + # - early storage (e.g. USB) support + + # Allows using framebuffer configured by the initial boot firmware + "simplefb" ]; # Include lots of firmware. From 5bc36c1b3018b34a561e1257ce7b80fd506c6587 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Mon, 19 Apr 2021 16:20:57 -0400 Subject: [PATCH 04/14] profiles/all-hardware.nix: Add support for Allwinner hardware --- nixos/modules/profiles/all-hardware.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nixos/modules/profiles/all-hardware.nix b/nixos/modules/profiles/all-hardware.nix index b2dd488908a7..0af87fa621a5 100644 --- a/nixos/modules/profiles/all-hardware.nix +++ b/nixos/modules/profiles/all-hardware.nix @@ -58,6 +58,15 @@ in # Allows using framebuffer configured by the initial boot firmware "simplefb" + + # Allwinner support + + # Required for early KMS + "sun4i-drm" + "sun8i-mixer" # Audio, but required for kms + + # PWM for the backlight + "pwm-sun4i" ]; # Include lots of firmware. From a8af02fe6d1d7f187fca0b54159eb8eeb87dbfc4 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Mon, 19 Apr 2021 16:21:46 -0400 Subject: [PATCH 05/14] profiles/all-hardware.nix: Add modules for integrated displays Namely, this is used by the pinebook's display --- nixos/modules/profiles/all-hardware.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nixos/modules/profiles/all-hardware.nix b/nixos/modules/profiles/all-hardware.nix index 0af87fa621a5..78557797ebc1 100644 --- a/nixos/modules/profiles/all-hardware.nix +++ b/nixos/modules/profiles/all-hardware.nix @@ -67,6 +67,15 @@ in # PWM for the backlight "pwm-sun4i" + + # Misc. uncategorized hardware + + # Used for some platform's integrated displays + "panel-simple" + "pwm-bl" + + # Misc "weak" dependencies + "analogix-anx6345" # For DP or eDP (e.g. integrated display) ]; # Include lots of firmware. From a846d198316d9522b7456f4b54779df1cd4f13a5 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Mon, 19 Apr 2021 16:22:11 -0400 Subject: [PATCH 06/14] profiles/all-hardware.nix: Add power regulator modules This is used on some allwinner platforms, and is a weak dependency for USB to work. --- nixos/modules/profiles/all-hardware.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nixos/modules/profiles/all-hardware.nix b/nixos/modules/profiles/all-hardware.nix index 78557797ebc1..e3ec50f9e789 100644 --- a/nixos/modules/profiles/all-hardware.nix +++ b/nixos/modules/profiles/all-hardware.nix @@ -74,6 +74,11 @@ in "panel-simple" "pwm-bl" + # Power supply drivers, some platforms need them for USB + "axp20x-ac-power" + "axp20x-battery" + "pinctrl-axp209" + # Misc "weak" dependencies "analogix-anx6345" # For DP or eDP (e.g. integrated display) ]; From 70205bd13c8e790148158e08716f0820b9c309b6 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Mon, 19 Apr 2021 21:40:00 -0400 Subject: [PATCH 07/14] profiles/all-hardware.nix: Add support for Raspberry Pi 4 USB --- nixos/modules/profiles/all-hardware.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nixos/modules/profiles/all-hardware.nix b/nixos/modules/profiles/all-hardware.nix index e3ec50f9e789..30e7983b248f 100644 --- a/nixos/modules/profiles/all-hardware.nix +++ b/nixos/modules/profiles/all-hardware.nix @@ -68,6 +68,10 @@ in # PWM for the backlight "pwm-sun4i" + # Broadcom + + "pcie-brcmstb" + # Misc. uncategorized hardware # Used for some platform's integrated displays @@ -79,6 +83,9 @@ in "axp20x-battery" "pinctrl-axp209" + # USB drivers + "xhci-pci-renesas" + # Misc "weak" dependencies "analogix-anx6345" # For DP or eDP (e.g. integrated display) ]; From 535d463cf911f37f94357f4e470499b9c18aec9f Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Thu, 22 Apr 2021 15:57:37 -0400 Subject: [PATCH 08/14] profiles/all-hardware.nix: Add rockchip modules --- nixos/modules/profiles/all-hardware.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nixos/modules/profiles/all-hardware.nix b/nixos/modules/profiles/all-hardware.nix index 30e7983b248f..31599f281095 100644 --- a/nixos/modules/profiles/all-hardware.nix +++ b/nixos/modules/profiles/all-hardware.nix @@ -72,6 +72,14 @@ in "pcie-brcmstb" + # Rockchip + "dw-hdmi" + "dw-mipi-dsi" + "rockchipdrm" + "rockchip-rga" + "phy-rockchip-pcie" + "pcie-rockchip-host" + # Misc. uncategorized hardware # Used for some platform's integrated displays From 9fa3e2c2a3898717d1a32add3ff90bb9803e9930 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Thu, 22 Apr 2021 15:58:16 -0400 Subject: [PATCH 09/14] profiles/all-hardware.nix: Add regulator needed for rockchip But not exclusive to rockchip --- nixos/modules/profiles/all-hardware.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/modules/profiles/all-hardware.nix b/nixos/modules/profiles/all-hardware.nix index 31599f281095..04ee3af6600a 100644 --- a/nixos/modules/profiles/all-hardware.nix +++ b/nixos/modules/profiles/all-hardware.nix @@ -90,6 +90,7 @@ in "axp20x-ac-power" "axp20x-battery" "pinctrl-axp209" + "mp8859" # USB drivers "xhci-pci-renesas" From 82625705c624feb2aafabf7a0af8b64b4b036ec8 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Thu, 22 Apr 2021 15:58:39 -0400 Subject: [PATCH 10/14] profiles/all-hardware.nix: Add analogix-dp While it's being brought in implicitly by the other analogix driver, let's be explicit, in case things change. --- nixos/modules/profiles/all-hardware.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/modules/profiles/all-hardware.nix b/nixos/modules/profiles/all-hardware.nix index 04ee3af6600a..2371f21fa08f 100644 --- a/nixos/modules/profiles/all-hardware.nix +++ b/nixos/modules/profiles/all-hardware.nix @@ -96,6 +96,7 @@ in "xhci-pci-renesas" # Misc "weak" dependencies + "analogix-dp" "analogix-anx6345" # For DP or eDP (e.g. integrated display) ]; From 14ac6de0244049c7a4a3d0cfd400c6e6f5081ea9 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Sat, 1 May 2021 16:58:50 -0400 Subject: [PATCH 11/14] profiles/all-hardware.nix: Fix for arvmv7l-linux --- nixos/modules/profiles/all-hardware.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/profiles/all-hardware.nix b/nixos/modules/profiles/all-hardware.nix index 2371f21fa08f..7b305319e841 100644 --- a/nixos/modules/profiles/all-hardware.nix +++ b/nixos/modules/profiles/all-hardware.nix @@ -46,7 +46,7 @@ in # VMware support. "mptspi" "vmxnet3" "vsock" ] ++ lib.optional platform.isx86 "vmw_balloon" - ++ lib.optionals (!platform.isAarch64) [ # not sure where else they're missing + ++ lib.optionals (!platform.isAarch64 && !platform.isAarch32) [ # not sure where else they're missing "vmw_vmci" "vmwgfx" "vmw_vsock_vmci_transport" # Hyper-V support. From f5b7687d26c48f35c46f3a497c7145dcb06ddfc0 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Sat, 1 May 2021 19:43:55 -0400 Subject: [PATCH 12/14] profiles/all-hardware.nix: Share some config for all ARM --- nixos/modules/profiles/all-hardware.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nixos/modules/profiles/all-hardware.nix b/nixos/modules/profiles/all-hardware.nix index 7b305319e841..c185acc5a0fc 100644 --- a/nixos/modules/profiles/all-hardware.nix +++ b/nixos/modules/profiles/all-hardware.nix @@ -51,7 +51,7 @@ in # Hyper-V support. "hv_storvsc" - ] ++ lib.optionals pkgs.stdenv.isAarch64 [ + ] ++ lib.optionals (pkgs.stdenv.isAarch32 || pkgs.stdenv.isAarch64) [ # Most of the following falls into two categories: # - early KMS / early display # - early storage (e.g. USB) support @@ -67,6 +67,10 @@ in # PWM for the backlight "pwm-sun4i" + ] ++ lib.optionals pkgs.stdenv.isAarch64 [ + # Most of the following falls into two categories: + # - early KMS / early display + # - early storage (e.g. USB) support # Broadcom From cb9b46a3cdcbb4c82c582441f213259ce5399b15 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Mon, 3 May 2021 23:46:29 -0400 Subject: [PATCH 13/14] profiles/all-hardware.nix: Add vc4 for broadcom hardware Namely, early KMS on raspberry pi --- nixos/modules/profiles/all-hardware.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nixos/modules/profiles/all-hardware.nix b/nixos/modules/profiles/all-hardware.nix index c185acc5a0fc..c7a13974a516 100644 --- a/nixos/modules/profiles/all-hardware.nix +++ b/nixos/modules/profiles/all-hardware.nix @@ -67,6 +67,10 @@ in # PWM for the backlight "pwm-sun4i" + + # Broadcom + + "vc4" ] ++ lib.optionals pkgs.stdenv.isAarch64 [ # Most of the following falls into two categories: # - early KMS / early display From 1cb977c8588c9aa1bf30fe7fa154b5fcc763471f Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Mon, 3 May 2021 23:45:26 -0400 Subject: [PATCH 14/14] sd-image: Rely on profiles/all-hardware.nix This ensures that SD images and UEFI installers don't drift in compatibility with regards to early initrd. --- nixos/modules/installer/sd-card/sd-image-aarch64.nix | 7 ------- nixos/modules/installer/sd-card/sd-image.nix | 1 + 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/nixos/modules/installer/sd-card/sd-image-aarch64.nix b/nixos/modules/installer/sd-card/sd-image-aarch64.nix index 96ebb7537da3..165e2aac27b4 100644 --- a/nixos/modules/installer/sd-card/sd-image-aarch64.nix +++ b/nixos/modules/installer/sd-card/sd-image-aarch64.nix @@ -18,13 +18,6 @@ # - ttyAMA0: for QEMU's -machine virt boot.kernelParams = ["console=ttyS0,115200n8" "console=ttyAMA0,115200n8" "console=tty0"]; - boot.initrd.availableKernelModules = [ - # Allows early (earlier) modesetting for the Raspberry Pi - "vc4" "bcm2835_dma" "i2c_bcm2835" - # Allows early (earlier) modesetting for Allwinner SoCs - "sun4i_drm" "sun8i_drm_hdmi" "sun8i_mixer" - ]; - sdImage = { populateFirmwareCommands = let configTxt = pkgs.writeText "config.txt" '' diff --git a/nixos/modules/installer/sd-card/sd-image.nix b/nixos/modules/installer/sd-card/sd-image.nix index 45c8c67169b8..d0fe79903d34 100644 --- a/nixos/modules/installer/sd-card/sd-image.nix +++ b/nixos/modules/installer/sd-card/sd-image.nix @@ -29,6 +29,7 @@ in imports = [ (mkRemovedOptionModule [ "sdImage" "bootPartitionID" ] "The FAT partition for SD image now only holds the Raspberry Pi firmware files. Use firmwarePartitionID to configure that partition's ID.") (mkRemovedOptionModule [ "sdImage" "bootSize" ] "The boot files for SD image have been moved to the main ext4 partition. The FAT partition now only holds the Raspberry Pi firmware files. Changing its size may not be required.") + ../../profiles/all-hardware.nix ]; options.sdImage = {