Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DT-related fixes in UART driver for CC13xx/CC26xx #25647

Merged
merged 2 commits into from
May 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 31 additions & 42 deletions drivers/serial/uart_cc13xx_cc26xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,17 +490,18 @@ 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 { \
get_dev_data(dev)->rx_constrained = false; \
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, \
Expand All @@ -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(); \
Expand All @@ -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; \
} \
Expand Down Expand Up @@ -555,52 +564,32 @@ 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 { \
get_dev_data(dev)->pm_state = DEVICE_PM_ACTIVE_STATE; \
} 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
Expand Down