Skip to content

Commit ef87d48

Browse files
nandojvenashif
authored andcommitted
boards: arm: sam0: Fix pinmux init prio
After pinmux being converted to build a separate static library console not show anymore and there is a hard fault. The hard fault happen because pinmux drivers are not ready yet and board emits an assert. This change board pinmux initialization to PRE_KERNEL_2 and let system take care error handling. Signed-off-by: Gerson Fernando Budke <[email protected]>
1 parent 2760fb9 commit ef87d48

File tree

11 files changed

+95
-74
lines changed

11 files changed

+95
-74
lines changed

boards/arm/adafruit_feather_m0_basic_proto/pinmux.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
static int board_pinmux_init(const struct device *dev)
1212
{
1313
const struct device *muxa = DEVICE_DT_GET(DT_NODELABEL(pinmux_a));
14-
15-
__ASSERT_NO_MSG(device_is_ready(muxa));
16-
17-
#if (ATMEL_SAM0_DT_SERCOM_CHECK(4, atmel_sam0_spi) && CONFIG_SPI_SAM0)
1814
const struct device *muxb = DEVICE_DT_GET(DT_NODELABEL(pinmux_b));
1915

20-
__ASSERT_NO_MSG(device_is_ready(muxb));
21-
#endif
2216
ARG_UNUSED(dev);
23-
ARG_UNUSED(muxa);
17+
18+
if (!device_is_ready(muxa)) {
19+
return -ENXIO;
20+
}
21+
if (!device_is_ready(muxb)) {
22+
return -ENXIO;
23+
}
2424

2525
#if (ATMEL_SAM0_DT_SERCOM_CHECK(4, atmel_sam0_spi) && CONFIG_SPI_SAM0)
2626
/* SPI SERCOM4 on MISO=PA12/pad 0, MOSI=PB10/pad 2, SCK=PB11/pad 3 */
@@ -75,4 +75,4 @@ static int board_pinmux_init(const struct device *dev)
7575
return 0;
7676
}
7777

78-
SYS_INIT(board_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);
78+
SYS_INIT(board_pinmux_init, PRE_KERNEL_2, CONFIG_PINMUX_INIT_PRIORITY);

boards/arm/adafruit_itsybitsy_m4_express/pinmux.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@
1010

1111
static int board_pinmux_init(const struct device *dev)
1212
{
13-
__unused const struct device *muxa = DEVICE_DT_GET(DT_NODELABEL(pinmux_a));
14-
__unused const struct device *muxb = DEVICE_DT_GET(DT_NODELABEL(pinmux_b));
15-
16-
__ASSERT_NO_MSG(device_is_ready(muxa));
17-
__ASSERT_NO_MSG(device_is_ready(muxb));
13+
const struct device *muxa = DEVICE_DT_GET(DT_NODELABEL(pinmux_a));
14+
const struct device *muxb = DEVICE_DT_GET(DT_NODELABEL(pinmux_b));
1815

1916
ARG_UNUSED(dev);
20-
ARG_UNUSED(muxa);
21-
ARG_UNUSED(muxb);
17+
18+
if (!device_is_ready(muxa)) {
19+
return -ENXIO;
20+
}
21+
if (!device_is_ready(muxb)) {
22+
return -ENXIO;
23+
}
2224

2325
#if ATMEL_SAM0_DT_SERCOM_CHECK(1, atmel_sam0_spi) && defined(CONFIG_SPI_SAM0)
2426
/* SPI SERCOM1 on MISO=PB23/pad 3, MOSI=PA0/pad 0, SCK=PA1/pad 1 */
@@ -62,4 +64,4 @@ static int board_pinmux_init(const struct device *dev)
6264
return 0;
6365
}
6466

65-
SYS_INIT(board_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);
67+
SYS_INIT(board_pinmux_init, PRE_KERNEL_2, CONFIG_PINMUX_INIT_PRIORITY);

boards/arm/adafruit_trinket_m0/pinmux.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ static int board_pinmux_init(const struct device *dev)
1212
{
1313
const struct device *muxa = DEVICE_DT_GET(DT_NODELABEL(pinmux_a));
1414

15-
__ASSERT_NO_MSG(device_is_ready(muxa));
16-
1715
ARG_UNUSED(dev);
18-
ARG_UNUSED(muxa);
16+
17+
if (!device_is_ready(muxa)) {
18+
return -ENXIO;
19+
}
1920

2021
#if (ATMEL_SAM0_DT_SERCOM_CHECK(0, atmel_sam0_spi) && CONFIG_SPI_SAM0)
2122
/* SPI SERCOM0 on MISO=PA9/pad 1, MOSI=PA6/pad 2, SCK=PA7/pad 3 */
@@ -58,4 +59,4 @@ static int board_pinmux_init(const struct device *dev)
5859
return 0;
5960
}
6061

61-
SYS_INIT(board_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);
62+
SYS_INIT(board_pinmux_init, PRE_KERNEL_2, CONFIG_PINMUX_INIT_PRIORITY);

