mirror of
https://github.com/NixOS/nixos-hardware
synced 2024-11-26 21:09:42 +01:00
raspberry-pi/4/i2c1: factor out easy dts into helper, add i2c0
This commit is contained in:
parent
e81c9aed16
commit
41c4e294f4
4 changed files with 47 additions and 22 deletions
|
@ -4,6 +4,7 @@
|
|||
imports = [
|
||||
./audio.nix
|
||||
./dwc2.nix
|
||||
./i2c0.nix
|
||||
./i2c1.nix
|
||||
./modesetting.nix
|
||||
./poe-hat.nix
|
||||
|
|
25
raspberry-pi/4/i2c0.nix
Normal file
25
raspberry-pi/4/i2c0.nix
Normal file
|
@ -0,0 +1,25 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.hardware.raspberry-pi."4".i2c0;
|
||||
inherit (import ./overlay.nix) simple-pi4-overlay;
|
||||
in
|
||||
{
|
||||
options.hardware = {
|
||||
raspberry-pi."4".i2c0 = {
|
||||
enable = lib.mkEnableOption ''
|
||||
Turn on the VideoCore I2C bus (maps to /dev/i2c-22) and enable access from the i2c group.
|
||||
After a reboot, i2c-tools (e.g. i2cdetect -F 22) should work for root or any user in i2c.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
hardware = {
|
||||
i2c.enable = lib.mkDefault true;
|
||||
deviceTree = {
|
||||
overlays = [ (simple-pi4-overlay { target = "i2c0if"; status = "okay"; }) ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
let
|
||||
cfg = config.hardware.raspberry-pi."4".i2c1;
|
||||
inherit (import ./overlay.nix) simple-pi4-overlay;
|
||||
in
|
||||
{
|
||||
options.hardware = {
|
||||
|
@ -15,29 +16,9 @@ in
|
|||
|
||||
config = lib.mkIf cfg.enable {
|
||||
hardware = {
|
||||
i2c.enable = true;
|
||||
i2c.enable = lib.mkDefault true;
|
||||
deviceTree = {
|
||||
overlays = [
|
||||
# Equivalent to dtparam=i2c1=on
|
||||
{
|
||||
name = "i2c1-on-overlay";
|
||||
dtsText = ''
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
/ {
|
||||
compatible = "brcm,bcm2711";
|
||||
fragment@0 {
|
||||
target = <&i2c1>;
|
||||
__overlay__ {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
||||
'';
|
||||
}
|
||||
];
|
||||
overlays = [ (simple-pi4-overlay { target = "i2c1"; status = "okay"; }) ];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
18
raspberry-pi/4/overlay.nix
Normal file
18
raspberry-pi/4/overlay.nix
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
simple-pi4-overlay = { target, status }: {
|
||||
name = "${target}-${status}-overlay";
|
||||
dtsText = ''
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
/ {
|
||||
compatible = "brcm,bcm2711";
|
||||
fragment@0 {
|
||||
target = <&${target}>;
|
||||
__overlay__ {
|
||||
status = "${status}";
|
||||
};
|
||||
};
|
||||
};
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue