Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752221AbcDNEPw (ORCPT ); Thu, 14 Apr 2016 00:15:52 -0400 Received: from mail-by2on0114.outbound.protection.outlook.com ([207.46.100.114]:4370 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751476AbcDNEPs (ORCPT ); Thu, 14 Apr 2016 00:15:48 -0400 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 1/9] mtd:fsl-quadspi:use the property fields of SPI-NOR Date: Thu, 14 Apr 2016 11:50:47 +0800 Message-ID: <1460605855-6689-2-git-send-email-B56489@freescale.com> X-Mailer: git-send-email 2.1.0.27.g96db324 In-Reply-To: <1460605855-6689-1-git-send-email-B56489@freescale.com> References: <1460605855-6689-1-git-send-email-B56489@freescale.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(199003)(189002)(2201001)(50986999)(36756003)(76176999)(5001770100001)(2906002)(5008740100001)(4326007)(81166005)(19580405001)(86362001)(19580395003)(1096002)(586003)(1220700001)(105586002)(106466001)(87936001)(92566002)(50226001)(77096005)(2950100001)(5003940100001)(6806005)(47776003)(189998001)(11100500001)(4001450100002)(229853001)(104016004)(50466002)(48376002)(7059030);DIR:OUT;SFP:1102;SCL:1;SRVR:SN2PR03MB080;H:tx30smr01.am.freescale.net;FPR:;SPF:Neutral;MLV:sfv;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD040;1:aAuQJBHFEoJVsZzxS6fluZmrx8sxD+Kd3JxRlLec1ypGku35kwNmLHxOAa+tuIgBwtSnCwzGjzRtzhM0etRONORLz1/Hqr7mrmo1ckgrG1ExZy7TwhQFDlWB54/7h/xca2lmOMQ+zSd8cn61HtRnfpjQIhl9PY9sAXBOm8QXa34Uu/wHO9b0EbIm/dVLOJoOFo0Yxx46qlYb0PdBFG0bDPtKOo1G5Zatxz3gjStr/Rjau57bOmiv74Xal3Ai2/FTtsrlETcB6OlotYqdT4jEswKvA1mGDGGaWzf0ZdKBBvyjRJ/q2eGYTDtailafEf487xcI8DdD9H4EqMfZVcKoM2Jbe+Ej+9iE8B7LXIYYpT9byDWU9rE4m9LPWGBo0T1Bant3PNpPLNX5atGEUJhEdmBhogZ3b3xmw3qmRvg9kdN+T3oqE3lQQWcFYdHNejw4val1cTDqUUI4x/nVk6s0geUcsyy6RwV/eEVnoB0+Y1MumbdrAlwKU0kOtJ7pi3pWcV3/D5QNe1avWlI+MiwW9IE5RLt9MpFbIt4KFCIPT2Esj4FqI4TbxZDHYm6JWJaW9tsx1B3265X04ORcYrtsmg== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 711d95b4-4291-42ee-5196-08d36419480f X-Microsoft-Exchange-Diagnostics: 1;SN2PR03MB080;2:Xc21Cv+MvOurkEFXL/8YGr5+Tfe3CQr8UUWslbOwdl+FDvpFSOfLYaVZDadwzCmzTG0dsOeH/L6UVp5MZE6FNk6wiy8CS1EQ5E9BkvTEB+JSWITQLtVB3k/LLxXL4U1EqKGZycanmbAU0qtLnk86uuEhyeJeGlsazJHgrBH+EVQWHI+96llIeqF1Xnn1WUo4;3:N179V9J8nrr3zFM05/wOm9HjqR37Vlyc1ArPBSgupPOuhZNDqzcSFK2+rySva4apm6bDfKqcWZkzKj3sdpCPln5No8KU7kx5pCjM4ke0Qylfrrw/Z3Dz0hLm4SOi++3inWfJzWxjg9bGPTAMK873eh9ygrjbt0byqXlzJpLtSJxyAlkb/tUGABDWm3v16aI4ecADituvMNF1rHc870xj0TUP/CHnDpbpRj0wJ7yjlZw= X-Microsoft-Antispam: U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NUJFwz921djORcttNq8kY5R0NJgHxzJMBdFnfrUmdyWtSzfvGJngFyUgDoJDtbIGN5ri8teY5MYaUE5WHWb+7O+wLbFAIfQrmA2C3VZqudrq6zXBUI7torAUuQ0jD3+ckPupF47DPwRzVnwrDISMMqGiZuIRSkid08BzwZCYP;4:eqv8gKuo9oPoHZYc20/QJM0H67IBAJhNLPCMli/5Vsk/jT0v46X7AiJtZXM3oooCQzlL1iSsVdX1jF3Y4jZnuZiasr0oO+lmMHewq8b9O3EBUCbVKhNtYdFcrOxC1f3W1mjbDiKwkUyV7K7jTZTx91Uq9TR9FAezmhydhQPiaq1/qtk94Qejy6eJzB5r3jCZ3wF66psiVpiUffJW9GMg5EvoZatLn+q6Iqq+Hw4HPnhA+sRpaH7AXs5ehSCTN5pzeug9+aGjKlP7lI3XcNHN+jIWJlki3R+x2veWc8Qx8qq9UB1M3Y6y8slwVrCMMUBwIPdhr9KTnTo6YuDL8z6bWpZ9ckbou2x2seKS9jrRRxNasVBeAFxdTa4oOMzr47Az74eOv0oNs2ZABdBLPDNMrwX2ogvFD45QIYaBN0UcX+mjjDuKO6PjaFBi1cGhnQ9e5eLCjkx/6y1sxKUnPnkRJOmd8LkrLC/c/MADes7qQjM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(13023025)(13017025)(13018025)(13024025)(8121501046)(5005006)(13015025)(10201501046)(3002001)(6055026);SRVR:SN2PR03MB080;BCL:0;PCL:0;RULEID:;SRVR:SN2PR03MB080; X-Forefront-PRVS: 0912297777 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN2PR03MB080;23:ZrVtB6izJkOYk/OAevUd1ovb3YjgKfhNLvKxCuyTwL?= =?us-ascii?Q?U92EIgyzTJSJ9ZKE73boPJNz+M0gLL44X9kT4LkkWkqwq+3JvUNSI7QB1I4C?= =?us-ascii?Q?MPjrmL2ECjInkl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Q?8RkPgDzO7zp37aG5I+F+u1?= X-Microsoft-Exchange-Diagnostics: 1;SN2PR03MB080;5:mU66tuChZzgFZcujSQTTiDcotuNmU0gy9g4F5oMTGoCB7fPaZyc8qCzslg4nWCtZmx7pDlcAkfxxjhTKBiTDLxJMoFD1L9DloT772g4nmBP0RxGm/Orc1tdGhNGzb9+CQ7O8JusTeQbr5b4w9944PQ==;24:RgiAd6/O1+U/l86fLR6Ynn0dPk572H3OMa4KCeTQ2AhGJH2vWXGirFGZ0XPvkh+z1g8ABlMBvXyPEbdEEctvEjx43x97JiVN7JHpvMBbpyY= X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2016 04:00:13.3267 (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: SN2PR03MB080 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