Skip to content

Commit

Permalink
[nrf fromlist] boards: nrf9160dk: Add DT node for I/O expander ...
Browse files Browse the repository at this point in the history
... 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]>
  • Loading branch information
anangl authored and tejlmand committed Feb 11, 2021
1 parent a27a09c commit c90bc89
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2021 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

/* NOTE: this feature is only available in nRF9160 DK v0.14.0 or later. */

&switch1_pin_routing {
status = "disabled";
};

&switch2_pin_routing {
status = "disabled";
};

&button1_pin_routing {
status = "disabled";
};

&button2_pin_routing {
status = "disabled";
};

&io_expander_pins_routing {
status = "okay";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2021 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

/* NOTE: this feature is only available in nRF9160 DK v0.14.0 or later. */

&led1_pin_routing {
status = "disabled";
};

&led2_pin_routing {
status = "disabled";
};

&led3_pin_routing {
status = "disabled";
};

&led4_pin_routing {
status = "disabled";
};

&io_expander_pins_routing {
status = "okay";
};
6 changes: 6 additions & 0 deletions boards/arm/nrf9160dk_nrf9160/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@ endif # BOARD_NRF9160DK_NRF9160NS
config BT_WAIT_NOP
default BT && $(dt_nodelabel_enabled,nrf52840_reset)

# Workaround for not being able to have commas in macro arguments
DT_COMPAT_NXP_PCAL6408A := nxp,pcal6408a

config I2C
default $(dt_compat_on_bus,$(DT_COMPAT_NXP_PCAL6408A),i2c)

endif # BOARD_NRF9160DK_NRF9160 || BOARD_NRF9160DK_NRF9160NS
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2021 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

/* NOTE: this feature is only available in nRF9160 DK v0.14.0 or later. */

&pcal6408a {
status = "okay";
};

&button0 {
gpios = <&pcal6408a 2 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
};

&button1 {
gpios = <&pcal6408a 3 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
};

&button2 {
gpios = <&pcal6408a 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
};

&button3 {
gpios = <&pcal6408a 1 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2021 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

/* NOTE: this feature is only available in nRF9160 DK v0.14.0 or later. */

&pcal6408a {
status = "okay";
};

&led0 {
gpios = <&pcal6408a 4 GPIO_ACTIVE_HIGH>;
};

&led1 {
gpios = <&pcal6408a 5 GPIO_ACTIVE_HIGH>;
};

&led2 {
gpios = <&pcal6408a 6 GPIO_ACTIVE_HIGH>;
};

&led3 {
gpios = <&pcal6408a 7 GPIO_ACTIVE_HIGH>;
};
18 changes: 18 additions & 0 deletions boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common_0_14_0.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@
gpios = <&interface_to_nrf52840 9 GPIO_ACTIVE_LOW>;
};

&i2c2 {
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
sda-pin = <30>;
scl-pin = <31>;

pcal6408a: pcal6408a@20 {
compatible = "nxp,pcal6408a";
status = "disabled";
reg = <0x20>;
label = "GPIO_P0";
gpio-controller;
#gpio-cells = <2>;
ngpios = <8>;
int-gpios = <&gpio0 6 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
};
};

&spi3 {
status = "okay";
sck-pin = <13>;
Expand Down

0 comments on commit c90bc89

Please sign in to comment.