Skip to content

Commit 98f291e

Browse files
committed
mnt/reform: init
1 parent 170ff93 commit 98f291e

File tree

13 files changed

+1380
-0
lines changed

13 files changed

+1380
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ See code for all available configurations.
375375
| [Microsoft Surface Pro 9](microsoft/surface-pro/9) | `<nixos-hardware/microsoft/surface-pro/9>` | `microsoft-surface-pro-9` |
376376
| [Morefine M600](morefine/m600) | `<nixos-hardware/morefine/m600>` | `morefine-m600` |
377377
| [Minisforum V3](minisforum/v3) | `<nixos-hardware/minisforum/v3>` | `minisforum-v3` |
378+
| [MNT Reform](mnt/reform) | `<nixos-hardware/mnt/reform` | `mnt-reform` |
378379
| [MECHREVO Yilong15Pro](mechrevo/GM5HG0A) | `<nixos-hardware/mechrevo/GM5HG0A>` | `mechrevo-gm5hg0a` |
379380
| [NXP iMX8 MPlus Evaluation Kit](nxp/imx8mp-evk) | `<nixos-hardware/nxp/imx8mp-evk>` | `nxp-imx8mp-evk` |
380381
| [NXP iMX8 MQuad Evaluation Kit](nxp/imx8mq-evk) | `<nixos-hardware/nxp/imx8mq-evk>` | `nxp-imx8mq-evk` |

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@
312312
microsoft-surface-pro-9 = import ./microsoft/surface-pro/9;
313313
milkv-pioneer = import ./milkv/pioneer;
314314
minisforum-v3 = import ./minisforum/v3;
315+
mnt-reform = import ./mnt/reform;
315316
morefine-m600 = import ./morefine/m600;
316317
msi-b350-tomahawk = import ./msi/b350-tomahawk;
317318
msi-b550-a-pro = import ./msi/b550-a-pro;

mnt/reform/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# MNT Reform Laptop
2+
3+
Currently the only supported CPU-module is RK3588. Feel free to add additional modules.

mnt/reform/default.nix

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}:
7+
let
8+
cfg = config.hardware.mnt-reform;
9+
in
10+
{
11+
imports = [ ./rk3588 ];
12+
options.hardware.mnt-reform = {
13+
module = lib.mkOption {
14+
description = "The installed CPU-Module of the MNT Reform Laptop";
15+
type = lib.types.nullOr (lib.types.enum [ "RK3588" ]);
16+
example = "RK3588";
17+
};
18+
};
19+
config = lib.mkIf (cfg.module != null) {
20+
boot.kernelPackages = pkgs.callPackage ./kernel.nix { };
21+
boot.extraModulePackages = [ (config.boot.kernelPackages.callPackage ./lpc.nix { }) ];
22+
};
23+
}

