Skip to content

Commit 7e5b687

Browse files
6by9Phil Elwell
authored and
Phil Elwell
committed
DT: Add overlays to configure I2C pins
Lifted from https://www.raspberrypi.org/forums/viewtopic.php?f=107&t=120938&p=825883 so not claiming this to be my own work. Adds overlays i2c0-bcm2708 and i2c1-bcm2708 that allow the pin allocations for i2c-0 and i2c-1 to be changed.
1 parent 36babd8 commit 7e5b687

File tree

4 files changed

+91
-0
lines changed

4 files changed

+91
-0
lines changed

arch/arm/boot/dts/overlays/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ dtb-$(RPI_DT_OVERLAYS) += hy28a-overlay.dtb
2929
dtb-$(RPI_DT_OVERLAYS) += hy28b-overlay.dtb
3030
dtb-$(RPI_DT_OVERLAYS) += i2c-rtc-overlay.dtb
3131
dtb-$(RPI_DT_OVERLAYS) += i2c-gpio-overlay.dtb
32+
dtb-$(RPI_DT_OVERLAYS) += i2c0-bcm2708-overlay.dtb
33+
dtb-$(RPI_DT_OVERLAYS) += i2c1-bcm2708-overlay.dtb
3234
dtb-$(RPI_DT_OVERLAYS) += i2s-mmap-overlay.dtb
3335
dtb-$(RPI_DT_OVERLAYS) += iqaudio-dac-overlay.dtb
3436
dtb-$(RPI_DT_OVERLAYS) += iqaudio-dacplus-overlay.dtb

arch/arm/boot/dts/overlays/README

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,22 @@ Params: ds1307 Select the DS1307 device
371371
pcf8563 Select the PCF8563 device
372372

373373

374+
Name: i2c0-bcm2708
375+
Info: Enable the i2c_bcm2708 driver for the i2c0 bus
376+
Load: dtoverlay=i2c0-bcm2708,<param>=<val>
377+
Params: sda0_pin GPIO pin for SDA0 (0, 28 [or 44] - default 0)
378+
scl0_pin GPIO pin for SCL0 (1, 29 [or 45] - default 1)
379+
380+
381+
Name: i2c1-bcm2708
382+
Info: Enable the i2c_bcm2708 driver for the i2c1 bus
383+
Load: dtoverlay=i2c1-bcm2708,<param>=<val>
384+
Params: sda1_pin GPIO pin for SDA1 (2 or 44 - default 2)
385+
scl1_pin GPIO pin for SCL1 (3 or 45 - default 3)
386+
pin_func Alternative pin function (4 (alt0), 6 (alt2) -
387+
default 4)
388+
389+
374390
Name: i2s-mmap
375391
Info: Enables mmap support in the bcm2708-i2s driver
376392
Load: dtoverlay=i2s-mmap
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Device tree overlay for i2c_bcm2708, i2c0 bus
3+
*
4+
* Compile:
5+
* dtc -@ -I dts -O dtb -o i2c0-bcm2708-overlay.dtb i2c0-bcm2708-overlay.dts
6+
*/
7+
8+
/dts-v1/;
9+
/plugin/;
10+
11+
/{
12+
compatible = "brcm,bcm2708";
13+
14+
fragment@0 {
15+
target = <&i2c0>;
16+
__overlay__ {
17+
pinctrl-0 = <&i2c0_pins>;
18+
status = "okay";
19+
};
20+
};
21+
22+
fragment@1 {
23+
target = <&gpio>;
24+
__overlay__ {
25+
i2c0_pins: i2c0 {
26+
brcm,pins = <0 1>;
27+
brcm,function = <4>; /* alt0 */
28+
};
29+
};
30+
};
31+
32+
__overrides__ {
33+
sda0_pin = <&i2c0_pins>,"brcm,pins:0";
34+
scl0_pin = <&i2c0_pins>,"brcm,pins:4";
35+
};
36+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Device tree overlay for i2c_bcm2708, i2c1 bus
3+
*
4+
* Compile:
5+
* dtc -@ -I dts -O dtb -o i2c1-bcm2708-overlay.dtb i2c1-bcm2708-overlay.dts
6+
*/
7+
8+
/dts-v1/;
9+
/plugin/;
10+
11+
/{
12+
compatible = "brcm,bcm2708";
13+
14+
fragment@0 {
15+
target = <&i2c1>;
16+
__overlay__ {
17+
pinctrl-0 = <&i2c1_pins>;
18+
status = "okay";
19+
};
20+
};
21+
22+
fragment@1 {
23+
target = <&gpio>;
24+
__overlay__ {
25+
i2c1_pins: i2c1 {
26+
brcm,pins = <2 3>;
27+
brcm,function = <4>; /* alt0 */
28+
};
29+
};
30+
};
31+
32+
__overrides__ {
33+
sda1_pin = <&i2c1_pins>,"brcm,pins:0";
34+
scl1_pin = <&i2c1_pins>,"brcm,pins:4";
35+
pin_func = <&i2c1_pins>,"brcm,function:0";
36+
};
37+
};

0 commit comments

Comments
 (0)