Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752126AbcDNEPe (ORCPT ); Thu, 14 Apr 2016 00:15:34 -0400 Received: from mail-bn1on0114.outbound.protection.outlook.com ([157.56.110.114]:42496 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751476AbcDNEPb (ORCPT ); Thu, 14 Apr 2016 00:15:31 -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 4/9] mtd: spi-nor: fsl-quadspi: extend support for some special requerment. Date: Thu, 14 Apr 2016 11:50:50 +0800 Message-ID: <1460605855-6689-5-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)(189002)(199003)(92566002)(48376002)(5008740100001)(36756003)(104016004)(6806005)(76176999)(229853001)(106466001)(50466002)(11100500001)(105586002)(2201001)(189998001)(2906002)(50986999)(1220700001)(1096002)(586003)(19580405001)(19580395003)(4001450100002)(50226001)(5001770100001)(47776003)(87936001)(81166005)(4326007)(5003940100001)(2950100001)(77096005)(86362001)(7059030);DIR:OUT;SFP:1102;SCL:1;SRVR:BN1PR03MB071;H:tx30smr01.am.freescale.net;FPR:;SPF:Neutral;MLV:sfv;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD046;1:lvEs2jacNd088Y9//BpiRC4zMqkcle/DT0rdEUFdDY3WluOsUG1aOgvX4pU5Jy2vU5mslR7u4NzV957DCAUlKpuGNaGjugnXhuyrqXbzUSX3zbnPFsMie4e1fH8RVly4OFrjTHTvgAAxN8Q84bs9EinqpoOgcboNsyJjJadSJxIfUqadedhjQh2D8bRUHjxexJ91ub9yf3nMEU5BQesOKQvUE94o3cjbvuQ1m9yHcVE4Q7zLMNzq8J2mFpLLW+zk61nMdMtKuXMOnV68HfGuxglmeNQ9DWiM6QIFwfZnem9ORlil97tw+Bdi1hV5R0sPJIs/N1UgcERERw8C4M2HpAH3KtK5T+9e2gWw8f8fy8eNruqrJWfcexBhn9zpC9iBrGPRyutvEYSfiBUnzcOilr+vwktBfU7iwBNzKoqC2eOmjZuUrVwCdmx6G/hR7XVyha8uI/zF02GD5WqQlmKfRM9KdeNtl3MHR3rihMEzrOfPZAJAXZsX47bRpUy6qwv7xebAl6P/v43UO6Huh5G7Y/Z1KubhkRtX6AHE237JznrMkKaujKQ7em2u97yBzRdfYvZslptl+arHSgvq7xzlvw== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 94506576-1990-4138-8782-08d364194dbb X-Microsoft-Exchange-Diagnostics: 1;BN1PR03MB071;2:GajrXhX0P9e3KyWwDKtduxqWF+80YJWdizPfAE3dKO/Ol7xx1V8b9kuig6p2MIib6okegbIZtrIyj4OcdJMKk0/83PbcJi2G9pgXZZAvSXVEqzXr1NsIABNDHBzaV3C5MnA3VLSUozP2cdS1Oc/+2WdDIQ6Er5WgygYsqoLYXRpWdxhP5Zz9N6WmVZ+pgRJj;3:mm4OlgHO+/KmDjviBM/sthUwYt66QeybHbiQnpoI+DbAWZZA+FkcX/jOZ6YoEFHgMnNrFDiYEDEh4qw8qm0FhIrVg/Mwa2QDUBr60aC/KcfcSvh1NdSZqpi9X3r4pG5aPtIOm4UEnz+wsfNmCTnTYpvuuw6q16rkN305l2/Iizedvnt89P2t+A5TIAbJN2GfEXfKGkVWzYIImzNEVrUO9zrw6SKwUH/aVe/q5MeOUNQ=;25:a8invMkxD/dnLeulzgow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X59VI9hwzSqlp/eKg2/sMHOGUk7Ja/WpPLZ65A64j06e1BPuUMxZlhMHNNht90wdo+eh7tSPVb7tZPbgOgM9qx7Cqxsub6ZaYZkjoQV4v0Hsj8C3ihm/YfKOu9dAslT/VP0OYe7A+eD/hp7M5ArP+4yo3832h5CrJovHMO/NfvG8UhnTrD+CFzjEEbOKQF4dVOUYNT4fti6XH00s+UUWXUIBPOaIqY680Ne4/PZLZOhdcD5MhB9QkrxeCyHI4sZoX5MvtZ5KVHk6U4hGo1dPctPOI8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(13023025)(8121501046)(13024025)(5005006)(13018025)(13017025)(13015025)(10201501046)(3002001)(6055026);SRVR:BN1PR03MB071;BCL:0;PCL:0;RULEID:;SRVR:BN1PR03MB071; X-Forefront-PRVS: 0912297777 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN1PR03MB071;23:8JyquHOZDRyPRCuNryqXepYDCxMCeFhXKhhMmVdzEj?= =?us-ascii?Q?//schuQrST3DwSBU9Wa1dzNvu9ufdu3AzacAKx43jDdRDN+eRa7TCS9jMpD1?= =?us-ascii?Q?Rs3j+87YmBbslW1N7//19hevxDfjfPHg7IY1L8sxN7vOWI0uK3XtBnmT24R8?= =?us-ascii?Q?tOAimwHlYTYF8I/RsbHUzNwtZux+kyfzDZnIMe9Xw5pmPNUbHGxP54QWcnz2?= =?us-ascii?Q?F+q0c1+Wy4eP58S73qsCsmX2ctn2WFGIKhq+voc6dh1nCpqLo0NyTPOaRj/6?= =?us-ascii?Q?I5LJPlQ6gB6WPw5B+EZ7nGriqbpw7sUy6LrCBQ1HPzwkFARnUVgf49fY6Ev8?= =?us-ascii?Q?jnInELldCtr8/0ic3KCE6AqrwSbAd5Y70MOTXmqfyauOWz1uEGyU+ZhqDB8n?= =?us-ascii?Q?AkMBOaoaVEkRXN4D0TAXCRkqcoMqFX5nl+lTT39cO4PPdoOzGulO1//BM9M5?= =?us-ascii?Q?FlZ11ZFV1AcrKVx12RKRg/yYa2teEU+4+PTE74ycVMEb+nI1GxPT80aOmN82?= =?us-ascii?Q?XqfKjWZrJz8JLCBHI2bv7mdWq2BoSPslxSRxCknAzaISmgDUjsGucRVIdwgc?= =?us-ascii?Q?YWpvfkN55eapu0ue+avMfPqh1aZC/Kxb2UH76VkeHiZuRHcs6iPIiZ/J6YwE?= =?us-ascii?Q?El5uqBx/IjniS39338sUSoEjASC7OxFcWdBdj3RnSwfDeeQuxGrWKIxdBe7T?= =?us-ascii?Q?mpTVk+w2IwUJkkmqrE+G1g4EfCRYl9296jOzVUqiwrPB47m0dogDQtO3EQW0?= =?us-ascii?Q?6GyRw99p3F3M5sQVicOeP9lRXD1Y8GjABqfXTDBJY1nQvSsNwhQvY596xfES?= =?us-ascii?Q?7cKybtOvC6DpBydtfLnY1k2S7j1iaPWoRoz7CtIAHwsKAiKVLkMVf8efI4dT?= =?us-ascii?Q?KG6mRokjcqEQ1QIZ/9Xo0WpNRS0WdOCk1/RlTjyP/ybWAAdoP6VVr2VuU57Y?= =?us-ascii?Q?yJWIaE4OZJ2sNqBzsofV63M4GoSdPbN4tcef2dA0RtDI7gqtXIxhKZh3pnVw?= =?us-ascii?Q?xTfvwWix16PrppZVEPBlUG?= X-Microsoft-Exchange-Diagnostics: 1;BN1PR03MB071;5:rAFvcZF+G02LKAlEdUWMHAd7kBIOLinWC0bRGdfhze9EEYk3/o2cgWvz5944w9aN96Ko9ADUa/hgjKrYkp+nS5NY+MlzC7XC+IKup8KSsB4C4QFyyfB8+QdSJBaQ7TaZ8a29nA/mj/OzI0aQyOp/kA==;24:J0mvJXc53AJw6AniyGqTIelf4JfJMPpjjphiwFBdA3R2JlUk6RHab/fjF/uoZj4VyLn0VlglH9i4Tt7aSB0oOMapMcsYrGc2s/LPRYtEkIE= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2016 04:00:22.8595 (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: 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