boards/arm/arduino_nano_33_iot/pinmux.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ static int board_pinmux_init(const struct device *dev)
1313
const struct device *muxa = DEVICE_DT_GET(DT_NODELABEL(pinmux_a));
1414
const struct device *muxb = DEVICE_DT_GET(DT_NODELABEL(pinmux_b));
1515

16-
__ASSERT_NO_MSG(device_is_ready(muxa));
17-
__ASSERT_NO_MSG(device_is_ready(muxb));
18-
1916
ARG_UNUSED(dev);
20-
ARG_UNUSED(muxa);
21-
ARG_UNUSED(muxb);
17+
18+
if (!device_is_ready(muxa)) {
19+
return -ENXIO;
20+
}
21+
if (!device_is_ready(muxb)) {
22+
return -ENXIO;
23+
}
2224

2325
#if defined(CONFIG_SPI_SAM0)
2426
#if ATMEL_SAM0_DT_SERCOM_CHECK(1, atmel_sam0_spi)
@@ -86,4 +88,4 @@ static int board_pinmux_init(const struct device *dev)
8688
return 0;
8789
}
8890

89-
SYS_INIT(board_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);
91+
SYS_INIT(board_pinmux_init, PRE_KERNEL_2, CONFIG_PINMUX_INIT_PRIORITY);

boards/arm/arduino_zero/pinmux.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ static int board_pinmux_init(const struct device *dev)
1313
const struct device *muxa = DEVICE_DT_GET(DT_NODELABEL(pinmux_a));
1414
const struct device *muxb = DEVICE_DT_GET(DT_NODELABEL(pinmux_b));
1515

16-
__ASSERT_NO_MSG(device_is_ready(muxa));
17-
__ASSERT_NO_MSG(device_is_ready(muxb));
18-
1916
ARG_UNUSED(dev);
20-
ARG_UNUSED(muxa);
21-
ARG_UNUSED(muxb);
17+
18+
if (!device_is_ready(muxa)) {
19+
return -ENXIO;
20+
}
21+
if (!device_is_ready(muxb)) {
22+
return -ENXIO;
23+
}
2224

2325
#if (ATMEL_SAM0_DT_SERCOM_CHECK(4, atmel_sam0_spi) && CONFIG_SPI_SAM0)
2426
/* SPI SERCOM4 on MISO=PA12/pad 0, MOSI=PB10/pad 2, SCK=PB11/pad 3 */
@@ -62,4 +64,4 @@ static int board_pinmux_init(const struct device *dev)
6264
return 0;
6365
}
6466

65-
SYS_INIT(board_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);
67+
SYS_INIT(board_pinmux_init, PRE_KERNEL_2, CONFIG_PINMUX_INIT_PRIORITY);

boards/arm/atsamd20_xpro/pinmux.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ static int board_pinmux_init(const struct device *dev)
1313
const struct device *muxa = DEVICE_DT_GET(DT_NODELABEL(pinmux_a));
1414
const struct device *muxb = DEVICE_DT_GET(DT_NODELABEL(pinmux_b));
1515

16-
__ASSERT_NO_MSG(device_is_ready(muxa));
17-
__ASSERT_NO_MSG(device_is_ready(muxb));
18-
1916
ARG_UNUSED(dev);
20-
ARG_UNUSED(muxa);
21-
ARG_UNUSED(muxb);
17+
18+
if (!device_is_ready(muxa)) {
19+
return -ENXIO;
20+
}
21+
if (!device_is_ready(muxb)) {
22+
return -ENXIO;
23+
}
2224

2325
#if (ATMEL_SAM0_DT_SERCOM_CHECK(0, atmel_sam0_spi) && CONFIG_SPI_SAM0)
2426
/* SPI SERCOM0 on MISO=PA04, MOSI=PA06, SCK=PA07 */
@@ -66,4 +68,4 @@ static int board_pinmux_init(const struct device *dev)
6668
return 0;
6769
}
6870

69-
SYS_INIT(board_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);
71+
SYS_INIT(board_pinmux_init, PRE_KERNEL_2, CONFIG_PINMUX_INIT_PRIORITY);

boards/arm/atsamd21_xpro/pinmux.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ static int board_pinmux_init(const struct device *dev)
1313
const struct device *muxa = DEVICE_DT_GET(DT_NODELABEL(pinmux_a));
1414
const struct device *muxb = DEVICE_DT_GET(DT_NODELABEL(pinmux_b));
1515

16-
__ASSERT_NO_MSG(device_is_ready(muxa));
17-
__ASSERT_NO_MSG(device_is_ready(muxb));
18-
1916
ARG_UNUSED(dev);
20-
ARG_UNUSED(muxa);
21-
ARG_UNUSED(muxb);
17+
18+
if (!device_is_ready(muxa)) {
19+
return -ENXIO;
20+
}
21+
if (!device_is_ready(muxb)) {
22+
return -ENXIO;
23+
}
2224

2325
#if (ATMEL_SAM0_DT_SERCOM_CHECK(0, atmel_sam0_spi) && CONFIG_SPI_SAM0)
2426
#warning Pin mapping may not be configured
@@ -76,4 +78,4 @@ static int board_pinmux_init(const struct device *dev)
7678
return 0;
7779
}
7880

