[PATCH v13 2/8] mtd: rawnand: rockchip: NFC drivers for RK3308, RK2928 and others

赵仪峰 yifeng.zhao at rock-chips.com
Wed Nov 4 02:30:32 EST 2020


On 2020/11/3 1:11, Johan Jonker wrote:
>On 11/2/20 6:00 PM, Miquel Raynal wrote:
>> Hi Johan,
>>
>> Johan Jonker <jbx6244 at gmail.com> wrote on Mon, 2 Nov 2020 17:31:18
>> +0100:
>>
>>> On 11/2/20 2:11 PM, Johan Jonker wrote:
>>>> Hi,
>>>>
>>>> On 11/2/20 2:07 PM, Miquel Raynal wrote:
>>>>> Hi Johan, Yifeng
>>>>>
>>>>> Johan Jonker <jbx6244 at gmail.com> wrote on Mon, 2 Nov 2020 13:57:56
>>>>> +0100:
>>>>>
>>>>>> Hi Yifeng,
>>>>>>
>>>>>> Don't poke with "ecc->bytes" ones it is set in rk_nfc_ecc_init(). It
>>>>>> will not be noted by the MTD frame work or userspace. I think there's
>>>>>> currently no way to let the user know that a different ECC must be used.
>>>>>> Neither can the user set ECC on the fly.
>>>>>>
>>>>>> Example R/W flow:
>>>>>>
>>>>>>         nand_select_target()
>>>>>> chip->ecc.write_page_raw()
>>>>>> chip->ecc.write_page()
>>>>>>
>>>>>> [..]
>>>>>>
>>>>>> chip->ecc.read_page_raw()
>>>>>> chip->ecc.read_page()
>>>>>>         nand_deselect_target()
>>>>>>
>>>>>> A write/read with:
>>>>>>
>>>>>> rk_nfc_read_page_hwecc()
>>>>>> rk_nfc_write_page_hwecc()
>>>>>>
>>>>>> or
>>>>>>
>>>>>> rk_nfc_read_page_raw()
>>>>>> rk_nfc_write_page_raw()
>>>>>>
>>>>>> must end up with the same result. If we can't archive that, then we
>>>>>> shouldn't offer RAW mode to the user for now. If Miquel agrees you
>>>>>> should just get the driver ready now without these 2 functions and round
>>>>>> things up.
>>>>>
>>>>> What about just not supporting the BootROM area if it was marked
>>>>> "reserved" by the BRom in the DT?
>>>>
>>>> Should we just fill the buffers with '0xff' for boot blocks?
>>>
>>> (part 2) ;)
>>> My fault....
>>> Better use:
>>>
>>>     if ((chip->options & NAND_IS_BOOT_MEDIUM) &&
>>>         (page < (pages_per_blk * rknand->boot_blks))) {
>>>
>>> return -EIO;
>>>
>>>     }
>>
>> Yup, I was about to tell you that I would prefer returning a nice
>> error, this is fine I guess.
>>
>> Anyway, I think reading bad block markers is done in raw mode, so if
>> raw accessors refuse to return valid values for boot blocks, you won't
>> be able to access it neither with raw nor corrected hooks.
>>
>> Perhaps refusing the access to the regular page access is ok, but maybe
>> we should be able to at least read these pages in raw mode
>> (and move the BBM to its right location). What do you think?
>
>I think that the problem with asymmetric read and write access is that a
>user reads data successful, but that it can't write it back after it's
>block is erased. You shouldn't give the illusion that the boot ROM
>blocks can be accessed in RAW mode. Something with perception...does
>user space known that Rockchip's NFC is special...
>
> 

Is it possible to return a error when the ECC is different between the boot ROM blocks and other blocks?
If the ECC is the same, and the OOB layout is the same and does not need special treatment.

static int rk_nfc_read_page_raw(struct nand_chip *chip, u8 *buf, int oob_on,int page)
{
...
 if ((chip->options & NAND_IS_BOOT_MEDIUM) &&
        (page < (pages_per_blk * rknand->boot_blks)) &&
	(rknand->boot_ecc != ecc->strength)) {
		return -EIO;
    }
...
}

About the BBM, the u-boot will create BBT at the first power up.
	chip->bbt_options = NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
If uboot does not create BBT, then the framework will scan the OOB of all blocks and  create it.
I modified the read OOB function (enable ECC) ,and it can read the correct bad block mask.

static int rk_nfc_write_oob(struct nand_chip *chip, int page)
{
	return rk_nfc_write_page_hwecc(chip, NULL, 1, page);
}

static int rk_nfc_read_oob(struct nand_chip *chip, int page)
{
	return rk_nfc_read_page_hwecc(chip, NULL, 1, page);
}

chip->ecc.read_oob = rk_nfc_read_oob;
chip->ecc.write_oob = rk_nfc_write_oob;



>>
>> Thanks,
>> Miquèl
>>
>>>
>>>
>>>>
>>>>>
>>>>> Raw accessors is really a nice and basic feature that I would like to
>>>>> have in every new driver.
>>>>>
>>>>> Thanks,
>>>>> Miquèl
>>>>>
>>>>
>>>
>
>
>
>


More information about the linux-mtd mailing list