Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:39

0001 /*
0002  * Copyright (C) 2024 Aaron Nyholm
0003  *
0004  * Redistribution and use in source and binary forms, with or without
0005  * modification, are permitted provided that the following conditions
0006  * are met:
0007  * 1. Redistributions of source code must retain the above copyright
0008  *    notice, this list of conditions and the following disclaimer.
0009  * 2. Redistributions in binary form must reproduce the above copyright
0010  *    notice, this list of conditions and the following disclaimer in the
0011  *    documentation and/or other materials provided with the distribution.
0012  *
0013  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
0014  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0015  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0016  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0017  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0018  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0019  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0020  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0021  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0022  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0023  * POSSIBILITY OF SUCH DAMAGE.
0024  */
0025 
0026 #ifndef _ZYNQ_QSPI_FLASHDEV_H
0027 #define _ZYNQ_QSPI_FLASHDEV_H
0028 
0029 #include <dev/flash/flashdev.h>
0030 #include <dev/spi/zynq-qspi-flash.h>
0031 
0032 #define ZQSPI_FLASH_MAX_REGIONS ((size_t)32)
0033 
0034 /*
0035  * @brief Initializes a flash device using zynq qspi flash
0036  * driver. The flash device is not registered in this call.
0037  * If an rtems_flashdev is created using zqspi_flash_init it must be
0038  * destroyed using xqspi_flash_destroy.
0039  *
0040  * @param[in] zqspiflash A initialised zqspiflash device to wrap.
0041  *
0042  * @retval A pointer to the rtems_flashdev.
0043  * @retval NULL on failure.
0044 */
0045 rtems_flashdev* zqspi_flashdev_init(zqspiflash *bmdriver);
0046 
0047 /*
0048  * @brief Destroys a rtems_flashdev initialised with zqspi_flash_init.
0049  * If an rtems_flashdev is created using zqspi_flash_init it must be
0050  * destroyed using zqspi_flash_destroy. The zqspiflash originally passed in
0051  * is untouched.
0052  *
0053  * @param[in] flash The flashdev to destroy
0054 */
0055 void zqspi_flashdev_destroy(rtems_flashdev* flash);
0056 
0057 /*
0058  * @brief Struct allocating memory space for flash regions. Used by
0059  * rtems_flashdev to store region allocations.
0060  */
0061 typedef struct zqspi_flash_region_table {
0062   rtems_flashdev_region zqspi_flash_regions[ZQSPI_FLASH_MAX_REGIONS];
0063   uint32_t zqspi_flash_bit_allocator;
0064 } zqspi_flash_region_table;
0065 
0066 #endif /* _ZYNQ_QSPI_FLASHDEV_H */