Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753593AbcCCHSf (ORCPT ); Thu, 3 Mar 2016 02:18:35 -0500 Received: from mail-bl2on0130.outbound.protection.outlook.com ([65.55.169.130]:33120 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751180AbcCCHSd (ORCPT ); Thu, 3 Mar 2016 02:18:33 -0500 Authentication-Results: spf=neutral (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=freescale.com; From: Yunhui Cui To: , , CC: , , , , Yunhui Cui Subject: [PATCH v3 1/4] mtd:fsl-quadspi:use the property fields of SPI-NOR Date: Thu, 3 Mar 2016 14:54:01 +0800 Message-ID: <1456988044-37061-1-git-send-email-B56489@freescale.com> X-Mailer: git-send-email 2.1.0.27.g96db324 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10019020)(979002)(6009001)(2980300002)(189002)(199003)(19580405001)(229853001)(48376002)(106466001)(86362001)(92566002)(50986999)(19580395003)(105586002)(36756003)(2201001)(87936001)(5001770100001)(50226001)(104016004)(586003)(2906002)(1220700001)(5003940100001)(1096002)(50466002)(4326007)(5008740100001)(47776003)(11100500001)(189998001)(77096005)(5001960100004)(6806005)(4001450100002)(7059030)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:BN1PR03MB071;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;MLV:ovrnspm;MX:1;A:1;PTR:InfoDomainNonexistent;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD054;1:ZnzLxb/naqhzG7jfK3tSRVq1z16NQw05F4p2qXrsxXybS7aZznOslASKzSPb0FEx0Oumwa88Zs8Waat6/f0QeyQin6dpxjcWzuGIVfmjp2eq/RojODOdhzHlYTbD/3vFH6XguyteT8h/KEZQ9t1yhxp7NBSEKkG0ck2FHVCvX+eocVkCT+bVKTLEEroMHVMChbrDM6zSMghA8v5Zx+aPztTw163WOzRCYzdI7Vyse3lhZFeAautyXCED3tdkEhWZCKcvMsyOLq9nCLO8lBDliw+JOGzK1M04PvTDejZex02pj6OVyLoCDoNludruQAYsLGTT8ZhV5kxx+QAxyU0Mp+D93pUtxnsQhnujEYuuz61pm3VMTxIbo1xbU1Go9tgR45xT28syJG1QEe5t4qPCCxRchiLWaFRoVEbXHC8auOpjumiaYywbQ88/xLQkoKHmKJT5LkDfe/s4e3bTEBuMFIVGUVk+B2w8icsVtHNzaNTpzqf2aVPSlmkSp9str8Ar MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: f3c7c7a5-a63b-4a1a-f3f2-08d34331db0f X-Microsoft-Exchange-Diagnostics: 1;BN1PR03MB071;2:WOfAA8omS2UKug+lK47AbX578MRRNBSTzdQEjcSv3N8UxRJpSZ1jwqd9Ho1yecQMSIMjuVYd4uBbHIwOqmH2ZB5mPQbkPpn5J78yWGgUbiSr3+y9X/HI2CWPxa2VKZ/0oxkpohmWtuAK6OEfX9re5oFieM1ULtLh7abj6e9y4w/jTHMMtfZIxiyb/EsDDQGi;3:0CQKJc68atCel6MAW9oEE+YyLg/KN0It2W4MuHPCnHCHEBah0nhFvobdI29V0fiRO4/sANaq03QPEmct3aI0R+xj4EMWmLKi1kLKFxm/s76Rn+WXD8I2c1syifLiiP+LlIazu9gjNoQDHLPXkD6CsMw8WAshXPG+8EVUpDGisaHHKA1+4kCZPYEmOkecab6ar+MrAtsbN0lIdfqAXWZzCYLAPd/Huk3hRaqdXlEOJS8=;25:Tj1vPD7l5JORwe8rbhduez2SPMzYqw5EaaINJ6SOQfIoPwqlfvNa7qk+QCqKrXA/4/72Urz2YPV7e1RRGkUfYJX76t0QLFdEoIynh+FgV2LpUXDXKy804fN9GOqgbHH77fP5CNMZ93g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dWUA86X0Q5UdC0ogL5057uTxH5NFhaR3Z0PgJbqJE7O1eiVrgyO151W140SoDP+5cRehMgZlhWr37MI/IVhj+dozSB110KYrTOQhnbfdiQWUx9X/gATduMPam4AlfA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(13015025)(13017025)(13023025)(13024025)(5005006)(8121501046)(13018025)(3002001)(10201501046);SRVR:BN1PR03MB071;BCL:0;PCL:0;RULEID:;SRVR:BN1PR03MB071; X-Forefront-PRVS: 0870212862 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN1PR03MB071;23:S/cEGcfD9ydKONXZUyLHzXsjUoY9cuPtcrZdoh9AKG?= =?us-ascii?Q?Tuj5BYCGmwUjjm6WlgLdvGqUmuiuneqC+KA+xh71nKnpyhfYiND3VRDSXEoE?= =?us-ascii?Q?USDnzsajBKQBPSsH0ag0HzlIObthjaa3ze0SSMtkiUnZ+CqvPcU12g/kHUBp?= =?us-ascii?Q?0rQOR0j5hPIdHDGQaEPC4glhbPwMM8FCHs5CiZSVPAgR1n5/0HvlfxRoD1hy?= =?us-ascii?Q?ZbxfCcR43eDvFkYFvbYzmy0fRmK4MdICsY//RAQUZcxU2BWQGHCjjbmdUq1H?= =?us-ascii?Q?Ci95dHVPWXfAIzZzfUrc9zKG1/WlYPUVLECb4oAB2A/d52n77kxPRmzKy8HC?= =?us-ascii?Q?CpBSIf+mdq1pFktg8FoWVEUXfRr9qBBrhGyovXa1s1beVgISdW9RhLE8bLTT?= =?us-ascii?Q?ZQ4ZQ+7iCpUTGw8o+GXDmAc5qTA1oCGxZTLSwc/UltzDBz8wog1kHswT4+xE?= =?us-ascii?Q?0kGleh1h6MOZhl5Uf18hROj/sMoknxdxlVyr5/dB6cQmK6BFCaTH6n9rK5uN?= =?us-ascii?Q?rw64mK3Dmnj8ZJZ0XVakaPC/QXiYjZg3fsUtFfxFRAF0eIwdrhDTfSBLy12v?= =?us-ascii?Q?EedK7vi+NikvalwLMbLUkoSlSim6kCvDbhD8Sh8KwSAwVspNW9qP44rjLwzN?= =?us-ascii?Q?1Dy4nrDUAvfUKmNhgMNh7tlfXubU3+jyyEJ2API78JCZAIm5cWkSeBr7qIj1?= =?us-ascii?Q?CJG87ui1YTwRSAXBuiS/kbymBKB8DZINPawf8hncnWeTtplpC/SOCfGrkbYV?= =?us-ascii?Q?0TEChq7Ri5ijasoHOEElBEFC9A0euBeMst3DMAOzcbfucsIkYeOg/OMY52aP?= =?us-ascii?Q?Nz6udrOPdnTUx66msfLWQujjCePSxoTSbAyaClusmxQzmieaDe8bSv1SmZtl?= =?us-ascii?Q?EUJL4pOWU5kfoksbqA2mQ6D61hDnThv4bZSooHA2GDoJDthQyWQnAgbhsrLv?= =?us-ascii?Q?sF1bNOME7xD9Ia6MgMdZ6EQ9CnRJHW8RQ6xoqr3vDPSQx7OkIilGjZrqqtls?= =?us-ascii?Q?+rx3igxG49nGA9GHDVJtSXnsNHtdR8Nl/Np3Dd8GAsTvh81BwQ09e0nlrjZ9?= =?us-ascii?Q?V9/CA=3D?= X-Microsoft-Exchange-Diagnostics: 1;BN1PR03MB071;5:XvnV1DLOuAoVKasBlnqbmAsYZI1QP3rGz7qSsKwnUsHDQgyt0ZbUfo3jjUK8CurGpDWgunr2MNiLQNcLbGulV4S4PfUkbYvN2fme8UwcHeAXLunwANbH3QKMrRQ/EO5Xy1axvBnct/d+ElgryxCudw==;24:+SSGyNM0qZQ+HK6u6hS4xuDNzDzoSU09sPziCFTAtBGLJ2j+jmsiB1qnkokCiSmAuZN+ABWlFtuTBD5GX49qZ5Oc32doi8xCfM4DjwfiVnc= X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2016 07:02:59.5214 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR03MB071 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2795 Lines: 87 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