Patchwork MTD: Add fixup for S29NS512P NOR flash.

login
register
mail settings
Submitter Javier Martin
Date May 11, 2012, 10:15 a.m.
Message ID <1336731341-615-1-git-send-email-javier.martin@vista-silicon.com>
Download mbox | patch
Permalink /patch/158483/
State New
Headers show

Comments

Javier Martin - May 11, 2012, 10:15 a.m.
Spansion S29NS512P flash uses a 16bit transfer to report number
of sectors instead of two 8bit accesses as CFI specifies.

Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
---
 drivers/mtd/chips/cfi_cmdset_0002.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
Artem Bityutskiy - May 12, 2012, 2:01 p.m.
On Fri, 2012-05-11 at 12:15 +0200, Javier Martin wrote:
> Spansion S29NS512P flash uses a 16bit transfer to report number
> of sectors instead of two 8bit accesses as CFI specifies.
> 
> Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
> ---
>  drivers/mtd/chips/cfi_cmdset_0002.c |   14 ++++++++++++++
>  1 files changed, 14 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
> index 23175ed..5873b1f 100644
> --- a/drivers/mtd/chips/cfi_cmdset_0002.c
> +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
> @@ -332,6 +332,19 @@ static void fixup_s29gl032n_sectors(struct mtd_info *mtd)
>  	}
>  }
>  
> +static void fixup_s29ns512p_sectors(struct mtd_info *mtd)
> +{
> +	struct map_info *map = mtd->priv;
> +	struct cfi_private *cfi = map->fldrv_priv;
> +
> +	/*
> +	 *  S29NS512P flash uses more than 8bits to report number of sectors,
> +	 * which is not permitted by CFI.
> +	 */
> +	cfi->cfiq->EraseRegionInfo[0] = 0x020001ff;
> +	pr_warning("%s: Bad S29NS512P CFI data, adjust to 512 sectors\n", mtd->name);

What is the purpose of printing this warning - how the user should act
upon it? If you successfully work-around a known HW issue, you should
not warn. HW workarounds are normal.
Artem Bityutskiy - May 13, 2012, 6:18 p.m.
On Fri, 2012-05-11 at 12:15 +0200, Javier Martin wrote:
> +	/*
> +	 *  S29NS512P flash uses more than 8bits to report number of sectors,
> +	 * which is not permitted by CFI.
> +	 */
> +	cfi->cfiq->EraseRegionInfo[0] = 0x020001ff;
> +	pr_warning("%s: Bad S29NS512P CFI data, adjust to 512 sectors\n", mtd->name);

I've removed the warning and pushed to l2-mtd.git, thanks! If you
disagree - please complain.
Javier Martin - May 14, 2012, 8:06 a.m.
On 13 May 2012 20:18, Artem Bityutskiy <dedekind1@gmail.com> wrote:
> On Fri, 2012-05-11 at 12:15 +0200, Javier Martin wrote:
>> +     /*
>> +      *  S29NS512P flash uses more than 8bits to report number of sectors,
>> +      * which is not permitted by CFI.
>> +      */
>> +     cfi->cfiq->EraseRegionInfo[0] = 0x020001ff;
>> +     pr_warning("%s: Bad S29NS512P CFI data, adjust to 512 sectors\n", mtd->name);
>
> I've removed the warning and pushed to l2-mtd.git, thanks! If you
> disagree - please complain.

Great, I totally agree.

Thanks.

Patch

diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index 23175ed..5873b1f 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -332,6 +332,19 @@  static void fixup_s29gl032n_sectors(struct mtd_info *mtd)
 	}
 }
 
+static void fixup_s29ns512p_sectors(struct mtd_info *mtd)
+{
+	struct map_info *map = mtd->priv;
+	struct cfi_private *cfi = map->fldrv_priv;
+
+	/*
+	 *  S29NS512P flash uses more than 8bits to report number of sectors,
+	 * which is not permitted by CFI.
+	 */
+	cfi->cfiq->EraseRegionInfo[0] = 0x020001ff;
+	pr_warning("%s: Bad S29NS512P CFI data, adjust to 512 sectors\n", mtd->name);
+}
+
 /* Used to fix CFI-Tables of chips without Extended Query Tables */
 static struct cfi_fixup cfi_nopri_fixup_table[] = {
 	{ CFI_MFR_SST, 0x234a, fixup_sst39vf }, /* SST39VF1602 */
@@ -362,6 +375,7 @@  static struct cfi_fixup cfi_fixup_table[] = {
 	{ CFI_MFR_AMD, 0x1301, fixup_s29gl064n_sectors },
 	{ CFI_MFR_AMD, 0x1a00, fixup_s29gl032n_sectors },
 	{ CFI_MFR_AMD, 0x1a01, fixup_s29gl032n_sectors },
+	{ CFI_MFR_AMD, 0x3f00, fixup_s29ns512p_sectors },
 	{ CFI_MFR_SST, 0x536a, fixup_sst38vf640x_sectorsize }, /* SST38VF6402 */
 	{ CFI_MFR_SST, 0x536b, fixup_sst38vf640x_sectorsize }, /* SST38VF6401 */
 	{ CFI_MFR_SST, 0x536c, fixup_sst38vf640x_sectorsize }, /* SST38VF6404 */