Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754623AbcCJJYZ (ORCPT ); Thu, 10 Mar 2016 04:24:25 -0500 Received: from mail-am1on0075.outbound.protection.outlook.com ([157.56.112.75]:23508 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754602AbcCJJYU convert rfc822-to-8bit (ORCPT ); Thu, 10 Mar 2016 04:24:20 -0500 From: Yunhui Cui To: Yunhui Cui , "dwmw2@infradead.org" , "computersforpeace@gmail.com" , "han.xu@freescale.com" CC: "linux-kernel@vger.kernel.org" , "linux-mtd@lists.infradead.org" , "linux-arm-kernel@lists.infradead.org" , Yao Yuan Subject: RE: [PATCH v3 1/4] mtd:fsl-quadspi:use the property fields of SPI-NOR Thread-Topic: [PATCH v3 1/4] mtd:fsl-quadspi:use the property fields of SPI-NOR Thread-Index: AQHRdRq7cB9cCsVgHUS0A4Z511Ttxp9ScM+A Date: Thu, 10 Mar 2016 09:24:17 +0000 Message-ID: References: <1456988044-37061-1-git-send-email-B56489@freescale.com> In-Reply-To: <1456988044-37061-1-git-send-email-B56489@freescale.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: freescale.com; dkim=none (message not signed) header.d=none;freescale.com; dmarc=none action=none header.from=nxp.com; x-originating-ip: [123.151.195.52] x-microsoft-exchange-diagnostics: 1;DB4PR04MB0735;5:5dRvMBdFcblrwen7kZUyZ8B4Z/CpafTVDfrMGKh0TuuebonhbQ1bPScHnQyKFfjnvrriVRznkUiCoV+0HFq6A0BzPg30Gs/29gvetKkyqd1CxnvVl16S9T7ANYEAU75HUi67Q9GrOOiTRd9s5WDH+g==;24:WFvLcmq8n/R913Oent6Qwj0Tw83yPosliUkJgwmoQ5p4SclIsrGd8HRhXbUWk4z44sIieBz74oFkCDjLU0zuOFAZfsOhbvyLzvvR4PtWpUI= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB4PR04MB0735; x-ms-office365-filtering-correlation-id: b3173233-38c7-4b6a-906d-08d348c5c0f4 x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001);SRVR:DB4PR04MB0735;BCL:0;PCL:0;RULEID:;SRVR:DB4PR04MB0735; x-forefront-prvs: 08770259B4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(377454003)(53754006)(13464003)(19580405001)(19580395003)(2501003)(76176999)(54356999)(50986999)(5003600100002)(5002640100001)(10400500002)(5008740100001)(5004730100002)(1096002)(1220700001)(2906002)(4326007)(2900100001)(2950100001)(81166005)(5001770100001)(189998001)(77096005)(6116002)(3846002)(102836003)(586003)(3280700002)(3660700001)(92566002)(2201001)(87936001)(74316001)(106116001)(86362001)(76576001)(122556002)(11100500001)(66066001)(33656002)(7059030);DIR:OUT;SFP:1101;SCL:1;SRVR:DB4PR04MB0735;H:DB5PR0401MB1912.eurprd04.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Mar 2016 09:24:17.1444 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR04MB0735 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3304 Lines: 100 Hi All, Thanks for your suggestions before. Could you help me to review this patch set if you are free? Thanks Yunhui -----Original Message----- From: Yunhui Cui [mailto:B56489@freescale.com] Sent: Thursday, March 03, 2016 2:54 PM To: dwmw2@infradead.org; computersforpeace@gmail.com; han.xu@freescale.com Cc: linux-kernel@vger.kernel.org; linux-mtd@lists.infradead.org; linux-arm-kernel@lists.infradead.org; Yao Yuan; Yunhui Cui Subject: [PATCH v3 1/4] mtd:fsl-quadspi:use the property fields of SPI-NOR We can get the read/write/erase opcode from the spi nor framework directly. This patch uses the information stored in the SPI-NOR to remove the hardcode in the fsl_qspi_init_lut(). Signed-off-by: Yunhui Cui Signed-off-by: Yunhui Cui --- drivers/mtd/spi-nor/fsl-quadspi.c | 40 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c index 9ab2b51..517ffe2 100644 --- a/drivers/mtd/spi-nor/fsl-quadspi.c +++ b/drivers/mtd/spi-nor/fsl-quadspi.c @@ -373,9 +373,13 @@ static void fsl_qspi_init_lut(struct fsl_qspi *q) void __iomem *base = q->iobase; int rxfifo = q->devtype_data->rxfifo; u32 lut_base; - u8 cmd, addrlen, dummy; int i; + struct spi_nor *nor = &q->nor[0]; + u8 addrlen = (nor->addr_width == 3) ? ADDR24BIT : ADDR32BIT; + u8 read_op = nor->read_opcode; + u8 read_dm = nor->read_dummy; + fsl_qspi_unlock_lut(q); /* Clear all the LUT table */ @@ -385,20 +389,10 @@ static void fsl_qspi_init_lut(struct fsl_qspi *q) /* Quad Read */ lut_base = SEQID_QUAD_READ * 4; - if (q->nor_size <= SZ_16M) { - cmd = SPINOR_OP_READ_1_1_4; - addrlen = ADDR24BIT; - dummy = 8; - } else { - /* use the 4-byte address */ - cmd = SPINOR_OP_READ_1_1_4; - addrlen = ADDR32BIT; - dummy = 8; - } - - qspi_writel(q, LUT0(CMD, PAD1, cmd) | LUT1(ADDR, PAD1, addrlen), + qspi_writel(q, LUT0(CMD, PAD1, read_op) | LUT1(ADDR, PAD1, addrlen), base + QUADSPI_LUT(lut_base)); - qspi_writel(q, LUT0(DUMMY, PAD1, dummy) | LUT1(FSL_READ, PAD4, rxfifo), + qspi_writel(q, LUT0(DUMMY, PAD1, read_dm) | + LUT1(FSL_READ, PAD4, rxfifo), base + QUADSPI_LUT(lut_base + 1)); /* Write enable */ @@ -409,16 +403,8 @@ static void fsl_qspi_init_lut(struct fsl_qspi *q) /* Page Program */ lut_base = SEQID_PP * 4; - if (q->nor_size <= SZ_16M) { - cmd = SPINOR_OP_PP; - addrlen = ADDR24BIT; - } else { - /* use the 4-byte address */ - cmd = SPINOR_OP_PP; - addrlen = ADDR32BIT; - } - - qspi_writel(q, LUT0(CMD, PAD1, cmd) | LUT1(ADDR, PAD1, addrlen), + qspi_writel(q, LUT0(CMD, PAD1, nor->program_opcode) | + LUT1(ADDR, PAD1, addrlen), base + QUADSPI_LUT(lut_base)); qspi_writel(q, LUT0(FSL_WRITE, PAD1, 0), base + QUADSPI_LUT(lut_base + 1)); @@ -432,10 +418,8 @@ static void fsl_qspi_init_lut(struct fsl_qspi *q) /* Erase a sector */ lut_base = SEQID_SE * 4; - cmd = q->nor[0].erase_opcode; - addrlen = q->nor_size <= SZ_16M ? ADDR24BIT : ADDR32BIT; - - qspi_writel(q, LUT0(CMD, PAD1, cmd) | LUT1(ADDR, PAD1, addrlen), + qspi_writel(q, LUT0(CMD, PAD1, nor->erase_opcode) | + LUT1(ADDR, PAD1, addrlen), base + QUADSPI_LUT(lut_base)); /* Erase the whole chip */ -- 2.1.0.27.g96db324