From c90bc89cfaee4e42cba0cb200c84e3a3dc0d474b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20G=C5=82=C4=85bek?= Date: Fri, 29 Jan 2021 18:55:59 +0100 Subject: [PATCH] [nrf fromlist] boards: nrf9160dk: Add DT node for I/O expander ... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... available in v0.14.0+ Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/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 --- .../dts/nrf9160dk_buttons_on_io_expander.dtsi | 27 +++++++++++++++++++ .../dts/nrf9160dk_leds_on_io_expander.dtsi | 27 +++++++++++++++++++ .../arm/nrf9160dk_nrf9160/Kconfig.defconfig | 6 +++++ .../dts/nrf9160dk_buttons_on_io_expander.dtsi | 27 +++++++++++++++++++ .../dts/nrf9160dk_leds_on_io_expander.dtsi | 27 +++++++++++++++++++ .../nrf9160dk_nrf9160_common_0_14_0.dtsi | 18 +++++++++++++ 6 files changed, 132 insertions(+) create mode 100644 boards/arm/nrf9160dk_nrf52840/dts/nrf9160dk_buttons_on_io_expander.dtsi create mode 100644 boards/arm/nrf9160dk_nrf52840/dts/nrf9160dk_leds_on_io_expander.dtsi create mode 100644 boards/arm/nrf9160dk_nrf9160/dts/nrf9160dk_buttons_on_io_expander.dtsi create mode 100644 boards/arm/nrf9160dk_nrf9160/dts/nrf9160dk_leds_on_io_expander.dtsi diff --git a/boards/arm/nrf9160dk_nrf52840/dts/nrf9160dk_buttons_on_io_expander.dtsi b/boards/arm/nrf9160dk_nrf52840/dts/nrf9160dk_buttons_on_io_expander.dtsi new file mode 100644 index 00000000000..5ab887957ba --- /dev/null +++ b/boards/arm/nrf9160dk_nrf52840/dts/nrf9160dk_buttons_on_io_expander.dtsi @@ -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"; +}; diff --git a/boards/arm/nrf9160dk_nrf52840/dts/nrf9160dk_leds_on_io_expander.dtsi b/boards/arm/nrf9160dk_nrf52840/dts/nrf9160dk_leds_on_io_expander.dtsi new file mode 100644 index 00000000000..f3367f28501 --- /dev/null +++ b/boards/arm/nrf9160dk_nrf52840/dts/nrf9160dk_leds_on_io_expander.dtsi @@ -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"; +}; diff --git a/boards/arm/nrf9160dk_nrf9160/Kconfig.defconfig b/boards/arm/nrf9160dk_nrf9160/Kconfig.defconfig index ce3e9151733..88c3c50a7c8 100644 --- a/boards/arm/nrf9160dk_nrf9160/Kconfig.defconfig +++ b/boards/arm/nrf9160dk_nrf9160/Kconfig.defconfig @@ -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 diff --git a/boards/arm/nrf9160dk_nrf9160/dts/nrf9160dk_buttons_on_io_expander.dtsi b/boards/arm/nrf9160dk_nrf9160/dts/nrf9160dk_buttons_on_io_expander.dtsi new file mode 100644 index 00000000000..648997f5d2e --- /dev/null +++ b/boards/arm/nrf9160dk_nrf9160/dts/nrf9160dk_buttons_on_io_expander.dtsi @@ -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)>; +}; diff --git a/boards/arm/nrf9160dk_nrf9160/dts/nrf9160dk_leds_on_io_expander.dtsi b/boards/arm/nrf9160dk_nrf9160/dts/nrf9160dk_leds_on_io_expander.dtsi new file mode 100644 index 00000000000..0bc46753eb7 --- /dev/null +++ b/boards/arm/nrf9160dk_nrf9160/dts/nrf9160dk_leds_on_io_expander.dtsi @@ -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>; +}; diff --git a/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common_0_14_0.dtsi b/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common_0_14_0.dtsi index 45f9b4ccbbe..d84f18bf5a9 100644 --- a/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common_0_14_0.dtsi +++ b/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common_0_14_0.dtsi @@ -21,6 +21,24 @@ gpios = <&interface_to_nrf52840 9 GPIO_ACTIVE_LOW>; }; +&i2c2 { + status = "okay"; + clock-frequency = ; + 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>;