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:
Vincent Wan 2020-05-27 10:57:22 -07:00 committed by Carles Cufí
commit 002de4decf

View file

@ -282,23 +282,36 @@ static const struct spi_driver_api spi_cc13xx_cc26xx_driver_api = {
.release = spi_cc13xx_cc26xx_release, .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 #ifdef CONFIG_SYS_POWER_MANAGEMENT
#define SPI_CC13XX_CC26XX_POWER_SPI(n) \ #define SPI_CC13XX_CC26XX_POWER_SPI(n) \
/* Set Power dependencies & constraints */ \ do { \
Power_setDependency(PowerCC26XX_PERIPH_SSI##n) /* Set Power dependencies & constraints */ \
if (DT_INST_REG_ADDR(n) == 0x40000000) { \
Power_setDependency(PowerCC26XX_PERIPH_SSI0); \
} else { \
Power_setDependency(PowerCC26XX_PERIPH_SSI1); \
} \
} while (0)
#else #else
#define SPI_CC13XX_CC26XX_POWER_SPI(n) \ #define SPI_CC13XX_CC26XX_POWER_SPI(n) \
do { \ 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 */ \ /* Enable SSI##n power domain */ \
PRCMPowerDomainOn(SPI_CC13XX_CC26XX_DOMAIN_##n); \ PRCMPowerDomainOn(domain); \
\ \
/* Enable SSI##n peripherals */ \ /* Enable SSI##n peripherals */ \
PRCMPeripheralRunEnable(PRCM_PERIPH_SSI##n); \ PRCMPeripheralRunEnable(periph); \
PRCMPeripheralSleepEnable(PRCM_PERIPH_SSI##n); \ PRCMPeripheralSleepEnable(periph); \
PRCMPeripheralDeepSleepEnable(PRCM_PERIPH_SSI##n); \ PRCMPeripheralDeepSleepEnable(periph); \
\ \
/* Load PRCM settings */ \ /* Load PRCM settings */ \
PRCMLoadSet(); \ 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. */\ /* SSI should not be accessed until power domain is on. */\
while (PRCMPowerDomainStatus( \ while (PRCMPowerDomainStatus(domain) != \
SPI_CC13XX_CC26XX_DOMAIN_##n) != \
PRCM_DOMAIN_POWER_ON) { \ PRCM_DOMAIN_POWER_ON) { \
continue; \ continue; \
} \ } \