Skip to content

Commit c52f0a9

Browse files
committed
refactor(nordic): dts cleanup and DK gpio driver removal
[no changelog]
1 parent 85b5c3b commit c52f0a9

9 files changed

Lines changed: 39 additions & 74 deletions

File tree

nordic/trezor/boards/arm/t3w1_revA_nrf52832/Kconfig.defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# T3W1 REVA NRF52833 board configuration
1+
# T3W1 REVA NRF52832 board configuration
22

33
# Copyright (c) 2019 Nordic Semiconductor ASA
44
# SPDX-License-Identifier: Apache-2.0

nordic/trezor/boards/arm/t3w1_revA_nrf52832/board.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
board:
55
name: t3w1_revA_nrf52832
66
full_name: t3w1_revA_nrf52832
7-
vendor: vendor
7+
vendor: trezor
88
socs:
99
- name: nrf52832

nordic/trezor/boards/arm/t3w1_revA_nrf52832/t3w1_revA_nrf52832.dts

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
/dts-v1/;
88
#include <nordic/nrf52832_ciaa.dtsi>
99
#include "t3w1_revA_nrf52832-pinctrl.dtsi"
10-
#include <zephyr/dt-bindings/input/input-event-codes.h>
1110

1211
/ {
1312
model = "T3W1 REVA NRF52832";
@@ -22,52 +21,33 @@
2221
zephyr,code-partition = &slot0_partition;
2322
};
2423

