More protection register fun.

Ken Gordon ken at magneticscrolls.com
Thu Jun 19 08:07:14 EDT 2003


from cfi_intelext_read_prot_reg in cfi_cmdset_0001.c (in CVS)

        int ofs_factor = cfi->interleave * cfi->device_type;


                while (count && ((offst-base_offst) < reg_sz)) {
                        *buf =
map_read8(map,(chip->start+((extp->ProtRegAddr+1)*ofs_factor)+offst));
                        buf++;
                        offst++;
                        count--;
                }

In my case (2x Intel Strataflash J3 on a PXA255, configured as 2x16 bit on a
32 bit bus):

    interleave = 2
    device_type = 2

    so ofs_factor = 4

    Now ProtRegAddr is 0x100 and appears to be a byte address within the
device. Now I don't claim any understanding of what device_type means and I
can only test this on hardware I have so can someone who fully uderstands
this code say whether it ought to be more like:

while (count && ((offst-base_offst) < reg_sz)) {
                       *buf =
map_read8(map,(chip->start+((extp->ProtRegAddr+2)*cfi->interleave)+offst));
// also +2 not +1 'cos the lock register is 16 bits
                       buf++;
                       offst++;
                       count--;
               }

Actually this doen't really work either 'cos it gets the same bytes for each
of the two chips.

Any ideas (I'm about to hack my one for my hardware and stop spending time
on this)

    Ken




More information about the linux-mtd mailing list