aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Sierra <asierra@xes-inc.com>2018-04-30 12:34:49 -0400
committerBoris Brezillon <boris.brezillon@bootlin.com>2018-05-04 03:50:19 -0400
commitb1c97e2335f24dbdcc26cfdc882b8b5a0bad25c2 (patch)
treec8ed6026cc8627b09e5abd8e78823f5fc4a49b4f
parent051529d0c010a07c84fb42626053e4df610857c5 (diff)
mtd: cfi: Support early CFI fixups
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>
-rw-r--r--drivers/mtd/chips/cfi_probe.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/mtd/chips/cfi_probe.c b/drivers/mtd/chips/cfi_probe.c
index e8d0164498b0..812df70ab6a6 100644
--- a/drivers/mtd/chips/cfi_probe.c
+++ b/drivers/mtd/chips/cfi_probe.c
@@ -63,6 +63,30 @@ do { \
63 63
64#endif 64#endif
65 65
66/*
67 * This fixup occurs immediately after reading the CFI structure and can affect
68 * the number of chips detected, unlike cfi_fixup, which occurs after an
69 * mtd_info structure has been created for the chip.
70 */
71struct cfi_early_fixup {
72 uint16_t mfr;
73 uint16_t id;
74 void (*fixup)(struct cfi_private *cfi);
75};
76
77static void cfi_early_fixup(struct cfi_private *cfi,
78 const struct cfi_early_fixup *fixups)
79{
80 const struct cfi_early_fixup *f;
81
82 for (f = fixups; f->fixup; f++) {
83 if (((f->mfr == CFI_MFR_ANY) || (f->mfr == cfi->mfr)) &&
84 ((f->id == CFI_ID_ANY) || (f->id == cfi->id))) {
85 f->fixup(cfi);
86 }
87 }
88}
89
66/* check for QRY. 90/* check for QRY.
67 in: interleave,type,mode 91 in: interleave,type,mode
68 ret: table index, <0 for error 92 ret: table index, <0 for error
@@ -151,6 +175,10 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base,
151 return 1; 175 return 1;
152} 176}
153 177
178static const struct cfi_early_fixup cfi_early_fixup_table[] = {
179 { },
180};
181
154static int __xipram cfi_chip_setup(struct map_info *map, 182static int __xipram cfi_chip_setup(struct map_info *map,
155 struct cfi_private *cfi) 183 struct cfi_private *cfi)
156{ 184{
@@ -235,6 +263,8 @@ static int __xipram cfi_chip_setup(struct map_info *map,
235 cfi_qry_mode_off(base, map, cfi); 263 cfi_qry_mode_off(base, map, cfi);
236 xip_allowed(base, map); 264 xip_allowed(base, map);
237 265
266 cfi_early_fixup(cfi, cfi_early_fixup_table);
267
238 printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank. Manufacturer ID %#08x Chip ID %#08x\n", 268 printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank. Manufacturer ID %#08x Chip ID %#08x\n",
239 map->name, cfi->interleave, cfi->device_type*8, base, 269 map->name, cfi->interleave, cfi->device_type*8, base,
240 map->bankwidth*8, cfi->mfr, cfi->id); 270 map->bankwidth*8, cfi->mfr, cfi->id);