Replace CONFIG_MTD_SMART in MTD drivers with other conditions
This commit is contained in:
parent
72179b7773
commit
8757465df2
@ -416,6 +416,7 @@ CONFIG_MTD_M25P=y
|
||||
CONFIG_M25P_SPIMODE=0
|
||||
CONFIG_M25P_MANUFACTURER=0x1C
|
||||
CONFIG_M25P_MEMORY_TYPE=0x31
|
||||
CONFIG_M25P_SUBSECTOR_ERASE=y
|
||||
CONFIG_MTD_SMART=y
|
||||
CONFIG_MTD_SMART_SECTOR_SIZE=512
|
||||
# CONFIG_MTD_RAMTRON is not set
|
||||
|
@ -135,6 +135,14 @@ config M25P_MEMORY_TYPE
|
||||
memory type for "F" series parts from EON is 0x31. The 4K sector erase size will
|
||||
automatically be enabled when filessytems that can use it are enabled, such as SMART.
|
||||
|
||||
config M25P_SUBSECTOR_ERASE
|
||||
bool "Sub-Sector Erase"
|
||||
default n
|
||||
---help---
|
||||
Some devices (such as the EON EN25F80) support a smaller erase block
|
||||
size (4K vs 64K). This option enables support for sub-sector erase.
|
||||
The SMART file system can take advantage of this option if it is enabled.
|
||||
|
||||
endif
|
||||
|
||||
config MTD_SMART
|
||||
|
@ -204,7 +204,7 @@ struct m25p_dev_s
|
||||
uint8_t pageshift; /* 8 */
|
||||
uint16_t nsectors; /* 128 or 64 */
|
||||
uint32_t npages; /* 32,768 or 65,536 */
|
||||
#ifdef CONFIG_MTD_SMART
|
||||
#ifdef CONFIG_M25P_SUBSECTOR_ERASE
|
||||
uint8_t subsectorshift; /* 0, 12 or 13 (4K or 8K) */
|
||||
#endif
|
||||
};
|
||||
@ -322,7 +322,7 @@ static inline int m25p_readid(struct m25p_dev_s *priv)
|
||||
{
|
||||
/* Okay.. is it a FLASH capacity that we understand? */
|
||||
|
||||
#ifdef CONFIG_MTD_SMART
|
||||
#ifdef CONFIG_M25P_SUBSECTOR_ERASE
|
||||
priv->subsectorshift = 0;
|
||||
#endif
|
||||
|
||||
@ -344,7 +344,7 @@ static inline int m25p_readid(struct m25p_dev_s *priv)
|
||||
priv->npages = M25P_EN25F80_NPAGES;
|
||||
priv->sectorshift = M25P_EN25F80_SECTOR_SHIFT;
|
||||
priv->nsectors = M25P_EN25F80_NSECTORS;
|
||||
#ifdef CONFIG_MTD_SMART
|
||||
#ifdef CONFIG_M25P_SUBSECTOR_ERASE
|
||||
priv->subsectorshift = M25P_EN25F80_SUBSECT_SHIFT;
|
||||
#endif
|
||||
return OK;
|
||||
@ -486,7 +486,7 @@ static void m25p_sectorerase(struct m25p_dev_s *priv, off_t sector, uint8_t type
|
||||
{
|
||||
off_t offset;
|
||||
|
||||
#ifdef CONFIG_MTD_SMART
|
||||
#ifdef CONFIG_M25P_SUBSECTOR_ERASE
|
||||
if (priv->subsectorshift > 0)
|
||||
{
|
||||
offset = sector << priv->subsectorshift;
|
||||
@ -681,7 +681,7 @@ static int m25p_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblock
|
||||
m25p_lock(priv->dev);
|
||||
while (blocksleft > 0)
|
||||
{
|
||||
#ifdef CONFIG_MTD_SMART
|
||||
#ifdef CONFIG_M25P_SUBSECTOR_ERASE
|
||||
size_t sectorboundry;
|
||||
size_t blkper;
|
||||
|
||||
@ -928,7 +928,7 @@ static int m25p_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
|
||||
*/
|
||||
|
||||
geo->blocksize = (1 << priv->pageshift);
|
||||
#ifdef CONFIG_MTD_SMART
|
||||
#ifdef CONFIG_M25P_SUBSECTOR_ERASE
|
||||
if (priv->subsectorshift > 0)
|
||||
{
|
||||
geo->erasesize = (1 << priv->subsectorshift);
|
||||
|
@ -121,6 +121,12 @@ static ssize_t ram_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nbl
|
||||
FAR uint8_t *buf);
|
||||
static ssize_t ram_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks,
|
||||
FAR const uint8_t *buf);
|
||||
static ssize_t ram_byteread(FAR struct mtd_dev_s *dev, off_t offset,
|
||||
size_t nbytes, FAR uint8_t *buf);
|
||||
#ifdef CONFIG_MTD_BYTE_WRITE
|
||||
static ssize_t ram_bytewrite(FAR struct mtd_dev_s *dev, off_t offset,
|
||||
size_t nbytes, FAR const uint8_t *buf);
|
||||
#endif
|
||||
static int ram_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg);
|
||||
|
||||
/****************************************************************************
|
||||
@ -160,7 +166,7 @@ static void *ram_write(FAR void *dest, FAR const void *src, size_t len)
|
||||
#endif
|
||||
|
||||
/* Report any attempt to change the value of bits that are not in the
|
||||
* erased state.
|
||||
* erased state.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
@ -224,30 +230,6 @@ static int ram_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ram_readbytes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_MTD_SMART
|
||||
static ssize_t ram_read_bytes(FAR struct mtd_dev_s *dev, off_t offset,
|
||||
size_t nbytes, FAR uint8_t *buf)
|
||||
{
|
||||
FAR struct ram_dev_s *priv = (FAR struct ram_dev_s *)dev;
|
||||
|
||||
DEBUGASSERT(dev && buf);
|
||||
|
||||
/* Don't let read read past end of buffer */
|
||||
|
||||
if (offset + nbytes > priv->nblocks * CONFIG_RAMMTD_ERASESIZE)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
ram_read(buf, &priv->start[offset], nbytes);
|
||||
return nbytes;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ram_bread
|
||||
****************************************************************************/
|
||||
@ -328,13 +310,35 @@ static ssize_t ram_bwrite(FAR struct mtd_dev_s *dev, off_t startblock,
|
||||
return nblocks;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ram_byteread
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t ram_byteread(FAR struct mtd_dev_s *dev, off_t offset,
|
||||
size_t nbytes, FAR uint8_t *buf)
|
||||
{
|
||||
FAR struct ram_dev_s *priv = (FAR struct ram_dev_s *)dev;
|
||||
|
||||
DEBUGASSERT(dev && buf);
|
||||
|
||||
/* Don't let read read past end of buffer */
|
||||
|
||||
if (offset + nbytes > priv->nblocks * CONFIG_RAMMTD_ERASESIZE)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
ram_read(buf, &priv->start[offset], nbytes);
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ram_bytewrite
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_MTD_BYTE_WRITE
|
||||
static ssize_t ram_bytewrite(FAR struct mtd_dev_s *dev, off_t offset,
|
||||
size_t nbytes, FAR const uint8_t *buf)
|
||||
size_t nbytes, FAR const uint8_t *buf)
|
||||
{
|
||||
FAR struct ram_dev_s *priv = (FAR struct ram_dev_s *)dev;
|
||||
off_t maxaddr;
|
||||
@ -462,17 +466,11 @@ FAR struct mtd_dev_s *rammtd_initialize(FAR uint8_t *start, size_t size)
|
||||
priv->mtd.erase = ram_erase;
|
||||
priv->mtd.bread = ram_bread;
|
||||
priv->mtd.bwrite = ram_bwrite;
|
||||
priv->mtd.ioctl = ram_ioctl;
|
||||
priv->mtd.erase = ram_erase;
|
||||
priv->mtd.read = ram_byteread;
|
||||
#ifdef CONFIG_MTD_BYTE_WRITE
|
||||
priv->mtd.write = ram_bytewrite;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MTD_SMART
|
||||
priv->mtd.read = ram_read_bytes;
|
||||
#else
|
||||
priv->mtd.read = NULL;
|
||||
#endif
|
||||
priv->mtd.ioctl = ram_ioctl;
|
||||
|
||||
priv->start = start;
|
||||
priv->nblocks = nblocks;
|
||||
|
Loading…
Reference in New Issue
Block a user