Skip to content

Instantly share code, notes, and snippets.

@sorki
Last active February 7, 2020 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sorki/c72dfbf1af51f7a42693622fbd020f07 to your computer and use it in GitHub Desktop.
Save sorki/c72dfbf1af51f7a42693622fbd020f07 to your computer and use it in GitHub Desktop.
overlays prototype
hardware.deviceTree.overlays = [
{ name = "spi"; dtsFile = ./dt/spi.dts; }
{ name = "pps";
dtsText = ''
/dts-v1/;
/plugin/;
/ {
compatible = "raspberrypi";
fragment@0 {
target-path = "/soc";
__overlay__ {
pps {
compatible = "pps-gpio";
status = "okay";
pinctl-name = "default";
pinctrl-0 = <&pps_pins>;
gpios = <&gpio 18 0>;
assert-falling-edge;
};
};
};
fragment@1 {
target = <&gpio>;
__overlay__ {
pps_pins: pps_pins {
brcm,pins = <18>;
brcm,function = <0>; // input
brcm,pull = <0>; // off
};
};
};
};
'';
}
];
/dts-v1/;
/plugin/;
/ {
compatible = "raspberrypi";
fragment@0 {
target = <&spi>;
__overlay__ {
cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
#address-cells = <1>;
#size-cells = <0>;
spidev@0 {
reg = <0>; // CE0
spi-max-frequency = <500000>;
compatible = "spidev";
};
spidev@1 {
reg = <1>; // CE1
spi-max-frequency = <500000>;
compatible = "spidev";
};
};
};
fragment@1 {
target = <&alt0>;
__overlay__ {
// Drop GPIO 7, SPI 8-11
brcm,pins = <4 5>;
};
};
fragment@2 {
target = <&gpio>;
__overlay__ {
spi0_pins: spi0_pins {
brcm,pins = <9 10 11>;
brcm,function = <4>; // alt0
};
spi0_cs_pins: spi0_cs_pins {
brcm,pins = <8 7>;
brcm,function = <1>; // out
};
};
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment