Added incomplete octospi hardware defintions.
Some checks failed
Build Documentation / build-html (push) Has been cancelled

Register addresses are defined. Bit defintions are still needed.

Bitmaps for OCTOSPI peripheral register

Incremental updates to qspi files

Redefined QSPI/OCTOSPI registers for STM32H5

Fixed register definitions for the STM32H5. However, more work still needs to be done. Some bits that shared registers on the STM32H7 have different register locations on the H5. This still needs to be accounted for.

Fixed more differences vs STM32H7 qspi

Added ifdef for including stm32_dma.h in stm32_qspi.c. Added stm32_qspi.c to Make.defs.

Register fixes. SPI activity but not able to format device yet.

Fixed DCYC mask

Set HCLK frequency to correct value. Undid ccrconfig debug.

Tested Interrupt Mode (single SPI). Added alternate bytes to meminfo and cmdinfo structures. Updated Kconfig variables for STM32H5.

Fixed base register in hardware/stm32_qspi.h. Updated qspi_dumpregs.

The base register was previously set to STM32_QUADSPI_BASE, changed to the correctly named STM32_OCTOSPI1_BASE. However, these defines for the OCTOSPI registers are not even used. Instead qspi_putreg and qspi_getreg utilize the priv->base value to access OCTOSPI registers.

Removed altbytes code, left as before. Moved QSPI clock selection to stm32h5xx_rcc.c

Changed STM32H5_QUADSPI to STM32H5_QSPI1

Added hook to define QSPI_CLK_FREQUENCY as STM32_QSPI_FREQUENCY from board.h

Removed changes to nuttx qspi.h

style fixes
This commit is contained in:
Kyle Wilson 2024-12-05 13:08:56 -06:00 committed by Xiang Xiao
parent ca4fd09275
commit 1cfab89e65
5 changed files with 3036 additions and 0 deletions

View file

@ -309,6 +309,10 @@ config STM32H5_ETHMAC
select ARCH_HAVE_PHY select ARCH_HAVE_PHY
select STM32H5_HAVE_PHY_POLLED select STM32H5_HAVE_PHY_POLLED
config STM32H5_QSPI1
bool "QSPI1"
default n
config STM32H5_USART2 config STM32H5_USART2
bool "USART2" bool "USART2"
default n default n
@ -1570,4 +1574,138 @@ config STM32H5_I2CTIMEOTICKS
endmenu # "I2C Configuration" endmenu # "I2C Configuration"
menu "QuadSPI Configuration"
depends on STM32H5_QSPI1
config STM32H5_QSPI_FLASH_SIZE
int "Size of attached serial flash, bytes"
default 16777216
range 1 2147483648
---help---
The STM32H5 QSPI peripheral requires the size of the Flash be specified
config STM32H5_QSPI_FIFO_THESHOLD
int "Number of bytes before asserting FIFO threshold flag"
default 4
range 1 32
---help---
The STM32H5 QSPI peripheral requires that the FIFO threshold be specified
I would leave it at the default value of 4 unless you know what you are doing.
config STM32H5_QSPI_CSHT
int "Number of cycles Chip Select must be inactive between transactions"
default 5
range 1 64
---help---
The STM32H5 QSPI peripheral requires that it be specified the minimum number
of AHB cycles that Chip Select be held inactive between transactions.
choice
prompt "Transfer technique"
default STM32H5_QSPI_DMA
---help---
You can choose between using polling, interrupts, or DMA to transfer data
over the QSPI interface.
config STM32H5_QSPI_POLLING
bool "Polling"
---help---
Use conventional register I/O with status polling to transfer data.
config STM32H5_QSPI_INTERRUPTS
bool "Interrupts"
---help---
User interrupt driven I/O transfers.
config STM32H5_QSPI_DMA
bool "DMA"
depends on STM32H5_DMA
---help---
Use DMA to improve QSPI transfer performance.
endchoice
choice
prompt "Bank selection"
default STM32H5_QSPI_MODE_BANK1
---help---
You can choose between using polling, interrupts, or DMA to transfer data
over the QSPI interface.
config STM32H5_QSPI_MODE_BANK1
bool "Bank 1"
config STM32H5_QSPI_MODE_BANK2
bool "Bank 2"
config STM32H5_QSPI_MODE_DUAL
bool "Dual Bank"
endchoice
choice
prompt "DMA Priority"
default STM32H5_QSPI_DMAPRIORITY_MEDIUM
depends on STM32H5_DMA
---help---
The DMA controller supports priority levels. You are probably fine
with the default of 'medium' except for special cases. In the event
of contention between to channels at the same priority, the lower
numbered channel has hardware priority over the higher numbered one.
config STM32H5_QSPI_DMAPRIORITY_VERYHIGH
bool "Very High priority"
depends on STM32H5_DMA
---help---
'Highest' priority.
config STM32H5_QSPI_DMAPRIORITY_HIGH
bool "High priority"
depends on STM32H5_DMA
---help---
'High' priority.
config STM32H5_QSPI_DMAPRIORITY_MEDIUM
bool "Medium priority"
depends on STM32H5_DMA
---help---
'Medium' priority.
config STM32H5_QSPI_DMAPRIORITY_LOW
bool "Low priority"
depends on STM32H5_DMA
---help---
'Low' priority.
endchoice
config STM32H5_QSPI_DMATHRESHOLD
int "QSPI DMA threshold"
default 4
depends on STM32H5_QSPI_DMA
---help---
When QSPI DMA is enabled, small DMA transfers will still be performed
by polling logic. This value is the threshold below which transfers
will still be performed by conventional register status polling.
config STM32H5_QSPI_DMADEBUG
bool "QSPI DMA transfer debug"
depends on STM32H5_QSPI_DMA && DEBUG_SPI && DEBUG_DMA
default n
---help---
Enable special debug instrumentation to analyze QSPI DMA data transfers.
This logic is as non-invasive as possible: It samples DMA
registers at key points in the data transfer and then dumps all of
the registers at the end of the transfer.
config STM32H5_QSPI_REGDEBUG
bool "QSPI Register level debug"
depends on DEBUG_SPI_INFO
default n
---help---
Output detailed register-level QSPI device debug information.
Requires also CONFIG_DEBUG_SPI_INFO.
endmenu
endif # ARCH_CHIP_STM32H5 endif # ARCH_CHIP_STM32H5

