Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752439AbcDVGtP (ORCPT ); Fri, 22 Apr 2016 02:49:15 -0400 Received: from mail-bn1bn0104.outbound.protection.outlook.com ([157.56.110.104]:59570 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751696AbcDVGtO (ORCPT ); Fri, 22 Apr 2016 02:49:14 -0400 Authentication-Results: spf=neutral (sender IP is 192.88.158.2) 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 v2 1/9] mtd:fsl-quadspi:use the property fields of SPI-NOR Date: Fri, 22 Apr 2016 14:39:44 +0800 Message-ID: <1461307192-866-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.158.2;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(199003)(189002)(586003)(189998001)(50226001)(50986999)(5008740100001)(87936001)(6806005)(5001770100001)(11100500001)(2906002)(4326007)(50466002)(36756003)(81166005)(4001450100002)(19580405001)(19580395003)(229853001)(2201001)(92566002)(86362001)(77096005)(5003940100001)(104016004)(1220700001)(1096002)(106466001)(48376002)(105586002)(47776003)(7059030);DIR:OUT;SFP:1102;SCL:1;SRVR:BN1PR03MB072;H:az84smr01.freescale.net;FPR:;SPF:Neutral;MLV:sfv;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD013;1:uBUiGWKV+v53+NfwdW1KhDkeENl+rzLxoHzxlfdTSC9k0ME5+p+czE8GsM3cD8IGB0LA6eIuffPvf9ge1zNoxWHw/PKhOimgEnJOGS5oWsvDYnTnORGUKsJqmF3a9afA0fyaodYIyLiXBl1wuekMFDLpg6dkjfRpvpjyIbLnPF+0GyU62a9oDoMYp4wdIW+fOmDn8MYBBFMqU2z1qUReB3Yv/w+qr+cYe+YUcMK0hlvLlSt1cav6NOigwZstaPBizMS2GifWlekgrUH43LEU4dtWlxpOGjFrPWkX4/FMovD5t6sdORhE3vRi/uqmUlFgjmYRJuZlk2rgFNDps270fMdl1CdBXlqoXcO2KgHo11VXQbhpvHw9zhBhRslbVyYamUs8qvXQSmNy0vfjDDlCdEV9y1em/xhHI4TbM3x3SY9+WBtJt7JT8jcT3KKW5dANP+IEEi55y7NlPPvoZvTkfyphKqXrtfPYicmpNgGXOnhqzv7/E841aJQHuHrkND6h4EmlRJrs1ihrQaaKUsF2+5V4We8Ggh3pH4+FUxlX0FLSRj8AFdj1yVYJtAHyraYZXe0/MIjKb7QZb3baGSSyTQ== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 4f232838-3bd8-42db-235a-08d36a7a35bb X-Microsoft-Exchange-Diagnostics: 1;BN1PR03MB072;2:aJ84qzjMQ6LrA5q6zIZzHlwv+tSLvTdbcK5HiHHO0uPLVY1EVogDDebTRT8NnMxq4Z3XScn2klGFu/3mSGvOZzXkI3N54S8gFS5jZWokxh3M6M5vA5VQ8DrhP71MXz11cp5kDDF5D8fj5Tbq0A9msdDvAvk2ZLLz3bLDny2MtVVfTltgEoTmxz+H/gYd9Jkq;3:W9vdBZ7zN/Med8+c3l/kSmUJYOx7GohHuty00AYQufW/ibrzwWXkApEu6a0lY+RLiPIrH0NucotgS+g66pYjC7nOQsGbcWkMTRVSVp1HlKAQnzatEDCtqSQFjJCfKo663ULF09tHd/fZqaCqU8LrS3p7iHkR4tt+kMeBxkX8J7ryNiGbspcbqokpUEZix+uTqUVo7tAG1ztQSkd4hxBZoMw2HfHKRIAmIp9b8fnfPUE=;25:65ghp/SwAHddxa2heqG4EPIjWl5as8j7ptmZo3S3IVRURHNLlxdGUxzteHGVC18EZrMOIX2HF42AYMe9EDbU2HbVpietgq2//gdj+aXzY0gAlbSMy1UiOGWrnBd2mhoQ2hXCZbzw4qaMm6jKmfLj3AyTiNT5I5LRJGCPIvATpmd+e07yJRb03vWvHnT92I+7KLZk5GbrXocYFLKLAjd7DRUOuY4djurlCA9TGQjaIz7OViJc3KgkxyWiDKII2rHTs8V1RqwZsr6Sr+lAXqiCaTdAYvASZrkOByWu9QvI6ELw4p0qF/d7tperHAf84NLH4g4/5Vpl+2ci0ukQlX21cA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN1PR03MB072; X-Microsoft-Exchange-Diagnostics: 1;BN1PR03MB072;20:JG8TJDcomeJsHndj0PLdTehiZ6/j8m1PSZCm5sBdrGQez65Iad8jB01in7FYZmYt9NpvFSrdlSxlNxrJVAx1AB6fsERJuOaUahsasHqiT9ipbhyHfwwlk+twrAF+ZOIwRoov+p94/C6Mp8nsvDmi88/qoVrioK+BjVUpEmPMc5ansSZtlMIX8ESbwHjuTlGmMe+px5/CFiB1BZn13EaQQyQyaUSmTJIqLjgIYOhL+E8HtXU6ndRZZYT4hJb5g5X6ZumyME1Bm7eQphqSHbE5rnz75Q0GlIC2blFFYfu7NU1cwrojTxd8wiuASJ1/qYzt26KY0hN+WoVlcsy82JO4dS7Ae8juWpG68XDUsemNcIywHAGYkxZwJtivXr6I61K602wrnGNr86Xrizj/VTnc1hColSIuLKk/ScFgMWpUdRAT/00sTYgdjtOKWl1oVvMn;4:gsZkEL6TJI2KHZcRuo+qaZEHfxxoBlXia2m6tNaDZvw5XT81iP7/EYAQkqKQhotRH9UShB8rbK1Jim6y+xNxWvOZPp+jaWSD1XcaRVgYKX4229+LzkefQnrxL7wWWKL+ckOjQ0kwlxdLWn9s2YMIlkWO2sm2JLXhuG3UCqycf49kg5gEPkD3ep/sdgEPg63eYQ28YMHkwGQ65xPRoJVabicorLyIDkuKcVAIbTav3BQjfadl660SeilLR1ckMSFmfrVXte2jK2L+j7Scuew6BASxnDsSQqzTJBguMJlY1q02y/RJALttma8CaFCtBEmvRSS76kITSr5uZ4krT0jjHIX454y8KP2rBS/cpAqJriFXzOL4SQuBIv3sO+b1QWvucoWpW4+zZtmsaZWpbiohytpq1zNO439FALDsXXv0Y3O4yXUpicHrKIvnK+lFis+y2XBs8JrluIE8awsAJ5+SDsF9IsxZ/4ziyK+Cc2LTSqK+ySwxxSEcA1LXtBeHQmu8 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(9101521026)(601004)(2401047)(13017025)(13024025)(8121501046)(13018025)(5005006)(13015025)(13023025)(10201501046)(3002001)(6055026);SRVR:BN1PR03MB072;BCL:0;PCL:0;RULEID:;SRVR:BN1PR03MB072; X-Forefront-PRVS: 0920602B08 X-Microsoft-Exchange-Diagnostics: 1;BN1PR03MB072;23:Nc30gtGIcGbgAfcuD+U5DLCYdydJUV+djj+JPHCwjZ8Z/h/jVNF057ZD+9cu4r3PGCw5M9lWiaUTPyAOhTl2n1oDcN7VtDTdAAuCRDSWzhIbH6z26vS37qxUdLmwr08IvrzjSHeJvzWU9l5lRgr6xn4b9mboAbobrU2A5VTwsfXEM02WzVwMKbYaRN81UcGDc99V6RbbvcoRsIHsFwnq8hjp4NU/gJ/gGEgI0fCttANuIcaKXmLa5icYnDq1XsQoaiWcYDEFcCja0rYizPOFThd/RX594lwmFq0SXpdw9NLeeKIKV+JwNmOY91kqPjKzj7hmbnD3m64rzxFpcQVjGhqD7np760nMm61pLvRaTanK4AfIQ35YTJNcGonDRr35Wov2IxQhm2zH2WX1n4Z5sWMxRlwNSQYA2suSJ8aGNn4uh4IAwKik4/3l5OMaNWjV325Nyky02qYFATLICkkRZieWE7/s5ctWRG92TFRph4PeptoagO9I0wTpuWlblHuVxlDTBhgIA0FcQDBB4tmYvUlgmg/AM58KRniRD/755YM++Ld1k9JrZULt1Zl8GBGF4iMWw87MPkl4Fylnm2twDh4Ts5/ojyerJoukM5HL0HIaOMA+jsBSp7y45iBm4Xl0uhWE7LRuCgfOEnBfcSHjNyRsA7RvJjtxA1eicHeyOkQKPcuY1isuLXTWsGKwHl3gbRMjgWSJEbK+VHrC1mQU23OsyOfyD4mmad9OohYMVi7j2AUu2XVw4aD5eOz1CwNOPg3hZkzkBwsKT8IErHiTG9Wa856CYphjfLLI3Ub9AuT/vlJLnNED6L3AK5vsIC2W3/rtdyKNt4fAlTT80hwE8CpDPVOyEVPWdSaY95VLSXCjMlqdkdXsVqB38+KFrIXfWiquy3v7pETtjTB7EvZkAsz2AeCGOvVuHx6TbpTOG3yu1cCxjQIVO633Lsw1vzv6 X-Microsoft-Exchange-Diagnostics: 1;BN1PR03MB072;5:NNROJgUUQSEFvRU76K3pIZCk2OwalQyxOxSLKOzrIH1EmQPqM6yObTqxw9DC+rG5r78l2/1Ab29oAVopDhEb4LlnR0cA42d8zIw83apMp0DBuBxYPjeGNXkqlVbM4niipL42XCCUz8Bt2rlG/KXpnUhNOOaSlB4WZmaU6uYwSe8oTEUMkJ72FDvPNI4Gs4A/;24:6N9yJhBU3OlBcsXG2dPZjqfEcm2xv/4ywpX4jCdRjEf1H8wJ8Ctjqj5hjgVjdo+a+V1i95+jcxWBhInRephAWEyfDy18mPO3+xJiVSJktcc=;7:JuYvjPF9KX4jL9wYOunT5AIarlEWjX+x9jaUpwt9divz6NkKYMX+YuaQCvR2MUdAAAPxJhY9c9tCZWEn89H9Rajq9tsui1QXqLzcbwDmgtD9zqNd88ISM6RULWOIUQ12gmf7ulp29hsOEjf5te8ey0fbfSBeC92eL/ZtYQaA4LYjNhzBk2+mMF4BT5tx00JVY+3KP+9S3RHPlPSxmuru7w== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2016 06:49:10.7198 (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.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR03MB072 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