From ecae736e0b2fd1a38d1d74f26ddb28be59c1f502 Mon Sep 17 00:00:00 2001 From: Pawel Dunaj Date: Mon, 24 Sep 2018 14:46:38 +0200 Subject: [PATCH] dts: Add support for Nordic QDEC Add QDEC binding and entry in Nordic SoC DTSI files. This closes issue #9364 Jira:DESK-259 Signed-off-by: Pawel Dunaj --- dts/Kconfig | 7 +++ dts/arm/nordic/nrf51822.dtsi | 8 +++ dts/arm/nordic/nrf52810.dtsi | 8 +++ dts/arm/nordic/nrf52832.dtsi | 8 +++ dts/arm/nordic/nrf52840.dtsi | 8 +++ dts/bindings/sensor/nordic,nrf-qdec.yaml | 73 ++++++++++++++++++++++++ soc/arm/nordic_nrf/nrf51/dts_fixup.h | 15 +++++ soc/arm/nordic_nrf/nrf52/dts_fixup.h | 15 +++++ 8 files changed, 142 insertions(+) create mode 100644 dts/bindings/sensor/nordic,nrf-qdec.yaml diff --git a/dts/Kconfig b/dts/Kconfig index 26a784a2de0ffa..36180746d55034 100644 --- a/dts/Kconfig +++ b/dts/Kconfig @@ -32,6 +32,13 @@ config HAS_DTS_SPI This option specifies that the target platform supports device tree configuration for SPI. +config HAS_DTS_QDEC + bool + depends on HAS_DTS + help + This option specifies that the target platform supports device tree + configuration for QDEC. + config HAS_DTS_USB bool depends on HAS_DTS diff --git a/dts/arm/nordic/nrf51822.dtsi b/dts/arm/nordic/nrf51822.dtsi index 047fc9903b8910..992ba123506c0b 100644 --- a/dts/arm/nordic/nrf51822.dtsi +++ b/dts/arm/nordic/nrf51822.dtsi @@ -93,6 +93,14 @@ label = "I2C_1"; }; + qdec: qdec@40012000 { + compatible = "nordic,nrf-qdec"; + reg = <0x40012000 0x1000>; + interrupts = <18 1>; + status = "disabled"; + label = "QDEC"; + }; + spi0: spi@40003000 { compatible = "nordic,nrf-spi"; #address-cells = <1>; diff --git a/dts/arm/nordic/nrf52810.dtsi b/dts/arm/nordic/nrf52810.dtsi index 7cdef62fdf6fe0..011261eb073549 100644 --- a/dts/arm/nordic/nrf52810.dtsi +++ b/dts/arm/nordic/nrf52810.dtsi @@ -82,6 +82,14 @@ label = "I2C_0"; }; + qdec: qdec@40012000 { + compatible = "nordic,nrf-qdec"; + reg = <0x40012000 0x1000>; + interrupts = <18 1>; + status = "disabled"; + label = "QDEC"; + }; + spi0: spi@40004000 { compatible = "nordic,nrf-spi"; #address-cells = <1>; diff --git a/dts/arm/nordic/nrf52832.dtsi b/dts/arm/nordic/nrf52832.dtsi index f7128dc0ee6c9e..e2d36b15488fa5 100644 --- a/dts/arm/nordic/nrf52832.dtsi +++ b/dts/arm/nordic/nrf52832.dtsi @@ -95,6 +95,14 @@ label = "I2C_1"; }; + qdec: qdec@40012000 { + compatible = "nordic,nrf-qdec"; + reg = <0x40012000 0x1000>; + interrupts = <18 1>; + status = "disabled"; + label = "QDEC"; + }; + spi0: spi@40003000 { compatible = "nordic,nrf-spi"; #address-cells = <1>; diff --git a/dts/arm/nordic/nrf52840.dtsi b/dts/arm/nordic/nrf52840.dtsi index 04b8ab166e4743..6382b2cae14283 100644 --- a/dts/arm/nordic/nrf52840.dtsi +++ b/dts/arm/nordic/nrf52840.dtsi @@ -113,6 +113,14 @@ label = "I2C_1"; }; + qdec: qdec@40012000 { + compatible = "nordic,nrf-qdec"; + reg = <0x40012000 0x1000>; + interrupts = <18 1>; + status = "disabled"; + label = "QDEC"; + }; + spi0: spi@40003000 { compatible = "nordic,nrf-spi"; #address-cells = <1>; diff --git a/dts/bindings/sensor/nordic,nrf-qdec.yaml b/dts/bindings/sensor/nordic,nrf-qdec.yaml new file mode 100644 index 00000000000000..17d38467833550 --- /dev/null +++ b/dts/bindings/sensor/nordic,nrf-qdec.yaml @@ -0,0 +1,73 @@ +# +# Copyright (c) 2018, Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# +--- +title: Nordic nRF Family QDEC node +version: 0.1 + +description: > + This is a representation of the Nordic nRF QDEC node + +properties: + compatible: + type: string + category: required + description: compatible strings + constraint: "nordic,nrf-qdec" + + reg: + type: array + description: mmio register space + generation: define + category: required + + interrupts: + type: array + category: required + description: required interrupts + generation: define + + a-pin: + type: int + description: A pin + generation: define + category: required + + b-pin: + type: int + description: B pin + generation: define + category: required + + led-pin: + type: int + description: LED pin for light based QDEC device + generation: define + category: optional + + enable-pin: + type: int + description: Enables connected QDEC device + generation: define + category: optional + + led-pre: + type: int + description: Time LED is enabled prior to sampling event (in us) + generation: define + category: required + + steps: + type: int + description: Number of steps on the rotating wheel + generation: define + category: required + + label: + type: string + category: required + description: Human readable string describing the device (used by Zephyr for API name) + generation: define +... diff --git a/soc/arm/nordic_nrf/nrf51/dts_fixup.h b/soc/arm/nordic_nrf/nrf51/dts_fixup.h index 8cb975f943c184..6c1ee29a09be1e 100644 --- a/soc/arm/nordic_nrf/nrf51/dts_fixup.h +++ b/soc/arm/nordic_nrf/nrf51/dts_fixup.h @@ -42,6 +42,21 @@ #define CONFIG_I2C_1_SDA_PIN NORDIC_NRF_I2C_40004000_SDA_PIN #define CONFIG_I2C_1_SCL_PIN NORDIC_NRF_I2C_40004000_SCL_PIN +#define CONFIG_QDEC_BASE_ADDR NORDIC_NRF_QDEC_40012000_BASE_ADDRESS +#define CONFIG_QDEC_NAME NORDIC_NRF_QDEC_40012000_LABEL +#define CONFIG_QDEC_IRQ_PRI NORDIC_NRF_QDEC_40012000_IRQ_0_PRIORITY +#define CONFIG_QDEC_IRQ NORDIC_NRF_QDEC_40012000_IRQ_0 +#define CONFIG_QDEC_A_PIN NORDIC_NRF_QDEC_40012000_A_PIN +#define CONFIG_QDEC_B_PIN NORDIC_NRF_QDEC_40012000_B_PIN +#if defined(NORDIC_NRF_QDEC_40012000_LED_PIN) +#define CONFIG_QDEC_LED_PIN NORDIC_NRF_QDEC_40012000_LED_PIN +#endif +#if defined(NORDIC_NRF_QDEC_40012000_ENABLE_PIN) +#define CONFIG_QDEC_ENABLE_PIN NORDIC_NRF_QDEC_40012000_ENABLE_PIN +#endif +#define CONFIG_QDEC_LED_PRE NORDIC_NRF_QDEC_40012000_LED_PRE +#define CONFIG_QDEC_STEPS NORDIC_NRF_QDEC_40012000_STEPS + #define CONFIG_SPI_0_BASE_ADDRESS NORDIC_NRF_SPI_40003000_BASE_ADDRESS #define CONFIG_SPI_0_NAME NORDIC_NRF_SPI_40003000_LABEL #define CONFIG_SPI_0_IRQ_PRI NORDIC_NRF_SPI_40003000_IRQ_0_PRIORITY diff --git a/soc/arm/nordic_nrf/nrf52/dts_fixup.h b/soc/arm/nordic_nrf/nrf52/dts_fixup.h index cbf5515e45c701..4c613040926451 100644 --- a/soc/arm/nordic_nrf/nrf52/dts_fixup.h +++ b/soc/arm/nordic_nrf/nrf52/dts_fixup.h @@ -75,6 +75,21 @@ #define CONFIG_I2C_1_SDA_PIN NORDIC_NRF_I2C_40004000_SDA_PIN #define CONFIG_I2C_1_SCL_PIN NORDIC_NRF_I2C_40004000_SCL_PIN +#define CONFIG_QDEC_BASE_ADDR NORDIC_NRF_QDEC_40012000_BASE_ADDRESS +#define CONFIG_QDEC_NAME NORDIC_NRF_QDEC_40012000_LABEL +#define CONFIG_QDEC_IRQ_PRI NORDIC_NRF_QDEC_40012000_IRQ_0_PRIORITY +#define CONFIG_QDEC_IRQ NORDIC_NRF_QDEC_40012000_IRQ_0 +#define CONFIG_QDEC_A_PIN NORDIC_NRF_QDEC_40012000_A_PIN +#define CONFIG_QDEC_B_PIN NORDIC_NRF_QDEC_40012000_B_PIN +#if defined(NORDIC_NRF_QDEC_40012000_LED_PIN) +#define CONFIG_QDEC_LED_PIN NORDIC_NRF_QDEC_40012000_LED_PIN +#endif +#if defined(NORDIC_NRF_QDEC_40012000_ENABLE_PIN) +#define CONFIG_QDEC_ENABLE_PIN NORDIC_NRF_QDEC_40012000_ENABLE_PIN +#endif +#define CONFIG_QDEC_LED_PRE NORDIC_NRF_QDEC_40012000_LED_PRE +#define CONFIG_QDEC_STEPS NORDIC_NRF_QDEC_40012000_STEPS + #define CONFIG_SPI_0_BASE_ADDRESS NORDIC_NRF_SPI_40003000_BASE_ADDRESS #define CONFIG_SPI_0_NAME NORDIC_NRF_SPI_40003000_LABEL #define CONFIG_SPI_0_IRQ_PRI NORDIC_NRF_SPI_40003000_IRQ_0_PRIORITY