mnt/reform/dtsPatch.nix

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
stdenv,
3+
reformDebianPackages,
4+
kernelSource,
5+
quilt,
6+
}:
7+
stdenv.mkDerivation {
8+
name = "mnt-dts-patch";
9+
nativeBuildInputs = [ quilt ];
10+
buildCommand = ''
11+
cp -r --reflink=auto ${reformDebianPackages}/linux/* .
12+
mkdir -p linux/debian/patches/reform
13+
cp -r --reflink=auto ${kernelSource}/* linux
14+
chmod +w -R .
15+
env --chdir=linux QUILT_PATCHES=debian/patches quilt new reform/dts.patch
16+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/freescale/fsl-ls1028a-mnt-reform2.dts
17+
cp fsl-ls1028a-mnt-reform2.dts linux/arch/arm64/boot/dts/freescale/fsl-ls1028a-mnt-reform2.dts
18+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/freescale/imx8mq-mnt-reform2-hdmi.dts
19+
cp imx8mq-mnt-reform2-hdmi.dts linux/arch/arm64/boot/dts/freescale/imx8mq-mnt-reform2-hdmi.dts
20+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/freescale/Makefile
21+
sed -i '/fsl-ls1028a-rdb.dtb/a dtb-$(CONFIG_ARCH_LAYERSCAPE) += fsl-ls1028a-mnt-reform2.dtb' linux/arch/arm64/boot/dts/freescale/Makefile
22+
sed -i '/imx8mq-mnt-reform2.dtb/a dtb-$(CONFIG_ARCH_MXC) += imx8mq-mnt-reform2-hdmi.dtb' linux/arch/arm64/boot/dts/freescale/Makefile
23+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/freescale/imx8mp-mnt-pocket-reform.dts
24+
cp imx8mp-mnt-pocket-reform.dts linux/arch/arm64/boot/dts/freescale/imx8mp-mnt-pocket-reform.dts
25+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/freescale/imx8mp-mnt-reform2.dts
26+
cp imx8mp-mnt-reform2.dts linux/arch/arm64/boot/dts/freescale/imx8mp-mnt-reform2.dts
27+
sed -i '/imx8mq-mnt-reform2.dtb/a dtb-$(CONFIG_ARCH_MXC) += imx8mp-mnt-pocket-reform.dtb' linux/arch/arm64/boot/dts/freescale/Makefile
28+
sed -i '/imx8mq-mnt-reform2.dtb/a dtb-$(CONFIG_ARCH_MXC) += imx8mp-mnt-reform2.dtb' linux/arch/arm64/boot/dts/freescale/Makefile
29+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/amlogic/meson-g12b-bananapi-cm4-mnt-pocket-reform.dts
30+
cp meson-g12b-bananapi-cm4-mnt-pocket-reform.dts linux/arch/arm64/boot/dts/amlogic/meson-g12b-bananapi-cm4-mnt-pocket-reform.dts
31+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/amlogic/Makefile
32+
sed -i '/meson-g12b-bananapi-cm4-mnt-reform2.dtb/a dtb-$(CONFIG_ARCH_MESON) += meson-g12b-bananapi-cm4-mnt-pocket-reform.dtb' linux/arch/arm64/boot/dts/amlogic/Makefile
33+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/rockchip/rk3588-mnt-reform2.dts
34+
cp rk3588-mnt-reform2.dts linux/arch/arm64/boot/dts/rockchip/rk3588-mnt-reform2.dts
35+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/rockchip/rk3588-mnt-reform2-dsi.dts
36+
cp rk3588-mnt-reform2-dsi.dts linux/arch/arm64/boot/dts/rockchip/rk3588-mnt-reform2-dsi.dts
37+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/rockchip/rk3588-mnt-pocket-reform.dts
38+
cp rk3588-mnt-pocket-reform.dts linux/arch/arm64/boot/dts/rockchip/rk3588-mnt-pocket-reform.dts
39+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/rockchip/rk3588-mnt-reform-next.dts
40+
cp rk3588-mnt-reform-next.dts linux/arch/arm64/boot/dts/rockchip/rk3588-mnt-reform-next.dts
41+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/rockchip/Makefile
42+
sed -i '/rk3588-mnt-reform2.dtb/a dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588-mnt-reform2-dsi.dtb' linux/arch/arm64/boot/dts/rockchip/Makefile
43+
sed -i '/rk3588-mnt-reform2-dsi.dtb/a dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588-mnt-reform-next.dtb' linux/arch/arm64/boot/dts/rockchip/Makefile
44+
sed -i '/rk3588-mnt-reform-next.dtb/a dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588-mnt-pocket-reform.dtb' linux/arch/arm64/boot/dts/rockchip/Makefile
45+
env --chdir=linux QUILT_PATCHES=debian/patches quilt refresh
46+
cp linux/debian/patches/reform/dts.patch $out
47+
'';
48+
}

mnt/reform/kernel.nix

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
{
2+
lib,
3+
callPackage,
4+
linuxPackagesFor,
5+
kernelPatches,
6+
fetchFromGitLab,
7+
...
8+
}:
9+
let
10+
modDirVersion = "6.16.5";
11+
reformDebianPackages = fetchFromGitLab {
12+
domain = "source.mnt.re";
13+
owner = "reform";
14+
repo = "reform-debian-packages";
15+
rev = "830c94db42beef876dc58ea56711659ae7bd415d";
16+
hash = "sha256-mdORgTOM7RJnEjY5G/iWMHf69wQkql11yRpQ/DrQKb4=";
17+
};
18+
linuxPkg =
19+
{
20+
lib,
21+
fetchzip,
22+
buildLinux,
23+
callPackage,
24+
...
25+
}@args:
26+
buildLinux (
27+
args
28+
// rec {
29+
version = "${modDirVersion}-mnt-reform";
30+
inherit modDirVersion;
31+
32+
src = fetchzip {
33+
url = "mirror://kernel/linux/kernel/v${lib.versions.major modDirVersion}.x/linux-${modDirVersion}.tar.xz";
34+
hash = "sha256-XiTuH40b3VJqzwygZzU0FcvMDj41Rq6IsMbm+3+QxDY=";
35+
};
36+
37+
kernelPatches =
38+
(map (patch: { inherit patch; }) (
39+
lib.filesystem.listFilesRecursive "${reformDebianPackages}/linux/patches${lib.versions.majorMinor modDirVersion}"
40+
))
41+
++ [
42+
{
43+
patch = callPackage ./dtsPatch.nix {
44+
inherit reformDebianPackages;
45+
kernelSource = src;
46+
};
47+
}
48+
];
49+
50+
structuredExtraConfig = with lib.kernel; {
51+
# configuration options from https://source.mnt.re/reform/reform-debian-packages/-/blob/7f31ba3a6742d60d8d502c1d86e63ef5df3916bf/linux/config
52+
DRM_LVDS_CODEC = module;
53+
DRM_CDNS_MHDP8546 = module;
54+
DRM_CDNS_HDMI_CEC = module;
55+
DRM_IMX_CDNS_MHDP = module;
56+
DRM_IMX_DCSS = module;
57+
# PHY_FSL_IMX8MQ_HDPTX = module; # configuration option does not exist
58+
DRM_PANEL_LVDS = module;
59+
I2C_IMX_LPI2C = module;
60+
I2C_MUX_REG = module;
61+
INTERCONNECT_IMX = yes;
62+
INTERCONNECT_IMX8MQ = yes;
63+
MFD_WM8994 = module;
64+
MUX_GPIO = module;
65+
MUX_MMIO = module;
66+
RTC_DRV_PCF8523 = module;
67+
USB_EHCI_FSL = module;
68+
# NO_HZ_IDLE = yes; # conflicts with NO_HZ_FULL
69+
SND_SOC_FSL_MICFIL = module;
70+
SND_IMX_SOC = module;
71+
SND_SOC_FSL_ASOC_CARD = module;
72+
SND_SOC_IMX_AUDMIX = module;
73+
SND_SOC_IMX_HDMI = module;
74+
INPUT_JOYSTICK = yes;
75+
JOYSTICK_XPAD = module;
76+
JOYSTICK_XPAD_FF = yes;
77+
JOYSTICK_XPAD_LEDS = yes;
78+
79+
INTERCONNECT_IMX8MP = yes;
80+
SND_SOC_FSL_ASRC = yes;
81+
DRM_IMX_LCDIF = yes;
82+
DRM_IMX8MP_DW_HDMI_BRIDGE = yes;
83+
DRM_IMX8MP_HDMI_PVI = yes;
84+
IMX8MM_THERMAL = yes;
85+
IMX2_WDT = yes;
86+
DRM_SAMSUNG_DSIM = yes;
87+
PHY_FSL_SAMSUNG_HDMI_PHY = yes;
88+
DRM = yes;
89+
DRM_PANEL_MNT_POCKET_REFORM = module;
90+
IMX8M_BLK_CTRL = yes;
91+
IMX_GPCV2_PM_DOMAINS = yes;
92+
DRM_DISPLAY_CONNECTOR = yes;
93+
DRM_FSL_LDB = yes;
94+
BACKLIGHT_CLASS_DEVICE = yes;
95+
BACKLIGHT_PWM = yes;
96+
BACKLIGHT_GPIO = yes;
97+
BACKLIGHT_LED = yes;
98+
CPU_FREQ_GOV_PERFORMANCE = yes;
99+
CPU_FREQ_GOV_POWERSAVE = yes;
100+
CPU_FREQ_GOV_USERSPACE = yes;
101+
CPU_FREQ_GOV_ONDEMAND = yes;
102+
CPU_FREQ_GOV_CONSERVATIVE = yes;
103+
CPU_FREQ_GOV_SCHEDUTIL = yes;
104+
ARM_IMX_CPUFREQ_DT = yes;
105+
ARM_IMX_BUS_DEVFREQ = yes;
106+
IMX_IRQSTEER = yes;
107+
108+
PCI_MESON = yes;
109+
DWMAC_MESON = module;
110+
MDIO_BUS_MUX_MESON_G12A = yes;
111+
I2C_MESON = yes;
112+
PWM_MESON = yes;
113+
USB_DWC3_MESON_G12A = yes;
114+
MMC_MESON_GX = yes;
115+
MMC_MESON_MX_SDIO = yes;
116+
MESON_DDR_PMU = yes;
117+
RTW88_8822CS = module;
118+
119+
PWM_FSL_FTM = yes;
120+
FSL_RCPM = yes;
121+
122+
ARCH_ROCKCHIP = yes;
123+
# ARM_ROCKCHIP_CPUFREQ = module; # configuration option does not exist
124+
DRM_PANTHOR = module;
125+
NVMEM_ROCKCHIP_OTP = yes;
126+
PHY_ROCKCHIP_SAMSUNG_HDPTX = module;
127+
PHY_ROCKCHIP_USBDP = module;
128+
REGULATOR = yes;
129+
# ROCKCHIP_REGULATOR_COUPLER = yes; # configuration option does not exist
130+
SPI_ROCKCHIP = yes;
131+
SPI_ROCKCHIP_SFC = module;
132+
ARM_SCMI_CPUFREQ = module;
133+
VIDEO_ROCKCHIP_VDEC2 = module;
134+
ROCKCHIP_DW_HDMI_QP = yes;
135+
ROCKCHIP_DW_MIPI_DSI2 = yes;
136+
PHY_ROCKCHIP_SAMSUNG_DCPHY = yes;
137+
REGULATOR_FIXED_VOLTAGE = yes;
138+
GPIO_ROCKCHIP = yes;
139+
PL330_DMA = yes;
140+
141+
DRM_MEGACHIPS_STDPXXXX_GE_B850V3_FW = no; # patches for 6.16 break this driver
142+
};
143+
}
144+
// (args.argsOverride or { })
145+
);
146+
147+
in
148+
lib.recurseIntoAttrs (linuxPackagesFor (callPackage linuxPkg { }))

mnt/reform/lpc.nix

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
stdenv,
3+
lib,
4+
fetchFromGitLab,
5+
kernel,
6+
kernelModuleMakeFlags,
7+
kmod,
8+
}:
9+
10+
stdenv.mkDerivation rec {
11+
name = "lpc";
12+
13+
src = fetchFromGitLab {
14+
domain = "source.mnt.re";
15+
owner = "reform";
16+
repo = "reform-tools";
17+
rev = "45f930403492aa2156522bfe30edb02e33494b69";
18+
hash = "sha256-no33CsV69nu1TR0cqxQDd1bFXqhjqOW9IUDxds0fyxE=";
19+
};
20+
21+
sourceRoot = "source/lpc";
22+
hardeningDisable = [
23+
"pic"
24+
"format"
25+
];
26+
nativeBuildInputs = kernel.moduleBuildDependencies;
27+
28+
installPhase = ''
29+
make -C "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" M="$(pwd)" INSTALL_MOD_PATH=$out modules_install $makeFlags
30+
'';
31+
32+
makeFlags = kernelModuleMakeFlags ++ [
33+
"KERNEL_DIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
34+
"INSTALL_MOD_PATH=${placeholder "out"}"
35+
];
36+
}

mnt/reform/rk3588/README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# MNT Reform Laptop with RK3588 CPU module
2+
## Use in system configuration
3+
4+
``` nix
5+
{
6+
imports = [ nixos-hardware.nixosModules.mnt-reform ];
7+
hardware.mnt-reform.module = "RK3588";
8+
}
9+
```
10+
11+
## Creating an installer SD-Image
12+
13+
Create and configure the `flake.nix` file:
14+
``` nix
15+
{
16+
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
17+
inputs.nixos-hardware.url = "github:nixos/nixos-hardware";
18+
inputs.flake-utils.url = "github:numtide/flake-utils";
19+
20+
outputs = { self, nixpkgs, nixos-hardware, flake-utils, ... }:
21+
flake-utils.lib.eachDefaultSystem (system:
22+
rec {
23+
packages.default = packages.installer;
24+
packages.installer = (import "${nixpkgs}/nixos" {
25+
configuration =
26+
{ config, ... }: {
27+
imports = [
28+
"${nixos-hardware}/mnt/reform/rk3588/installer.nix"
29+
];
30+
31+
# If you want to use ssh set a password
32+
# users.users.nixos.password = "super secure password";
33+
# OR add your public ssh key
34+
# users.users.nixos.openssh.authorizedKeys.keys = [ "ssh-rsa ..." ];
35+
36+
# Additional configuration goes here
37+
38+
# Only used when cross compiling
39+
nixpkgs.crossSystem = {
40+
config = "aarch64-unknown-linux-gnu";
41+
system = "aarch64-linux";
42+
};
43+
44+
system.stateVersion = "23.05";
45+
};
46+
inherit system;
47+
}).config.system.build.image;;
48+
});
49+
}
50+
```
51+
52+
Build the installer image.
53+
54+
``` sh
55+
nix build .#
56+
```

mnt/reform/rk3588/default.nix

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}:
7+
let
8+
cfg = config.hardware.mnt-reform;
9+
in
10+
{
11+
config = lib.mkIf (cfg.module == "RK3588") {
12+
13+
boot = {
14+
# kernelParams = [ "console=ttyS2,1500000n8" ];
15+
kernelParams = [
16+
"no_console_suspend"
17+
"console=tty1"
18+
];
19+
# kernel modules needed for the virtual console
20+
initrd.availableKernelModules = [
21+
"panel-edp"
22+
"phy-rockchip-samsung-hdptx"
23+
"rockchipdrm"
24+
"ti-sn65dsi86"
25+
];
26+
27+
};
28+
boot.loader = {
29+
grub.enable = false;
30+
generic-extlinux-compatible.enable = true;
31+
};
32+
hardware.alsa.enablePersistence = true;
33+
system.activationScripts.asound = ''
34+
if [ ! -e "/var/lib/alsa/asound.state" ]; then
35+
mkdir -p /var/lib/alsa
36+
cp ${./initial-asound.state} /var/lib/alsa/asound.state
37+
fi
38+
'';
39+
};
40+
}

0 commit comments

Comments
 (0)