devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Huang Shijie <b32955@freescale.com>
To: broonie@kernel.org
Cc: dwmw2@infradead.org, dedekind1@gmail.com,
	computersforpeace@gmail.com, shawn.guo@linaro.org,
	kernel@pengutronix.de, b18965@freescale.com,
	b44548@freescale.com, lznuaa@gmail.com,
	linux-mtd@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org,
	devicetree@vger.kernel.org, linux-doc@vger.kernel.org,
	Huang Shijie <b32955@freescale.com>
Subject: [PATCH v3 1/8] mtd: m25p80: move the spi-nor commands to a header
Date: Fri, 30 Aug 2013 10:07:22 +0800	[thread overview]
Message-ID: <1377828449-18912-2-git-send-email-b32955@freescale.com> (raw)
In-Reply-To: <1377828449-18912-1-git-send-email-b32955@freescale.com>

Why should move the spi-nor commands to a header?

The reason is caused by the Freescale's Quadspi controller.

(0) What is the Quadspi controller?

    The Quadspi(Quad Serial Peripheral Interface) acts as an interface to
    one single or two external serial flash devices, each with up to 4
    bidirectional data lines.

(1) The Quadspi controller is driven by the LUT(Look-up Table) registers.
    The LUT registers are a look-up-table for sequences of instructions.
    A valid sequence consists of four LUT registers.

(2) The definition of the LUT register shows below:

    ---------------------------------------------------
    | INSTR1 | PAD1 | OPRND1 | INSTR0 | PAD0 | OPRND0 |
    ---------------------------------------------------

    There are several types of INSTRx, such as:
    	CMD	: the SPI NOR command.
	ADDR	: the address for the SPI NOR command.
	DUMMY	: the dummy cycles needed by the SPI NOR command.
	....

(3) We should pre-populate the LUT table before the Quadspi controller
    starts to work. Take the SPI Write Enable command for example, we
    should set the LUT table like this:

         INSTR0 = CMD; PAD0 = 0; OPRND0 = 0x06 (SPI Write Enable command)

(4) Conclusion:
    We need to move the SPI NOR commands to a separate header which can be
    used the m25p80.c and the drivers, such Quadspi controller.
    (It seems the spear-smi.c driver also needs this header.)

Signed-off-by: Huang Shijie <b32955@freescale.com>
---
 drivers/mtd/devices/m25p80.c |   42 +--------------------------------
 include/linux/mtd/spi-nor.h  |   53 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 41 deletions(-)
 create mode 100644 include/linux/mtd/spi-nor.h

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 26b14f9..299cc69 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -30,52 +30,12 @@
 #include <linux/mtd/cfi.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
+#include <linux/mtd/spi-nor.h>
 #include <linux/of_platform.h>
 
 #include <linux/spi/spi.h>
 #include <linux/spi/flash.h>
 
