brcm2708: update linux 4.4 patches to latest version
[librecmc/librecmc.git] / target / linux / brcm2708 / patches-4.4 / 0161-DT-Add-overlays-to-configure-I2C-pins.patch
1 From 2d787b8c422a777f688b185420268dc618d995e4 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <6by9@users.noreply.github.com>
3 Date: Mon, 8 Feb 2016 23:49:41 +0000
4 Subject: [PATCH 161/304] DT: Add overlays to configure I2C pins
5
6 Lifted from
7 https://www.raspberrypi.org/forums/viewtopic.php?f=107&t=120938&p=825883
8 so not claiming this to be my own work.
9 Adds overlays i2c0-bcm2708 and i2c1-bcm2708 that allow the pin
10 allocations for i2c-0 and i2c-1 to be changed.
11 ---
12  arch/arm/boot/dts/overlays/Makefile                |  2 ++
13  arch/arm/boot/dts/overlays/README                  | 16 ++++++++++
14  .../arm/boot/dts/overlays/i2c0-bcm2708-overlay.dts | 36 +++++++++++++++++++++
15  .../arm/boot/dts/overlays/i2c1-bcm2708-overlay.dts | 37 ++++++++++++++++++++++
16  4 files changed, 91 insertions(+)
17  create mode 100644 arch/arm/boot/dts/overlays/i2c0-bcm2708-overlay.dts
18  create mode 100644 arch/arm/boot/dts/overlays/i2c1-bcm2708-overlay.dts
19
20 --- a/arch/arm/boot/dts/overlays/Makefile
21 +++ b/arch/arm/boot/dts/overlays/Makefile
22 @@ -29,6 +29,8 @@ dtb-$(RPI_DT_OVERLAYS) += hy28a-overlay.
23  dtb-$(RPI_DT_OVERLAYS) += hy28b-overlay.dtb
24  dtb-$(RPI_DT_OVERLAYS) += i2c-rtc-overlay.dtb
25  dtb-$(RPI_DT_OVERLAYS) += i2c-gpio-overlay.dtb
26 +dtb-$(RPI_DT_OVERLAYS) += i2c0-bcm2708-overlay.dtb
27 +dtb-$(RPI_DT_OVERLAYS) += i2c1-bcm2708-overlay.dtb
28  dtb-$(RPI_DT_OVERLAYS) += i2s-mmap-overlay.dtb
29  dtb-$(RPI_DT_OVERLAYS) += iqaudio-dac-overlay.dtb
30  dtb-$(RPI_DT_OVERLAYS) += iqaudio-dacplus-overlay.dtb
31 --- a/arch/arm/boot/dts/overlays/README
32 +++ b/arch/arm/boot/dts/overlays/README
33 @@ -371,6 +371,22 @@ Params: ds1307                  Select t
34          pcf8563                 Select the PCF8563 device
35  
36  
37 +Name:   i2c0-bcm2708
38 +Info:   Enable the i2c_bcm2708 driver for the i2c0 bus
39 +Load:   dtoverlay=i2c0-bcm2708,<param>=<val>
40 +Params: sda0_pin                GPIO pin for SDA0 (0, 28 [or 44] - default 0)
41 +        scl0_pin                GPIO pin for SCL0 (1, 29 [or 45] - default 1)
42 +
43 +
44 +Name:   i2c1-bcm2708
45 +Info:   Enable the i2c_bcm2708 driver for the i2c1 bus
46 +Load:   dtoverlay=i2c1-bcm2708,<param>=<val>
47 +Params: sda1_pin                GPIO pin for SDA1 (2 or 44 - default 2)
48 +        scl1_pin                GPIO pin for SCL1 (3 or 45 - default 3)
49 +        pin_func                Alternative pin function (4 (alt0), 6 (alt2) -
50 +                                default 4)
51 +
52 +
53  Name:   i2s-mmap
54  Info:   Enables mmap support in the bcm2708-i2s driver
55  Load:   dtoverlay=i2s-mmap
56 --- /dev/null
57 +++ b/arch/arm/boot/dts/overlays/i2c0-bcm2708-overlay.dts
58 @@ -0,0 +1,36 @@
59 +/*
60 + * Device tree overlay for i2c_bcm2708, i2c0 bus
61 + *
62 + * Compile:
63 + * dtc -@ -I dts -O dtb -o i2c0-bcm2708-overlay.dtb i2c0-bcm2708-overlay.dts
64 + */
65 +
66 +/dts-v1/;
67 +/plugin/;
68 +
69 +/{
70 +   compatible = "brcm,bcm2708";
71 +
72 +   fragment@0 {
73 +      target = <&i2c0>;
74 +      __overlay__ {
75 +         pinctrl-0 = <&i2c0_pins>;
76 +         status = "okay";
77 +      };
78 +   };
79 +
80 +   fragment@1 {
81 +      target = <&gpio>;
82 +      __overlay__ {
83 +         i2c0_pins: i2c0 {
84 +            brcm,pins = <0 1>;
85 +            brcm,function = <4>; /* alt0 */
86 +         };
87 +      };
88 +   };
89 +
90 +   __overrides__ {
91 +      sda0_pin = <&i2c0_pins>,"brcm,pins:0";
92 +      scl0_pin = <&i2c0_pins>,"brcm,pins:4";
93 +   };
94 +};
95 --- /dev/null
96 +++ b/arch/arm/boot/dts/overlays/i2c1-bcm2708-overlay.dts
97 @@ -0,0 +1,37 @@
98 +/*
99 + * Device tree overlay for i2c_bcm2708, i2c1 bus
100 + *
101 + * Compile:
102 + * dtc -@ -I dts -O dtb -o i2c1-bcm2708-overlay.dtb i2c1-bcm2708-overlay.dts
103 + */
104 +
105 +/dts-v1/;
106 +/plugin/;
107 +
108 +/{
109 +   compatible = "brcm,bcm2708";
110 +
111 +   fragment@0 {
112 +      target = <&i2c1>;
113 +      __overlay__ {
114 +         pinctrl-0 = <&i2c1_pins>;
115 +         status = "okay";
116 +      };
117 +   };
118 +
119 +   fragment@1 {
120 +      target = <&gpio>;
121 +      __overlay__ {
122 +         i2c1_pins: i2c1 {
123 +            brcm,pins = <2 3>;
124 +            brcm,function = <4>; /* alt0 */
125 +         };
126 +      };
127 +   };
128 +
129 +   __overrides__ {
130 +      sda1_pin = <&i2c1_pins>,"brcm,pins:0";
131 +      scl1_pin = <&i2c1_pins>,"brcm,pins:4";
132 +      pin_func = <&i2c1_pins>,"brcm,function:0";
133 +   };
134 +};