Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753932AbbHSM2f (ORCPT ); Wed, 19 Aug 2015 08:28:35 -0400 Received: from mail-bl2on0129.outbound.protection.outlook.com ([65.55.169.129]:3488 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751599AbbHSM2e (ORCPT ); Wed, 19 Aug 2015 08:28:34 -0400 X-Greylist: delayed 953 seconds by postgrey-1.27 at vger.kernel.org; Wed, 19 Aug 2015 08:28:34 EDT From: Hou Zhiqiang To: Jagan Teki , "linux-mtd@lists.infradead.org" CC: "linux-kernel@vger.kernel.org" , Hu Vincent , David Woodhouse , "Brian Norris" Subject: RE: [PATCH 3/3] mtd: spi-nor: sf: Add clear flag status register support Thread-Topic: [PATCH 3/3] mtd: spi-nor: sf: Add clear flag status register support Thread-Index: AQHQ2mVu+Ryhtelg0kmPXBqow87Pvp4TOZMA Date: Wed, 19 Aug 2015 12:12:38 +0000 Message-ID: References: <1439978205-6092-1-git-send-email-jteki@openedev.com> <1439978205-6092-3-git-send-email-jteki@openedev.com> In-Reply-To: <1439978205-6092-3-git-send-email-jteki@openedev.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=B48286@freescale.com; x-originating-ip: [123.151.195.51] x-microsoft-exchange-diagnostics: 1;CY1PR0301MB1260;5:Jt5v3ArKSdX4PFwFR/0eahSoHmPy5dnaoLJXUA/aLoKO4F8JyWYfXvgmaKz0rjeIgNvbaKc15ddJI5T48yPOk47LjBFib5Q9jSZetKMxIWvMa0OIHWxIck+Vu3xbGQl97MVhrXaFUZbTrE0dWP0Rhw==;24:eAlO+ywB3buD+IHUDi1UwklmmXkKVncVHVJId3A+frc+qZwuKaigKuLvOK03DKLwiMzD1y5uW5frDmkBW7Bpe4ZrlSFfFODV7KyB9Vwo9ik=;20:kkQJ8oUshEMOr2MiKt/0nYaQpxolaDd7Z1YWfCrDW8dC9IKbmwGkVbftEpddVldCXjdgfbShLEYrurSs+ZRDVA== x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1260; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(5005006)(8121501046)(3002001);SRVR:CY1PR0301MB1260;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1260; x-forefront-prvs: 0673F5BE31 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(189002)(13464003)(164054003)(199003)(5001770100001)(5001830100001)(5001860100001)(87936001)(62966003)(5003600100002)(64706001)(74316001)(77156002)(76576001)(189998001)(5002640100001)(97736004)(2501003)(2656002)(122556002)(102836002)(66066001)(101416001)(46102003)(33656002)(2900100001)(76176999)(77096005)(10400500002)(50986999)(2950100001)(4001540100001)(86362001)(106356001)(40100003)(81156007)(54356999)(5001960100002)(105586002)(106116001)(99286002)(92566002)(68736005)(19580405001)(19580395003)(575784001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0301MB1260;H:CY1PR0301MB0780.namprd03.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Content-Type: text/plain; charset="gb2312" MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Aug 2015 12:12:38.4003 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1260 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id t7JCSecS021301 Content-Length: 4114 Lines: 116 Hi Jagan, > -----Original Message----- > From: Jagan Teki [mailto:jteki@openedev.com] > Sent: 2015??8??19?? 17:57 > To: linux-mtd@lists.infradead.org > Cc: linux-kernel@vger.kernel.org; Jagan Teki; Hou Zhiqiang-B48286; Hu > Mingkai-B21284; David Woodhouse; Brian Norris > Subject: [PATCH 3/3] mtd: spi-nor: sf: Add clear flag status register > support > > The clear flag status register operation was required by Micron SPI-NOR > chips, which support FSR. And if an error bit of FSR have been set like > protection, voltage, erase, and program, it must be cleared by the clear > FSR operation. > > Signed-off-by: Jagan Teki > Cc: Hou Zhiqiang > Cc: Mingkai.Hu > Cc: David Woodhouse > Cc: Brian Norris > --- > drivers/mtd/spi-nor/spi-nor.c | 35 +++++++++++++++++++++++++++++++---- > include/linux/mtd/spi-nor.h | 9 +++++++++ > 2 files changed, 40 insertions(+), 4 deletions(-) > > diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi- > nor.c index f954d03..c5c472d5 100644 > --- a/drivers/mtd/spi-nor/spi-nor.c > +++ b/drivers/mtd/spi-nor/spi-nor.c > @@ -100,6 +100,28 @@ static int read_fsr(struct spi_nor *nor) } > > /* > + * Read the clear flag status register. > + * The clear flag status register operation was required by Micron > + * SPI-NOR chips, which support FSR. And if an error bit of FSR > + * have been set like protection, voltage, erase, and program, > + * it must be cleared by the clear FSR operation. > + * Returns zero for FSR bits cleared and negative if error occurred. > + */ > +static int read_cfsr(struct spi_nor *nor) { > + int ret; > + u8 val; > + > + ret = nor->read_reg(nor, SPINOR_OP_RDCFSR, &val, 1); There should be a write_reg instead of read_reg. There isn??t a register named CFSR, and the command SPINOR_OP_RDCFSR is used to clear the FSR, another words reset FSR to default value. > + if (ret < 0) { > + pr_err("error %d reading CFSR\n", ret); > + return ret; > + } > + > + return val; > +} > + > +/* > * Read configuration register, returning its value in the > * location. Return the configuration register value. > * Returns negative if error occured. > @@ -209,10 +231,15 @@ static inline int spi_nor_sr_ready(struct spi_nor > *nor) static inline int spi_nor_fsr_ready(struct spi_nor *nor) { > int fsr = read_fsr(nor); > - if (fsr < 0) > - return fsr; > - else > - return fsr & FSR_READY; > + if (fsr & FSR_ERR_MASK) { > + pr_err("flag status(0x%x) error occured\n", fsr); > + int cfsr = read_cfsr(nor); > + if (cfsr < 0) > + return cfsr; > + return -1; > + } > + > + return fsr & FSR_READY; > } > > static int spi_nor_ready(struct spi_nor *nor) diff --git > a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index > c5a58c4..36c1681 100644 > --- a/include/linux/mtd/spi-nor.h > +++ b/include/linux/mtd/spi-nor.h > @@ -35,6 +35,7 @@ > #define SPINOR_OP_RDID 0x9f /* Read JEDEC ID */ > #define SPINOR_OP_RDCR 0x35 /* Read configuration register */ > #define SPINOR_OP_RDFSR 0x70 /* Read flag status register */ > +#define SPINOR_OP_RDCFSR 0x50 /* Read clear flag status register */ > > /* 4-byte address opcodes - used on Spansion and some Macronix flashes. > */ > #define SPINOR_OP_READ4 0x13 /* Read data bytes (low > frequency) */ > @@ -74,6 +75,14 @@ > /* Enhanced Volatile Configuration Register bits */ > #define EVCR_QUAD_EN_MICRON 0x80 /* Micron Quad I/O */ > > +/* Flag Status Register Error bits */ > +#define FSR_ERR_PROT 0x2 /* Protection */ > +#define FSR_ERR_VOLT 0x8 /* Voltage on Vpp */ > +#define FSR_ERR_PROG 0x10 /* Program operation */ > +#define FSR_ERR_ERASE 0x20 /* Erase operation */ > +#define FSR_ERR_MASK (FSR_ERR_PROT | FSR_ERR_VOLT | \ > + FSR_ERR_PROG | FSR_ERR_ERASE) > + > /* Flag Status Register bits */ > #define FSR_READY 0x80 > > -- > 1.9.1 Thanks, Zhiqiang ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?