mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-08-09 00:36:59 +02:00
mtd: spi-nor: Always build SPI_STACKED_PARALLEL code
Prevent the code gated by SPI_STACKED_PARALLEL from bitrot
by using if (CONFIG_IS_ENABLED(SPI_STACKED_PARALLEL)) around
it. That way, it is always at least compiled.
Fixes: 5d40b3d384
("mtd: spi-nor: Add parallel and stacked memories support")
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
This commit is contained in:
parent
f896aa6567
commit
43423cdc5d
@ -3047,13 +3047,6 @@ static int spi_nor_init_params(struct spi_nor *nor,
|
|||||||
const struct flash_info *info,
|
const struct flash_info *info,
|
||||||
struct spi_nor_flash_parameter *params)
|
struct spi_nor_flash_parameter *params)
|
||||||
{
|
{
|
||||||
#if CONFIG_IS_ENABLED(DM_SPI) && CONFIG_IS_ENABLED(SPI_STACKED_PARALLEL)
|
|
||||||
struct udevice *dev = nor->spi->dev;
|
|
||||||
u64 flash_size[SNOR_FLASH_CNT_MAX] = {0};
|
|
||||||
u32 idx = 0, i = 0;
|
|
||||||
int rc;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Set legacy flash parameters as default. */
|
/* Set legacy flash parameters as default. */
|
||||||
memset(params, 0, sizeof(*params));
|
memset(params, 0, sizeof(*params));
|
||||||
|
|
||||||
@ -3172,62 +3165,69 @@ static int spi_nor_init_params(struct spi_nor *nor,
|
|||||||
|
|
||||||
spi_nor_post_sfdp_fixups(nor, params);
|
spi_nor_post_sfdp_fixups(nor, params);
|
||||||
}
|
}
|
||||||
#if CONFIG_IS_ENABLED(DM_SPI) && CONFIG_IS_ENABLED(SPI_STACKED_PARALLEL)
|
|
||||||
/*
|
if (CONFIG_IS_ENABLED(SPI_STACKED_PARALLEL)) {
|
||||||
* The flashes that are connected in stacked mode should be of same make.
|
u64 flash_size[SNOR_FLASH_CNT_MAX] = { 0 };
|
||||||
* Except the flash size all other properties are identical for all the
|
struct udevice *dev = nor->spi->dev;
|
||||||
* flashes connected in stacked mode.
|
u32 idx = 0, i = 0;
|
||||||
* The flashes that are connected in parallel mode should be identical.
|
int rc;
|
||||||
*/
|
|
||||||
while (i < SNOR_FLASH_CNT_MAX) {
|
/*
|
||||||
rc = ofnode_read_u64_index(dev_ofnode(dev), "stacked-memories",
|
* The flashes that are connected in stacked mode should be of same make.
|
||||||
idx, &flash_size[i]);
|
* Except the flash size all other properties are identical for all the
|
||||||
if (rc == -EINVAL) {
|
* flashes connected in stacked mode.
|
||||||
break;
|
* The flashes that are connected in parallel mode should be identical.
|
||||||
} else if (rc == -EOVERFLOW) {
|
*/
|
||||||
idx++;
|
while (i < SNOR_FLASH_CNT_MAX) {
|
||||||
} else {
|
rc = ofnode_read_u64_index(dev_ofnode(dev), "stacked-memories",
|
||||||
idx++;
|
idx, &flash_size[i]);
|
||||||
i++;
|
if (rc == -EINVAL) {
|
||||||
if (!(nor->flags & SNOR_F_HAS_STACKED))
|
break;
|
||||||
nor->flags |= SNOR_F_HAS_STACKED;
|
} else if (rc == -EOVERFLOW) {
|
||||||
if (!(nor->spi->flags & SPI_XFER_STACKED))
|
idx++;
|
||||||
nor->spi->flags |= SPI_XFER_STACKED;
|
} else {
|
||||||
|
idx++;
|
||||||
|
i++;
|
||||||
|
if (!(nor->flags & SNOR_F_HAS_STACKED))
|
||||||
|
nor->flags |= SNOR_F_HAS_STACKED;
|
||||||
|
if (!(nor->spi->flags & SPI_XFER_STACKED))
|
||||||
|
nor->spi->flags |= SPI_XFER_STACKED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
idx = 0;
|
||||||
|
while (i < SNOR_FLASH_CNT_MAX) {
|
||||||
|
rc = ofnode_read_u64_index(dev_ofnode(dev), "parallel-memories",
|
||||||
|
idx, &flash_size[i]);
|
||||||
|
if (rc == -EINVAL) {
|
||||||
|
break;
|
||||||
|
} else if (rc == -EOVERFLOW) {
|
||||||
|
idx++;
|
||||||
|
} else {
|
||||||
|
idx++;
|
||||||
|
i++;
|
||||||
|
if (!(nor->flags & SNOR_F_HAS_PARALLEL))
|
||||||
|
nor->flags |= SNOR_F_HAS_PARALLEL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nor->flags & (SNOR_F_HAS_STACKED | SNOR_F_HAS_PARALLEL)) {
|
||||||
|
params->size = 0;
|
||||||
|
for (idx = 0; idx < SNOR_FLASH_CNT_MAX; idx++)
|
||||||
|
params->size += flash_size[idx];
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* In parallel-memories the erase operation is
|
||||||
|
* performed on both the flashes simultaneously
|
||||||
|
* so, double the erasesize.
|
||||||
|
*/
|
||||||
|
if (nor->flags & SNOR_F_HAS_PARALLEL) {
|
||||||
|
nor->mtd.erasesize <<= 1;
|
||||||
|
params->page_size <<= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
|
||||||
idx = 0;
|
|
||||||
while (i < SNOR_FLASH_CNT_MAX) {
|
|
||||||
rc = ofnode_read_u64_index(dev_ofnode(dev), "parallel-memories",
|
|
||||||
idx, &flash_size[i]);
|
|
||||||
if (rc == -EINVAL) {
|
|
||||||
break;
|
|
||||||
} else if (rc == -EOVERFLOW) {
|
|
||||||
idx++;
|
|
||||||
} else {
|
|
||||||
idx++;
|
|
||||||
i++;
|
|
||||||
if (!(nor->flags & SNOR_F_HAS_PARALLEL))
|
|
||||||
nor->flags |= SNOR_F_HAS_PARALLEL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nor->flags & (SNOR_F_HAS_STACKED | SNOR_F_HAS_PARALLEL)) {
|
|
||||||
params->size = 0;
|
|
||||||
for (idx = 0; idx < SNOR_FLASH_CNT_MAX; idx++)
|
|
||||||
params->size += flash_size[idx];
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* In parallel-memories the erase operation is
|
|
||||||
* performed on both the flashes simultaneously
|
|
||||||
* so, double the erasesize.
|
|
||||||
*/
|
|
||||||
if (nor->flags & SNOR_F_HAS_PARALLEL) {
|
|
||||||
nor->mtd.erasesize <<= 1;
|
|
||||||
params->page_size <<= 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
spi_nor_late_init_fixups(nor, params);
|
spi_nor_late_init_fixups(nor, params);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user