drivers: usb: stm32: Store dt clock information into an array
Use STM32_DT_INST_CLOCKS() to access usb device clock information. This will help accessing domain clock information from dt nodes. Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This commit is contained in:
parent
fccf4c95c0
commit
cbc44075b7
1 changed files with 9 additions and 17 deletions
|
@ -64,8 +64,9 @@ LOG_MODULE_REGISTER(usb_dc_stm32);
|
||||||
#define USB_IRQ_PRI DT_INST_IRQ_BY_NAME(0, USB_IRQ_NAME, priority)
|
#define USB_IRQ_PRI DT_INST_IRQ_BY_NAME(0, USB_IRQ_NAME, priority)
|
||||||
#define USB_NUM_BIDIR_ENDPOINTS DT_INST_PROP(0, num_bidir_endpoints)
|
#define USB_NUM_BIDIR_ENDPOINTS DT_INST_PROP(0, num_bidir_endpoints)
|
||||||
#define USB_RAM_SIZE DT_INST_PROP(0, ram_size)
|
#define USB_RAM_SIZE DT_INST_PROP(0, ram_size)
|
||||||
#define USB_CLOCK_BITS DT_INST_CLOCKS_CELL(0, bits)
|
|
||||||
#define USB_CLOCK_BUS DT_INST_CLOCKS_CELL(0, bus)
|
static const struct stm32_pclken pclken[] = STM32_DT_INST_CLOCKS(0);
|
||||||
|
|
||||||
#if DT_INST_NODE_HAS_PROP(0, maximum_speed)
|
#if DT_INST_NODE_HAS_PROP(0, maximum_speed)
|
||||||
#define USB_MAXIMUM_SPEED DT_INST_PROP(0, maximum_speed)
|
#define USB_MAXIMUM_SPEED DT_INST_PROP(0, maximum_speed)
|
||||||
#endif
|
#endif
|
||||||
|
@ -206,11 +207,11 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd)
|
||||||
static int usb_dc_stm32_clock_enable(void)
|
static int usb_dc_stm32_clock_enable(void)
|
||||||
{
|
{
|
||||||
const struct device *const clk = DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE);
|
const struct device *const clk = DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE);
|
||||||
struct stm32_pclken pclken = {
|
|
||||||
.bus = USB_CLOCK_BUS,
|
|
||||||
.enr = USB_CLOCK_BITS,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
if (!device_is_ready(clk)) {
|
||||||
|
LOG_ERR("clock control device not ready");
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Some SoCs in STM32F0/L0/L4 series disable USB clock by
|
* Some SoCs in STM32F0/L0/L4 series disable USB clock by
|
||||||
* default. We force USB clock source to MSI or PLL clock for this
|
* default. We force USB clock source to MSI or PLL clock for this
|
||||||
|
@ -268,12 +269,7 @@ static int usb_dc_stm32_clock_enable(void)
|
||||||
|
|
||||||
#endif /* RCC_HSI48_SUPPORT / LL_RCC_USB_CLKSOURCE_NONE */
|
#endif /* RCC_HSI48_SUPPORT / LL_RCC_USB_CLKSOURCE_NONE */
|
||||||
|
|
||||||
if (!device_is_ready(clk)) {
|
if (clock_control_on(clk, (clock_control_subsys_t *)&pclken[0]) != 0) {
|
||||||
LOG_ERR("clock control device not ready");
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clock_control_on(clk, (clock_control_subsys_t *)&pclken) != 0) {
|
|
||||||
LOG_ERR("Unable to enable USB clock");
|
LOG_ERR("Unable to enable USB clock");
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
@ -304,12 +300,8 @@ static int usb_dc_stm32_clock_enable(void)
|
||||||
static int usb_dc_stm32_clock_disable(void)
|
static int usb_dc_stm32_clock_disable(void)
|
||||||
{
|
{
|
||||||
const struct device *clk = DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE);
|
const struct device *clk = DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE);
|
||||||
struct stm32_pclken pclken = {
|
|
||||||
.bus = USB_CLOCK_BUS,
|
|
||||||
.enr = USB_CLOCK_BITS,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (clock_control_off(clk, (clock_control_subsys_t *)&pclken) != 0) {
|
if (clock_control_off(clk, (clock_control_subsys_t *)&pclken[0]) != 0) {
|
||||||
LOG_ERR("Unable to disable USB clock");
|
LOG_ERR("Unable to disable USB clock");
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue