Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753375AbcDVHEI (ORCPT ); Fri, 22 Apr 2016 03:04:08 -0400 Received: from mail-bl2on0136.outbound.protection.outlook.com ([65.55.169.136]:39088 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751681AbcDVHEF (ORCPT ); Fri, 22 Apr 2016 03:04:05 -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 4/9] mtd: spi-nor: fsl-quadspi: extend support for some special requerment. Date: Fri, 22 Apr 2016 14:39:47 +0800 Message-ID: <1461307192-866-4-git-send-email-B56489@freescale.com> X-Mailer: git-send-email 2.1.0.27.g96db324 In-Reply-To: <1461307192-866-1-git-send-email-B56489@freescale.com> References: <1461307192-866-1-git-send-email-B56489@freescale.com> 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)(81166005)(4001450100002)(92566002)(2950100001)(5008740100001)(36756003)(5003940100001)(2906002)(104016004)(189998001)(229853001)(6806005)(5001770100001)(4326007)(47776003)(19580405001)(2201001)(48376002)(86362001)(106466001)(105586002)(1096002)(50466002)(76176999)(1220700001)(19580395003)(11100500001)(77096005)(50226001)(87936001)(50986999)(586003)(7059030);DIR:OUT;SFP:1102;SCL:1;SRVR:BN1PR03MB070;H:az84smr01.freescale.net;FPR:;SPF:Neutral;MLV:sfv;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD015;1:FCJvFoyGzv9zMWwYJbRKGy9PRMnugfl0blOQTt4rU8SsLesN4Mlrlkv0d07vf7K3xfku+EAPraEDhnvdp/h/xH3TvEaYIjDgE/+ccg9Wh6YDuzefIg8+5Ukb0oop+eHjpaSMCdT9S7lsz7u78FPdchtZeVxf8K0aHPnJdKT1aQ7AborKcaC/grxUN82KMjmNjGZ0jQQyNRIVTuTfQzKzOdnZjd9zJz2w02g+QsxC9XE7m+wQy7/ZnkGAgMXhYhwj1AI4YqZP7jXOkxGa67l5HHAqpIZK9lXdDfWZ6D/eBKyc0RqtGQEdxwlNjxi0atibWnbs1Mib/7uHmzQmfWzuVEKKcUhqRpk5iSboZ75AzcrLHOPu7z6xRtcO0qrl3P2qDpXz1yhJPTOQ+7NFOWNfMzEbKF87LgPj3C2i9CaRGZ1QXAuRTs4UACeZLhhlR/XsiL7Cy9ACnAceizPg2+lYVO2219tSk0VU/UGDsK6s7XYuA1QgBuq9WIPScELOI57ZbJsLpgOKgFpQDACCei610N4yeh9/+cSYROxEPyBFCPnH6zp5Mk0XMppEw5+wSmr3pb6xbunOoNndl6gZ5kWUpw== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 4200abee-c90a-47a9-a1de-08d36a7a3ae1 X-Microsoft-Exchange-Diagnostics: 1;BN1PR03MB070;2:EWnC5Gx63v4lhcY4lX1wQC2QwIr/gmCAhPzpOeGiYkZg//4xFyHJOSDfqVYvVBCyNHNXCDbmuVo1XqQX5AnXUwnPHY2FsCTqzjp/hAfSBzOndB8egWIrbDkCbZ9BF3vy65TKJFIU7PzLV/JdxcQ0V2M9RVRCXI+YgiamHWVJYfCRleijEzrii2atZengQt59;3:ut8335v9K+p1XO5gJELzTbvRsDigh+VZnIGkFlQ11ETH7ETDP8IaSSrUkS86tw7gD85GgHHLLTUqNMGgWEBK/TWYYXYVbcovfdc8CaLQk/hXtPcBmqf9QzyFTyj3fceeWTnWW81WBjNhNO+Zxk4oxMhl1AWH9LP2++boT10L0DydAqoabtvQ+iU40eO+j4qg3yMeZuZFwlYlrFLO0kpsI+E9Ng8dIUFGgILClOFuumw=;25:XfR/F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ZIam4nZDt5Uh2wIkIK9KQhwmxC74PhAVTipwUagrXr7g0aY8EytrWOuo2YV6UXgXerkws9eX8uSVbGsmG4xU0m3j5OFyqlRlqulmXq8nJY6t7XvUz7sGzNGVAhPXbmwsETY5mB4J4WGGbN0zlnQMHIkYoeYmJtRiSBOx/GhLowNTYRBJlJBk688hLqEFfIgqJEPaWCRHICbmfV79W9lvUp4AP6tWSZoIZJuSNi+DX39d+4hVrgA6rrB/us97jqCGcVwSQji/flEyVhQSZOUkS3+WiegOdTnYCnBE6//oAgiKb66SUgvi9SDD4zC7XoSCLM18fua X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(9101521026)(601004)(2401047)(8121501046)(5005006)(13015025)(13018025)(13023025)(13024025)(13017025)(10201501046)(3002001)(6055026);SRVR:BN1PR03MB070;BCL:0;PCL:0;RULEID:;SRVR:BN1PR03MB070; X-Forefront-PRVS: 0920602B08 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN1PR03MB070;23:ZawboPb+ul95fUihIOrT944kJw++ILAHcicd3KwzDD?= =?us-ascii?Q?2g9FvwnrzxHKdvh50u8zr4YULHHbsO2NfnoJ+xXHBIYum7R1hB1JmrrreLeL?= =?us-ascii?Q?v2R9tazh9crSvocbtjsKQPmjFAujOAmgE7Mv5X3ur+5Y8cAkelZidR+KyJoa?= =?us-ascii?Q?nN99KwCGE+dAf7jnXpGZAJYLg+Fh704XHbn2zqsROcV4Z6gav1r1HmbPP3rR?= =?us-ascii?Q?+j8NJVRbOd7PebIA3tp7o7VAluZ8VM9GThiz87BVjhDcR9XKamUYa/WMZcQA?= =?us-ascii?Q?Z9vUmpDKQ3J8sipnQ3wufCzXkv3iYVHRyJfVvIsJXzFJ07hPBbGWH3VQBFZR?= =?us-ascii?Q?vRGnkvDmRbqjtgtn3rDcZwHagom04u0cfuuHCSJjQWJZ2J1p5h2pRpTZHWWX?= =?us-ascii?Q?nIRo1VtGuRtJFpBO8omPSRd8DpMNeszg4jutOFV5PZNnf27suWngpokATOLx?= =?us-ascii?Q?If78hOSw1SnLE+8vFFBpidizSq55TlzR3FkK5snZTD7xnegRWn36p3MNNuJJ?= =?us-ascii?Q?9Vc2jxggS/4YPgw5z5awXVJ2BZcd9nF7Z5OflBs9lzofwhmxRCqKY0KhBv/u?= =?us-ascii?Q?+C6KH76I+masJ/B61Kf4cjmpRrpX7Rsr5VFrqm6ECrh8967k1Uhh2z+vJBgf?= =?us-ascii?Q?nehbv1EJD31vEYieW+m/Tb3bsGn/3hM4+Z1ChKZrEDAwSjwVOqgfoCPgmpzz?= =?us-ascii?Q?LX2yzdFOkhKjvqiRkdNBuRWtQ6Vk0CtZle8mH/oqB+qhRtoZ9H5ASZmboarf?= =?us-ascii?Q?UzGJgNtcameC88GdEq/eWricvRqOGEnFuMag5e/6KNboQ7yUheHzW0YatWd1?= =?us-ascii?Q?Piu0x+TcvCfnaYp1RoCTnUknammzEiA4PZ/AF9ATH773Y4aO03mHfvHIZX3E?= =?us-ascii?Q?ucaOx5x4JmtVcnEkHnMbwgzTJugnjhe+h4MoRhd+HPqPsNwZRUVkFcPvQe62?= =?us-ascii?Q?eTLfCLpCdU/jJtF2JO1Uy7zwZL+ESapQrAtejyRqd6Z59aWBzLHppADrGqta?= =?us-ascii?Q?EGMrlOB6K43c4oNCbetaVO?= X-Microsoft-Exchange-Diagnostics: 1;BN1PR03MB070;5:qi+RIWrnpJnwCtc5u44MBIIpnUI2Za2s7YYK6Ka0MRlaYoZTF3Kj14ZmWegtwY7DgM9FH2put5ZPufj07dJ6D0i1ymZ1dKdz1jZAwvJhNN/8kAcXFT/e0elF68cnUj/arxyMc5019PD/3YUrXgpObLr0YE+5y+6jR2UoqSdOLj1cWiOMYVQAta1fE83f/cxi;24:2iuLyFfdl3RSAEYHzWCp8NPqR0leoAPI9sztJvnRTsUjgTMd2KcKO1APiG9iVzBUszVCL6FXz3aSRd3yxaQk1xaloM31tBzVQh2RZ97EBic=;7:fhPM2vjQBneTbxwOwm/Kpd3QCwIiqU3Ag55koaiMO86LkiZeoQm7XyuTNQ9m0YKaEKu/2EHEBlHspl03uqSZZ3UAYprI4C0lZ5bE5Og9LgeASNDCRdPVn6BQPxNqVzstJcfFulQ5cb92VxlyFxePVVu+K56NFkLAbVuiD+MWbqlUHw3WEhmS4Thg7BffbsjbODUeqhTUE4N1eqaa43Dj7w== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2016 06:49:19.2671 (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: BN1PR03MB070 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3747 Lines: 124 From: Yunhui Cui Add extra info in LUT table to support some special requerments. Spansion S25FS-S family flash need some special operations. Signed-off-by: Yunhui Cui --- drivers/mtd/spi-nor/fsl-quadspi.c | 44 +++++++++++++++++++++++++++++++++++++-- include/linux/mtd/spi-nor.h | 4 ++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c index 09adaa4..16ebabbd 100644 --- a/drivers/mtd/spi-nor/fsl-quadspi.c +++ b/drivers/mtd/spi-nor/fsl-quadspi.c @@ -205,6 +205,9 @@ #define SEQID_RDCR 9 #define SEQID_EN4B 10 #define SEQID_BRWR 11 +#define SEQID_RDAR 12 +#define SEQID_WRAR 13 + #define QUADSPI_MIN_IOMAP SZ_4M @@ -470,6 +473,28 @@ static void fsl_qspi_init_lut(struct fsl_qspi *q) qspi_writel(q, LUT0(CMD, PAD1, SPINOR_OP_BRWR), base + QUADSPI_LUT(lut_base)); + /* + * Read any device register. + * Used for Spansion S25FS-S family flash only. + */ + lut_base = SEQID_RDAR * 4; + qspi_writel(q, LUT0(CMD, PAD1, SPINOR_OP_SPANSION_RDAR) | + LUT1(ADDR, PAD1, ADDR24BIT), + base + QUADSPI_LUT(lut_base)); + qspi_writel(q, LUT0(DUMMY, PAD1, 8) | LUT1(FSL_READ, PAD1, 1), + base + QUADSPI_LUT(lut_base + 1)); + + /* + * Write any device register. + * Used for Spansion S25FS-S family flash only. + */ + lut_base = SEQID_WRAR * 4; + qspi_writel(q, LUT0(CMD, PAD1, SPINOR_OP_SPANSION_WRAR) | + LUT1(ADDR, PAD1, ADDR24BIT), + base + QUADSPI_LUT(lut_base)); + qspi_writel(q, LUT0(FSL_WRITE, PAD1, 1), + base + QUADSPI_LUT(lut_base + 1)); + fsl_qspi_lock_lut(q); } @@ -477,9 +502,15 @@ static void fsl_qspi_init_lut(struct fsl_qspi *q) static int fsl_qspi_get_seqid(struct fsl_qspi *q, u8 cmd) { switch (cmd) { + case SPINOR_OP_READ4_1_1_4: case SPINOR_OP_READ_1_1_4: case SPINOR_OP_READ_FAST: + case SPINOR_OP_READ4_FAST: return SEQID_READ; + case SPINOR_OP_SPANSION_RDAR: + return SEQID_RDAR; + case SPINOR_OP_SPANSION_WRAR: + return SEQID_WRAR; case SPINOR_OP_WREN: return SEQID_WREN; case SPINOR_OP_WRDI: @@ -491,6 +522,7 @@ static int fsl_qspi_get_seqid(struct fsl_qspi *q, u8 cmd) case SPINOR_OP_CHIP_ERASE: return SEQID_CHIP_ERASE; case SPINOR_OP_PP: + case SPINOR_OP_PP_4B: return SEQID_PP; case SPINOR_OP_RDID: return SEQID_RDID; @@ -830,8 +862,12 @@ static int fsl_qspi_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len) { int ret; struct fsl_qspi *q = nor->priv; + u32 to = 0; + + if (opcode == SPINOR_OP_SPANSION_RDAR) + memcpy(&to, nor->cmd_buf, 4); - ret = fsl_qspi_runcmd(q, opcode, 0, len); + ret = fsl_qspi_runcmd(q, opcode, to, len); if (ret) return ret; @@ -843,9 +879,13 @@ static int fsl_qspi_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len) { struct fsl_qspi *q = nor->priv; int ret; + u32 to = 0; + + if (opcode == SPINOR_OP_SPANSION_WRAR) + memcpy(&to, nor->cmd_buf, 4); if (!buf) { - ret = fsl_qspi_runcmd(q, opcode, 0, 1); + ret = fsl_qspi_runcmd(q, opcode, to, 1); if (ret) return ret; diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 3c36113..fd0631b 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -74,6 +74,10 @@ /* Used for Spansion flashes only. */ #define SPINOR_OP_BRWR 0x17 /* Bank register write */ +/* Used for Spansion S25FS-S family flash only. */ +#define SPINOR_OP_SPANSION_RDAR 0x65 /* Read any device register */ +#define SPINOR_OP_SPANSION_WRAR 0x71 /* Write any device register */ + /* Used for Micron flashes only. */ #define SPINOR_OP_RD_EVCR 0x65 /* Read EVCR register */ #define SPINOR_OP_WD_EVCR 0x61 /* Write EVCR register */ -- 2.1.0.27.g96db324