[PATCH] [PATCH v5] mtd:spi-nor: Add Altera Quad SPI Driver

2015-08-20 Thread vndao
From: VIET NGA DAO 

Altera Quad SPI Controller is a soft IP which enables access to
Altera EPCS and EPCQ flash chips. This patch adds driver
for these devices.

Signed-off-by: VIET NGA DAO 

---
v5:
- Remove Micron support
- Add multiple flashes probe failure handle

v4:
- Add more flash devices support ( EPCQL and Micron)
- Remove redundant messages
- Change EPCQ_OPCODE_ID to NON_EPCS_OPCODE_ID
- Replace get_flash_name to altera_quadspi_scan
- Remove clk related parts
- Remove altera_quadspi_plat
- Change device tree reg name and remove opcode-id

v3:
- Change altera_epcq driver name to altera_quadspi for more generic name
- Implement flash name searching in altera_quadspi.c instead of spi-nor
- Edit the altra quadspi info table in spi-nor
- Remove wait_til_ready in all read,write, erase, lock, unlock functions
- Merge .h and .c into 1 file

v2:
- Change to spi_nor structure
- Add lock and unlock functions for spi_nor
- Simplify the altera_epcq_lock function
- Replace reg by compatible in device tree
---
 .../devicetree/bindings/mtd/altera-quadspi.txt |   45 ++
 drivers/mtd/spi-nor/Kconfig|8 +
 drivers/mtd/spi-nor/Makefile   |1 +
 drivers/mtd/spi-nor/altera-quadspi.c   |  557 
 drivers/mtd/spi-nor/spi-nor.c  |   18 +
 5 files changed, 629 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mtd/altera-quadspi.txt
 create mode 100644 drivers/mtd/spi-nor/altera-quadspi.c

diff --git a/Documentation/devicetree/bindings/mtd/altera-quadspi.txt 
b/Documentation/devicetree/bindings/mtd/altera-quadspi.txt
new file mode 100644
index 000..e1bcf18
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/altera-quadspi.txt
@@ -0,0 +1,45 @@
+* MTD Altera QUADSPI driver
+
+Required properties:
+- compatible: Should be "altr,quadspi-1.0"
+- reg: Address and length of the register set  for the device. It contains
+  the information of registers in the same order as described by reg-names
+- reg-names: Should contain the reg names
+  "avl_csr": Should contain the register configuration base address
+  "avl_mem": Should contain the data base address
+- #address-cells: Must be <1>.
+- #size-cells: Must be <0>.
+- flash device tree subnode, there must be a node with the following fields:
+   - compatible: Should contain the flash name:
+ 1. EPCS:   epcs16, epcs64, epcs128
+ 2. EPCQ:   epcq16, epcq32, epcq64, epcq128, epcq256, epcq512, epcq1024
+ 3. EPCQ-L: epcql256, epcql512, epcql1024
+   - #address-cells: please refer to /mtd/partition.txt
+   - #size-cells: please refer to /mtd/partition.txt
+   For partitions inside each flash, please refer to /mtd/partition.txt
+
+Example:
+
+   quadspi_controller_0: quadspi@0x180014a0 {
+   compatible = "altr,quadspi-1.0";
+   reg = <0x180014a0 0x0020>,
+ <0x1400 0x0400>;
+   reg-names = "avl_csr", "avl_mem";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   flash0: epcq256@0 {
+   compatible = "altr,epcq256";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   partition@0 {
+   /* 16 MB for raw data. */
+   label = "EPCQ Flash 0 raw data";
+   reg = <0x0 0x100>;
+   };
+   partition@100 {
+   /* 16 MB for jffs2 data. */
+   label = "EPCQ Flash 0 JFFS 2";
+   reg = <0x100 0x100>;
+   };
+   };
+   }; //end quadspi@0x180014a0 (quadspi_controller_0)
diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
index 64a4f0e..5aa1197 100644
--- a/drivers/mtd/spi-nor/Kconfig
+++ b/drivers/mtd/spi-nor/Kconfig
@@ -28,4 +28,12 @@ config SPI_FSL_QUADSPI
  This enables support for the Quad SPI controller in master mode.
  We only connect the NOR to this controller now.
 
+config SPI_ALTERA_QUADSPI
+   tristate "Altera Generic Quad SPI Controller"
+   depends on OF
+   help
+ This enables access to Altera EPCQ/EPCS flash chips,
+ used for data storage. See the driver source for the current list,
+ or to add other chips.
+
 endif # MTD_SPI_NOR
diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile
index 6a7ce14..4e700df 100644
--- 

[PATCH] [PATCH v5] mtd:spi-nor: Add Altera Quad SPI Driver

2015-08-20 Thread vndao
From: VIET NGA DAO vn...@altera.com

Altera Quad SPI Controller is a soft IP which enables access to
Altera EPCS and EPCQ flash chips. This patch adds driver
for these devices.

Signed-off-by: VIET NGA DAO vn...@altera.com

---
v5:
- Remove Micron support
- Add multiple flashes probe failure handle

v4:
- Add more flash devices support ( EPCQL and Micron)
- Remove redundant messages
- Change EPCQ_OPCODE_ID to NON_EPCS_OPCODE_ID
- Replace get_flash_name to altera_quadspi_scan
- Remove clk related parts
- Remove altera_quadspi_plat
- Change device tree reg name and remove opcode-id

v3:
- Change altera_epcq driver name to altera_quadspi for more generic name
- Implement flash name searching in altera_quadspi.c instead of spi-nor
- Edit the altra quadspi info table in spi-nor
- Remove wait_til_ready in all read,write, erase, lock, unlock functions
- Merge .h and .c into 1 file

v2:
- Change to spi_nor structure
- Add lock and unlock functions for spi_nor
- Simplify the altera_epcq_lock function
- Replace reg by compatible in device tree
---
 .../devicetree/bindings/mtd/altera-quadspi.txt |   45 ++
 drivers/mtd/spi-nor/Kconfig|8 +
 drivers/mtd/spi-nor/Makefile   |1 +
 drivers/mtd/spi-nor/altera-quadspi.c   |  557 
 drivers/mtd/spi-nor/spi-nor.c  |   18 +
 5 files changed, 629 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mtd/altera-quadspi.txt
 create mode 100644 drivers/mtd/spi-nor/altera-quadspi.c