View file

@ -58,6 +58,10 @@ ifeq ($(CONFIG_STM32H5_SPI),y)
CHIP_CSRCS += stm32_spi.c CHIP_CSRCS += stm32_spi.c
endif endif
ifeq ($(CONFIG_STM32H5_QSPI1),y)
CHIP_CSRCS += stm32_qspi.c
endif
# Required chip type specific files # Required chip type specific files
ifeq ($(CONFIG_STM32H5_STM32H5XXXX),y) ifeq ($(CONFIG_STM32H5_STM32H5XXXX),y)

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,129 @@
/****************************************************************************
* arch/arm/src/stm32h5/stm32_qspi.h
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
****************************************************************************/
#ifndef __ARCH_ARM_SRC_STM32H5_STM32_QSPI_H
#define __ARCH_ARM_SRC_STM32H5_STM32_QSPI_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/spi/qspi.h>
#include <stdint.h>
#include <stdbool.h>
#include "chip.h"
#ifdef CONFIG_STM32H5_QSPI1
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Inline Functions
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Public Data
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: stm32l4_qspi_initialize
*
* Description:
* Initialize the selected QSPI port in master mode
*
* Input Parameters:
* intf - Interface number(must be zero)
*
* Returned Value:
* Valid SPI device structure reference on success; a NULL on failure
*
****************************************************************************/
struct qspi_dev_s;
struct qspi_dev_s *stm32_qspi_initialize(int intf);
/****************************************************************************
* Name: stm32l4_qspi_enter_memorymapped
*
* Description:
* Put the QSPI device into memory mapped mode
*
* Input Parameters:
* dev - QSPI device
* meminfo - parameters like for a memory transfer used for reading
* lpto - number of cycles to wait to automatically de-assert CS
*
* Returned Value:
* None
*
****************************************************************************/
void stm32_qspi_enter_memorymapped(struct qspi_dev_s *dev,
const struct qspi_meminfo_s *meminfo,
uint32_t lpto);
/****************************************************************************
* Name: stm32l4_qspi_exit_memorymapped
*
* Description:
* Take the QSPI device out of memory mapped mode
*
* Input Parameters:
* dev - QSPI device
*
* Returned Value:
* None
*
****************************************************************************/
void stm32_qspi_exit_memorymapped(struct qspi_dev_s *dev);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* CONFIG_STM32H5_QSPI */
#endif /* __ARCH_ARM_SRC_STM32H5_STM32_QSPI_H */

View file

@ -1205,6 +1205,15 @@ void stm32_stdclockconfig(void)
putreg32(regval, STM32_RCC_CCIPR5); putreg32(regval, STM32_RCC_CCIPR5);
#endif #endif
/* Configure OCTOSPI1 source clock */
#if defined(STM32_RCC_CCIPR4_OCTOSPI1SEL)
regval = getreg32(STM32_RCC_CCIPR4);
regval &= ~RCC_CCIPR4_OCTOSPI1SEL_MASK;
regval |= STM32_RCC_CCIPR4_OCTOSPI1SEL;
putreg32(regval, STM32_RCC_CCIPR4);
#endif
/* Configure SPI1 source clock */ /* Configure SPI1 source clock */
#if defined(STM32_RCC_CCIPR3_SPI1SEL) #if defined(STM32_RCC_CCIPR3_SPI1SEL)