linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: josh.wu@atmel.com (Josh Wu)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v11 2/4] MTD: at91: add dt parameters for Atmel PMECC
Date: Tue, 26 Jun 2012 14:05:10 +0800	[thread overview]
Message-ID: <4FE95116.7080503@atmel.com> (raw)
In-Reply-To: <CACQ1gAgg4VREYPuZU1J+CkSRcypXdtqGvU-DiyJ=bTjb-3fRKQ@mail.gmail.com>

On 6/25/2012 6:35 PM, Richard Genoud wrote:
> 2012/6/25 Josh Wu <josh.wu@atmel.com>:
>> Add DT support for PMECC parameters.
>>
>> Signed-off-by: Hong Xu <hong.xu@atmel.com>
>> Signed-off-by: Josh Wu <josh.wu@atmel.com>
>> ---
>>   .../devicetree/bindings/mtd/atmel-nand.txt         |    9 ++++
>>   drivers/mtd/nand/atmel_nand.c                      |   52 +++++++++++++++++++-
>>   2 files changed, 60 insertions(+), 1 deletion(-)
>>
>> diff --git a/Documentation/devicetree/bindings/mtd/atmel-nand.txt b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
>> index a200695..ed6927a 100644
>> --- a/Documentation/devicetree/bindings/mtd/atmel-nand.txt
>> +++ b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
>> @@ -16,6 +16,15 @@ Optional properties:
>>   - nand-ecc-mode : String, operation mode of the NAND ecc mode, soft by default.
>>    Supported values are: "none", "soft", "hw", "hw_syndrome", "hw_oob_first",
>>    "soft_bch".
>> +- atmel,has-pmecc : boolean to enable Programmable Multibit ECC hardware.
>> +  Only supported by at91sam9x5 or later sam9 product.
>> +- atmel,pmecc-cap : error correct capability for Programmable Multibit ECC
>> +  Controller. Supported values are: 2, 4, 8, 12, 24.
>> +- atmel,pmecc-sector-size : sector size for ECC computation. Supported values
>> +  are: 512, 1024.
>> +- atmel,pmecc-lookup-table-offset : includes two offsets of lookup table in ROM
>> +  for different sector size. First one is for sector size 512, the next is for
>> +  sector size 1024.
>>   - nand-bus-width : 8 or 16 bus width if not present 8
>>   - nand-on-flash-bbt: boolean to enable on flash bbt option if not present false
>>
> Maybe you should update the reg parameter documentation with the
> needed resources.
>

I will update the reg parameter documentation and add one example for 
PMECC setting. thanks.

>> diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
>> index 7a41a04..b97ad9f 100644
>> --- a/drivers/mtd/nand/atmel_nand.c
>> +++ b/drivers/mtd/nand/atmel_nand.c
>> @@ -93,6 +93,11 @@ struct atmel_nand_host {
>>
>>         struct completion       comp;
>>         struct dma_chan         *dma_chan;
>> +
>> +       bool                    has_pmecc;
>> +       u8                      pmecc_corr_cap;
>> +       u16                     pmecc_sector_size;
>> +       u32                     pmecc_lookup_table_offset;
>>   };
>>
>>   static int cpu_has_dma(void)
>> @@ -481,7 +486,8 @@ static void atmel_nand_hwctl(struct mtd_info *mtd, int mode)
>>   static int __devinit atmel_of_init_port(struct atmel_nand_host *host,
>>                                          struct device_node *np)
>>   {
>> -       u32 val;
>> +       u32 val, table_offset;
>> +       u32 offset[2];
>>         int ecc_mode;
>>         struct atmel_nand_data *board = &host->board;
>>         enum of_gpio_flags flags;
>> @@ -517,6 +523,50 @@ static int __devinit atmel_of_init_port(struct atmel_nand_host *host,
>>         board->enable_pin = of_get_gpio(np, 1);
>>         board->det_pin = of_get_gpio(np, 2);
>>
>> +       host->has_pmecc = of_property_read_bool(np, "atmel,has-pmecc");
>> +
>> +       if (!(board->ecc_mode == NAND_ECC_HW) || !host->has_pmecc)
>> +               return 0;       /* Not using PMECC */
>> +
>> +       /* use PMECC, get correction capability, sector size and lookup
>> +        * table offset.
>> +        */
>> +       if (of_property_read_u32(np, "atmel,pmecc-cap", &val) != 0) {
>> +               dev_err(host->dev, "Cannot decide PMECC Capability\n");
>> +               return -EINVAL;
>> +       } else if ((val != 2) && (val != 4) && (val != 8) && (val != 12) &&
>> +           (val != 24)) {
>> +               dev_err(host->dev,
>> +                       "Unsupported PMECC correction capability: %d; should be 2, 4, 8, 12 or 24\n",
>> +                       val);
>> +               return -EINVAL;
>> +       }
>> +       host->pmecc_corr_cap = (u8)val;
>> +
>> +       if (of_property_read_u32(np, "atmel,pmecc-sector-size", &val) != 0) {
>> +               dev_err(host->dev, "Cannot decide PMECC Sector Size\n");
>> +               return -EINVAL;
>> +       } else if ((val != 512) && (val != 1024)) {
>> +               dev_err(host->dev,
>> +                       "Unsupported PMECC sector size: %d; should be 512 or 1024 bytes\n",
>> +                       val);
>> +               return -EINVAL;
>> +       }
>> +       host->pmecc_sector_size = (u16)val;
>> +
>> +       if (of_property_read_u32_array(np, "atmel,pmecc-lookup-table-offset",
>> +                       offset, 2) != 0) {
>> +               dev_err(host->dev, "Cannot get PMECC lookup table offset\n");
>> +               return -EINVAL;
>> +       }
>> +       table_offset = host->pmecc_sector_size == 512 ? offset[0] : offset[1];
>> +
>> +       if (!table_offset) {
>> +               dev_err(host->dev, "Invalid PMECC lookup table offset\n");
>> +               return -EINVAL;
>> +       }
>> +       host->pmecc_lookup_table_offset = table_offset;
>> +
>>         return 0;
>>   }
>>   #else
>> --
>> 1.7.9.5
>>
>>
>> ______________________________________________________
>> Linux MTD discussion mailing list
>> http://lists.infradead.org/mailman/listinfo/linux-mtd/
> Richard.
>

Best Regards,
Josh Wu

  reply	other threads:[~2012-06-26  6:05 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-25 10:07 [PATCH v11 0/4] MTD: at91: Add PMECC support for at91 nand flash driver Josh Wu
2012-06-25 10:07 ` [PATCH v11 1/4] MTD: at91: extract hw ecc initialization to one function Josh Wu
2012-06-27  9:26   ` Artem Bityutskiy
2012-06-25 10:07 ` [PATCH v11 2/4] MTD: at91: add dt parameters for Atmel PMECC Josh Wu
2012-06-25 10:35   ` Richard Genoud
2012-06-26  6:05     ` Josh Wu [this message]
2012-06-25 10:07 ` [PATCH v11 3/4] MTD: nand: add return value for write_page()/write_page_raw() functions in structure of nand_ecc_ctrl Josh Wu
2012-06-27  9:26   ` Artem Bityutskiy
2012-06-25 10:07 ` [PATCH v11 4/4] MTD: at91: atmel_nand: Update driver to support Programmable Multibit ECC controller Josh Wu
2012-06-25 10:27   ` Richard Genoud
2012-06-26  6:03     ` Josh Wu
2012-06-26 14:15   ` Richard Genoud
2012-06-26 14:37     ` [PATCH v11 4/4] MTD: at91: atmel_nand: Update driver to support Programmable Multibit ECC controller (REPORT SPAM) William F.
2012-06-27 11:22     ` [PATCH v11 4/4] MTD: at91: atmel_nand: Update driver to support Programmable Multibit ECC controller Josh Wu
2012-06-27  3:45 ` [PATCH v11 0/4] MTD: at91: Add PMECC support for at91 nand flash driver Artem Bityutskiy
2012-06-27  3:49 ` Artem Bityutskiy
2012-06-27  4:11   ` Josh Wu
2012-06-27  4:28     ` Artem Bityutskiy
2012-06-27  5:34       ` Josh Wu
2012-06-27  8:39       ` Nicolas Ferre
2012-06-27  9:14         ` Artem Bityutskiy
2012-06-27  9:28 ` Artem Bityutskiy

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=4FE95116.7080503@atmel.com \
    --to=josh.wu@atmel.com \
    --cc=linux-arm-kernel@lists.infradead.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).