diff --git a/Documentation/devicetree/bindings/mtd/altera-quadspi.txt 
b/Documentation/devicetree/bindings/mtd/altera-quadspi.txt
new file mode 100644
index 000..e1bcf18
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/altera-quadspi.txt
@@ -0,0 +1,45 @@
+* MTD Altera QUADSPI driver
+
+Required properties:
+- compatible: Should be altr,quadspi-1.0
+- reg: Address and length of the register set  for the device. It contains
+  the information of registers in the same order as described by reg-names
+- reg-names: Should contain the reg names
+  avl_csr: Should contain the register configuration base address
+  avl_mem: Should contain the data base address
+- #address-cells: Must be 1.
+- #size-cells: Must be 0.
+- flash device tree subnode, there must be a node with the following fields:
+   - compatible: Should contain the flash name:
+ 1. EPCS:   epcs16, epcs64, epcs128
+ 2. EPCQ:   epcq16, epcq32, epcq64, epcq128, epcq256, epcq512, epcq1024
+ 3. EPCQ-L: epcql256, epcql512, epcql1024
+   - #address-cells: please refer to /mtd/partition.txt
+   - #size-cells: please refer to /mtd/partition.txt
+   For partitions inside each flash, please refer to /mtd/partition.txt
+
+Example:
+
+   quadspi_controller_0: quadspi@0x180014a0 {
+   compatible = altr,quadspi-1.0;
+   reg = 0x180014a0 0x0020,
+ 0x1400 0x0400;
+   reg-names = avl_csr, avl_mem;
+   #address-cells = 1;
+   #size-cells = 0;
+   flash0: epcq256@0 {
+   compatible = altr,epcq256;
+   #address-cells = 1;
+   #size-cells = 1;
+   partition@0 {
+   /* 16 MB for raw data. */
+   label = EPCQ Flash 0 raw data;
+   reg = 0x0 0x100;
+   };
+   partition@100 {
+   /* 16 MB for jffs2 data. */
+   label = EPCQ Flash 0 JFFS 2;
+   reg = 0x100 0x100;
+   };
+   };
+   }; //end quadspi@0x180014a0 (quadspi_controller_0)
diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
index 64a4f0e..5aa1197 100644
--- a/drivers/mtd/spi-nor/Kconfig
+++ b/drivers/mtd/spi-nor/Kconfig
@@ -28,4 +28,12 @@ config SPI_FSL_QUADSPI
  This enables support for the Quad SPI controller in master mode.
  We only connect the NOR to this controller now.
 
+config SPI_ALTERA_QUADSPI
+   tristate Altera Generic Quad SPI Controller
+   depends on OF
+   help
+ This enables access to Altera EPCQ/EPCS flash chips,
+ used for data storage. See the driver source for the current list,
+ or to add other chips.
+
 endif # MTD_SPI_NOR
diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile
index 6a7ce14..4e700df 100644
--- 

[PATCH] [PATCH v4] mtd:spi-nor: Add Altera Quad SPI Driver

2015-06-03 Thread vndao
From: VIET NGA DAO 

Altera Quad SPI Controller is a soft IP which enables access to
Altera EPCS, EPCQ and Mircon flash chips. This patch adds driver
for these devices.

Signed-off-by: VIET NGA DAO 

---
v4:
- Add more flash devices support ( EPCQL and Micron)
- Remove redundant messages
- Change EPCQ_OPCODE_ID to NON_EPCS_OPCODE_ID
- Replace get_flash_name to altera_quadspi_scan
- Remove clk related parts
- Remove altera_quadspi_plat
- Change device tree reg name and remove opcode-id

v3:
- Change altera_epcq driver name to altera_quadspi for more generic name
- Implement flash name searching in altera_quadspi.c instead of spi-nor
- Edit the altra quadspi info table in spi-nor
- Remove wait_til_ready in all read,write, erase, lock, unlock functions
- Merge .h and .c into 1 file

v2:
- Change to spi_nor structure
- Add lock and unlock functions for spi_nor
- Simplify the altera_epcq_lock function
- Replace reg by compatible in device tree
---
 .../devicetree/bindings/mtd/altera-quadspi.txt |   49 ++
 drivers/mtd/spi-nor/Kconfig|8 +
 drivers/mtd/spi-nor/Makefile   |1 +
 drivers/mtd/spi-nor/altera-quadspi.c   |  568 
 drivers/mtd/spi-nor/spi-nor.c  |   30 +
 5 files changed, 656 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mtd/altera-quadspi.txt
 create mode 100644 drivers/mtd/spi-nor/altera-quadspi.c

diff --git a/Documentation/devicetree/bindings/mtd/altera-quadspi.txt 
b/Documentation/devicetree/bindings/mtd/altera-quadspi.txt
new file mode 100644
index 000..2873319
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/altera-quadspi.txt
@@ -0,0 +1,49 @@
+* MTD Altera QUADSPI driver
+
+Required properties:
+- compatible: Should be "altr,quadspi-1.0"
+- reg: Address and length of the register set  for the device. It contains
+  the information of registers in the same order as described by reg-names
+- reg-names: Should contain the reg names
+  "avl_csr": Should contain the register configuration base address
+  "avl_mem": Should contain the data base address
+- #address-cells: Must be <1>.
+- #size-cells: Must be <0>.
+- flash device tree subnode, there must be a node with the following fields:
+   - compatible: Should contain the flash name:
+ 1. EPCS:   epcs16, epcs64, epcs128
+ 2. EPCQ:   epcq16, epcq32, epcq64, epcq128, epcq256, epcq512, epcq1024
+ 3. EPCQ-L: epcql256, epcql512, epcql1024
+ 4. Mircon: n25q016-nonjedec, n25q032-nonjedec, n25q064-nonjedec,
+n25q128a13-nonjedec, n25q128a11-nonjedec, 
n25q256a-nonjedec,
+n25q256a11-nonjedec, n25q512a-nonjedec, 
n25q512ax3-nonjedec,
+mt25ql512-nonjedec, n25q00-nonjedec, n25q00a11-nonjedec
+   - #address-cells: please refer to /mtd/partition.txt
+   - #size-cells: please refer to /mtd/partition.txt
+   For partitions inside each flash, please refer to /mtd/partition.txt
+
+Example:
+
+   quadspi_controller_0: quadspi@0x180014a0 {
+   compatible = "altr,quadspi-1.0";
+   reg = <0x180014a0 0x0020>,
+ <0x1400 0x0400>;
+   reg-names = "avl_csr", "avl_mem";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   flash0: epcq256@0 {
+   compatible = "altr,epcq256";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   partition@0 {
+   /* 16 MB for raw data. */
+   label = "EPCQ Flash 0 raw data";
+   reg = <0x0 0x100>;
+   };
+   partition@100 {
+   /* 16 MB for jffs2 data. */
+   label = "EPCQ Flash 0 JFFS 2";
+   reg = <0x100 0x100>;
+   };
+   };
+   }; //end quadspi@0x180014a0 (quadspi_controller_0)
diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
index 64a4f0e..678dbe3 100644
--- a/drivers/mtd/spi-nor/Kconfig
+++ b/drivers/mtd/spi-nor/Kconfig
@@ -28,4 +28,12 @@ config SPI_FSL_QUADSPI
  This enables support for the Quad SPI controller in master mode.
  We only connect the NOR to this controller now.
 
+config SPI_ALTERA_QUADSPI
+   tristate "Altera Generic Quad SPI Controller"
+   depends on OF
+   help
+ This enables access to Altera 

[PATCH] [PATCH v4] mtd:spi-nor: Add Altera Quad SPI Driver

2015-06-03 Thread vndao
From: VIET NGA DAO vn...@altera.com

