Skip to content

Commit 8a25474

Browse files
nordicjmcfriedt
authored andcommitted
boards: nordic: nrf9160dk: Replace SYS_INIT with board hooks
Updates to use board hooks since SYS_INIT should not be used in boards Signed-off-by: Jamie McCrae <[email protected]>
1 parent 9f0dc12 commit 8a25474

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

boards/nordic/nrf9160dk/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ config BOARD_NRF9160DK
88
# (board.c), so it is forced here to be enabled always, not only
99
# enabled by default (in defconfig).
1010
select GPIO if BOARD_NRF9160DK_NRF52840
11+
select BOARD_EARLY_INIT_HOOK if BOARD_NRF9160DK_NRF52840 && \
12+
$(dt_nodelabel_exists,external_flash_pins_routing)
13+
select BOARD_LATE_INIT_HOOK if BOARD_NRF9160DK_NRF52840
1114

1215
if BOARD_NRF9160DK_NRF52840
1316

boards/nordic/nrf9160dk/board.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static int reset_pin_configure(void)
160160
}
161161
#endif /* USE_RESET_GPIO */
162162

163-
static int init(void)
163+
void board_late_init_hook(void)
164164
{
165165
int rc;
166166

@@ -170,7 +170,7 @@ static int init(void)
170170

171171
if (!device_is_ready(cfg->gpio)) {
172172
LOG_ERR("%s is not ready", cfg->gpio->name);
173-
return -ENODEV;
173+
return;
174174
}
175175

176176
flags |= (cfg->on ? GPIO_OUTPUT_ACTIVE
@@ -188,7 +188,7 @@ static int init(void)
188188
}
189189
#endif
190190
if (rc) {
191-
return rc;
191+
return;
192192
}
193193
}
194194

@@ -201,21 +201,17 @@ static int init(void)
201201
rc = reset_pin_configure();
202202
if (rc) {
203203
LOG_ERR("Unable to configure reset pin, err %d", rc);
204-
return -EIO;
204+
return;
205205
}
206206
#endif
207207

208208
LOG_INF("Board configured.");
209-
210-
return 0;
211209
}
212210

213-
SYS_INIT(init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
214-
215211
#define EXT_MEM_CTRL DT_NODELABEL(external_flash_pins_routing)
216-
#if DT_NODE_EXISTS(EXT_MEM_CTRL)
217212

218-
static int early_init(void)
213+
#if DT_NODE_EXISTS(EXT_MEM_CTRL)
214+
void board_early_init_hook(void)
219215
{
220216
/* As soon as possible after the system starts up, enable the analog
221217
* switch that routes signals to the external flash. Otherwise, the
@@ -234,9 +230,5 @@ static int early_init(void)
234230
nrf_gpio_pin_set(psel);
235231
}
236232
nrf_gpio_cfg_output(psel);
237-
238-
return 0;
239233
}
240-
241-
SYS_INIT(early_init, PRE_KERNEL_1, 0);
242234
#endif

0 commit comments

Comments
 (0)