You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ag...@apache.org on 2020/05/15 22:11:43 UTC

[incubator-nuttx] branch master updated (35efcee -> e6a984d)

This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from 35efcee  net/netdev/netdev_register.c:  Add some comments.
     new 369293d  boards/arm/stm32h7/stm32h747i-disco: bring support for SDMMC
     new 07bd520  arch/arm/src/stm32h7/stm32_sdmmc: check IDMA buffer address
     new 583d81e  boards/arm/stm32h7/stm32h747i-disco: bring FAT DMA allocator
     new 2d43c57  boards/arm/stm32h7/stm32h747i-disco: SDMMC card detect interrupt
     new 4585af3  boards/arm/stm32h7/stm32h747i-disco: change the license header of all new files to an Apache 2.0 license.
     new 671191d  boards/arm/stm32h7/stm32h747i-disco: fix nxstyle warnings
     new e6a984d  arch/arm/src/stm32h7/stm32_sdmmc.c:  Fix wrong selection in modifying the conflict.

The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 arch/arm/src/stm32h7/hardware/stm32_exti.h         | 130 ++++++++++-----------
 arch/arm/src/stm32h7/hardware/stm32_sdmmc.h        |   2 +
 arch/arm/src/stm32h7/stm32_exti_gpio.c             |   4 +-
 arch/arm/src/stm32h7/stm32_sdmmc.c                 |  59 +++++++---
 boards/arm/stm32h7/stm32h747i-disco/src/Makefile   |   8 ++
 .../stm32h7/stm32h747i-disco/src/stm32_bringup.c   |  18 +++
 .../stm32h747i-disco}/src/stm32_dma_alloc.c        |   4 +-
 .../stm32h747i-disco/src/stm32_sdmmc.c}            |  29 ++---
 .../stm32h747i-disco/src/stm32h747i-disco.h        |  44 ++++++-
 9 files changed, 196 insertions(+), 102 deletions(-)
 copy boards/arm/{stm32/nucleo-f429zi => stm32h7/stm32h747i-disco}/src/stm32_dma_alloc.c (97%)
 copy boards/arm/{stm32/nucleo-f429zi/src/stm32_sdio.c => stm32h7/stm32h747i-disco/src/stm32_sdmmc.c} (88%)


[incubator-nuttx] 06/07: boards/arm/stm32h7/stm32h747i-disco: fix nxstyle warnings

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 671191d7a192c633d8468d61f97f4a6649699183
Author: Pierre-Olivier Vauboin <po...@lambdaconcept.com>
AuthorDate: Tue Apr 14 12:52:06 2020 +0200

    boards/arm/stm32h7/stm32h747i-disco: fix nxstyle warnings
---
 arch/arm/src/stm32h7/hardware/stm32_exti.h         | 124 ++++++++++-----------
 .../stm32h7/stm32h747i-disco/src/stm32_bringup.c   |   3 +-
 .../stm32h7/stm32h747i-disco/src/stm32_dma_alloc.c |  12 +-
 .../arm/stm32h7/stm32h747i-disco/src/stm32_sdmmc.c |   4 +-
 .../stm32h747i-disco/src/stm32h747i-disco.h        |   4 -
 5 files changed, 73 insertions(+), 74 deletions(-)

diff --git a/arch/arm/src/stm32h7/hardware/stm32_exti.h b/arch/arm/src/stm32h7/hardware/stm32_exti.h
index ea140ad..538197c 100644
--- a/arch/arm/src/stm32h7/hardware/stm32_exti.h
+++ b/arch/arm/src/stm32h7/hardware/stm32_exti.h
@@ -186,68 +186,68 @@
 /* EXTI event input mapping *********************************************************/
 
 #define EXTI_EVENT_EXTI(n)          (1 << (n) /* 0-15 EXTI[15:0] */