Altera Quad SPI Controller is a soft IP which enables access to
Altera EPCS, EPCQ and Mircon flash chips. This patch adds driver
for these devices.

Signed-off-by: VIET NGA DAO vn...@altera.com

---
v4:
- Add more flash devices support ( EPCQL and Micron)
- Remove redundant messages
- Change EPCQ_OPCODE_ID to NON_EPCS_OPCODE_ID
- Replace get_flash_name to altera_quadspi_scan
- Remove clk related parts
- Remove altera_quadspi_plat
- Change device tree reg name and remove opcode-id

v3:
- Change altera_epcq driver name to altera_quadspi for more generic name
- Implement flash name searching in altera_quadspi.c instead of spi-nor
- Edit the altra quadspi info table in spi-nor
- Remove wait_til_ready in all read,write, erase, lock, unlock functions
- Merge .h and .c into 1 file

v2:
- Change to spi_nor structure
- Add lock and unlock functions for spi_nor
- Simplify the altera_epcq_lock function
- Replace reg by compatible in device tree
---
 .../devicetree/bindings/mtd/altera-quadspi.txt |   49 ++
 drivers/mtd/spi-nor/Kconfig|8 +
 drivers/mtd/spi-nor/Makefile   |1 +
 drivers/mtd/spi-nor/altera-quadspi.c   |  568 
 drivers/mtd/spi-nor/spi-nor.c  |   30 +
 5 files changed, 656 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mtd/altera-quadspi.txt
 create mode 100644 drivers/mtd/spi-nor/altera-quadspi.c

diff --git a/Documentation/devicetree/bindings/mtd/altera-quadspi.txt 
b/Documentation/devicetree/bindings/mtd/altera-quadspi.txt
new file mode 100644
index 000..2873319
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/altera-quadspi.txt
@@ -0,0 +1,49 @@
+* MTD Altera QUADSPI driver
+
+Required properties:
+- compatible: Should be altr,quadspi-1.0
+- reg: Address and length of the register set  for the device. It contains
+  the information of registers in the same order as described by reg-names
+- reg-names: Should contain the reg names
+  avl_csr: Should contain the register configuration base address
+  avl_mem: Should contain the data base address
+- #address-cells: Must be 1.
+- #size-cells: Must be 0.
+- flash device tree subnode, there must be a node with the following fields:
+   - compatible: Should contain the flash name:
+ 1. EPCS:   epcs16, epcs64, epcs128
+ 2. EPCQ:   epcq16, epcq32, epcq64, epcq128, epcq256, epcq512, epcq1024
+ 3. EPCQ-L: epcql256, epcql512, epcql1024
+ 4. Mircon: n25q016-nonjedec, n25q032-nonjedec, n25q064-nonjedec,
+n25q128a13-nonjedec, n25q128a11-nonjedec, 
n25q256a-nonjedec,
+n25q256a11-nonjedec, n25q512a-nonjedec, 
n25q512ax3-nonjedec,
+mt25ql512-nonjedec, n25q00-nonjedec, n25q00a11-nonjedec
+   - #address-cells: please refer to /mtd/partition.txt
+   - #size-cells: please refer to /mtd/partition.txt
+   For partitions inside each flash, please refer to /mtd/partition.txt
+
+Example:
+
+   quadspi_controller_0: quadspi@0x180014a0 {
+   compatible = altr,quadspi-1.0;
+   reg = 0x180014a0 0x0020,
+ 0x1400 0x0400;
+   reg-names = avl_csr, avl_mem;
+   #address-cells = 1;
+   #size-cells = 0;
+   flash0: epcq256@0 {
+   compatible = altr,epcq256;
+   #address-cells = 1;
+   #size-cells = 1;
+   partition@0 {
+   /* 16 MB for raw data. */
+   label = EPCQ Flash 0 raw data;
+   reg = 0x0 0x100;
+   };
+   partition@100 {
+   /* 16 MB for jffs2 data. */
+   label = EPCQ Flash 0 JFFS 2;
+   reg = 0x100 0x100;
+   };
+   };
+   }; //end quadspi@0x180014a0 (quadspi_controller_0)
diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
index 64a4f0e..678dbe3 100644
--- a/drivers/mtd/spi-nor/Kconfig
+++ b/drivers/mtd/spi-nor/Kconfig
@@ -28,4 +28,12 @@ config SPI_FSL_QUADSPI
  This enables support for the Quad SPI controller in master mode.
  We only connect the NOR to this controller now.
 
+config SPI_ALTERA_QUADSPI
+   tristate Altera Generic Quad SPI Controller
+   depends on OF
+   help
+ This enables access to Altera EPCQ/EPCS/Micron 

[PATCH] [PATCH v3] mtd:spi-nor: Add Altera Quad SPI Driver

2015-03-16 Thread vndao
From: VIET NGA DAO 

Altera Quad SPI Controller is a soft IP which enables access to Altera EPCQ and
EPCS flash chips. This patch adds driver for these devices.

Signed-off-by: VIET NGA DAO 

---
v3:
- Change altera_epcq driver name to altera_quadspi for more generic name
- Implement flash name searching in altera_quadspi.c instead of spi-nor
- Edit the altra quadspi info table in spi-nor
- Remove wait_til_ready in all read,write, erase, lock, unlock functions
- Merge .h and .c into 1 file

v2:
- Change to spi_nor structure
- Add lock and unlock functions for spi_nor
- Simplify the altera_epcq_lock function
- Replace reg by compatible in device tree
---
 .../devicetree/bindings/mtd/altera_quadspi.txt |  45 ++
 drivers/mtd/spi-nor/Kconfig|   8 +
 drivers/mtd/spi-nor/Makefile   |   1 +
 drivers/mtd/spi-nor/altera_quadspi.c   | 608 +
 drivers/mtd/spi-nor/spi-nor.c  |  11 +
 5 files changed, 673 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/altera_quadspi.txt
 create mode 100644 drivers/mtd/spi-nor/altera_quadspi.c

