This commit is contained in:
dump_stack() 2024-10-18 14:51:48 +00:00
parent 18aa1fc67e
commit 008b321cf1
Signed by: dump_stack
GPG Key ID: C9905BA72B5E02BB
11 changed files with 346 additions and 66 deletions

View File

@ -11,6 +11,7 @@
pkgs.linux-firmware (pkgs.callPackage ./pkgs/t14s-firmware.nix { })
];
boot.loader.efi.canTouchEfiVariables = false;
boot.loader.systemd-boot = {
enable = true;
extraFiles = {
@ -44,10 +45,44 @@
acpi
openssl
light
];
services.getty.autologinUser = lib.mkDefault "root";
nixpkgs.overlays = [
(final: prev: {
qrtr = prev.callPackage ./pkgs/qrtr.nix {};
qmic = prev.callPackage ./pkgs/qmic.nix {};
rmtfs = prev.callPackage ./pkgs/rmtfs.nix { inherit (final) qrtr qmic; };
pd-mapper = final.callPackage ./pkgs/pd-mapper.nix { inherit (final) qrtr; };
})
];
systemd.services = {
pd-mapper = {
unitConfig = {
Requires = "qrtr-ns.service";
After = "qrtr-ns.service";
};
serviceConfig = {
Restart = "always";
ExecStart = "${pkgs.pd-mapper}/bin/pd-mapper";
};
wantedBy = [
"multi-user.target"
];
};
qrtr-ns = {
serviceConfig = {
ExecStart = "${pkgs.qrtr}/bin/qrtr-ns -v -f 1";
Restart = "always";
};
wantedBy = ["multi-user.target"];
};
};
nixpkgs.config.allowUnfree = true;
nix.settings = {

View File

@ -1,60 +1,85 @@
{ config, lib, pkgs, ... }:
let
inherit (config.boot.loader) efi;
linux_x1e_pkg = { buildLinux, ... } @ args:
buildLinux (args // rec {
version = "6.10.0";
modDirVersion = "6.10.0-next-20240725";
version = "6.12.0";
modDirVersion = "6.12.0-rc3";
src = pkgs.fetchFromGitLab {
domain = "git.codelinaro.org";
owner = "abel.vesa";
repo = "linux";
rev = "x1e80100-20240725"; # "x1e80100-next";
hash = "sha256-0DFmPJEFl+cQT3Li4vuptBwavRc9CQOatd8TIYht+54=";
src = pkgs.fetchFromGitHub {
owner = "jhovold";
repo = "linux";
# wip/x1e80100-6.12-rc3
rev = "84318c8e3038f579070e7c5d109d1d2311a5f437";
hash = "sha256-kpuzjqcI4YGS+S9OvIUhm6z8xCGMA5h5+JlcHhoEETM=";
};
kernelPatches = (args.kernelPatches or [ ]);
extraMeta.branch = "6.10";
extraMeta.branch = "6.12";
} // (args.argsOverride or { }));
linux_x1e = pkgs.callPackage linux_x1e_pkg { defconfig = "x1e_defconfig"; };
linux_x1e = pkgs.callPackage linux_x1e_pkg {
defconfig = "johan_defconfig";
};
linuxPackages_x1e = pkgs.recurseIntoAttrs (pkgs.linuxPackagesFor linux_x1e);
dtb = "${linuxPackages_x1e.kernel}/dtbs/qcom/x1e78100-lenovo-thinkpad-t14s.dtb";
dtbHash = builtins.hashFile "md5" dtb;
dtbName = "x1e78100-${dtbHash}.dtb";
in {
hardware = {
deviceTree = {
enable = true;
name = "qcom/x1e78100-lenovo-thinkpad-t14s.dtb";
};
};
boot = {
kernelPackages = linuxPackages_x1e;
kernelPatches = [
{
name = "backlight";
patch = ./patches/backlight.patch;
}
{
name = "bluetooth";
patch = ./patches/bluetooth.patch;
}
{
name = "disable-type-c-dp";
patch = ./patches/disable-type-c-dp.patch;
}
{
name = "vmlinuz.efi";
patch = null;
extraStructuredConfig = with lib.kernel; {
EFI_ZBOOT = lib.mkForce no;
};
}
{
name = "disable-qr-code-panic-screen";
patch = null;
extraStructuredConfig = with lib.kernel; {
DRM_PANIC_SCREEN_QR_CODE = lib.mkForce no;
};
}
{
name = "disable-rust";
patch = null;
extraStructuredConfig = with lib.kernel; {
RUST = lib.mkForce no;
};
}
];
kernelParams = [
"dtb=${dtbName}"
#"initcall_debug"
#"earlycon=efifb"
"console=tty0"
#"ignore_loglevel"
#"keep_bootcon"
"regulator_ignore_unused"
"clk_ignore_unused"
"pd_ignore_unused"
"arm64.nopauth"
#"acpi=no"
"efi=novamap"
#"efi=noruntime"
"pcie_aspm.policy=powersupersave"
"iommu.strict=0"
"iommu.passthrough=0"
#"earlyprintk=xdbc"
#"usbcore.autosuspend=-1"
"module_blacklist=edac_core,qcom_q6v5_pas"
];
supportedFilesystems.zfs = false;
@ -66,6 +91,7 @@ in {
"nvme"
"uas"
"usb-storage"
"pcie-qcom"
"gpio-sbu-mux"
"leds-qcom-lpg"
@ -96,36 +122,6 @@ in {
# fat32
"vfat" "nls-cp437" "nls-iso8859-1"
];
systemd = {
enable = true;
enableTpm2 = false;
};
};
loader = {
systemd-boot.enable = lib.mkForce true;
efi.canTouchEfiVariables = false;
systemd-boot.extraFiles = {
"${dtbName}" = dtb;
};
};
};
system.activationScripts.t14s-gen6-dtb = ''
in_package="${dtb}"
esp_tool_folder="${efi.efiSysMountPoint}/"
in_esp="''${esp_tool_folder}${dtbName}"
in_esp_backup="''${esp_tool_folder}/dtb/${dtbName}"
in_esp_backup_dir="''${esp_tool_folder}/dtb/"
mkdir -p "$in_esp_backup_dir"
cp "$in_package" "$in_esp_backup"
>&2 echo "Ensuring $in_esp in EFI System Partition"
if ! ${pkgs.diffutils}/bin/cmp --silent "$in_package" "$in_esp"; then
>&2 echo "Copying $in_package -> $in_esp"
mkdir -p "$esp_tool_folder"
cp "$in_package" "$in_esp"
sync
fi
'';
}

51
patches/backlight.patch Normal file
View File

@ -0,0 +1,51 @@
diff --git a/arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dts b/arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dts
index 04d6983ca8f3..0d42b275fd66 100644
--- a/arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dts
+++ b/arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dts
@@ -19,6 +19,14 @@ / {
compatible = "lenovo,thinkpad-t14s", "qcom,x1e78100", "qcom,x1e80100";
chassis-type = "laptop";
+ backlight: backlight {
+ compatible = "pwm-backlight";
+ pwms = <&pmk8550_pwm 0 5000000>;
+ enable-gpios = <&pmc8380_3_gpios 4 GPIO_ACTIVE_HIGH>;
+ pinctrl-0 = <&edp_bl_en>, <&edp_bl_pwm>;
+ pinctrl-names = "default";
+ };
+
gpio-keys {
compatible = "gpio-keys";
@@ -744,12 +752,9 @@ &mdss_dp3 {
aux-bus {
panel {
compatible = "edp-panel";
- enable-gpios = <&pmc8380_3_gpios 4 GPIO_ACTIVE_HIGH>;
+ backlight = <&backlight>;
power-supply = <&vreg_edp_3p3>;
- pinctrl-0 = <&edp_bl_en>;
- pinctrl-names = "default";
-
port {
edp_panel_in: endpoint {
remote-endpoint = <&mdss_dp3_out>;
@@ -849,6 +854,17 @@ rtmr0_1p15_reg_en: rtmr0-1p15-reg-en-state {
};
};
+&pmk8550_pwm {
+ status = "okay";
+};
+
+&pmk8550_gpios {
+ edp_bl_pwm: edp-bl-pwm-state {
+ pins = "gpio5";
+ function = "func3";
+ };
+};
+
&qupv3_0 {
status = "okay";
};

48
patches/bluetooth.patch Normal file
View File

@ -0,0 +1,48 @@
diff --git a/arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dts b/arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dts
index 04d6983ca8f3..0bb3ca93cfaa 100644
--- a/arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dts
+++ b/arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dts
@@ -19,6 +19,11 @@ / {
compatible = "lenovo,thinkpad-t14s", "qcom,x1e78100", "qcom,x1e80100";
chassis-type = "laptop";
+ aliases {
+ serial0 = &uart21;
+ serial1 = &uart14;
+ };
+
gpio-keys {
compatible = "gpio-keys";
@@ -1013,6 +1018,31 @@ wcd_default: wcd-reset-n-active-state {
bias-disable;
output-low;
};
+
+ bt_en_default: bt-en-sleep {
+ pins = "gpio116";
+ function = "gpio";
+ output-low;
+ bias-disable;
+ qcom,drive-strength = <16>;
+ };
+};
+
+&uart14 {
+ status = "okay";
+
+ bluetooth: bt_wcn7850 {
+ compatible = "qcom,wcn7850-bt";
+ pinctrl-names = "default";
+ pinctrl-0 = <&bt_en_default>;
+ enable-gpios = <&tlmm 116 GPIO_ACTIVE_HIGH>;
+ max-speed = <3200000>;
+ };
+};
+
+&uart21 {
+ compatible = "qcom,geni-debug-uart";
+ status = "okay";
};
&usb_1_ss0_hsphy {

View File

@ -0,0 +1,27 @@
diff --git a/arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dts b/arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dts
index 04d6983ca8f3..998cb8920dbc 100644
--- a/arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dts
+++ b/arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dts
@@ -719,22 +719,6 @@ &mdss {
status = "okay";
};
-&mdss_dp0 {
- status = "okay";
-};
-
-&mdss_dp0_out {
- data-lanes = <0 1 2 3>;
-};
-
-&mdss_dp1 {
- status = "okay";
-};
-
-&mdss_dp1_out {
- data-lanes = <0 1 2 3>;
-};
-
&mdss_dp3 {
compatible = "qcom,x1e80100-dp";
/delete-property/ #sound-dai-cells;

33
pkgs/pd-mapper.nix Normal file
View File

@ -0,0 +1,33 @@
{
stdenv,
lib,
fetchFromGitHub,
pkg-config,
qrtr,
lzma,
}:
stdenv.mkDerivation {
pname = "pd-mapper";
version = "2024-06-19";
src = fetchFromGitHub {
owner = "linux-msm";
repo = "pd-mapper";
rev = "e7c42e1522249593302a5b8920b9e7b42dc3f25e";
sha256 = "sha256-gTUpltbY5439IEEvnxnt8WOFUgfpQUJWr5f+OB12W8A=";
};
nativeBuildInputs = [ pkg-config lzma ];
buildInputs = [ qrtr ];
installFlags = [ "prefix=$(out)" ];
meta = with lib; {
description = "pd mapper";
homepage = "https://github.com/linux-msm/pd-mapper";
license = licenses.bsd3;
platforms = platforms.linux;
};
}

26
pkgs/qmic.nix Normal file
View File

@ -0,0 +1,26 @@
{
stdenv,
lib,
fetchFromGitHub
}:
stdenv.mkDerivation {
pname = "qmic";
version = "2022-07-18";
src = fetchFromGitHub {
owner = "linux-msm";
repo = "qmic";
rev = "4574736afce75aa5eec1e1069a19563410167c9f";
sha256 = "sha256-0/mIg98pN66ZaVsQ6KmZINuNfiKvdEHMsqDx0iciF8w=";
};
installFlags = [ "prefix=$(out)" ];
meta = with lib; {
description = "QMI IDL compiler";
homepage = "https://github.com/linux-msm/qmic";
license = licenses.bsd3;
platforms = platforms.aarch64;
};
}

33
pkgs/qrtr.nix Normal file
View File

@ -0,0 +1,33 @@
{
stdenv,
lib,
fetchFromGitHub,
meson,
cmake,
pkg-config,
systemd,
ninja,
}:
stdenv.mkDerivation {
pname = "qrtr";
version = "2024-05-21";
src = fetchFromGitHub {
owner = "linux-msm";
repo = "qrtr";
rev = "daf7f4cc326a5036dcce2bd7deaf2c32841b0336";
hash = "sha256-OGx5fxxtrNN9EJJxxH4MTDRFGsyu4LNo+ks46zbJqF0=";
};
nativeBuildInputs = [ meson cmake pkg-config systemd ninja ];
installFlags = [ "prefix=$(out)" ];
meta = with lib; {
description = "QMI IDL compiler";
homepage = "https://github.com/linux-msm/qrtr";
license = licenses.bsd3;
platforms = platforms.aarch64;
};
}

31
pkgs/rmtfs.nix Normal file
View File

@ -0,0 +1,31 @@
{
lib,
stdenv,
fetchFromGitHub,
udev,
qrtr,
qmic
}:
stdenv.mkDerivation {
pname = "rmtfs";
version = "2024-03-18";
buildInputs = [ udev qrtr qmic ];
src = fetchFromGitHub {
owner = "linux-msm";
repo = "rmtfs";
rev = "33e1e40615efc59b17a515afe857c51b8b8c1ad1";
hash = "sha256-AxFuDmfLTcnnwm+nezwLc8yaHcX+pFkX5qSIO38T/BM=";
};
installFlags = [ "prefix=$(out)" ];
meta = with lib; {
description = "Qualcomm Remote Filesystem Service";
homepage = "https://github.com/linux-msm/rmtfs";
license = licenses.bsd3;
platforms = platforms.aarch64;
};
}

View File

@ -7,13 +7,13 @@
stdenvNoCC.mkDerivation rec {
pname = "linux-firmware";
version = "20240726";
version = "20241003";
src = fetchFromGitHub {
owner = "jollheef";
repo = "linux-firmware-x1e78100-lenovo-thinkpad-t14s";
rev = "4ba0b781ffc27cb48736942822192b548a316838";
hash = "sha256-ZeV6JRxU1gMwtWZH8sePCrZXFa27GxoKpLK4sg3Ljyo=";
rev = "e3ba8bb550b023b9f8501360f1d85d74d3de96b4";
hash = "sha256-REkQpg+27to11VoDfAksvqzi5M7MDjAcAvR7P8cnRk0=";
};
installPhase = ''

View File

@ -5,7 +5,7 @@ efi_part_label=i_t14sg6_efi
nix_part_label=i_t14sg6_nix
boot_size=256M
fallocate -l4G ${file}
fallocate -l8G ${file}
parted ${file} mklabel gpt
parted ${file} mkpart ${efi_part_label} fat32 0% ${boot_size}
@ -23,7 +23,7 @@ mkdir /mnt/boot
mount ${drive}p1 /mnt/boot
mkdir -p /mnt/etc/nixos
cp -r pkgs *.nix /mnt/etc/nixos/
cp -r patches pkgs *.nix /mnt/etc/nixos/
nixos-install --root /mnt --no-root-password
umount -R /mnt