-#define EXTI_EVENT_PVDAVD           16  /* PVD and AVD */
-#define EXTI_EVENT_RTCALARM         17  /* RTC alarms */
-#define EXTI_EVENT_RTC              18  /* RTC tamper, RTC timestamp, RCC LSECSS */
-#define EXTI_EVENT_RTCWKUP          19  /* RTC wakeup timer */
-#define EXTI_EVENT_COMP1            20  /* COMP1 */
-#define EXTI_EVENT_COMP2            21  /* COMP2 */
-#define EXTI_EVENT_I2C1WKUP         22  /* I2C1 wakeup */
-#define EXTI_EVENT_I2C2WKUP         23  /* I2C2 wakeup */
-#define EXTI_EVENT_I2C3WKUP         24  /* I2C3 wakeup */
-#define EXTI_EVENT_I2C4WKUP         25  /* I2C4 wakeup */
-#define EXTI_EVENT_USART1WKUP       26  /* USART1 wakeup */
-#define EXTI_EVENT_USART2WKUP       27  /* USART2 wakeup */
-#define EXTI_EVENT_USART3WKUP       28  /* USART3 wakeup */
-#define EXTI_EVENT_USART6WKUP       29  /* USART6 wakeup */
-#define EXTI_EVENT_UART4WKUP        30  /* UART4 wakeup */
-#define EXTI_EVENT_UART5WKUP        31  /* UART5 wakeup */
-#define EXTI_EVENT_UART7WKUP        32  /* UART7 wakeup */
-#define EXTI_EVENT_UART8WKUP        33  /* UART8 wakeup */
-#define EXTI_EVENT_LPUARTRXWKUP     34  /* LPUART1 RX wakeup */
-#define EXTI_EVENT_LPUARTTXWKUP     35  /* LPUART1 TX wakeup */
-#define EXTI_EVENT_SPI1WKUP         36  /* SPI1 wakeup */
-#define EXTI_EVENT_SPI2WKUP         37  /* SPI2 wakeup */
-#define EXTI_EVENT_SPI3WKUP         38  /* SPI3 wakeup */
-#define EXTI_EVENT_SPI4WKUP         39  /* SPI4 wakeup */
-#define EXTI_EVENT_SPI5WKUP         40  /* SPI5 wakeup */
-#define EXTI_EVENT_SPI6WKUP         41  /* SPI6 wakeup */
-#define EXTI_EVENT_MDIOWKUP         42  /* MDIO wakeup */
-#define EXTI_EVENT_USB1WKUP         43  /* USB1 wakeup */
-#define EXTI_EVENT_USB2WKUP         44  /* USB2 wakeup */
-#define EXTI_EVENT_LPTIM1WKUP       47  /* LPTIM1 wakeup */
-#define EXTI_EVENT_LPTIM2WKUP       48  /* LPTIM2 wakeup */
-#define EXTI_EVENT_LPTM2OUT         49  /* LPTIM2 output */
-#define EXTI_EVENT_LPTIM3WKUP       50  /* LPTIM3 wakeup */
-#define EXTI_EVENT_LPTIM3OUT        51  /* LPTIM3 output */
-#define EXTI_EVENT_LPTIM4WKUP       52  /* LPTIM4 wakeup */
-#define EXTI_EVENT_LPTIM5WKUP       53  /* LPTIM5 wakeup */
-#define EXTI_EVENT_SWPMIWKUP        54  /* SWPMI wakeup */
-#define EXTI_EVENT_WKUP1            55  /* WKUP1 */
-#define EXTI_EVENT_WKUP2            56  /* WKUP2 */
-#define EXTI_EVENT_WKUP3            57  /* WKUP3 */
-#define EXTI_EVENT_WKUP4            58  /* WKUP4 */
-#define EXTI_EVENT_WKUP5            59  /* WKUP5 */
-#define EXTI_EVENT_WKUP6            60  /* WKUP6 */
-#define EXTI_EVENT_RCC              61  /* RCC interrupt */
-#define EXTI_EVENT_I2C4EV           62  /* I2C4 Event interrupt */
-#define EXTI_EVENT_I2C4ERR          63  /* I2C4 Error interrupt */
-#define EXTI_EVENT_LPUART1          64  /* LPUART1 global Interrupt */
-#define EXTI_EVENT_SPI6             65  /* SPI6 interrupt */
-#define EXTI_EVENT_BDMA0            66  /* BDMA CH0 interrupt */
-#define EXTI_EVENT_BDMA1            67  /* BDMA CH1 interrupt */
-#define EXTI_EVENT_BDMA2            68  /* BDMA CH2 interrupt */
-#define EXTI_EVENT_BDMA3            69  /* BDMA CH3 interrupt */
-#define EXTI_EVENT_BDMA4            70  /* BDMA CH4 interrupt */
-#define EXTI_EVENT_RDMB5            71  /* BDMA CH5 interrupt */
-#define EXTI_EVENT_BDMA6            72  /* BDMA CH6 interrupt */
-#define EXTI_EVENT_BDMA7            73  /* BDMA CH7 interrupt */
-#define EXTI_EVENT_DMAMUX2          74  /* DMAMUX2 interrupt */
-#define EXTI_EVENT_ADC3             75  /* ADC3 interrupt */
-#define EXTI_EVENT_SAI4             76  /* SAI4 interrupt */
-#define EXTI_EVENT_CECWKUP          85  /* HDMI-CEC wakeup */
-#define EXTI_EVENT_ETHWKUP          86  /* Ethernet wakeup */
-#define EXTI_EVENT_HSECSS           87  /* HSECSS interrupt */
+#define EXTI_EVENT_PVDAVD           16        /* PVD and AVD */
+#define EXTI_EVENT_RTCALARM         17        /* RTC alarms */
+#define EXTI_EVENT_RTC              18        /* RTC tamper, RTC timestamp, RCC LSECSS */
+#define EXTI_EVENT_RTCWKUP          19        /* RTC wakeup timer */
+#define EXTI_EVENT_COMP1            20        /* COMP1 */
+#define EXTI_EVENT_COMP2            21        /* COMP2 */
+#define EXTI_EVENT_I2C1WKUP         22        /* I2C1 wakeup */
+#define EXTI_EVENT_I2C2WKUP         23        /* I2C2 wakeup */
+#define EXTI_EVENT_I2C3WKUP         24        /* I2C3 wakeup */
+#define EXTI_EVENT_I2C4WKUP         25        /* I2C4 wakeup */
+#define EXTI_EVENT_USART1WKUP       26        /* USART1 wakeup */
+#define EXTI_EVENT_USART2WKUP       27        /* USART2 wakeup */
+#define EXTI_EVENT_USART3WKUP       28        /* USART3 wakeup */
+#define EXTI_EVENT_USART6WKUP       29        /* USART6 wakeup */
+#define EXTI_EVENT_UART4WKUP        30        /* UART4 wakeup */
+#define EXTI_EVENT_UART5WKUP        31        /* UART5 wakeup */
+#define EXTI_EVENT_UART7WKUP        32        /* UART7 wakeup */
+#define EXTI_EVENT_UART8WKUP        33        /* UART8 wakeup */
+#define EXTI_EVENT_LPUARTRXWKUP     34        /* LPUART1 RX wakeup */
+#define EXTI_EVENT_LPUARTTXWKUP     35        /* LPUART1 TX wakeup */
+#define EXTI_EVENT_SPI1WKUP         36        /* SPI1 wakeup */
+#define EXTI_EVENT_SPI2WKUP         37        /* SPI2 wakeup */
+#define EXTI_EVENT_SPI3WKUP         38        /* SPI3 wakeup */
+#define EXTI_EVENT_SPI4WKUP         39        /* SPI4 wakeup */
+#define EXTI_EVENT_SPI5WKUP         40        /* SPI5 wakeup */
+#define EXTI_EVENT_SPI6WKUP         41        /* SPI6 wakeup */
+#define EXTI_EVENT_MDIOWKUP         42        /* MDIO wakeup */
+#define EXTI_EVENT_USB1WKUP         43        /* USB1 wakeup */
+#define EXTI_EVENT_USB2WKUP         44        /* USB2 wakeup */
+#define EXTI_EVENT_LPTIM1WKUP       47        /* LPTIM1 wakeup */
+#define EXTI_EVENT_LPTIM2WKUP       48        /* LPTIM2 wakeup */
+#define EXTI_EVENT_LPTM2OUT         49        /* LPTIM2 output */
+#define EXTI_EVENT_LPTIM3WKUP       50        /* LPTIM3 wakeup */
+#define EXTI_EVENT_LPTIM3OUT        51        /* LPTIM3 output */
+#define EXTI_EVENT_LPTIM4WKUP       52        /* LPTIM4 wakeup */
+#define EXTI_EVENT_LPTIM5WKUP       53        /* LPTIM5 wakeup */
+#define EXTI_EVENT_SWPMIWKUP        54        /* SWPMI wakeup */
+#define EXTI_EVENT_WKUP1            55        /* WKUP1 */
+#define EXTI_EVENT_WKUP2            56        /* WKUP2 */
+#define EXTI_EVENT_WKUP3            57        /* WKUP3 */
+#define EXTI_EVENT_WKUP4            58        /* WKUP4 */
+#define EXTI_EVENT_WKUP5            59        /* WKUP5 */
+#define EXTI_EVENT_WKUP6            60        /* WKUP6 */
+#define EXTI_EVENT_RCC              61        /* RCC interrupt */
+#define EXTI_EVENT_I2C4EV           62        /* I2C4 Event interrupt */
+#define EXTI_EVENT_I2C4ERR          63        /* I2C4 Error interrupt */
+#define EXTI_EVENT_LPUART1          64        /* LPUART1 global Interrupt */
+#define EXTI_EVENT_SPI6             65        /* SPI6 interrupt */
+#define EXTI_EVENT_BDMA0            66        /* BDMA CH0 interrupt */
+#define EXTI_EVENT_BDMA1            67        /* BDMA CH1 interrupt */
+#define EXTI_EVENT_BDMA2            68        /* BDMA CH2 interrupt */
+#define EXTI_EVENT_BDMA3            69        /* BDMA CH3 interrupt */
+#define EXTI_EVENT_BDMA4            70        /* BDMA CH4 interrupt */
+#define EXTI_EVENT_RDMB5            71        /* BDMA CH5 interrupt */
+#define EXTI_EVENT_BDMA6            72        /* BDMA CH6 interrupt */
+#define EXTI_EVENT_BDMA7            73        /* BDMA CH7 interrupt */
+#define EXTI_EVENT_DMAMUX2          74        /* DMAMUX2 interrupt */
+#define EXTI_EVENT_ADC3             75        /* ADC3 interrupt */
+#define EXTI_EVENT_SAI4             76        /* SAI4 interrupt */
+#define EXTI_EVENT_CECWKUP          85        /* HDMI-CEC wakeup */
+#define EXTI_EVENT_ETHWKUP          86        /* Ethernet wakeup */
+#define EXTI_EVENT_HSECSS           87        /* HSECSS interrupt */
 
 #endif /* CONFIG_STM32H7_STM32H7X3XX || CONFIG_STM32H7_STM32H7X7XX */
 #endif /* __ARCH_ARM_SRC_STM32H7_HARDWARE_STM32_EXTI_H */
