spinand: call SPI setup_for_spinand if supported
Call SPI setup_for_spinand() if supported and defined to configure the SPI slave for the attached NAND. This is needed to configure the SPI with the NAND page size and spare size for correct configuration of the device. Call it as soon as the NAND is detected to correctly handle SPI controller with select_op_variant detection. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
This commit is contained in:

committed by
Tom Rini

parent
ef45b9c395
commit
5ff602a351
@@ -941,6 +941,19 @@ spinand_select_op_variant(struct spinand_device *spinand,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int spinand_setup_slave(struct spinand_device *spinand,
|
||||||
|
const struct spinand_info *spinand_info)
|
||||||
|
{
|
||||||
|
struct spi_slave *slave = spinand->slave;
|
||||||
|
struct udevice *bus = slave->dev->parent;
|
||||||
|
struct dm_spi_ops *ops = spi_get_ops(bus);
|
||||||
|
|
||||||
|
if (!ops->setup_for_spinand)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return ops->setup_for_spinand(slave, spinand_info);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* spinand_match_and_init() - Try to find a match between a device ID and an
|
* spinand_match_and_init() - Try to find a match between a device ID and an
|
||||||
* entry in a spinand_info table
|
* entry in a spinand_info table
|
||||||
@@ -964,6 +977,7 @@ int spinand_match_and_init(struct spinand_device *spinand,
|
|||||||
u8 *id = spinand->id.data;
|
u8 *id = spinand->id.data;
|
||||||
struct nand_device *nand = spinand_to_nand(spinand);
|
struct nand_device *nand = spinand_to_nand(spinand);
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
int ret;
|
||||||
|
|
||||||
for (i = 0; i < table_size; i++) {
|
for (i = 0; i < table_size; i++) {
|
||||||
const struct spinand_info *info = &table[i];
|
const struct spinand_info *info = &table[i];
|
||||||
@@ -975,6 +989,10 @@ int spinand_match_and_init(struct spinand_device *spinand,
|
|||||||
if (memcmp(id + 1, info->devid.id, info->devid.len))
|
if (memcmp(id + 1, info->devid.id, info->devid.len))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
ret = spinand_setup_slave(spinand, info);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
nand->memorg = table[i].memorg;
|
nand->memorg = table[i].memorg;
|
||||||
nand->eccreq = table[i].eccreq;
|
nand->eccreq = table[i].eccreq;
|
||||||
spinand->eccinfo = table[i].eccinfo;
|
spinand->eccinfo = table[i].eccinfo;
|
||||||
|
Reference in New Issue
Block a user