diff --git a/Documentation/devicetree/bindings/mtd/altera_quadspi.txt 
b/Documentation/devicetree/bindings/mtd/altera_quadspi.txt
new file mode 100644
index 000..f5bdd35
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/altera_quadspi.txt
@@ -0,0 +1,45 @@
+* MTD Altera QUADSPI driver
+
+Required properties:
+- compatible: Should be "altr,quadspi-1.0"
+- reg: Address and length of the register set  for the device. It contains
+  the information of registers in the same order as described by reg-names
+- reg-names: Should contain the reg names
+  "csr_base": Should contain the register configuration base address
+  "data_base": Should contain the data base address
+- is-epcs: boolean type.
+   If present, the device contains EPCS flashes.
+   Otherwise, it contains EPCQ flashes.
+- #address-cells: Must be <1>.
+- #size-cells: Must be <0>.
+- flash device tree subnode, there must be a node with the following fields:
+   - compatible: Should contain the flash name
+   - #address-cells: please refer to /mtd/partition.txt
+   - #size-cells: please refer to /mtd/partition.txt
+   For partitions inside each flash, please refer to /mtd/partition.txt
+
+Example:
+
+   quadspi_controller_0: quadspi@0x0 {
+   compatible = "altr,quadspi-1.0";
+   reg = <0x0001 0x 0x0020>,
+   <0x 0x 0x0200>;
+   reg-names = "csr_base", "data_base";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   flash0: epcq256@0 {
+   compatible = "epcq256-nonjedec";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   partition@0 {
+   /* 16 MB for raw data. */
+   label = "EPCQ Flash 0 raw data";
+   reg = <0x0 0x100>;
+   };
+   partition@100 {
+   /* 16 MB for jffs2 data. */
+   label = "EPCQ Flash 0 JFFS 2";
+   reg = <0x100 0x100>;
+   };
+   };
+   }; //end quadspi@0x0 (quadspi_controller_0)
diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
index 64a4f0e..b9eed6d 100644
--- a/drivers/mtd/spi-nor/Kconfig
+++ b/drivers/mtd/spi-nor/Kconfig
@@ -28,4 +28,12 @@ config SPI_FSL_QUADSPI
  This enables support for the Quad SPI controller in master mode.
  We only connect the NOR to this controller now.
 
+config SPI_ALTERA_QUADSPI
+   tristate "Support Altera EPCQ/EPCS Flash chips"
+   depends on OF
+   help
+ This enables access to Altera EPCQ/EPCS flash chips, used for data
+ storage. See the driver source for the current list,
+ or to add other chips.
+
 endif # MTD_SPI_NOR
diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile
index 6a7ce14..1a36a72 100644
--- a/drivers/mtd/spi-nor/Makefile
+++ b/drivers/mtd/spi-nor/Makefile
@@ -1,2 +1,3 @@
 obj-$(CONFIG_MTD_SPI_NOR)  += spi-nor.o
 obj-$(CONFIG_SPI_FSL_QUADSPI)  += fsl-quadspi.o
+obj-$(CONFIG_SPI_ALTERA_QUADSPI)   += altera_quadspi.o
diff --git a/drivers/mtd/spi-nor/altera_quadspi.c 
b/drivers/mtd/spi-nor/altera_quadspi.c
new file mode 100644
index 000..1d178d9
--- 

[PATCH] mtd:spi-nor: Add lock and unlock callback functions to struct spi_nor

2015-03-16 Thread vndao
From: VIET NGA DAO 

This patch introduces a properly-replaceable spi_nor callback that does
flash specific lock and unlock. The existing code for spi_nor_lock and
spi_nor_unlock is moved into their own functions which are stm_lock and
stm_unlock.

Signed-off-by: VIET NGA DAO 
---
 drivers/mtd/spi-nor/spi-nor.c | 56 ---
 include/linux/mtd/spi-nor.h   |  4 
 2 files changed, 41 insertions(+), 19 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index b6a5a0c..43bb552 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -369,17 +369,13 @@ erase_err:
return ret;
 }
 
-static int spi_nor_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
+static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len)
 {
-   struct spi_nor *nor = mtd_to_spi_nor(mtd);
+   struct mtd_info *mtd = nor->mtd;
uint32_t offset = ofs;
uint8_t status_old, status_new;
int ret = 0;
 
-   ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_LOCK);
-   if (ret)
-   return ret;
-
status_old = read_sr(nor);
 
if (offset < mtd->size - (mtd->size / 2))
@@ -402,26 +398,18 @@ static int spi_nor_lock(struct mtd_info *mtd, loff_t ofs, 
uint64_t len)
(status_old & (SR_BP2 | SR_BP1 | SR_BP0))) {
write_enable(nor);
ret = write_sr(nor, status_new);
-   if (ret)
-   goto err;
}
 
-err:
-   spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_LOCK);
return ret;
 }
 
-static int spi_nor_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
+static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len)
 {
-   struct spi_nor *nor = mtd_to_spi_nor(mtd);
+   struct mtd_info *mtd = nor->mtd;
uint32_t offset = ofs;
uint8_t status_old, status_new;
int ret = 0;
 
-   ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_UNLOCK);
-   if (ret)
-   return ret;
-
status_old = read_sr(nor);
 
if (offset+len > mtd->size - (mtd->size / 64))
@@ -444,15 +432,41 @@ static int spi_nor_unlock(struct mtd_info *mtd, loff_t 
ofs, uint64_t len)
(status_old & (SR_BP2 | SR_BP1 | SR_BP0))) {
write_enable(nor);
ret = write_sr(nor, status_new);
-   if (ret)
-   goto err;
}
 
-err:
+   return ret;
+}
+
+static int spi_nor_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
+{
+   struct spi_nor *nor = mtd_to_spi_nor(mtd);
+   int ret;
+
+   ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_LOCK);
+   if (ret)
+   return ret;
+
+   ret = nor->flash_lock(nor, ofs, len);
+
spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_UNLOCK);
return ret;
 }
 
+static int spi_nor_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
+{
+   struct spi_nor *nor = mtd_to_spi_nor(mtd);
+   int ret;
+
+   ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_UNLOCK);
+   if (ret)
+   return ret;
+
+   ret = nor->flash_unlock(nor, ofs, len);
+
+   spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_LOCK);
+   return ret;
+}
+
 /* Used when the "_ext_id" is two bytes at most */
 #define INFO(_jedec_id, _ext_id, _sector_size, _n_sectors, _flags) \
