disk: Fix nxp usdhc driver optional gpio properties

The power and chip detect gpios are optional device tree properties for
the nxp usdhc driver. Fixes a build error on the mm_swiftio board, which
does not set the power gpio property.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
This commit is contained in:
Maureen Helm 2020-10-21 19:09:10 -05:00 committed by Kumar Gala
parent abc72694ab
commit 10d33e2d28

View file

@ -2804,6 +2804,28 @@ static int disk_usdhc_init(const struct device *dev)
return disk_access_register(&usdhc_disk);
}
#define DISK_ACCESS_USDHC_INIT_NONE(n)
#define DISK_ACCESS_USDHC_INIT_PWR_PROPS(n) \
.pwr_name = DT_INST_GPIO_LABEL(n, pwr_gpios), \
.pwr_pin = DT_INST_GPIO_PIN(n, pwr_gpios), \
.pwr_flags = DT_INST_GPIO_FLAGS(n, pwr_gpios),
#define DISK_ACCESS_USDHC_INIT_CD_PROPS(n) \
.detect_name = DT_INST_GPIO_LABEL(n, cd_gpios), \
.detect_pin = DT_INST_GPIO_PIN(n, cd_gpios), \
.detect_flags = DT_INST_GPIO_FLAGS(n, cd_gpios),
#define DISK_ACCESS_USDHC_INIT_PWR(n) \
COND_CODE_1(DT_INST_NODE_HAS_PROP(n, pwr_gpios), \
(DISK_ACCESS_USDHC_INIT_PWR_PROPS(n)), \
(DISK_ACCESS_USDHC_INIT_NONE(n)))
#define DISK_ACCESS_USDHC_INIT_CD(n) \
COND_CODE_1(DT_INST_NODE_HAS_PROP(n, cd_gpios), \
(DISK_ACCESS_USDHC_INIT_CD_PROPS(n)), \
(DISK_ACCESS_USDHC_INIT_NONE(n)))
#define DISK_ACCESS_USDHC_INIT(n) \
static const struct usdhc_config usdhc_config_##n = { \
.base = (USDHC_Type *) DT_INST_REG_ADDR(n), \
@ -2811,12 +2833,8 @@ static int disk_usdhc_init(const struct device *dev)
.clock_subsys = \
(clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name), \
.nusdhc = n, \
.pwr_name = DT_INST_GPIO_LABEL(n, pwr_gpios), \
.pwr_pin = DT_INST_GPIO_PIN(n, pwr_gpios), \
.pwr_flags = DT_INST_GPIO_FLAGS(n, pwr_gpios), \
.detect_name = DT_INST_GPIO_LABEL(n, cd_gpios), \
.detect_pin = DT_INST_GPIO_PIN(n, cd_gpios), \
.detect_flags = DT_INST_GPIO_FLAGS(n, cd_gpios), \
DISK_ACCESS_USDHC_INIT_PWR(n) \
DISK_ACCESS_USDHC_INIT_CD(n) \
.data_timeout = USDHC_DATA_TIMEOUT, \
.endian = USDHC_LITTLE_ENDIAN, \
.read_watermark = USDHC_READ_WATERMARK_LEVEL, \