79-
SYS_INIT(board_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);
81+
SYS_INIT(board_pinmux_init, PRE_KERNEL_2, CONFIG_PINMUX_INIT_PRIORITY);

boards/arm/atsame54_xpro/pinmux.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@ static int board_pinmux_init(const struct device *dev)
1515
const struct device *muxc = DEVICE_DT_GET(DT_NODELABEL(pinmux_c));
1616
const struct device *muxd = DEVICE_DT_GET(DT_NODELABEL(pinmux_d));
1717

18-
__ASSERT_NO_MSG(device_is_ready(muxa));
19-
__ASSERT_NO_MSG(device_is_ready(muxb));
20-
__ASSERT_NO_MSG(device_is_ready(muxc));
21-
__ASSERT_NO_MSG(device_is_ready(muxd));
22-
2318
ARG_UNUSED(dev);
24-
ARG_UNUSED(muxa);
25-
ARG_UNUSED(muxb);
26-
ARG_UNUSED(muxc);
27-
ARG_UNUSED(muxd);
19+
20+
if (!device_is_ready(muxa)) {
21+
return -ENXIO;
22+
}
23+
if (!device_is_ready(muxb)) {
24+
return -ENXIO;
25+
}
26+
if (!device_is_ready(muxc)) {
27+
return -ENXIO;
28+
}
29+
if (!device_is_ready(muxd)) {
30+
return -ENXIO;
31+
}
2832

2933
#if (ATMEL_SAM0_DT_SERCOM_CHECK(0, atmel_sam0_spi) && CONFIG_SPI_SAM0)
3034
#warning Pin mapping may not be configured
@@ -107,4 +111,4 @@ static int board_pinmux_init(const struct device *dev)
107111
return 0;
108112
}
109113

110-
SYS_INIT(board_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);
114+
SYS_INIT(board_pinmux_init, PRE_KERNEL_2, CONFIG_PINMUX_INIT_PRIORITY);

boards/arm/atsamr21_xpro/pinmux.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@ static int board_pinmux_init(const struct device *dev)
1515
const struct device *muxb = DEVICE_DT_GET(DT_NODELABEL(pinmux_b));
1616
const struct device *muxc = DEVICE_DT_GET(DT_NODELABEL(pinmux_c));
1717

18-
__ASSERT_NO_MSG(device_is_ready(muxa));
19-
__ASSERT_NO_MSG(device_is_ready(muxb));
20-
__ASSERT_NO_MSG(device_is_ready(muxc));
21-
2218
ARG_UNUSED(dev);
23-
ARG_UNUSED(muxa);
24-
ARG_UNUSED(muxb);
25-
ARG_UNUSED(muxc);
19+
20+
if (!device_is_ready(muxa)) {
21+
return -ENXIO;
22+
}
23+
if (!device_is_ready(muxb)) {
24+
return -ENXIO;
25+
}
26+
if (!device_is_ready(muxc)) {
27+
return -ENXIO;
28+
}
2629

2730
#if (ATMEL_SAM0_DT_SERCOM_CHECK(0, atmel_sam0_spi) && CONFIG_SPI_SAM0)
2831
#warning Pin mapping may not be configured
@@ -91,4 +94,4 @@ static int board_pinmux_init(const struct device *dev)
9194
return 0;
9295
}
9396

94-
SYS_INIT(board_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);
97+
SYS_INIT(board_pinmux_init, PRE_KERNEL_2, CONFIG_PINMUX_INIT_PRIORITY);

boards/arm/seeeduino_xiao/pinmux.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@
1010

1111
static int board_pinmux_init(const struct device *dev)
1212
{
13-
__unused const struct device *muxa = DEVICE_DT_GET(DT_NODELABEL(pinmux_a));
14-
__unused const struct device *muxb = DEVICE_DT_GET(DT_NODELABEL(pinmux_b));
15-
16-
__ASSERT_NO_MSG(device_is_ready(muxa));
17-
__ASSERT_NO_MSG(device_is_ready(muxb));
13+
const struct device *muxa = DEVICE_DT_GET(DT_NODELABEL(pinmux_a));
14+
const struct device *muxb = DEVICE_DT_GET(DT_NODELABEL(pinmux_b));
1815

1916
ARG_UNUSED(dev);
20-
ARG_UNUSED(muxa);
21-
ARG_UNUSED(muxb);
17+
18+
if (!device_is_ready(muxa)) {
19+
return -ENXIO;
20+
}
21+
if (!device_is_ready(muxb)) {
22+
return -ENXIO;
23+
}
2224

2325
#if ATMEL_SAM0_DT_SERCOM_CHECK(2, atmel_sam0_i2c) && defined(CONFIG_I2C_SAM0)
2426
/* SERCOM2 on SDA=PA08, SCL=PA09 */
@@ -74,4 +76,4 @@ static int board_pinmux_init(const struct device *dev)
7476
return 0;
7577
}
7678

77-
SYS_INIT(board_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);
79+
SYS_INIT(board_pinmux_init, PRE_KERNEL_2, CONFIG_PINMUX_INIT_PRIORITY);

0 commit comments

Comments
 (0)