[PATCH 2/3] mtd: nand: add the infrastructure to retrieve the ONFI unique ID
Miquel RAYNAL
miquel.raynal at free-electrons.com
Tue Nov 14 09:07:38 PST 2017
Hello,
In the cover letter I forgot to give a link to the series this work is
based on:
http://patchwork.ozlabs.org/project/linux-mtd/list/?series=12308
I also spotted a mistake there:
> +static int nand_read_unique_id(struct nand_chip *chip, char *dest)
> +{
> + struct mtd_info *mtd = nand_to_mtd(chip);
> + u8 id[ONFI_UNIQUEID_LEN * 2];
> + int string_len = ONFI_FULL_UNIQUEID_STRING_LEN;
> + int ret, i, j, pos;
> +
> + /* ->exec_op related definitions */
> + const struct nand_sdr_timings *sdr =
> + nand_get_sdr_timings(&chip->data_interface);
> + u8 addr = 0;
> + struct nand_op_instr instrs[] = {
> + NAND_OP_CMD(NAND_CMD_READ_UNIQUEID, 0),
> + NAND_OP_ADDR(1, &addr, PSEC_TO_NSEC(sdr->tWB_max)),
> + NAND_OP_WAIT_RDY(PSEC_TO_MSEC(sdr->tR_max),
> + PSEC_TO_NSEC(sdr->tRR_min)),
> + };
> + struct nand_operation op = NAND_OPERATION(instrs);
> +
> + if (!chip->exec_op)
> + return -ENOTSUPP;
> +
> + if (!dest)
> + return -EINVAL;
> +
> + if (!(onfi_opt_cmd(chip) & ONFI_OPT_CMD_READ_UNIQUEID))
> + return -ENOTSUPP;
> +
> + ret = nand_exec_op(chip, &op);
> + if (ret)
> + return ret;
> +
> + /* Pattern is repeated 16 times */
> + for (i = 0; i < ONFI_UNIQUEID_REPETITIONS; i++) {
> + /* Each pattern is 32B wide (the ID + the ID XORed)
> */
> + if (chip->exec_op) {
> + struct nand_op_instr instrs[] = {
> + NAND_OP_8BIT_DATA_IN(sizeof(id), id,
> 0),
> + };
> + struct nand_operation op =
> NAND_OPERATION(instrs); +
> + ret = nand_exec_op(chip, &op);
> + if (ret)
> + return ret;
> + } else {
> + chip->read_buf(mtd, id, sizeof(id));
> + }
No need for that 'else' statement as this function will not run without
->exec_op() support.
Sorry about that, I will correct it in a later version.
Miquèl
More information about the linux-mtd
mailing list