Skip to content

Commit

Permalink
mtd: cfi: Support early CFI fixups
Browse files Browse the repository at this point in the history
Some CFI devices need fixups that affect the number of chips detected,
but the current fixup infrastructure (struct cfi_fixup and cfi_fixup())
does not cover this situation.

Introduce struct cfi_early_fixup and cfi_early_fixup() to fill the void.

Signed-off-by: Aaron Sierra <asierra@xes-inc.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
  • Loading branch information
Aaron Sierra authored and Boris Brezillon committed May 4, 2018
1 parent 051529d commit b1c97e2
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions drivers/mtd/chips/cfi_probe.c
Original file line number Diff line number Diff line change
@@ -63,6 +63,30 @@ do { \

#endif

/*
* This fixup occurs immediately after reading the CFI structure and can affect
* the number of chips detected, unlike cfi_fixup, which occurs after an
* mtd_info structure has been created for the chip.
*/
struct cfi_early_fixup {
uint16_t mfr;
uint16_t id;
void (*fixup)(struct cfi_private *cfi);
};

static void cfi_early_fixup(struct cfi_private *cfi,
const struct cfi_early_fixup *fixups)
{
const struct cfi_early_fixup *f;

for (f = fixups; f->fixup; f++) {
if (((f->mfr == CFI_MFR_ANY) || (f->mfr == cfi->mfr)) &&
((f->id == CFI_ID_ANY) || (f->id == cfi->id))) {
f->fixup(cfi);
}
}
}

/* check for QRY.
in: interleave,type,mode
ret: table index, <0 for error
@@ -151,6 +175,10 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base,
return 1;
}

static const struct cfi_early_fixup cfi_early_fixup_table[] = {
{ },
};

static int __xipram cfi_chip_setup(struct map_info *map,
struct cfi_private *cfi)
{
@@ -235,6 +263,8 @@ static int __xipram cfi_chip_setup(struct map_info *map,
cfi_qry_mode_off(base, map, cfi);
xip_allowed(base, map);

cfi_early_fixup(cfi, cfi_early_fixup_table);

printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank. Manufacturer ID %#08x Chip ID %#08x\n",
map->name, cfi->interleave, cfi->device_type*8, base,
map->bankwidth*8, cfi->mfr, cfi->id);

0 comments on commit b1c97e2

Please sign in to comment.