RTEMS  5.0.0
alt_qspi.h
Go to the documentation of this file.
1 
7 /******************************************************************************
8 *
9 * Copyright 2013 Altera Corporation. All Rights Reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * 1. Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 *
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 *
21 * 3. The name of the author may not be used to endorse or promote products
22 * derived from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY EXPRESS OR
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO
27 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
29 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
33 * OF SUCH DAMAGE.
34 *
35 ******************************************************************************/
36 
37 /******************************************************************************
38 *
39 * !!!! Customer Be Aware, Exception!!!
40 *
41 * 1. Qspi Direct Access Mode is not working!
42 *
43 * This is because the qspi flash memory installed on our DevKit board, Micro
44 * part N25Q00xx, 8 Gb, is not completely compatible with our embedded Synopsis
45 * QSPI controller IP. Therefore there is no viable direct access code offered
46 * in the lib. All the memory rea/write functionality is offered with indirect
47 * access only.
48 *
49 * Should you install a different flash memory part in your custom board, and
50 * wondering wether direct access mode works, please contact with us.
51 *
52 ******************************************************************************/
53 
58 #ifndef __ALT_QSPI_H__
59 #define __ALT_QSPI_H__
60 
61 #include <bsp/hwlib.h>
62 
63 #ifdef __cplusplus
64 extern "C"
65 {
66 #endif /* __cplusplus */
67 
68 /******************************************************************************/
80 /******************************************************************************/
89 /******************************************************************************/
108 
109 /******************************************************************************/
120 
121 /******************************************************************************/
133 
134 /******************************************************************************/
142 
143 /******************************************************************************/
158 {
168 
178 
183 
189 
194 
200 
205 
217 
225 
233 
241 
249 
255 
257 
258 /******************************************************************************/
271 uint32_t alt_qspi_int_status_get(void);
272 
273 /******************************************************************************/
289 ALT_STATUS_CODE alt_qspi_int_clear(const uint32_t mask);
290 
291 /******************************************************************************/
316 ALT_STATUS_CODE alt_qspi_int_disable(const uint32_t mask);
317 
318 /******************************************************************************/
343 ALT_STATUS_CODE alt_qspi_int_enable(const uint32_t mask);
344 
345 /******************************************************************************/
351 bool alt_qspi_is_idle(void);
352 
355 /******************************************************************************/
383 /******************************************************************************/
404 ALT_STATUS_CODE alt_qspi_read(void * dest, uint32_t src, size_t size);
405 
406 /******************************************************************************/
427 ALT_STATUS_CODE alt_qspi_write(uint32_t dest, const void * src, size_t size);
428 
431 /******************************************************************************/
461 /******************************************************************************/
467 typedef enum ALT_QSPI_MODE_e
468 {
480 
481 /******************************************************************************/
487 typedef enum ALT_QSPI_CS_MODE_e
488 {
495 
496 /******************************************************************************/
501 {
519 
520 /******************************************************************************/
528 {
529  uint32_t block_size;
534  uint32_t page_size;
539  uint32_t addr_size;
563 
564 /******************************************************************************/
570 {
578 
579 /******************************************************************************/
584 {
592 
593 /******************************************************************************/
603 {
613  uint32_t cs_da;
621  uint32_t cs_dads;
634  uint32_t cs_eot;
647  uint32_t cs_sot;
659  uint32_t rd_datacap;
674 
675 /******************************************************************************/
683 {
684  uint32_t op_code;
714  uint32_t dummy_cycles;
720 
721 /******************************************************************************/
728 
729 /******************************************************************************/
743 
744 /******************************************************************************/
759 
760 /******************************************************************************/
790  const ALT_QSPI_CS_MODE_t cs_mode);
791 
792 /******************************************************************************/
803 
804 /******************************************************************************/
815 
816 /******************************************************************************/
823 uint32_t alt_qspi_mode_bit_config_get(void);
824 
825 /******************************************************************************/
841 ALT_STATUS_CODE alt_qspi_mode_bit_config_set(const uint32_t mode_bits);
842 
843 /******************************************************************************/
856 
857 /******************************************************************************/
869 
870 /******************************************************************************/
883 
884 /******************************************************************************/
901 
902 /******************************************************************************/
915 
916 /******************************************************************************/
933 
934 /******************************************************************************/
949 
950 /******************************************************************************/
972 
975 /******************************************************************************/
1000 /******************************************************************************/
1008 
1009 /******************************************************************************/
1017 
1018 /******************************************************************************/
1027 uint32_t alt_qspi_ahb_remap_address_get(void);
1028 
1029 /******************************************************************************/
1045 ALT_STATUS_CODE alt_qspi_ahb_remap_address_set(const uint32_t ahb_remap_addr);
1046 
1047 /******************************************************************************/
1059 
1060 /******************************************************************************/
1073 
1076 /******************************************************************************/
1093 /******************************************************************************/
1126 ALT_STATUS_CODE alt_qspi_indirect_read_start(const uint32_t flash_addr,
1127  const size_t num_bytes);
1128 
1129 /******************************************************************************/
1138 
1139 /******************************************************************************/
1147 
1148 /******************************************************************************/
1158 uint32_t alt_qspi_indirect_read_fill_level(void);
1159 
1160 /******************************************************************************/
1172 
1173 /******************************************************************************/
1189 ALT_STATUS_CODE alt_qspi_indirect_read_watermark_set(const uint32_t watermark);
1190 
1191 /******************************************************************************/
1202 
1203 /******************************************************************************/
1238 ALT_STATUS_CODE alt_qspi_indirect_write_start(const uint32_t flash_addr,
1239  const size_t num_bytes);
1240 
1241 /******************************************************************************/
1250 
1251 /******************************************************************************/
1259 
1260 /******************************************************************************/
1270 uint32_t alt_qspi_indirect_write_fill_level(void);
1271 
1272 /******************************************************************************/
1284 
1285 /******************************************************************************/
1301 ALT_STATUS_CODE alt_qspi_indirect_write_watermark_set(const uint32_t watermark);
1302 
1303 /******************************************************************************/
1316 
1317 /******************************************************************************/
1339 #define ALT_QSPI_SRAM_FIFO_SIZE (512)
1340 
1341 /*
1342  * The size of the onboard SRAM in entries. Each entry is word (32-bit) sized.
1343  */
1344 #define ALT_QSPI_SRAM_FIFO_ENTRY_COUNT (512 / sizeof(uint32_t))
1345 
1346 /******************************************************************************/
1367 uint32_t alt_qspi_sram_partition_get(void);
1368 
1369 /******************************************************************************/
1384 ALT_STATUS_CODE alt_qspi_sram_partition_set(const uint32_t read_part_size);
1385 
1390 /******************************************************************************/
1398 /******************************************************************************/
1411 ALT_STATUS_CODE alt_qspi_erase_subsector(const uint32_t addr);
1412 
1413 /******************************************************************************/
1426 ALT_STATUS_CODE alt_qspi_erase_sector(const uint32_t addr);
1427 
1428 /******************************************************************************/
1436 
1439 /******************************************************************************/
1464 /******************************************************************************/
1472 
1473 /******************************************************************************/
1484 
1485 /******************************************************************************/
1503 ALT_STATUS_CODE alt_qspi_dma_config_get(uint32_t * single_type_sz,
1504  uint32_t * burst_type_sz);
1505 
1506 /******************************************************************************/
1530 ALT_STATUS_CODE alt_qspi_dma_config_set(const uint32_t single_type_sz,
1531  const uint32_t burst_type_sz);
1532 
1533 
1538 #ifdef __cplusplus
1539 }
1540 #endif /* __cplusplus */
1541 #endif /* __ALT_QSPI_H__ */
Definition: alt_qspi.h:515
uint32_t alt_qspi_mode_bit_config_get(void)
Definition: alt_qspi.c:1216
Definition: alt_qspi.h:508
Definition: alt_qspi.h:489
ALT_STATUS_CODE alt_qspi_indirect_read_cancel(void)
Definition: alt_qspi.c:1737
ALT_STATUS_CODE alt_qspi_indirect_write_start(const uint32_t flash_addr, const size_t num_bytes)
Definition: alt_qspi.c:1793
ALT_STATUS_CODE alt_qspi_device_size_config_get(ALT_QSPI_DEV_SIZE_CONFIG_t *cfg)
Definition: alt_qspi.c:1245
Definition: alt_qspi.h:682
Definition: alt_qspi.h:473
ALT_STATUS_CODE alt_qspi_dma_enable(void)
Definition: alt_qspi.c:2127
bool wrprot_enable
Definition: alt_qspi.h:556
ALT_STATUS_CODE alt_qspi_device_read_config_set(const ALT_QSPI_DEV_INST_CONFIG_t *cfg)
Definition: alt_qspi.c:1339
struct ALT_QSPI_DEV_SIZE_CONFIG_s ALT_QSPI_DEV_SIZE_CONFIG_t
ALT_STATUS_CODE alt_qspi_mode_bit_enable(void)
Definition: alt_qspi.c:1207
ALT_STATUS_CODE alt_qspi_indirect_write_finish(void)
Definition: alt_qspi.c:1869
bool alt_qspi_indirect_write_is_complete(void)
Definition: alt_qspi.c:1927
uint32_t dummy_cycles
Definition: alt_qspi.h:714
ALT_QSPI_CLK_PHASE_e
Definition: alt_qspi.h:569
ALT_QSPI_MODE_t addr_xfer_type
Definition: alt_qspi.h:696
Definition: alt_qspi.h:527
ALT_STATUS_CODE alt_qspi_enable(void)
Definition: alt_qspi.c:422
ALT_STATUS_CODE alt_qspi_erase_subsector(const uint32_t addr)
Definition: alt_qspi.c:1988
ALT_STATUS_CODE alt_qspi_erase_sector(const uint32_t addr)
Definition: alt_qspi.c:2005
Definition: alt_qspi.h:506
ALT_QSPI_BAUD_DIV_t alt_qspi_baud_rate_div_get(void)
Definition: alt_qspi.c:1134
ALT_STATUS_CODE alt_qspi_init(void)
Definition: alt_qspi.c:312
ALT_STATUS_CODE alt_qspi_ahb_remap_address_set(const uint32_t ahb_remap_addr)
Definition: alt_qspi.c:1625
uint32_t alt_qspi_sram_partition_get(void)
Definition: alt_qspi.c:1937
uint32_t cs_sot
Definition: alt_qspi.h:647
ALT_QSPI_MODE_e
Definition: alt_qspi.h:467
ALT_STATUS_CODE alt_qspi_disable(void)
Definition: alt_qspi.c:415
ALT_STATUS_CODE alt_qspi_uninit(void)
Definition: alt_qspi.c:407
Definition: alt_qspi.h:514
Definition: alt_qspi.h:254
uint32_t cs_dads
Definition: alt_qspi.h:621
Definition: alt_qspi.h:602
ALT_STATUS_CODE alt_qspi_int_enable(const uint32_t mask)
Definition: alt_qspi.c:565
Definition: alt_qspi.h:193
Definition: alt_qspi.h:240
Definition: alt_qspi.h:503
uint32_t cs_da
Definition: alt_qspi.h:613
ALT_QSPI_CLK_POLARITY_t clk_pol
Definition: alt_qspi.h:609
ALT_STATUS_CODE alt_qspi_device_size_config_set(const ALT_QSPI_DEV_SIZE_CONFIG_t *cfg)
Definition: alt_qspi.c:1274
Definition: alt_qspi.h:588
enum ALT_QSPI_BAUD_DIV_e ALT_QSPI_BAUD_DIV_t
ALT_STATUS_CODE alt_qspi_dma_disable(void)
Definition: alt_qspi.c:2118
Definition: alt_qspi.h:216
ALT_STATUS_CODE alt_qspi_ahb_address_remap_enable(void)
Definition: alt_qspi.c:1647
Definition: alt_qspi.h:585
uint32_t rd_datacap
Definition: alt_qspi.h:659
Definition: alt_qspi.h:232
Definition: alt_qspi.h:182
uint32_t block_size
Definition: alt_qspi.h:529
uint32_t alt_qspi_indirect_write_watermark_get(void)
Definition: alt_qspi.c:1907
uint32_t page_size
Definition: alt_qspi.h:534
Definition: alt_qspi.h:571
uint32_t alt_qspi_ahb_remap_address_get(void)
Definition: alt_qspi.c:1619
Definition: alt_qspi.h:574
struct ALT_QSPI_DEV_INST_CONFIG_s ALT_QSPI_DEV_INST_CONFIG_t
ALT_STATUS_CODE alt_qspi_indirect_write_watermark_set(const uint32_t watermark)
Definition: alt_qspi.c:1913
ALT_STATUS_CODE alt_qspi_indirect_read_finish(void)
Definition: alt_qspi.c:1732
bool alt_qspi_is_idle(void)
Definition: alt_qspi.c:586
Definition: alt_qspi.h:502
ALT_STATUS_CODE alt_qspi_timing_config_get(ALT_QSPI_TIMING_CONFIG_t *cfg)
Definition: alt_qspi.c:1504
ALT_STATUS_CODE alt_qspi_device_write_config_get(ALT_QSPI_DEV_INST_CONFIG_t *cfg)
Definition: alt_qspi.c:1410
uint32_t upper_wrprot_block
Definition: alt_qspi.h:550
enum ALT_QSPI_CS_MODE_e ALT_QSPI_CS_MODE_t
Definition: alt_qspi.h:248
Definition: alt_qspi.h:177
Definition: alt_qspi.h:224
Definition: alt_qspi.h:517
ALT_STATUS_CODE alt_qspi_sram_partition_set(const uint32_t read_part_size)
Definition: alt_qspi.c:1947
ALT_STATUS_CODE alt_qspi_dma_config_get(uint32_t *single_type_sz, uint32_t *burst_type_sz)
Definition: alt_qspi.c:2136
ALT_STATUS_CODE alt_qspi_direct_disable(void)
Definition: alt_qspi.c:1601
uint32_t cs_eot
Definition: alt_qspi.h:634
Definition: alt_qspi.h:204
Definition: alt_qspi.h:491
uint32_t op_code
Definition: alt_qspi.h:684
ALT_STATUS_CODE alt_qspi_indirect_write_cancel(void)
Definition: alt_qspi.c:1878
ALT_STATUS_CODE alt_qspi_read(void *dest, uint32_t src, size_t size)
Definition: alt_qspi.c:694
ALT_STATUS_CODE alt_qspi_timing_config_set(const ALT_QSPI_TIMING_CONFIG_t *cfg)
Definition: alt_qspi.c:1524
uint32_t alt_qspi_indirect_read_fill_level(void)
Definition: alt_qspi.c:1746
enum ALT_QSPI_CLK_PHASE_e ALT_QSPI_CLK_PHASE_t
ALT_QSPI_MODE_t inst_type
Definition: alt_qspi.h:687
enum ALT_QSPI_CLK_POLARITY_e ALT_QSPI_CLK_POLARITY_t
ALT_QSPI_CLK_PHASE_t clk_phase
Definition: alt_qspi.h:604
Definition: alt_qspi.h:504
ALT_STATUS_CODE alt_qspi_indirect_read_start(const uint32_t flash_addr, const size_t num_bytes)
Definition: alt_qspi.c:1669
ALT_STATUS_CODE alt_qspi_chip_select_config_get(uint32_t *cs, ALT_QSPI_CS_MODE_t *cs_mode)
Definition: alt_qspi.c:1156
Definition: alt_qspi.h:476
ALT_STATUS_CODE alt_qspi_mode_bit_config_set(const uint32_t mode_bits)
Definition: alt_qspi.c:1223
ALT_STATUS_CODE alt_qspi_int_disable(const uint32_t mask)
Definition: alt_qspi.c:546
ALT_QSPI_CS_MODE_e
Definition: alt_qspi.h:487
int32_t ALT_STATUS_CODE
Definition: hwlib.h:60
ALT_QSPI_BAUD_DIV_e
Definition: alt_qspi.h:500
Definition: alt_qspi.h:505
ALT_STATUS_CODE alt_qspi_baud_rate_div_set(const ALT_QSPI_BAUD_DIV_t baud_rate_div)
Definition: alt_qspi.c:1140
ALT_STATUS_CODE alt_qspi_indirect_read_watermark_set(const uint32_t watermark)
Definition: alt_qspi.c:1760
ALT_STATUS_CODE alt_qspi_mode_bit_disable(void)
Definition: alt_qspi.c:1198
Definition: alt_qspi.h:167
uint32_t addr_size
Definition: alt_qspi.h:539
enum ALT_QSPI_MODE_e ALT_QSPI_MODE_t
ALT_STATUS_CODE alt_qspi_device_write_config_set(const ALT_QSPI_DEV_INST_CONFIG_t *cfg)
Definition: alt_qspi.c:1427
Definition: alt_qspi.h:510
Definition: alt_qspi.h:513
Definition: alt_qspi.h:199
uint32_t alt_qspi_int_status_get(void)
Definition: alt_qspi.c:525
ALT_STATUS_CODE alt_qspi_direct_enable(void)
Definition: alt_qspi.c:1610
ALT_STATUS_CODE alt_qspi_int_clear(const uint32_t mask)
Definition: alt_qspi.c:532
enum ALT_QSPI_INT_STATUS_e ALT_QSPI_INT_STATUS_t
uint32_t alt_qspi_indirect_write_fill_level(void)
Definition: alt_qspi.c:1899
Definition: alt_qspi.h:509
unsigned size
Definition: tte.h:74
Definition: alt_qspi.h:516
Definition: alt_qspi.h:188
Definition: alt_qspi.h:512
ALT_STATUS_CODE alt_qspi_erase_chip(void)
Definition: alt_qspi.c:2034
ALT_STATUS_CODE alt_qspi_device_read_config_get(ALT_QSPI_DEV_INST_CONFIG_t *cfg)
Definition: alt_qspi.c:1325
Definition: alt_qspi.h:507
ALT_QSPI_CLK_POLARITY_e
Definition: alt_qspi.h:583
Definition: alt_qspi.h:469
bool alt_qspi_indirect_read_is_complete(void)
Definition: alt_qspi.c:1774
ALT_STATUS_CODE alt_qspi_dma_config_set(const uint32_t single_type_sz, const uint32_t burst_type_sz)
Definition: alt_qspi.c:2171
ALT_STATUS_CODE alt_qspi_ahb_address_remap_disable(void)
Definition: alt_qspi.c:1638
uint32_t alt_qspi_indirect_read_watermark_get(void)
Definition: alt_qspi.c:1754
ALT_STATUS_CODE alt_qspi_chip_select_config_set(const uint32_t cs, const ALT_QSPI_CS_MODE_t cs_mode)
Definition: alt_qspi.c:1167
uint32_t lower_wrprot_block
Definition: alt_qspi.h:544
ALT_QSPI_MODE_t data_xfer_type
Definition: alt_qspi.h:705
struct ALT_QSPI_TIMING_CONFIG_s ALT_QSPI_TIMING_CONFIG_t
Definition: alt_qspi.h:511
ALT_QSPI_INT_STATUS_e
Definition: alt_qspi.h:157
ALT_STATUS_CODE alt_qspi_write(uint32_t dest, const void *src, size_t size)
Definition: alt_qspi.c:809