From: Abhishek Sahu <absahu@codeaurora.org>
To: Archit Taneja <architt@codeaurora.org>
Cc: dwmw2@infradead.org, computersforpeace@gmail.com,
boris.brezillon@free-electrons.com, marek.vasut@gmail.com,
richard@nod.at, cyrille.pitchen@wedev4u.fr, robh+dt@kernel.org,
mark.rutland@arm.com, linux-mtd@lists.infradead.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-msm@vger.kernel.org, andy.gross@linaro.org,
sricharan@codeaurora.org
Subject: Re: [PATCH 09/14] qcom: mtd: nand: BAM support for read page
Date: Mon, 17 Jul 2017 12:47:07 +0530 [thread overview]
Message-ID: <53fd2482d3f8f6d965910fc1a711751a@codeaurora.org> (raw)
In-Reply-To: <ddf2e1c0-e08e-c8b8-2b10-ef39ce1482b2@codeaurora.org>
On 2017-07-04 15:10, Archit Taneja wrote:
> On 06/29/2017 12:46 PM, Abhishek Sahu wrote:
>> 1. The BAM mode requires few registers configuration before each
>> NAND page read and codeword read which is different from ADM
>> so add the helper functions which will be called in BAM mode
>> only.
>>
>> 2. The NAND page read handling of BAM is different from ADM so
>> call the appropriate helper functions
>>
>> Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
>> ---
>> drivers/mtd/nand/qcom_nandc.c | 63
>> ++++++++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 62 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mtd/nand/qcom_nandc.c
>> b/drivers/mtd/nand/qcom_nandc.c
>> index 8e7dc9e..17766af 100644
>> --- a/drivers/mtd/nand/qcom_nandc.c
>> +++ b/drivers/mtd/nand/qcom_nandc.c
>> @@ -870,6 +870,35 @@ static void config_cw_read(struct
>> qcom_nand_controller *nandc)
>> }
>>
>> /*
>> + * Helpers to prepare DMA descriptors for configuring registers
>> + * before reading a NAND page with BAM.
>> + */
>> +static void config_bam_page_read(struct qcom_nand_controller *nandc)
>> +{
>> + write_reg_dma(nandc, NAND_FLASH_CMD, 3, 0);
>> + write_reg_dma(nandc, NAND_DEV0_CFG0, 3, 0);
>> + write_reg_dma(nandc, NAND_EBI2_ECC_BUF_CFG, 1, 0);
>> + write_reg_dma(nandc, NAND_ERASED_CW_DETECT_CFG, 1, 0);
>> + write_reg_dma(nandc, NAND_ERASED_CW_DETECT_CFG, 1,
>> + NAND_ERASED_CW_SET | NAND_BAM_NEXT_SGL);
>> +}
>> +
>> +/*
>> + * Helpers to prepare DMA descriptors for configuring registers
>> + * before reading each codeword in NAND page with BAM.
>> + */
>
> If I understood right, EBI2 nand required us to load all the registers
> configured in config_cw_read() for every codeword, and for BAM, the
> registers configured in config_bam_page_read() just needs to be done
> once,
> and the registers in config_bam_cw_read() need to be reloaded for
> every
> codeword?
>
> Could you please clarify this better in the commit message and
> comments? Also,
> I still see config_cw_read() being used for QPIC nand in nandc_param()
> and
> copy_last_cw()?
>
> Also, I think these should be called config_qpic_page_read() and
> config_qpic_cw_read() since it seems more of a property of the NAND
> controller
> rather than the underlying DMA engine. If so, config_cw_read() can be
> called
> config_cw_ebi2_read(). Please correct me if I'm wrong somewhere.
>
I did some code reorganization in v2 in this area and now, we don't
have do different things for EBI2 and QPIC for read.
>> +static void config_bam_cw_read(struct qcom_nand_controller *nandc)
>> +{
>> + write_reg_dma(nandc, NAND_READ_LOCATION_0, 2, 0);
>> + write_reg_dma(nandc, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL);
>> + write_reg_dma(nandc, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL);
>> +
>> + read_reg_dma(nandc, NAND_FLASH_STATUS, 2, 0);
>> + read_reg_dma(nandc, NAND_ERASED_CW_DETECT_STATUS, 1,
>> + NAND_BAM_NEXT_SGL);
>> +}
>> +
>> +/*
>> * helpers to prepare dma descriptors used to configure registers
>> needed for
>> * writing a codeword/step in a page
>> */
>> @@ -1398,6 +1427,9 @@ static int read_page_ecc(struct qcom_nand_host
>> *host, u8 *data_buf,
>> struct nand_ecc_ctrl *ecc = &chip->ecc;
>> int i, ret;
>>
>> + if (nandc->dma_bam_enabled)
>> + config_bam_page_read(nandc);
>> +
>> /* queue cmd descs for each codeword */
>> for (i = 0; i < ecc->steps; i++) {
>> int data_size, oob_size;
>> @@ -1411,7 +1443,36 @@ static int read_page_ecc(struct qcom_nand_host
>> *host, u8 *data_buf,
>> oob_size = host->ecc_bytes_hw + host->spare_bytes;
>> }
>>
>> - config_cw_read(nandc);
>> + if (nandc->dma_bam_enabled) {
>> + if (data_buf && oob_buf) {
>> + nandc_set_reg(nandc, NAND_READ_LOCATION_0,
>> + (0 << READ_LOCATION_OFFSET) |
>> + (data_size <<
>> + READ_LOCATION_SIZE) |
>> + (0 << READ_LOCATION_LAST));
>> + nandc_set_reg(nandc, NAND_READ_LOCATION_1,
>> + (data_size <<
>> + READ_LOCATION_OFFSET) |
>> + (oob_size << READ_LOCATION_SIZE) |
>> + (1 << READ_LOCATION_LAST));
>> + } else if (data_buf) {
>> + nandc_set_reg(nandc, NAND_READ_LOCATION_0,
>> + (0 << READ_LOCATION_OFFSET) |
>> + (data_size <<
>> + READ_LOCATION_SIZE) |
>> + (1 << READ_LOCATION_LAST));
>> + } else {
>> + nandc_set_reg(nandc, NAND_READ_LOCATION_0,
>> + (data_size <<
>> + READ_LOCATION_OFFSET) |
>> + (oob_size << READ_LOCATION_SIZE) |
>> + (1 << READ_LOCATION_LAST));
>> + }
>
> Could we put the READ_LOCATION_x register configuration into a small
> helper?
> This is probably a matter of taste, but you could consider configuring
> like this.
> Maybe something similar for patch #11 for raw page reads.
>
I will use macro for assigning READ LOCATION registers in v2,
which makes the code cleaner. If required, I will use helpers
also.
> if (data_buf && oob_buf) {
> r0_off = 0;
> r0_size = r1_off = data_size;
> r1_size = oob_size;
> r0_last = 0;
> r1_last = 1;
> } else if (data_buf) {
> rl0_off = 0;
> rl0_size = data_size;
> rl0_last = 1;
> } else {
> rl0_off = data_size;
> rl0_size = oob_size;
> rl0_last = 1;
> }
>
> nandc_set_reg(nandc, NAND_READ_LOCATION_0,
> (rl0_off << READ_LOCATION_OFFSET) |
> (rl0_size << READ_LOCATION_SIZE) |
> (rl0_last << READ_LOCATION_LAST));
> if (rl1_last)
> /* program LOCATION_1 register */
>
> Thanks,
> Archit
>
>> +
>> + config_bam_cw_read(nandc);
>> + } else {
>> + config_cw_read(nandc);
>> + }
>>
>> if (data_buf)
>> read_data_dma(nandc, FLASH_BUF_ACC, data_buf,
>>
--
Abhishek Sahu
next prev parent reply other threads:[~2017-07-17 7:17 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-29 7:15 [PATCH 00/14] Add QCOM QPIC NAND support Abhishek Sahu
2017-06-29 7:15 ` [PATCH 01/14] qcom: mtd: nand: Add driver data for QPIC DMA Abhishek Sahu
2017-06-29 9:46 ` Marek Vasut
2017-07-03 4:38 ` Archit Taneja
2017-07-03 19:41 ` Boris Brezillon
2017-07-17 6:11 ` Abhishek Sahu
2017-07-17 7:22 ` Boris Brezillon
2017-07-17 8:49 ` Abhishek Sahu
2017-07-03 6:21 ` Sricharan R
2017-06-29 7:15 ` [PATCH 02/14] qcom: mtd: nand: add and initialize QPIC DMA resources Abhishek Sahu
2017-06-29 9:48 ` Marek Vasut
2017-07-17 6:36 ` Abhishek Sahu
2017-07-03 5:17 ` Archit Taneja
2017-07-17 6:26 ` Abhishek Sahu
2017-07-03 6:24 ` Sricharan R
2017-07-03 6:32 ` Sricharan R
2017-06-29 7:15 ` [PATCH 03/14] qcom: mtd: nand: Fixed config error for BCH Abhishek Sahu
2017-06-29 9:49 ` Marek Vasut
2017-07-03 19:47 ` Boris Brezillon
2017-07-17 6:38 ` Abhishek Sahu
2017-07-03 6:25 ` Sricharan R
2017-06-29 7:15 ` [PATCH 04/14] qcom: mtd: nand: reorganize nand devices probing Abhishek Sahu
2017-06-29 7:15 ` [PATCH 05/14] qcom: mtd: nand: allocate bam transaction Abhishek Sahu
2017-06-29 9:50 ` Marek Vasut
2017-07-17 6:42 ` Abhishek Sahu
2017-07-03 8:22 ` Sricharan R
2017-07-17 6:44 ` Abhishek Sahu
2017-06-29 7:15 ` [PATCH 06/14] qcom: mtd: nand: add bam dma descriptor handling Abhishek Sahu
2017-07-04 6:10 ` Archit Taneja
2017-07-17 6:47 ` Abhishek Sahu
2017-06-29 7:15 ` [PATCH 07/14] qcom: mtd: nand: support for passing flags in transfer functions Abhishek Sahu
2017-06-29 9:52 ` Marek Vasut
2017-07-04 6:49 ` Archit Taneja
2017-07-10 14:10 ` Sricharan R
2017-07-17 6:59 ` Abhishek Sahu
2017-06-29 7:16 ` [PATCH 08/14] qcom: mtd: nand: Add support for additional CSRs Abhishek Sahu
2017-07-04 6:54 ` Archit Taneja
2017-07-17 7:10 ` Abhishek Sahu
2017-06-29 7:16 ` [PATCH 09/14] qcom: mtd: nand: BAM support for read page Abhishek Sahu
2017-07-04 9:40 ` Archit Taneja
2017-07-10 14:15 ` Sricharan R
2017-07-17 7:17 ` Abhishek Sahu [this message]
2017-06-29 7:16 ` [PATCH 10/14] qcom: mtd: nand: support for QPIC Page read/write Abhishek Sahu
2017-07-04 9:44 ` Archit Taneja
2017-07-17 7:25 ` Abhishek Sahu
2017-07-10 14:18 ` Sricharan R
2017-07-17 7:36 ` Abhishek Sahu
2017-06-29 7:16 ` [PATCH 11/14] qcom: mtd: nand: BAM raw read and write support Abhishek Sahu
2017-06-29 7:16 ` [PATCH 12/14] qcom: mtd: nand: change register offset defines with enums Abhishek Sahu
2017-07-04 9:55 ` Archit Taneja
2017-07-17 7:31 ` Abhishek Sahu
2017-06-29 7:16 ` [PATCH 13/14] qcom: mtd: nand: support for QPIC version 1.5.0 Abhishek Sahu
2017-07-04 9:57 ` Archit Taneja
2017-07-17 7:32 ` Abhishek Sahu
2017-06-29 7:16 ` [PATCH 14/14] qcom: mtd: nand: programmed NAND_DEV_CMD_VLD register Abhishek Sahu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53fd2482d3f8f6d965910fc1a711751a@codeaurora.org \
--to=absahu@codeaurora.org \
--cc=andy.gross@linaro.org \
--cc=architt@codeaurora.org \
--cc=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=cyrille.pitchen@wedev4u.fr \
--cc=devicetree@vger.kernel.org \
--cc=dwmw2@infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=mark.rutland@arm.com \
--cc=richard@nod.at \
--cc=robh+dt@kernel.org \
--cc=sricharan@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).