diff --git a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_bringup.c b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_bringup.c
index a21db33..11b615e 100644
--- a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_bringup.c
+++ b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_bringup.c
@@ -228,7 +228,8 @@ int stm32_bringup(void)
   ret = stm32_sdio_initialize();
   if (ret < 0)
     {
-      syslog(LOG_ERR, "ERROR: Failed to initialize MMC/SD driver: %d\n", ret);
+      syslog(LOG_ERR,
+             "ERROR: Failed to initialize MMC/SD driver: %d\n", ret);
     }
 #endif
 
diff --git a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_dma_alloc.c b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_dma_alloc.c
index b8485af..e1e9654 100644
--- a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_dma_alloc.c
+++ b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_dma_alloc.c
@@ -51,14 +51,16 @@ static GRAN_HANDLE dma_allocator;
 /* The DMA heap size constrains the total number of things that can be
  * ready to do DMA at a time.
  *
- * For example, FAT DMA depends on one sector-sized buffer per filesystem plus
- * one sector-sized buffer per file.
+ * For example, FAT DMA depends on one sector-sized buffer per
+ * filesystem plus one sector-sized buffer per file.
  *
- * We use a fundamental alignment / granule size of 64B; this is sufficient
- * to guarantee alignment for the largest STM32 DMA burst (16 beats x 32bits).
+ * We use a fundamental alignment / granule size of 64B; this is
+ * sufficient to guarantee alignment for the largest STM32 DMA burst
+ * (16 beats x 32bits).
  */
 
-static uint8_t g_dma_heap[BOARD_DMA_ALLOC_POOL_SIZE] __attribute__((aligned(64)));
+static uint8_t g_dma_heap[BOARD_DMA_ALLOC_POOL_SIZE]
+                __attribute__((aligned(64)));
 
 /****************************************************************************
  * Public Functions
diff --git a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_sdmmc.c b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_sdmmc.c
index 8b33efb..58d1d9b 100644
--- a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_sdmmc.c
+++ b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_sdmmc.c
@@ -113,8 +113,8 @@ int stm32_sdio_initialize(void)
 
   /* Register an interrupt handler for the card detect pin */
 
-  (void)stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true,
-                           stm32_ncd_interrupt, NULL);
+  stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true,
+                     stm32_ncd_interrupt, NULL);
 #endif
 
   /* Mount the SDIO-based MMC/SD block driver */
diff --git a/boards/arm/stm32h7/stm32h747i-disco/src/stm32h747i-disco.h b/boards/arm/stm32h7/stm32h747i-disco/src/stm32h747i-disco.h
index f57a2d7..d4aa95e 100644
--- a/boards/arm/stm32h7/stm32h747i-disco/src/stm32h747i-disco.h
+++ b/boards/arm/stm32h7/stm32h747i-disco/src/stm32h747i-disco.h
@@ -123,10 +123,6 @@
 #define SDIO_MINOR         0
 
 /****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
  * Name: stm32_bringup
  *
  * Description:


[incubator-nuttx] 04/07: boards/arm/stm32h7/stm32h747i-disco: SDMMC card detect interrupt

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 2d43c57a67f53819942cf02119ece428c73b7f70
Author: Pierre-Olivier Vauboin <po...@lambdaconcept.com>
AuthorDate: Wed Apr 1 12:46:35 2020 +0200

    boards/arm/stm32h7/stm32h747i-disco: SDMMC card detect interrupt
---
 arch/arm/src/stm32h7/hardware/stm32_exti.h                 | 4 ++--
 arch/arm/src/stm32h7/stm32_exti_gpio.c                     | 4 ++--
 boards/arm/stm32h7/stm32h747i-disco/src/stm32h747i-disco.h | 2 ++
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/arm/src/stm32h7/hardware/stm32_exti.h b/arch/arm/src/stm32h7/hardware/stm32_exti.h
index 0667c9e..ea140ad 100644
--- a/arch/arm/src/stm32h7/hardware/stm32_exti.h
+++ b/arch/arm/src/stm32h7/hardware/stm32_exti.h
@@ -48,7 +48,7 @@
  * families
  */
 
-#if defined(CONFIG_STM32H7_STM32H7X3XX)
+#if defined(CONFIG_STM32H7_STM32H7X3XX) || defined(CONFIG_STM32H7_STM32H7X7XX)
 
 /************************************************************************************
  * Pre-processor Definitions
@@ -249,5 +249,5 @@
 #define EXTI_EVENT_ETHWKUP          86  /* Ethernet wakeup */
 #define EXTI_EVENT_HSECSS           87  /* HSECSS interrupt */
 
-#endif /* CONFIG_STM32H7_STM32H7X3XX */
+#endif /* CONFIG_STM32H7_STM32H7X3XX || CONFIG_STM32H7_STM32H7X7XX */
 #endif /* __ARCH_ARM_SRC_STM32H7_HARDWARE_STM32_EXTI_H */
