mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
mtd: Implement BIOC_PARTINFO for all drivers
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
committed by
Gustavo Henrique Nihei
parent
5a1de89370
commit
71269811ca
@@ -212,6 +212,21 @@ static int cxd56_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
|
||||
}
|
||||
break;
|
||||
|
||||
case BIOC_PARTINFO:
|
||||
{
|
||||
FAR struct partition_info_s *info =
|
||||
(FAR struct partition_info_s *)arg;
|
||||
if (info != NULL)
|
||||
{
|
||||
info->magic = 0;
|
||||
info->numsectors = priv->density / PAGE_SIZE;
|
||||
info->sectorsize = PAGE_SIZE;
|
||||
info->startsector = 0;
|
||||
info->parent[0] = '\0';
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MTDIOC_BULKERASE:
|
||||
{
|
||||
/* Erase the entire device */
|
||||
|
||||
@@ -349,6 +349,22 @@ static int lc823450_ioctl(FAR struct mtd_dev_s *dev, int cmd,
|
||||
geo->erasesize, geo->neraseblocks);
|
||||
break;
|
||||
|
||||
case BIOC_PARTINFO:
|
||||
{
|
||||
FAR struct partition_info_s *info =
|
||||
(FAR struct partition_info_s *)arg;
|
||||
if (info != NULL)
|
||||
{
|
||||
info->magic = 0;
|
||||
info->numsectors = priv->nblocks;
|
||||
info->sectorsize = priv->blocksize;
|
||||
info->startsector = 0;
|
||||
info->parent[0] = '\0';
|
||||
ret = OK;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case BIOC_XIPBASE:
|
||||
finfo("BIOC_XIPBASE\n");
|
||||
ppv = (FAR void**)arg;
|
||||
|
||||
@@ -887,6 +887,28 @@ static int lpc43_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
|
||||
}
|
||||
break;
|
||||
|
||||
case BIOC_PARTINFO:
|
||||
{
|
||||
FAR struct partition_info_s *info =
|
||||
(FAR struct partition_info_s *)arg;
|
||||
if (info != NULL)
|
||||
{
|
||||
info->magic = 0;
|
||||
#ifdef CONFIG_SPIFI_SECTOR512
|
||||
info->numsectors = priv->nblocks <<
|
||||
(SPIFI_BLKSHIFT - SPIFI_512SHIFT);
|
||||
info->sectorsize = 512;
|
||||
#else
|
||||
info->numsectors = priv->nblocks;
|
||||
info->sectorsize = SPIFI_BLKSIZE;
|
||||
#endif
|
||||
info->startsector = 0;
|
||||
info->parent[0] = '\0';
|
||||
ret = OK;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MTDIOC_BULKERASE:
|
||||
{
|
||||
/* Erase the entire device */
|
||||
|
||||
@@ -244,6 +244,22 @@ static int ameba_flash_ioctl(FAR struct mtd_dev_s *dev,
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case BIOC_PARTINFO:
|
||||
{
|
||||
FAR struct partition_info_s *info =
|
||||
(FAR struct partition_info_s *)arg;
|
||||
if (info != NULL)
|
||||
{
|
||||
info->magic = 0;
|
||||
info->numsectors = priv->nsectors *
|
||||
AMEBA_SECTOR_SIZE / AMEBA_PAGE_SIZE;
|
||||
info->sectorsize = AMEBA_PAGE_SIZE;
|
||||
info->startsector = 0;
|
||||
info->parent[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case MTDIOC_BULKERASE:
|
||||
{
|
||||
|
||||
@@ -394,6 +394,22 @@ static int tiva_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
|
||||
}
|
||||
break;
|
||||
|
||||
case BIOC_PARTINFO:
|
||||
{
|
||||
FAR struct partition_info_s *info =
|
||||
(FAR struct partition_info_s *)arg;
|
||||
if (info != NULL)
|
||||
{
|
||||
info->magic = 0;
|
||||
info->numsectors = TIVA_VIRTUAL_NPAGES;
|
||||
info->sectorsize = TIVA_FLASH_PAGESIZE;
|
||||
info->startsector = 0;
|
||||
info->parent[0] = '\0';
|
||||
ret = OK;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case BIOC_XIPBASE:
|
||||
{
|
||||
FAR void **ppv = (FAR void**)arg;
|
||||
|
||||
@@ -287,14 +287,13 @@ int bl602_ioctl(FAR struct mtd_dev_s *dev, int cmd,
|
||||
{
|
||||
int ret = -EINVAL;
|
||||
FAR struct bl602_spiflash_s *priv = MTD2PRIV(dev);
|
||||
FAR struct mtd_geometry_s *geo;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case MTDIOC_GEOMETRY:
|
||||
{
|
||||
finfo("cmd(0x%x) MTDIOC_GEOMETRY.\n", cmd);
|
||||
geo = (FAR struct mtd_geometry_s *)arg;
|
||||
FAR struct mtd_geometry_s *geo = (FAR struct mtd_geometry_s *)arg;
|
||||
if (geo)
|
||||
{
|
||||
geo->blocksize = SPIFLASH_BLOCKSIZE;
|
||||
@@ -308,6 +307,22 @@ int bl602_ioctl(FAR struct mtd_dev_s *dev, int cmd,
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BIOC_PARTINFO:
|
||||
{
|
||||
FAR struct partition_info_s *info =
|
||||
(FAR struct partition_info_s *)arg;
|
||||
if (info != NULL)
|
||||
{
|
||||
info->magic = 0;
|
||||
info->numsectors = priv->config->flash_size /
|
||||
SPIFLASH_BLOCKSIZE;
|
||||
info->sectorsize = SPIFLASH_BLOCKSIZE;
|
||||
info->startsector = 0;
|
||||
info->parent[0] = '\0';
|
||||
ret = OK;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
finfo("cmd(0x%x) not support.\n", cmd);
|
||||
|
||||
@@ -853,7 +853,6 @@ static int esp32c3_ioctl(struct mtd_dev_s *dev, int cmd,
|
||||
unsigned long arg)
|
||||
{
|
||||
int ret = OK;
|
||||
struct mtd_geometry_s *geo;
|
||||
|
||||
finfo("cmd: %d \n", cmd);
|
||||
|
||||
@@ -861,7 +860,7 @@ static int esp32c3_ioctl(struct mtd_dev_s *dev, int cmd,
|
||||
{
|
||||
case MTDIOC_GEOMETRY:
|
||||
{
|
||||
geo = (struct mtd_geometry_s *)arg;
|
||||
struct mtd_geometry_s *geo = (struct mtd_geometry_s *)arg;
|
||||
if (geo)
|
||||
{
|
||||
geo->blocksize = SPI_FLASH_BLK_SIZE;
|
||||
@@ -876,9 +875,23 @@ static int esp32c3_ioctl(struct mtd_dev_s *dev, int cmd,
|
||||
}
|
||||
break;
|
||||
|
||||
case BIOC_PARTINFO:
|
||||
{
|
||||
struct partition_info_s *info = (struct partition_info_s *)arg;
|
||||
if (info != NULL)
|
||||
{
|
||||
info->magic = 0;
|
||||
info->numsectors = SPI_FLASH_SIZE / SPI_FLASH_BLK_SIZE;
|
||||
info->sectorsize = SPI_FLASH_BLK_SIZE;
|
||||
info->startsector = 0;
|
||||
info->parent[0] = '\0';
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MTDIOC_ERASESTATE:
|
||||
{
|
||||
FAR uint8_t *result = (FAR uint8_t *)arg;
|
||||
uint8_t *result = (uint8_t *)arg;
|
||||
*result = SPI_FLASH_ERASED_STATE;
|
||||
|
||||
ret = OK;
|
||||
|
||||
@@ -1909,7 +1909,6 @@ static int esp32_ioctl(FAR struct mtd_dev_s *dev, int cmd,
|
||||
{
|
||||
int ret = -EINVAL;
|
||||
FAR struct esp32_spiflash_s *priv = MTD2PRIV(dev);
|
||||
FAR struct mtd_geometry_s *geo;
|
||||
|
||||
finfo("cmd: %d \n", cmd);
|
||||
|
||||
@@ -1917,7 +1916,7 @@ static int esp32_ioctl(FAR struct mtd_dev_s *dev, int cmd,
|
||||
{
|
||||
case MTDIOC_GEOMETRY:
|
||||
{
|
||||
geo = (FAR struct mtd_geometry_s *)arg;
|
||||
FAR struct mtd_geometry_s *geo = (FAR struct mtd_geometry_s *)arg;
|
||||
if (geo)
|
||||
{
|
||||
geo->blocksize = MTD_BLKSIZE(priv);
|
||||
@@ -1931,6 +1930,22 @@ static int esp32_ioctl(FAR struct mtd_dev_s *dev, int cmd,
|
||||
}
|
||||
break;
|
||||
|
||||
case BIOC_PARTINFO:
|
||||
{
|
||||
FAR struct partition_info_s *info =
|
||||
(FAR struct partition_info_s *)arg;
|
||||
if (info != NULL)
|
||||
{
|
||||
info->magic = 0;
|
||||
info->numsectors = MTD_SIZE(priv) / MTD_BLKSIZE(priv);
|
||||
info->sectorsize = MTD_BLKSIZE(priv);
|
||||
info->startsector = 0;
|
||||
info->parent[0] = '\0';
|
||||
ret = OK;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MTDIOC_ERASESTATE:
|
||||
{
|
||||
FAR uint8_t *result = (FAR uint8_t *)arg;
|
||||
|
||||
Reference in New Issue
Block a user