Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2665115pxb; Tue, 23 Feb 2021 12:22:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJxpdzId/Z5ciO2dNFK6HkPP01ftjMZX2xMrgSxU5gSveNEpgWtZFEpzzTzmpUAAjcXTNiu2 X-Received: by 2002:a17:906:584e:: with SMTP id h14mr11569909ejs.332.1614111758857; Tue, 23 Feb 2021 12:22:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614111758; cv=none; d=google.com; s=arc-20160816; b=df04U0gX+iImgNAbGpgNNa1UqxnJVrUjb542mQoMKDCIHjphcEQwNENk+W3cl9WrWa fJp7mi1NmkkIksizuMumR9J6IulwXFc+lUxi3tX4mXNRXVEzRFBaqpIAaeVmvoa6azaw VUesiA9XWMzPZQC2OXgA9JCioTdS2TnNyFfUgE5ClYTwUgQXCxssEyP0ZOApzwREbajT uYNuZpwsl7NEAvMIqJVpJulueJqchGSynp1tgyQrMtvYXggSV9Mf/0LNdhxoD1xqYuLe FwxnzHow7bQPyos16LLuG+olbr9oWgMunnmterYlWix873RsW27f1ZMGPmxydvBYYjxe CKig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=0ljcB+1Jk59sN2TSBYgfD7ttqQzvB45vS4juIhLaIlU=; b=h9LIetWAbjj/xB3H5KTrDmtyqHlDFkUtskWj9m0xqj4QE5YW5snnBvipFqzxntStt/ rgFmGv16UobZXrPUXnJ0oXv+N6ZBUmEkLbBI4eSZAnJJm+UcoGoGUBXqD5AXylHEc+3e JpcN1ZheIPiuGjJcYk686ZwQto5aLIg9G6Q2MTLPhAah25Zw1Ju7U+sKvqTXuTsaj58a 5P+2lAI2uki/dQHJJJAqucqIZRWbr5kwGwJom0pb6rSafaCB2tRKXL+kEoLDy0TaaIA7 a6z0FZnuqOL/yAl2hvldNwj62hjRH4J/BVL1OGqqnAgiUDINUhRQVn5/A+i4OHguWCAd cw9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gv50si11095074ejc.145.2021.02.23.12.22.15; Tue, 23 Feb 2021 12:22:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233561AbhBWQVm convert rfc822-to-8bit (ORCPT + 99 others); Tue, 23 Feb 2021 11:21:42 -0500 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:14497 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232733AbhBWQVm (ORCPT ); Tue, 23 Feb 2021 11:21:42 -0500 X-Originating-IP: 86.210.203.113 Received: from xps13 (lfbn-tou-1-972-113.w86-210.abo.wanadoo.fr [86.210.203.113]) (Authenticated sender: miquel.raynal@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id D7200240008; Tue, 23 Feb 2021 16:20:56 +0000 (UTC) Date: Tue, 23 Feb 2021 17:20:55 +0100 From: Miquel Raynal To: Md Sadre Alam Cc: mani@kernel.org, boris.brezillon@collabora.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, sricharan@codeaurora.org Subject: Re: [PATCH] mtd: rawnand: qcom: Add helper to configure location register Message-ID: <20210223172055.54eba1ad@xps13> In-Reply-To: <1614006343-5947-1-git-send-email-mdalam@codeaurora.org> References: <1614006343-5947-1-git-send-email-mdalam@codeaurora.org> Organization: Bootlin X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Md Sadre Alam wrote on Mon, 22 Feb 2021 20:35:43 +0530: > This change will add helper nandc_set_read_loc() to configure > location register value. QPIC V2 on wards there is separate > location register to read the last code word. This helper > will use to configure location register for last code word > as well. > " Create a nandc_set_read_loc() helper to abstract the configuration of the location register. QPIC v2 onwards features a separate location register for the last codeword, so introducing this extra helper will simplify the addition of QPIC v2 support. " > Signed-off-by: Md Sadre Alam > --- > drivers/mtd/nand/raw/qcom_nandc.c | 38 ++++++++++++++++++++++++++------------ > 1 file changed, 26 insertions(+), 12 deletions(-) > > diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c > index bfefb4e..82d083ad 100644 > --- a/drivers/mtd/nand/raw/qcom_nandc.c > +++ b/drivers/mtd/nand/raw/qcom_nandc.c > @@ -181,8 +181,8 @@ > #define ECC_BCH_4BIT BIT(2) > #define ECC_BCH_8BIT BIT(3) > > -#define nandc_set_read_loc(nandc, reg, cw_offset, read_size, is_last_read_loc) \ > -nandc_set_reg(nandc, NAND_READ_LOCATION_##reg, \ > +#define nandc_set_read_loc_first(nandc, reg, cw_offset, read_size, is_last_read_loc) \ Please do the s/nandc/chip/ renaming in patch 1. > +nandc_set_reg(nandc, reg, \ > ((cw_offset) << READ_LOCATION_OFFSET) | \ > ((read_size) << READ_LOCATION_SIZE) | \ > ((is_last_read_loc) << READ_LOCATION_LAST)) > @@ -667,6 +667,20 @@ static bool qcom_nandc_is_last_cw(struct nand_ecc_ctrl *ecc, int cw) > return cw == (ecc->steps - 1); > } > > +/* helper to configure location register values */ > +static void nandc_set_read_loc(struct nand_chip *chip, int cw, int reg, > + int cw_offset, int read_size, int is_last_read_loc) > +{ > + struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); > + > + int reg_base = NAND_READ_LOCATION_0; > + > + reg_base += reg * 4; > + > + return nandc_set_read_loc_first(nandc, reg_base, cw_offset, > + read_size, is_last_read_loc); > +} > + > /* helper to configure address register values */ > static void set_address(struct qcom_nand_host *host, u16 column, int page) > { > @@ -726,7 +740,7 @@ static void update_rw_regs(struct qcom_nand_host *host, int num_cw, bool read) > nandc_set_reg(nandc, NAND_EXEC_CMD, 1); > > if (read) > - nandc_set_read_loc(nandc, 0, 0, host->use_ecc ? > + nandc_set_read_loc(chip, 0, 0, 0, host->use_ecc ? > host->cw_data : host->cw_size, 1); > } > > @@ -1221,7 +1235,7 @@ static int nandc_param(struct qcom_nand_host *host) > nandc_set_reg(nandc, NAND_DEV_CMD_VLD_RESTORE, nandc->vld); > } > > - nandc_set_read_loc(nandc, 0, 0, 512, 1); > + nandc_set_read_loc(chip, 0, 0, 0, 512, 1); > > if (!nandc->props->qpic_v2) { > write_reg_dma(nandc, NAND_DEV_CMD_VLD, 1, 0); > @@ -1649,16 +1663,16 @@ qcom_nandc_read_cw_raw(struct mtd_info *mtd, struct nand_chip *chip, > } > > if (nandc->props->is_bam) { > - nandc_set_read_loc(nandc, 0, read_loc, data_size1, 0); > + nandc_set_read_loc(chip, cw, 0, read_loc, data_size1, 0); > read_loc += data_size1; > > - nandc_set_read_loc(nandc, 1, read_loc, oob_size1, 0); > + nandc_set_read_loc(chip, cw, 1, read_loc, oob_size1, 0); > read_loc += oob_size1; > > - nandc_set_read_loc(nandc, 2, read_loc, data_size2, 0); > + nandc_set_read_loc(chip, cw, 2, read_loc, data_size2, 0); > read_loc += data_size2; > > - nandc_set_read_loc(nandc, 3, read_loc, oob_size2, 1); > + nandc_set_read_loc(chip, cw, 3, read_loc, oob_size2, 1); > } > > config_nand_cw_read(chip, false); > @@ -1889,13 +1903,13 @@ static int read_page_ecc(struct qcom_nand_host *host, u8 *data_buf, > > if (nandc->props->is_bam) { > if (data_buf && oob_buf) { > - nandc_set_read_loc(nandc, 0, 0, data_size, 0); > - nandc_set_read_loc(nandc, 1, data_size, > + nandc_set_read_loc(chip, i, 0, 0, data_size, 0); > + nandc_set_read_loc(chip, i, 1, data_size, > oob_size, 1); > } else if (data_buf) { > - nandc_set_read_loc(nandc, 0, 0, data_size, 1); > + nandc_set_read_loc(chip, i, 0, 0, data_size, 1); > } else { > - nandc_set_read_loc(nandc, 0, data_size, > + nandc_set_read_loc(chip, i, 0, data_size, > oob_size, 1); > } > } Thanks, Miquèl