diff --git a/arch/arm/src/stm32h7/stm32_exti_gpio.c b/arch/arm/src/stm32h7/stm32_exti_gpio.c
index 35ba242..f3d5f5d 100644
--- a/arch/arm/src/stm32h7/stm32_exti_gpio.c
+++ b/arch/arm/src/stm32h7/stm32_exti_gpio.c
@@ -66,7 +66,7 @@
  * families
  */
 
-#if defined(CONFIG_STM32H7_STM32H7X3XX)
+#if defined(CONFIG_STM32H7_STM32H7X3XX) || defined(CONFIG_STM32H7_STM32H7X7XX)
 
 /****************************************************************************
  * Private Types
@@ -396,4 +396,4 @@ int stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
   return OK;
 }
 
-#endif /* CONFIG_STM32H7_STM32H7X3XX */
+#endif /* CONFIG_STM32H7_STM32H7X3XX || CONFIG_STM32H7_STM32H7X7XX */
diff --git a/boards/arm/stm32h7/stm32h747i-disco/src/stm32h747i-disco.h b/boards/arm/stm32h7/stm32h747i-disco/src/stm32h747i-disco.h
index 9ab7000..f57a2d7 100644
--- a/boards/arm/stm32h7/stm32h747i-disco/src/stm32h747i-disco.h
+++ b/boards/arm/stm32h7/stm32h747i-disco/src/stm32h747i-disco.h
@@ -117,6 +117,8 @@
 #  undef HAVE_SDIO
 #endif
 
+#define GPIO_SDIO_NCD      (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTI|GPIO_PIN8)
+
 #define SDIO_SLOTNO        0
 #define SDIO_MINOR         0
 


[incubator-nuttx] 07/07: arch/arm/src/stm32h7/stm32_sdmmc.c: Fix wrong selection in modifying the conflict.

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit e6a984dc2b40b8fd96195b5c90e2305561a65e4c
Author: Gregory Nutt <gn...@nuttx.org>
AuthorDate: Fri May 15 15:40:39 2020 -0600

    arch/arm/src/stm32h7/stm32_sdmmc.c:  Fix wrong selection in modifying the conflict.
---
 arch/arm/src/stm32h7/stm32_sdmmc.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/arch/arm/src/stm32h7/stm32_sdmmc.c b/arch/arm/src/stm32h7/stm32_sdmmc.c
index 93af586..4c087ab 100644
--- a/arch/arm/src/stm32h7/stm32_sdmmc.c
+++ b/arch/arm/src/stm32h7/stm32_sdmmc.c
@@ -1526,17 +1526,6 @@ static void stm32_endtransfer(struct stm32_dev_s *priv,
 
   sdmmc_putreg32(priv, STM32_SDMMC_XFRDONE_ICR, STM32_SDMMC_ICR_OFFSET);
 
-#if defined(CONFIG_STM32H7_SDMMC_IDMA) && \
-    !defined(CONFIG_ARCH_HAVE_SDIO_DELAYED_INVLDT)
-  /* invalidate dcache in case of DMA receive. */
-
-  if (priv->receivecnt)
-    {
-      up_invalidate_dcache((uintptr_t)priv->buffer,
-                           (uintptr_t)priv->buffer + priv->remaining);
-    }
-#endif
-
   /* DMA debug instrumentation */
 
   stm32_sample(priv, SAMPLENDX_END_TRANSFER);
@@ -1748,7 +1737,7 @@ static int stm32_sdmmc_interrupt(int irq, void *context, void *arg)
                */
 
               mcerr("ERROR: Data block CRC failure, remaining: %d\n",
-                   priv->remaining);
+                    priv->remaining);
 
               stm32_endtransfer(priv,
                                 SDIOWAIT_TRANSFERDONE | SDIOWAIT_ERROR);
@@ -3081,8 +3070,8 @@ static int stm32_dmapreflight(FAR struct sdio_dev_s *dev,
           (uintptr_t)buffer + buflen <= SRAM4_END))
         {
           mcerr("invalid IDMA address "
-                  "buffer:0x%08x end:0x%08x\n",
-                  buffer, buffer + buflen - 1);
+                "buffer:0x%08x end:0x%08x\n",
+                buffer, buffer + buflen - 1);
           return -EFAULT;
         }
     }
@@ -3101,8 +3090,8 @@ static int stm32_dmapreflight(FAR struct sdio_dev_s *dev,
       ((uintptr_t)(buffer + buflen) & (ARMV7M_DCACHE_LINESIZE - 1)) != 0))
     {
       mcerr("dcache unaligned "
-              "buffer:0x%08x end:0x%08x\n",
-              buffer, buffer + buflen - 1);
+            "buffer:0x%08x end:0x%08x\n",
+            buffer, buffer + buflen - 1);
       return -EFAULT;
     }
 #  endif


[incubator-nuttx] 03/07: boards/arm/stm32h7/stm32h747i-disco: bring FAT DMA allocator

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 583d81e3dea2572da301124ffaf2781b92e1d5f2
Author: Pierre-Olivier Vauboin <po...@lambdaconcept.com>
AuthorDate: Tue Mar 31 18:11:33 2020 +0200

    boards/arm/stm32h7/stm32h747i-disco: bring FAT DMA allocator
    
    Buffers are allocated in the main ram, which is suitable for use with the
    underlying STM32H7 SDMMC1 core in IDMA mode.
    
    Files are copied from stm32f7/nucleo-144.
---
 boards/arm/stm32h7/stm32h747i-disco/src/Makefile   |   4 +
 .../stm32h7/stm32h747i-disco/src/stm32_bringup.c   |   7 ++
 .../stm32h7/stm32h747i-disco/src/stm32_dma_alloc.c | 117 +++++++++++++++++++++
 .../stm32h747i-disco/src/stm32h747i-disco.h        |  15 +++
 4 files changed, 143 insertions(+)

diff --git a/boards/arm/stm32h7/stm32h747i-disco/src/Makefile b/boards/arm/stm32h7/stm32h747i-disco/src/Makefile
index 9518e4f..9241b0c 100644
--- a/boards/arm/stm32h7/stm32h747i-disco/src/Makefile
+++ b/boards/arm/stm32h7/stm32h747i-disco/src/Makefile
@@ -72,4 +72,8 @@ ifeq ($(CONFIG_STM32H7_SDMMC), y)
 CSRCS += stm32_sdmmc.c
 endif
 
+ifeq ($(CONFIG_FAT_DMAMEMORY), y)
+CSRCS += stm32_dma_alloc.c
+endif
+
 include $(TOPDIR)/boards/Board.mk
diff --git a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_bringup.c b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_bringup.c
index 28c1939..a21db33 100644
--- a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_bringup.c
+++ b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_bringup.c
@@ -215,6 +215,13 @@ int stm32_bringup(void)
     }
 #endif /* CONFIG_ADC */
 
