r1 device tree examples
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 1 Dec 2017 09:19:38 +0000 (10:19 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 1 Dec 2017 09:20:11 +0000 (10:20 +0100)
device-tree/gpio-button.dts [new file with mode: 0644]
device-tree/gpio-led.dts [new file with mode: 0644]
device-tree/i2c-tmp75.dts [new file with mode: 0644]

diff --git a/device-tree/gpio-button.dts b/device-tree/gpio-button.dts
new file mode 100644 (file)
index 0000000..e86fdb4
--- /dev/null
@@ -0,0 +1,48 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+       compatible = "allwinner,sun4i-a10", "allwinner,sun7i-a20", "allwinner,sun50i-a64", "allwinner,sun50i-h5";
+
+       /*
+        * This fragment is needed only for the internal pull-up activation,
+        * external pull-up resistor is highly recommended if using long wires
+        */
+       fragment@0 {
+               target = <&pio>;
+               __overlay__ {
+                       gpio_button_0: gpio_button_0 {
+                               pins = "PH3", "PH5";
+                               function = "gpio_in";
+                               bias-pull-up;
+                       };
+               };
+       };
+
+       fragment@1 {
+               target-path = "/";
+               __overlay__ {
+                       gpio-keys-user {
+                               /*
+                                * Use "gpio-keys" for EINT capable pins, "gpio-keys-polled" for other pins
+                                * add "poll-interval" property if using "gpio-keys-polled"
+                                */
+                               compatible = "gpio-keys";
+                               pinctrl-names = "default";
+                               pinctrl-0 = <&gpio_button_0>;
+
+                               up {
+                                       label = "button-up";
+                                       linux,code = <103>; /* KEY_UP, see include/uapi/linux/input-event-codes.h */
+                                       gpios = <&pio 7 3 1>; /* PH3 GPIO_ACTIVE_LOW */
+                               };
+
+                               down {
+                                       label = "button-down";
+                                       linux,code = <108>; /* KEY_DOWN, see include/uapi/linux/input-event-codes.h */
+                                       gpios = <&pio 7 5 1>; /* PH5 GPIO_ACTIVE_LOW */
+                               };
+                       };
+               };
+       };
+};
diff --git a/device-tree/gpio-led.dts b/device-tree/gpio-led.dts
new file mode 100644 (file)
index 0000000..002f0cc
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * add few leds
+ */
+
+/dts-v1/;
+/plugin/;
+
+/ {
+       compatible = "allwinner,sun4i-a10", "allwinner,sun7i-a20", "allwinner,sun50i-a64", "allwinner,sun50i-h5";
+
+       /* Documentation/devicetree/bindings/leds/leds-gpio.txt */
+       fragment@0 {
+               target-path = "/";
+
+               __overlay__ {
+                       user-leds {
+                               compatible = "gpio-leds";
+
+                               leds@0 {
+                                       label = "gpio:red-top";
+                                       gpios = <&pio 8 20 0>; /* PI20 GPIO_ACTIVE_HIGH */
+                                       linux,default-trigger = "mmc0";
+                               };
+
+                               leds@1 {
+                                       label = "gpio:green-bottom";
+                                       gpios = <&pio 8 21 0>; /* PI21 GPIO_ACTIVE_HIGH */
+                                       linux,default-trigger = "cpu";
+                               };
+                       };
+               };
+       };
+};
diff --git a/device-tree/i2c-tmp75.dts b/device-tree/i2c-tmp75.dts
new file mode 100644 (file)
index 0000000..dbb72bc
--- /dev/null
@@ -0,0 +1,19 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+       compatible = "allwinner,sun4i-a10", "allwinner,sun7i-a20", "allwinner,sun50i-a64", "allwinner,sun50i-h5";
+
+       fragment@0 {
+               target = <&i2c2>;
+               __overlay__ {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       tmp75@49 {
+                               compatible = "ti,tmp75";
+                               reg = <0x49>;
+                               status = "okay";
+                       };
+               };
+       };
+};