Create an MTD driver for SPIFI
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4951 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
4a7999b0b7
commit
5329acdad6
|
@ -92,24 +92,24 @@
|
|||
* have the same relationship as in the Control register)
|
||||
*/
|
||||
|
||||
#define SPIFI_MODE3 (1 << 0)
|
||||
#define SPIFI_MODE0 (0)
|
||||
#define SPIFI_MINIMAL (1 << 1)
|
||||
#define SPIFI_MAXIMAL (0)
|
||||
#define SPIFI_FORCE_ERASE (1 << 2)
|
||||
#define SPIFI_ERASE_NOT_REQD (1 << 3)
|
||||
#define SPIFI_CALLER_ERASE (1 << 3)
|
||||
#define SPIFI_ERASE_AS_REQD (0)
|
||||
#define SPIFI_VERIFY_PROG (1 << 4)
|
||||
#define SPIFI_VERIFY_ERASE (1 << 5)
|
||||
#define SPIFI_NO_VERIFY (0)
|
||||
#define SPIFI_FULLCLK (1 << 6)
|
||||
#define SPIFI_HALFCLK (0)
|
||||
#define SPIFI_RCVCLK (1 << 7)
|
||||
#define SPIFI_INTCLK (0)
|
||||
#define SPIFI_DUAL (1 << 8)
|
||||
#define SPIFI_CALLER_PROT (1 << 9)
|
||||
#define SPIFI_DRIVER_PROT (0)
|
||||
#define S_MODE3 (1 << 0)
|
||||
#define S_MODE0 (0)
|
||||
#define S_MINIMAL (1 << 1)
|
||||
#define S_MAXIMAL (0)
|
||||
#define S_FORCE_ERASE (1 << 2)
|
||||
#define S_ERASE_NOT_REQD (1 << 3)
|
||||
#define S_CALLER_ERASE (1 << 3)
|
||||
#define S_ERASE_AS_REQD (0)
|
||||
#define S_VERIFY_PROG (1 << 4)
|
||||
#define S_VERIFY_ERASE (1 << 5)
|
||||
#define S_NO_VERIFY (0)
|
||||
#define S_FULLCLK (1 << 6)
|
||||
#define S_HALFCLK (0)
|
||||
#define S_RCVCLK (1 << 7)
|
||||
#define S_INTCLK (0)
|
||||
#define S_DUAL (1 << 8)
|
||||
#define S_CALLER_PROT (1 << 9)
|
||||
#define S_DRIVER_PROT (0)
|
||||
|
||||
/* The length of a standard program command is 256 on all devices */
|
||||
|
||||
|
@ -178,9 +178,9 @@ struct spifi_dev_s
|
|||
|
||||
struct spifi_operands_s
|
||||
{
|
||||
char *dest;
|
||||
uint8_t *dest;
|
||||
uint32_t length;
|
||||
char *scratch;
|
||||
uint8_t *scratch;
|
||||
int32_t protect;
|
||||
uint32_t options;
|
||||
};
|
||||
|
@ -191,7 +191,7 @@ struct spifi_driver_s
|
|||
{
|
||||
int32_t (*spifi_init)(struct spifi_dev_s *dev, uint32_t cshigh,
|
||||
uint32_t options, uint32_t mhz);
|
||||
int32_t (*spifi_program)(struct spifi_dev_s *dev, char *source,
|
||||
int32_t (*spifi_program)(struct spifi_dev_s *dev, const uint8_t *source,
|
||||
struct spifi_operands_s *opers);
|
||||
int32_t (*spifi_erase)(struct spifi_dev_s *dev,
|
||||
struct spifi_operands_s *opers);
|
||||
|
@ -206,16 +206,16 @@ struct spifi_driver_s
|
|||
int32_t (*checkAd)(struct spifi_dev_s *dev,
|
||||
struct spifi_operands_s *opers);
|
||||
int32_t (*setProt)(struct spifi_dev_s *dev,
|
||||
struct spifi_operands_s *opers, char *change, char *saveprot);
|
||||
int32_t (*check_block) (struct spifi_dev_s *dev, char *source,
|
||||
struct spifi_operands_s *opers, uint8_t *change, uint8_t *saveprot);
|
||||
int32_t (*check_block) (struct spifi_dev_s *dev, uint8_t *source,
|
||||
struct spifi_operands_s *opers, uint32_t check_program);
|
||||
int32_t (*send_erase_cmd)(struct spifi_dev_s *dev, uint8_t op,
|
||||
uint32_t addr);
|
||||
uint32_t (*ck_erase) (struct spifi_dev_s *dev, uint32_t *addr,
|
||||
uint32_t length);
|
||||
int32_t (*prog_block)(struct spifi_dev_s *dev, char *source,
|
||||
int32_t (*prog_block)(struct spifi_dev_s *dev, uint8_t *source,
|
||||
struct spifi_operands_s *opers, uint32_t *left_in_page);
|
||||
uint32_t (*ck_prog)(struct spifi_dev_s *dev, char *source, char *dest,
|
||||
uint32_t (*ck_prog)(struct spifi_dev_s *dev, uint8_t *source, uint8_t *dest,
|
||||
uint32_t length);
|
||||
|
||||
/* Low level functions */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -41,6 +41,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/mtd.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "chip/lpc43_spifi.h"
|
||||
|
@ -50,6 +51,33 @@
|
|||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* SPIFI Configuration ******************************************************/
|
||||
/* This logic supports some special options that can be used to create an
|
||||
* MTD device on the SPIFI FLASH.
|
||||
*
|
||||
* CONFIG_LPC43_SPIFI - Enable SPIFI support
|
||||
*
|
||||
* SPIFI device geometry:
|
||||
*
|
||||
* CONFIG_SPIFI_OFFSET - Offset the beginning of the block driver this many
|
||||
* bytes into the device address space. This offset must be an exact
|
||||
* multiple of the erase block size (CONFIG_SPIFI_BLKSIZE). Default 0.
|
||||
* CONFIG_SPIFI_BLKSIZE - The size of one device erase block. If not defined
|
||||
* then the driver will try to determine the correct erase block size by
|
||||
* examining that data returned from spifi_initialize (which sometimes
|
||||
* seems bad).
|
||||
*
|
||||
* Other SPIFI options
|
||||
*
|
||||
* CONFIG_SPIFI_SECTOR512 - If defined, then the driver will report a more
|
||||
* FAT friendly 512 byte sector size and will manage the read-modify-write
|
||||
* operations on the larger erase block.
|
||||
* CONFIG_SPIFI_READONLY - Define to support only read-only operations.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_SPIFI_OFFSET
|
||||
# define CONFIG_SPIFI_OFFSET 0
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
|
@ -63,21 +91,26 @@
|
|||
* Public Functions
|
||||
****************************************************************************/
|
||||
/****************************************************************************
|
||||
* Function: lpc43_spifi_initialize
|
||||
* Name: lpc43_spifi_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the SPIFI interface per settings in the board.h file
|
||||
* Create an initialized MTD device instance for the SPIFI device. MTD
|
||||
* devices are not registered in the file system, but are created as
|
||||
* instances that can be bound to other functions (such as a block or
|
||||
* character driver front end).
|
||||
*
|
||||
* SPIFI interface clocking is configured per settings in the board.h file.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero is returned on success; on failure, a negated errno value is
|
||||
* returned.
|
||||
* Returned value:
|
||||
* One success, a reference to the initialized MTD device instance is
|
||||
* returned; NULL is returned on any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int lpc43_spifi_initialize(void);
|
||||
FAR struct mtd_dev_s *lpc43_spifi_initialize(void);
|
||||
|
||||
#endif /* CONFIG_LPC43_SPIFI */
|
||||
#endif /* __ARCH_ARM_SRC_LPC43XX_LPC43_SPIFI_H */
|
||||
|
|
Loading…
Reference in New Issue