+#if defined(CONFIG_FAT_DMAMEMORY)
+  if (stm32_dma_alloc_init() < 0)
+    {
+      syslog(LOG_ERR, "DMA alloc FAILED");
+    }
+#endif
+
 #ifdef HAVE_SDIO
   /* Initialize the SDIO block driver */
 
diff --git a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_dma_alloc.c b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_dma_alloc.c
new file mode 100644
index 0000000..8498d5a
--- /dev/null
+++ b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_dma_alloc.c
@@ -0,0 +1,117 @@
+/****************************************************************************
+ * boards/arm/stm32h7/stm32h747i-disco/src/stm32_dma_alloc.c
+ *
+ *   Copyright (C) 2016 PX4 Development Team. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 3. Neither the name PX4 nor the names of its contributors may be
+ *    used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <syslog.h>
+#include <stdint.h>
+#include <errno.h>
+#include <nuttx/mm/gran.h>
+
+#include "stm32h747i-disco.h"
+
+#if defined(CONFIG_FAT_DMAMEMORY)
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#if !defined(CONFIG_GRAN)
+#  error microSD DMA support requires CONFIG_GRAN
+#endif
+
+#define BOARD_DMA_ALLOC_POOL_SIZE (8*512)
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static GRAN_HANDLE dma_allocator;
+
+/* The DMA heap size constrains the total number of things that can be
+ * ready to do DMA at a time.
+ *
+ * For example, FAT DMA depends on one sector-sized buffer per filesystem plus
+ * one sector-sized buffer per file.
+ *
+ * We use a fundamental alignment / granule size of 64B; this is sufficient
+ * to guarantee alignment for the largest STM32 DMA burst (16 beats x 32bits).
+ */
+
+static uint8_t g_dma_heap[BOARD_DMA_ALLOC_POOL_SIZE] __attribute__((aligned(64)));
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_dma_alloc_init
+ *
+ * Description:
+ *   All boards may optionally provide this API to instantiate a pool of
+ *   memory for uses with FAST FS DMA operations.
+ *
+ ****************************************************************************/
+
+int stm32_dma_alloc_init(void)
+{
+  dma_allocator = gran_initialize(g_dma_heap,
+                                  sizeof(g_dma_heap),
+                                  7,  /* 128B granule - must be > alignment (XXX bug?) */
+                                  6); /* 64B alignment */
+
+  if (dma_allocator == NULL)
+    {
+      return -ENOMEM;
+    }
+
+  return OK;
+}
+
+/* DMA-aware allocator stubs for the FAT filesystem. */
+
+void *fat_dma_alloc(size_t size)
+{
+  return gran_alloc(dma_allocator, size);
+}
+
+void fat_dma_free(FAR void *memory, size_t size)
+{
+  gran_free(dma_allocator, memory, size);
+}
+
+#endif /* CONFIG_FAT_DMAMEMORY */
diff --git a/boards/arm/stm32h7/stm32h747i-disco/src/stm32h747i-disco.h b/boards/arm/stm32h7/stm32h747i-disco/src/stm32h747i-disco.h
index a5c43ad7..9ab7000 100644
--- a/boards/arm/stm32h7/stm32h747i-disco/src/stm32h747i-disco.h
+++ b/boards/arm/stm32h7/stm32h747i-disco/src/stm32h747i-disco.h
@@ -165,6 +165,21 @@ int stm32_adc_setup(void);
 #endif
 
 /****************************************************************************
+ * Name: stm32_dma_alloc_init
+ *
+ * Description:
+ *   Called to create a FAT DMA allocator
+ *
+ * Returned Value:
+ *   0 on success or -ENOMEM
+ *
+ ****************************************************************************/
+
+#if defined (CONFIG_FAT_DMAMEMORY)
+int stm32_dma_alloc_init(void);
+#endif
+
+/****************************************************************************
  * Name: stm32_sdio_initialize
  *
  * Description:


[incubator-nuttx] 02/07: arch/arm/src/stm32h7/stm32_sdmmc: check IDMA buffer address

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 07bd520ccb36ac51aaa8347886d576fe68ec8979
Author: Pierre-Olivier Vauboin <po...@lambdaconcept.com>
AuthorDate: Tue Mar 31 17:51:01 2020 +0200

    arch/arm/src/stm32h7/stm32_sdmmc: check IDMA buffer address
    
    For SDMMC1, IDMA cannot access SRAM123 or SRAM4. Refer to ST AN5200 for
    details. This patch makes stm32_dmapreflight check the buffer address and
    return an error when the buffer is located in a invalid address space.
    
    This does not fix the hardware limitation but at least makes it visible.
---
 arch/arm/src/stm32h7/stm32_sdmmc.c | 64 ++++++++++++++++++++++++++++++++------
 1 file changed, 54 insertions(+), 10 deletions(-)

diff --git a/arch/arm/src/stm32h7/stm32_sdmmc.c b/arch/arm/src/stm32h7/stm32_sdmmc.c
index 99a98d9..93af586 100644
--- a/arch/arm/src/stm32h7/stm32_sdmmc.c
+++ b/arch/arm/src/stm32h7/stm32_sdmmc.c
@@ -98,6 +98,12 @@
  * be monitored off the an HP work thread for a residual of less than
  * FIFO_SIZE_IN_BYTES / 2.
  *
+ * HW Issues when using IDMA
+ *
+ *    The DMA buffer must be located in a zone accessible via IDMA.
+ * For SDMMC1, IDMA cannot access SRAM123 or SRAM4. Refer to ST AN5200.
+ * Buffer validity is checked when CONFIG_ARCH_HAVE_SDIO_PREFLIGHT is set.
+ *
  * MDMA is only available on for SDMMC1 and Not supported at this time.
  *
  * Required system configuration options:
@@ -110,13 +116,13 @@
  *     APIs to manage concurrent accesses on the SDMMC bus.  This is not
  *     needed for the simple case of a single SD card, for example.
  *   CONFIG_STM32H7_SDMMC_IDMA - Enable SDMMC IDMA.
- *     DMA support for SDMMC. If disabled disabled, the SDMMC will work in
+ *     DMA support for SDMMC. If disabled, the SDMMC will work in
  *     interrupt mode and still use the IDMA to a local buffer for data
  *     lengths less the 32 bytes due to the FIFO limitations.
  *   CONFIG_SDMMC1/2_WIDTH_D1_ONLY - This may be selected to force the driver
  *     operate with only a single data line (the default is to use all
  *     4 SD data lines).
- *   CONFIG_CONFIG_STM32H7_SDMMC_XFRDEBUG - Enables some very low-level debug
+ *   CONFIG_STM32H7_SDMMC_XFRDEBUG - Enables some very low-level debug
  *     output This also requires CONFIG_DEBUG_FS and CONFIG_DEBUG_INFO
  *   CONFIG_SDMMC1/2_SDIO_MODE
  *     Build ins additional support needed only for SDIO cards (vs. SD memory
@@ -141,6 +147,11 @@
 
 #if !defined(CONFIG_STM32H7_SDMMC_IDMA)
 #  warning "Large Non-DMA transfer may result in RX overrun failures"
+#elif defined(CONFIG_STM32H7_SDMMC1)
+#  define SRAM123_START STM32_SRAM123_BASE
+#  define SRAM123_END   (SRAM123_START + STM32H7_SRAM123_SIZE)
+#  define SRAM4_START   STM32_SRAM4_BASE
+#  define SRAM4_END     (SRAM4_START + STM32H7_SRAM4_SIZE)
 #endif
 
 #ifndef CONFIG_SCHED_WORKQUEUE
@@ -153,7 +164,7 @@
 #endif
 
 #if !defined(CONFIG_DEBUG_FS) || !defined(CONFIG_DEBUG_FEATURES)
-#  undef CONFIG_CONFIG_STM32H7_SDMMC_XFRDEBUG
+#  undef CONFIG_STM32H7_SDMMC_XFRDEBUG
 #endif
 
 #ifdef CONFIG_SDMMC1_SDIO_PULLUP
@@ -1515,6 +1526,21 @@ static void stm32_endtransfer(struct stm32_dev_s *priv,
 
   sdmmc_putreg32(priv, STM32_SDMMC_XFRDONE_ICR, STM32_SDMMC_ICR_OFFSET);
 
+#if defined(CONFIG_STM32H7_SDMMC_IDMA) && \
+    !defined(CONFIG_ARCH_HAVE_SDIO_DELAYED_INVLDT)
+  /* invalidate dcache in case of DMA receive. */
+
+  if (priv->receivecnt)
+    {
+      up_invalidate_dcache((uintptr_t)priv->buffer,
+                           (uintptr_t)priv->buffer + priv->remaining);
+    }
+#endif
+
+  /* DMA debug instrumentation */
+
+  stm32_sample(priv, SAMPLENDX_END_TRANSFER);
+
   /* Mark the transfer finished */
 
   priv->remaining = 0;
