drivers: spi: cc13xx_cc26xx: set power config based on SPI base addr
The power configuration is dependent on which SPI is physically used. In order to allow DT_INST_FOREACH_STATUS_OKAY() to iterate through instances without the assumption that index 0 corresponds to SPI0 (which would be incorrect in the case when only SPI1 is enabled), we need to check the base address to identify which SPI is being dealt with. Fixes #25673 Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
This commit is contained in:
parent
6af9793f0c
commit
002de4decf
1 changed files with 24 additions and 12 deletions
|
@ -282,23 +282,36 @@ static const struct spi_driver_api spi_cc13xx_cc26xx_driver_api = {
|
|||
.release = spi_cc13xx_cc26xx_release,
|
||||
};
|
||||
|
||||
#define SPI_CC13XX_CC26XX_DOMAIN_0 PRCM_DOMAIN_SERIAL
|
||||
#define SPI_CC13XX_CC26XX_DOMAIN_1 PRCM_DOMAIN_PERIPH
|
||||
|
||||
#ifdef CONFIG_SYS_POWER_MANAGEMENT
|
||||
#define SPI_CC13XX_CC26XX_POWER_SPI(n) \
|
||||
do { \
|
||||
/* Set Power dependencies & constraints */ \
|
||||
Power_setDependency(PowerCC26XX_PERIPH_SSI##n)
|
||||
if (DT_INST_REG_ADDR(n) == 0x40000000) { \
|
||||
Power_setDependency(PowerCC26XX_PERIPH_SSI0); \
|
||||
} else { \
|
||||
Power_setDependency(PowerCC26XX_PERIPH_SSI1); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define SPI_CC13XX_CC26XX_POWER_SPI(n) \
|
||||
do { \
|
||||
u32_t domain, periph; \
|
||||
\
|
||||
/* Enable UART power domain */ \
|
||||
if (DT_INST_REG_ADDR(n) == 0x40000000) { \
|
||||
domain = PRCM_DOMAIN_SERIAL; \
|
||||
periph = PRCM_PERIPH_SSI0; \
|
||||
} else { \
|
||||
domain = PRCM_DOMAIN_PERIPH; \
|
||||
periph = PRCM_PERIPH_SSI1; \
|
||||
} \
|
||||
/* Enable SSI##n power domain */ \
|
||||
PRCMPowerDomainOn(SPI_CC13XX_CC26XX_DOMAIN_##n); \
|
||||
PRCMPowerDomainOn(domain); \
|
||||
\
|
||||
/* Enable SSI##n peripherals */ \
|
||||
PRCMPeripheralRunEnable(PRCM_PERIPH_SSI##n); \
|
||||
PRCMPeripheralSleepEnable(PRCM_PERIPH_SSI##n); \
|
||||
PRCMPeripheralDeepSleepEnable(PRCM_PERIPH_SSI##n); \
|
||||
PRCMPeripheralRunEnable(periph); \
|
||||
PRCMPeripheralSleepEnable(periph); \
|
||||
PRCMPeripheralDeepSleepEnable(periph); \
|
||||
\
|
||||
/* Load PRCM settings */ \
|
||||
PRCMLoadSet(); \
|
||||
|
@ -307,8 +320,7 @@ static const struct spi_driver_api spi_cc13xx_cc26xx_driver_api = {
|
|||
} \
|
||||
\
|
||||
/* SSI should not be accessed until power domain is on. */\
|
||||
while (PRCMPowerDomainStatus( \
|
||||
SPI_CC13XX_CC26XX_DOMAIN_##n) != \
|
||||
while (PRCMPowerDomainStatus(domain) != \
|
||||
PRCM_DOMAIN_POWER_ON) { \
|
||||
continue; \
|
||||
} \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue