rpi4: Add option to turn on the ARM I2C bus (i2c1).

This commit is contained in:
M. Ian Graham 2021-12-11 00:51:56 +09:00
parent 4c9f07277b
commit 1bc731fde4
2 changed files with 45 additions and 0 deletions

View File

@ -4,6 +4,7 @@
imports = [
./audio.nix
./dwc2.nix
./i2c1.nix
./modesetting.nix
./poe-hat.nix
./tc358743.nix

44
raspberry-pi/4/i2c1.nix Normal file
View File

@ -0,0 +1,44 @@
{ config, lib, pkgs, ... }:
let
cfg = config.hardware.raspberry-pi."4".i2c1;
in
{
options.hardware = {
raspberry-pi."4".i2c1 = {
enable = lib.mkEnableOption ''
Turn on the ARM I2C bus (/dev/i2c-1 on GPIO pins 3 and 5) and enable access from the i2c group.
After a reboot, i2c-tools (e.g. i2cdetect -F 1) should work for root or any user in i2c.
'';
};
};
config = lib.mkIf cfg.enable {
hardware = {
i2c.enable = 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";
};
};
};
'';
}
];
};
};
};
}