@@ -3038,7 +3064,29 @@ static int stm32_registercallback(FAR struct sdio_dev_s *dev,
 static int stm32_dmapreflight(FAR struct sdio_dev_s *dev,
                               FAR const uint8_t *buffer, size_t buflen)
 {
-  /* DMA must be possible to the buffer */
+  struct stm32_dev_s *priv = (struct stm32_dev_s *)dev;
+
+  DEBUGASSERT(priv != NULL && buffer != NULL && buflen > 0);
+
+  /* IDMA must be possible to the buffer */
+
+#if defined(CONFIG_STM32H7_SDMMC1)
+  if (priv->base == STM32_SDMMC1_BASE)
+    {
+      /* For SDMMC1, IDMA cannot access SRAM123 or SRAM4. */
+
+      if (((uintptr_t)buffer >= SRAM123_START &&
+          (uintptr_t)buffer + buflen <= SRAM123_END) ||
+          ((uintptr_t)buffer >= SRAM4_START &&
+          (uintptr_t)buffer + buflen <= SRAM4_END))
+        {
+          mcerr("invalid IDMA address "
+                  "buffer:0x%08x end:0x%08x\n",
+                  buffer, buffer + buflen - 1);
+          return -EFAULT;
+        }
+    }
+#endif
 
 #  if defined(CONFIG_ARMV7M_DCACHE) && !defined(CONFIG_ARMV7M_DCACHE_WRITETHROUGH)
   /* buffer alignment is required for DMA transfers with dcache in buffered
@@ -3048,15 +3096,11 @@ static int stm32_dmapreflight(FAR struct sdio_dev_s *dev,
    * ARMV7M_DCACHE_LINESIZE boundaries.
    */
 
-  struct stm32_dev_s *priv = (struct stm32_dev_s *)dev;
-
-  DEBUGASSERT(priv != NULL && buffer != NULL && buflen > 0);
-
   if (buffer != priv->rxfifo &&
       (((uintptr_t)buffer & (ARMV7M_DCACHE_LINESIZE - 1)) != 0 ||
       ((uintptr_t)(buffer + buflen) & (ARMV7M_DCACHE_LINESIZE - 1)) != 0))
     {
-      dmainfo("stm32_dmapreflight: dcache unaligned "
+      mcerr("dcache unaligned "
               "buffer:0x%08x end:0x%08x\n",
               buffer, buffer + buflen - 1);
       return -EFAULT;
@@ -3276,7 +3320,7 @@ static int stm32_dmasendsetup(FAR struct sdio_dev_s *dev,
 static int stm32_dmadelydinvldt(FAR struct sdio_dev_s *dev,
                               FAR const uint8_t *buffer, size_t buflen)
 {
-  /* Invaliate cache to physical memory when not in DTCM memory. */
+  /* Invalidate cache to physical memory when not in DTCM memory. */
 
   if ((uintptr_t)buffer < DTCM_START ||
       (uintptr_t)buffer + buflen > DTCM_END)


[incubator-nuttx] 01/07: boards/arm/stm32h7/stm32h747i-disco: bring support for SDMMC

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 369293dd840127c55061340c76d1fa83233c7818
Author: Pierre-Olivier Vauboin <po...@lambdaconcept.com>
AuthorDate: Tue Mar 31 17:35:20 2020 +0200

    boards/arm/stm32h7/stm32h747i-disco: bring support for SDMMC
---
 arch/arm/src/stm32h7/hardware/stm32_sdmmc.h        |   2 +
 boards/arm/stm32h7/stm32h747i-disco/src/Makefile   |   4 +
 .../stm32h7/stm32h747i-disco/src/stm32_bringup.c   |  10 ++
 .../src/{stm32h747i-disco.h => stm32_sdmmc.c}      | 185 ++++++++++++---------
 .../stm32h747i-disco/src/stm32h747i-disco.h        |  25 +++
 5 files changed, 144 insertions(+), 82 deletions(-)

diff --git a/arch/arm/src/stm32h7/hardware/stm32_sdmmc.h b/arch/arm/src/stm32h7/hardware/stm32_sdmmc.h
index 752b226..5f56274 100644
--- a/arch/arm/src/stm32h7/hardware/stm32_sdmmc.h
+++ b/arch/arm/src/stm32h7/hardware/stm32_sdmmc.h
@@ -47,6 +47,8 @@
 
 #if defined(CONFIG_STM32H7_STM32H7X3XX)
 #  include "stm32h7x3xx_sdmmc.h"
+#elif defined(CONFIG_STM32H7_STM32H7X7XX)
+#  include "stm32h7x3xx_sdmmc.h"
 #else
 #  error "Unsupported STM32 H7 part"
 #endif
diff --git a/boards/arm/stm32h7/stm32h747i-disco/src/Makefile b/boards/arm/stm32h7/stm32h747i-disco/src/Makefile
index d82ebb1..9518e4f 100644
--- a/boards/arm/stm32h7/stm32h747i-disco/src/Makefile
+++ b/boards/arm/stm32h7/stm32h747i-disco/src/Makefile
@@ -68,4 +68,8 @@ ifeq ($(CONFIG_LIB_BOARDCTL),y)
 CSRCS += stm32_appinitialize.c
 endif
 
+ifeq ($(CONFIG_STM32H7_SDMMC), y)
+CSRCS += stm32_sdmmc.c
+endif
+
 include $(TOPDIR)/boards/Board.mk
diff --git a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_bringup.c b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_bringup.c
index 80ae17a..28c1939 100644
--- a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_bringup.c
+++ b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_bringup.c
@@ -215,5 +215,15 @@ int stm32_bringup(void)
     }
 #endif /* CONFIG_ADC */
 
+#ifdef HAVE_SDIO
+  /* Initialize the SDIO block driver */
+
+  ret = stm32_sdio_initialize();
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: Failed to initialize MMC/SD driver: %d\n", ret);
+    }
+#endif
+
   return OK;
 }
diff --git a/boards/arm/stm32h7/stm32h747i-disco/src/stm32h747i-disco.h b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_sdmmc.c
similarity index 51%
copy from boards/arm/stm32h7/stm32h747i-disco/src/stm32h747i-disco.h
copy to boards/arm/stm32h7/stm32h747i-disco/src/stm32_sdmmc.c
index 7bc2e30..6546d69 100644
--- a/boards/arm/stm32h7/stm32h747i-disco/src/stm32h747i-disco.h
+++ b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_sdmmc.c
@@ -1,9 +1,8 @@
 /****************************************************************************
- * boards/arm/stm32h7/stm32h747i-disco/src/stm32h747i-disco.h
+ * boards/arm/stm32h7/stm32h747i-disco/src/stm32_sdmmc.c
  *
-#   Copyright (C) 2017, 2019 Gwenhael Goavec-Merou. All rights reserved.
-#   Authors: Gwenhael Goavec-Merou<gw...@trabucayre.com>
- *           David Sidrane <da...@nscdg.com>
+ *   Copyright (C) 2016-2019 Gregory Nutt. All rights reserved.
+ *   Author: Gregory Nutt <gn...@nuttx.org>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -34,17 +33,23 @@
  *
  ****************************************************************************/
 
-#ifndef __BOARDS_ARM_STM32H7_STM32H747I_DISCO_SRC_STM32H747I_DISCO_H
-#define __BOARDS_ARM_STM32H7_STM32H747I_DISCO_SRC_STM32H747I_DISCO_H
-
 /****************************************************************************
  * Included Files
  ****************************************************************************/
 
 #include <nuttx/config.h>
-#include <nuttx/compiler.h>
 
-#include <stdint.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <debug.h>
+#include <errno.h>
+
+#include <nuttx/sdio.h>
+#include <nuttx/mmcsd.h>
+
+#include "stm32_gpio.h"
+#include "stm32_sdmmc.h"
+#include "stm32h747i-disco.h"
 
 /****************************************************************************
  * Pre-processor Definitions
@@ -52,103 +57,119 @@
 
 /* Configuration ************************************************************/
 
-/* procfs File System */
+/* Card detections requires card support and a card detection GPIO */
 
-#ifdef CONFIG_FS_PROCFS
-#  ifdef CONFIG_NSH_PROC_MOUNTPOINT
-#    define STM32_PROCFS_MOUNTPOINT CONFIG_NSH_PROC_MOUNTPOINT
-#  else
-#    define STM32_PROCFS_MOUNTPOINT "/proc"
-#  endif
+#define HAVE_NCD   1
+#if !defined(HAVE_SDIO) || !defined(GPIO_SDIO_NCD)
+#  undef HAVE_NCD
 #endif
 
-/* Check if we can support the RTC driver */
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
 
-#define HAVE_RTC_DRIVER 1
-#if !defined(CONFIG_RTC) || !defined(CONFIG_RTC_DRIVER)
-#  undef HAVE_RTC_DRIVER
+static FAR struct sdio_dev_s *g_sdio_dev;
+#ifdef HAVE_NCD
+static bool g_sd_inserted = 0xff; /* Impossible value */
 #endif
 
-/* LED
- *
- * LD1 Green   PI12
- * LD2 Orange  PI13
- * LD3 Red     PI14
- * LD4 Blue    PI15
- */
-
-#define GPIO_LD1        (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | \
-                         GPIO_PORTI | GPIO_PIN12)
-#define GPIO_LD2        (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | \
-                         GPIO_PORTI | GPIO_PIN13)
-#define GPIO_LD3        (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | \
-                         GPIO_PORTI | GPIO_PIN14)
-#define GPIO_LD4        (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | \
-                         GPIO_PORTI | GPIO_PIN15)
-
-#define GPIO_LED_GREEN  GPIO_LD1
-#define GPIO_LED_ORANGE GPIO_LD2
-#define GPIO_LED_RED    GPIO_LD3
-#define GPIO_LED_BLUE   GPIO_LD4
-
-#define LED_DRIVER_PATH "/dev/userleds"
-
-/* BUTTONS
- *
- * The Blue pushbutton B1, labeled "Wakeup", is connected to GPIO PC13.  A
- * high value will be sensed when the button is depressed.
- *
- * Notes:
- *    1) That the EXTI is included in the definition to enable an interrupt
- *       on this IO.
- *    2) The following definitions assume the default Solder Bridges are
- *       installed.
- */
-
-#define GPIO_BTN_USER  (GPIO_INPUT | GPIO_FLOAT | GPIO_EXTI | GPIO_PORTC | GPIO_PIN13)
-
 /****************************************************************************
- * Public Functions
+ * Private Functions
  ****************************************************************************/
 
 /****************************************************************************
- * Name: stm32_bringup
+ * Name: stm32_ncd_interrupt
  *
  * Description:
- *   Perform architecture-specific initialization
- *
- *   CONFIG_BOARD_LATE_INITIALIZE=y :
- *     Called from board_late_initialize().
- *
- *   CONFIG_BOARD_LATE_INITIALIZE=y && CONFIG_LIB_BOARDCTL=y :
- *     Called from the NSH library
+ *   Card detect interrupt handler.
  *
  ****************************************************************************/
 
