stm32: Use DT_NUM_INST_STATUS_OKAY for num IRQ sources
Use DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) to determine number of potential interrupt sources. This mitigates the wasting of memory on devices with mutliple UCPD ports but only one UCPD port is used. Signed-off-by: Sam Hurst <sbh1187@gmail.com>
This commit is contained in:
parent
99e07709ff
commit
050323f00f
1 changed files with 38 additions and 30 deletions
|
@ -1010,7 +1010,6 @@ static void ucpd_isr(const struct device *dev_inst[])
|
||||||
const struct tcpc_config *config;
|
const struct tcpc_config *config;
|
||||||
struct tcpc_data *data;
|
struct tcpc_data *data;
|
||||||
uint32_t sr;
|
uint32_t sr;
|
||||||
uint32_t ucpd_base;
|
|
||||||
struct alert_info *info;
|
struct alert_info *info;
|
||||||
uint32_t tx_done_mask = UCPD_SR_TXMSGSENT |
|
uint32_t tx_done_mask = UCPD_SR_TXMSGSENT |
|
||||||
UCPD_SR_TXMSGABT |
|
UCPD_SR_TXMSGABT |
|
||||||
|
@ -1018,39 +1017,48 @@ static void ucpd_isr(const struct device *dev_inst[])
|
||||||
UCPD_SR_HRSTSENT |
|
UCPD_SR_HRSTSENT |
|
||||||
UCPD_SR_HRSTDISC;
|
UCPD_SR_HRSTDISC;
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_SOC_SERIES_STM32G0X)) {
|
#if DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) > 1
|
||||||
/*
|
/*
|
||||||
* Since the UCPD peripherals share the same interrupt line, determine
|
* Multiple UCPD ports are available
|
||||||
* which one generated the interrupt.
|
*/
|
||||||
*/
|
|
||||||
if (LL_SYSCFG_IsActiveFlag_UCPD1()) {
|
|
||||||
/* UCPD1 interrupt is pending */
|
|
||||||
ucpd_base = UCPD1_BASE;
|
|
||||||
} else if (LL_SYSCFG_IsActiveFlag_UCPD2()) {
|
|
||||||
/* UCPD2 interrupt is pending */
|
|
||||||
ucpd_base = UCPD2_BASE;
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* The interrupt was triggered by some other device sharing this
|
|
||||||
* interrupt line.
|
|
||||||
*/
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find correct device instance for this port */
|
uint32_t ucpd_base;
|
||||||
for (int i = 0; i < DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT); i++) {
|
|
||||||
dev = dev_inst[i];
|
/*
|
||||||
config = dev->config;
|
* Since the UCPD peripherals share the same interrupt line, determine
|
||||||
if ((uint32_t)(config->ucpd_port) == ucpd_base) {
|
* which one generated the interrupt.
|
||||||
break;
|
*/
|
||||||
}
|
if (LL_SYSCFG_IsActiveFlag_UCPD1()) {
|
||||||
}
|
/* UCPD1 interrupt is pending */
|
||||||
|
ucpd_base = UCPD1_BASE;
|
||||||
|
} else if (LL_SYSCFG_IsActiveFlag_UCPD2()) {
|
||||||
|
/* UCPD2 interrupt is pending */
|
||||||
|
ucpd_base = UCPD2_BASE;
|
||||||
} else {
|
} else {
|
||||||
/* Only one port available */
|
/*
|
||||||
dev = dev_inst[0];
|
* The interrupt was triggered by some other device sharing this
|
||||||
config = dev->config;
|
* interrupt line.
|
||||||
|
*/
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Find correct device instance for this port */
|
||||||
|
for (int i = 0; i < DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT); i++) {
|
||||||
|
dev = dev_inst[i];
|
||||||
|
config = dev->config;
|
||||||
|
if ((uint32_t)(config->ucpd_port) == ucpd_base) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/*
|
||||||
|
* Only one UCPD port available
|
||||||
|
*/
|
||||||
|
|
||||||
|
dev = dev_inst[0];
|
||||||
|
config = dev->config;
|
||||||
|
#endif /* Get the UCPD port that initiated that interrupt */
|
||||||
|
|
||||||
data = dev->data;
|
data = dev->data;
|
||||||
info = &data->alert_info;
|
info = &data->alert_info;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue