Skip to content

Commit b201950

Browse files
committed
lenovo-thinkpad-x13s: Add support for aarch64 system
1 parent 9a049b4 commit b201950

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed

flake.nix

+1
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@
244244
lenovo-thinkpad-x13-amd = import ./lenovo/thinkpad/x13/amd;
245245
lenovo-thinkpad-x13-yoga = import ./lenovo/thinkpad/x13/yoga;
246246
lenovo-thinkpad-x13-yoga-3th-gen = import ./lenovo/thinkpad/x13/yoga/3th-gen;
247+
lenovo-thinkpad-x13s = import ./lenovo/thinkpad/x13s;
247248
lenovo-thinkpad-x140e = import ./lenovo/thinkpad/x140e;
248249
lenovo-thinkpad-x200s = import ./lenovo/thinkpad/x200s;
249250
lenovo-thinkpad-x220 = import ./lenovo/thinkpad/x220;

lenovo/thinkpad/x13s/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Lenovo X13s
2+
3+
[Debian](https://wiki.debian.org/InstallingDebianOn/Thinkpad/X13s)
4+
[PostmarketOS](https://wiki.postmarketos.org/wiki/Lenovo_ThinkPad_X13s_(lenovo-21bx))
5+
6+
## Camera
7+
The MIPI camera does work, however, it's not accelerated by the ISP and therefore image processing is done on CPU.
8+
9+
## Wifi and Bluetooth MAC addresses
10+
Currently they need to be set manually

lenovo/thinkpad/x13s/default.nix

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
{ lib, pkgs, ... }:
2+
3+
let
4+
dtbName = "sc8280xp-lenovo-thinkpad-x13s.dtb";
5+
dtb = "${pkgs.linux}/dtbs/qcom/${dtbName}";
6+
# Version the dtb based on the kernel
7+
dtbEfiPath = "dtbs/x13s-${pkgs.linux.version}.dtb";
8+
cfg = {
9+
wifiMac = "e4:65:38:52:22:a9";
10+
bluetoothMac = "E4:25:18:22:44:AA";
11+
};
12+
inherit (lib) mkDefault;
13+
in
14+
{
15+
imports = [
16+
../.
17+
../../../common/pc/laptop
18+
];
19+
20+
boot = {
21+
loader.systemd-boot.extraFiles = {
22+
"${dtbEfiPath}" = dtb;
23+
};
24+
25+
kernelParams = mkDefault [
26+
# needed to boot
27+
"dtb=${dtbEfiPath}"
28+
29+
# jhovold recommended
30+
"clk_ignore_unused"
31+
"pd_ignore_unused"
32+
"arm64.nopauth"
33+
];
34+
35+
kernelModules = mkDefault [
36+
"nvme"
37+
"phy-qcom-qmp-pcie"
38+
"pcie-qcom"
39+
40+
"i2c-core"
41+
"i2c-hid"
42+
"i2c-hid-of"
43+
"i2c-qcom-geni"
44+
45+
"leds_qcom_lpg"
46+
"pwm_bl"
47+
"qrtr"
48+
"pmic_glink_altmode"
49+
"gpio_sbu_mux"
50+
"phy-qcom-qmp-combo"
51+
"gpucc_sc8280xp"
52+
"dispcc_sc8280xp"
53+
"phy_qcom_edp"
54+
"panel-edp"
55+
"msm"
56+
];
57+
};
58+
59+
hardware.enableRedistributableFirmware = mkDefault true;
60+
61+
systemd.services.bluetooth-x13s-mac = lib.mkIf (cfg.bluetoothMac != null) {
62+
wantedBy = [ "multi-user.target" ];
63+
before = [ "bluetooth.service" ];
64+
requiredBy = [ "bluetooth.service" ];
65+
66+
serviceConfig = {
67+
Type = "oneshot";
68+
RemainAfterExit = true;
69+
ExecStart = "${pkgs.util-linux}/bin/script -q -c '${pkgs.bluez}/bin/btmgmt --index 0 public-addr ${cfg.bluetoothMac}'";
70+
};
71+
};
72+
73+
# https://github.com/jhovold/linux/wiki/X13s#modem
74+
networking.networkmanager.fccUnlockScripts = [
75+
76+
{
77+
id = "105b:e0c3";
78+
path = "${pkgs.modemmanager}/share/ModemManager/fcc-unlock.available.d/105b";
79+
}
80+
];
81+
82+
# https://github.com/jhovold/linux/wiki/X13s#camera
83+
services.udev.extraRules = lib.strings.concatLines (
84+
[
85+
''
86+
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="linux,cma", GROUP="video", MODE="0660"
87+
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="system", GROUP="video", MODE="0660"
88+
''
89+
]
90+
++ (
91+
if cfg.wifiMac != null then
92+
[
93+
''
94+
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0006:01:00.0", RUN+="${pkgs.iproute2}/bin/ip link set dev $name address ${cfg.wifiMac}"
95+
''
96+
]
97+
else
98+
[ ]
99+
)
100+
);
101+
}

0 commit comments

Comments
 (0)