zephyr/boards/arm/efr32_radio/board.c
Christian Taedcke 0c6ccc0941 boards: silabs: Fix board controller init priority
Before this fix the board init function were called too early, before
the gpio driver was initialized. Because of the the board controller
for the serial port was not enabled properly.

This commit fixes this issue.

Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
2021-03-26 08:40:28 -04:00

40 lines
1.0 KiB
C

/*
* Copyright (c) 2018 Christian Taedcke
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <init.h>
#include <drivers/gpio.h>
#include <sys/printk.h>
/* This pin is used to enable the serial port using the board controller */
#ifdef CONFIG_BOARD_EFR32_RADIO_BRD4180A
#define VCOM_ENABLE_GPIO_NAME "GPIO_D"
#define VCOM_ENABLE_GPIO_PIN 4
#else
#define VCOM_ENABLE_GPIO_NAME "GPIO_A"
#define VCOM_ENABLE_GPIO_PIN 5
#endif /* CONFIG_BOARD_EFR32_RADIO_BRD4180A */
static int efr32_radio_init(const struct device *dev)
{
const struct device *vce_dev; /* Virtual COM Port Enable GPIO Device */
ARG_UNUSED(dev);
/* Enable the board controller to be able to use the serial port */
vce_dev = device_get_binding(VCOM_ENABLE_GPIO_NAME);
if (!vce_dev) {
printk("Virtual COM Port Enable device was not found!\n");
return -ENODEV;
}
gpio_pin_configure(vce_dev, VCOM_ENABLE_GPIO_PIN, GPIO_OUTPUT_HIGH);
return 0;
}
/* needs to be done after GPIO driver init */
SYS_INIT(efr32_radio_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);