-/* Flash opcodes. */
-#define	OPCODE_WREN		0x06	/* Write enable */
-#define	OPCODE_RDSR		0x05	/* Read status register */
-#define	OPCODE_WRSR		0x01	/* Write status register 1 byte */
-#define	OPCODE_NORM_READ	0x03	/* Read data bytes (low frequency) */
-#define	OPCODE_FAST_READ	0x0b	/* Read data bytes (high frequency) */
-#define	OPCODE_PP		0x02	/* Page program (up to 256 bytes) */
-#define	OPCODE_BE_4K		0x20	/* Erase 4KiB block */
-#define	OPCODE_BE_4K_PMC	0xd7	/* Erase 4KiB block on PMC chips */
-#define	OPCODE_BE_32K		0x52	/* Erase 32KiB block */
-#define	OPCODE_CHIP_ERASE	0xc7	/* Erase whole flash chip */
-#define	OPCODE_SE		0xd8	/* Sector erase (usually 64KiB) */
-#define	OPCODE_RDID		0x9f	/* Read JEDEC ID */
-
-/* 4-byte address opcodes - used on Spansion and some Macronix flashes. */
-#define	OPCODE_NORM_READ_4B	0x13	/* Read data bytes (low frequency) */
-#define	OPCODE_FAST_READ_4B	0x0c	/* Read data bytes (high frequency) */
-#define	OPCODE_PP_4B		0x12	/* Page program (up to 256 bytes) */
-#define	OPCODE_SE_4B		0xdc	/* Sector erase (usually 64KiB) */
-
-/* Used for SST flashes only. */
-#define	OPCODE_BP		0x02	/* Byte program */
-#define	OPCODE_WRDI		0x04	/* Write disable */
-#define	OPCODE_AAI_WP		0xad	/* Auto address increment word program */
-
-/* Used for Macronix and Winbond flashes. */
-#define	OPCODE_EN4B		0xb7	/* Enter 4-byte mode */
-#define	OPCODE_EX4B		0xe9	/* Exit 4-byte mode */
-
-/* Used for Spansion flashes only. */
-#define	OPCODE_BRWR		0x17	/* Bank register write */
-
-/* Status Register bits. */
-#define	SR_WIP			1	/* Write in progress */
-#define	SR_WEL			2	/* Write enable latch */
-/* meaning of other SR_* bits may differ between vendors */
-#define	SR_BP0			4	/* Block protect 0 */
-#define	SR_BP1			8	/* Block protect 1 */
-#define	SR_BP2			0x10	/* Block protect 2 */
-#define	SR_SRWD			0x80	/* SR write protect */
-
 /* Define max times to check status register before we give up. */
 #define	MAX_READY_WAIT_JIFFIES	(40 * HZ)	/* M25P16 specs 40s max chip erase */
 #define	MAX_CMD_SIZE		5
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
new file mode 100644
index 0000000..f2637b9
--- /dev/null
+++ b/include/linux/mtd/spi-nor.h
@@ -0,0 +1,53 @@
+/*
+ * This header contains the SPI-NOR commands and the relative macros
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+#ifndef __LINUX_MTD_SPI_NOR_H
+#define __LINUX_MTD_SPI_NOR_H
+
+/* Flash opcodes. */
+#define	OPCODE_WREN		0x06	/* Write enable */
+#define	OPCODE_RDSR		0x05	/* Read status register */
+#define	OPCODE_WRSR		0x01	/* Write status register 1 byte */
+#define	OPCODE_NORM_READ	0x03	/* Read data bytes (low frequency) */
+#define	OPCODE_FAST_READ	0x0b	/* Read data bytes (high frequency) */
+#define	OPCODE_PP		0x02	/* Page program (up to 256 bytes) */
+#define	OPCODE_BE_4K		0x20	/* Erase 4KiB block */
+#define	OPCODE_BE_4K_PMC	0xd7	/* Erase 4KiB block on PMC chips */
+#define	OPCODE_BE_32K		0x52	/* Erase 32KiB block */
+#define	OPCODE_CHIP_ERASE	0xc7	/* Erase whole flash chip */
+#define	OPCODE_SE		0xd8	/* Sector erase (usually 64KiB) */
+#define	OPCODE_RDID		0x9f	/* Read JEDEC ID */
+
+/* 4-byte address opcodes - used on Spansion and some Macronix flashes. */
+#define	OPCODE_NORM_READ_4B	0x13	/* Read data bytes (low frequency) */
+#define	OPCODE_FAST_READ_4B	0x0c	/* Read data bytes (high frequency) */
+#define	OPCODE_PP_4B		0x12	/* Page program (up to 256 bytes) */
+#define	OPCODE_SE_4B		0xdc	/* Sector erase (usually 64KiB) */
+
+/* Used for SST flashes only. */
+#define	OPCODE_BP		0x02	/* Byte program */
+#define	OPCODE_WRDI		0x04	/* Write disable */
+#define	OPCODE_AAI_WP		0xad	/* Auto address increment word program */
+
+/* Used for Macronix and Winbond flashes. */
+#define	OPCODE_EN4B		0xb7	/* Enter 4-byte mode */
+#define	OPCODE_EX4B		0xe9	/* Exit 4-byte mode */
+
+/* Used for Spansion flashes only. */
+#define	OPCODE_BRWR		0x17	/* Bank register write */
+
+/* Status Register bits. */
+#define	SR_WIP			1	/* Write in progress */
+#define	SR_WEL			2	/* Write enable latch */
+/* meaning of other SR_* bits may differ between vendors */
+#define	SR_BP0			4	/* Block protect 0 */
+#define	SR_BP1			8	/* Block protect 1 */
+#define	SR_BP2			0x10	/* Block protect 2 */
+#define	SR_SRWD			0x80	/* SR write protect */
+
+#endif /* __LINUX_MTD_SPI_NOR_H */
-- 
1.7.1



  reply	other threads:[~2013-08-30  2:07 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-30  2:07 [PATCH v3 0/8] Add the Quadspi driver for vf610-twr Huang Shijie
2013-08-30  2:07 ` Huang Shijie [this message]
2013-08-30  2:07 ` [PATCH v3 2/8] mtd: m25p80: add support for Spansion s25fl128s chip Huang Shijie
2013-08-30  2:07 ` [PATCH v3 3/8] mtd: m25p80: add the quad-read support Huang Shijie
2013-08-30  2:07 ` [PATCH v3 4/8] mtd: m25p80: add the DDR " Huang Shijie
2013-08-30  2:07 ` [PATCH v3 5/8] spi: Add Freescale QuadSpi driver Huang Shijie
2013-09-10 18:09   ` Mark Brown
2013-09-11  2:40     ` Huang Shijie
2013-09-11 10:39       ` Mark Brown
2013-08-30  2:07 ` [PATCH v3 6/8] Documentation: add the binding file for Quadspi driver Huang Shijie
2013-08-30  2:07 ` [PATCH v3 7/8] ARM: dts: vf610: change the PAD values for Quadspi Huang Shijie
2013-08-30  2:07 ` [PATCH v3 8/8] ARM: dts: vf610-twr: Add SPI NOR support Huang Shijie
2013-09-04  2:16 ` [PATCH v3 0/8] Add the Quadspi driver for vf610-twr Huang Shijie
2013-09-04  9:55   ` Mark Brown
2013-09-04 10:29     ` Huang Shijie
2013-09-04 11:33       ` Mark Brown
2013-09-05  1:43         ` Huang Shijie
2013-09-04 13:45           ` thomas.langer
2013-09-05  2:04             ` Huang Shijie
2013-09-05  4:25               ` Gupta, Pekon
2013-09-05  5:34                 ` Huang Shijie
2013-09-05  6:32                   ` Gupta, Pekon
2013-09-05  7:45                     ` Huang Shijie
2013-09-05  9:11                       ` Gupta, Pekon
2013-09-05  9:30                         ` Huang Shijie
2013-09-05 13:50                           ` Mark Brown
2013-09-06  2:36                             ` Huang Shijie
2013-09-08 13:47                               ` Mark Brown
2013-09-09  3:07                                 ` Huang Shijie
2013-09-09 15:14                                   ` Mark Brown
2013-09-10  6:59                                     ` Huang Shijie
2013-09-10 18:07                                       ` Mark Brown
2013-09-11  2:38                                         ` Huang Shijie
2013-09-11 10:41                                           ` Mark Brown
2013-09-11 10:54                                             ` Huang Shijie
2013-09-11 11:30                                               ` Mark Brown
2013-09-11 12:26                                                 ` Gupta, Pekon
2013-09-11 12:35                                                   ` Mark Brown
2013-09-12  9:18                                                 ` Huang Shijie
2013-09-12 10:20                                                   ` Mark Brown
2013-09-13  3:30                                                     ` Huang Shijie
2013-09-12 15:32                                                       ` David Woodhouse
2013-09-12 10:39                                                   ` David Woodhouse
2013-09-12 10:56                                                     ` Gupta, Pekon
2013-09-12 11:17                                                       ` David Woodhouse
2013-09-12 11:48                                                         ` Mark Brown
2013-09-12 11:55                                                           ` Russell King - ARM Linux
2013-09-12 13:24                                                             ` Mark Brown
2013-09-12 13:25                                                             ` Ricard Wanderlof
2013-09-12 14:10                                                               ` Russell King - ARM Linux
2013-09-12 12:02                                                           ` David Woodhouse
2013-09-12 13:43                                                             ` Mark Brown
2013-09-12 14:03                                                               ` David Woodhouse
2013-09-12 14:40                                                                 ` Mark Brown
2013-09-13  3:14                                                                 ` Huang Shijie
2013-09-11 14:05                                               ` David Woodhouse
2013-09-11 15:07                                                 ` Mark Brown
     [not found]                                   ` <20130909151450 <52318953.6090405@freescale.com>
     [not found]                                     ` <52318953.6090405@freescale.com>
2013-09-12  9:50                                       ` David Woodhouse
2013-09-12 10:19                                         ` Mark Brown
2013-09-13  2:58                                         ` Huang Shijie
2013-09-12 15:22                                           ` David Woodhouse
2013-09-13  4:12                                             ` Huang Shijie
2013-09-12 16:26                                               ` David Woodhouse
2013-09-13  3:06                                                 ` Huang Shijie
2013-09-12 16:27                                               ` Fabio Estevam
     [not found]                                                 ` <CAOMZO5C54wCdEOHJmwVLk_zkh-twjis1ys20Gd1+T+ygM+A6bg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-09-13  2:21                                                   ` Huang Shijie
2013-09-12 20:56                                               ` Mark Brown
     [not found]                                                 ` <20130912205644.GW29403-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-09-13  4:55                                                   ` Huang Shijie
     [not found]                                                     ` <52329AD3.2050608-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2013-09-13 10:21                                                       ` Mark Brown
     [not found]                                                         ` <20130913102127.GD29403-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-09-16  2:40                                                           ` Huang Shijie
2013-09-16 10:19                                                             ` Mark Brown
     [not found]                                                               ` <20130916101912.GY29403-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-09-16 10:27                                                                 ` Huang Shijie
     [not found]                                                                   ` <5236DD17.5090203-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2013-09-16 11:06                                                                     ` Mark Brown
     [not found]                                                                       ` <20130916110634.GC29403-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-09-17  2:14                                                                         ` Huang Shijie
     [not found]                                                                           ` <5237BB01.3080700-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2013-09-17 10:51                                                                             ` Mark Brown
     [not found]                                                                               ` <20130917105142.GO21013-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-09-17 15:05                                                                                 ` Gerhard Sittig
2013-09-17 16:49                                                                                   ` Gerhard Sittig
2013-09-17 19:54                                                                                     ` Sourav Poddar
     [not found]                                                                                   ` <20130917150548.GE14747-kDjWylLy9wD0K7fsECOQyeGNnDKD8DIp@public.gmane.org>
2013-09-17 19:13                                                                                     ` Mark Brown
     [not found]                                                                                       ` <20130917191318.GJ21013-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-09-18 15:40                                                                                         ` David Woodhouse
     [not found]                                                                                           ` <1379518822.753.91.camel-Fexsq3y4057IgHVZqg5X0TlWvGAXklZc@public.gmane.org>
2013-09-18 16:00                                                                                             ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1377828449-18912-2-git-send-email-b32955@freescale.com \
    --to=b32955@freescale.com \
    --cc=b18965@freescale.com \
    --cc=b44548@freescale.com \
    --cc=broonie@kernel.org \
    --cc=computersforpeace@gmail.com \
    --cc=dedekind1@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dwmw2@infradead.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=lznuaa@gmail.com \
    --cc=shawn.guo@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).