Skip to content

Commit c90bc89

Browse files
anangltejlmand
authored andcommitted
[nrf fromlist] boards: nrf9160dk: Add DT node for I/O expander ...
... available in v0.14.0+ Upstream PR: zephyrproject-rtos/zephyr#31624 Add devicetree node representing the PCAL6408A I2C-based I/O expander that is available in nRF9160 DK v0.14.0 or later. Provide also .dtsi files that can be used in applications to simplify switching to interfacing onboard LEDs and buttons through this expander instead of SoC pins. Signed-off-by: Andrzej Głąbek <[email protected]>
1 parent a27a09c commit c90bc89

File tree

6 files changed

+132
-0
lines changed

6 files changed

+132
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2021 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/* NOTE: this feature is only available in nRF9160 DK v0.14.0 or later. */
8+
9+
&switch1_pin_routing {
10+
status = "disabled";
11+
};
12+
13+
&switch2_pin_routing {
14+
status = "disabled";
15+
};
16+
17+
&button1_pin_routing {
18+
status = "disabled";
19+
};
20+
21+
&button2_pin_routing {
22+
status = "disabled";
23+
};
24+
25+
&io_expander_pins_routing {
26+
status = "okay";
27+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2021 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/* NOTE: this feature is only available in nRF9160 DK v0.14.0 or later. */
8+
9+
&led1_pin_routing {
10+
status = "disabled";
11+
};
12+
13+
&led2_pin_routing {
14+
status = "disabled";
15+
};
16+
17+
&led3_pin_routing {
18+
status = "disabled";
19+
};
20+
21+
&led4_pin_routing {
22+
status = "disabled";
23+
};
24+
25+
&io_expander_pins_routing {
26+
status = "okay";
27+
};

boards/arm/nrf9160dk_nrf9160/Kconfig.defconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,10 @@ endif # BOARD_NRF9160DK_NRF9160NS
3838
config BT_WAIT_NOP
3939
default BT && $(dt_nodelabel_enabled,nrf52840_reset)
4040

41+
# Workaround for not being able to have commas in macro arguments
42+
DT_COMPAT_NXP_PCAL6408A := nxp,pcal6408a
43+
44+
config I2C
45+
default $(dt_compat_on_bus,$(DT_COMPAT_NXP_PCAL6408A),i2c)
46+
4147
endif # BOARD_NRF9160DK_NRF9160 || BOARD_NRF9160DK_NRF9160NS
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2021 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/* NOTE: this feature is only available in nRF9160 DK v0.14.0 or later. */
8+
9+
&pcal6408a {
10+
status = "okay";
11+
};
12+
13+
&button0 {
14+
gpios = <&pcal6408a 2 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
15+
};
16+
17+
&button1 {
18+
gpios = <&pcal6408a 3 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
19+
};
20+
21+
&button2 {
22+
gpios = <&pcal6408a 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
23+
};
24+
25+
&button3 {
26+
gpios = <&pcal6408a 1 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
27+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2021 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/* NOTE: this feature is only available in nRF9160 DK v0.14.0 or later. */
8+
9+
&pcal6408a {
10+
status = "okay";
11+
};
12+
13+
&led0 {
14+
gpios = <&pcal6408a 4 GPIO_ACTIVE_HIGH>;
15+
};
16+
17+
&led1 {
18+
gpios = <&pcal6408a 5 GPIO_ACTIVE_HIGH>;
19+
};
20+
21+
&led2 {
22+
gpios = <&pcal6408a 6 GPIO_ACTIVE_HIGH>;
23+
};
24+
25+
&led3 {
26+
gpios = <&pcal6408a 7 GPIO_ACTIVE_HIGH>;
27+
};

boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common_0_14_0.dtsi

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,24 @@
2121
gpios = <&interface_to_nrf52840 9 GPIO_ACTIVE_LOW>;
2222
};
2323

24+
&i2c2 {
25+
status = "okay";
26+
clock-frequency = <I2C_BITRATE_FAST>;
27+
sda-pin = <30>;
28+
scl-pin = <31>;
29+
30+
pcal6408a: pcal6408a@20 {
31+
compatible = "nxp,pcal6408a";
32+
status = "disabled";
33+
reg = <0x20>;
34+
label = "GPIO_P0";
35+
gpio-controller;
36+
#gpio-cells = <2>;
37+
ngpios = <8>;
38+
int-gpios = <&gpio0 6 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
39+
};
40+
};
41+
2442
&spi3 {
2543
status = "okay";
2644
sck-pin = <13>;

0 commit comments

Comments
 (0)