((kernel_ulong_t)&(struct flash_info) { \
@@ -1045,6 +1059,10 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, 
enum read_mode mode)
 
/* nor protection support for STmicro chips */
if (JEDEC_MFR(info) == CFI_MFR_ST) {
+   nor->flash_lock = stm_lock;
+   nor->flash_unlock = stm_unlock;
+   }
+   if (nor->flash_lock && nor->flash_unlock) {
mtd->_lock = spi_nor_lock;
mtd->_unlock = spi_nor_unlock;
}
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 4720b86..e4e73d5 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -155,6 +155,8 @@ enum spi_nor_option_flags {
  * @write: [DRIVER-SPECIFIC] write data to the SPI NOR
  * @erase: [DRIVER-SPECIFIC] erase a sector of the SPI NOR
  * at the offset @offs
+ * @lock:  [FLASH-SPECIFIC] lock a region of the SPI NOR
+ * @unlock:[FLASH-SPECIFIC] unlock a region of the SPI NOR
  * @priv:  the private data
  */
 struct spi_nor {
@@ -188,6 +190,8 @@ struct spi_nor {
void (*write)(struct spi_nor *nor, loff_t to,
size_t len, size_t *retlen, const u_char *write_buf);
int (*erase)(struct spi_nor *nor, loff_t offs);
+   int (*flash_lock)(struct spi_nor *nor, loff_t ofs, uint64_t len);
+   int (*flash_unlock)(struct spi_nor *nor, loff_t ofs, uint64_t len);
 
void *priv;
 };
-- 
1.7.11.GIT

--
To 

[PATCH] [PATCH v3] mtd:spi-nor: Add Altera Quad SPI Driver

2015-03-16 Thread vndao
From: VIET NGA DAO vn...@altera.com

Altera Quad SPI Controller is a soft IP which enables access to Altera EPCQ and
EPCS flash chips. This patch adds driver for these devices.

Signed-off-by: VIET NGA DAO vn...@altera.com

---
v3:
- Change altera_epcq driver name to altera_quadspi for more generic name
- Implement flash name searching in altera_quadspi.c instead of spi-nor
- Edit the altra quadspi info table in spi-nor
- Remove wait_til_ready in all read,write, erase, lock, unlock functions
- Merge .h and .c into 1 file

v2:
- Change to spi_nor structure
- Add lock and unlock functions for spi_nor
- Simplify the altera_epcq_lock function
- Replace reg by compatible in device tree
---
 .../devicetree/bindings/mtd/altera_quadspi.txt |  45 ++
 drivers/mtd/spi-nor/Kconfig|   8 +
 drivers/mtd/spi-nor/Makefile   |   1 +
 drivers/mtd/spi-nor/altera_quadspi.c   | 608 +
 drivers/mtd/spi-nor/spi-nor.c  |  11 +
 5 files changed, 673 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/altera_quadspi.txt
 create mode 100644 drivers/mtd/spi-nor/altera_quadspi.c

diff --git a/Documentation/devicetree/bindings/mtd/altera_quadspi.txt 
b/Documentation/devicetree/bindings/mtd/altera_quadspi.txt
new file mode 100644
index 000..f5bdd35
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/altera_quadspi.txt
@@ -0,0 +1,45 @@
+* MTD Altera QUADSPI driver
+
+Required properties:
+- compatible: Should be altr,quadspi-1.0
+- reg: Address and length of the register set  for the device. It contains
+  the information of registers in the same order as described by reg-names
+- reg-names: Should contain the reg names
+  csr_base: Should contain the register configuration base address
+  data_base: Should contain the data base address
+- is-epcs: boolean type.
+   If present, the device contains EPCS flashes.
+   Otherwise, it contains EPCQ flashes.
+- #address-cells: Must be 1.
+- #size-cells: Must be 0.
+- flash device tree subnode, there must be a node with the following fields:
+   - compatible: Should contain the flash name
+   - #address-cells: please refer to /mtd/partition.txt
+   - #size-cells: please refer to /mtd/partition.txt
+   For partitions inside each flash, please refer to /mtd/partition.txt
+
+Example:
+
+   quadspi_controller_0: quadspi@0x0 {
+   compatible = altr,quadspi-1.0;
+   reg = 0x0001 0x 0x0020,
+   0x 0x 0x0200;
+   reg-names = csr_base, data_base;
+   #address-cells = 1;
+   #size-cells = 0;
+   flash0: epcq256@0 {
+   compatible = epcq256-nonjedec;
+   #address-cells = 1;
+   #size-cells = 1;
+   partition@0 {
+   /* 16 MB for raw data. */
+   label = EPCQ Flash 0 raw data;
+   reg = 0x0 0x100;
+   };
+   partition@100 {
+   /* 16 MB for jffs2 data. */
+   label = EPCQ Flash 0 JFFS 2;
+   reg = 0x100 0x100;
+   };
+   };
+   }; //end quadspi@0x0 (quadspi_controller_0)
diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
index 64a4f0e..b9eed6d 100644
--- a/drivers/mtd/spi-nor/Kconfig
+++ b/drivers/mtd/spi-nor/Kconfig
@@ -28,4 +28,12 @@ config SPI_FSL_QUADSPI
  This enables support for the Quad SPI controller in master mode.
  We only connect the NOR to this controller now.
 
+config SPI_ALTERA_QUADSPI
+   tristate Support Altera EPCQ/EPCS Flash chips
+   depends on OF
+   help
+ This enables access to Altera EPCQ/EPCS flash chips, used for data
+ storage. See the driver source for the current list,
+ or to add other chips.
+
 endif # MTD_SPI_NOR
diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile
index 6a7ce14..1a36a72 100644
--- a/drivers/mtd/spi-nor/Makefile
+++ b/drivers/mtd/spi-nor/Makefile
@@ -1,2 +1,3 @@
 obj-$(CONFIG_MTD_SPI_NOR)  += spi-nor.o
 obj-$(CONFIG_SPI_FSL_QUADSPI)  += fsl-quadspi.o
+obj-$(CONFIG_SPI_ALTERA_QUADSPI)   += altera_quadspi.o
diff --git a/drivers/mtd/spi-nor/altera_quadspi.c 
b/drivers/mtd/spi-nor/altera_quadspi.c
new file mode 100644
index 000..1d178d9
--- /dev/null
+++ 

[PATCH] mtd:spi-nor: Add lock and unlock callback functions to struct spi_nor

2015-03-16 Thread vndao
From: VIET NGA DAO vn...@altera.com

This patch introduces a properly-replaceable spi_nor callback that does
flash specific lock and unlock. The existing code for spi_nor_lock and
spi_nor_unlock is moved into their own functions which are stm_lock and
stm_unlock.

Signed-off-by: VIET NGA DAO vn...@altera.com
---
 drivers/mtd/spi-nor/spi-nor.c | 56 ---
 include/linux/mtd/spi-nor.h   |  4 
 2 files changed, 41 insertions(+), 19 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index b6a5a0c..43bb552 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -369,17 +369,13 @@ erase_err:
return ret;
 }
 
-static int spi_nor_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
+static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len)
 {
-   struct spi_nor *nor = mtd_to_spi_nor(mtd);
+   struct mtd_info *mtd = nor-mtd;
uint32_t offset = ofs;
uint8_t status_old, status_new;
int ret = 0;
 
-   ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_LOCK);
-   if (ret)
-   return ret;
-
status_old = read_sr(nor);
 
if (offset  mtd-size - (mtd-size / 2))
@@ -402,26 +398,18 @@ static int spi_nor_lock(struct mtd_info *mtd, loff_t ofs, 
uint64_t len)
(status_old  (SR_BP2 | SR_BP1 | SR_BP0))) {
write_enable(nor);
ret = write_sr(nor, status_new);
-   if (ret)
-   goto err;
}
 
-err:
-   spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_LOCK);
return ret;
 }
 
-static int spi_nor_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
+static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len)
 {
-   struct spi_nor *nor = mtd_to_spi_nor(mtd);
+   struct mtd_info *mtd = nor-mtd;
uint32_t offset = ofs;
uint8_t status_old, status_new;
int ret = 0;
 
-   ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_UNLOCK);
-   if (ret)
-   return ret;
-
status_old = read_sr(nor);
 
if (offset+len  mtd-size - (mtd-size / 64))
@@ -444,15 +432,41 @@ static int spi_nor_unlock(struct mtd_info *mtd, loff_t 
ofs, uint64_t len)
(status_old  (SR_BP2 | SR_BP1 | SR_BP0))) {
write_enable(nor);
ret = write_sr(nor, status_new);
-   if (ret)
-   goto err;
}
 
