/* ================================================================== >>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<< ------------------------------------------------------------------ Copyright (c) 2019-2020 by Lattice Semiconductor Corporation ALL RIGHTS RESERVED ------------------------------------------------------------------ IMPORTANT: THIS FILE IS USED BY OR GENERATED BY the LATTICE PROPELâ„¢ DEVELOPMENT SUITE, WHICH INCLUDES PROPEL BUILDER AND PROPEL SDK. Lattice grants permission to use this code pursuant to the terms of the Lattice Propel License Agreement. DISCLAIMER: LATTICE MAKES NO WARRANTIES ON THIS FILE OR ITS CONTENTS, WHETHER EXPRESSED, IMPLIED, STATUTORY, OR IN ANY PROVISION OF THE LATTICE PROPEL LICENSE AGREEMENT OR COMMUNICATION WITH LICENSEE, AND LATTICE SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. LATTICE DOES NOT WARRANT THAT THE FUNCTIONS CONTAINED HEREIN WILL MEET LICENSEE 'S REQUIREMENTS, OR THAT LICENSEE' S OPERATION OF ANY DEVICE, SOFTWARE OR SYSTEM USING THIS FILE OR ITS CONTENTS WILL BE UNINTERRUPTED OR ERROR FREE, OR THAT DEFECTS HEREIN WILL BE CORRECTED. LICENSEE ASSUMES RESPONSIBILITY FOR SELECTION OF MATERIALS TO ACHIEVE ITS INTENDED RESULTS, AND FOR THE PROPER INSTALLATION, USE, AND RESULTS OBTAINED THEREFROM. LICENSEE ASSUMES THE ENTIRE RISK OF THE FILE AND ITS CONTENTS PROVING DEFECTIVE OR FAILING TO PERFORM PROPERLY AND IN SUCH EVENT, LICENSEE SHALL ASSUME THE ENTIRE COST AND RISK OF ANY REPAIR, SERVICE, CORRECTION, OR ANY OTHER LIABILITIES OR DAMAGES CAUSED BY OR ASSOCIATED WITH THE SOFTWARE.IN NO EVENT SHALL LATTICE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS FILE OR ITS CONTENTS, EVEN IF LATTICE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. LATTICE 'S SOLE LIABILITY, AND LICENSEE' S SOLE REMEDY, IS SET FORTH ABOVE. LATTICE DOES NOT WARRANT OR REPRESENT THAT THIS FILE, ITS CONTENTS OR USE THEREOF DOES NOT INFRINGE ON THIRD PARTIES' INTELLECTUAL PROPERTY RIGHTS, INCLUDING ANY PATENT. IT IS THE USER' S RESPONSIBILITY TO VERIFY THE USER SOFTWARE DESIGN FOR CONSISTENCY AND FUNCTIONALITY THROUGH THE USE OF FORMAL SOFTWARE VALIDATION METHODS. ------------------------------------------------------------------ ================================================================== */ #ifndef STREAMER_H_ #define STREAMER_H_ struct spi_streamer { unsigned int control; //0x00 unsigned int cmd_data; //0x04 unsigned int tx_fifo_data; //0x08 unsigned int rx_fifo_data; //0x0C unsigned int trans_ctrl; //0x10 unsigned int ph4_num_bytes; //0x14 unsigned int status; //0x18 unsigned int fifo_ctrl; //0x1C unsigned int irq_status; //0x20 unsigned int irq_enable; //0x24 unsigned int irq_set; //0x28 }; struct spi_streamer_instance { const char *instance_name; unsigned int base_addr; unsigned int irq_en; unsigned int *p_rx_fifo; unsigned int *p_tx_fifo; }; #define STRMR_CTRL_SPI_MODE0 (0) #define STRMR_CTRL_SPI_MODE3 (3) #define STRMR_CTRL_SCLK_DIV1 (0 << 2) #define STRMR_CTRL_SCLK_DIV2 (1 << 2) #define STRMR_CTRL_SCLK_DIV4 (2 << 2) #define STRMR_CTRL_SCLK_DIV8 (3 << 2) #define STRMR_CTRL_SCLK_DIV16 (4 << 2) #define STRMR_CTRL_SCLK_DIV32 (5 << 2) #define STRMR_CTRL_SOFT_RST (1 << 31) #define TRANS_PH1_NUMBYTES_OFFSET (0) #define TRANS_PH2_NUMBYTES_OFFSET (3) #define TRANS_PH3_DUMMY_OFFESET (12) #define TRANS_PH1_MODE_SPI (0 << 17) #define TRANS_PH1_MODE_QSPI (3 << 17) #define TRANS_PH2_MODE_SPI (0 << 19) #define TRANS_PH2_MODE_QSPI (3 << 19) #define TRANS_PH3_MODE_SPI (0 << 21) #define TRANS_PH3_MODE_QSPI (3 << 21) #define TRANS_PH4_MODE_SPI (0 << 23) #define TRANS_PH4_MODE_QSPI (3 << 23) #define TRANS_RXFIFO_LAST_EN (1 << 25) #define TRANS_START (1 << 31) #define STRMR_STAT_TX_FIFO_EMPTY (1 << 0) #define STRMR_STAT_TX_FIFO_ALMOST_EMPTY (1 << 1) #define STRMR_STAT_TX_FIFO_ALMOST_FULL (1 << 2) #define STRMR_STAT_TX_FIFO_FULL (1 << 3) #define STRMR_STAT_RX_FIFO_EMPTY (1 << 4) #define STRMR_STAT_RX_FIFO_ALMOST_EMPTY (1 << 5) #define STRMR_STAT_RX_FIFO_ALMOST_FULL (1 << 6) #define STRMR_STAT_RX_FIFO_FULL (1 << 7) #define STRMR_STAT_BUSY (1 << 31) #define STRMR_FIFO_CTRL_FLUSH_TX (1 << 7) #define STRMR_FIFO_CTRL_RX_DEST_INT (0 << 8) #define STRMR_FIFO_CTRL_RX_DEST_EXT (1 << 8) #define STRMR_FIFO_CTRL_RX_DEST_TX (3 << 8) #define STRMR_FIFO_CTRL_FLUSH_RX (1 << 15) #define STRMR_IRQ_DONE (1 << 0) #define STRMR_IRQ_TX_FIFO_EMPTY (1 << 1) #define STRMR_IRQ_TX_FIFO_ALMOST_EMPTY (1 << 2) #define STRMR_IRQ_TX_FIFO_ALMOST_FULL (1 << 3) #define STRMR_IRQ_TX_FIFO_FULL (1 << 4) #define STRMR_IRQ_RX_FIFO_EMPTY (1 << 5) #define STRMR_IRQ_RX_FIFO_ALMOST_EMPTY (1 << 6) #define STRMR_IRQ_RX_FIFO_ALMOST_FULL (1 << 7) #define STRMR_IRQ_RX_FIFO_FULL (1 << 8) /* SPI flash command definition */ #define WR_EN 0x06 //prototypes unsigned char spi_streamer_init(struct spi_streamer_instance *this_spi, unsigned int base_addr, unsigned int spi_mode, unsigned int sck_div); unsigned char spi_write(struct spi_streamer_instance *this_spir, unsigned int addr, unsigned int length, unsigned char *buff, unsigned char addr4B); unsigned char spi_read(struct spi_streamer_instance *this_spi, unsigned int addr, unsigned int length, unsigned char *buff, unsigned char addr4B); unsigned char spi_read_esb(void *this_spi_streamer, unsigned int addr, unsigned int length, unsigned char addr4B); unsigned char spi_erase_4k(struct spi_streamer_instance *this_spi, unsigned int addr, unsigned char addr4B); unsigned char spi_read_txfifo(struct spi_streamer_instance *this_spi, unsigned int addr, unsigned int length); unsigned char spi_write_txfifo(struct spi_streamer_instance *this_spi, unsigned int addr, unsigned int length); void qspi_stramer_isr(unsigned int intr_level, void *ctx); #endif /* STREAMER_H_ */