-int stm32_bringup(void);
+#ifdef HAVE_NCD
+static int stm32_ncd_interrupt(int irq, FAR void *context, FAR void *param)
+{
+  bool present;
 
-/****************************************************************************
- * Name: stm32_spidev_initialize
- *
- * Description:
- *   Called to configure SPI chip select GPIO pins for the board.
- *
- ****************************************************************************/
+  present = !stm32_gpioread(GPIO_SDIO_NCD);
+  if (present != g_sd_inserted)
+    {
+      sdio_mediachange(g_sdio_dev, present);
+      g_sd_inserted = present;
+    }
 
-#ifdef CONFIG_STM32H7_SPI
-void stm32_spidev_initialize(void);
+  return OK;
+}
 #endif
 
 /****************************************************************************
- * Name: stm32_adc_setup
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_sdio_initialize
  *
  * Description:
- *   Initialize ADC and register the ADC driver.
+ *   Initialize SDIO-based MMC/SD card support
  *
  ****************************************************************************/
 
-#ifdef CONFIG_ADC
-int stm32_adc_setup(void);
+int stm32_sdio_initialize(void)
+{
+  int ret;
+
+#ifdef HAVE_NCD
+  /* Card detect */
+
+  bool cd_status;
+
+  /* Configure the card detect GPIO */
+
+  stm32_configgpio(GPIO_SDIO_NCD);
+
+  /* Register an interrupt handler for the card detect pin */
+
+  (void)stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true,
+                           stm32_ncd_interrupt, NULL);
+#endif
+
+  /* Mount the SDIO-based MMC/SD block driver */
+
+  /* First, get an instance of the SDIO interface */
+
+  finfo("Initializing SDIO slot %d\n", SDIO_SLOTNO);
+
+  g_sdio_dev = sdio_initialize(SDIO_SLOTNO);
+  if (!g_sdio_dev)
+    {
+      ferr("ERROR: Failed to initialize SDIO slot %d\n", SDIO_SLOTNO);
+      return -ENODEV;
+    }
+
+  /* Now bind the SDIO interface to the MMC/SD driver */
+
+  finfo("Bind SDIO to the MMC/SD driver, minor=%d\n", SDIO_MINOR);
+
+  ret = mmcsd_slotinitialize(SDIO_MINOR, g_sdio_dev);
+  if (ret != OK)
+    {
+      ferr("ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n", ret);
+      return ret;
+    }
+
+  finfo("Successfully bound SDIO to the MMC/SD driver\n");
+
+#ifdef HAVE_NCD
+  /* Use SD card detect pin to check if a card is g_sd_inserted */
+
+  cd_status = !stm32_gpioread(GPIO_SDIO_NCD);
+  finfo("Card detect : %d\n", cd_status);
+
+  sdio_mediachange(g_sdio_dev, cd_status);
+#else
+  /* Assume that the SD card is inserted.  What choice do we have? */
+
+  sdio_mediachange(g_sdio_dev, true);
 #endif
 