-err:
+   return ret;
+}
+
+static int spi_nor_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
+{
+   struct spi_nor *nor = mtd_to_spi_nor(mtd);
+   int ret;
+
+   ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_LOCK);
+   if (ret)
+   return ret;
+
+   ret = nor-flash_lock(nor, ofs, len);
+
spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_UNLOCK);
return ret;
 }
 
+static int spi_nor_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
+{
+   struct spi_nor *nor = mtd_to_spi_nor(mtd);
+   int ret;
+
+   ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_UNLOCK);
+   if (ret)
+   return ret;
+
+   ret = nor-flash_unlock(nor, ofs, len);
+
+   spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_LOCK);
+   return ret;
+}
+
 /* Used when the _ext_id is two bytes at most */
 #define INFO(_jedec_id, _ext_id, _sector_size, _n_sectors, _flags) \
((kernel_ulong_t)(struct flash_info) { \
@@ -1045,6 +1059,10 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, 
enum read_mode mode)
 
/* nor protection support for STmicro chips */
if (JEDEC_MFR(info) == CFI_MFR_ST) {
+   nor-flash_lock = stm_lock;
+   nor-flash_unlock = stm_unlock;
+   }
+   if (nor-flash_lock  nor-flash_unlock) {
mtd-_lock = spi_nor_lock;
mtd-_unlock = spi_nor_unlock;
}
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 4720b86..e4e73d5 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -155,6 +155,8 @@ enum spi_nor_option_flags {
  * @write: [DRIVER-SPECIFIC] write data to the SPI NOR
  * @erase: [DRIVER-SPECIFIC] erase a sector of the SPI NOR
  * at the offset @offs
+ * @lock:  [FLASH-SPECIFIC] lock a region of the SPI NOR
+ * @unlock:[FLASH-SPECIFIC] unlock a region of the SPI NOR
  * @priv:  the private data
  */
 struct spi_nor {
@@ -188,6 +190,8 @@ struct spi_nor {
void (*write)(struct spi_nor *nor, loff_t to,
size_t len, size_t *retlen, const u_char *write_buf);
int (*erase)(struct spi_nor *nor, loff_t offs);
+   int (*flash_lock)(struct spi_nor *nor, loff_t ofs, uint64_t len);
+   int (*flash_unlock)(struct spi_nor *nor, loff_t ofs, uint64_t len);
 
void *priv;
 };
-- 
1.7.11.GIT

--
To 

[PATCH mtd] mtd:devices: Add Altera EPCQ Driver

2014-12-18 Thread vndao
From: Viet Nga Dao 

Altera EPCQ Controller is a soft IP which enables access to Altera EPCQ and
EPCS flash chips. This patch adds driver for these devices.

Signed-off-by: Viet Nga Dao 
---
 .../devicetree/bindings/mtd/altera_epcq.txt|   45 ++
 drivers/mtd/devices/Kconfig|   12 +
 drivers/mtd/devices/Makefile   |2 +-
 drivers/mtd/devices/altera_epcq.c  |  804 
 drivers/mtd/devices/altera_epcq.h  |  130 
 5 files changed, 992 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mtd/altera_epcq.txt
 create mode 100644 drivers/mtd/devices/altera_epcq.c
 create mode 100644 drivers/mtd/devices/altera_epcq.h

diff --git a/Documentation/devicetree/bindings/mtd/altera_epcq.txt 
b/Documentation/devicetree/bindings/mtd/altera_epcq.txt
new file mode 100644
index 000..d14f50e
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/altera_epcq.txt
@@ -0,0 +1,45 @@
+* MTD Altera EPCQ driver
+
+Required properties:
+- compatible: Should be "altr,epcq-1.0"
+- reg: Address and length of the register set  for the device. It contains
+  the information of registers in the same order as described by reg-names
+- reg-names: Should contain the reg names
+  "csr_base": Should contain the register configuration base address
+  "data_base": Should contain the data base address
+- is-epcs: boolean type.
+   If present, the device contains EPCS flashes.
+   Otherwise, it contains EPCQ flashes.
+- #address-cells: Must be <1>.
+- #size-cells: Must be <0>.
+- flash device tree subnode, there must be a node with the following fields:
+   - reg: Should contain the flash id
+   - #address-cells: please refer to /mtd/partition.txt
+   - #size-cells: please refer to /mtd/partition.txt
+   For partitions inside each flash, please refer to /mtd/partition.txt
+
+Example:
+
+   epcq_controller_0: epcq@0x0 {
+   compatible = "altr,epcq-1.0";
+   reg = <0x0001 0x 0x0020>,
+   <0x 0x 0x0200>;
+   reg-names = "csr_base", "data_base";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   flash0: epcq256@0 {
+   reg = <0>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   partition@0 {
+   /* 16 MB for raw data. */
+   label = "EPCQ Flash 0 raw data";
+   reg = <0x0 0x100>;
+   };
+   partition@100 {
+   /* 16 MB for jffs2 data. */
+   label = "EPCQ Flash 0 JFFS 2";
+   reg = <0x100 0x100>;
+   };
+   };
+   }; //end epcq@0x0 (epcq_controller_0)
diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
index c49d0b1..020b864 100644
--- a/drivers/mtd/devices/Kconfig
+++ b/drivers/mtd/devices/Kconfig
@@ -218,6 +218,18 @@ config MTD_ST_SPI_FSM
  SPI Fast Sequence Mode (FSM) Serial Flash Controller and support
  for a subset of connected Serial Flash devices.
 
+config MTD_ALTERA_EPCQ
+   tristate "Support Altera EPCQ/EPCS Flash chips"
+   depends on OF
+   help
+ This enables access to Altera EPCQ/EPCS flash chips, used for data
+ storage. See the driver source for the current list,
+ or to add other chips.
+
+ If you want to compile this driver as a module ( = code which can be
+ inserted in and removed from the running kernel whenever you want),
+ say M here and read .
+
 if MTD_DOCG3
 config BCH_CONST_M
default 14
diff --git a/drivers/mtd/devices/Makefile b/drivers/mtd/devices/Makefile
index f0b0e61..b429c4d 100644
--- a/drivers/mtd/devices/Makefile
+++ b/drivers/mtd/devices/Makefile
@@ -16,6 +16,6 @@ obj-$(CONFIG_MTD_SPEAR_SMI)   += spear_smi.o
 obj-$(CONFIG_MTD_SST25L)   += sst25l.o
 obj-$(CONFIG_MTD_BCM47XXSFLASH)+= bcm47xxsflash.o
 obj-$(CONFIG_MTD_ST_SPI_FSM)+= st_spi_fsm.o
-
+obj-$(CONFIG_MTD_ALTERA_EPCQ)  += altera_epcq.o
 
 CFLAGS_docg3.o += -I$(src)
diff --git a/drivers/mtd/devices/altera_epcq.c 
b/drivers/mtd/devices/altera_epcq.c
new file mode 100644
index 000..09213d5
--- /dev/null
+++ b/drivers/mtd/devices/altera_epcq.c
@@ -0,0 +1,804 @@
+/*
+ * Copyright (C) 2014 Altera 

[PATCH mtd] mtd:devices: Add Altera EPCQ Driver

2014-12-18 Thread vndao
From: Viet Nga Dao vn...@altera.com

Altera EPCQ Controller is a soft IP which enables access to Altera EPCQ and
EPCS flash chips. This patch adds driver for these devices.

Signed-off-by: Viet Nga Dao vn...@altera.com
---
 .../devicetree/bindings/mtd/altera_epcq.txt|   45 ++
 drivers/mtd/devices/Kconfig|   12 +
 drivers/mtd/devices/Makefile   |2 +-
 drivers/mtd/devices/altera_epcq.c  |  804 
 drivers/mtd/devices/altera_epcq.h  |  130 
 5 files changed, 992 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mtd/altera_epcq.txt
 create mode 100644 drivers/mtd/devices/altera_epcq.c
 create mode 100644 drivers/mtd/devices/altera_epcq.h

diff --git a/Documentation/devicetree/bindings/mtd/altera_epcq.txt 
b/Documentation/devicetree/bindings/mtd/altera_epcq.txt
new file mode 100644
index 000..d14f50e
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/altera_epcq.txt
@@ -0,0 +1,45 @@
+* MTD Altera EPCQ driver
+
+Required properties:
+- compatible: Should be altr,epcq-1.0
+- reg: Address and length of the register set  for the device. It contains
+  the information of registers in the same order as described by reg-names
+- reg-names: Should contain the reg names
+  csr_base: Should contain the register configuration base address
+  data_base: Should contain the data base address
+- is-epcs: boolean type.
+   If present, the device contains EPCS flashes.
+   Otherwise, it contains EPCQ flashes.
+- #address-cells: Must be 1.
+- #size-cells: Must be 0.
+- flash device tree subnode, there must be a node with the following fields:
+   - reg: Should contain the flash id
+   - #address-cells: please refer to /mtd/partition.txt
+   - #size-cells: please refer to /mtd/partition.txt
+   For partitions inside each flash, please refer to /mtd/partition.txt
+
+Example:
+
+   epcq_controller_0: epcq@0x0 {
+   compatible = altr,epcq-1.0;
+   reg = 0x0001 0x 0x0020,
+   0x 0x 0x0200;
+   reg-names = csr_base, data_base;
+   #address-cells = 1;
+   #size-cells = 0;
+   flash0: epcq256@0 {
+   reg = 0;
+   #address-cells = 1;
+   #size-cells = 1;
+   partition@0 {
+   /* 16 MB for raw data. */
+   label = EPCQ Flash 0 raw data;
+   reg = 0x0 0x100;
+   };
+   partition@100 {
+   /* 16 MB for jffs2 data. */
+   label = EPCQ Flash 0 JFFS 2;
+   reg = 0x100 0x100;
+   };
+   };
+   }; //end epcq@0x0 (epcq_controller_0)
diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
index c49d0b1..020b864 100644
--- a/drivers/mtd/devices/Kconfig
+++ b/drivers/mtd/devices/Kconfig
@@ -218,6 +218,18 @@ config MTD_ST_SPI_FSM
  SPI Fast Sequence Mode (FSM) Serial Flash Controller and support
  for a subset of connected Serial Flash devices.
 
