From 325a9b3ea44049f178209ff4d13d84bded5c408f Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Thu, 4 Oct 2018 20:00:16 -0500 Subject: [PATCH] boards: arc: Convert boards to use device tree for LEDs & Buttons Convert over arc based boards to use device tree instead of board.h to describe buttons & LEDs. There are a few boards that the button gpio flags need validation. Signed-off-by: Kumar Gala --- .../arc/arduino_101_sss/arduino_101_sss.dts | 9 ++ boards/arc/arduino_101_sss/board.h | 3 - boards/arc/em_starterkit/board.dtsi | 97 +++++++++++++++++++ boards/arc/em_starterkit/board.h | 51 ---------- boards/arc/em_starterkit/em_starterkit.dts | 2 +- .../arc/em_starterkit/em_starterkit_em11d.dts | 1 + .../arc/em_starterkit/em_starterkit_em7d.dts | 1 + boards/arc/quark_se_c1000_ss_devboard/board.h | 13 --- .../quark_se_c1000_ss_devboard.dts | 27 ++++++ dts/arc/emsk.dtsi | 9 ++ dts/arc/quark_se_c1000_ss.dtsi | 1 + 11 files changed, 146 insertions(+), 68 deletions(-) create mode 100644 boards/arc/em_starterkit/board.dtsi diff --git a/boards/arc/arduino_101_sss/arduino_101_sss.dts b/boards/arc/arduino_101_sss/arduino_101_sss.dts index afe21a8312f..3c4e79a4b14 100644 --- a/boards/arc/arduino_101_sss/arduino_101_sss.dts +++ b/boards/arc/arduino_101_sss/arduino_101_sss.dts @@ -15,6 +15,7 @@ compatible = "intel,arduino_101_sss", "intel,quark_se_c1000"; aliases { + led0 = &led0; uart-0 = &uart0; uart-1 = &uart1; }; @@ -24,6 +25,14 @@ zephyr,flash = &flash0; zephyr,console = &uart1; }; + + leds { + compatible = "gpio-leds"; + led0: led_0 { + gpios = <&gpio0 8 0>; + label = "LED"; + }; + }; }; &uart1 { diff --git a/boards/arc/arduino_101_sss/board.h b/boards/arc/arduino_101_sss/board.h index af07a0a764c..39d984a6c10 100644 --- a/boards/arc/arduino_101_sss/board.h +++ b/boards/arc/arduino_101_sss/board.h @@ -9,7 +9,4 @@ #include -#define LED0_GPIO_PORT CONFIG_GPIO_QMSI_0_NAME -#define LED0_GPIO_PIN 8 - #endif /* __INC_BOARD_H */ diff --git a/boards/arc/em_starterkit/board.dtsi b/boards/arc/em_starterkit/board.dtsi new file mode 100644 index 00000000000..b3ec81b9324 --- /dev/null +++ b/boards/arc/em_starterkit/board.dtsi @@ -0,0 +1,97 @@ +/ { + aliases { + led0 = &led0; + led1 = &led1; + led2 = &led2; + led3 = &led3; + led4 = &led4; + led5 = &led5; + led6 = &led6; + led7 = &led7; + led8 = &led8; + sw0 = &button0; + sw1 = &button1; + sw2 = &button2; + }; + + leds { + compatible = "gpio-leds"; + led0: led_0 { + gpios = <&gpio1 0 0>; + label = "LED 0"; + }; + led1: led_1 { + gpios = <&gpio1 1 0>; + label = "LED 1"; + }; + led2: led_2 { + gpios = <&gpio1 2 0>; + label = "LED 2"; + }; + led3: led_3 { + gpios = <&gpio1 3 0>; + label = "LED 3"; + }; + led4: led_4 { + gpios = <&gpio1 4 0>; + label = "LED 4"; + }; + led5: led_5 { + gpios = <&gpio1 5 0>; + label = "LED 1"; + }; + led6: led_6 { + gpios = <&gpio1 6 0>; + label = "LED 2"; + }; + led7: led_7 { + gpios = <&gpio1 7 0>; + label = "LED 3"; + }; + led8: led_8 { + gpios = <&gpio1 8 0>; + label = "LED 4"; + }; + + }; + + buttons { + compatible = "gpio-keys"; + button0: button_0 { + /* gpio flags need validation */ + gpios = <&gpio0 0 GPIO_INT_ACTIVE_LOW>; + label = "Push button switch 0"; + }; + button1: button_1 { + /* gpio flags need validation */ + gpios = <&gpio0 1 GPIO_INT_ACTIVE_LOW>; + label = "Push button switch 1"; + }; + button2: button_2 { + /* gpio flags need validation */ + gpios = <&gpio0 2 GPIO_INT_ACTIVE_LOW>; + label = "Push button switch 2"; + }; + switch0: switch_0 { + /* gpio flags need validation */ + gpios = <&gpio2 0 GPIO_INT_ACTIVE_LOW>; + label = "DIP SW1 - Switch 1"; + }; + switch1: switch_1 { + /* gpio flags need validation */ + gpios = <&gpio2 1 GPIO_INT_ACTIVE_LOW>; + label = "DIP SW1 - Switch 2"; + }; + switch2: switch_2 { + /* gpio flags need validation */ + gpios = <&gpio2 2 GPIO_INT_ACTIVE_LOW>; + label = "DIP SW1 - Switch 3"; + }; + switch3: switch_3 { + /* gpio flags need validation */ + gpios = <&gpio2 3 GPIO_INT_ACTIVE_LOW>; + label = "DIP SW1 - Switch 4"; + }; + }; + +}; diff --git a/boards/arc/em_starterkit/board.h b/boards/arc/em_starterkit/board.h index 7a8ede8b826..5580515e240 100644 --- a/boards/arc/em_starterkit/board.h +++ b/boards/arc/em_starterkit/board.h @@ -9,55 +9,4 @@ #include -/* Switches */ -#define SW0_GPIO_PIN 0 -#define SW0_GPIO_NAME CONFIG_GPIO_DW_2_NAME - -#define SW1_GPIO_PIN 1 -#define SW1_GPIO_NAME CONFIG_GPIO_DW_2_NAME - -#define SW2_GPIO_PIN 2 -#define SW2_GPIO_NAME CONFIG_GPIO_DW_2_NAME - -#define SW3_GPIO_PIN 3 -#define SW3_GPIO_NAME CONFIG_GPIO_DW_2_NAME - -/* Buttons */ -#define BTN0_GPIO_PIN 0 -#define BTN0_GPIO_NAME CONFIG_GPIO_DW_0_NAME - -#define BTN1_GPIO_PIN 1 -#define BTN1_GPIO_NAME CONFIG_GPIO_DW_0_NAME - -#define BTN2_GPIO_PIN 2 -#define BTN2_GPIO_NAME CONFIG_GPIO_DW_0_NAME - -/* Onboard LEDs */ -#define LED0_GPIO_PORT CONFIG_GPIO_DW_1_NAME -#define LED0_GPIO_PIN 0 - -#define LED1_GPIO_PORT CONFIG_GPIO_DW_1_NAME -#define LED1_GPIO_PIN 1 - -#define LED2_GPIO_PORT CONFIG_GPIO_DW_1_NAME -#define LED2_GPIO_PIN 2 - -#define LED3_GPIO_PORT CONFIG_GPIO_DW_1_NAME -#define LED3_GPIO_PIN 3 - -#define LED4_GPIO_PORT CONFIG_GPIO_DW_1_NAME -#define LED4_GPIO_PIN 4 - -#define LED5_GPIO_PORT CONFIG_GPIO_DW_1_NAME -#define LED5_GPIO_PIN 5 - -#define LED6_GPIO_PORT CONFIG_GPIO_DW_1_NAME -#define LED6_GPIO_PIN 6 - -#define LED7_GPIO_PORT CONFIG_GPIO_DW_1_NAME -#define LED7_GPIO_PIN 7 - -#define LED8_GPIO_PORT CONFIG_GPIO_DW_1_NAME -#define LED8_GPIO_PIN 8 - #endif /* __INC_BOARD_H */ diff --git a/boards/arc/em_starterkit/em_starterkit.dts b/boards/arc/em_starterkit/em_starterkit.dts index d9870c9f9cf..8ac9d82f3a0 100644 --- a/boards/arc/em_starterkit/em_starterkit.dts +++ b/boards/arc/em_starterkit/em_starterkit.dts @@ -7,7 +7,7 @@ /dts-v1/; #include - +#include "board.dtsi" / { model = "em_starterkit-em9d"; diff --git a/boards/arc/em_starterkit/em_starterkit_em11d.dts b/boards/arc/em_starterkit/em_starterkit_em11d.dts index 0a6a99856e5..972a5526c13 100644 --- a/boards/arc/em_starterkit/em_starterkit_em11d.dts +++ b/boards/arc/em_starterkit/em_starterkit_em11d.dts @@ -7,6 +7,7 @@ /dts-v1/; #include +#include "board.dtsi" / { model = "em_starterkit-em11d"; diff --git a/boards/arc/em_starterkit/em_starterkit_em7d.dts b/boards/arc/em_starterkit/em_starterkit_em7d.dts index 5558583eafa..0cc91077846 100644 --- a/boards/arc/em_starterkit/em_starterkit_em7d.dts +++ b/boards/arc/em_starterkit/em_starterkit_em7d.dts @@ -7,6 +7,7 @@ /dts-v1/; #include +#include "board.dtsi" / { model = "em_starterkit-em7d"; diff --git a/boards/arc/quark_se_c1000_ss_devboard/board.h b/boards/arc/quark_se_c1000_ss_devboard/board.h index a706a89af23..65b22b46e4c 100644 --- a/boards/arc/quark_se_c1000_ss_devboard/board.h +++ b/boards/arc/quark_se_c1000_ss_devboard/board.h @@ -9,17 +9,4 @@ #include -/* Push button switch 0 */ -#define SW0_GPIO_PIN 4 -#define SW0_GPIO_NAME CONFIG_GPIO_QMSI_1_NAME - -/* Push button switch 1 */ -#define SW1_GPIO_PIN 5 -#define SW1_GPIO_NAME CONFIG_GPIO_QMSI_0_NAME - - -/* Onboard LED */ -#define LED0_GPIO_PORT CONFIG_GPIO_QMSI_0_NAME -#define LED0_GPIO_PIN 25 - #endif /* __INC_BOARD_H */ diff --git a/boards/arc/quark_se_c1000_ss_devboard/quark_se_c1000_ss_devboard.dts b/boards/arc/quark_se_c1000_ss_devboard/quark_se_c1000_ss_devboard.dts index 5bd1a4cc206..df60b881b20 100644 --- a/boards/arc/quark_se_c1000_ss_devboard/quark_se_c1000_ss_devboard.dts +++ b/boards/arc/quark_se_c1000_ss_devboard/quark_se_c1000_ss_devboard.dts @@ -15,6 +15,9 @@ compatible = "intel,quark_se_c1000_ss_devboard", "intel,quark_se_c1000"; aliases { + led0 = &led0; + sw0 = &button0; + sw1 = &button1; uart-0 = &uart0; uart-1 = &uart1; }; @@ -24,6 +27,30 @@ zephyr,flash = &flash0; zephyr,console = &uart1; }; + + leds { + compatible = "gpio-leds"; + led0: led_0 { + gpios = <&gpio0 25 0>; + label = "LED"; + }; + }; + + buttons { + /* Push button switch 0 KEY1 */ + compatible = "gpio-keys"; + button0: button_0 { + /* gpio flags need validation */ + gpios = <&gpio1 4 GPIO_INT_ACTIVE_LOW>; + label = "Push button switch 0"; + }; + button1: button_1 { + /* gpio flags need validation */ + gpios = <&gpio0 5 GPIO_INT_ACTIVE_LOW>; + label = "Push button switch 1"; + }; + }; + }; &uart1 { diff --git a/dts/arc/emsk.dtsi b/dts/arc/emsk.dtsi index ccb86ea0fce..2d43900a398 100644 --- a/dts/arc/emsk.dtsi +++ b/dts/arc/emsk.dtsi @@ -7,6 +7,7 @@ #include "skeleton.dtsi" #include #include +#include / { @@ -111,6 +112,8 @@ interrupts = ; interrupt-parent = <&intc>; + gpio-controller; + #gpio-cells = <2>; }; gpio1: gpio@f000200C { @@ -121,6 +124,8 @@ interrupts = ; interrupt-parent = <&intc>; + gpio-controller; + #gpio-cells = <2>; }; gpio2: gpio@f0002018 { @@ -132,6 +137,8 @@ interrupts = ; interrupt-parent = <&intc>; + gpio-controller; + #gpio-cells = <2>; }; gpio3: gpio@f0002024 { @@ -143,6 +150,8 @@ interrupts = ; interrupt-parent = <&intc>; + gpio-controller; + #gpio-cells = <2>; }; spi0: spi@f0006000 { diff --git a/dts/arc/quark_se_c1000_ss.dtsi b/dts/arc/quark_se_c1000_ss.dtsi index ce84ff57c2b..4c1daae7ae8 100644 --- a/dts/arc/quark_se_c1000_ss.dtsi +++ b/dts/arc/quark_se_c1000_ss.dtsi @@ -7,6 +7,7 @@ #include "skeleton.dtsi" #include +#include / { cpus {