-#endif /* __BOARDS_ARM_STM32H7_STM32H747I_DISCO_SRC_STM32H747I_DISCO_H */
+  return OK;
+}
diff --git a/boards/arm/stm32h7/stm32h747i-disco/src/stm32h747i-disco.h b/boards/arm/stm32h7/stm32h747i-disco/src/stm32h747i-disco.h
index 7bc2e30..a5c43ad7 100644
--- a/boards/arm/stm32h7/stm32h747i-disco/src/stm32h747i-disco.h
+++ b/boards/arm/stm32h7/stm32h747i-disco/src/stm32h747i-disco.h
@@ -107,6 +107,19 @@
 
 #define GPIO_BTN_USER  (GPIO_INPUT | GPIO_FLOAT | GPIO_EXTI | GPIO_PORTC | GPIO_PIN13)
 
+/* SD/TF Card'detected pin */
+
+#if defined(CONFIG_STM32H7_SDMMC1)
+#  define HAVE_SDIO
+#endif
+
+#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_MMCSD_SDIO)
+#  undef HAVE_SDIO
+#endif
+
+#define SDIO_SLOTNO        0
+#define SDIO_MINOR         0
+
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -151,4 +164,16 @@ void stm32_spidev_initialize(void);
 int stm32_adc_setup(void);
 #endif
 
+/****************************************************************************
+ * Name: stm32_sdio_initialize
+ *
+ * Description:
+ *   Initialize SDIO-based MMC/SD card support
+ *
+ ****************************************************************************/
+
+#ifdef HAVE_SDIO
+int stm32_sdio_initialize(void);
+#endif
+
 #endif /* __BOARDS_ARM_STM32H7_STM32H747I_DISCO_SRC_STM32H747I_DISCO_H */


[incubator-nuttx] 05/07: boards/arm/stm32h7/stm32h747i-disco: change the license header of all new files to an Apache 2.0 license.

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 4585af393c80f3f5fc8ed5d3e312d400130d1de9
Author: Pierre-Olivier Vauboin <po...@lambdaconcept.com>
AuthorDate: Tue Apr 14 12:28:22 2020 +0200

    boards/arm/stm32h7/stm32h747i-disco: change the license header of all new files to an Apache 2.0 license.
---
 .../stm32h7/stm32h747i-disco/src/stm32_dma_alloc.c | 38 +++++++--------------
 .../arm/stm32h7/stm32h747i-disco/src/stm32_sdmmc.c | 39 +++++++---------------
 2 files changed, 24 insertions(+), 53 deletions(-)

diff --git a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_dma_alloc.c b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_dma_alloc.c
index 8498d5a..b8485af 100644
--- a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_dma_alloc.c
+++ b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_dma_alloc.c
@@ -1,34 +1,20 @@
 /****************************************************************************
  * boards/arm/stm32h7/stm32h747i-disco/src/stm32_dma_alloc.c
  *
- *   Copyright (C) 2016 PX4 Development Team. All rights reserved.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- * 3. Neither the name PX4 nor the names of its contributors may be
- *    used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
  *
  ****************************************************************************/
 
diff --git a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_sdmmc.c b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_sdmmc.c
index 6546d69..8b33efb 100644
--- a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_sdmmc.c
+++ b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_sdmmc.c
@@ -1,35 +1,20 @@
 /****************************************************************************
  * boards/arm/stm32h7/stm32h747i-disco/src/stm32_sdmmc.c
  *
- *   Copyright (C) 2016-2019 Gregory Nutt. All rights reserved.
- *   Author: Gregory Nutt <gn...@nuttx.org>
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- *    used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
  *
  ****************************************************************************/