+config MTD_ALTERA_EPCQ
+   tristate Support Altera EPCQ/EPCS Flash chips
+   depends on OF
+   help
+ This enables access to Altera EPCQ/EPCS flash chips, used for data
+ storage. See the driver source for the current list,
+ or to add other chips.
+
+ If you want to compile this driver as a module ( = code which can be
+ inserted in and removed from the running kernel whenever you want),
+ say M here and read file:Documentation/kbuild/modules.txt.
+
 if MTD_DOCG3
 config BCH_CONST_M
default 14
diff --git a/drivers/mtd/devices/Makefile b/drivers/mtd/devices/Makefile
index f0b0e61..b429c4d 100644
--- a/drivers/mtd/devices/Makefile
+++ b/drivers/mtd/devices/Makefile
@@ -16,6 +16,6 @@ obj-$(CONFIG_MTD_SPEAR_SMI)   += spear_smi.o
 obj-$(CONFIG_MTD_SST25L)   += sst25l.o
 obj-$(CONFIG_MTD_BCM47XXSFLASH)+= bcm47xxsflash.o
 obj-$(CONFIG_MTD_ST_SPI_FSM)+= st_spi_fsm.o
-
+obj-$(CONFIG_MTD_ALTERA_EPCQ)  += altera_epcq.o
 
 CFLAGS_docg3.o += -I$(src)
diff --git a/drivers/mtd/devices/altera_epcq.c 
b/drivers/mtd/devices/altera_epcq.c
new file mode 100644
index 000..09213d5
--- /dev/null
+++ b/drivers/mtd/devices/altera_epcq.c
@@ -0,0 +1,804 @@
+/*

[net-next] net: phy: Adding SGMII support for Marvell 88ee1145 driver

2014-10-23 Thread vndao
From: Viet Nga Dao 

Additional code to m88e1145_config_init function to allow the driver to
support SGMII mode.

Signed-off-by: Viet Nga Dao 
---
 drivers/net/phy/marvell.c |   19 +++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index bd37e45..b14cb10 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -50,9 +50,13 @@
 #define MII_M1011_PHY_SCR  0x10
 #define MII_M1011_PHY_SCR_AUTO_CROSS   0x0060
 
+#define MII_M1145_PHY_EXT_SR   0x1b
 #define MII_M1145_PHY_EXT_CR   0x14
 #define MII_M1145_RGMII_RX_DELAY   0x0080
 #define MII_M1145_RGMII_TX_DELAY   0x0002
+#define MII_M1145_HWCFG_MODE_SGMII_NO_CLK  0x4
+#define MII_M1145_HWCFG_MODE_MASK  0xf
+#define MII_M1145_HWCFG_FIBER_COPPER_AUTO  0x8000
 
 #define MII_M_PHY_LED_CONTROL  0x18
 #define MII_M_PHY_LED_DIRECT   0x4100
@@ -620,6 +624,7 @@ static int m88e1149_config_init(struct phy_device *phydev)
 static int m88e1145_config_init(struct phy_device *phydev)
 {
int err;
+   int temp;
 
/* Take care of errata E0 & E1 */
err = phy_write(phydev, 0x1d, 0x001b);
@@ -676,6 +681,20 @@ static int m88e1145_config_init(struct phy_device *phydev)
}
}
 
+   if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
+   temp = phy_read(phydev, MII_M1145_PHY_EXT_SR);
+   if (temp < 0)
+   return temp;
+
+   temp &= ~(MII_M1145_HWCFG_MODE_MASK);
+   temp |= MII_M1145_HWCFG_MODE_SGMII_NO_CLK;
+   temp |= MII_M1145_HWCFG_FIBER_COPPER_AUTO;
+
+   err = phy_write(phydev, MII_M1145_PHY_EXT_SR, temp);
+   if (err < 0)
+   return err;
+   }
+
err = marvell_of_reg_init(phydev);
if (err < 0)
return err;
-- 
1.7.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[net-next] net: phy: Adding SGMII support for Marvell 88ee1145 driver

