Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1991192imm; Thu, 18 Oct 2018 07:27:57 -0700 (PDT) X-Google-Smtp-Source: ACcGV61aMa74w/1d1dvH/BTgB1G0PtHO9YsOsPuWXBDIg7o9RfphwNTwc2jGTqklwDfFTGuIV++t X-Received: by 2002:a17:902:3041:: with SMTP id u59-v6mr16924683plb.279.1539872877336; Thu, 18 Oct 2018 07:27:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539872877; cv=none; d=google.com; s=arc-20160816; b=MU0Rn0hm3+wQ4AGcGuSEYwszcOlDtvxtU26YuvJyaWNSXBDOsjJn7X80mAfNVqtAa/ HwX8q2IZW2HKLr7etdZOYNBeuLPBwqbTiAZS4zYKAQjdxydX8edj92cIsweBmBacAR4G Yt/cS9mVf0oKo0SQqFe0VvArg+HCsAm3dsf54L4sSkxSZg72q58WyKQ/xryiM8qGOvgi kAmkqNTyLLkvDyiK/POMXEe/zDIz3j2xhxJguiLB+9jYaBIRu8djKzvu7TMQOVYXaBff sOlU/beFPu4tfUoHhgPzYHFAVHQ2Df4nrUB/vDTaNNvBI7GAyJ1MdZ7Kt5Chav8RfxDZ HByw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=ACsnBZcHuena556GtK5HD0AydNubomB/kd5JL6bw99k=; b=kw3yb4jmOdeuNvl/7lADFmGAZv75K5eDdpNdnZKrxYOwZfWVoPl/GJm/WI0oqxg97f mOLVyUizz5MbcCzyPnBTO903O5ElvzzINQ3f84SDY2zWdBA3hIIJg2cxkyQ1ggi5Tgby Kf68W3LMyAPqSebo6cWDAzKadI01teJ5tqER9JN9uZ6JIYD2R4n+6svoJ3ZLRmO+vPff zZ1hS/Ig0q9BRIBRYM0baSiClbx4vQXSt0BCDzcD08HrulRg7PTfW3GQHeX1BIAtg1Xa jhuJofW4cKNYr0JN2n79fSTVThEnWO08Jgko4z4Fmh+OeODfCobm0Fg6CHTrFigeczJc 8dOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o127-v6si21353844pfb.128.2018.10.18.07.27.41; Thu, 18 Oct 2018 07:27:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728296AbeJRW0R (ORCPT + 99 others); Thu, 18 Oct 2018 18:26:17 -0400 Received: from mail.bootlin.com ([62.4.15.54]:33279 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728077AbeJRW0R (ORCPT ); Thu, 18 Oct 2018 18:26:17 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id A98A32090A; Thu, 18 Oct 2018 16:25:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (AAubervilliers-681-1-25-52.w90-88.abo.wanadoo.fr [90.88.145.52]) by mail.bootlin.com (Postfix) with ESMTPSA id 281BB208C7; Thu, 18 Oct 2018 16:24:50 +0200 (CEST) Date: Thu, 18 Oct 2018 16:24:49 +0200 From: Boris Brezillon To: Jianxin Pan Cc: , Liang Yang , Yixun Lan , David Woodhouse , Brian Norris , Marek Vasut , Richard Weinberger , Jerome Brunet , Neil Armstrong , Martin Blumenstingl , Carlo Caione , Kevin Hilman , Rob Herring , Jian Hu , Hanjie Lin , Victor Wan , , , Subject: Re: [PATCH v5 2/2] mtd: rawnand: meson: add support for Amlogic NAND flash controller Message-ID: <20181018162449.3fe433e7@bbrezillon> In-Reply-To: <1539839345-14021-3-git-send-email-jianxin.pan@amlogic.com> References: <1539839345-14021-1-git-send-email-jianxin.pan@amlogic.com> <1539839345-14021-3-git-send-email-jianxin.pan@amlogic.com> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 18 Oct 2018 13:09:05 +0800 Jianxin Pan wrote: > +static int meson_nfc_exec_op(struct nand_chip *chip, > + const struct nand_operation *op, bool check_only) > +{ > + struct mtd_info *mtd = nand_to_mtd(chip); > + struct meson_nfc *nfc = nand_get_controller_data(chip); > + const struct nand_op_instr *instr = NULL; > + int ret = 0, cmd; > + unsigned int op_id; > + int i; > + > + for (op_id = 0; op_id < op->ninstrs; op_id++) { > + instr = &op->instrs[op_id]; > + switch (instr->type) { > + case NAND_OP_CMD_INSTR: > + if (instr->ctx.cmd.opcode == NAND_CMD_STATUS) > + meson_nfc_cmd_idle(nfc, nfc->timing.twb); Hm, I don't want drivers to base their decisions on the opcode value. There's a ->delay_ns field in the instruction object, can't you use that one instead? Also, I don't understand why this is only needed for the STATUS command. It should normally be applied to all instructions. > + cmd = nfc->param.chip_select | NFC_CMD_CLE; > + cmd |= instr->ctx.cmd.opcode & 0xff; > + writel(cmd, nfc->reg_base + NFC_REG_CMD); > + if (instr->ctx.cmd.opcode == NAND_CMD_STATUS) > + meson_nfc_cmd_idle(nfc, nfc->timing.twhr); > + break; > + > + case NAND_OP_ADDR_INSTR: > + for (i = 0; i < instr->ctx.addr.naddrs; i++) { > + cmd = nfc->param.chip_select | NFC_CMD_ALE; > + cmd |= instr->ctx.addr.addrs[i] & 0xff; > + writel(cmd, nfc->reg_base + NFC_REG_CMD); > + } > + break; > + > + case NAND_OP_DATA_IN_INSTR: > + meson_nfc_read_buf(mtd, instr->ctx.data.buf.in, > + instr->ctx.data.len); > + break; > + > + case NAND_OP_DATA_OUT_INSTR: > + meson_nfc_write_buf(mtd, instr->ctx.data.buf.out, > + instr->ctx.data.len); > + break; > + > + case NAND_OP_WAITRDY_INSTR: > + meson_nfc_queue_rb(nfc, instr->ctx.waitrdy.timeout_ms); > + break; > + } > + } > + return ret; > +}