diff --git a/drivers/serial/uart_cc13xx_cc26xx.c b/drivers/serial/uart_cc13xx_cc26xx.c index 235782539f1c7d..fe35720c9abe0f 100644 --- a/drivers/serial/uart_cc13xx_cc26xx.c +++ b/drivers/serial/uart_cc13xx_cc26xx.c @@ -490,9 +490,6 @@ static const struct uart_driver_api uart_cc13xx_cc26xx_driver_api = { #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ }; -#define UART_CC13XX_CC26XX_DOMAIN_0 PRCM_DOMAIN_SERIAL -#define UART_CC13XX_CC26XX_DOMAIN_1 PRCM_DOMAIN_PERIPH - #ifdef CONFIG_SYS_POWER_MANAGEMENT #define UART_CC13XX_CC26XX_POWER_UART(n) \ do { \ @@ -500,7 +497,11 @@ static const struct uart_driver_api uart_cc13xx_cc26xx_driver_api = { get_dev_data(dev)->tx_constrained = false; \ \ /* Set Power dependencies */ \ - Power_setDependency(PowerCC26XX_PERIPH_UART##n); \ + if (DT_INST_REG_ADDR(n) == 0x40001000) { \ + Power_setDependency(PowerCC26XX_PERIPH_UART0); \ + } else { \ + Power_setDependency(PowerCC26X2_PERIPH_UART1); \ + } \ \ /* Register notification function */ \ Power_registerNotify(&get_dev_data(dev)->postNotify, \ @@ -510,12 +511,21 @@ static const struct uart_driver_api uart_cc13xx_cc26xx_driver_api = { #else #define UART_CC13XX_CC26XX_POWER_UART(n) \ do { \ + u32_t domain, periph; \ + \ /* Enable UART power domain */ \ - PRCMPowerDomainOn(UART_CC13XX_CC26XX_DOMAIN_##n); \ + if (DT_INST_REG_ADDR(n) == 0x40001000) { \ + domain = PRCM_DOMAIN_SERIAL; \ + periph = PRCM_PERIPH_UART0; \ + } else { \ + domain = PRCM_DOMAIN_PERIPH; \ + periph = PRCM_PERIPH_UART1; \ + } \ + PRCMPowerDomainOn(domain); \ \ /* Enable UART peripherals */ \ - PRCMPeripheralRunEnable(PRCM_PERIPH_UART##n); \ - PRCMPeripheralSleepEnable(PRCM_PERIPH_UART##n); \ + PRCMPeripheralRunEnable(periph); \ + PRCMPeripheralSleepEnable(periph); \ \ /* Load PRCM settings */ \ PRCMLoadSet(); \ @@ -524,8 +534,7 @@ static const struct uart_driver_api uart_cc13xx_cc26xx_driver_api = { } \ \ /* UART should not be accessed until power domain is on. */ \ - while (PRCMPowerDomainStatus( \ - UART_CC13XX_CC26XX_DOMAIN_##n) != \ + while (PRCMPowerDomainStatus(domain) != \ PRCM_DOMAIN_POWER_ON) { \ continue; \ } \ @@ -555,44 +564,24 @@ static const struct uart_driver_api uart_cc13xx_cc26xx_driver_api = { #define UART_CC13XX_CC26XX_INT_FIELDS #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ -/* - * DEVICE_DEFINE() requires the kernel level to be explicitly passed - * using the actual macro name, hence we are forced to list these permutations - * out. - */ -#define UART_CC13XX_CC26XX_DEVICE_DEFINE_0 \ - DEVICE_DEFINE(uart_cc13xx_cc26xx_0, DT_INST_LABEL(0), \ - uart_cc13xx_cc26xx_init_0, \ - uart_cc13xx_cc26xx_pm_control, \ - &uart_cc13xx_cc26xx_data_0, &uart_cc13xx_cc26xx_config_0,\ - PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \ - &uart_cc13xx_cc26xx_driver_api) - -#define UART_CC13XX_CC26XX_DEVICE_DEFINE_1 \ - DEVICE_DEFINE(uart_cc13xx_cc26xx_1, DT_INST_LABEL(1), \ - uart_cc13xx_cc26xx_init_1, \ - uart_cc13xx_cc26xx_pm_control, \ - &uart_cc13xx_cc26xx_data_1, &uart_cc13xx_cc26xx_config_1,\ - POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \ - &uart_cc13xx_cc26xx_driver_api) - -#define UART_CC13XX_CC26XX_DEVICE_API_INIT_0 \ - DEVICE_AND_API_INIT(uart_cc13xx_cc26xx_0, DT_INST_LABEL(0), \ - uart_cc13xx_cc26xx_init_0, &uart_cc13xx_cc26xx_data_0, \ - &uart_cc13xx_cc26xx_config_0, PRE_KERNEL_1, \ - CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \ +#define UART_CC13XX_CC26XX_DEVICE_DEFINE(n) \ + DEVICE_DEFINE(uart_cc13xx_cc26xx_##n, DT_INST_LABEL(n), \ + uart_cc13xx_cc26xx_init_##n, \ + uart_cc13xx_cc26xx_pm_control, \ + &uart_cc13xx_cc26xx_data_##n, &uart_cc13xx_cc26xx_config_##n,\ + PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \ &uart_cc13xx_cc26xx_driver_api) -#define UART_CC13XX_CC26XX_DEVICE_API_INIT_1 \ - DEVICE_AND_API_INIT(uart_cc13xx_cc26xx_1, DT_INST_LABEL(1), \ - uart_cc13xx_cc26xx_init_1, &uart_cc13xx_cc26xx_data_1, \ - &uart_cc13xx_cc26xx_config_1, POST_KERNEL, \ - CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \ +#define UART_CC13XX_CC26XX_DEVICE_API_INIT(n) \ + DEVICE_AND_API_INIT(uart_cc13xx_cc26xx_##n, DT_INST_LABEL(n), \ + uart_cc13xx_cc26xx_init_##n, &uart_cc13xx_cc26xx_data_##n, \ + &uart_cc13xx_cc26xx_config_##n, PRE_KERNEL_1, \ + CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \ &uart_cc13xx_cc26xx_driver_api) #ifdef CONFIG_DEVICE_POWER_MANAGEMENT #define UART_CC13XX_CC26XX_DEVICE_INIT(n) \ - UART_CC13XX_CC26XX_DEVICE_DEFINE_##n + UART_CC13XX_CC26XX_DEVICE_DEFINE(n) #define UART_CC13XX_CC26XX_INIT_PM_STATE \ do { \ @@ -600,7 +589,7 @@ static const struct uart_driver_api uart_cc13xx_cc26xx_driver_api = { } while (0) #else #define UART_CC13XX_CC26XX_DEVICE_INIT(n) \ - UART_CC13XX_CC26XX_DEVICE_API_INIT_##n + UART_CC13XX_CC26XX_DEVICE_API_INIT(n) #define UART_CC13XX_CC26XX_INIT_PM_STATE #endif