25-
leds {
24+
outputs {
2625
compatible = "gpio-leds";
27-
28-
led0: led_0 {
26+
output_0: output_0 {
2927
gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>;
30-
label = "Reserved";
3128
};
32-
33-
};
34-
35-
buttons {
36-
compatible = "gpio-keys";
37-
38-
button0: button_0 {
39-
gpios = <&gpio0 14 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
40-
label = "Stay in bootloader";
41-
zephyr,code = <INPUT_KEY_0>;
29+
output_1: output_1 {
30+
gpios = <&gpio0 29 (GPIO_ACTIVE_HIGH)>;
4231
};
4332
};
4433

45-
spi_sync_in
46-
{
34+
inputs {
4735
compatible = "gpio-keys";
48-
spi_ready: spi_ready {
49-
gpios = <&gpio0 12 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
50-
label = "Trezor has data ready";
36+
input_0: input_0 {
37+
gpios = <&gpio0 14 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
5138
};
52-
};
53-
spi_sync_out
54-
{
55-
compatible = "gpio-leds";
56-
spi_request: spi_request {
57-
gpios = <&gpio0 29 (GPIO_ACTIVE_HIGH)>;
58-
label = "NRF is requesting to send data to trezor";
39+
input_1: input_1 {
40+
gpios = <&gpio0 12 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
5941
};
6042
};
6143

62-
/* These aliases are provided for compatibility with samples */
6344
aliases {
64-
led0 = &led0;
65-
sw0 = &button0;
66-
bootloader-botton0 = &button0;
67-
mcuboot-button0 = &button0;
45+
mcuboot-button0 = &input_0;
6846
watchdog0 = &wdt0;
69-
spi-ready = &spi_ready;
70-
spi-request = &spi_request;
47+
spi-ready = &input_1;
48+
spi-request = &output_1;
49+
stay-in-bootloader = &input_0;
50+
reserved-output = &output_0;
7151
};
7252
};
7353

@@ -106,7 +86,7 @@
10686
pinctrl-1 = <&spi0_sleep>;
10787
pinctrl-names = "default", "sleep";
10888
cs-gpios = <&gpio0 0 GPIO_ACTIVE_LOW>;
109-
reg_my_spi_master: spi-dev-a@0 {
89+
trezor_spi_dev: spi-dev-a@0 {
11090
reg = <0>;
11191
};
11292
};

nordic/trezor/boards/arm/t3w1_revA_nrf52832/t3w1_revA_nrf52832.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
identifier: t3w1_revA_nrf52832
2-
name: tw31-revA-NRF52832
2+
name: t3w1-revA-NRF52832
33
type: mcu
44
arch: arm
55
ram: 64

nordic/trezor/trezor-ble/prj.conf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@ CONFIG_NVS=y
9191
CONFIG_SETTINGS=y
9292
CONFIG_SETTINGS_RUNTIME=y
9393

94-
# Enable DK LED and Buttons library
95-
CONFIG_DK_LIBRARY=y
96-
9794
# This example requires more stack
9895
CONFIG_MAIN_STACK_SIZE=1152
9996
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096

nordic/trezor/trezor-ble/src/main.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
#include <zephyr/bluetooth/hci.h>
3333
#include <zephyr/bluetooth/uuid.h>
3434

35-
#include <dk_buttons_and_leds.h>
36-
3735
#include <zephyr/settings/settings.h>
3836

3937
#include <zephyr/logging/log.h>

nordic/trezor/trezor-ble/src/signals/signals.c

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,57 +16,52 @@
1616
* You should have received a copy of the GNU General Public License
1717
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
*/
19+
20+
#include <zephyr/drivers/gpio.h>
1921
#include <zephyr/kernel.h>
2022
#include <zephyr/logging/log.h>
21-
#include <zephyr/settings/settings.h>
22-
#include <zephyr/types.h>
2323

2424
#include <signals/signals.h>
2525

26-
#include <dk_buttons_and_leds.h>
27-
2826
#define LOG_MODULE_NAME signals
2927
LOG_MODULE_REGISTER(LOG_MODULE_NAME);
3028

31-
#define OUT_RESERVED DK_LED1
32-
33-
#define IN_STAY_IN_BOOTLOADER DK_BTN1_MSK
29+
static const struct gpio_dt_spec stay_in_bootloader_btn =
30+
GPIO_DT_SPEC_GET(DT_ALIAS(stay_in_bootloader), gpios);
31+
static const struct gpio_dt_spec reserved_output =
32+
GPIO_DT_SPEC_GET(DT_ALIAS(reserved_output), gpios);
3433

3534
static K_SEM_DEFINE(signals_ok, 0, 1);
3635

3736
static bool out_reserved = false;
3837

39-
void button_changed(uint32_t button_state, uint32_t has_changed) {}
40-
41-
static void configure_gpio(void) {
38+
bool signals_init(void) {
4239
int err;
4340

44-
err = dk_buttons_init(button_changed);
41+
err = gpio_pin_configure_dt(&stay_in_bootloader_btn, GPIO_INPUT);
4542
if (err) {
46-
LOG_ERR("Cannot init INPUT (err: %d)", err);
43+
LOG_ERR("Cannot configure bootloader button (err: %d)", err);
44+
return false;
4745
}
4846

49-
err = dk_leds_init();
47+
err = gpio_pin_configure_dt(&reserved_output, GPIO_OUTPUT_INACTIVE);
5048
if (err) {
51-
LOG_ERR("Cannot init OUTPUT (err: %d)", err);
49+
LOG_ERR("Cannot configure reserved output (err: %d)", err);
50+
return false;
5251
}
53-
}
54-
55-
bool signals_is_stay_in_bootloader(void) {
56-
return (dk_get_buttons() & IN_STAY_IN_BOOTLOADER) != 0;
57-
}
58-
59-
bool signals_init(void) {
60-
configure_gpio();
6152

6253
k_sem_give(&signals_ok);
6354

6455
return true;
6556
}
6657

58+
bool signals_is_stay_in_bootloader(void) {
59+
return gpio_pin_get_dt(&stay_in_bootloader_btn) > 0;
60+
}
61+
6762
void signals_set_reserved(bool set) {
6863
out_reserved = set;
69-
dk_set_led(OUT_RESERVED, set);
64+
gpio_pin_set_dt(&reserved_output, set);
7065
}
7166

7267
bool signals_out_get_reserved(void) { return out_reserved; }

nordic/trezor/trezor-ble/src/trz_comm/spi.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,13 @@ const struct device *spi_dev;
4646
static struct k_poll_signal spi_done_sig =
4747
K_POLL_SIGNAL_INITIALIZER(spi_done_sig);
4848

49-
struct spi_cs_control spim_cs = {
50-
.gpio = SPI_CS_GPIOS_DT_SPEC_GET(DT_NODELABEL(reg_my_spi_master)),
51-
.delay = 0,
52-
};
53-
5449
static const struct spi_config spi_cfg = {
5550
.operation = SPI_WORD_SET(8) | SPI_TRANSFER_MSB,
5651
.frequency = 8000000,
5752
.slave = 0,
5853
.cs =
5954
{
60-
.gpio = SPI_CS_GPIOS_DT_SPEC_GET(DT_NODELABEL(reg_my_spi_master)),
55+
.gpio = SPI_CS_GPIOS_DT_SPEC_GET(DT_NODELABEL(trezor_spi_dev)),
6156
.delay = 0,
6257
},
6358
};
@@ -109,7 +104,7 @@ void spi_init(void) {
109104
if (!device_is_ready(spi_dev)) {
110105
LOG_WRN("SPI master device not ready!");
111106
}
112-
if (!device_is_ready(spim_cs.gpio.port)) {
107+
if (!device_is_ready(spi_cfg.cs.gpio.port)) {
113108
LOG_WRN("SPI master chip select device not ready!");
114109
}
115110

vendor/libtropic

Submodule libtropic updated 353 files

0 commit comments

Comments
 (0)