2014-10-23 Thread vndao
From: Viet Nga Dao 

Additional code to m88e1145_config_init function to allow the driver to
support SGMII mode.

Signed-off-by: Viet Nga Dao 
---
 drivers/net/phy/marvell.c |   19 +++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index bd37e45..b14cb10 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -50,9 +50,13 @@
 #define MII_M1011_PHY_SCR  0x10
 #define MII_M1011_PHY_SCR_AUTO_CROSS   0x0060
 
+#define MII_M1145_PHY_EXT_SR   0x1b
 #define MII_M1145_PHY_EXT_CR   0x14
 #define MII_M1145_RGMII_RX_DELAY   0x0080
 #define MII_M1145_RGMII_TX_DELAY   0x0002
+#define MII_M1145_HWCFG_MODE_SGMII_NO_CLK  0x4
+#define MII_M1145_HWCFG_MODE_MASK  0xf
+#define MII_M1145_HWCFG_FIBER_COPPER_AUTO  0x8000
 
 #define MII_M_PHY_LED_CONTROL  0x18
 #define MII_M_PHY_LED_DIRECT   0x4100
@@ -620,6 +624,7 @@ static int m88e1149_config_init(struct phy_device *phydev)
 static int m88e1145_config_init(struct phy_device *phydev)
 {
int err;
+   int temp;
 
/* Take care of errata E0 & E1 */
err = phy_write(phydev, 0x1d, 0x001b);
@@ -676,6 +681,20 @@ static int m88e1145_config_init(struct phy_device *phydev)
}
}
 
+   if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
+   temp = phy_read(phydev, MII_M1145_PHY_EXT_SR);
+   if (temp < 0)
+   return temp;
+
+   temp &= ~(MII_M1145_HWCFG_MODE_MASK);
+   temp |= MII_M1145_HWCFG_MODE_SGMII_NO_CLK;
+   temp |= MII_M1145_HWCFG_FIBER_COPPER_AUTO;
+
+   err = phy_write(phydev, MII_M1145_PHY_EXT_SR, temp);
+   if (err < 0)
+   return err;
+   }
+
err = marvell_of_reg_init(phydev);
if (err < 0)
return err;
-- 
1.7.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[net-next] net: phy: Adding SGMII support for Marvell 88ee1145 driver

2014-10-23 Thread vndao
From: Viet Nga Dao vn...@altera.com

Additional code to m88e1145_config_init function to allow the driver to
support SGMII mode.

Signed-off-by: Viet Nga Dao vn...@altera.com
---
 drivers/net/phy/marvell.c |   19 +++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index bd37e45..b14cb10 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -50,9 +50,13 @@
 #define MII_M1011_PHY_SCR  0x10
 #define MII_M1011_PHY_SCR_AUTO_CROSS   0x0060
 
+#define MII_M1145_PHY_EXT_SR   0x1b
 #define MII_M1145_PHY_EXT_CR   0x14
 #define MII_M1145_RGMII_RX_DELAY   0x0080
 #define MII_M1145_RGMII_TX_DELAY   0x0002
+#define MII_M1145_HWCFG_MODE_SGMII_NO_CLK  0x4
+#define MII_M1145_HWCFG_MODE_MASK  0xf
+#define MII_M1145_HWCFG_FIBER_COPPER_AUTO  0x8000
 
 #define MII_M_PHY_LED_CONTROL  0x18
 #define MII_M_PHY_LED_DIRECT   0x4100
@@ -620,6 +624,7 @@ static int m88e1149_config_init(struct phy_device *phydev)
 static int m88e1145_config_init(struct phy_device *phydev)
 {
int err;
+   int temp;
 
/* Take care of errata E0  E1 */
err = phy_write(phydev, 0x1d, 0x001b);
@@ -676,6 +681,20 @@ static int m88e1145_config_init(struct phy_device *phydev)
}
}
 
+   if (phydev-interface == PHY_INTERFACE_MODE_SGMII) {
+   temp = phy_read(phydev, MII_M1145_PHY_EXT_SR);
+   if (temp  0)
+   return temp;
+
+   temp = ~(MII_M1145_HWCFG_MODE_MASK);
+   temp |= MII_M1145_HWCFG_MODE_SGMII_NO_CLK;
+   temp |= MII_M1145_HWCFG_FIBER_COPPER_AUTO;
+
+   err = phy_write(phydev, MII_M1145_PHY_EXT_SR, temp);
+   if (err  0)
+   return err;
+   }
+
err = marvell_of_reg_init(phydev);
if (err  0)
return err;
-- 
1.7.7.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[net-next] net: phy: Adding SGMII support for Marvell 88ee1145 driver

2014-10-23 Thread vndao
From: Viet Nga Dao vn...@altera.com

Additional code to m88e1145_config_init function to allow the driver to
support SGMII mode.

Signed-off-by: Viet Nga Dao vn...@altera.com
---
 drivers/net/phy/marvell.c |   19 +++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index bd37e45..b14cb10 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -50,9 +50,13 @@
 #define MII_M1011_PHY_SCR  0x10
 #define MII_M1011_PHY_SCR_AUTO_CROSS   0x0060
 
+#define MII_M1145_PHY_EXT_SR   0x1b
 #define MII_M1145_PHY_EXT_CR   0x14
 #define MII_M1145_RGMII_RX_DELAY   0x0080
 #define MII_M1145_RGMII_TX_DELAY   0x0002
+#define MII_M1145_HWCFG_MODE_SGMII_NO_CLK  0x4
+#define MII_M1145_HWCFG_MODE_MASK  0xf
+#define MII_M1145_HWCFG_FIBER_COPPER_AUTO  0x8000
 
 #define MII_M_PHY_LED_CONTROL  0x18
 #define MII_M_PHY_LED_DIRECT   0x4100
@@ -620,6 +624,7 @@ static int m88e1149_config_init(struct phy_device *phydev)
 static int m88e1145_config_init(struct phy_device *phydev)
 {
int err;
+   int temp;
 
/* Take care of errata E0  E1 */
err = phy_write(phydev, 0x1d, 0x001b);
@@ -676,6 +681,20 @@ static int m88e1145_config_init(struct phy_device *phydev)
}
}
 
+   if (phydev-interface == PHY_INTERFACE_MODE_SGMII) {
+   temp = phy_read(phydev, MII_M1145_PHY_EXT_SR);
+   if (temp  0)
+   return temp;
+
+   temp = ~(MII_M1145_HWCFG_MODE_MASK);
+   temp |= MII_M1145_HWCFG_MODE_SGMII_NO_CLK;
+   temp |= MII_M1145_HWCFG_FIBER_COPPER_AUTO;
+
+   err = phy_write(phydev, MII_M1145_PHY_EXT_SR, temp);
+   if (err  0)
+   return err;
+   }
+
err = marvell_of_reg_init(phydev);
if (err  0)
return err;
-- 
1.7.7.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/