mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-24 21:54:01 +00:00
nand: vybrid: Re-introduce vf610_nfc.dev
This member was presumably dropped when this driver was converted from Linux. However, it is still used in log statements during initialization. This patch adds the member back. In addition, allocation of struct vf610_nfc has been moved to the callers of vf610_nfc_nand_init. This allows it to be allocated by DM (if it is being used) and for dev to be initialized. Signed-off-by: Sean Anderson <seanga2@gmail.com> Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
This commit is contained in:
parent
15b6ab4cee
commit
7f36806c9b
1 changed files with 21 additions and 17 deletions
|
@ -152,6 +152,8 @@ enum vf610_nfc_alt_buf {
|
|||
|
||||
struct vf610_nfc {
|
||||
struct nand_chip chip;
|
||||
/* NULL without CONFIG_NAND_VF610_NFC_DT */
|
||||
struct udevice *dev;
|
||||
void __iomem *regs;
|
||||
uint buf_offset;
|
||||
int write_sz;
|
||||
|
@ -631,11 +633,10 @@ struct vf610_nfc_config {
|
|||
int flash_bbt;
|
||||
};
|
||||
|
||||
static int vf610_nfc_nand_init(int devnum, void __iomem *addr)
|
||||
static int vf610_nfc_nand_init(struct vf610_nfc *nfc, int devnum)
|
||||
{
|
||||
struct mtd_info *mtd;
|
||||
struct nand_chip *chip;
|
||||
struct vf610_nfc *nfc;
|
||||
struct nand_chip *chip = &nfc->chip;
|
||||
struct mtd_info *mtd = nand_to_mtd(chip);
|
||||
int err = 0;
|
||||
struct vf610_nfc_config cfg = {
|
||||
.hardware_ecc = 1,
|
||||
|
@ -647,16 +648,6 @@ static int vf610_nfc_nand_init(int devnum, void __iomem *addr)
|
|||
.flash_bbt = 1,
|
||||
};
|
||||
|
||||
nfc = calloc(1, sizeof(*nfc));
|
||||
if (!nfc) {
|
||||
printf(KERN_ERR "%s: Memory exhausted!\n", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
chip = &nfc->chip;
|
||||
nfc->regs = addr;
|
||||
|
||||
mtd = nand_to_mtd(chip);
|
||||
nand_set_controller_data(chip, nfc);
|
||||
|
||||
if (cfg.width == 16)
|
||||
|
@ -777,20 +768,23 @@ static const struct udevice_id vf610_nfc_dt_ids[] = {
|
|||
static int vf610_nfc_dt_probe(struct udevice *dev)
|
||||
{
|
||||
struct resource res;
|
||||
struct vf610_nfc *nfc = dev_get_priv(dev);
|
||||
int ret;
|
||||
|
||||
ret = dev_read_resource(dev, 0, &res);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return vf610_nfc_nand_init(0, devm_ioremap(dev, res.start,
|
||||
resource_size(&res)));
|
||||
nfc->regs = devm_ioremap(dev, res.start, resource_size(&res));
|
||||
nfc->dev = dev;
|
||||
return vf610_nfc_nand_init(nfc, 0);
|
||||
}
|
||||
|
||||
U_BOOT_DRIVER(vf610_nfc_dt) = {
|
||||
.name = "vf610-nfc-dt",
|
||||
.id = UCLASS_MTD,
|
||||
.of_match = vf610_nfc_dt_ids,
|
||||
.priv_auto_alloc_size = sizeof(struct vf610_nfc),
|
||||
.probe = vf610_nfc_dt_probe,
|
||||
};
|
||||
|
||||
|
@ -809,7 +803,17 @@ void board_nand_init(void)
|
|||
#else
|
||||
void board_nand_init(void)
|
||||
{
|
||||
int err = vf610_nfc_nand_init(0, (void __iomem *)CONFIG_SYS_NAND_BASE);
|
||||
int err;
|
||||
struct vf610_nfc *nfc;
|
||||
|
||||
nfc = calloc(1, sizeof(*nfc));
|
||||
if (!nfc) {
|
||||
printf("%s: Out of memory\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
nfc->regs = (void __iomem *)CONFIG_SYS_NAND_BASE;
|
||||
err = vf610_nfc_nand_init(nfc, 0);
|
||||
if (err)
|
||||
printf("VF610 NAND init failed (err %d)\n", err);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue