drivers: usb_dc_nrfx: Enable and properly initialize nrfx POWER driver
This is a follow-up to commit 701e9befe4
.
The NRFX_POWER Kconfig option should be enabled together with USB_NRFX,
not with CLOCK_CONTROL_NRF, as the USB driver is the actual user of
the nrfx POWER driver.
This patch adds also missing initialization of the nrfx POWER driver
and refactors a bit the usb_init() function introduced in the commit
mentioned above, so that it does not redefine the DT_DRV_COMPAT macro
and uses for conditional compilation the same Kconfig option that is
the dependency of NRFX_USBREG.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
This commit is contained in:
parent
30908a91ce
commit
460a97d378
3 changed files with 14 additions and 11 deletions
|
@ -15,7 +15,6 @@ menuconfig CLOCK_CONTROL_NRF
|
|||
depends on SOC_COMPATIBLE_NRF
|
||||
depends on !CLOCK_CONTROL_NRF_FORCE_ALT
|
||||
select NRFX_CLOCK
|
||||
select NRFX_POWER
|
||||
default y
|
||||
help
|
||||
Enable support for the Nordic Semiconductor nRFxx series SoC clock
|
||||
|
|
|
@ -53,8 +53,8 @@ menuconfig USB_NRFX
|
|||
depends on HAS_HW_NRF_USBD
|
||||
select USB_DEVICE_DRIVER
|
||||
select NRFX_USBD
|
||||
select NRFX_POWER
|
||||
select USB_DEVICE_DISABLE_ZLP_EPIN_HANDLING
|
||||
select NRFX_USBREG if SOC_SERIES_NRF53X
|
||||
help
|
||||
nRF USB Device Controller Driver
|
||||
|
||||
|
|
|
@ -1927,24 +1927,28 @@ int usb_dc_wakeup_request(void)
|
|||
|
||||
static int usb_init(const struct device *arg)
|
||||
{
|
||||
|
||||
#ifdef CONFIG_SOC_SERIES_NRF53X
|
||||
#undef DT_DRV_COMPAT
|
||||
#define DT_DRV_COMPAT nordic_nrf_clock
|
||||
|
||||
#ifdef CONFIG_HAS_HW_NRF_USBREG
|
||||
/* Use CLOCK/POWER priority for compatibility with other series where
|
||||
* USB events are handled by CLOCK interrupt handler.
|
||||
*/
|
||||
IRQ_CONNECT(USBREGULATOR_IRQn, DT_INST_IRQ(0, priority),
|
||||
nrfx_usbreg_irq_handler, 0, 0);
|
||||
IRQ_CONNECT(USBREGULATOR_IRQn,
|
||||
DT_IRQ(DT_INST(0, nordic_nrf_clock), priority),
|
||||
nrfx_isr, nrfx_usbreg_irq_handler, 0);
|
||||
irq_enable(USBREGULATOR_IRQn);
|
||||
#endif
|
||||
|
||||
static const nrfx_power_usbevt_config_t config = {
|
||||
/* Use default configuration of the nrfx_power driver. */
|
||||
static const nrfx_power_config_t power_config = { 0 };
|
||||
|
||||
static const nrfx_power_usbevt_config_t usbevt_config = {
|
||||
.handler = usb_dc_power_event_handler
|
||||
};
|
||||
|
||||
nrfx_power_usbevt_init(&config);
|
||||
/* Ignore the return value, as NRFX_ERROR_ALREADY_INITIALIZED is not
|
||||
* a problem here.
|
||||
*/
|
||||
(void)nrfx_power_init(&power_config);
|
||||
nrfx_power_usbevt_init(&usbevt_config);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue