From 2b5f78a88f9bc1f3ff302d66b8c90288b2b281b3 Mon Sep 17 00:00:00 2001 From: Maureen Helm Date: Tue, 14 Jan 2020 13:58:54 -0600 Subject: [PATCH] disk: Convert sdhc spi driver to new gpio api Converts the sdhc spi driver to the new gpio api. Updates device trees for the olimexino_stm32 and nrf52840_blip boards to set appropriate active high/low polarity for the spi chip select pin. Signed-off-by: Maureen Helm --- boards/arm/olimexino_stm32/olimexino_stm32.dts | 2 +- samples/subsys/fs/fat_fs/nrf52840_blip.overlay | 2 +- subsys/disk/disk_access_spi_sdhc.c | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/boards/arm/olimexino_stm32/olimexino_stm32.dts b/boards/arm/olimexino_stm32/olimexino_stm32.dts index 1b949cc4ff7..6620221e725 100644 --- a/boards/arm/olimexino_stm32/olimexino_stm32.dts +++ b/boards/arm/olimexino_stm32/olimexino_stm32.dts @@ -79,7 +79,7 @@ uext_serial: &usart1 {}; &spi2 { status = "okay"; - cs-gpios = <&gpiod 2 0>; + cs-gpios = <&gpiod 2 GPIO_ACTIVE_HIGH>; sdhc0: sdhc@0 { compatible = "zephyr,mmc-spi-slot"; diff --git a/samples/subsys/fs/fat_fs/nrf52840_blip.overlay b/samples/subsys/fs/fat_fs/nrf52840_blip.overlay index 23ed37192f7..3cc2f39a3c3 100644 --- a/samples/subsys/fs/fat_fs/nrf52840_blip.overlay +++ b/samples/subsys/fs/fat_fs/nrf52840_blip.overlay @@ -6,7 +6,7 @@ &spi1 { status = "okay"; - cs-gpios = <&gpio0 17 0>; + cs-gpios = <&gpio0 17 GPIO_ACTIVE_HIGH>; sdhc0: sdhc@0 { compatible = "zephyr,mmc-spi-slot"; diff --git a/subsys/disk/disk_access_spi_sdhc.c b/subsys/disk/disk_access_spi_sdhc.c index 87bcf6c6983..03ef1bec38d 100644 --- a/subsys/disk/disk_access_spi_sdhc.c +++ b/subsys/disk/disk_access_spi_sdhc.c @@ -28,6 +28,7 @@ struct sdhc_spi_data { struct spi_config cfg; struct device *cs; u32_t pin; + gpio_devicetree_flags_t flags; bool high_capacity; u32_t sector_count; @@ -71,7 +72,7 @@ static int sdhc_spi_trace(struct sdhc_spi_data *data, int dir, int err, /* Asserts or deasserts chip select */ static void sdhc_spi_set_cs(struct sdhc_spi_data *data, int value) { - gpio_pin_write(data->cs, data->pin, value); + gpio_pin_set(data->cs, data->pin, value); } /* Receives a fixed number of bytes */ @@ -775,10 +776,12 @@ static int sdhc_spi_init(struct device *dev) __ASSERT_NO_MSG(data->cs != NULL); data->pin = DT_INST_0_ZEPHYR_MMC_SPI_SLOT_CS_GPIOS_PIN; + data->flags = DT_INST_0_ZEPHYR_MMC_SPI_SLOT_CS_GPIOS_FLAGS; disk_spi_sdhc_init(dev); - return gpio_pin_configure(data->cs, data->pin, GPIO_DIR_OUT); + return gpio_pin_configure(data->cs, data->pin, + GPIO_OUTPUT_INACTIVE | data->flags); } static int disk_spi_sdhc_access_status(struct disk_info *disk)