diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-09-09 17:48:21 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-09-09 17:48:21 -0400 |
commit | a59e57da49f7c3f3de8cf4b7568a0c6c82f5b242 (patch) | |
tree | 521ccae942f9d226409cadb5503f74f78858e0af | |
parent | 0ce5c79f384b9f730cf03a1e464673ae906e7c89 (diff) | |
parent | d1f936d73683a540227cca3aaecdb68b6c3d53c5 (diff) |
Merge tag 'for-linus-20170904' of git://git.infradead.org/linux-mtd
Pull MTD updates from Boris Brezillon:
"General updates:
- Constify pci_device_id in various drivers
- Constify device_type
- Remove pad control code from the Gemini driver
- Use %pOF to print OF node full_name
- Various fixes in the physmap_of driver
- Remove unused vars in mtdswap
- Check devm_kzalloc() return value in the spear_smi driver
- Check clk_prepare_enable() return code in the st_spi_fsm driver
- Create per MTD device debugfs enties
NAND updates, from Boris Brezillon:
- Fix memory leaks in the core
- Remove unused NAND locking support
- Rename nand.h into rawnand.h (preparing support for spi NANDs)
- Use NAND_MAX_ID_LEN where appropriate
- Fix support for 20nm Hynix chips
- Fix support for Samsung and Hynix SLC NANDs
- Various cleanup, improvements and fixes in the qcom driver
- Fixes for bugs detected by various static code analysis tools
- Fix mxc ooblayout definition
- Add a new part_parsers to tmio and sharpsl platform data in order
to define a custom list of partition parsers
- Request the reset line in exclusive mode in the sunxi driver
- Fix a build error in the orion-nand driver when compiled for ARMv4
- Allow 64-bit mvebu platforms to select the PXA3XX driver
SPI NOR updates, from Cyrille Pitchen and Marek Vasut:
- add support to the JEDEC JESD216B specification (SFDP tables).
- add support to the Intel Denverton SPI flash controller.
- fix error recovery for Spansion/Cypress SPI NOR memories.
- fix 4-byte address management for the Aspeed SPI controller.
- add support to some Microchip SST26 memory parts
- remove unneeded pinctrl header Write a message for tag:"
* tag 'for-linus-20170904' of git://git.infradead.org/linux-mtd: (74 commits)
mtd: nand: complain loudly when chip->bits_per_cell is not correctly initialized
mtd: nand: make Samsung SLC NAND usable again
mtd: nand: tmio: Register partitions using the parsers
mfd: tmio: Add partition parsers platform data
mtd: nand: sharpsl: Register partitions using the parsers
mtd: nand: sharpsl: Add partition parsers platform data
mtd: nand: qcom: Support for IPQ8074 QPIC NAND controller
mtd: nand: qcom: support for IPQ4019 QPIC NAND controller
dt-bindings: qcom_nandc: IPQ8074 QPIC NAND documentation
dt-bindings: qcom_nandc: IPQ4019 QPIC NAND documentation
dt-bindings: qcom_nandc: fix the ipq806x device tree example
mtd: nand: qcom: support for different DEV_CMD register offsets
mtd: nand: qcom: QPIC data descriptors handling
mtd: nand: qcom: enable BAM or ADM mode
mtd: nand: qcom: erased codeword detection configuration
mtd: nand: qcom: support for read location registers
mtd: nand: qcom: support for passing flags in DMA helper functions
mtd: nand: qcom: add BAM DMA descriptor handling
mtd: nand: qcom: allocate BAM transaction
mtd: nand: qcom: DMA mapping support for register read buffer
...
162 files changed, 2113 insertions, 765 deletions
diff --git a/Documentation/devicetree/bindings/mtd/qcom_nandc.txt b/Documentation/devicetree/bindings/mtd/qcom_nandc.txt index 70dd5118a324..73d336befa08 100644 --- a/Documentation/devicetree/bindings/mtd/qcom_nandc.txt +++ b/Documentation/devicetree/bindings/mtd/qcom_nandc.txt | |||
@@ -1,11 +1,20 @@ | |||
1 | * Qualcomm NAND controller | 1 | * Qualcomm NAND controller |
2 | 2 | ||
3 | Required properties: | 3 | Required properties: |
4 | - compatible: should be "qcom,ipq806x-nand" | 4 | - compatible: must be one of the following: |
5 | * "qcom,ipq806x-nand" - for EBI2 NAND controller being used in IPQ806x | ||
6 | SoC and it uses ADM DMA | ||
7 | * "qcom,ipq4019-nand" - for QPIC NAND controller v1.4.0 being used in | ||
8 | IPQ4019 SoC and it uses BAM DMA | ||
9 | * "qcom,ipq8074-nand" - for QPIC NAND controller v1.5.0 being used in | ||
10 | IPQ8074 SoC and it uses BAM DMA | ||
11 | |||
5 | - reg: MMIO address range | 12 | - reg: MMIO address range |
6 | - clocks: must contain core clock and always on clock | 13 | - clocks: must contain core clock and always on clock |
7 | - clock-names: must contain "core" for the core clock and "aon" for the | 14 | - clock-names: must contain "core" for the core clock and "aon" for the |
8 | always on clock | 15 | always on clock |
16 | |||
17 | EBI2 specific properties: | ||
9 | - dmas: DMA specifier, consisting of a phandle to the ADM DMA | 18 | - dmas: DMA specifier, consisting of a phandle to the ADM DMA |
10 | controller node and the channel number to be used for | 19 | controller node and the channel number to be used for |
11 | NAND. Refer to dma.txt and qcom_adm.txt for more details | 20 | NAND. Refer to dma.txt and qcom_adm.txt for more details |
@@ -16,6 +25,12 @@ Required properties: | |||
16 | - qcom,data-crci: must contain the ADM data type CRCI block instance | 25 | - qcom,data-crci: must contain the ADM data type CRCI block instance |
17 | number specified for the NAND controller on the given | 26 | number specified for the NAND controller on the given |
18 | platform | 27 | platform |
28 | |||
29 | QPIC specific properties: | ||
30 | - dmas: DMA specifier, consisting of a phandle to the BAM DMA | ||
31 | and the channel number to be used for NAND. Refer to | ||
32 | dma.txt, qcom_bam_dma.txt for more details | ||
33 | - dma-names: must contain all 3 channel names : "tx", "rx", "cmd" | ||
19 | - #address-cells: <1> - subnodes give the chip-select number | 34 | - #address-cells: <1> - subnodes give the chip-select number |
20 | - #size-cells: <0> | 35 | - #size-cells: <0> |
21 | 36 | ||
@@ -26,7 +41,6 @@ chip-selects which (may) contain NAND flash chips. Their properties are as | |||
26 | follows. | 41 | follows. |
27 | 42 | ||
28 | Required properties: | 43 | Required properties: |
29 | - compatible: should contain "qcom,nandcs" | ||
30 | - reg: a single integer representing the chip-select | 44 | - reg: a single integer representing the chip-select |
31 | number (e.g., 0, 1, 2, etc.) | 45 | number (e.g., 0, 1, 2, etc.) |
32 | - #address-cells: see partition.txt | 46 | - #address-cells: see partition.txt |
@@ -43,8 +57,8 @@ partition.txt for more detail. | |||
43 | 57 | ||
44 | Example: | 58 | Example: |
45 | 59 | ||
46 | nand@1ac00000 { | 60 | nand-controller@1ac00000 { |
47 | compatible = "qcom,ebi2-nandc"; | 61 | compatible = "qcom,ipq806x-nand"; |
48 | reg = <0x1ac00000 0x800>; | 62 | reg = <0x1ac00000 0x800>; |
49 | 63 | ||
50 | clocks = <&gcc EBI2_CLK>, | 64 | clocks = <&gcc EBI2_CLK>, |
@@ -59,8 +73,7 @@ nand@1ac00000 { | |||
59 | #address-cells = <1>; | 73 | #address-cells = <1>; |
60 | #size-cells = <0>; | 74 | #size-cells = <0>; |
61 | 75 | ||
62 | nandcs@0 { | 76 | nand@0 { |
63 | compatible = "qcom,nandcs"; | ||
64 | reg = <0>; | 77 | reg = <0>; |
65 | 78 | ||
66 | nand-ecc-strength = <4>; | 79 | nand-ecc-strength = <4>; |
@@ -84,3 +97,43 @@ nand@1ac00000 { | |||
84 | }; | 97 | }; |
85 | }; | 98 | }; |
86 | }; | 99 | }; |
100 | |||
101 | nand-controller@79b0000 { | ||
102 | compatible = "qcom,ipq4019-nand"; | ||
103 | reg = <0x79b0000 0x1000>; | ||
104 | |||
105 | clocks = <&gcc GCC_QPIC_CLK>, | ||
106 | <&gcc GCC_QPIC_AHB_CLK>; | ||
107 | clock-names = "core", "aon"; | ||
108 | |||
109 | dmas = <&qpicbam 0>, | ||
110 | <&qpicbam 1>, | ||
111 | <&qpicbam 2>; | ||
112 | dma-names = "tx", "rx", "cmd"; | ||
113 | |||
114 | #address-cells = <1>; | ||
115 | #size-cells = <0>; | ||
116 | |||
117 | nand@0 { | ||
118 | reg = <0>; | ||
119 | nand-ecc-strength = <4>; | ||
120 | nand-ecc-step-size = <512>; | ||
121 | nand-bus-width = <8>; | ||
122 | |||
123 | partitions { | ||
124 | compatible = "fixed-partitions"; | ||
125 | #address-cells = <1>; | ||
126 | #size-cells = <1>; | ||
127 | |||
128 | partition@0 { | ||
129 | label = "boot-nand"; | ||
130 | reg = <0 0x58a0000>; | ||
131 | }; | ||
132 | |||
133 | partition@58a0000 { | ||
134 | label = "fs-nand"; | ||
135 | reg = <0x58a0000 0x4000000>; | ||
136 | }; | ||
137 | }; | ||
138 | }; | ||
139 | }; | ||
diff --git a/Documentation/driver-api/mtdnand.rst b/Documentation/driver-api/mtdnand.rst index e9afa586d15e..2a5191b6d445 100644 --- a/Documentation/driver-api/mtdnand.rst +++ b/Documentation/driver-api/mtdnand.rst | |||
@@ -516,7 +516,7 @@ mirrored table is performed. | |||
516 | 516 | ||
517 | The most important field in the nand_bbt_descr structure is the | 517 | The most important field in the nand_bbt_descr structure is the |
518 | options field. The options define most of the table properties. Use the | 518 | options field. The options define most of the table properties. Use the |
519 | predefined constants from nand.h to define the options. | 519 | predefined constants from rawnand.h to define the options. |
520 | 520 | ||
521 | - Number of bits per block | 521 | - Number of bits per block |
522 | 522 | ||
@@ -843,7 +843,7 @@ Chip option constants | |||
843 | Constants for chip id table | 843 | Constants for chip id table |
844 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 844 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
845 | 845 | ||
846 | These constants are defined in nand.h. They are OR-ed together to | 846 | These constants are defined in rawnand.h. They are OR-ed together to |
847 | describe the chip functionality:: | 847 | describe the chip functionality:: |
848 | 848 | ||
849 | /* Buswitdh is 16 bit */ | 849 | /* Buswitdh is 16 bit */ |
@@ -865,7 +865,7 @@ describe the chip functionality:: | |||
865 | Constants for runtime options | 865 | Constants for runtime options |
866 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 866 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
867 | 867 | ||
868 | These constants are defined in nand.h. They are OR-ed together to | 868 | These constants are defined in rawnand.h. They are OR-ed together to |
869 | describe the functionality:: | 869 | describe the functionality:: |
870 | 870 | ||
871 | /* The hw ecc generator provides a syndrome instead a ecc value on read | 871 | /* The hw ecc generator provides a syndrome instead a ecc value on read |
@@ -956,7 +956,7 @@ developer. Each struct member has a short description which is marked | |||
956 | with an [XXX] identifier. See the chapter "Documentation hints" for an | 956 | with an [XXX] identifier. See the chapter "Documentation hints" for an |
957 | explanation. | 957 | explanation. |
958 | 958 | ||
959 | .. kernel-doc:: include/linux/mtd/nand.h | 959 | .. kernel-doc:: include/linux/mtd/rawnand.h |
960 | :internal: | 960 | :internal: |
961 | 961 | ||
962 | Public Functions Provided | 962 | Public Functions Provided |
diff --git a/MAINTAINERS b/MAINTAINERS index 24f57993d78a..fece49dcb0f6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -9184,7 +9184,7 @@ T: git git://git.infradead.org/linux-mtd.git nand/fixes | |||
9184 | T: git git://git.infradead.org/l2-mtd.git nand/next | 9184 | T: git git://git.infradead.org/l2-mtd.git nand/next |
9185 | S: Maintained | 9185 | S: Maintained |
9186 | F: drivers/mtd/nand/ | 9186 | F: drivers/mtd/nand/ |
9187 | F: include/linux/mtd/nand*.h | 9187 | F: include/linux/mtd/*nand*.h |
9188 | 9188 | ||
9189 | NATIVE INSTRUMENTS USB SOUND INTERFACE DRIVER | 9189 | NATIVE INSTRUMENTS USB SOUND INTERFACE DRIVER |
9190 | M: Daniel Mack <zonque@gmail.com> | 9190 | M: Daniel Mack <zonque@gmail.com> |
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c index e568c8c6f69c..cbde0030c092 100644 --- a/arch/arm/mach-davinci/board-da850-evm.c +++ b/arch/arm/mach-davinci/board-da850-evm.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/input/tps6507x-ts.h> | 26 | #include <linux/input/tps6507x-ts.h> |
27 | #include <linux/mfd/tps6507x.h> | 27 | #include <linux/mfd/tps6507x.h> |
28 | #include <linux/mtd/mtd.h> | 28 | #include <linux/mtd/mtd.h> |
29 | #include <linux/mtd/nand.h> | 29 | #include <linux/mtd/rawnand.h> |
30 | #include <linux/mtd/partitions.h> | 30 | #include <linux/mtd/partitions.h> |
31 | #include <linux/mtd/physmap.h> | 31 | #include <linux/mtd/physmap.h> |
32 | #include <linux/platform_device.h> | 32 | #include <linux/platform_device.h> |
diff --git a/arch/arm/mach-davinci/board-dm355-evm.c b/arch/arm/mach-davinci/board-dm355-evm.c index 18296a99c4d2..62e7bc3018f0 100644 --- a/arch/arm/mach-davinci/board-dm355-evm.c +++ b/arch/arm/mach-davinci/board-dm355-evm.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/mtd/mtd.h> | 15 | #include <linux/mtd/mtd.h> |
16 | #include <linux/mtd/partitions.h> | 16 | #include <linux/mtd/partitions.h> |
17 | #include <linux/mtd/nand.h> | 17 | #include <linux/mtd/rawnand.h> |
18 | #include <linux/i2c.h> | 18 | #include <linux/i2c.h> |
19 | #include <linux/gpio.h> | 19 | #include <linux/gpio.h> |
20 | #include <linux/clk.h> | 20 | #include <linux/clk.h> |
diff --git a/arch/arm/mach-davinci/board-dm355-leopard.c b/arch/arm/mach-davinci/board-dm355-leopard.c index 284ff27c1b32..be997243447b 100644 --- a/arch/arm/mach-davinci/board-dm355-leopard.c +++ b/arch/arm/mach-davinci/board-dm355-leopard.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <linux/platform_device.h> | 13 | #include <linux/platform_device.h> |
14 | #include <linux/mtd/mtd.h> | 14 | #include <linux/mtd/mtd.h> |
15 | #include <linux/mtd/partitions.h> | 15 | #include <linux/mtd/partitions.h> |
16 | #include <linux/mtd/nand.h> | 16 | #include <linux/mtd/rawnand.h> |
17 | #include <linux/i2c.h> | 17 | #include <linux/i2c.h> |
18 | #include <linux/gpio.h> | 18 | #include <linux/gpio.h> |
19 | #include <linux/clk.h> | 19 | #include <linux/clk.h> |
diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c index 0464999b7137..e75741fb2c1d 100644 --- a/arch/arm/mach-davinci/board-dm365-evm.c +++ b/arch/arm/mach-davinci/board-dm365-evm.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <linux/mtd/mtd.h> | 23 | #include <linux/mtd/mtd.h> |
24 | #include <linux/mtd/partitions.h> | 24 | #include <linux/mtd/partitions.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/mtd/nand.h> | 26 | #include <linux/mtd/rawnand.h> |
27 | #include <linux/input.h> | 27 | #include <linux/input.h> |
28 | #include <linux/spi/spi.h> | 28 | #include <linux/spi/spi.h> |
29 | #include <linux/spi/eeprom.h> | 29 | #include <linux/spi/eeprom.h> |
diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c index 70e00dbeec96..b07c9b18d427 100644 --- a/arch/arm/mach-davinci/board-dm644x-evm.c +++ b/arch/arm/mach-davinci/board-dm644x-evm.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/platform_data/pcf857x.h> | 17 | #include <linux/platform_data/pcf857x.h> |
18 | #include <linux/platform_data/at24.h> | 18 | #include <linux/platform_data/at24.h> |
19 | #include <linux/mtd/mtd.h> | 19 | #include <linux/mtd/mtd.h> |
20 | #include <linux/mtd/nand.h> | 20 | #include <linux/mtd/rawnand.h> |
21 | #include <linux/mtd/partitions.h> | 21 | #include <linux/mtd/partitions.h> |
22 | #include <linux/mtd/physmap.h> | 22 | #include <linux/mtd/physmap.h> |
23 | #include <linux/phy.h> | 23 | #include <linux/phy.h> |
diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c index 1d76e7480a42..cb0a41e83582 100644 --- a/arch/arm/mach-davinci/board-dm646x-evm.c +++ b/arch/arm/mach-davinci/board-dm646x-evm.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <media/i2c/adv7343.h> | 29 | #include <media/i2c/adv7343.h> |
30 | 30 | ||
31 | #include <linux/mtd/mtd.h> | 31 | #include <linux/mtd/mtd.h> |
32 | #include <linux/mtd/nand.h> | 32 | #include <linux/mtd/rawnand.h> |
33 | #include <linux/mtd/partitions.h> | 33 | #include <linux/mtd/partitions.h> |
34 | #include <linux/clk.h> | 34 | #include <linux/clk.h> |
35 | #include <linux/export.h> | 35 | #include <linux/export.h> |
diff --git a/arch/arm/mach-davinci/board-sffsdr.c b/arch/arm/mach-davinci/board-sffsdr.c index 41c7c9615791..d85accf7f760 100644 --- a/arch/arm/mach-davinci/board-sffsdr.c +++ b/arch/arm/mach-davinci/board-sffsdr.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <linux/platform_data/at24.h> | 29 | #include <linux/platform_data/at24.h> |
30 | #include <linux/mtd/mtd.h> | 30 | #include <linux/mtd/mtd.h> |
31 | #include <linux/mtd/nand.h> | 31 | #include <linux/mtd/rawnand.h> |
32 | #include <linux/mtd/partitions.h> | 32 | #include <linux/mtd/partitions.h> |
33 | 33 | ||
34 | #include <asm/mach-types.h> | 34 | #include <asm/mach-types.h> |
diff --git a/arch/arm/mach-dove/dove-db-setup.c b/arch/arm/mach-dove/dove-db-setup.c index bcb678fd2415..8971c3c0f0fe 100644 --- a/arch/arm/mach-dove/dove-db-setup.c +++ b/arch/arm/mach-dove/dove-db-setup.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <linux/platform_device.h> | 13 | #include <linux/platform_device.h> |
14 | #include <linux/irq.h> | 14 | #include <linux/irq.h> |
15 | #include <linux/mtd/physmap.h> | 15 | #include <linux/mtd/physmap.h> |
16 | #include <linux/mtd/nand.h> | 16 | #include <linux/mtd/rawnand.h> |
17 | #include <linux/timer.h> | 17 | #include <linux/timer.h> |
18 | #include <linux/ata_platform.h> | 18 | #include <linux/ata_platform.h> |
19 | #include <linux/mv643xx_eth.h> | 19 | #include <linux/mv643xx_eth.h> |
diff --git a/arch/arm/mach-ep93xx/snappercl15.c b/arch/arm/mach-ep93xx/snappercl15.c index b2db791b3b38..8b29398f4dc7 100644 --- a/arch/arm/mach-ep93xx/snappercl15.c +++ b/arch/arm/mach-ep93xx/snappercl15.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/fb.h> | 25 | #include <linux/fb.h> |
26 | 26 | ||
27 | #include <linux/mtd/partitions.h> | 27 | #include <linux/mtd/partitions.h> |
28 | #include <linux/mtd/nand.h> | 28 | #include <linux/mtd/rawnand.h> |
29 | 29 | ||
30 | #include <mach/hardware.h> | 30 | #include <mach/hardware.h> |
31 | #include <linux/platform_data/video-ep93xx.h> | 31 | #include <linux/platform_data/video-ep93xx.h> |
diff --git a/arch/arm/mach-ep93xx/ts72xx.c b/arch/arm/mach-ep93xx/ts72xx.c index 55b186ef863a..8745162ec05d 100644 --- a/arch/arm/mach-ep93xx/ts72xx.c +++ b/arch/arm/mach-ep93xx/ts72xx.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/io.h> | 18 | #include <linux/io.h> |
19 | #include <linux/mtd/nand.h> | 19 | #include <linux/mtd/rawnand.h> |
20 | #include <linux/mtd/partitions.h> | 20 | #include <linux/mtd/partitions.h> |
21 | 21 | ||
22 | #include <mach/hardware.h> | 22 | #include <mach/hardware.h> |
diff --git a/arch/arm/mach-imx/mach-qong.c b/arch/arm/mach-imx/mach-qong.c index 8c2cbd693d21..42a700053103 100644 --- a/arch/arm/mach-imx/mach-qong.c +++ b/arch/arm/mach-imx/mach-qong.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/memory.h> | 18 | #include <linux/memory.h> |
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/mtd/physmap.h> | 20 | #include <linux/mtd/physmap.h> |
21 | #include <linux/mtd/nand.h> | 21 | #include <linux/mtd/rawnand.h> |
22 | #include <linux/gpio.h> | 22 | #include <linux/gpio.h> |
23 | 23 | ||
24 | #include <asm/mach-types.h> | 24 | #include <asm/mach-types.h> |
diff --git a/arch/arm/mach-ixp4xx/ixdp425-setup.c b/arch/arm/mach-ixp4xx/ixdp425-setup.c index 508c2d7786e2..93b89291c06b 100644 --- a/arch/arm/mach-ixp4xx/ixdp425-setup.c +++ b/arch/arm/mach-ixp4xx/ixdp425-setup.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/i2c-gpio.h> | 17 | #include <linux/i2c-gpio.h> |
18 | #include <linux/io.h> | 18 | #include <linux/io.h> |
19 | #include <linux/mtd/mtd.h> | 19 | #include <linux/mtd/mtd.h> |
20 | #include <linux/mtd/nand.h> | 20 | #include <linux/mtd/rawnand.h> |
21 | #include <linux/mtd/partitions.h> | 21 | #include <linux/mtd/partitions.h> |
22 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
23 | #include <linux/gpio.h> | 23 | #include <linux/gpio.h> |
diff --git a/arch/arm/mach-mmp/aspenite.c b/arch/arm/mach-mmp/aspenite.c index 5db0edf716dd..d2283009a5ff 100644 --- a/arch/arm/mach-mmp/aspenite.c +++ b/arch/arm/mach-mmp/aspenite.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/smc91x.h> | 16 | #include <linux/smc91x.h> |
17 | #include <linux/mtd/mtd.h> | 17 | #include <linux/mtd/mtd.h> |
18 | #include <linux/mtd/partitions.h> | 18 | #include <linux/mtd/partitions.h> |
19 | #include <linux/mtd/nand.h> | 19 | #include <linux/mtd/rawnand.h> |
20 | #include <linux/interrupt.h> | 20 | #include <linux/interrupt.h> |
21 | #include <linux/platform_data/mv_usb.h> | 21 | #include <linux/platform_data/mv_usb.h> |
22 | 22 | ||
diff --git a/arch/arm/mach-omap1/board-fsample.c b/arch/arm/mach-omap1/board-fsample.c index fad95b74bb65..b93ad58b0a63 100644 --- a/arch/arm/mach-omap1/board-fsample.c +++ b/arch/arm/mach-omap1/board-fsample.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
18 | #include <linux/mtd/mtd.h> | 18 | #include <linux/mtd/mtd.h> |
19 | #include <linux/mtd/nand.h> | 19 | #include <linux/mtd/rawnand.h> |
20 | #include <linux/mtd/partitions.h> | 20 | #include <linux/mtd/partitions.h> |
21 | #include <linux/mtd/physmap.h> | 21 | #include <linux/mtd/physmap.h> |
22 | #include <linux/input.h> | 22 | #include <linux/input.h> |
diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c index dece47d76282..6a38c7603064 100644 --- a/arch/arm/mach-omap1/board-h2.c +++ b/arch/arm/mach-omap1/board-h2.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
25 | #include <linux/i2c.h> | 25 | #include <linux/i2c.h> |
26 | #include <linux/mtd/mtd.h> | 26 | #include <linux/mtd/mtd.h> |
27 | #include <linux/mtd/nand.h> | 27 | #include <linux/mtd/rawnand.h> |
28 | #include <linux/mtd/partitions.h> | 28 | #include <linux/mtd/partitions.h> |
29 | #include <linux/mtd/physmap.h> | 29 | #include <linux/mtd/physmap.h> |
30 | #include <linux/input.h> | 30 | #include <linux/input.h> |
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c index 6d32beeb2d88..302260583e8e 100644 --- a/arch/arm/mach-omap1/board-h3.c +++ b/arch/arm/mach-omap1/board-h3.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <linux/workqueue.h> | 23 | #include <linux/workqueue.h> |
24 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
25 | #include <linux/mtd/mtd.h> | 25 | #include <linux/mtd/mtd.h> |
26 | #include <linux/mtd/nand.h> | 26 | #include <linux/mtd/rawnand.h> |
27 | #include <linux/mtd/partitions.h> | 27 | #include <linux/mtd/partitions.h> |
28 | #include <linux/mtd/physmap.h> | 28 | #include <linux/mtd/physmap.h> |
29 | #include <linux/input.h> | 29 | #include <linux/input.h> |
diff --git a/arch/arm/mach-omap1/board-nand.c b/arch/arm/mach-omap1/board-nand.c index 7684f9203474..1bffbb4e050f 100644 --- a/arch/arm/mach-omap1/board-nand.c +++ b/arch/arm/mach-omap1/board-nand.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/io.h> | 17 | #include <linux/io.h> |
18 | #include <linux/mtd/mtd.h> | 18 | #include <linux/mtd/mtd.h> |
19 | #include <linux/mtd/nand.h> | 19 | #include <linux/mtd/rawnand.h> |
20 | 20 | ||
21 | #include "common.h" | 21 | #include "common.h" |
22 | 22 | ||
diff --git a/arch/arm/mach-omap1/board-perseus2.c b/arch/arm/mach-omap1/board-perseus2.c index 150b57ba42bf..e994a78bdd09 100644 --- a/arch/arm/mach-omap1/board-perseus2.c +++ b/arch/arm/mach-omap1/board-perseus2.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
18 | #include <linux/mtd/mtd.h> | 18 | #include <linux/mtd/mtd.h> |
19 | #include <linux/mtd/nand.h> | 19 | #include <linux/mtd/rawnand.h> |
20 | #include <linux/mtd/partitions.h> | 20 | #include <linux/mtd/partitions.h> |
21 | #include <linux/mtd/physmap.h> | 21 | #include <linux/mtd/physmap.h> |
22 | #include <linux/input.h> | 22 | #include <linux/input.h> |
diff --git a/arch/arm/mach-orion5x/db88f5281-setup.c b/arch/arm/mach-orion5x/db88f5281-setup.c index 12f74b46e2ff..3f5863de766a 100644 --- a/arch/arm/mach-orion5x/db88f5281-setup.c +++ b/arch/arm/mach-orion5x/db88f5281-setup.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/pci.h> | 16 | #include <linux/pci.h> |
17 | #include <linux/irq.h> | 17 | #include <linux/irq.h> |
18 | #include <linux/mtd/physmap.h> | 18 | #include <linux/mtd/physmap.h> |
19 | #include <linux/mtd/nand.h> | 19 | #include <linux/mtd/rawnand.h> |
20 | #include <linux/timer.h> | 20 | #include <linux/timer.h> |
21 | #include <linux/mv643xx_eth.h> | 21 | #include <linux/mv643xx_eth.h> |
22 | #include <linux/i2c.h> | 22 | #include <linux/i2c.h> |
diff --git a/arch/arm/mach-orion5x/kurobox_pro-setup.c b/arch/arm/mach-orion5x/kurobox_pro-setup.c index 9dc3f59bed9c..83d43cff4bd7 100644 --- a/arch/arm/mach-orion5x/kurobox_pro-setup.c +++ b/arch/arm/mach-orion5x/kurobox_pro-setup.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/irq.h> | 15 | #include <linux/irq.h> |
16 | #include <linux/delay.h> | 16 | #include <linux/delay.h> |
17 | #include <linux/mtd/physmap.h> | 17 | #include <linux/mtd/physmap.h> |
18 | #include <linux/mtd/nand.h> | 18 | #include <linux/mtd/rawnand.h> |
19 | #include <linux/mv643xx_eth.h> | 19 | #include <linux/mv643xx_eth.h> |
20 | #include <linux/i2c.h> | 20 | #include <linux/i2c.h> |
21 | #include <linux/serial_reg.h> | 21 | #include <linux/serial_reg.h> |
diff --git a/arch/arm/mach-orion5x/ts209-setup.c b/arch/arm/mach-orion5x/ts209-setup.c index 7bd671b2854c..0c315515dd2d 100644 --- a/arch/arm/mach-orion5x/ts209-setup.c +++ b/arch/arm/mach-orion5x/ts209-setup.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/pci.h> | 15 | #include <linux/pci.h> |
16 | #include <linux/irq.h> | 16 | #include <linux/irq.h> |
17 | #include <linux/mtd/physmap.h> | 17 | #include <linux/mtd/physmap.h> |
18 | #include <linux/mtd/nand.h> | 18 | #include <linux/mtd/rawnand.h> |
19 | #include <linux/mv643xx_eth.h> | 19 | #include <linux/mv643xx_eth.h> |
20 | #include <linux/gpio_keys.h> | 20 | #include <linux/gpio_keys.h> |
21 | #include <linux/input.h> | 21 | #include <linux/input.h> |
diff --git a/arch/arm/mach-orion5x/ts78xx-setup.c b/arch/arm/mach-orion5x/ts78xx-setup.c index 7ef80a8304c0..94778739e38f 100644 --- a/arch/arm/mach-orion5x/ts78xx-setup.c +++ b/arch/arm/mach-orion5x/ts78xx-setup.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/mv643xx_eth.h> | 17 | #include <linux/mv643xx_eth.h> |
18 | #include <linux/ata_platform.h> | 18 | #include <linux/ata_platform.h> |
19 | #include <linux/mtd/nand.h> | 19 | #include <linux/mtd/rawnand.h> |
20 | #include <linux/mtd/partitions.h> | 20 | #include <linux/mtd/partitions.h> |
21 | #include <linux/timeriomem-rng.h> | 21 | #include <linux/timeriomem-rng.h> |
22 | #include <asm/mach-types.h> | 22 | #include <asm/mach-types.h> |
diff --git a/arch/arm/mach-pxa/balloon3.c b/arch/arm/mach-pxa/balloon3.c index 1467c1d1e541..d6d92f388f14 100644 --- a/arch/arm/mach-pxa/balloon3.c +++ b/arch/arm/mach-pxa/balloon3.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <linux/types.h> | 29 | #include <linux/types.h> |
30 | #include <linux/platform_data/pcf857x.h> | 30 | #include <linux/platform_data/pcf857x.h> |
31 | #include <linux/i2c/pxa-i2c.h> | 31 | #include <linux/i2c/pxa-i2c.h> |
32 | #include <linux/mtd/nand.h> | 32 | #include <linux/mtd/rawnand.h> |
33 | #include <linux/mtd/physmap.h> | 33 | #include <linux/mtd/physmap.h> |
34 | #include <linux/regulator/max1586.h> | 34 | #include <linux/regulator/max1586.h> |
35 | 35 | ||
diff --git a/arch/arm/mach-pxa/em-x270.c b/arch/arm/mach-pxa/em-x270.c index 811a7317f3ea..6d28035ebba5 100644 --- a/arch/arm/mach-pxa/em-x270.c +++ b/arch/arm/mach-pxa/em-x270.c | |||
@@ -15,7 +15,7 @@ | |||
15 | 15 | ||
16 | #include <linux/dm9000.h> | 16 | #include <linux/dm9000.h> |
17 | #include <linux/platform_data/rtc-v3020.h> | 17 | #include <linux/platform_data/rtc-v3020.h> |
18 | #include <linux/mtd/nand.h> | 18 | #include <linux/mtd/rawnand.h> |
19 | #include <linux/mtd/partitions.h> | 19 | #include <linux/mtd/partitions.h> |
20 | #include <linux/mtd/physmap.h> | 20 | #include <linux/mtd/physmap.h> |
21 | #include <linux/input.h> | 21 | #include <linux/input.h> |
diff --git a/arch/arm/mach-pxa/eseries.c b/arch/arm/mach-pxa/eseries.c index fa9d71d194f0..91f7c3e40065 100644 --- a/arch/arm/mach-pxa/eseries.c +++ b/arch/arm/mach-pxa/eseries.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/mfd/tc6387xb.h> | 20 | #include <linux/mfd/tc6387xb.h> |
21 | #include <linux/mfd/tc6393xb.h> | 21 | #include <linux/mfd/tc6393xb.h> |
22 | #include <linux/mfd/t7l66xb.h> | 22 | #include <linux/mfd/t7l66xb.h> |
23 | #include <linux/mtd/nand.h> | 23 | #include <linux/mtd/rawnand.h> |
24 | #include <linux/mtd/partitions.h> | 24 | #include <linux/mtd/partitions.h> |
25 | #include <linux/usb/gpio_vbus.h> | 25 | #include <linux/usb/gpio_vbus.h> |
26 | #include <linux/memblock.h> | 26 | #include <linux/memblock.h> |
diff --git a/arch/arm/mach-pxa/palmtx.c b/arch/arm/mach-pxa/palmtx.c index 36646975b5d2..47e3e38e9bec 100644 --- a/arch/arm/mach-pxa/palmtx.c +++ b/arch/arm/mach-pxa/palmtx.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <linux/wm97xx.h> | 28 | #include <linux/wm97xx.h> |
29 | #include <linux/power_supply.h> | 29 | #include <linux/power_supply.h> |
30 | #include <linux/usb/gpio_vbus.h> | 30 | #include <linux/usb/gpio_vbus.h> |
31 | #include <linux/mtd/nand.h> | 31 | #include <linux/mtd/rawnand.h> |
32 | #include <linux/mtd/partitions.h> | 32 | #include <linux/mtd/partitions.h> |
33 | #include <linux/mtd/mtd.h> | 33 | #include <linux/mtd/mtd.h> |
34 | #include <linux/mtd/physmap.h> | 34 | #include <linux/mtd/physmap.h> |
diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c index 13de6602966f..6a386fd6363e 100644 --- a/arch/arm/mach-pxa/tosa.c +++ b/arch/arm/mach-pxa/tosa.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <linux/mmc/host.h> | 24 | #include <linux/mmc/host.h> |
25 | #include <linux/mfd/tc6393xb.h> | 25 | #include <linux/mfd/tc6393xb.h> |
26 | #include <linux/mfd/tmio.h> | 26 | #include <linux/mfd/tmio.h> |
27 | #include <linux/mtd/nand.h> | 27 | #include <linux/mtd/rawnand.h> |
28 | #include <linux/mtd/partitions.h> | 28 | #include <linux/mtd/partitions.h> |
29 | #include <linux/mtd/physmap.h> | 29 | #include <linux/mtd/physmap.h> |
30 | #include <linux/pm.h> | 30 | #include <linux/pm.h> |
diff --git a/arch/arm/mach-s3c24xx/common-smdk.c b/arch/arm/mach-s3c24xx/common-smdk.c index 9e0bc46e90ec..0e116c92bf01 100644 --- a/arch/arm/mach-s3c24xx/common-smdk.c +++ b/arch/arm/mach-s3c24xx/common-smdk.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
24 | 24 | ||
25 | #include <linux/mtd/mtd.h> | 25 | #include <linux/mtd/mtd.h> |
26 | #include <linux/mtd/nand.h> | 26 | #include <linux/mtd/rawnand.h> |
27 | #include <linux/mtd/nand_ecc.h> | 27 | #include <linux/mtd/nand_ecc.h> |
28 | #include <linux/mtd/partitions.h> | 28 | #include <linux/mtd/partitions.h> |
29 | #include <linux/io.h> | 29 | #include <linux/io.h> |
diff --git a/arch/arm/mach-s3c24xx/mach-anubis.c b/arch/arm/mach-s3c24xx/mach-anubis.c index 029ef1b58925..c14cab361922 100644 --- a/arch/arm/mach-s3c24xx/mach-anubis.c +++ b/arch/arm/mach-s3c24xx/mach-anubis.c | |||
@@ -40,7 +40,7 @@ | |||
40 | #include <linux/platform_data/i2c-s3c2410.h> | 40 | #include <linux/platform_data/i2c-s3c2410.h> |
41 | 41 | ||
42 | #include <linux/mtd/mtd.h> | 42 | #include <linux/mtd/mtd.h> |
43 | #include <linux/mtd/nand.h> | 43 | #include <linux/mtd/rawnand.h> |
44 | #include <linux/mtd/nand_ecc.h> | 44 | #include <linux/mtd/nand_ecc.h> |
45 | #include <linux/mtd/partitions.h> | 45 | #include <linux/mtd/partitions.h> |
46 | 46 | ||
diff --git a/arch/arm/mach-s3c24xx/mach-at2440evb.c b/arch/arm/mach-s3c24xx/mach-at2440evb.c index 7b28eb623fc1..ebdbafb9382a 100644 --- a/arch/arm/mach-s3c24xx/mach-at2440evb.c +++ b/arch/arm/mach-s3c24xx/mach-at2440evb.c | |||
@@ -41,7 +41,7 @@ | |||
41 | #include <linux/platform_data/i2c-s3c2410.h> | 41 | #include <linux/platform_data/i2c-s3c2410.h> |
42 | 42 | ||
43 | #include <linux/mtd/mtd.h> | 43 | #include <linux/mtd/mtd.h> |
44 | #include <linux/mtd/nand.h> | 44 | #include <linux/mtd/rawnand.h> |
45 | #include <linux/mtd/nand_ecc.h> | 45 | #include <linux/mtd/nand_ecc.h> |
46 | #include <linux/mtd/partitions.h> | 46 | #include <linux/mtd/partitions.h> |
47 | 47 | ||
diff --git a/arch/arm/mach-s3c24xx/mach-bast.c b/arch/arm/mach-s3c24xx/mach-bast.c index 5185036765db..704dc84b3480 100644 --- a/arch/arm/mach-s3c24xx/mach-bast.c +++ b/arch/arm/mach-s3c24xx/mach-bast.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <linux/serial_8250.h> | 28 | #include <linux/serial_8250.h> |
29 | 29 | ||
30 | #include <linux/mtd/mtd.h> | 30 | #include <linux/mtd/mtd.h> |
31 | #include <linux/mtd/nand.h> | 31 | #include <linux/mtd/rawnand.h> |
32 | #include <linux/mtd/nand_ecc.h> | 32 | #include <linux/mtd/nand_ecc.h> |
33 | #include <linux/mtd/partitions.h> | 33 | #include <linux/mtd/partitions.h> |
34 | 34 | ||
diff --git a/arch/arm/mach-s3c24xx/mach-gta02.c b/arch/arm/mach-s3c24xx/mach-gta02.c index b0ed401da3a3..afe18baf0c84 100644 --- a/arch/arm/mach-s3c24xx/mach-gta02.c +++ b/arch/arm/mach-s3c24xx/mach-gta02.c | |||
@@ -50,7 +50,7 @@ | |||
50 | #include <linux/mfd/pcf50633/pmic.h> | 50 | #include <linux/mfd/pcf50633/pmic.h> |
51 | 51 | ||
52 | #include <linux/mtd/mtd.h> | 52 | #include <linux/mtd/mtd.h> |
53 | #include <linux/mtd/nand.h> | 53 | #include <linux/mtd/rawnand.h> |
54 | #include <linux/mtd/nand_ecc.h> | 54 | #include <linux/mtd/nand_ecc.h> |
55 | #include <linux/mtd/partitions.h> | 55 | #include <linux/mtd/partitions.h> |
56 | #include <linux/mtd/physmap.h> | 56 | #include <linux/mtd/physmap.h> |
diff --git a/arch/arm/mach-s3c24xx/mach-jive.c b/arch/arm/mach-s3c24xx/mach-jive.c index f5b5c49b56ac..17821976f769 100644 --- a/arch/arm/mach-s3c24xx/mach-jive.c +++ b/arch/arm/mach-s3c24xx/mach-jive.c | |||
@@ -43,7 +43,7 @@ | |||
43 | #include <asm/mach-types.h> | 43 | #include <asm/mach-types.h> |
44 | 44 | ||
45 | #include <linux/mtd/mtd.h> | 45 | #include <linux/mtd/mtd.h> |
46 | #include <linux/mtd/nand.h> | 46 | #include <linux/mtd/rawnand.h> |
47 | #include <linux/mtd/nand_ecc.h> | 47 | #include <linux/mtd/nand_ecc.h> |
48 | #include <linux/mtd/partitions.h> | 48 | #include <linux/mtd/partitions.h> |
49 | 49 | ||
diff --git a/arch/arm/mach-s3c24xx/mach-mini2440.c b/arch/arm/mach-s3c24xx/mach-mini2440.c index 71af8d2fd320..15140d34f927 100644 --- a/arch/arm/mach-s3c24xx/mach-mini2440.c +++ b/arch/arm/mach-s3c24xx/mach-mini2440.c | |||
@@ -49,7 +49,7 @@ | |||
49 | #include <linux/platform_data/usb-s3c2410_udc.h> | 49 | #include <linux/platform_data/usb-s3c2410_udc.h> |
50 | 50 | ||
51 | #include <linux/mtd/mtd.h> | 51 | #include <linux/mtd/mtd.h> |
52 | #include <linux/mtd/nand.h> | 52 | #include <linux/mtd/rawnand.h> |
53 | #include <linux/mtd/nand_ecc.h> | 53 | #include <linux/mtd/nand_ecc.h> |
54 | #include <linux/mtd/partitions.h> | 54 | #include <linux/mtd/partitions.h> |
55 | 55 | ||
diff --git a/arch/arm/mach-s3c24xx/mach-osiris.c b/arch/arm/mach-s3c24xx/mach-osiris.c index 64b1a0b7b803..ed3b22ceef06 100644 --- a/arch/arm/mach-s3c24xx/mach-osiris.c +++ b/arch/arm/mach-s3c24xx/mach-osiris.c | |||
@@ -36,7 +36,7 @@ | |||
36 | #include <linux/platform_data/i2c-s3c2410.h> | 36 | #include <linux/platform_data/i2c-s3c2410.h> |
37 | 37 | ||
38 | #include <linux/mtd/mtd.h> | 38 | #include <linux/mtd/mtd.h> |
39 | #include <linux/mtd/nand.h> | 39 | #include <linux/mtd/rawnand.h> |
40 | #include <linux/mtd/nand_ecc.h> | 40 | #include <linux/mtd/nand_ecc.h> |
41 | #include <linux/mtd/partitions.h> | 41 | #include <linux/mtd/partitions.h> |
42 | 42 | ||
diff --git a/arch/arm/mach-s3c24xx/mach-qt2410.c b/arch/arm/mach-s3c24xx/mach-qt2410.c index 868c82087403..84e3a9c53184 100644 --- a/arch/arm/mach-s3c24xx/mach-qt2410.c +++ b/arch/arm/mach-s3c24xx/mach-qt2410.c | |||
@@ -36,7 +36,7 @@ | |||
36 | #include <linux/spi/spi_gpio.h> | 36 | #include <linux/spi/spi_gpio.h> |
37 | #include <linux/io.h> | 37 | #include <linux/io.h> |
38 | #include <linux/mtd/mtd.h> | 38 | #include <linux/mtd/mtd.h> |
39 | #include <linux/mtd/nand.h> | 39 | #include <linux/mtd/rawnand.h> |
40 | #include <linux/mtd/nand_ecc.h> | 40 | #include <linux/mtd/nand_ecc.h> |
41 | #include <linux/mtd/partitions.h> | 41 | #include <linux/mtd/partitions.h> |
42 | 42 | ||
diff --git a/arch/arm/mach-s3c24xx/mach-rx3715.c b/arch/arm/mach-s3c24xx/mach-rx3715.c index a39fb9780dd3..b5ba615cf9dd 100644 --- a/arch/arm/mach-s3c24xx/mach-rx3715.c +++ b/arch/arm/mach-s3c24xx/mach-rx3715.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include <linux/serial.h> | 27 | #include <linux/serial.h> |
28 | #include <linux/io.h> | 28 | #include <linux/io.h> |
29 | #include <linux/mtd/mtd.h> | 29 | #include <linux/mtd/mtd.h> |
30 | #include <linux/mtd/nand.h> | 30 | #include <linux/mtd/rawnand.h> |
31 | #include <linux/mtd/nand_ecc.h> | 31 | #include <linux/mtd/nand_ecc.h> |
32 | #include <linux/mtd/partitions.h> | 32 | #include <linux/mtd/partitions.h> |
33 | 33 | ||
diff --git a/arch/arm/mach-s3c24xx/mach-vstms.c b/arch/arm/mach-s3c24xx/mach-vstms.c index f5e6322145fa..1adc957edf0f 100644 --- a/arch/arm/mach-s3c24xx/mach-vstms.c +++ b/arch/arm/mach-s3c24xx/mach-vstms.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <linux/io.h> | 21 | #include <linux/io.h> |
22 | #include <linux/mtd/mtd.h> | 22 | #include <linux/mtd/mtd.h> |
23 | #include <linux/mtd/nand.h> | 23 | #include <linux/mtd/rawnand.h> |
24 | #include <linux/mtd/nand_ecc.h> | 24 | #include <linux/mtd/nand_ecc.h> |
25 | #include <linux/mtd/partitions.h> | 25 | #include <linux/mtd/partitions.h> |
26 | #include <linux/memblock.h> | 26 | #include <linux/memblock.h> |
diff --git a/arch/blackfin/mach-bf537/boards/dnp5370.c b/arch/blackfin/mach-bf537/boards/dnp5370.c index e79b3b810c39..c4a8ffb15417 100644 --- a/arch/blackfin/mach-bf537/boards/dnp5370.c +++ b/arch/blackfin/mach-bf537/boards/dnp5370.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/io.h> | 18 | #include <linux/io.h> |
19 | #include <linux/mtd/mtd.h> | 19 | #include <linux/mtd/mtd.h> |
20 | #include <linux/mtd/nand.h> | 20 | #include <linux/mtd/rawnand.h> |
21 | #include <linux/mtd/partitions.h> | 21 | #include <linux/mtd/partitions.h> |
22 | #include <linux/mtd/plat-ram.h> | 22 | #include <linux/mtd/plat-ram.h> |
23 | #include <linux/mtd/physmap.h> | 23 | #include <linux/mtd/physmap.h> |
diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c index 7528148dc492..400e6693643e 100644 --- a/arch/blackfin/mach-bf537/boards/stamp.c +++ b/arch/blackfin/mach-bf537/boards/stamp.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include <linux/platform_device.h> | 12 | #include <linux/platform_device.h> |
13 | #include <linux/io.h> | 13 | #include <linux/io.h> |
14 | #include <linux/mtd/mtd.h> | 14 | #include <linux/mtd/mtd.h> |
15 | #include <linux/mtd/nand.h> | 15 | #include <linux/mtd/rawnand.h> |
16 | #include <linux/mtd/partitions.h> | 16 | #include <linux/mtd/partitions.h> |
17 | #include <linux/mtd/plat-ram.h> | 17 | #include <linux/mtd/plat-ram.h> |
18 | #include <linux/mtd/physmap.h> | 18 | #include <linux/mtd/physmap.h> |
diff --git a/arch/blackfin/mach-bf561/boards/acvilon.c b/arch/blackfin/mach-bf561/boards/acvilon.c index 37f8f25a1347..696cc9d7820a 100644 --- a/arch/blackfin/mach-bf561/boards/acvilon.c +++ b/arch/blackfin/mach-bf561/boards/acvilon.c | |||
@@ -38,7 +38,7 @@ | |||
38 | #include <linux/mtd/mtd.h> | 38 | #include <linux/mtd/mtd.h> |
39 | #include <linux/mtd/partitions.h> | 39 | #include <linux/mtd/partitions.h> |
40 | #include <linux/mtd/physmap.h> | 40 | #include <linux/mtd/physmap.h> |
41 | #include <linux/mtd/nand.h> | 41 | #include <linux/mtd/rawnand.h> |
42 | #include <linux/mtd/plat-ram.h> | 42 | #include <linux/mtd/plat-ram.h> |
43 | #include <linux/spi/spi.h> | 43 | #include <linux/spi/spi.h> |
44 | #include <linux/spi/flash.h> | 44 | #include <linux/spi/flash.h> |
diff --git a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c index 3f646c787e58..925a98eb6d68 100644 --- a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c +++ b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/mtd/mtd.h> | 18 | #include <linux/mtd/mtd.h> |
19 | #include <linux/mtd/nand.h> | 19 | #include <linux/mtd/rawnand.h> |
20 | #include <linux/mtd/partitions.h> | 20 | #include <linux/mtd/partitions.h> |
21 | #include <arch/memmap.h> | 21 | #include <arch/memmap.h> |
22 | #include <hwregs/reg_map.h> | 22 | #include <hwregs/reg_map.h> |
diff --git a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c index a74540514bdb..53b56a429dde 100644 --- a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c +++ b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/mtd/mtd.h> | 18 | #include <linux/mtd/mtd.h> |
19 | #include <linux/mtd/nand.h> | 19 | #include <linux/mtd/rawnand.h> |
20 | #include <linux/mtd/partitions.h> | 20 | #include <linux/mtd/partitions.h> |
21 | #include <arch/memmap.h> | 21 | #include <arch/memmap.h> |
22 | #include <hwregs/reg_map.h> | 22 | #include <hwregs/reg_map.h> |
diff --git a/arch/mips/alchemy/devboards/db1200.c b/arch/mips/alchemy/devboards/db1200.c index 992442a03d8b..83831002c832 100644 --- a/arch/mips/alchemy/devboards/db1200.c +++ b/arch/mips/alchemy/devboards/db1200.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <linux/leds.h> | 29 | #include <linux/leds.h> |
30 | #include <linux/mmc/host.h> | 30 | #include <linux/mmc/host.h> |
31 | #include <linux/mtd/mtd.h> | 31 | #include <linux/mtd/mtd.h> |
32 | #include <linux/mtd/nand.h> | 32 | #include <linux/mtd/rawnand.h> |
33 | #include <linux/mtd/partitions.h> | 33 | #include <linux/mtd/partitions.h> |
34 | #include <linux/platform_device.h> | 34 | #include <linux/platform_device.h> |
35 | #include <linux/serial_8250.h> | 35 | #include <linux/serial_8250.h> |
diff --git a/arch/mips/alchemy/devboards/db1300.c b/arch/mips/alchemy/devboards/db1300.c index a5504f57cb00..3e7fbdbdb3c4 100644 --- a/arch/mips/alchemy/devboards/db1300.c +++ b/arch/mips/alchemy/devboards/db1300.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/mmc/host.h> | 18 | #include <linux/mmc/host.h> |
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/mtd/mtd.h> | 20 | #include <linux/mtd/mtd.h> |
21 | #include <linux/mtd/nand.h> | 21 | #include <linux/mtd/rawnand.h> |
22 | #include <linux/mtd/partitions.h> | 22 | #include <linux/mtd/partitions.h> |
23 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
24 | #include <linux/smsc911x.h> | 24 | #include <linux/smsc911x.h> |
diff --git a/arch/mips/alchemy/devboards/db1550.c b/arch/mips/alchemy/devboards/db1550.c index 1c01d6eadb08..421bd5793f7e 100644 --- a/arch/mips/alchemy/devboards/db1550.c +++ b/arch/mips/alchemy/devboards/db1550.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include <linux/io.h> | 12 | #include <linux/io.h> |
13 | #include <linux/interrupt.h> | 13 | #include <linux/interrupt.h> |
14 | #include <linux/mtd/mtd.h> | 14 | #include <linux/mtd/mtd.h> |
15 | #include <linux/mtd/nand.h> | 15 | #include <linux/mtd/rawnand.h> |
16 | #include <linux/mtd/partitions.h> | 16 | #include <linux/mtd/partitions.h> |
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/pm.h> | 18 | #include <linux/pm.h> |
diff --git a/arch/mips/include/asm/mach-jz4740/jz4740_nand.h b/arch/mips/include/asm/mach-jz4740/jz4740_nand.h index 7f7b0fc554da..f381d465e768 100644 --- a/arch/mips/include/asm/mach-jz4740/jz4740_nand.h +++ b/arch/mips/include/asm/mach-jz4740/jz4740_nand.h | |||
@@ -16,7 +16,7 @@ | |||
16 | #ifndef __ASM_MACH_JZ4740_JZ4740_NAND_H__ | 16 | #ifndef __ASM_MACH_JZ4740_JZ4740_NAND_H__ |
17 | #define __ASM_MACH_JZ4740_JZ4740_NAND_H__ | 17 | #define __ASM_MACH_JZ4740_JZ4740_NAND_H__ |
18 | 18 | ||
19 | #include <linux/mtd/nand.h> | 19 | #include <linux/mtd/rawnand.h> |
20 | #include <linux/mtd/partitions.h> | 20 | #include <linux/mtd/partitions.h> |
21 | 21 | ||
22 | #define JZ_NAND_NUM_BANKS 4 | 22 | #define JZ_NAND_NUM_BANKS 4 |
diff --git a/arch/mips/netlogic/xlr/platform-flash.c b/arch/mips/netlogic/xlr/platform-flash.c index f03131fec41d..4d1b4c003376 100644 --- a/arch/mips/netlogic/xlr/platform-flash.c +++ b/arch/mips/netlogic/xlr/platform-flash.c | |||
@@ -19,7 +19,7 @@ | |||
19 | 19 | ||
20 | #include <linux/mtd/mtd.h> | 20 | #include <linux/mtd/mtd.h> |
21 | #include <linux/mtd/physmap.h> | 21 | #include <linux/mtd/physmap.h> |
22 | #include <linux/mtd/nand.h> | 22 | #include <linux/mtd/rawnand.h> |
23 | #include <linux/mtd/partitions.h> | 23 | #include <linux/mtd/partitions.h> |
24 | 24 | ||
25 | #include <asm/netlogic/haldefs.h> | 25 | #include <asm/netlogic/haldefs.h> |
diff --git a/arch/mips/pnx833x/common/platform.c b/arch/mips/pnx833x/common/platform.c index 7cf4eb50fc72..a7a4e9f5146d 100644 --- a/arch/mips/pnx833x/common/platform.c +++ b/arch/mips/pnx833x/common/platform.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include <linux/resource.h> | 30 | #include <linux/resource.h> |
31 | #include <linux/serial.h> | 31 | #include <linux/serial.h> |
32 | #include <linux/serial_pnx8xxx.h> | 32 | #include <linux/serial_pnx8xxx.h> |
33 | #include <linux/mtd/nand.h> | 33 | #include <linux/mtd/rawnand.h> |
34 | #include <linux/mtd/partitions.h> | 34 | #include <linux/mtd/partitions.h> |
35 | 35 | ||
36 | #include <irq.h> | 36 | #include <irq.h> |
diff --git a/arch/mips/rb532/devices.c b/arch/mips/rb532/devices.c index 0966adccf520..32ea3e6731d6 100644 --- a/arch/mips/rb532/devices.c +++ b/arch/mips/rb532/devices.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/ctype.h> | 20 | #include <linux/ctype.h> |
21 | #include <linux/string.h> | 21 | #include <linux/string.h> |
22 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
23 | #include <linux/mtd/nand.h> | 23 | #include <linux/mtd/rawnand.h> |
24 | #include <linux/mtd/mtd.h> | 24 | #include <linux/mtd/mtd.h> |
25 | #include <linux/mtd/partitions.h> | 25 | #include <linux/mtd/partitions.h> |
26 | #include <linux/gpio.h> | 26 | #include <linux/gpio.h> |
diff --git a/arch/sh/boards/mach-migor/setup.c b/arch/sh/boards/mach-migor/setup.c index 5de60a77eaa1..0bcbe58b11e9 100644 --- a/arch/sh/boards/mach-migor/setup.c +++ b/arch/sh/boards/mach-migor/setup.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/mmc/host.h> | 15 | #include <linux/mmc/host.h> |
16 | #include <linux/mtd/physmap.h> | 16 | #include <linux/mtd/physmap.h> |
17 | #include <linux/mfd/tmio.h> | 17 | #include <linux/mfd/tmio.h> |
18 | #include <linux/mtd/nand.h> | 18 | #include <linux/mtd/rawnand.h> |
19 | #include <linux/i2c.h> | 19 | #include <linux/i2c.h> |
20 | #include <linux/regulator/fixed.h> | 20 | #include <linux/regulator/fixed.h> |
21 | #include <linux/regulator/machine.h> | 21 | #include <linux/regulator/machine.h> |
diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c index b833e6cc684c..84b16133554b 100644 --- a/drivers/mtd/devices/docg3.c +++ b/drivers/mtd/devices/docg3.c | |||
@@ -1809,37 +1809,22 @@ static int dbg_protection_show(struct seq_file *s, void *p) | |||
1809 | } | 1809 | } |
1810 | DEBUGFS_RO_ATTR(protection, dbg_protection_show); | 1810 | DEBUGFS_RO_ATTR(protection, dbg_protection_show); |
1811 | 1811 | ||
1812 | static int __init doc_dbg_register(struct docg3 *docg3) | 1812 | static void __init doc_dbg_register(struct mtd_info *floor) |
1813 | { | ||
1814 | struct dentry *root, *entry; | ||
1815 | |||
1816 | root = debugfs_create_dir("docg3", NULL); | ||
1817 | if (!root) | ||
1818 | return -ENOMEM; | ||
1819 | |||
1820 | entry = debugfs_create_file("flashcontrol", S_IRUSR, root, docg3, | ||
1821 | &flashcontrol_fops); | ||
1822 | if (entry) | ||
1823 | entry = debugfs_create_file("asic_mode", S_IRUSR, root, | ||
1824 | docg3, &asic_mode_fops); | ||
1825 | if (entry) | ||
1826 | entry = debugfs_create_file("device_id", S_IRUSR, root, | ||
1827 | docg3, &device_id_fops); | ||
1828 | if (entry) | ||
1829 | entry = debugfs_create_file("protection", S_IRUSR, root, | ||
1830 | docg3, &protection_fops); | ||
1831 | if (entry) { | ||
1832 | docg3->debugfs_root = root; | ||
1833 | return 0; | ||
1834 | } else { | ||
1835 | debugfs_remove_recursive(root); | ||
1836 | return -ENOMEM; | ||
1837 | } | ||
1838 | } | ||
1839 | |||
1840 | static void doc_dbg_unregister(struct docg3 *docg3) | ||
1841 | { | 1813 | { |
1842 | debugfs_remove_recursive(docg3->debugfs_root); | 1814 | struct dentry *root = floor->dbg.dfs_dir; |
1815 | struct docg3 *docg3 = floor->priv; | ||
1816 | |||
1817 | if (IS_ERR_OR_NULL(root)) | ||
1818 | return; | ||
1819 | |||
1820 | debugfs_create_file("docg3_flashcontrol", S_IRUSR, root, docg3, | ||
1821 | &flashcontrol_fops); | ||
1822 | debugfs_create_file("docg3_asic_mode", S_IRUSR, root, docg3, | ||
1823 | &asic_mode_fops); | ||
1824 | debugfs_create_file("docg3_device_id", S_IRUSR, root, docg3, | ||
1825 | &device_id_fops); | ||
1826 | debugfs_create_file("docg3_protection", S_IRUSR, root, docg3, | ||
1827 | &protection_fops); | ||
1843 | } | 1828 | } |
1844 | 1829 | ||
1845 | /** | 1830 | /** |
@@ -2114,6 +2099,8 @@ static int __init docg3_probe(struct platform_device *pdev) | |||
2114 | 0); | 2099 | 0); |
2115 | if (ret) | 2100 | if (ret) |
2116 | goto err_probe; | 2101 | goto err_probe; |
2102 | |||
2103 | doc_dbg_register(cascade->floors[floor]); | ||
2117 | } | 2104 | } |
2118 | 2105 | ||
2119 | ret = doc_register_sysfs(pdev, cascade); | 2106 | ret = doc_register_sysfs(pdev, cascade); |
@@ -2121,7 +2108,6 @@ static int __init docg3_probe(struct platform_device *pdev) | |||
2121 | goto err_probe; | 2108 | goto err_probe; |
2122 | 2109 | ||
2123 | platform_set_drvdata(pdev, cascade); | 2110 | platform_set_drvdata(pdev, cascade); |
2124 | doc_dbg_register(cascade->floors[0]->priv); | ||
2125 | return 0; | 2111 | return 0; |
2126 | 2112 | ||
2127 | notfound: | 2113 | notfound: |
@@ -2148,7 +2134,6 @@ static int docg3_release(struct platform_device *pdev) | |||
2148 | int floor; | 2134 | int floor; |
2149 | 2135 | ||
2150 | doc_unregister_sysfs(pdev, cascade); | 2136 | doc_unregister_sysfs(pdev, cascade); |
2151 | doc_dbg_unregister(docg3); | ||
2152 | for (floor = 0; floor < DOC_MAX_NBFLOORS; floor++) | 2137 | for (floor = 0; floor < DOC_MAX_NBFLOORS; floor++) |
2153 | if (cascade->floors[floor]) | 2138 | if (cascade->floors[floor]) |
2154 | doc_release_device(cascade->floors[floor]); | 2139 | doc_release_device(cascade->floors[floor]); |
diff --git a/drivers/mtd/devices/docg3.h b/drivers/mtd/devices/docg3.h index 19fb93f96a3a..e99946575398 100644 --- a/drivers/mtd/devices/docg3.h +++ b/drivers/mtd/devices/docg3.h | |||
@@ -299,7 +299,6 @@ struct docg3_cascade { | |||
299 | * @oob_autoecc: if 1, use only bytes 0-7, 15, and fill the others with HW ECC | 299 | * @oob_autoecc: if 1, use only bytes 0-7, 15, and fill the others with HW ECC |
300 | * if 0, use all the 16 bytes. | 300 | * if 0, use all the 16 bytes. |
301 | * @oob_write_buf: prepared OOB for next page_write | 301 | * @oob_write_buf: prepared OOB for next page_write |
302 | * @debugfs_root: debugfs root node | ||
303 | */ | 302 | */ |
304 | struct docg3 { | 303 | struct docg3 { |
305 | struct device *dev; | 304 | struct device *dev; |
@@ -312,7 +311,6 @@ struct docg3 { | |||
312 | loff_t oob_write_ofs; | 311 | loff_t oob_write_ofs; |
313 | int oob_autoecc; | 312 | int oob_autoecc; |
314 | u8 oob_write_buf[DOC_LAYOUT_OOB_SIZE]; | 313 | u8 oob_write_buf[DOC_LAYOUT_OOB_SIZE]; |
315 | struct dentry *debugfs_root; | ||
316 | }; | 314 | }; |
317 | 315 | ||
318 | #define doc_err(fmt, arg...) dev_err(docg3->dev, (fmt), ## arg) | 316 | #define doc_err(fmt, arg...) dev_err(docg3->dev, (fmt), ## arg) |
diff --git a/drivers/mtd/devices/spear_smi.c b/drivers/mtd/devices/spear_smi.c index dd5069876537..ddf478976013 100644 --- a/drivers/mtd/devices/spear_smi.c +++ b/drivers/mtd/devices/spear_smi.c | |||
@@ -775,6 +775,8 @@ static int spear_smi_probe_config_dt(struct platform_device *pdev, | |||
775 | pdata->board_flash_info = devm_kzalloc(&pdev->dev, | 775 | pdata->board_flash_info = devm_kzalloc(&pdev->dev, |
776 | sizeof(*pdata->board_flash_info), | 776 | sizeof(*pdata->board_flash_info), |
777 | GFP_KERNEL); | 777 | GFP_KERNEL); |
778 | if (!pdata->board_flash_info) | ||
779 | return -ENOMEM; | ||
778 | 780 | ||
779 | /* Fill structs for each subnode (flash device) */ | 781 | /* Fill structs for each subnode (flash device) */ |
780 | while ((pp = of_get_next_child(np, pp))) { | 782 | while ((pp = of_get_next_child(np, pp))) { |
diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c index 21afd94cd904..7bc29d725200 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c | |||
@@ -2073,15 +2073,17 @@ static int stfsm_probe(struct platform_device *pdev) | |||
2073 | ret = stfsm_init(fsm); | 2073 | ret = stfsm_init(fsm); |
2074 | if (ret) { | 2074 | if (ret) { |
2075 | dev_err(&pdev->dev, "Failed to initialise FSM Controller\n"); | 2075 | dev_err(&pdev->dev, "Failed to initialise FSM Controller\n"); |
2076 | return ret; | 2076 | goto err_clk_unprepare; |
2077 | } | 2077 | } |
2078 | 2078 | ||
2079 | stfsm_fetch_platform_configs(pdev); | 2079 | stfsm_fetch_platform_configs(pdev); |
2080 | 2080 | ||
2081 | /* Detect SPI FLASH device */ | 2081 | /* Detect SPI FLASH device */ |
2082 | info = stfsm_jedec_probe(fsm); | 2082 | info = stfsm_jedec_probe(fsm); |
2083 | if (!info) | 2083 | if (!info) { |
2084 | return -ENODEV; | 2084 | ret = -ENODEV; |
2085 | goto err_clk_unprepare; | ||
2086 | } | ||
2085 | fsm->info = info; | 2087 | fsm->info = info; |
2086 | 2088 | ||
2087 | /* Use device size to determine address width */ | 2089 | /* Use device size to determine address width */ |
@@ -2095,11 +2097,11 @@ static int stfsm_probe(struct platform_device *pdev) | |||
2095 | if (info->config) { | 2097 | if (info->config) { |
2096 | ret = info->config(fsm); | 2098 | ret = info->config(fsm); |
2097 | if (ret) | 2099 | if (ret) |
2098 | return ret; | 2100 | goto err_clk_unprepare; |
2099 | } else { | 2101 | } else { |
2100 | ret = stfsm_prepare_rwe_seqs_default(fsm); | 2102 | ret = stfsm_prepare_rwe_seqs_default(fsm); |
2101 | if (ret) | 2103 | if (ret) |
2102 | return ret; | 2104 | goto err_clk_unprepare; |
2103 | } | 2105 | } |
2104 | 2106 | ||
2105 | fsm->mtd.name = info->name; | 2107 | fsm->mtd.name = info->name; |
@@ -2124,6 +2126,10 @@ static int stfsm_probe(struct platform_device *pdev) | |||
2124 | fsm->mtd.erasesize, (fsm->mtd.erasesize >> 10)); | 2126 | fsm->mtd.erasesize, (fsm->mtd.erasesize >> 10)); |
2125 | 2127 | ||
2126 | return mtd_device_register(&fsm->mtd, NULL, 0); | 2128 | return mtd_device_register(&fsm->mtd, NULL, 0); |
2129 | |||
2130 | err_clk_unprepare: | ||
2131 | clk_disable_unprepare(fsm->clk); | ||
2132 | return ret; | ||
2127 | } | 2133 | } |
2128 | 2134 | ||
2129 | static int stfsm_remove(struct platform_device *pdev) | 2135 | static int stfsm_remove(struct platform_device *pdev) |
@@ -2147,9 +2153,7 @@ static int stfsmfsm_resume(struct device *dev) | |||
2147 | { | 2153 | { |
2148 | struct stfsm *fsm = dev_get_drvdata(dev); | 2154 | struct stfsm *fsm = dev_get_drvdata(dev); |
2149 | 2155 | ||
2150 | clk_prepare_enable(fsm->clk); | 2156 | return clk_prepare_enable(fsm->clk); |
2151 | |||
2152 | return 0; | ||
2153 | } | 2157 | } |
2154 | #endif | 2158 | #endif |
2155 | 2159 | ||
diff --git a/drivers/mtd/inftlcore.c b/drivers/mtd/inftlcore.c index 8db740d6eb08..57ef1fb42a04 100644 --- a/drivers/mtd/inftlcore.c +++ b/drivers/mtd/inftlcore.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/mtd/mtd.h> | 33 | #include <linux/mtd/mtd.h> |
34 | #include <linux/mtd/nftl.h> | 34 | #include <linux/mtd/nftl.h> |
35 | #include <linux/mtd/inftl.h> | 35 | #include <linux/mtd/inftl.h> |
36 | #include <linux/mtd/nand.h> | 36 | #include <linux/mtd/rawnand.h> |
37 | #include <linux/uaccess.h> | 37 | #include <linux/uaccess.h> |
38 | #include <asm/errno.h> | 38 | #include <asm/errno.h> |
39 | #include <asm/io.h> | 39 | #include <asm/io.h> |
diff --git a/drivers/mtd/maps/amd76xrom.c b/drivers/mtd/maps/amd76xrom.c index f2b68667ea59..26de0a1d08cf 100644 --- a/drivers/mtd/maps/amd76xrom.c +++ b/drivers/mtd/maps/amd76xrom.c | |||
@@ -296,7 +296,7 @@ static void amd76xrom_remove_one(struct pci_dev *pdev) | |||
296 | amd76xrom_cleanup(window); | 296 | amd76xrom_cleanup(window); |
297 | } | 297 | } |
298 | 298 | ||
299 | static struct pci_device_id amd76xrom_pci_tbl[] = { | 299 | static const struct pci_device_id amd76xrom_pci_tbl[] = { |
300 | { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7410, | 300 | { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7410, |
301 | PCI_ANY_ID, PCI_ANY_ID, }, | 301 | PCI_ANY_ID, PCI_ANY_ID, }, |
302 | { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7440, | 302 | { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7440, |
@@ -319,7 +319,7 @@ static struct pci_driver amd76xrom_driver = { | |||
319 | static int __init init_amd76xrom(void) | 319 | static int __init init_amd76xrom(void) |
320 | { | 320 | { |
321 | struct pci_dev *pdev; | 321 | struct pci_dev *pdev; |
322 | struct pci_device_id *id; | 322 | const struct pci_device_id *id; |
323 | pdev = NULL; | 323 | pdev = NULL; |
324 | for(id = amd76xrom_pci_tbl; id->vendor; id++) { | 324 | for(id = amd76xrom_pci_tbl; id->vendor; id++) { |
325 | pdev = pci_get_device(id->vendor, id->device, NULL); | 325 | pdev = pci_get_device(id->vendor, id->device, NULL); |
diff --git a/drivers/mtd/maps/ck804xrom.c b/drivers/mtd/maps/ck804xrom.c index 4f206a99164c..584962ec49f8 100644 --- a/drivers/mtd/maps/ck804xrom.c +++ b/drivers/mtd/maps/ck804xrom.c | |||
@@ -326,7 +326,7 @@ static void ck804xrom_remove_one(struct pci_dev *pdev) | |||
326 | ck804xrom_cleanup(window); | 326 | ck804xrom_cleanup(window); |
327 | } | 327 | } |
328 | 328 | ||
329 | static struct pci_device_id ck804xrom_pci_tbl[] = { | 329 | static const struct pci_device_id ck804xrom_pci_tbl[] = { |
330 | { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, 0x0051), .driver_data = DEV_CK804 }, | 330 | { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, 0x0051), .driver_data = DEV_CK804 }, |
331 | { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, 0x0360), .driver_data = DEV_MCP55 }, | 331 | { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, 0x0360), .driver_data = DEV_MCP55 }, |
332 | { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, 0x0361), .driver_data = DEV_MCP55 }, | 332 | { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, 0x0361), .driver_data = DEV_MCP55 }, |
@@ -353,7 +353,7 @@ static struct pci_driver ck804xrom_driver = { | |||
353 | static int __init init_ck804xrom(void) | 353 | static int __init init_ck804xrom(void) |
354 | { | 354 | { |
355 | struct pci_dev *pdev; | 355 | struct pci_dev *pdev; |
356 | struct pci_device_id *id; | 356 | const struct pci_device_id *id; |
357 | int retVal; | 357 | int retVal; |
358 | pdev = NULL; | 358 | pdev = NULL; |
359 | 359 | ||
diff --git a/drivers/mtd/maps/esb2rom.c b/drivers/mtd/maps/esb2rom.c index 9646b0766ce0..da9f6d76ce1d 100644 --- a/drivers/mtd/maps/esb2rom.c +++ b/drivers/mtd/maps/esb2rom.c | |||
@@ -384,7 +384,7 @@ static void esb2rom_remove_one(struct pci_dev *pdev) | |||
384 | esb2rom_cleanup(window); | 384 | esb2rom_cleanup(window); |
385 | } | 385 | } |
386 | 386 | ||
387 | static struct pci_device_id esb2rom_pci_tbl[] = { | 387 | static const struct pci_device_id esb2rom_pci_tbl[] = { |
388 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_0, | 388 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_0, |
389 | PCI_ANY_ID, PCI_ANY_ID, }, | 389 | PCI_ANY_ID, PCI_ANY_ID, }, |
390 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0, | 390 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0, |
@@ -414,7 +414,7 @@ static struct pci_driver esb2rom_driver = { | |||
414 | static int __init init_esb2rom(void) | 414 | static int __init init_esb2rom(void) |
415 | { | 415 | { |
416 | struct pci_dev *pdev; | 416 | struct pci_dev *pdev; |
417 | struct pci_device_id *id; | 417 | const struct pci_device_id *id; |
418 | int retVal; | 418 | int retVal; |
419 | 419 | ||
420 | pdev = NULL; | 420 | pdev = NULL; |
diff --git a/drivers/mtd/maps/ichxrom.c b/drivers/mtd/maps/ichxrom.c index 976d42f63aef..1888c5bf13f8 100644 --- a/drivers/mtd/maps/ichxrom.c +++ b/drivers/mtd/maps/ichxrom.c | |||
@@ -323,7 +323,7 @@ static void ichxrom_remove_one(struct pci_dev *pdev) | |||
323 | ichxrom_cleanup(window); | 323 | ichxrom_cleanup(window); |
324 | } | 324 | } |
325 | 325 | ||
326 | static struct pci_device_id ichxrom_pci_tbl[] = { | 326 | static const struct pci_device_id ichxrom_pci_tbl[] = { |
327 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_0, | 327 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_0, |
328 | PCI_ANY_ID, PCI_ANY_ID, }, | 328 | PCI_ANY_ID, PCI_ANY_ID, }, |
329 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0, | 329 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0, |
@@ -351,7 +351,7 @@ static struct pci_driver ichxrom_driver = { | |||
351 | static int __init init_ichxrom(void) | 351 | static int __init init_ichxrom(void) |
352 | { | 352 | { |
353 | struct pci_dev *pdev; | 353 | struct pci_dev *pdev; |
354 | struct pci_device_id *id; | 354 | const struct pci_device_id *id; |
355 | 355 | ||
356 | pdev = NULL; | 356 | pdev = NULL; |
357 | for (id = ichxrom_pci_tbl; id->vendor; id++) { | 357 | for (id = ichxrom_pci_tbl; id->vendor; id++) { |
diff --git a/drivers/mtd/maps/intel_vr_nor.c b/drivers/mtd/maps/intel_vr_nor.c index 8bf79775e7c1..dd5d6855f543 100644 --- a/drivers/mtd/maps/intel_vr_nor.c +++ b/drivers/mtd/maps/intel_vr_nor.c | |||
@@ -170,7 +170,7 @@ static int vr_nor_init_maps(struct vr_nor_mtd *p) | |||
170 | return err; | 170 | return err; |
171 | } | 171 | } |
172 | 172 | ||
173 | static struct pci_device_id vr_nor_pci_ids[] = { | 173 | static const struct pci_device_id vr_nor_pci_ids[] = { |
174 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x500D)}, | 174 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x500D)}, |
175 | {0,} | 175 | {0,} |
176 | }; | 176 | }; |
diff --git a/drivers/mtd/maps/pci.c b/drivers/mtd/maps/pci.c index eb0242e0b2d9..7b3bb40aff72 100644 --- a/drivers/mtd/maps/pci.c +++ b/drivers/mtd/maps/pci.c | |||
@@ -228,7 +228,7 @@ static struct mtd_pci_info intel_dc21285_info = { | |||
228 | * PCI device ID table | 228 | * PCI device ID table |
229 | */ | 229 | */ |
230 | 230 | ||
231 | static struct pci_device_id mtd_pci_ids[] = { | 231 | static const struct pci_device_id mtd_pci_ids[] = { |
232 | { | 232 | { |
233 | .vendor = PCI_VENDOR_ID_INTEL, | 233 | .vendor = PCI_VENDOR_ID_INTEL, |
234 | .device = 0x530d, | 234 | .device = 0x530d, |
diff --git a/drivers/mtd/maps/physmap_of_core.c b/drivers/mtd/maps/physmap_of_core.c index 62fa6836f218..b1bd4faecfb2 100644 --- a/drivers/mtd/maps/physmap_of_core.c +++ b/drivers/mtd/maps/physmap_of_core.c | |||
@@ -178,8 +178,8 @@ static int of_flash_probe(struct platform_device *dev) | |||
178 | */ | 178 | */ |
179 | p = of_get_property(dp, "reg", &count); | 179 | p = of_get_property(dp, "reg", &count); |
180 | if (!p || count % reg_tuple_size != 0) { | 180 | if (!p || count % reg_tuple_size != 0) { |
181 | dev_err(&dev->dev, "Malformed reg property on %s\n", | 181 | dev_err(&dev->dev, "Malformed reg property on %pOF\n", |
182 | dev->dev.of_node->full_name); | 182 | dev->dev.of_node); |
183 | err = -EINVAL; | 183 | err = -EINVAL; |
184 | goto err_flash_remove; | 184 | goto err_flash_remove; |
185 | } | 185 | } |
@@ -235,10 +235,10 @@ static int of_flash_probe(struct platform_device *dev) | |||
235 | 235 | ||
236 | err = of_flash_probe_gemini(dev, dp, &info->list[i].map); | 236 | err = of_flash_probe_gemini(dev, dp, &info->list[i].map); |
237 | if (err) | 237 | if (err) |
238 | return err; | 238 | goto err_out; |
239 | err = of_flash_probe_versatile(dev, dp, &info->list[i].map); | 239 | err = of_flash_probe_versatile(dev, dp, &info->list[i].map); |
240 | if (err) | 240 | if (err) |
241 | return err; | 241 | goto err_out; |
242 | 242 | ||
243 | err = -ENOMEM; | 243 | err = -ENOMEM; |
244 | info->list[i].map.virt = ioremap(info->list[i].map.phys, | 244 | info->list[i].map.virt = ioremap(info->list[i].map.phys, |
diff --git a/drivers/mtd/maps/physmap_of_gemini.c b/drivers/mtd/maps/physmap_of_gemini.c index 05b286b5289f..4ed1a6bb4d3c 100644 --- a/drivers/mtd/maps/physmap_of_gemini.c +++ b/drivers/mtd/maps/physmap_of_gemini.c | |||
@@ -43,13 +43,6 @@ | |||
43 | 43 | ||
44 | #define FLASH_PARALLEL_HIGH_PIN_CNT (1 << 20) /* else low pin cnt */ | 44 | #define FLASH_PARALLEL_HIGH_PIN_CNT (1 << 20) /* else low pin cnt */ |
45 | 45 | ||
46 | /* Miscellaneous Control Register */ | ||
47 | #define GLOBAL_MISC_CTRL 0x30 | ||
48 | #define FLASH_PADS_MASK 0x07 | ||
49 | #define NAND_PADS_DISABLE BIT(2) | ||
50 | #define PFLASH_PADS_DISABLE BIT(1) | ||
51 | #define SFLASH_PADS_DISABLE BIT(0) | ||
52 | |||
53 | static const struct of_device_id syscon_match[] = { | 46 | static const struct of_device_id syscon_match[] = { |
54 | { .compatible = "cortina,gemini-syscon" }, | 47 | { .compatible = "cortina,gemini-syscon" }, |
55 | { }, | 48 | { }, |
@@ -102,15 +95,6 @@ int of_flash_probe_gemini(struct platform_device *pdev, | |||
102 | map->bankwidth * 8); | 95 | map->bankwidth * 8); |
103 | } | 96 | } |
104 | 97 | ||
105 | /* Activate parallel (NOR flash) mode */ | ||
106 | ret = regmap_update_bits(rmap, GLOBAL_MISC_CTRL, | ||
107 | FLASH_PADS_MASK, | ||
108 | SFLASH_PADS_DISABLE | NAND_PADS_DISABLE); | ||
109 | if (ret) { | ||
110 | dev_err(dev, "unable to set up physmap pads\n"); | ||
111 | return -ENODEV; | ||
112 | } | ||
113 | |||
114 | dev_info(&pdev->dev, "initialized Gemini-specific physmap control\n"); | 98 | dev_info(&pdev->dev, "initialized Gemini-specific physmap control\n"); |
115 | 99 | ||
116 | return 0; | 100 | return 0; |
diff --git a/drivers/mtd/maps/physmap_of_versatile.c b/drivers/mtd/maps/physmap_of_versatile.c index 8c6ccded9be8..03f2b6e7bc7e 100644 --- a/drivers/mtd/maps/physmap_of_versatile.c +++ b/drivers/mtd/maps/physmap_of_versatile.c | |||
@@ -97,7 +97,7 @@ static const struct of_device_id ebi_match[] = { | |||
97 | static int ap_flash_init(struct platform_device *pdev) | 97 | static int ap_flash_init(struct platform_device *pdev) |
98 | { | 98 | { |
99 | struct device_node *ebi; | 99 | struct device_node *ebi; |
100 | static void __iomem *ebi_base; | 100 | void __iomem *ebi_base; |
101 | u32 val; | 101 | u32 val; |
102 | int ret; | 102 | int ret; |
103 | 103 | ||
diff --git a/drivers/mtd/maps/sun_uflash.c b/drivers/mtd/maps/sun_uflash.c index 414956eca0c9..1e73bba6e286 100644 --- a/drivers/mtd/maps/sun_uflash.c +++ b/drivers/mtd/maps/sun_uflash.c | |||
@@ -55,8 +55,8 @@ int uflash_devinit(struct platform_device *op, struct device_node *dp) | |||
55 | /* Non-CFI userflash device-- once I find one we | 55 | /* Non-CFI userflash device-- once I find one we |
56 | * can work on supporting it. | 56 | * can work on supporting it. |
57 | */ | 57 | */ |
58 | printk(KERN_ERR PFX "Unsupported device at %s, 0x%llx\n", | 58 | printk(KERN_ERR PFX "Unsupported device at %pOF, 0x%llx\n", |
59 | dp->full_name, (unsigned long long)op->resource[0].start); | 59 | dp, (unsigned long long)op->resource[0].start); |
60 | 60 | ||
61 | return -ENODEV; | 61 | return -ENODEV; |
62 | } | 62 | } |
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 956382cea256..e7ea842ba3db 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
41 | #include <linux/reboot.h> | 41 | #include <linux/reboot.h> |
42 | #include <linux/leds.h> | 42 | #include <linux/leds.h> |
43 | #include <linux/debugfs.h> | ||
43 | 44 | ||
44 | #include <linux/mtd/mtd.h> | 45 | #include <linux/mtd/mtd.h> |
45 | #include <linux/mtd/partitions.h> | 46 | #include <linux/mtd/partitions.h> |
@@ -339,7 +340,7 @@ static struct attribute *mtd_attrs[] = { | |||
339 | }; | 340 | }; |
340 | ATTRIBUTE_GROUPS(mtd); | 341 | ATTRIBUTE_GROUPS(mtd); |
341 | 342 | ||
342 | static struct device_type mtd_devtype = { | 343 | static const struct device_type mtd_devtype = { |
343 | .name = "mtd", | 344 | .name = "mtd", |
344 | .groups = mtd_groups, | 345 | .groups = mtd_groups, |
345 | .release = mtd_release, | 346 | .release = mtd_release, |
@@ -477,6 +478,8 @@ int mtd_pairing_groups(struct mtd_info *mtd) | |||
477 | } | 478 | } |
478 | EXPORT_SYMBOL_GPL(mtd_pairing_groups); | 479 | EXPORT_SYMBOL_GPL(mtd_pairing_groups); |
479 | 480 | ||
481 | static struct dentry *dfs_dir_mtd; | ||
482 | |||
480 | /** | 483 | /** |
481 | * add_mtd_device - register an MTD device | 484 | * add_mtd_device - register an MTD device |
482 | * @mtd: pointer to new MTD device info structure | 485 | * @mtd: pointer to new MTD device info structure |
@@ -552,6 +555,14 @@ int add_mtd_device(struct mtd_info *mtd) | |||
552 | if (error) | 555 | if (error) |
553 | goto fail_added; | 556 | goto fail_added; |
554 | 557 | ||
558 | if (!IS_ERR_OR_NULL(dfs_dir_mtd)) { | ||
559 | mtd->dbg.dfs_dir = debugfs_create_dir(dev_name(&mtd->dev), dfs_dir_mtd); | ||
560 | if (IS_ERR_OR_NULL(mtd->dbg.dfs_dir)) { | ||
561 | pr_debug("mtd device %s won't show data in debugfs\n", | ||
562 | dev_name(&mtd->dev)); | ||
563 | } | ||
564 | } | ||
565 | |||
555 | device_create(&mtd_class, mtd->dev.parent, MTD_DEVT(i) + 1, NULL, | 566 | device_create(&mtd_class, mtd->dev.parent, MTD_DEVT(i) + 1, NULL, |
556 | "mtd%dro", i); | 567 | "mtd%dro", i); |
557 | 568 | ||
@@ -594,6 +605,8 @@ int del_mtd_device(struct mtd_info *mtd) | |||
594 | 605 | ||
595 | mutex_lock(&mtd_table_mutex); | 606 | mutex_lock(&mtd_table_mutex); |
596 | 607 | ||
608 | debugfs_remove_recursive(mtd->dbg.dfs_dir); | ||
609 | |||
597 | if (idr_find(&mtd_idr, mtd->index) != mtd) { | 610 | if (idr_find(&mtd_idr, mtd->index) != mtd) { |
598 | ret = -ENODEV; | 611 | ret = -ENODEV; |
599 | goto out_error; | 612 | goto out_error; |
@@ -1811,6 +1824,8 @@ static int __init init_mtd(void) | |||
1811 | if (ret) | 1824 | if (ret) |
1812 | goto out_procfs; | 1825 | goto out_procfs; |
1813 | 1826 | ||
1827 | dfs_dir_mtd = debugfs_create_dir("mtd", NULL); | ||
1828 | |||
1814 | return 0; | 1829 | return 0; |
1815 | 1830 | ||
1816 | out_procfs: | 1831 | out_procfs: |
@@ -1826,6 +1841,7 @@ err_reg: | |||
1826 | 1841 | ||
1827 | static void __exit cleanup_mtd(void) | 1842 | static void __exit cleanup_mtd(void) |
1828 | { | 1843 | { |
1844 | debugfs_remove_recursive(dfs_dir_mtd); | ||
1829 | cleanup_mtdchar(); | 1845 | cleanup_mtdchar(); |
1830 | if (proc_mtd) | 1846 | if (proc_mtd) |
1831 | remove_proc_entry("mtd", NULL); | 1847 | remove_proc_entry("mtd", NULL); |
diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c index f12879a3d4ff..7d9080e33865 100644 --- a/drivers/mtd/mtdswap.c +++ b/drivers/mtd/mtdswap.c | |||
@@ -138,8 +138,6 @@ struct mtdswap_dev { | |||
138 | 138 | ||
139 | char *page_buf; | 139 | char *page_buf; |
140 | char *oob_buf; | 140 | char *oob_buf; |
141 | |||
142 | struct dentry *debugfs_root; | ||
143 | }; | 141 | }; |
144 | 142 | ||
145 | struct mtdswap_oobdata { | 143 | struct mtdswap_oobdata { |
@@ -1315,29 +1313,19 @@ static const struct file_operations mtdswap_fops = { | |||
1315 | 1313 | ||
1316 | static int mtdswap_add_debugfs(struct mtdswap_dev *d) | 1314 | static int mtdswap_add_debugfs(struct mtdswap_dev *d) |
1317 | { | 1315 | { |
1318 | struct gendisk *gd = d->mbd_dev->disk; | 1316 | struct dentry *root = d->mtd->dbg.dfs_dir; |
1319 | struct device *dev = disk_to_dev(gd); | ||
1320 | |||
1321 | struct dentry *root; | ||
1322 | struct dentry *dent; | 1317 | struct dentry *dent; |
1323 | 1318 | ||
1324 | root = debugfs_create_dir(gd->disk_name, NULL); | 1319 | if (!IS_ENABLED(CONFIG_DEBUG_FS)) |
1325 | if (IS_ERR(root)) | ||
1326 | return 0; | 1320 | return 0; |
1327 | 1321 | ||
1328 | if (!root) { | 1322 | if (IS_ERR_OR_NULL(root)) |
1329 | dev_err(dev, "failed to initialize debugfs\n"); | ||
1330 | return -1; | 1323 | return -1; |
1331 | } | ||
1332 | |||
1333 | d->debugfs_root = root; | ||
1334 | 1324 | ||
1335 | dent = debugfs_create_file("stats", S_IRUSR, root, d, | 1325 | dent = debugfs_create_file("mtdswap_stats", S_IRUSR, root, d, |
1336 | &mtdswap_fops); | 1326 | &mtdswap_fops); |
1337 | if (!dent) { | 1327 | if (!dent) { |
1338 | dev_err(d->dev, "debugfs_create_file failed\n"); | 1328 | dev_err(d->dev, "debugfs_create_file failed\n"); |
1339 | debugfs_remove_recursive(root); | ||
1340 | d->debugfs_root = NULL; | ||
1341 | return -1; | 1329 | return -1; |
1342 | } | 1330 | } |
1343 | 1331 | ||
@@ -1540,7 +1528,6 @@ static void mtdswap_remove_dev(struct mtd_blktrans_dev *dev) | |||
1540 | { | 1528 | { |
1541 | struct mtdswap_dev *d = MTDSWAP_MBD_TO_MTDSWAP(dev); | 1529 | struct mtdswap_dev *d = MTDSWAP_MBD_TO_MTDSWAP(dev); |
1542 | 1530 | ||
1543 | debugfs_remove_recursive(d->debugfs_root); | ||
1544 | del_mtd_blktrans_dev(dev); | 1531 | del_mtd_blktrans_dev(dev); |
1545 | mtdswap_cleanup(d); | 1532 | mtdswap_cleanup(d); |
1546 | kfree(d); | 1533 | kfree(d); |
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig index dbfa72d61d5a..3f2036f31da4 100644 --- a/drivers/mtd/nand/Kconfig +++ b/drivers/mtd/nand/Kconfig | |||
@@ -315,7 +315,7 @@ config MTD_NAND_ATMEL | |||
315 | 315 | ||
316 | config MTD_NAND_PXA3xx | 316 | config MTD_NAND_PXA3xx |
317 | tristate "NAND support on PXA3xx and Armada 370/XP" | 317 | tristate "NAND support on PXA3xx and Armada 370/XP" |
318 | depends on PXA3xx || ARCH_MMP || PLAT_ORION | 318 | depends on PXA3xx || ARCH_MMP || PLAT_ORION || ARCH_MVEBU |
319 | help | 319 | help |
320 | This enables the driver for the NAND flash device found on | 320 | This enables the driver for the NAND flash device found on |
321 | PXA3xx processors (NFCv1) and also on Armada 370/XP (NFCv2). | 321 | PXA3xx processors (NFCv1) and also on Armada 370/XP (NFCv2). |
diff --git a/drivers/mtd/nand/ams-delta.c b/drivers/mtd/nand/ams-delta.c index 5d6c26f3cf7f..dcec9cf4983f 100644 --- a/drivers/mtd/nand/ams-delta.c +++ b/drivers/mtd/nand/ams-delta.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
22 | #include <linux/mtd/mtd.h> | 22 | #include <linux/mtd/mtd.h> |
23 | #include <linux/mtd/nand.h> | 23 | #include <linux/mtd/rawnand.h> |
24 | #include <linux/mtd/partitions.h> | 24 | #include <linux/mtd/partitions.h> |
25 | #include <linux/gpio.h> | 25 | #include <linux/gpio.h> |
26 | #include <linux/platform_data/gpio-omap.h> | 26 | #include <linux/platform_data/gpio-omap.h> |
diff --git a/drivers/mtd/nand/atmel/nand-controller.c b/drivers/mtd/nand/atmel/nand-controller.c index 1913ce18fb1c..f25eca79f4e5 100644 --- a/drivers/mtd/nand/atmel/nand-controller.c +++ b/drivers/mtd/nand/atmel/nand-controller.c | |||
@@ -59,7 +59,7 @@ | |||
59 | #include <linux/mfd/syscon/atmel-matrix.h> | 59 | #include <linux/mfd/syscon/atmel-matrix.h> |
60 | #include <linux/mfd/syscon/atmel-smc.h> | 60 | #include <linux/mfd/syscon/atmel-smc.h> |
61 | #include <linux/module.h> | 61 | #include <linux/module.h> |
62 | #include <linux/mtd/nand.h> | 62 | #include <linux/mtd/rawnand.h> |
63 | #include <linux/of_address.h> | 63 | #include <linux/of_address.h> |
64 | #include <linux/of_irq.h> | 64 | #include <linux/of_irq.h> |
65 | #include <linux/of_platform.h> | 65 | #include <linux/of_platform.h> |
@@ -2091,8 +2091,8 @@ atmel_hsmc_nand_controller_legacy_init(struct atmel_hsmc_nand_controller *nc) | |||
2091 | } | 2091 | } |
2092 | 2092 | ||
2093 | nc->irq = of_irq_get(nand_np, 0); | 2093 | nc->irq = of_irq_get(nand_np, 0); |
2094 | if (nc->irq < 0) { | 2094 | if (nc->irq <= 0) { |
2095 | ret = nc->irq; | 2095 | ret = nc->irq ?: -ENXIO; |
2096 | if (ret != -EPROBE_DEFER) | 2096 | if (ret != -EPROBE_DEFER) |
2097 | dev_err(dev, "Failed to get IRQ number (err = %d)\n", | 2097 | dev_err(dev, "Failed to get IRQ number (err = %d)\n", |
2098 | ret); | 2098 | ret); |
@@ -2183,11 +2183,12 @@ atmel_hsmc_nand_controller_init(struct atmel_hsmc_nand_controller *nc) | |||
2183 | 2183 | ||
2184 | nc->irq = of_irq_get(np, 0); | 2184 | nc->irq = of_irq_get(np, 0); |
2185 | of_node_put(np); | 2185 | of_node_put(np); |
2186 | if (nc->irq < 0) { | 2186 | if (nc->irq <= 0) { |
2187 | if (nc->irq != -EPROBE_DEFER) | 2187 | ret = nc->irq ?: -ENXIO; |
2188 | if (ret != -EPROBE_DEFER) | ||
2188 | dev_err(dev, "Failed to get IRQ number (err = %d)\n", | 2189 | dev_err(dev, "Failed to get IRQ number (err = %d)\n", |
2189 | nc->irq); | 2190 | ret); |
2190 | return nc->irq; | 2191 | return ret; |
2191 | } | 2192 | } |
2192 | 2193 | ||
2193 | np = of_parse_phandle(dev->of_node, "atmel,nfc-io", 0); | 2194 | np = of_parse_phandle(dev->of_node, "atmel,nfc-io", 0); |
diff --git a/drivers/mtd/nand/atmel/pmecc.c b/drivers/mtd/nand/atmel/pmecc.c index 8c210a5776bc..146af8218314 100644 --- a/drivers/mtd/nand/atmel/pmecc.c +++ b/drivers/mtd/nand/atmel/pmecc.c | |||
@@ -47,7 +47,7 @@ | |||
47 | #include <linux/genalloc.h> | 47 | #include <linux/genalloc.h> |
48 | #include <linux/iopoll.h> | 48 | #include <linux/iopoll.h> |
49 | #include <linux/module.h> | 49 | #include <linux/module.h> |
50 | #include <linux/mtd/nand.h> | 50 | #include <linux/mtd/rawnand.h> |
51 | #include <linux/of_irq.h> | 51 | #include <linux/of_irq.h> |
52 | #include <linux/of_platform.h> | 52 | #include <linux/of_platform.h> |
53 | #include <linux/platform_device.h> | 53 | #include <linux/platform_device.h> |
diff --git a/drivers/mtd/nand/au1550nd.c b/drivers/mtd/nand/au1550nd.c index 9bf6d9915694..9d4a28fa6b73 100644 --- a/drivers/mtd/nand/au1550nd.c +++ b/drivers/mtd/nand/au1550nd.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/interrupt.h> | 15 | #include <linux/interrupt.h> |
16 | #include <linux/mtd/mtd.h> | 16 | #include <linux/mtd/mtd.h> |
17 | #include <linux/mtd/nand.h> | 17 | #include <linux/mtd/rawnand.h> |
18 | #include <linux/mtd/partitions.h> | 18 | #include <linux/mtd/partitions.h> |
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <asm/io.h> | 20 | #include <asm/io.h> |
diff --git a/drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h b/drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h index 8ea75710a854..c8834767ab6d 100644 --- a/drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h +++ b/drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h | |||
@@ -6,7 +6,7 @@ | |||
6 | #endif | 6 | #endif |
7 | 7 | ||
8 | #include <linux/mtd/mtd.h> | 8 | #include <linux/mtd/mtd.h> |
9 | #include <linux/mtd/nand.h> | 9 | #include <linux/mtd/rawnand.h> |
10 | 10 | ||
11 | struct bcm47xxnflash { | 11 | struct bcm47xxnflash { |
12 | struct bcma_drv_cc *cc; | 12 | struct bcma_drv_cc *cc; |
diff --git a/drivers/mtd/nand/bf5xx_nand.c b/drivers/mtd/nand/bf5xx_nand.c index 3962f55bd034..5655dca6ce43 100644 --- a/drivers/mtd/nand/bf5xx_nand.c +++ b/drivers/mtd/nand/bf5xx_nand.c | |||
@@ -49,7 +49,7 @@ | |||
49 | #include <linux/bitops.h> | 49 | #include <linux/bitops.h> |
50 | 50 | ||
51 | #include <linux/mtd/mtd.h> | 51 | #include <linux/mtd/mtd.h> |
52 | #include <linux/mtd/nand.h> | 52 | #include <linux/mtd/rawnand.h> |
53 | #include <linux/mtd/nand_ecc.h> | 53 | #include <linux/mtd/nand_ecc.h> |
54 | #include <linux/mtd/partitions.h> | 54 | #include <linux/mtd/partitions.h> |
55 | 55 | ||
diff --git a/drivers/mtd/nand/brcmnand/brcmnand.c b/drivers/mtd/nand/brcmnand/brcmnand.c index 7419c5ce63f8..e0eb51d8c012 100644 --- a/drivers/mtd/nand/brcmnand/brcmnand.c +++ b/drivers/mtd/nand/brcmnand/brcmnand.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <linux/bitops.h> | 29 | #include <linux/bitops.h> |
30 | #include <linux/mm.h> | 30 | #include <linux/mm.h> |
31 | #include <linux/mtd/mtd.h> | 31 | #include <linux/mtd/mtd.h> |
32 | #include <linux/mtd/nand.h> | 32 | #include <linux/mtd/rawnand.h> |
33 | #include <linux/mtd/partitions.h> | 33 | #include <linux/mtd/partitions.h> |
34 | #include <linux/of.h> | 34 | #include <linux/of.h> |
35 | #include <linux/of_platform.h> | 35 | #include <linux/of_platform.h> |
diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c index 2fd733eba0a3..bc558c438a57 100644 --- a/drivers/mtd/nand/cafe_nand.c +++ b/drivers/mtd/nand/cafe_nand.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <linux/device.h> | 13 | #include <linux/device.h> |
14 | #undef DEBUG | 14 | #undef DEBUG |
15 | #include <linux/mtd/mtd.h> | 15 | #include <linux/mtd/mtd.h> |
16 | #include <linux/mtd/nand.h> | 16 | #include <linux/mtd/rawnand.h> |
17 | #include <linux/mtd/partitions.h> | 17 | #include <linux/mtd/partitions.h> |
18 | #include <linux/rslib.h> | 18 | #include <linux/rslib.h> |
19 | #include <linux/pci.h> | 19 | #include <linux/pci.h> |
diff --git a/drivers/mtd/nand/cmx270_nand.c b/drivers/mtd/nand/cmx270_nand.c index 949b9400dcb7..1fc435f994e1 100644 --- a/drivers/mtd/nand/cmx270_nand.c +++ b/drivers/mtd/nand/cmx270_nand.c | |||
@@ -18,7 +18,7 @@ | |||
18 | * CM-X270 board. | 18 | * CM-X270 board. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/mtd/nand.h> | 21 | #include <linux/mtd/rawnand.h> |
22 | #include <linux/mtd/partitions.h> | 22 | #include <linux/mtd/partitions.h> |
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/gpio.h> | 24 | #include <linux/gpio.h> |
diff --git a/drivers/mtd/nand/cs553x_nand.c b/drivers/mtd/nand/cs553x_nand.c index 594b28684138..d48877540f14 100644 --- a/drivers/mtd/nand/cs553x_nand.c +++ b/drivers/mtd/nand/cs553x_nand.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | #include <linux/delay.h> | 25 | #include <linux/delay.h> |
26 | #include <linux/mtd/mtd.h> | 26 | #include <linux/mtd/mtd.h> |
27 | #include <linux/mtd/nand.h> | 27 | #include <linux/mtd/rawnand.h> |
28 | #include <linux/mtd/nand_ecc.h> | 28 | #include <linux/mtd/nand_ecc.h> |
29 | #include <linux/mtd/partitions.h> | 29 | #include <linux/mtd/partitions.h> |
30 | 30 | ||
diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c index 7b26e53b95b1..ccc8c43abcff 100644 --- a/drivers/mtd/nand/davinci_nand.c +++ b/drivers/mtd/nand/davinci_nand.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <linux/err.h> | 29 | #include <linux/err.h> |
30 | #include <linux/clk.h> | 30 | #include <linux/clk.h> |
31 | #include <linux/io.h> | 31 | #include <linux/io.h> |
32 | #include <linux/mtd/nand.h> | 32 | #include <linux/mtd/rawnand.h> |
33 | #include <linux/mtd/partitions.h> | 33 | #include <linux/mtd/partitions.h> |
34 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
35 | #include <linux/of_device.h> | 35 | #include <linux/of_device.h> |
diff --git a/drivers/mtd/nand/denali.h b/drivers/mtd/nand/denali.h index 237cc706b0fb..9239e6793e6e 100644 --- a/drivers/mtd/nand/denali.h +++ b/drivers/mtd/nand/denali.h | |||
@@ -21,7 +21,7 @@ | |||
21 | #define __DENALI_H__ | 21 | #define __DENALI_H__ |
22 | 22 | ||
23 | #include <linux/bitops.h> | 23 | #include <linux/bitops.h> |
24 | #include <linux/mtd/nand.h> | 24 | #include <linux/mtd/rawnand.h> |
25 | 25 | ||
26 | #define DEVICE_RESET 0x0 | 26 | #define DEVICE_RESET 0x0 |
27 | #define DEVICE_RESET__BANK(bank) BIT(bank) | 27 | #define DEVICE_RESET__BANK(bank) BIT(bank) |
diff --git a/drivers/mtd/nand/denali_dt.c b/drivers/mtd/nand/denali_dt.c index 47f398edf18f..56e2e177644d 100644 --- a/drivers/mtd/nand/denali_dt.c +++ b/drivers/mtd/nand/denali_dt.c | |||
@@ -118,7 +118,9 @@ static int denali_dt_probe(struct platform_device *pdev) | |||
118 | dev_err(&pdev->dev, "no clk available\n"); | 118 | dev_err(&pdev->dev, "no clk available\n"); |
119 | return PTR_ERR(dt->clk); | 119 | return PTR_ERR(dt->clk); |
120 | } | 120 | } |
121 | clk_prepare_enable(dt->clk); | 121 | ret = clk_prepare_enable(dt->clk); |
122 | if (ret) | ||
123 | return ret; | ||
122 | 124 | ||
123 | denali->clk_x_rate = clk_get_rate(dt->clk); | 125 | denali->clk_x_rate = clk_get_rate(dt->clk); |
124 | 126 | ||
diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c index a023ab9e9cbf..c3aa53caab5c 100644 --- a/drivers/mtd/nand/diskonchip.c +++ b/drivers/mtd/nand/diskonchip.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include <linux/io.h> | 27 | #include <linux/io.h> |
28 | 28 | ||
29 | #include <linux/mtd/mtd.h> | 29 | #include <linux/mtd/mtd.h> |
30 | #include <linux/mtd/nand.h> | 30 | #include <linux/mtd/rawnand.h> |
31 | #include <linux/mtd/doc2000.h> | 31 | #include <linux/mtd/doc2000.h> |
32 | #include <linux/mtd/partitions.h> | 32 | #include <linux/mtd/partitions.h> |
33 | #include <linux/mtd/inftl.h> | 33 | #include <linux/mtd/inftl.h> |
diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c index a27a84fbfb84..2436cbc71662 100644 --- a/drivers/mtd/nand/docg4.c +++ b/drivers/mtd/nand/docg4.c | |||
@@ -41,7 +41,7 @@ | |||
41 | #include <linux/bitops.h> | 41 | #include <linux/bitops.h> |
42 | #include <linux/mtd/partitions.h> | 42 | #include <linux/mtd/partitions.h> |
43 | #include <linux/mtd/mtd.h> | 43 | #include <linux/mtd/mtd.h> |
44 | #include <linux/mtd/nand.h> | 44 | #include <linux/mtd/rawnand.h> |
45 | #include <linux/bch.h> | 45 | #include <linux/bch.h> |
46 | #include <linux/bitrev.h> | 46 | #include <linux/bitrev.h> |
47 | #include <linux/jiffies.h> | 47 | #include <linux/jiffies.h> |
diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c index b9ac16f05057..17db2f90aa2c 100644 --- a/drivers/mtd/nand/fsl_elbc_nand.c +++ b/drivers/mtd/nand/fsl_elbc_nand.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #include <linux/interrupt.h> | 34 | #include <linux/interrupt.h> |
35 | 35 | ||
36 | #include <linux/mtd/mtd.h> | 36 | #include <linux/mtd/mtd.h> |
37 | #include <linux/mtd/nand.h> | 37 | #include <linux/mtd/rawnand.h> |
38 | #include <linux/mtd/nand_ecc.h> | 38 | #include <linux/mtd/nand_ecc.h> |
39 | #include <linux/mtd/partitions.h> | 39 | #include <linux/mtd/partitions.h> |
40 | 40 | ||
diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c index 59408ec2c69f..9e03bac7f34c 100644 --- a/drivers/mtd/nand/fsl_ifc_nand.c +++ b/drivers/mtd/nand/fsl_ifc_nand.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/of_address.h> | 26 | #include <linux/of_address.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/mtd/mtd.h> | 28 | #include <linux/mtd/mtd.h> |
29 | #include <linux/mtd/nand.h> | 29 | #include <linux/mtd/rawnand.h> |
30 | #include <linux/mtd/partitions.h> | 30 | #include <linux/mtd/partitions.h> |
31 | #include <linux/mtd/nand_ecc.h> | 31 | #include <linux/mtd/nand_ecc.h> |
32 | #include <linux/fsl_ifc.h> | 32 | #include <linux/fsl_ifc.h> |
diff --git a/drivers/mtd/nand/fsl_upm.c b/drivers/mtd/nand/fsl_upm.c index d85fa2555b68..a88e2cf66e0f 100644 --- a/drivers/mtd/nand/fsl_upm.c +++ b/drivers/mtd/nand/fsl_upm.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/delay.h> | 16 | #include <linux/delay.h> |
17 | #include <linux/mtd/nand.h> | 17 | #include <linux/mtd/rawnand.h> |
18 | #include <linux/mtd/nand_ecc.h> | 18 | #include <linux/mtd/nand_ecc.h> |
19 | #include <linux/mtd/partitions.h> | 19 | #include <linux/mtd/partitions.h> |
20 | #include <linux/mtd/mtd.h> | 20 | #include <linux/mtd/mtd.h> |
diff --git a/drivers/mtd/nand/fsmc_nand.c b/drivers/mtd/nand/fsmc_nand.c index 9d8b051d3187..eac15d9bf49e 100644 --- a/drivers/mtd/nand/fsmc_nand.c +++ b/drivers/mtd/nand/fsmc_nand.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <linux/sched.h> | 28 | #include <linux/sched.h> |
29 | #include <linux/types.h> | 29 | #include <linux/types.h> |
30 | #include <linux/mtd/mtd.h> | 30 | #include <linux/mtd/mtd.h> |
31 | #include <linux/mtd/nand.h> | 31 | #include <linux/mtd/rawnand.h> |
32 | #include <linux/mtd/nand_ecc.h> | 32 | #include <linux/mtd/nand_ecc.h> |
33 | #include <linux/platform_device.h> | 33 | #include <linux/platform_device.h> |
34 | #include <linux/of.h> | 34 | #include <linux/of.h> |
diff --git a/drivers/mtd/nand/gpio.c b/drivers/mtd/nand/gpio.c index 85294f150f4f..fd3648952b5a 100644 --- a/drivers/mtd/nand/gpio.c +++ b/drivers/mtd/nand/gpio.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/gpio.h> | 26 | #include <linux/gpio.h> |
27 | #include <linux/io.h> | 27 | #include <linux/io.h> |
28 | #include <linux/mtd/mtd.h> | 28 | #include <linux/mtd/mtd.h> |
29 | #include <linux/mtd/nand.h> | 29 | #include <linux/mtd/rawnand.h> |
30 | #include <linux/mtd/partitions.h> | 30 | #include <linux/mtd/partitions.h> |
31 | #include <linux/mtd/nand-gpio.h> | 31 | #include <linux/mtd/nand-gpio.h> |
32 | #include <linux/of.h> | 32 | #include <linux/of.h> |
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.h b/drivers/mtd/nand/gpmi-nand/gpmi-nand.h index 9df0ad64e7e0..a45e4ce13d10 100644 --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.h +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.h | |||
@@ -17,7 +17,7 @@ | |||
17 | #ifndef __DRIVERS_MTD_NAND_GPMI_NAND_H | 17 | #ifndef __DRIVERS_MTD_NAND_GPMI_NAND_H |
18 | #define __DRIVERS_MTD_NAND_GPMI_NAND_H | 18 | #define __DRIVERS_MTD_NAND_GPMI_NAND_H |
19 | 19 | ||
20 | #include <linux/mtd/nand.h> | 20 | #include <linux/mtd/rawnand.h> |
21 | #include <linux/platform_device.h> | 21 | #include <linux/platform_device.h> |
22 | #include <linux/dma-mapping.h> | 22 | #include <linux/dma-mapping.h> |
23 | #include <linux/dmaengine.h> | 23 | #include <linux/dmaengine.h> |
diff --git a/drivers/mtd/nand/hisi504_nand.c b/drivers/mtd/nand/hisi504_nand.c index 530caa80b1b6..d9ee1a7e6956 100644 --- a/drivers/mtd/nand/hisi504_nand.c +++ b/drivers/mtd/nand/hisi504_nand.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
28 | #include <linux/interrupt.h> | 28 | #include <linux/interrupt.h> |
29 | #include <linux/mtd/nand.h> | 29 | #include <linux/mtd/rawnand.h> |
30 | #include <linux/dma-mapping.h> | 30 | #include <linux/dma-mapping.h> |
31 | #include <linux/platform_device.h> | 31 | #include <linux/platform_device.h> |
32 | #include <linux/mtd/partitions.h> | 32 | #include <linux/mtd/partitions.h> |
diff --git a/drivers/mtd/nand/jz4740_nand.c b/drivers/mtd/nand/jz4740_nand.c index 0d06a1f07d82..ad827d4af3e9 100644 --- a/drivers/mtd/nand/jz4740_nand.c +++ b/drivers/mtd/nand/jz4740_nand.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | 21 | ||
22 | #include <linux/mtd/mtd.h> | 22 | #include <linux/mtd/mtd.h> |
23 | #include <linux/mtd/nand.h> | 23 | #include <linux/mtd/rawnand.h> |
24 | #include <linux/mtd/partitions.h> | 24 | #include <linux/mtd/partitions.h> |
25 | 25 | ||
26 | #include <linux/gpio.h> | 26 | #include <linux/gpio.h> |
diff --git a/drivers/mtd/nand/jz4780_nand.c b/drivers/mtd/nand/jz4780_nand.c index 8bc835f71b26..e69f6ae4c539 100644 --- a/drivers/mtd/nand/jz4780_nand.c +++ b/drivers/mtd/nand/jz4780_nand.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/mtd/mtd.h> | 22 | #include <linux/mtd/mtd.h> |
23 | #include <linux/mtd/nand.h> | 23 | #include <linux/mtd/rawnand.h> |
24 | #include <linux/mtd/partitions.h> | 24 | #include <linux/mtd/partitions.h> |
25 | 25 | ||
26 | #include <linux/jz4780-nemc.h> | 26 | #include <linux/jz4780-nemc.h> |
diff --git a/drivers/mtd/nand/lpc32xx_mlc.c b/drivers/mtd/nand/lpc32xx_mlc.c index 846a66c1b133..c3bb358ef01e 100644 --- a/drivers/mtd/nand/lpc32xx_mlc.c +++ b/drivers/mtd/nand/lpc32xx_mlc.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
28 | #include <linux/platform_device.h> | 28 | #include <linux/platform_device.h> |
29 | #include <linux/mtd/mtd.h> | 29 | #include <linux/mtd/mtd.h> |
30 | #include <linux/mtd/nand.h> | 30 | #include <linux/mtd/rawnand.h> |
31 | #include <linux/mtd/partitions.h> | 31 | #include <linux/mtd/partitions.h> |
32 | #include <linux/clk.h> | 32 | #include <linux/clk.h> |
33 | #include <linux/err.h> | 33 | #include <linux/err.h> |
@@ -705,7 +705,9 @@ static int lpc32xx_nand_probe(struct platform_device *pdev) | |||
705 | res = -ENOENT; | 705 | res = -ENOENT; |
706 | goto err_exit1; | 706 | goto err_exit1; |
707 | } | 707 | } |
708 | clk_prepare_enable(host->clk); | 708 | res = clk_prepare_enable(host->clk); |
709 | if (res) | ||
710 | goto err_exit1; | ||
709 | 711 | ||
710 | nand_chip->cmd_ctrl = lpc32xx_nand_cmd_ctrl; | 712 | nand_chip->cmd_ctrl = lpc32xx_nand_cmd_ctrl; |
711 | nand_chip->dev_ready = lpc32xx_nand_device_ready; | 713 | nand_chip->dev_ready = lpc32xx_nand_device_ready; |
@@ -846,9 +848,12 @@ static int lpc32xx_nand_remove(struct platform_device *pdev) | |||
846 | static int lpc32xx_nand_resume(struct platform_device *pdev) | 848 | static int lpc32xx_nand_resume(struct platform_device *pdev) |
847 | { | 849 | { |
848 | struct lpc32xx_nand_host *host = platform_get_drvdata(pdev); | 850 | struct lpc32xx_nand_host *host = platform_get_drvdata(pdev); |
851 | int ret; | ||
849 | 852 | ||
850 | /* Re-enable NAND clock */ | 853 | /* Re-enable NAND clock */ |
851 | clk_prepare_enable(host->clk); | 854 | ret = clk_prepare_enable(host->clk); |
855 | if (ret) | ||
856 | return ret; | ||
852 | 857 | ||
853 | /* Fresh init of NAND controller */ | 858 | /* Fresh init of NAND controller */ |
854 | lpc32xx_nand_setup(host); | 859 | lpc32xx_nand_setup(host); |
diff --git a/drivers/mtd/nand/lpc32xx_slc.c b/drivers/mtd/nand/lpc32xx_slc.c index a0669a33f8fe..b61f28a1554d 100644 --- a/drivers/mtd/nand/lpc32xx_slc.c +++ b/drivers/mtd/nand/lpc32xx_slc.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
25 | #include <linux/mtd/mtd.h> | 25 | #include <linux/mtd/mtd.h> |
26 | #include <linux/mtd/nand.h> | 26 | #include <linux/mtd/rawnand.h> |
27 | #include <linux/mtd/partitions.h> | 27 | #include <linux/mtd/partitions.h> |
28 | #include <linux/clk.h> | 28 | #include <linux/clk.h> |
29 | #include <linux/err.h> | 29 | #include <linux/err.h> |
@@ -840,7 +840,9 @@ static int lpc32xx_nand_probe(struct platform_device *pdev) | |||
840 | res = -ENOENT; | 840 | res = -ENOENT; |
841 | goto err_exit1; | 841 | goto err_exit1; |
842 | } | 842 | } |
843 | clk_prepare_enable(host->clk); | 843 | res = clk_prepare_enable(host->clk); |
844 | if (res) | ||
845 | goto err_exit1; | ||
844 | 846 | ||
845 | /* Set NAND IO addresses and command/ready functions */ | 847 | /* Set NAND IO addresses and command/ready functions */ |
846 | chip->IO_ADDR_R = SLC_DATA(host->io_base); | 848 | chip->IO_ADDR_R = SLC_DATA(host->io_base); |
@@ -972,9 +974,12 @@ static int lpc32xx_nand_remove(struct platform_device *pdev) | |||
972 | static int lpc32xx_nand_resume(struct platform_device *pdev) | 974 | static int lpc32xx_nand_resume(struct platform_device *pdev) |
973 | { | 975 | { |
974 | struct lpc32xx_nand_host *host = platform_get_drvdata(pdev); | 976 | struct lpc32xx_nand_host *host = platform_get_drvdata(pdev); |
977 | int ret; | ||
975 | 978 | ||
976 | /* Re-enable NAND clock */ | 979 | /* Re-enable NAND clock */ |
977 | clk_prepare_enable(host->clk); | 980 | ret = clk_prepare_enable(host->clk); |
981 | if (ret) | ||
982 | return ret; | ||
978 | 983 | ||
979 | /* Fresh init of NAND controller */ | 984 | /* Fresh init of NAND controller */ |
980 | lpc32xx_nand_setup(host); | 985 | lpc32xx_nand_setup(host); |
diff --git a/drivers/mtd/nand/mpc5121_nfc.c b/drivers/mtd/nand/mpc5121_nfc.c index 0e86fb6277c3..b6b97cc9fba6 100644 --- a/drivers/mtd/nand/mpc5121_nfc.c +++ b/drivers/mtd/nand/mpc5121_nfc.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/interrupt.h> | 33 | #include <linux/interrupt.h> |
34 | #include <linux/io.h> | 34 | #include <linux/io.h> |
35 | #include <linux/mtd/mtd.h> | 35 | #include <linux/mtd/mtd.h> |
36 | #include <linux/mtd/nand.h> | 36 | #include <linux/mtd/rawnand.h> |
37 | #include <linux/mtd/partitions.h> | 37 | #include <linux/mtd/partitions.h> |
38 | #include <linux/of_address.h> | 38 | #include <linux/of_address.h> |
39 | #include <linux/of_device.h> | 39 | #include <linux/of_device.h> |
diff --git a/drivers/mtd/nand/mtk_ecc.c b/drivers/mtd/nand/mtk_ecc.c index 6c3a4aab0b48..7f3b065b6b8f 100644 --- a/drivers/mtd/nand/mtk_ecc.c +++ b/drivers/mtd/nand/mtk_ecc.c | |||
@@ -464,8 +464,8 @@ static int mtk_ecc_probe(struct platform_device *pdev) | |||
464 | 464 | ||
465 | irq = platform_get_irq(pdev, 0); | 465 | irq = platform_get_irq(pdev, 0); |
466 | if (irq < 0) { | 466 | if (irq < 0) { |
467 | dev_err(dev, "failed to get irq\n"); | 467 | dev_err(dev, "failed to get irq: %d\n", irq); |
468 | return -EINVAL; | 468 | return irq; |
469 | } | 469 | } |
470 | 470 | ||
471 | ret = dma_set_mask(dev, DMA_BIT_MASK(32)); | 471 | ret = dma_set_mask(dev, DMA_BIT_MASK(32)); |
diff --git a/drivers/mtd/nand/mtk_nand.c b/drivers/mtd/nand/mtk_nand.c index f7ae99464375..d86a7d131cc0 100644 --- a/drivers/mtd/nand/mtk_nand.c +++ b/drivers/mtd/nand/mtk_nand.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
20 | #include <linux/delay.h> | 20 | #include <linux/delay.h> |
21 | #include <linux/clk.h> | 21 | #include <linux/clk.h> |
22 | #include <linux/mtd/nand.h> | 22 | #include <linux/mtd/rawnand.h> |
23 | #include <linux/mtd/mtd.h> | 23 | #include <linux/mtd/mtd.h> |
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | #include <linux/iopoll.h> | 25 | #include <linux/iopoll.h> |
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index a764d5ca7536..53e5e0337c3e 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/mtd/mtd.h> | 24 | #include <linux/mtd/mtd.h> |
25 | #include <linux/mtd/nand.h> | 25 | #include <linux/mtd/rawnand.h> |
26 | #include <linux/mtd/partitions.h> | 26 | #include <linux/mtd/partitions.h> |
27 | #include <linux/interrupt.h> | 27 | #include <linux/interrupt.h> |
28 | #include <linux/device.h> | 28 | #include <linux/device.h> |
@@ -876,6 +876,8 @@ static void mxc_do_addr_cycle(struct mtd_info *mtd, int column, int page_addr) | |||
876 | } | 876 | } |
877 | } | 877 | } |
878 | 878 | ||
879 | #define MXC_V1_ECCBYTES 5 | ||
880 | |||
879 | static int mxc_v1_ooblayout_ecc(struct mtd_info *mtd, int section, | 881 | static int mxc_v1_ooblayout_ecc(struct mtd_info *mtd, int section, |
880 | struct mtd_oob_region *oobregion) | 882 | struct mtd_oob_region *oobregion) |
881 | { | 883 | { |
@@ -885,7 +887,7 @@ static int mxc_v1_ooblayout_ecc(struct mtd_info *mtd, int section, | |||
885 | return -ERANGE; | 887 | return -ERANGE; |
886 | 888 | ||
887 | oobregion->offset = (section * 16) + 6; | 889 | oobregion->offset = (section * 16) + 6; |
888 | oobregion->length = nand_chip->ecc.bytes; | 890 | oobregion->length = MXC_V1_ECCBYTES; |
889 | 891 | ||
890 | return 0; | 892 | return 0; |
891 | } | 893 | } |
@@ -907,8 +909,7 @@ static int mxc_v1_ooblayout_free(struct mtd_info *mtd, int section, | |||
907 | oobregion->length = 4; | 909 | oobregion->length = 4; |
908 | } | 910 | } |
909 | } else { | 911 | } else { |
910 | oobregion->offset = ((section - 1) * 16) + | 912 | oobregion->offset = ((section - 1) * 16) + MXC_V1_ECCBYTES + 6; |
911 | nand_chip->ecc.bytes + 6; | ||
912 | if (section < nand_chip->ecc.steps) | 913 | if (section < nand_chip->ecc.steps) |
913 | oobregion->length = (section * 16) + 6 - | 914 | oobregion->length = (section * 16) + 6 - |
914 | oobregion->offset; | 915 | oobregion->offset; |
diff --git a/drivers/mtd/nand/nand_amd.c b/drivers/mtd/nand/nand_amd.c index 170403a3bfa8..22f060f38123 100644 --- a/drivers/mtd/nand/nand_amd.c +++ b/drivers/mtd/nand/nand_amd.c | |||
@@ -15,7 +15,7 @@ | |||
15 | * GNU General Public License for more details. | 15 | * GNU General Public License for more details. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/mtd/nand.h> | 18 | #include <linux/mtd/rawnand.h> |
19 | 19 | ||
20 | static void amd_nand_decode_id(struct nand_chip *chip) | 20 | static void amd_nand_decode_id(struct nand_chip *chip) |
21 | { | 21 | { |
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index c6c18b82f8f4..bcc8cef1c615 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #include <linux/nmi.h> | 39 | #include <linux/nmi.h> |
40 | #include <linux/types.h> | 40 | #include <linux/types.h> |
41 | #include <linux/mtd/mtd.h> | 41 | #include <linux/mtd/mtd.h> |
42 | #include <linux/mtd/nand.h> | 42 | #include <linux/mtd/rawnand.h> |
43 | #include <linux/mtd/nand_ecc.h> | 43 | #include <linux/mtd/nand_ecc.h> |
44 | #include <linux/mtd/nand_bch.h> | 44 | #include <linux/mtd/nand_bch.h> |
45 | #include <linux/interrupt.h> | 45 | #include <linux/interrupt.h> |
@@ -1248,179 +1248,6 @@ int nand_reset(struct nand_chip *chip, int chipnr) | |||
1248 | } | 1248 | } |
1249 | 1249 | ||
1250 | /** | 1250 | /** |
1251 | * __nand_unlock - [REPLACEABLE] unlocks specified locked blocks | ||
1252 | * @mtd: mtd info | ||
1253 | * @ofs: offset to start unlock from | ||
1254 | * @len: length to unlock | ||
1255 | * @invert: | ||
1256 | * - when = 0, unlock the range of blocks within the lower and | ||
1257 | * upper boundary address | ||
1258 | * - when = 1, unlock the range of blocks outside the boundaries | ||
1259 | * of the lower and upper boundary address | ||
1260 | * | ||
1261 | * Returs unlock status. | ||
1262 | */ | ||
1263 | static int __nand_unlock(struct mtd_info *mtd, loff_t ofs, | ||
1264 | uint64_t len, int invert) | ||
1265 | { | ||
1266 | int ret = 0; | ||
1267 | int status, page; | ||
1268 | struct nand_chip *chip = mtd_to_nand(mtd); | ||
1269 | |||
1270 | /* Submit address of first page to unlock */ | ||
1271 | page = ofs >> chip->page_shift; | ||
1272 | chip->cmdfunc(mtd, NAND_CMD_UNLOCK1, -1, page & chip->pagemask); | ||
1273 | |||
1274 | /* Submit address of last page to unlock */ | ||
1275 | page = (ofs + len) >> chip->page_shift; | ||
1276 | chip->cmdfunc(mtd, NAND_CMD_UNLOCK2, -1, | ||
1277 | (page | invert) & chip->pagemask); | ||
1278 | |||
1279 | /* Call wait ready function */ | ||
1280 | status = chip->waitfunc(mtd, chip); | ||
1281 | /* See if device thinks it succeeded */ | ||
1282 | if (status & NAND_STATUS_FAIL) { | ||
1283 | pr_debug("%s: error status = 0x%08x\n", | ||
1284 | __func__, status); | ||
1285 | ret = -EIO; | ||
1286 | } | ||
1287 | |||
1288 | return ret; | ||
1289 | } | ||
1290 | |||
1291 | /** | ||
1292 | * nand_unlock - [REPLACEABLE] unlocks specified locked blocks | ||
1293 | * @mtd: mtd info | ||
1294 | * @ofs: offset to start unlock from | ||
1295 | * @len: length to unlock | ||
1296 | * | ||
1297 | * Returns unlock status. | ||
1298 | */ | ||
1299 | int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) | ||
1300 | { | ||
1301 | int ret = 0; | ||
1302 | int chipnr; | ||
1303 | struct nand_chip *chip = mtd_to_nand(mtd); | ||
1304 | |||
1305 | pr_debug("%s: start = 0x%012llx, len = %llu\n", | ||
1306 | __func__, (unsigned long long)ofs, len); | ||
1307 | |||
1308 | if (check_offs_len(mtd, ofs, len)) | ||
1309 | return -EINVAL; | ||
1310 | |||
1311 | /* Align to last block address if size addresses end of the device */ | ||
1312 | if (ofs + len == mtd->size) | ||
1313 | len -= mtd->erasesize; | ||
1314 | |||
1315 | nand_get_device(mtd, FL_UNLOCKING); | ||
1316 | |||
1317 | /* Shift to get chip number */ | ||
1318 | chipnr = ofs >> chip->chip_shift; | ||
1319 | |||
1320 | /* | ||
1321 | * Reset the chip. | ||
1322 | * If we want to check the WP through READ STATUS and check the bit 7 | ||
1323 | * we must reset the chip | ||
1324 | * some operation can also clear the bit 7 of status register | ||
1325 | * eg. erase/program a locked block | ||
1326 | */ | ||
1327 | nand_reset(chip, chipnr); | ||
1328 | |||
1329 | chip->select_chip(mtd, chipnr); | ||
1330 | |||
1331 | /* Check, if it is write protected */ | ||
1332 | if (nand_check_wp(mtd)) { | ||
1333 | pr_debug("%s: device is write protected!\n", | ||
1334 | __func__); | ||
1335 | ret = -EIO; | ||
1336 | goto out; | ||
1337 | } | ||
1338 | |||
1339 | ret = __nand_unlock(mtd, ofs, len, 0); | ||
1340 | |||
1341 | out: | ||
1342 | chip->select_chip(mtd, -1); | ||
1343 | nand_release_device(mtd); | ||
1344 | |||
1345 | return ret; | ||
1346 | } | ||
1347 | EXPORT_SYMBOL(nand_unlock); | ||
1348 | |||
1349 | /** | ||
1350 | * nand_lock - [REPLACEABLE] locks all blocks present in the device | ||
1351 | * @mtd: mtd info | ||
1352 | * @ofs: offset to start unlock from | ||
1353 | * @len: length to unlock | ||
1354 | * | ||
1355 | * This feature is not supported in many NAND parts. 'Micron' NAND parts do | ||
1356 | * have this feature, but it allows only to lock all blocks, not for specified | ||
1357 | * range for block. Implementing 'lock' feature by making use of 'unlock', for | ||
1358 | * now. | ||
1359 | * | ||
1360 | * Returns lock status. | ||
1361 | */ | ||
1362 | int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) | ||
1363 | { | ||
1364 | int ret = 0; | ||
1365 | int chipnr, status, page; | ||
1366 | struct nand_chip *chip = mtd_to_nand(mtd); | ||
1367 | |||
1368 | pr_debug("%s: start = 0x%012llx, len = %llu\n", | ||
1369 | __func__, (unsigned long long)ofs, len); | ||
1370 | |||
1371 | if (check_offs_len(mtd, ofs, len)) | ||
1372 | return -EINVAL; | ||
1373 | |||
1374 | nand_get_device(mtd, FL_LOCKING); | ||
1375 | |||
1376 | /* Shift to get chip number */ | ||
1377 | chipnr = ofs >> chip->chip_shift; | ||
1378 | |||
1379 | /* | ||
1380 | * Reset the chip. | ||
1381 | * If we want to check the WP through READ STATUS and check the bit 7 | ||
1382 | * we must reset the chip | ||
1383 | * some operation can also clear the bit 7 of status register | ||
1384 | * eg. erase/program a locked block | ||
1385 | */ | ||
1386 | nand_reset(chip, chipnr); | ||
1387 | |||
1388 | chip->select_chip(mtd, chipnr); | ||
1389 | |||
1390 | /* Check, if it is write protected */ | ||
1391 | if (nand_check_wp(mtd)) { | ||
1392 | pr_debug("%s: device is write protected!\n", | ||
1393 | __func__); | ||
1394 | status = MTD_ERASE_FAILED; | ||
1395 | ret = -EIO; | ||
1396 | goto out; | ||
1397 | } | ||
1398 | |||
1399 | /* Submit address of first page to lock */ | ||
1400 | page = ofs >> chip->page_shift; | ||
1401 | chip->cmdfunc(mtd, NAND_CMD_LOCK, -1, page & chip->pagemask); | ||
1402 | |||
1403 | /* Call wait ready function */ | ||
1404 | status = chip->waitfunc(mtd, chip); | ||
1405 | /* See if device thinks it succeeded */ | ||
1406 | if (status & NAND_STATUS_FAIL) { | ||
1407 | pr_debug("%s: error status = 0x%08x\n", | ||
1408 | __func__, status); | ||
1409 | ret = -EIO; | ||
1410 | goto out; | ||
1411 | } | ||
1412 | |||
1413 | ret = __nand_unlock(mtd, ofs, len, 0x1); | ||
1414 | |||
1415 | out: | ||
1416 | chip->select_chip(mtd, -1); | ||
1417 | nand_release_device(mtd); | ||
1418 | |||
1419 | return ret; | ||
1420 | } | ||
1421 | EXPORT_SYMBOL(nand_lock); | ||
1422 | |||
1423 | /** | ||
1424 | * nand_check_erased_buf - check if a buffer contains (almost) only 0xff data | 1251 | * nand_check_erased_buf - check if a buffer contains (almost) only 0xff data |
1425 | * @buf: buffer to test | 1252 | * @buf: buffer to test |
1426 | * @len: buffer length | 1253 | * @len: buffer length |
@@ -3993,10 +3820,13 @@ static void nand_manufacturer_detect(struct nand_chip *chip) | |||
3993 | * nand_decode_ext_id() otherwise. | 3820 | * nand_decode_ext_id() otherwise. |
3994 | */ | 3821 | */ |
3995 | if (chip->manufacturer.desc && chip->manufacturer.desc->ops && | 3822 | if (chip->manufacturer.desc && chip->manufacturer.desc->ops && |
3996 | chip->manufacturer.desc->ops->detect) | 3823 | chip->manufacturer.desc->ops->detect) { |
3824 | /* The 3rd id byte holds MLC / multichip data */ | ||
3825 | chip->bits_per_cell = nand_get_bits_per_cell(chip->id.data[2]); | ||
3997 | chip->manufacturer.desc->ops->detect(chip); | 3826 | chip->manufacturer.desc->ops->detect(chip); |
3998 | else | 3827 | } else { |
3999 | nand_decode_ext_id(chip); | 3828 | nand_decode_ext_id(chip); |
3829 | } | ||
4000 | } | 3830 | } |
4001 | 3831 | ||
4002 | /* | 3832 | /* |
@@ -4036,7 +3866,7 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type) | |||
4036 | const struct nand_manufacturer *manufacturer; | 3866 | const struct nand_manufacturer *manufacturer; |
4037 | struct mtd_info *mtd = nand_to_mtd(chip); | 3867 | struct mtd_info *mtd = nand_to_mtd(chip); |
4038 | int busw; | 3868 | int busw; |
4039 | int i, ret; | 3869 | int i; |
4040 | u8 *id_data = chip->id.data; | 3870 | u8 *id_data = chip->id.data; |
4041 | u8 maf_id, dev_id; | 3871 | u8 maf_id, dev_id; |
4042 | 3872 | ||
@@ -4066,7 +3896,7 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type) | |||
4066 | chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); | 3896 | chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); |
4067 | 3897 | ||
4068 | /* Read entire ID string */ | 3898 | /* Read entire ID string */ |
4069 | for (i = 0; i < 8; i++) | 3899 | for (i = 0; i < ARRAY_SIZE(chip->id.data); i++) |
4070 | id_data[i] = chip->read_byte(mtd); | 3900 | id_data[i] = chip->read_byte(mtd); |
4071 | 3901 | ||
4072 | if (id_data[0] != maf_id || id_data[1] != dev_id) { | 3902 | if (id_data[0] != maf_id || id_data[1] != dev_id) { |
@@ -4075,7 +3905,7 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type) | |||
4075 | return -ENODEV; | 3905 | return -ENODEV; |
4076 | } | 3906 | } |
4077 | 3907 | ||
4078 | chip->id.len = nand_id_len(id_data, 8); | 3908 | chip->id.len = nand_id_len(id_data, ARRAY_SIZE(chip->id.data)); |
4079 | 3909 | ||
4080 | /* Try to identify manufacturer */ | 3910 | /* Try to identify manufacturer */ |
4081 | manufacturer = nand_get_manufacturer(maf_id); | 3911 | manufacturer = nand_get_manufacturer(maf_id); |
@@ -4177,10 +4007,6 @@ ident_done: | |||
4177 | if (mtd->writesize > 512 && chip->cmdfunc == nand_command) | 4007 | if (mtd->writesize > 512 && chip->cmdfunc == nand_command) |
4178 | chip->cmdfunc = nand_command_lp; | 4008 | chip->cmdfunc = nand_command_lp; |
4179 | 4009 | ||
4180 | ret = nand_manufacturer_init(chip); | ||
4181 | if (ret) | ||
4182 | return ret; | ||
4183 | |||
4184 | pr_info("device found, Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n", | 4010 | pr_info("device found, Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n", |
4185 | maf_id, dev_id); | 4011 | maf_id, dev_id); |
4186 | 4012 | ||
@@ -4388,23 +4214,6 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips, | |||
4388 | return ret; | 4214 | return ret; |
4389 | } | 4215 | } |
4390 | 4216 | ||
4391 | /* Initialize the ->data_interface field. */ | ||
4392 | ret = nand_init_data_interface(chip); | ||
4393 | if (ret) | ||
4394 | goto err_nand_init; | ||
4395 | |||
4396 | /* | ||
4397 | * Setup the data interface correctly on the chip and controller side. | ||
4398 | * This explicit call to nand_setup_data_interface() is only required | ||
4399 | * for the first die, because nand_reset() has been called before | ||
4400 | * ->data_interface and ->default_onfi_timing_mode were set. | ||
4401 | * For the other dies, nand_reset() will automatically switch to the | ||
4402 | * best mode for us. | ||
4403 | */ | ||
4404 | ret = nand_setup_data_interface(chip, 0); | ||
4405 | if (ret) | ||
4406 | goto err_nand_init; | ||
4407 | |||
4408 | nand_maf_id = chip->id.data[0]; | 4217 | nand_maf_id = chip->id.data[0]; |
4409 | nand_dev_id = chip->id.data[1]; | 4218 | nand_dev_id = chip->id.data[1]; |
4410 | 4219 | ||
@@ -4434,12 +4243,6 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips, | |||
4434 | mtd->size = i * chip->chipsize; | 4243 | mtd->size = i * chip->chipsize; |
4435 | 4244 | ||
4436 | return 0; | 4245 | return 0; |
4437 | |||
4438 | err_nand_init: | ||
4439 | /* Free manufacturer priv data. */ | ||
4440 | nand_manufacturer_cleanup(chip); | ||
4441 | |||
4442 | return ret; | ||
4443 | } | 4246 | } |
4444 | EXPORT_SYMBOL(nand_scan_ident); | 4247 | EXPORT_SYMBOL(nand_scan_ident); |
4445 | 4248 | ||
@@ -4826,55 +4629,60 @@ int nand_scan_tail(struct mtd_info *mtd) | |||
4826 | struct nand_chip *chip = mtd_to_nand(mtd); | 4629 | struct nand_chip *chip = mtd_to_nand(mtd); |
4827 | struct nand_ecc_ctrl *ecc = &chip->ecc; | 4630 | struct nand_ecc_ctrl *ecc = &chip->ecc; |
4828 | struct nand_buffers *nbuf = NULL; | 4631 | struct nand_buffers *nbuf = NULL; |
4829 | int ret; | 4632 | int ret, i; |
4830 | 4633 | ||
4831 | /* New bad blocks should be marked in OOB, flash-based BBT, or both */ | 4634 | /* New bad blocks should be marked in OOB, flash-based BBT, or both */ |
4832 | if (WARN_ON((chip->bbt_options & NAND_BBT_NO_OOB_BBM) && | 4635 | if (WARN_ON((chip->bbt_options & NAND_BBT_NO_OOB_BBM) && |
4833 | !(chip->bbt_options & NAND_BBT_USE_FLASH))) { | 4636 | !(chip->bbt_options & NAND_BBT_USE_FLASH))) { |
4834 | ret = -EINVAL; | 4637 | return -EINVAL; |
4835 | goto err_ident; | ||
4836 | } | 4638 | } |
4837 | 4639 | ||
4838 | if (invalid_ecc_page_accessors(chip)) { | 4640 | if (invalid_ecc_page_accessors(chip)) { |
4839 | pr_err("Invalid ECC page accessors setup\n"); | 4641 | pr_err("Invalid ECC page accessors setup\n"); |
4840 | ret = -EINVAL; | 4642 | return -EINVAL; |
4841 | goto err_ident; | ||
4842 | } | 4643 | } |
4843 | 4644 | ||
4844 | if (!(chip->options & NAND_OWN_BUFFERS)) { | 4645 | if (!(chip->options & NAND_OWN_BUFFERS)) { |
4845 | nbuf = kzalloc(sizeof(*nbuf), GFP_KERNEL); | 4646 | nbuf = kzalloc(sizeof(*nbuf), GFP_KERNEL); |
4846 | if (!nbuf) { | 4647 | if (!nbuf) |
4847 | ret = -ENOMEM; | 4648 | return -ENOMEM; |
4848 | goto err_ident; | ||
4849 | } | ||
4850 | 4649 | ||
4851 | nbuf->ecccalc = kmalloc(mtd->oobsize, GFP_KERNEL); | 4650 | nbuf->ecccalc = kmalloc(mtd->oobsize, GFP_KERNEL); |
4852 | if (!nbuf->ecccalc) { | 4651 | if (!nbuf->ecccalc) { |
4853 | ret = -ENOMEM; | 4652 | ret = -ENOMEM; |
4854 | goto err_free; | 4653 | goto err_free_nbuf; |
4855 | } | 4654 | } |
4856 | 4655 | ||
4857 | nbuf->ecccode = kmalloc(mtd->oobsize, GFP_KERNEL); | 4656 | nbuf->ecccode = kmalloc(mtd->oobsize, GFP_KERNEL); |
4858 | if (!nbuf->ecccode) { | 4657 | if (!nbuf->ecccode) { |
4859 | ret = -ENOMEM; | 4658 | ret = -ENOMEM; |
4860 | goto err_free; | 4659 | goto err_free_nbuf; |
4861 | } | 4660 | } |
4862 | 4661 | ||
4863 | nbuf->databuf = kmalloc(mtd->writesize + mtd->oobsize, | 4662 | nbuf->databuf = kmalloc(mtd->writesize + mtd->oobsize, |
4864 | GFP_KERNEL); | 4663 | GFP_KERNEL); |
4865 | if (!nbuf->databuf) { | 4664 | if (!nbuf->databuf) { |
4866 | ret = -ENOMEM; | 4665 | ret = -ENOMEM; |
4867 | goto err_free; | 4666 | goto err_free_nbuf; |
4868 | } | 4667 | } |
4869 | 4668 | ||
4870 | chip->buffers = nbuf; | 4669 | chip->buffers = nbuf; |
4871 | } else { | 4670 | } else if (!chip->buffers) { |
4872 | if (!chip->buffers) { | 4671 | return -ENOMEM; |
4873 | ret = -ENOMEM; | ||
4874 | goto err_ident; | ||
4875 | } | ||
4876 | } | 4672 | } |
4877 | 4673 | ||
4674 | /* | ||
4675 | * FIXME: some NAND manufacturer drivers expect the first die to be | ||
4676 | * selected when manufacturer->init() is called. They should be fixed | ||
4677 | * to explictly select the relevant die when interacting with the NAND | ||
4678 | * chip. | ||
4679 | */ | ||
4680 | chip->select_chip(mtd, 0); | ||
4681 | ret = nand_manufacturer_init(chip); | ||
4682 | chip->select_chip(mtd, -1); | ||
4683 | if (ret) | ||
4684 | goto err_free_nbuf; | ||
4685 | |||
4878 | /* Set the internal oob buffer location, just after the page data */ | 4686 | /* Set the internal oob buffer location, just after the page data */ |
4879 | chip->oob_poi = chip->buffers->databuf + mtd->writesize; | 4687 | chip->oob_poi = chip->buffers->databuf + mtd->writesize; |
4880 | 4688 | ||
@@ -4896,7 +4704,7 @@ int nand_scan_tail(struct mtd_info *mtd) | |||
4896 | WARN(1, "No oob scheme defined for oobsize %d\n", | 4704 | WARN(1, "No oob scheme defined for oobsize %d\n", |
4897 | mtd->oobsize); | 4705 | mtd->oobsize); |
4898 | ret = -EINVAL; | 4706 | ret = -EINVAL; |
4899 | goto err_free; | 4707 | goto err_nand_manuf_cleanup; |
4900 | } | 4708 | } |
4901 | } | 4709 | } |
4902 | 4710 | ||
@@ -4911,7 +4719,7 @@ int nand_scan_tail(struct mtd_info *mtd) | |||
4911 | if (!ecc->calculate || !ecc->correct || !ecc->hwctl) { | 4719 | if (!ecc->calculate || !ecc->correct || !ecc->hwctl) { |
4912 | WARN(1, "No ECC functions supplied; hardware ECC not possible\n"); | 4720 | WARN(1, "No ECC functions supplied; hardware ECC not possible\n"); |
4913 | ret = -EINVAL; | 4721 | ret = -EINVAL; |
4914 | goto err_free; | 4722 | goto err_nand_manuf_cleanup; |
4915 | } | 4723 | } |
4916 | if (!ecc->read_page) | 4724 | if (!ecc->read_page) |
4917 | ecc->read_page = nand_read_page_hwecc_oob_first; | 4725 | ecc->read_page = nand_read_page_hwecc_oob_first; |
@@ -4943,7 +4751,7 @@ int nand_scan_tail(struct mtd_info *mtd) | |||
4943 | ecc->write_page == nand_write_page_hwecc)) { | 4751 | ecc->write_page == nand_write_page_hwecc)) { |
4944 | WARN(1, "No ECC functions supplied; hardware ECC not possible\n"); | 4752 | WARN(1, "No ECC functions supplied; hardware ECC not possible\n"); |
4945 | ret = -EINVAL; | 4753 | ret = -EINVAL; |
4946 | goto err_free; | 4754 | goto err_nand_manuf_cleanup; |
4947 | } | 4755 | } |
4948 | /* Use standard syndrome read/write page function? */ | 4756 | /* Use standard syndrome read/write page function? */ |
4949 | if (!ecc->read_page) | 4757 | if (!ecc->read_page) |
@@ -4963,7 +4771,7 @@ int nand_scan_tail(struct mtd_info *mtd) | |||
4963 | if (!ecc->strength) { | 4771 | if (!ecc->strength) { |
4964 | WARN(1, "Driver must set ecc.strength when using hardware ECC\n"); | 4772 | WARN(1, "Driver must set ecc.strength when using hardware ECC\n"); |
4965 | ret = -EINVAL; | 4773 | ret = -EINVAL; |
4966 | goto err_free; | 4774 | goto err_nand_manuf_cleanup; |
4967 | } | 4775 | } |
4968 | break; | 4776 | break; |
4969 | } | 4777 | } |
@@ -4976,7 +4784,7 @@ int nand_scan_tail(struct mtd_info *mtd) | |||
4976 | ret = nand_set_ecc_soft_ops(mtd); | 4784 | ret = nand_set_ecc_soft_ops(mtd); |
4977 | if (ret) { | 4785 | if (ret) { |
4978 | ret = -EINVAL; | 4786 | ret = -EINVAL; |
4979 | goto err_free; | 4787 | goto err_nand_manuf_cleanup; |
4980 | } | 4788 | } |
4981 | break; | 4789 | break; |
4982 | 4790 | ||
@@ -4984,7 +4792,7 @@ int nand_scan_tail(struct mtd_info *mtd) | |||
4984 | if (!ecc->read_page || !ecc->write_page) { | 4792 | if (!ecc->read_page || !ecc->write_page) { |
4985 | WARN(1, "No ECC functions supplied; on-die ECC not possible\n"); | 4793 | WARN(1, "No ECC functions supplied; on-die ECC not possible\n"); |
4986 | ret = -EINVAL; | 4794 | ret = -EINVAL; |
4987 | goto err_free; | 4795 | goto err_nand_manuf_cleanup; |
4988 | } | 4796 | } |
4989 | if (!ecc->read_oob) | 4797 | if (!ecc->read_oob) |
4990 | ecc->read_oob = nand_read_oob_std; | 4798 | ecc->read_oob = nand_read_oob_std; |
@@ -5008,7 +4816,7 @@ int nand_scan_tail(struct mtd_info *mtd) | |||
5008 | default: | 4816 | default: |
5009 | WARN(1, "Invalid NAND_ECC_MODE %d\n", ecc->mode); | 4817 | WARN(1, "Invalid NAND_ECC_MODE %d\n", ecc->mode); |
5010 | ret = -EINVAL; | 4818 | ret = -EINVAL; |
5011 | goto err_free; | 4819 | goto err_nand_manuf_cleanup; |
5012 | } | 4820 | } |
5013 | 4821 | ||
5014 | /* For many systems, the standard OOB write also works for raw */ | 4822 | /* For many systems, the standard OOB write also works for raw */ |
@@ -5029,13 +4837,13 @@ int nand_scan_tail(struct mtd_info *mtd) | |||
5029 | if (ecc->steps * ecc->size != mtd->writesize) { | 4837 | if (ecc->steps * ecc->size != mtd->writesize) { |
5030 | WARN(1, "Invalid ECC parameters\n"); | 4838 | WARN(1, "Invalid ECC parameters\n"); |
5031 | ret = -EINVAL; | 4839 | ret = -EINVAL; |
5032 | goto err_free; | 4840 | goto err_nand_manuf_cleanup; |
5033 | } | 4841 | } |
5034 | ecc->total = ecc->steps * ecc->bytes; | 4842 | ecc->total = ecc->steps * ecc->bytes; |
5035 | if (ecc->total > mtd->oobsize) { | 4843 | if (ecc->total > mtd->oobsize) { |
5036 | WARN(1, "Total number of ECC bytes exceeded oobsize\n"); | 4844 | WARN(1, "Total number of ECC bytes exceeded oobsize\n"); |
5037 | ret = -EINVAL; | 4845 | ret = -EINVAL; |
5038 | goto err_free; | 4846 | goto err_nand_manuf_cleanup; |
5039 | } | 4847 | } |
5040 | 4848 | ||
5041 | /* | 4849 | /* |
@@ -5117,6 +4925,21 @@ int nand_scan_tail(struct mtd_info *mtd) | |||
5117 | if (!mtd->bitflip_threshold) | 4925 | if (!mtd->bitflip_threshold) |
5118 | mtd->bitflip_threshold = DIV_ROUND_UP(mtd->ecc_strength * 3, 4); | 4926 | mtd->bitflip_threshold = DIV_ROUND_UP(mtd->ecc_strength * 3, 4); |
5119 | 4927 | ||
4928 | /* Initialize the ->data_interface field. */ | ||
4929 | ret = nand_init_data_interface(chip); | ||
4930 | if (ret) | ||
4931 | goto err_nand_manuf_cleanup; | ||
4932 | |||
4933 | /* Enter fastest possible mode on all dies. */ | ||
4934 | for (i = 0; i < chip->numchips; i++) { | ||
4935 | chip->select_chip(mtd, i); | ||
4936 | ret = nand_setup_data_interface(chip, i); | ||
4937 | chip->select_chip(mtd, -1); | ||
4938 | |||
4939 | if (ret) | ||
4940 | goto err_nand_data_iface_cleanup; | ||
4941 | } | ||
4942 | |||
5120 | /* Check, if we should skip the bad block table scan */ | 4943 | /* Check, if we should skip the bad block table scan */ |
5121 | if (chip->options & NAND_SKIP_BBTSCAN) | 4944 | if (chip->options & NAND_SKIP_BBTSCAN) |
5122 | return 0; | 4945 | return 0; |
@@ -5124,10 +4947,17 @@ int nand_scan_tail(struct mtd_info *mtd) | |||
5124 | /* Build bad block table */ | 4947 | /* Build bad block table */ |
5125 | ret = chip->scan_bbt(mtd); | 4948 | ret = chip->scan_bbt(mtd); |
5126 | if (ret) | 4949 | if (ret) |
5127 | goto err_free; | 4950 | goto err_nand_data_iface_cleanup; |
4951 | |||
5128 | return 0; | 4952 | return 0; |
5129 | 4953 | ||
5130 | err_free: | 4954 | err_nand_data_iface_cleanup: |
4955 | nand_release_data_interface(chip); | ||
4956 | |||
4957 | err_nand_manuf_cleanup: | ||
4958 | nand_manufacturer_cleanup(chip); | ||
4959 | |||
4960 | err_free_nbuf: | ||
5131 | if (nbuf) { | 4961 | if (nbuf) { |
5132 | kfree(nbuf->databuf); | 4962 | kfree(nbuf->databuf); |
5133 | kfree(nbuf->ecccode); | 4963 | kfree(nbuf->ecccode); |
@@ -5135,12 +4965,6 @@ err_free: | |||
5135 | kfree(nbuf); | 4965 | kfree(nbuf); |
5136 | } | 4966 | } |
5137 | 4967 | ||
5138 | err_ident: | ||
5139 | /* Clean up nand_scan_ident(). */ | ||
5140 | |||
5141 | /* Free manufacturer priv data. */ | ||
5142 | nand_manufacturer_cleanup(chip); | ||
5143 | |||
5144 | return ret; | 4968 | return ret; |
5145 | } | 4969 | } |
5146 | EXPORT_SYMBOL(nand_scan_tail); | 4970 | EXPORT_SYMBOL(nand_scan_tail); |
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c index 7695efea65f2..2915b6739bf8 100644 --- a/drivers/mtd/nand/nand_bbt.c +++ b/drivers/mtd/nand/nand_bbt.c | |||
@@ -61,7 +61,7 @@ | |||
61 | #include <linux/types.h> | 61 | #include <linux/types.h> |
62 | #include <linux/mtd/mtd.h> | 62 | #include <linux/mtd/mtd.h> |
63 | #include <linux/mtd/bbm.h> | 63 | #include <linux/mtd/bbm.h> |
64 | #include <linux/mtd/nand.h> | 64 | #include <linux/mtd/rawnand.h> |
65 | #include <linux/bitops.h> | 65 | #include <linux/bitops.h> |
66 | #include <linux/delay.h> | 66 | #include <linux/delay.h> |
67 | #include <linux/vmalloc.h> | 67 | #include <linux/vmalloc.h> |
diff --git a/drivers/mtd/nand/nand_bch.c b/drivers/mtd/nand/nand_bch.c index 44763f87eae4..505441c9373b 100644 --- a/drivers/mtd/nand/nand_bch.c +++ b/drivers/mtd/nand/nand_bch.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/bitops.h> | 26 | #include <linux/bitops.h> |
27 | #include <linux/mtd/mtd.h> | 27 | #include <linux/mtd/mtd.h> |
28 | #include <linux/mtd/nand.h> | 28 | #include <linux/mtd/rawnand.h> |
29 | #include <linux/mtd/nand_bch.h> | 29 | #include <linux/mtd/nand_bch.h> |
30 | #include <linux/bch.h> | 30 | #include <linux/bch.h> |
31 | 31 | ||
diff --git a/drivers/mtd/nand/nand_ecc.c b/drivers/mtd/nand/nand_ecc.c index d1770b066396..7613a0388044 100644 --- a/drivers/mtd/nand/nand_ecc.c +++ b/drivers/mtd/nand/nand_ecc.c | |||
@@ -43,7 +43,7 @@ | |||
43 | #include <linux/kernel.h> | 43 | #include <linux/kernel.h> |
44 | #include <linux/module.h> | 44 | #include <linux/module.h> |
45 | #include <linux/mtd/mtd.h> | 45 | #include <linux/mtd/mtd.h> |
46 | #include <linux/mtd/nand.h> | 46 | #include <linux/mtd/rawnand.h> |
47 | #include <linux/mtd/nand_ecc.h> | 47 | #include <linux/mtd/nand_ecc.h> |
48 | #include <asm/byteorder.h> | 48 | #include <asm/byteorder.h> |
49 | #else | 49 | #else |
diff --git a/drivers/mtd/nand/nand_hynix.c b/drivers/mtd/nand/nand_hynix.c index b12dc7325378..985751eda317 100644 --- a/drivers/mtd/nand/nand_hynix.c +++ b/drivers/mtd/nand/nand_hynix.c | |||
@@ -15,7 +15,7 @@ | |||
15 | * GNU General Public License for more details. | 15 | * GNU General Public License for more details. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/mtd/nand.h> | 18 | #include <linux/mtd/rawnand.h> |
19 | #include <linux/sizes.h> | 19 | #include <linux/sizes.h> |
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | 21 | ||
@@ -477,7 +477,7 @@ static void hynix_nand_extract_ecc_requirements(struct nand_chip *chip, | |||
477 | * The ECC requirements field meaning depends on the | 477 | * The ECC requirements field meaning depends on the |
478 | * NAND technology. | 478 | * NAND technology. |
479 | */ | 479 | */ |
480 | u8 nand_tech = chip->id.data[5] & 0x3; | 480 | u8 nand_tech = chip->id.data[5] & 0x7; |
481 | 481 | ||
482 | if (nand_tech < 3) { | 482 | if (nand_tech < 3) { |
483 | /* > 26nm, reference: H27UBG8T2A datasheet */ | 483 | /* > 26nm, reference: H27UBG8T2A datasheet */ |
@@ -533,7 +533,7 @@ static void hynix_nand_extract_scrambling_requirements(struct nand_chip *chip, | |||
533 | if (nand_tech > 0) | 533 | if (nand_tech > 0) |
534 | chip->options |= NAND_NEED_SCRAMBLING; | 534 | chip->options |= NAND_NEED_SCRAMBLING; |
535 | } else { | 535 | } else { |
536 | nand_tech = chip->id.data[5] & 0x3; | 536 | nand_tech = chip->id.data[5] & 0x7; |
537 | 537 | ||
538 | /* < 32nm */ | 538 | /* < 32nm */ |
539 | if (nand_tech > 2) | 539 | if (nand_tech > 2) |
diff --git a/drivers/mtd/nand/nand_ids.c b/drivers/mtd/nand/nand_ids.c index 92e2cf8e9ff9..5423c3bb388e 100644 --- a/drivers/mtd/nand/nand_ids.c +++ b/drivers/mtd/nand/nand_ids.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * published by the Free Software Foundation. | 6 | * published by the Free Software Foundation. |
7 | * | 7 | * |
8 | */ | 8 | */ |
9 | #include <linux/mtd/nand.h> | 9 | #include <linux/mtd/rawnand.h> |
10 | #include <linux/sizes.h> | 10 | #include <linux/sizes.h> |
11 | 11 | ||
12 | #define LP_OPTIONS 0 | 12 | #define LP_OPTIONS 0 |
diff --git a/drivers/mtd/nand/nand_macronix.c b/drivers/mtd/nand/nand_macronix.c index 84855c3e1a02..d290ff2a6d2f 100644 --- a/drivers/mtd/nand/nand_macronix.c +++ b/drivers/mtd/nand/nand_macronix.c | |||
@@ -15,7 +15,7 @@ | |||
15 | * GNU General Public License for more details. | 15 | * GNU General Public License for more details. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/mtd/nand.h> | 18 | #include <linux/mtd/rawnand.h> |
19 | 19 | ||
20 | static int macronix_nand_init(struct nand_chip *chip) | 20 | static int macronix_nand_init(struct nand_chip *chip) |
21 | { | 21 | { |
diff --git a/drivers/mtd/nand/nand_micron.c b/drivers/mtd/nand/nand_micron.c index c30ab60f8e1b..abf6a3c376e8 100644 --- a/drivers/mtd/nand/nand_micron.c +++ b/drivers/mtd/nand/nand_micron.c | |||
@@ -15,7 +15,7 @@ | |||
15 | * GNU General Public License for more details. | 15 | * GNU General Public License for more details. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/mtd/nand.h> | 18 | #include <linux/mtd/rawnand.h> |
19 | 19 | ||
20 | /* | 20 | /* |
21 | * Special Micron status bit that indicates when the block has been | 21 | * Special Micron status bit that indicates when the block has been |
diff --git a/drivers/mtd/nand/nand_samsung.c b/drivers/mtd/nand/nand_samsung.c index 1e0755997762..d348f0129ae7 100644 --- a/drivers/mtd/nand/nand_samsung.c +++ b/drivers/mtd/nand/nand_samsung.c | |||
@@ -15,7 +15,7 @@ | |||
15 | * GNU General Public License for more details. | 15 | * GNU General Public License for more details. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/mtd/nand.h> | 18 | #include <linux/mtd/rawnand.h> |
19 | 19 | ||
20 | static void samsung_nand_decode_id(struct nand_chip *chip) | 20 | static void samsung_nand_decode_id(struct nand_chip *chip) |
21 | { | 21 | { |
diff --git a/drivers/mtd/nand/nand_timings.c b/drivers/mtd/nand/nand_timings.c index 7e36d7d13c26..5d1533bcc5bd 100644 --- a/drivers/mtd/nand/nand_timings.c +++ b/drivers/mtd/nand/nand_timings.c | |||
@@ -11,7 +11,7 @@ | |||
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/err.h> | 12 | #include <linux/err.h> |
13 | #include <linux/export.h> | 13 | #include <linux/export.h> |
14 | #include <linux/mtd/nand.h> | 14 | #include <linux/mtd/rawnand.h> |
15 | 15 | ||
16 | static const struct nand_data_interface onfi_sdr_timings[] = { | 16 | static const struct nand_data_interface onfi_sdr_timings[] = { |
17 | /* Mode 0 */ | 17 | /* Mode 0 */ |
diff --git a/drivers/mtd/nand/nand_toshiba.c b/drivers/mtd/nand/nand_toshiba.c index fa787ba38dcd..57df857074e6 100644 --- a/drivers/mtd/nand/nand_toshiba.c +++ b/drivers/mtd/nand/nand_toshiba.c | |||
@@ -15,7 +15,7 @@ | |||
15 | * GNU General Public License for more details. | 15 | * GNU General Public License for more details. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/mtd/nand.h> | 18 | #include <linux/mtd/rawnand.h> |
19 | 19 | ||
20 | static void toshiba_nand_decode_id(struct nand_chip *chip) | 20 | static void toshiba_nand_decode_id(struct nand_chip *chip) |
21 | { | 21 | { |
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c index e4211c3cc49b..fec613221958 100644 --- a/drivers/mtd/nand/nandsim.c +++ b/drivers/mtd/nand/nandsim.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/errno.h> | 33 | #include <linux/errno.h> |
34 | #include <linux/string.h> | 34 | #include <linux/string.h> |
35 | #include <linux/mtd/mtd.h> | 35 | #include <linux/mtd/mtd.h> |
36 | #include <linux/mtd/nand.h> | 36 | #include <linux/mtd/rawnand.h> |
37 | #include <linux/mtd/nand_bch.h> | 37 | #include <linux/mtd/nand_bch.h> |
38 | #include <linux/mtd/partitions.h> | 38 | #include <linux/mtd/partitions.h> |
39 | #include <linux/delay.h> | 39 | #include <linux/delay.h> |
@@ -287,11 +287,6 @@ MODULE_PARM_DESC(bch, "Enable BCH ecc and set how many bits should " | |||
287 | /* Maximum page cache pages needed to read or write a NAND page to the cache_file */ | 287 | /* Maximum page cache pages needed to read or write a NAND page to the cache_file */ |
288 | #define NS_MAX_HELD_PAGES 16 | 288 | #define NS_MAX_HELD_PAGES 16 |
289 | 289 | ||
290 | struct nandsim_debug_info { | ||
291 | struct dentry *dfs_root; | ||
292 | struct dentry *dfs_wear_report; | ||
293 | }; | ||
294 | |||
295 | /* | 290 | /* |
296 | * A union to represent flash memory contents and flash buffer. | 291 | * A union to represent flash memory contents and flash buffer. |
297 | */ | 292 | */ |
@@ -370,8 +365,6 @@ struct nandsim { | |||
370 | void *file_buf; | 365 | void *file_buf; |
371 | struct page *held_pages[NS_MAX_HELD_PAGES]; | 366 | struct page *held_pages[NS_MAX_HELD_PAGES]; |
372 | int held_cnt; | 367 | int held_cnt; |
373 | |||
374 | struct nandsim_debug_info dbg; | ||
375 | }; | 368 | }; |
376 | 369 | ||
377 | /* | 370 | /* |
@@ -524,39 +517,23 @@ static const struct file_operations dfs_fops = { | |||
524 | */ | 517 | */ |
525 | static int nandsim_debugfs_create(struct nandsim *dev) | 518 | static int nandsim_debugfs_create(struct nandsim *dev) |
526 | { | 519 | { |
527 | struct nandsim_debug_info *dbg = &dev->dbg; | 520 | struct dentry *root = nsmtd->dbg.dfs_dir; |
528 | struct dentry *dent; | 521 | struct dentry *dent; |
529 | 522 | ||
530 | if (!IS_ENABLED(CONFIG_DEBUG_FS)) | 523 | if (!IS_ENABLED(CONFIG_DEBUG_FS)) |
531 | return 0; | 524 | return 0; |
532 | 525 | ||
533 | dent = debugfs_create_dir("nandsim", NULL); | 526 | if (IS_ERR_OR_NULL(root)) |
534 | if (!dent) { | 527 | return -1; |
535 | NS_ERR("cannot create \"nandsim\" debugfs directory\n"); | ||
536 | return -ENODEV; | ||
537 | } | ||
538 | dbg->dfs_root = dent; | ||
539 | 528 | ||
540 | dent = debugfs_create_file("wear_report", S_IRUSR, | 529 | dent = debugfs_create_file("nandsim_wear_report", S_IRUSR, |
541 | dbg->dfs_root, dev, &dfs_fops); | 530 | root, dev, &dfs_fops); |
542 | if (!dent) | 531 | if (IS_ERR_OR_NULL(dent)) { |
543 | goto out_remove; | 532 | NS_ERR("cannot create \"nandsim_wear_report\" debugfs entry\n"); |
544 | dbg->dfs_wear_report = dent; | 533 | return -1; |
534 | } | ||
545 | 535 | ||
546 | return 0; | 536 | return 0; |
547 | |||
548 | out_remove: | ||
549 | debugfs_remove_recursive(dbg->dfs_root); | ||
550 | return -ENODEV; | ||
551 | } | ||
552 | |||
553 | /** | ||
554 | * nandsim_debugfs_remove - destroy all debugfs files | ||
555 | */ | ||
556 | static void nandsim_debugfs_remove(struct nandsim *ns) | ||
557 | { | ||
558 | if (IS_ENABLED(CONFIG_DEBUG_FS)) | ||
559 | debugfs_remove_recursive(ns->dbg.dfs_root); | ||
560 | } | 537 | } |
561 | 538 | ||
562 | /* | 539 | /* |
@@ -2352,9 +2329,6 @@ static int __init ns_init_module(void) | |||
2352 | if ((retval = setup_wear_reporting(nsmtd)) != 0) | 2329 | if ((retval = setup_wear_reporting(nsmtd)) != 0) |
2353 | goto err_exit; | 2330 | goto err_exit; |
2354 | 2331 | ||
2355 | if ((retval = nandsim_debugfs_create(nand)) != 0) | ||
2356 | goto err_exit; | ||
2357 | |||
2358 | if ((retval = init_nandsim(nsmtd)) != 0) | 2332 | if ((retval = init_nandsim(nsmtd)) != 0) |
2359 | goto err_exit; | 2333 | goto err_exit; |
2360 | 2334 | ||
@@ -2370,10 +2344,12 @@ static int __init ns_init_module(void) | |||
2370 | if (retval != 0) | 2344 | if (retval != 0) |
2371 | goto err_exit; | 2345 | goto err_exit; |
2372 | 2346 | ||
2347 | if ((retval = nandsim_debugfs_create(nand)) != 0) | ||
2348 | goto err_exit; | ||
2349 | |||
2373 | return 0; | 2350 | return 0; |
2374 | 2351 | ||
2375 | err_exit: | 2352 | err_exit: |
2376 | nandsim_debugfs_remove(nand); | ||
2377 | free_nandsim(nand); | 2353 | free_nandsim(nand); |
2378 | nand_release(nsmtd); | 2354 | nand_release(nsmtd); |
2379 | for (i = 0;i < ARRAY_SIZE(nand->partitions); ++i) | 2355 | for (i = 0;i < ARRAY_SIZE(nand->partitions); ++i) |
@@ -2396,7 +2372,6 @@ static void __exit ns_cleanup_module(void) | |||
2396 | struct nandsim *ns = nand_get_controller_data(chip); | 2372 | struct nandsim *ns = nand_get_controller_data(chip); |
2397 | int i; | 2373 | int i; |
2398 | 2374 | ||
2399 | nandsim_debugfs_remove(ns); | ||
2400 | free_nandsim(ns); /* Free nandsim private resources */ | 2375 | free_nandsim(ns); /* Free nandsim private resources */ |
2401 | nand_release(nsmtd); /* Unregister driver */ | 2376 | nand_release(nsmtd); /* Unregister driver */ |
2402 | for (i = 0;i < ARRAY_SIZE(ns->partitions); ++i) | 2377 | for (i = 0;i < ARRAY_SIZE(ns->partitions); ++i) |
diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c index 28e6118362f7..d8a806894937 100644 --- a/drivers/mtd/nand/ndfc.c +++ b/drivers/mtd/nand/ndfc.c | |||
@@ -22,7 +22,7 @@ | |||
22 | * | 22 | * |
23 | */ | 23 | */ |
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | #include <linux/mtd/nand.h> | 25 | #include <linux/mtd/rawnand.h> |
26 | #include <linux/mtd/nand_ecc.h> | 26 | #include <linux/mtd/nand_ecc.h> |
27 | #include <linux/mtd/partitions.h> | 27 | #include <linux/mtd/partitions.h> |
28 | #include <linux/mtd/ndfc.h> | 28 | #include <linux/mtd/ndfc.h> |
diff --git a/drivers/mtd/nand/nuc900_nand.c b/drivers/mtd/nand/nuc900_nand.c index 8f64011d32ef..7bb4d2ea9342 100644 --- a/drivers/mtd/nand/nuc900_nand.c +++ b/drivers/mtd/nand/nuc900_nand.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/err.h> | 19 | #include <linux/err.h> |
20 | 20 | ||
21 | #include <linux/mtd/mtd.h> | 21 | #include <linux/mtd/mtd.h> |
22 | #include <linux/mtd/nand.h> | 22 | #include <linux/mtd/rawnand.h> |
23 | #include <linux/mtd/partitions.h> | 23 | #include <linux/mtd/partitions.h> |
24 | 24 | ||
25 | #define REG_FMICSR 0x00 | 25 | #define REG_FMICSR 0x00 |
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c index 084934a9f19c..54540c8fa1a2 100644 --- a/drivers/mtd/nand/omap2.c +++ b/drivers/mtd/nand/omap2.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/jiffies.h> | 18 | #include <linux/jiffies.h> |
19 | #include <linux/sched.h> | 19 | #include <linux/sched.h> |
20 | #include <linux/mtd/mtd.h> | 20 | #include <linux/mtd/mtd.h> |
21 | #include <linux/mtd/nand.h> | 21 | #include <linux/mtd/rawnand.h> |
22 | #include <linux/mtd/partitions.h> | 22 | #include <linux/mtd/partitions.h> |
23 | #include <linux/omap-dma.h> | 23 | #include <linux/omap-dma.h> |
24 | #include <linux/io.h> | 24 | #include <linux/io.h> |
diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c index 209170ed2b76..5a5aa1f07d07 100644 --- a/drivers/mtd/nand/orion_nand.c +++ b/drivers/mtd/nand/orion_nand.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
16 | #include <linux/of.h> | 16 | #include <linux/of.h> |
17 | #include <linux/mtd/mtd.h> | 17 | #include <linux/mtd/mtd.h> |
18 | #include <linux/mtd/nand.h> | 18 | #include <linux/mtd/rawnand.h> |
19 | #include <linux/mtd/partitions.h> | 19 | #include <linux/mtd/partitions.h> |
20 | #include <linux/clk.h> | 20 | #include <linux/clk.h> |
21 | #include <linux/err.h> | 21 | #include <linux/err.h> |
@@ -54,13 +54,16 @@ static void orion_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) | |||
54 | { | 54 | { |
55 | struct nand_chip *chip = mtd_to_nand(mtd); | 55 | struct nand_chip *chip = mtd_to_nand(mtd); |
56 | void __iomem *io_base = chip->IO_ADDR_R; | 56 | void __iomem *io_base = chip->IO_ADDR_R; |
57 | #if __LINUX_ARM_ARCH__ >= 5 | ||
57 | uint64_t *buf64; | 58 | uint64_t *buf64; |
59 | #endif | ||
58 | int i = 0; | 60 | int i = 0; |
59 | 61 | ||
60 | while (len && (unsigned long)buf & 7) { | 62 | while (len && (unsigned long)buf & 7) { |
61 | *buf++ = readb(io_base); | 63 | *buf++ = readb(io_base); |
62 | len--; | 64 | len--; |
63 | } | 65 | } |
66 | #if __LINUX_ARM_ARCH__ >= 5 | ||
64 | buf64 = (uint64_t *)buf; | 67 | buf64 = (uint64_t *)buf; |
65 | while (i < len/8) { | 68 | while (i < len/8) { |
66 | /* | 69 | /* |
@@ -74,6 +77,10 @@ static void orion_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) | |||
74 | buf64[i++] = x; | 77 | buf64[i++] = x; |
75 | } | 78 | } |
76 | i *= 8; | 79 | i *= 8; |
80 | #else | ||
81 | readsl(io_base, buf, len/4); | ||
82 | i = len / 4 * 4; | ||
83 | #endif | ||
77 | while (i < len) | 84 | while (i < len) |
78 | buf[i++] = readb(io_base); | 85 | buf[i++] = readb(io_base); |
79 | } | 86 | } |
diff --git a/drivers/mtd/nand/oxnas_nand.c b/drivers/mtd/nand/oxnas_nand.c index 1b207aac840c..d649d5944826 100644 --- a/drivers/mtd/nand/oxnas_nand.c +++ b/drivers/mtd/nand/oxnas_nand.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/clk.h> | 21 | #include <linux/clk.h> |
22 | #include <linux/reset.h> | 22 | #include <linux/reset.h> |
23 | #include <linux/mtd/mtd.h> | 23 | #include <linux/mtd/mtd.h> |
24 | #include <linux/mtd/nand.h> | 24 | #include <linux/mtd/rawnand.h> |
25 | #include <linux/mtd/partitions.h> | 25 | #include <linux/mtd/partitions.h> |
26 | #include <linux/of.h> | 26 | #include <linux/of.h> |
27 | 27 | ||
@@ -112,14 +112,19 @@ static int oxnas_nand_probe(struct platform_device *pdev) | |||
112 | if (count > 1) | 112 | if (count > 1) |
113 | return -EINVAL; | 113 | return -EINVAL; |
114 | 114 | ||
115 | clk_prepare_enable(oxnas->clk); | 115 | err = clk_prepare_enable(oxnas->clk); |
116 | if (err) | ||
117 | return err; | ||
118 | |||
116 | device_reset_optional(&pdev->dev); | 119 | device_reset_optional(&pdev->dev); |
117 | 120 | ||
118 | for_each_child_of_node(np, nand_np) { | 121 | for_each_child_of_node(np, nand_np) { |
119 | chip = devm_kzalloc(&pdev->dev, sizeof(struct nand_chip), | 122 | chip = devm_kzalloc(&pdev->dev, sizeof(struct nand_chip), |
120 | GFP_KERNEL); | 123 | GFP_KERNEL); |
121 | if (!chip) | 124 | if (!chip) { |
122 | return -ENOMEM; | 125 | err = -ENOMEM; |
126 | goto err_clk_unprepare; | ||
127 | } | ||
123 | 128 | ||
124 | chip->controller = &oxnas->base; | 129 | chip->controller = &oxnas->base; |
125 | 130 | ||
@@ -139,12 +144,12 @@ static int oxnas_nand_probe(struct platform_device *pdev) | |||
139 | /* Scan to find existence of the device */ | 144 | /* Scan to find existence of the device */ |
140 | err = nand_scan(mtd, 1); | 145 | err = nand_scan(mtd, 1); |
141 | if (err) | 146 | if (err) |
142 | return err; | 147 | goto err_clk_unprepare; |
143 | 148 | ||
144 | err = mtd_device_register(mtd, NULL, 0); | 149 | err = mtd_device_register(mtd, NULL, 0); |
145 | if (err) { | 150 | if (err) { |
146 | nand_release(mtd); | 151 | nand_release(mtd); |
147 | return err; | 152 | goto err_clk_unprepare; |
148 | } | 153 | } |
149 | 154 | ||
150 | oxnas->chips[nchips] = chip; | 155 | oxnas->chips[nchips] = chip; |
@@ -152,12 +157,18 @@ static int oxnas_nand_probe(struct platform_device *pdev) | |||
152 | } | 157 | } |
153 | 158 | ||
154 | /* Exit if no chips found */ | 159 | /* Exit if no chips found */ |
155 | if (!nchips) | 160 | if (!nchips) { |
156 | return -ENODEV; | 161 | err = -ENODEV; |
162 | goto err_clk_unprepare; | ||
163 | } | ||
157 | 164 | ||
158 | platform_set_drvdata(pdev, oxnas); | 165 | platform_set_drvdata(pdev, oxnas); |
159 | 166 | ||
160 | return 0; | 167 | return 0; |
168 | |||
169 | err_clk_unprepare: | ||
170 | clk_disable_unprepare(oxnas->clk); | ||
171 | return err; | ||
161 | } | 172 | } |
162 | 173 | ||
163 | static int oxnas_nand_remove(struct platform_device *pdev) | 174 | static int oxnas_nand_remove(struct platform_device *pdev) |
diff --git a/drivers/mtd/nand/pasemi_nand.c b/drivers/mtd/nand/pasemi_nand.c index 074b8b01289e..a47a7e4bd25a 100644 --- a/drivers/mtd/nand/pasemi_nand.c +++ b/drivers/mtd/nand/pasemi_nand.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/mtd/mtd.h> | 27 | #include <linux/mtd/mtd.h> |
28 | #include <linux/mtd/nand.h> | 28 | #include <linux/mtd/rawnand.h> |
29 | #include <linux/mtd/nand_ecc.h> | 29 | #include <linux/mtd/nand_ecc.h> |
30 | #include <linux/of_address.h> | 30 | #include <linux/of_address.h> |
31 | #include <linux/of_irq.h> | 31 | #include <linux/of_irq.h> |
diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c index 791de3e4bbb6..925a1323604d 100644 --- a/drivers/mtd/nand/plat_nand.c +++ b/drivers/mtd/nand/plat_nand.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/mtd/mtd.h> | 17 | #include <linux/mtd/mtd.h> |
18 | #include <linux/mtd/nand.h> | 18 | #include <linux/mtd/rawnand.h> |
19 | #include <linux/mtd/partitions.h> | 19 | #include <linux/mtd/partitions.h> |
20 | 20 | ||
21 | struct plat_nand_data { | 21 | struct plat_nand_data { |
diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c index 74dae4bbdac8..85cff68643e0 100644 --- a/drivers/mtd/nand/pxa3xx_nand.c +++ b/drivers/mtd/nand/pxa3xx_nand.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
22 | #include <linux/clk.h> | 22 | #include <linux/clk.h> |
23 | #include <linux/mtd/mtd.h> | 23 | #include <linux/mtd/mtd.h> |
24 | #include <linux/mtd/nand.h> | 24 | #include <linux/mtd/rawnand.h> |
25 | #include <linux/mtd/partitions.h> | 25 | #include <linux/mtd/partitions.h> |
26 | #include <linux/io.h> | 26 | #include <linux/io.h> |
27 | #include <linux/iopoll.h> | 27 | #include <linux/iopoll.h> |
diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c index 88af7145a51a..3baddfc997d1 100644 --- a/drivers/mtd/nand/qcom_nandc.c +++ b/drivers/mtd/nand/qcom_nandc.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/dma-mapping.h> | 17 | #include <linux/dma-mapping.h> |
18 | #include <linux/dmaengine.h> | 18 | #include <linux/dmaengine.h> |
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/mtd/nand.h> | 20 | #include <linux/mtd/rawnand.h> |
21 | #include <linux/mtd/partitions.h> | 21 | #include <linux/mtd/partitions.h> |
22 | #include <linux/of.h> | 22 | #include <linux/of.h> |
23 | #include <linux/of_device.h> | 23 | #include <linux/of_device.h> |
@@ -53,6 +53,8 @@ | |||
53 | #define NAND_VERSION 0xf08 | 53 | #define NAND_VERSION 0xf08 |
54 | #define NAND_READ_LOCATION_0 0xf20 | 54 | #define NAND_READ_LOCATION_0 0xf20 |
55 | #define NAND_READ_LOCATION_1 0xf24 | 55 | #define NAND_READ_LOCATION_1 0xf24 |
56 | #define NAND_READ_LOCATION_2 0xf28 | ||
57 | #define NAND_READ_LOCATION_3 0xf2c | ||
56 | 58 | ||
57 | /* dummy register offsets, used by write_reg_dma */ | 59 | /* dummy register offsets, used by write_reg_dma */ |
58 | #define NAND_DEV_CMD1_RESTORE 0xdead | 60 | #define NAND_DEV_CMD1_RESTORE 0xdead |
@@ -109,7 +111,11 @@ | |||
109 | #define READ_ADDR 0 | 111 | #define READ_ADDR 0 |
110 | 112 | ||
111 | /* NAND_DEV_CMD_VLD bits */ | 113 | /* NAND_DEV_CMD_VLD bits */ |
112 | #define READ_START_VLD 0 | 114 | #define READ_START_VLD BIT(0) |
115 | #define READ_STOP_VLD BIT(1) | ||
116 | #define WRITE_START_VLD BIT(2) | ||
117 | #define ERASE_START_VLD BIT(3) | ||
118 | #define SEQ_READ_START_VLD BIT(4) | ||
113 | 119 | ||
114 | /* NAND_EBI2_ECC_BUF_CFG bits */ | 120 | /* NAND_EBI2_ECC_BUF_CFG bits */ |
115 | #define NUM_STEPS 0 | 121 | #define NUM_STEPS 0 |
@@ -131,6 +137,11 @@ | |||
131 | #define ERASED_PAGE (PAGE_ALL_ERASED | PAGE_ERASED) | 137 | #define ERASED_PAGE (PAGE_ALL_ERASED | PAGE_ERASED) |
132 | #define ERASED_CW (CODEWORD_ALL_ERASED | CODEWORD_ERASED) | 138 | #define ERASED_CW (CODEWORD_ALL_ERASED | CODEWORD_ERASED) |
133 | 139 | ||
140 | /* NAND_READ_LOCATION_n bits */ | ||
141 | #define READ_LOCATION_OFFSET 0 | ||
142 | #define READ_LOCATION_SIZE 16 | ||
143 | #define READ_LOCATION_LAST 31 | ||
144 | |||
134 | /* Version Mask */ | 145 | /* Version Mask */ |
135 | #define NAND_VERSION_MAJOR_MASK 0xf0000000 | 146 | #define NAND_VERSION_MAJOR_MASK 0xf0000000 |
136 | #define NAND_VERSION_MAJOR_SHIFT 28 | 147 | #define NAND_VERSION_MAJOR_SHIFT 28 |
@@ -148,6 +159,13 @@ | |||
148 | #define FETCH_ID 0xb | 159 | #define FETCH_ID 0xb |
149 | #define RESET_DEVICE 0xd | 160 | #define RESET_DEVICE 0xd |
150 | 161 | ||
162 | /* Default Value for NAND_DEV_CMD_VLD */ | ||
163 | #define NAND_DEV_CMD_VLD_VAL (READ_START_VLD | WRITE_START_VLD | \ | ||
164 | ERASE_START_VLD | SEQ_READ_START_VLD) | ||
165 | |||
166 | /* NAND_CTRL bits */ | ||
167 | #define BAM_MODE_EN BIT(0) | ||
168 | |||
151 | /* | 169 | /* |
152 | * the NAND controller performs reads/writes with ECC in 516 byte chunks. | 170 | * the NAND controller performs reads/writes with ECC in 516 byte chunks. |
153 | * the driver calls the chunks 'step' or 'codeword' interchangeably | 171 | * the driver calls the chunks 'step' or 'codeword' interchangeably |
@@ -169,11 +187,81 @@ | |||
169 | #define ECC_BCH_4BIT BIT(2) | 187 | #define ECC_BCH_4BIT BIT(2) |
170 | #define ECC_BCH_8BIT BIT(3) | 188 | #define ECC_BCH_8BIT BIT(3) |
171 | 189 | ||
190 | #define nandc_set_read_loc(nandc, reg, offset, size, is_last) \ | ||
191 | nandc_set_reg(nandc, NAND_READ_LOCATION_##reg, \ | ||
192 | ((offset) << READ_LOCATION_OFFSET) | \ | ||
193 | ((size) << READ_LOCATION_SIZE) | \ | ||
194 | ((is_last) << READ_LOCATION_LAST)) | ||
195 | |||
196 | /* | ||
197 | * Returns the actual register address for all NAND_DEV_ registers | ||
198 | * (i.e. NAND_DEV_CMD0, NAND_DEV_CMD1, NAND_DEV_CMD2 and NAND_DEV_CMD_VLD) | ||
199 | */ | ||
200 | #define dev_cmd_reg_addr(nandc, reg) ((nandc)->props->dev_cmd_reg_start + (reg)) | ||
201 | |||
202 | #define QPIC_PER_CW_CMD_SGL 32 | ||
203 | #define QPIC_PER_CW_DATA_SGL 8 | ||
204 | |||
205 | /* | ||
206 | * Flags used in DMA descriptor preparation helper functions | ||
207 | * (i.e. read_reg_dma/write_reg_dma/read_data_dma/write_data_dma) | ||
208 | */ | ||
209 | /* Don't set the EOT in current tx BAM sgl */ | ||
210 | #define NAND_BAM_NO_EOT BIT(0) | ||
211 | /* Set the NWD flag in current BAM sgl */ | ||
212 | #define NAND_BAM_NWD BIT(1) | ||
213 | /* Finish writing in the current BAM sgl and start writing in another BAM sgl */ | ||
214 | #define NAND_BAM_NEXT_SGL BIT(2) | ||
215 | /* | ||
216 | * Erased codeword status is being used two times in single transfer so this | ||
217 | * flag will determine the current value of erased codeword status register | ||
218 | */ | ||
219 | #define NAND_ERASED_CW_SET BIT(4) | ||
220 | |||
221 | /* | ||
222 | * This data type corresponds to the BAM transaction which will be used for all | ||
223 | * NAND transfers. | ||
224 | * @cmd_sgl - sgl for NAND BAM command pipe | ||
225 | * @data_sgl - sgl for NAND BAM consumer/producer pipe | ||
226 | * @cmd_sgl_pos - current index in command sgl. | ||
227 | * @cmd_sgl_start - start index in command sgl. | ||
228 | * @tx_sgl_pos - current index in data sgl for tx. | ||
229 | * @tx_sgl_start - start index in data sgl for tx. | ||
230 | * @rx_sgl_pos - current index in data sgl for rx. | ||
231 | * @rx_sgl_start - start index in data sgl for rx. | ||
232 | */ | ||
233 | struct bam_transaction { | ||
234 | struct scatterlist *cmd_sgl; | ||
235 | struct scatterlist *data_sgl; | ||
236 | u32 cmd_sgl_pos; | ||
237 | u32 cmd_sgl_start; | ||
238 | u32 tx_sgl_pos; | ||
239 | u32 tx_sgl_start; | ||
240 | u32 rx_sgl_pos; | ||
241 | u32 rx_sgl_start; | ||
242 | }; | ||
243 | |||
244 | /* | ||
245 | * This data type corresponds to the nand dma descriptor | ||
246 | * @list - list for desc_info | ||
247 | * @dir - DMA transfer direction | ||
248 | * @adm_sgl - sgl which will be used for single sgl dma descriptor. Only used by | ||
249 | * ADM | ||
250 | * @bam_sgl - sgl which will be used for dma descriptor. Only used by BAM | ||
251 | * @sgl_cnt - number of SGL in bam_sgl. Only used by BAM | ||
252 | * @dma_desc - low level DMA engine descriptor | ||
253 | */ | ||
172 | struct desc_info { | 254 | struct desc_info { |
173 | struct list_head node; | 255 | struct list_head node; |
174 | 256 | ||
175 | enum dma_data_direction dir; | 257 | enum dma_data_direction dir; |
176 | struct scatterlist sgl; | 258 | union { |
259 | struct scatterlist adm_sgl; | ||
260 | struct { | ||
261 | struct scatterlist *bam_sgl; | ||
262 | int sgl_cnt; | ||
263 | }; | ||
264 | }; | ||
177 | struct dma_async_tx_descriptor *dma_desc; | 265 | struct dma_async_tx_descriptor *dma_desc; |
178 | }; | 266 | }; |
179 | 267 | ||
@@ -202,6 +290,13 @@ struct nandc_regs { | |||
202 | __le32 orig_vld; | 290 | __le32 orig_vld; |
203 | 291 | ||
204 | __le32 ecc_buf_cfg; | 292 | __le32 ecc_buf_cfg; |
293 | __le32 read_location0; | ||
294 | __le32 read_location1; | ||
295 | __le32 read_location2; | ||
296 | __le32 read_location3; | ||
297 | |||
298 | __le32 erased_cw_detect_cfg_clr; | ||
299 | __le32 erased_cw_detect_cfg_set; | ||
205 | }; | 300 | }; |
206 | 301 | ||
207 | /* | 302 | /* |
@@ -226,14 +321,17 @@ struct nandc_regs { | |||
226 | * by upper layers directly | 321 | * by upper layers directly |
227 | * @buf_size/count/start: markers for chip->read_buf/write_buf functions | 322 | * @buf_size/count/start: markers for chip->read_buf/write_buf functions |
228 | * @reg_read_buf: local buffer for reading back registers via DMA | 323 | * @reg_read_buf: local buffer for reading back registers via DMA |
324 | * @reg_read_dma: contains dma address for register read buffer | ||
229 | * @reg_read_pos: marker for data read in reg_read_buf | 325 | * @reg_read_pos: marker for data read in reg_read_buf |
230 | * | 326 | * |
231 | * @regs: a contiguous chunk of memory for DMA register | 327 | * @regs: a contiguous chunk of memory for DMA register |
232 | * writes. contains the register values to be | 328 | * writes. contains the register values to be |
233 | * written to controller | 329 | * written to controller |
234 | * @cmd1/vld: some fixed controller register values | 330 | * @cmd1/vld: some fixed controller register values |
235 | * @ecc_modes: supported ECC modes by the current controller, | 331 | * @props: properties of current NAND controller, |
236 | * initialized via DT match data | 332 | * initialized via DT match data |
333 | * @max_cwperpage: maximum QPIC codewords required. calculated | ||
334 | * from all connected NAND devices pagesize | ||
237 | */ | 335 | */ |
238 | struct qcom_nand_controller { | 336 | struct qcom_nand_controller { |
239 | struct nand_hw_control controller; | 337 | struct nand_hw_control controller; |
@@ -247,23 +345,39 @@ struct qcom_nand_controller { | |||
247 | struct clk *core_clk; | 345 | struct clk *core_clk; |
248 | struct clk *aon_clk; | 346 | struct clk *aon_clk; |
249 | 347 | ||
250 | struct dma_chan *chan; | 348 | union { |
251 | unsigned int cmd_crci; | 349 | /* will be used only by QPIC for BAM DMA */ |
252 | unsigned int data_crci; | 350 | struct { |
351 | struct dma_chan *tx_chan; | ||
352 | struct dma_chan *rx_chan; | ||
353 | struct dma_chan *cmd_chan; | ||
354 | }; | ||
355 | |||
356 | /* will be used only by EBI2 for ADM DMA */ | ||
357 | struct { | ||
358 | struct dma_chan *chan; | ||
359 | unsigned int cmd_crci; | ||
360 | unsigned int data_crci; | ||
361 | }; | ||
362 | }; | ||
363 | |||
253 | struct list_head desc_list; | 364 | struct list_head desc_list; |
365 | struct bam_transaction *bam_txn; | ||
254 | 366 | ||
255 | u8 *data_buffer; | 367 | u8 *data_buffer; |
256 | int buf_size; | 368 | int buf_size; |
257 | int buf_count; | 369 | int buf_count; |
258 | int buf_start; | 370 | int buf_start; |
371 | unsigned int max_cwperpage; | ||
259 | 372 | ||
260 | __le32 *reg_read_buf; | 373 | __le32 *reg_read_buf; |
374 | dma_addr_t reg_read_dma; | ||
261 | int reg_read_pos; | 375 | int reg_read_pos; |
262 | 376 | ||
263 | struct nandc_regs *regs; | 377 | struct nandc_regs *regs; |
264 | 378 | ||
265 | u32 cmd1, vld; | 379 | u32 cmd1, vld; |
266 | u32 ecc_modes; | 380 | const struct qcom_nandc_props *props; |
267 | }; | 381 | }; |
268 | 382 | ||
269 | /* | 383 | /* |
@@ -316,6 +430,78 @@ struct qcom_nand_host { | |||
316 | u32 clrreadstatus; | 430 | u32 clrreadstatus; |
317 | }; | 431 | }; |
318 | 432 | ||
433 | /* | ||
434 | * This data type corresponds to the NAND controller properties which varies | ||
435 | * among different NAND controllers. | ||
436 | * @ecc_modes - ecc mode for NAND | ||
437 | * @is_bam - whether NAND controller is using BAM | ||
438 | * @dev_cmd_reg_start - NAND_DEV_CMD_* registers starting offset | ||
439 | */ | ||
440 | struct qcom_nandc_props { | ||
441 | u32 ecc_modes; | ||
442 | bool is_bam; | ||
443 | u32 dev_cmd_reg_start; | ||
444 | }; | ||
445 | |||
446 | /* Frees the BAM transaction memory */ | ||
447 | static void free_bam_transaction(struct qcom_nand_controller *nandc) | ||
448 | { | ||
449 | struct bam_transaction *bam_txn = nandc->bam_txn; | ||
450 | |||
451 | devm_kfree(nandc->dev, bam_txn); | ||
452 | } | ||
453 | |||
454 | /* Allocates and Initializes the BAM transaction */ | ||
455 | static struct bam_transaction * | ||
456 | alloc_bam_transaction(struct qcom_nand_controller *nandc) | ||
457 | { | ||
458 | struct bam_transaction *bam_txn; | ||
459 | size_t bam_txn_size; | ||
460 | unsigned int num_cw = nandc->max_cwperpage; | ||
461 | void *bam_txn_buf; | ||
462 | |||
463 | bam_txn_size = | ||
464 | sizeof(*bam_txn) + num_cw * | ||
465 | ((sizeof(*bam_txn->cmd_sgl) * QPIC_PER_CW_CMD_SGL) + | ||
466 | (sizeof(*bam_txn->data_sgl) * QPIC_PER_CW_DATA_SGL)); | ||
467 | |||
468 | bam_txn_buf = devm_kzalloc(nandc->dev, bam_txn_size, GFP_KERNEL); | ||
469 | if (!bam_txn_buf) | ||
470 | return NULL; | ||
471 | |||
472 | bam_txn = bam_txn_buf; | ||
473 | bam_txn_buf += sizeof(*bam_txn); | ||
474 | |||
475 | bam_txn->cmd_sgl = bam_txn_buf; | ||
476 | bam_txn_buf += | ||
477 | sizeof(*bam_txn->cmd_sgl) * QPIC_PER_CW_CMD_SGL * num_cw; | ||
478 | |||
479 | bam_txn->data_sgl = bam_txn_buf; | ||
480 | |||
481 | return bam_txn; | ||
482 | } | ||
483 | |||
484 | /* Clears the BAM transaction indexes */ | ||
485 | static void clear_bam_transaction(struct qcom_nand_controller *nandc) | ||
486 | { | ||
487 | struct bam_transaction *bam_txn = nandc->bam_txn; | ||
488 | |||
489 | if (!nandc->props->is_bam) | ||
490 | return; | ||
491 | |||
492 | bam_txn->cmd_sgl_pos = 0; | ||
493 | bam_txn->cmd_sgl_start = 0; | ||
494 | bam_txn->tx_sgl_pos = 0; | ||
495 | bam_txn->tx_sgl_start = 0; | ||
496 | bam_txn->rx_sgl_pos = 0; | ||
497 | bam_txn->rx_sgl_start = 0; | ||
498 | |||
499 | sg_init_table(bam_txn->cmd_sgl, nandc->max_cwperpage * | ||
500 | QPIC_PER_CW_CMD_SGL); | ||
501 | sg_init_table(bam_txn->data_sgl, nandc->max_cwperpage * | ||
502 | QPIC_PER_CW_DATA_SGL); | ||
503 | } | ||
504 | |||
319 | static inline struct qcom_nand_host *to_qcom_nand_host(struct nand_chip *chip) | 505 | static inline struct qcom_nand_host *to_qcom_nand_host(struct nand_chip *chip) |
320 | { | 506 | { |
321 | return container_of(chip, struct qcom_nand_host, chip); | 507 | return container_of(chip, struct qcom_nand_host, chip); |
@@ -339,6 +525,24 @@ static inline void nandc_write(struct qcom_nand_controller *nandc, int offset, | |||
339 | iowrite32(val, nandc->base + offset); | 525 | iowrite32(val, nandc->base + offset); |
340 | } | 526 | } |
341 | 527 | ||
528 | static inline void nandc_read_buffer_sync(struct qcom_nand_controller *nandc, | ||
529 | bool is_cpu) | ||
530 | { | ||
531 | if (!nandc->props->is_bam) | ||
532 | return; | ||
533 | |||
534 | if (is_cpu) | ||
535 | dma_sync_single_for_cpu(nandc->dev, nandc->reg_read_dma, | ||
536 | MAX_REG_RD * | ||
537 | sizeof(*nandc->reg_read_buf), | ||
538 | DMA_FROM_DEVICE); | ||
539 | else | ||
540 | dma_sync_single_for_device(nandc->dev, nandc->reg_read_dma, | ||
541 | MAX_REG_RD * | ||
542 | sizeof(*nandc->reg_read_buf), | ||
543 | DMA_FROM_DEVICE); | ||
544 | } | ||
545 | |||
342 | static __le32 *offset_to_nandc_reg(struct nandc_regs *regs, int offset) | 546 | static __le32 *offset_to_nandc_reg(struct nandc_regs *regs, int offset) |
343 | { | 547 | { |
344 | switch (offset) { | 548 | switch (offset) { |
@@ -372,6 +576,14 @@ static __le32 *offset_to_nandc_reg(struct nandc_regs *regs, int offset) | |||
372 | return ®s->orig_vld; | 576 | return ®s->orig_vld; |
373 | case NAND_EBI2_ECC_BUF_CFG: | 577 | case NAND_EBI2_ECC_BUF_CFG: |
374 | return ®s->ecc_buf_cfg; | 578 | return ®s->ecc_buf_cfg; |
579 | case NAND_READ_LOCATION_0: | ||
580 | return ®s->read_location0; | ||
581 | case NAND_READ_LOCATION_1: | ||
582 | return ®s->read_location1; | ||
583 | case NAND_READ_LOCATION_2: | ||
584 | return ®s->read_location2; | ||
585 | case NAND_READ_LOCATION_3: | ||
586 | return ®s->read_location3; | ||
375 | default: | 587 | default: |
376 | return NULL; | 588 | return NULL; |
377 | } | 589 | } |
@@ -446,11 +658,119 @@ static void update_rw_regs(struct qcom_nand_host *host, int num_cw, bool read) | |||
446 | nandc_set_reg(nandc, NAND_FLASH_STATUS, host->clrflashstatus); | 658 | nandc_set_reg(nandc, NAND_FLASH_STATUS, host->clrflashstatus); |
447 | nandc_set_reg(nandc, NAND_READ_STATUS, host->clrreadstatus); | 659 | nandc_set_reg(nandc, NAND_READ_STATUS, host->clrreadstatus); |
448 | nandc_set_reg(nandc, NAND_EXEC_CMD, 1); | 660 | nandc_set_reg(nandc, NAND_EXEC_CMD, 1); |
661 | |||
662 | if (read) | ||
663 | nandc_set_read_loc(nandc, 0, 0, host->use_ecc ? | ||
664 | host->cw_data : host->cw_size, 1); | ||
665 | } | ||
666 | |||
667 | /* | ||
668 | * Maps the scatter gather list for DMA transfer and forms the DMA descriptor | ||
669 | * for BAM. This descriptor will be added in the NAND DMA descriptor queue | ||
670 | * which will be submitted to DMA engine. | ||
671 | */ | ||
672 | static int prepare_bam_async_desc(struct qcom_nand_controller *nandc, | ||
673 | struct dma_chan *chan, | ||
674 | unsigned long flags) | ||
675 | { | ||
676 | struct desc_info *desc; | ||
677 | struct scatterlist *sgl; | ||
678 | unsigned int sgl_cnt; | ||
679 | int ret; | ||
680 | struct bam_transaction *bam_txn = nandc->bam_txn; | ||
681 | enum dma_transfer_direction dir_eng; | ||
682 | struct dma_async_tx_descriptor *dma_desc; | ||
683 | |||
684 | desc = kzalloc(sizeof(*desc), GFP_KERNEL); | ||
685 | if (!desc) | ||
686 | return -ENOMEM; | ||
687 | |||
688 | if (chan == nandc->cmd_chan) { | ||
689 | sgl = &bam_txn->cmd_sgl[bam_txn->cmd_sgl_start]; | ||
690 | sgl_cnt = bam_txn->cmd_sgl_pos - bam_txn->cmd_sgl_start; | ||
691 | bam_txn->cmd_sgl_start = bam_txn->cmd_sgl_pos; | ||
692 | dir_eng = DMA_MEM_TO_DEV; | ||
693 | desc->dir = DMA_TO_DEVICE; | ||
694 | } else if (chan == nandc->tx_chan) { | ||
695 | sgl = &bam_txn->data_sgl[bam_txn->tx_sgl_start]; | ||
696 | sgl_cnt = bam_txn->tx_sgl_pos - bam_txn->tx_sgl_start; | ||
697 | bam_txn->tx_sgl_start = bam_txn->tx_sgl_pos; | ||
698 | dir_eng = DMA_MEM_TO_DEV; | ||
699 | desc->dir = DMA_TO_DEVICE; | ||
700 | } else { | ||
701 | sgl = &bam_txn->data_sgl[bam_txn->rx_sgl_start]; | ||
702 | sgl_cnt = bam_txn->rx_sgl_pos - bam_txn->rx_sgl_start; | ||
703 | bam_txn->rx_sgl_start = bam_txn->rx_sgl_pos; | ||
704 | dir_eng = DMA_DEV_TO_MEM; | ||
705 | desc->dir = DMA_FROM_DEVICE; | ||
706 | } | ||
707 | |||
708 | sg_mark_end(sgl + sgl_cnt - 1); | ||
709 | ret = dma_map_sg(nandc->dev, sgl, sgl_cnt, desc->dir); | ||
710 | if (ret == 0) { | ||
711 | dev_err(nandc->dev, "failure in mapping desc\n"); | ||
712 | kfree(desc); | ||
713 | return -ENOMEM; | ||
714 | } | ||
715 | |||
716 | desc->sgl_cnt = sgl_cnt; | ||
717 | desc->bam_sgl = sgl; | ||
718 | |||
719 | dma_desc = dmaengine_prep_slave_sg(chan, sgl, sgl_cnt, dir_eng, | ||
720 | flags); | ||
721 | |||
722 | if (!dma_desc) { | ||
723 | dev_err(nandc->dev, "failure in prep desc\n"); | ||
724 | dma_unmap_sg(nandc->dev, sgl, sgl_cnt, desc->dir); | ||
725 | kfree(desc); | ||
726 | return -EINVAL; | ||
727 | } | ||
728 | |||
729 | desc->dma_desc = dma_desc; | ||
730 | |||
731 | list_add_tail(&desc->node, &nandc->desc_list); | ||
732 | |||
733 | return 0; | ||
734 | } | ||
735 | |||
736 | /* | ||
737 | * Prepares the data descriptor for BAM DMA which will be used for NAND | ||
738 | * data reads and writes. | ||
739 | */ | ||
740 | static int prep_bam_dma_desc_data(struct qcom_nand_controller *nandc, bool read, | ||
741 | const void *vaddr, | ||
742 | int size, unsigned int flags) | ||
743 | { | ||
744 | int ret; | ||
745 | struct bam_transaction *bam_txn = nandc->bam_txn; | ||
746 | |||
747 | if (read) { | ||
748 | sg_set_buf(&bam_txn->data_sgl[bam_txn->rx_sgl_pos], | ||
749 | vaddr, size); | ||
750 | bam_txn->rx_sgl_pos++; | ||
751 | } else { | ||
752 | sg_set_buf(&bam_txn->data_sgl[bam_txn->tx_sgl_pos], | ||
753 | vaddr, size); | ||
754 | bam_txn->tx_sgl_pos++; | ||
755 | |||
756 | /* | ||
757 | * BAM will only set EOT for DMA_PREP_INTERRUPT so if this flag | ||
758 | * is not set, form the DMA descriptor | ||
759 | */ | ||
760 | if (!(flags & NAND_BAM_NO_EOT)) { | ||
761 | ret = prepare_bam_async_desc(nandc, nandc->tx_chan, | ||
762 | DMA_PREP_INTERRUPT); | ||
763 | if (ret) | ||
764 | return ret; | ||
765 | } | ||
766 | } | ||
767 | |||
768 | return 0; | ||
449 | } | 769 | } |
450 | 770 | ||
451 | static int prep_dma_desc(struct qcom_nand_controller *nandc, bool read, | 771 | static int prep_adm_dma_desc(struct qcom_nand_controller *nandc, bool read, |
452 | int reg_off, const void *vaddr, int size, | 772 | int reg_off, const void *vaddr, int size, |
453 | bool flow_control) | 773 | bool flow_control) |
454 | { | 774 | { |
455 | struct desc_info *desc; | 775 | struct desc_info *desc; |
456 | struct dma_async_tx_descriptor *dma_desc; | 776 | struct dma_async_tx_descriptor *dma_desc; |
@@ -463,7 +783,7 @@ static int prep_dma_desc(struct qcom_nand_controller *nandc, bool read, | |||
463 | if (!desc) | 783 | if (!desc) |
464 | return -ENOMEM; | 784 | return -ENOMEM; |
465 | 785 | ||
466 | sgl = &desc->sgl; | 786 | sgl = &desc->adm_sgl; |
467 | 787 | ||
468 | sg_init_one(sgl, vaddr, size); | 788 | sg_init_one(sgl, vaddr, size); |
469 | 789 | ||
@@ -524,9 +844,10 @@ err: | |||
524 | * | 844 | * |
525 | * @first: offset of the first register in the contiguous block | 845 | * @first: offset of the first register in the contiguous block |
526 | * @num_regs: number of registers to read | 846 | * @num_regs: number of registers to read |
847 | * @flags: flags to control DMA descriptor preparation | ||
527 | */ | 848 | */ |
528 | static int read_reg_dma(struct qcom_nand_controller *nandc, int first, | 849 | static int read_reg_dma(struct qcom_nand_controller *nandc, int first, |
529 | int num_regs) | 850 | int num_regs, unsigned int flags) |
530 | { | 851 | { |
531 | bool flow_control = false; | 852 | bool flow_control = false; |
532 | void *vaddr; | 853 | void *vaddr; |
@@ -535,11 +856,14 @@ static int read_reg_dma(struct qcom_nand_controller *nandc, int first, | |||
535 | if (first == NAND_READ_ID || first == NAND_FLASH_STATUS) | 856 | if (first == NAND_READ_ID || first == NAND_FLASH_STATUS) |
536 | flow_control = true; | 857 | flow_control = true; |
537 | 858 | ||
859 | if (first == NAND_DEV_CMD_VLD || first == NAND_DEV_CMD1) | ||
860 | first = dev_cmd_reg_addr(nandc, first); | ||
861 | |||
538 | size = num_regs * sizeof(u32); | 862 | size = num_regs * sizeof(u32); |
539 | vaddr = nandc->reg_read_buf + nandc->reg_read_pos; | 863 | vaddr = nandc->reg_read_buf + nandc->reg_read_pos; |
540 | nandc->reg_read_pos += num_regs; | 864 | nandc->reg_read_pos += num_regs; |
541 | 865 | ||
542 | return prep_dma_desc(nandc, true, first, vaddr, size, flow_control); | 866 | return prep_adm_dma_desc(nandc, true, first, vaddr, size, flow_control); |
543 | } | 867 | } |
544 | 868 | ||
545 | /* | 869 | /* |
@@ -548,9 +872,10 @@ static int read_reg_dma(struct qcom_nand_controller *nandc, int first, | |||
548 | * | 872 | * |
549 | * @first: offset of the first register in the contiguous block | 873 | * @first: offset of the first register in the contiguous block |
550 | * @num_regs: number of registers to write | 874 | * @num_regs: number of registers to write |
875 | * @flags: flags to control DMA descriptor preparation | ||
551 | */ | 876 | */ |
552 | static int write_reg_dma(struct qcom_nand_controller *nandc, int first, | 877 | static int write_reg_dma(struct qcom_nand_controller *nandc, int first, |
553 | int num_regs) | 878 | int num_regs, unsigned int flags) |
554 | { | 879 | { |
555 | bool flow_control = false; | 880 | bool flow_control = false; |
556 | struct nandc_regs *regs = nandc->regs; | 881 | struct nandc_regs *regs = nandc->regs; |
@@ -562,15 +887,26 @@ static int write_reg_dma(struct qcom_nand_controller *nandc, int first, | |||
562 | if (first == NAND_FLASH_CMD) | 887 | if (first == NAND_FLASH_CMD) |
563 | flow_control = true; | 888 | flow_control = true; |
564 | 889 | ||
565 | if (first == NAND_DEV_CMD1_RESTORE) | 890 | if (first == NAND_ERASED_CW_DETECT_CFG) { |
566 | first = NAND_DEV_CMD1; | 891 | if (flags & NAND_ERASED_CW_SET) |
892 | vaddr = ®s->erased_cw_detect_cfg_set; | ||
893 | else | ||
894 | vaddr = ®s->erased_cw_detect_cfg_clr; | ||
895 | } | ||
896 | |||
897 | if (first == NAND_EXEC_CMD) | ||
898 | flags |= NAND_BAM_NWD; | ||
899 | |||
900 | if (first == NAND_DEV_CMD1_RESTORE || first == NAND_DEV_CMD1) | ||
901 | first = dev_cmd_reg_addr(nandc, NAND_DEV_CMD1); | ||
567 | 902 | ||
568 | if (first == NAND_DEV_CMD_VLD_RESTORE) | 903 | if (first == NAND_DEV_CMD_VLD_RESTORE || first == NAND_DEV_CMD_VLD) |
569 | first = NAND_DEV_CMD_VLD; | 904 | first = dev_cmd_reg_addr(nandc, NAND_DEV_CMD_VLD); |
570 | 905 | ||
571 | size = num_regs * sizeof(u32); | 906 | size = num_regs * sizeof(u32); |
572 | 907 | ||
573 | return prep_dma_desc(nandc, false, first, vaddr, size, flow_control); | 908 | return prep_adm_dma_desc(nandc, false, first, vaddr, size, |
909 | flow_control); | ||
574 | } | 910 | } |
575 | 911 | ||
576 | /* | 912 | /* |
@@ -580,11 +916,15 @@ static int write_reg_dma(struct qcom_nand_controller *nandc, int first, | |||
580 | * @reg_off: offset within the controller's data buffer | 916 | * @reg_off: offset within the controller's data buffer |
581 | * @vaddr: virtual address of the buffer we want to write to | 917 | * @vaddr: virtual address of the buffer we want to write to |
582 | * @size: DMA transaction size in bytes | 918 | * @size: DMA transaction size in bytes |
919 | * @flags: flags to control DMA descriptor preparation | ||
583 | */ | 920 | */ |
584 | static int read_data_dma(struct qcom_nand_controller *nandc, int reg_off, | 921 | static int read_data_dma(struct qcom_nand_controller *nandc, int reg_off, |
585 | const u8 *vaddr, int size) | 922 | const u8 *vaddr, int size, unsigned int flags) |
586 | { | 923 | { |
587 | return prep_dma_desc(nandc, true, reg_off, vaddr, size, false); | 924 | if (nandc->props->is_bam) |
925 | return prep_bam_dma_desc_data(nandc, true, vaddr, size, flags); | ||
926 | |||
927 | return prep_adm_dma_desc(nandc, true, reg_off, vaddr, size, false); | ||
588 | } | 928 | } |
589 | 929 | ||
590 | /* | 930 | /* |
@@ -594,48 +934,84 @@ static int read_data_dma(struct qcom_nand_controller *nandc, int reg_off, | |||
594 | * @reg_off: offset within the controller's data buffer | 934 | * @reg_off: offset within the controller's data buffer |
595 | * @vaddr: virtual address of the buffer we want to read from | 935 | * @vaddr: virtual address of the buffer we want to read from |
596 | * @size: DMA transaction size in bytes | 936 | * @size: DMA transaction size in bytes |
937 | * @flags: flags to control DMA descriptor preparation | ||
597 | */ | 938 | */ |
598 | static int write_data_dma(struct qcom_nand_controller *nandc, int reg_off, | 939 | static int write_data_dma(struct qcom_nand_controller *nandc, int reg_off, |
599 | const u8 *vaddr, int size) | 940 | const u8 *vaddr, int size, unsigned int flags) |
600 | { | 941 | { |
601 | return prep_dma_desc(nandc, false, reg_off, vaddr, size, false); | 942 | if (nandc->props->is_bam) |
943 | return prep_bam_dma_desc_data(nandc, false, vaddr, size, flags); | ||
944 | |||
945 | return prep_adm_dma_desc(nandc, false, reg_off, vaddr, size, false); | ||
602 | } | 946 | } |
603 | 947 | ||
604 | /* | 948 | /* |
605 | * helper to prepare dma descriptors to configure registers needed for reading a | 949 | * Helper to prepare DMA descriptors for configuring registers |
606 | * codeword/step in a page | 950 | * before reading a NAND page. |
607 | */ | 951 | */ |
608 | static void config_cw_read(struct qcom_nand_controller *nandc) | 952 | static void config_nand_page_read(struct qcom_nand_controller *nandc) |
609 | { | 953 | { |
610 | write_reg_dma(nandc, NAND_FLASH_CMD, 3); | 954 | write_reg_dma(nandc, NAND_ADDR0, 2, 0); |
611 | write_reg_dma(nandc, NAND_DEV0_CFG0, 3); | 955 | write_reg_dma(nandc, NAND_DEV0_CFG0, 3, 0); |
612 | write_reg_dma(nandc, NAND_EBI2_ECC_BUF_CFG, 1); | 956 | write_reg_dma(nandc, NAND_EBI2_ECC_BUF_CFG, 1, 0); |
957 | write_reg_dma(nandc, NAND_ERASED_CW_DETECT_CFG, 1, 0); | ||
958 | write_reg_dma(nandc, NAND_ERASED_CW_DETECT_CFG, 1, | ||
959 | NAND_ERASED_CW_SET | NAND_BAM_NEXT_SGL); | ||
960 | } | ||
613 | 961 | ||
614 | write_reg_dma(nandc, NAND_EXEC_CMD, 1); | 962 | /* |
963 | * Helper to prepare DMA descriptors for configuring registers | ||
964 | * before reading each codeword in NAND page. | ||
965 | */ | ||
966 | static void config_nand_cw_read(struct qcom_nand_controller *nandc) | ||
967 | { | ||
968 | if (nandc->props->is_bam) | ||
969 | write_reg_dma(nandc, NAND_READ_LOCATION_0, 4, | ||
970 | NAND_BAM_NEXT_SGL); | ||
615 | 971 | ||
616 | read_reg_dma(nandc, NAND_FLASH_STATUS, 2); | 972 | write_reg_dma(nandc, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL); |
617 | read_reg_dma(nandc, NAND_ERASED_CW_DETECT_STATUS, 1); | 973 | write_reg_dma(nandc, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); |
974 | |||
975 | read_reg_dma(nandc, NAND_FLASH_STATUS, 2, 0); | ||
976 | read_reg_dma(nandc, NAND_ERASED_CW_DETECT_STATUS, 1, | ||
977 | NAND_BAM_NEXT_SGL); | ||
618 | } | 978 | } |
619 | 979 | ||
620 | /* | 980 | /* |
621 | * helpers to prepare dma descriptors used to configure registers needed for | 981 | * Helper to prepare dma descriptors to configure registers needed for reading a |
622 | * writing a codeword/step in a page | 982 | * single codeword in page |
623 | */ | 983 | */ |
624 | static void config_cw_write_pre(struct qcom_nand_controller *nandc) | 984 | static void config_nand_single_cw_page_read(struct qcom_nand_controller *nandc) |
625 | { | 985 | { |
626 | write_reg_dma(nandc, NAND_FLASH_CMD, 3); | 986 | config_nand_page_read(nandc); |
627 | write_reg_dma(nandc, NAND_DEV0_CFG0, 3); | 987 | config_nand_cw_read(nandc); |
628 | write_reg_dma(nandc, NAND_EBI2_ECC_BUF_CFG, 1); | ||
629 | } | 988 | } |
630 | 989 | ||
631 | static void config_cw_write_post(struct qcom_nand_controller *nandc) | 990 | /* |
991 | * Helper to prepare DMA descriptors used to configure registers needed for | ||
992 | * before writing a NAND page. | ||
993 | */ | ||
994 | static void config_nand_page_write(struct qcom_nand_controller *nandc) | ||
632 | { | 995 | { |
633 | write_reg_dma(nandc, NAND_EXEC_CMD, 1); | 996 | write_reg_dma(nandc, NAND_ADDR0, 2, 0); |
997 | write_reg_dma(nandc, NAND_DEV0_CFG0, 3, 0); | ||
998 | write_reg_dma(nandc, NAND_EBI2_ECC_BUF_CFG, 1, | ||
999 | NAND_BAM_NEXT_SGL); | ||
1000 | } | ||
634 | 1001 | ||
635 | read_reg_dma(nandc, NAND_FLASH_STATUS, 1); | 1002 | /* |
1003 | * Helper to prepare DMA descriptors for configuring registers | ||
1004 | * before writing each codeword in NAND page. | ||
1005 | */ | ||
1006 | static void config_nand_cw_write(struct qcom_nand_controller *nandc) | ||
1007 | { | ||
1008 | write_reg_dma(nandc, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL); | ||
1009 | write_reg_dma(nandc, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); | ||
636 | 1010 | ||
637 | write_reg_dma(nandc, NAND_FLASH_STATUS, 1); | 1011 | read_reg_dma(nandc, NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL); |
638 | write_reg_dma(nandc, NAND_READ_STATUS, 1); | 1012 | |
1013 | write_reg_dma(nandc, NAND_FLASH_STATUS, 1, 0); | ||
1014 | write_reg_dma(nandc, NAND_READ_STATUS, 1, NAND_BAM_NEXT_SGL); | ||
639 | } | 1015 | } |
640 | 1016 | ||
641 | /* | 1017 | /* |
@@ -672,8 +1048,7 @@ static int nandc_param(struct qcom_nand_host *host) | |||
672 | 1048 | ||
673 | /* configure CMD1 and VLD for ONFI param probing */ | 1049 | /* configure CMD1 and VLD for ONFI param probing */ |
674 | nandc_set_reg(nandc, NAND_DEV_CMD_VLD, | 1050 | nandc_set_reg(nandc, NAND_DEV_CMD_VLD, |
675 | (nandc->vld & ~(1 << READ_START_VLD)) | 1051 | (nandc->vld & ~READ_START_VLD)); |
676 | | 0 << READ_START_VLD); | ||
677 | nandc_set_reg(nandc, NAND_DEV_CMD1, | 1052 | nandc_set_reg(nandc, NAND_DEV_CMD1, |
678 | (nandc->cmd1 & ~(0xFF << READ_ADDR)) | 1053 | (nandc->cmd1 & ~(0xFF << READ_ADDR)) |
679 | | NAND_CMD_PARAM << READ_ADDR); | 1054 | | NAND_CMD_PARAM << READ_ADDR); |
@@ -682,21 +1057,22 @@ static int nandc_param(struct qcom_nand_host *host) | |||
682 | 1057 | ||
683 | nandc_set_reg(nandc, NAND_DEV_CMD1_RESTORE, nandc->cmd1); | 1058 | nandc_set_reg(nandc, NAND_DEV_CMD1_RESTORE, nandc->cmd1); |
684 | nandc_set_reg(nandc, NAND_DEV_CMD_VLD_RESTORE, nandc->vld); | 1059 | nandc_set_reg(nandc, NAND_DEV_CMD_VLD_RESTORE, nandc->vld); |
1060 | nandc_set_read_loc(nandc, 0, 0, 512, 1); | ||
685 | 1061 | ||
686 | write_reg_dma(nandc, NAND_DEV_CMD_VLD, 1); | 1062 | write_reg_dma(nandc, NAND_DEV_CMD_VLD, 1, 0); |
687 | write_reg_dma(nandc, NAND_DEV_CMD1, 1); | 1063 | write_reg_dma(nandc, NAND_DEV_CMD1, 1, NAND_BAM_NEXT_SGL); |
688 | 1064 | ||
689 | nandc->buf_count = 512; | 1065 | nandc->buf_count = 512; |
690 | memset(nandc->data_buffer, 0xff, nandc->buf_count); | 1066 | memset(nandc->data_buffer, 0xff, nandc->buf_count); |
691 | 1067 | ||
692 | config_cw_read(nandc); | 1068 | config_nand_single_cw_page_read(nandc); |
693 | 1069 | ||
694 | read_data_dma(nandc, FLASH_BUF_ACC, nandc->data_buffer, | 1070 | read_data_dma(nandc, FLASH_BUF_ACC, nandc->data_buffer, |
695 | nandc->buf_count); | 1071 | nandc->buf_count, 0); |
696 | 1072 | ||
697 | /* restore CMD1 and VLD regs */ | 1073 | /* restore CMD1 and VLD regs */ |
698 | write_reg_dma(nandc, NAND_DEV_CMD1_RESTORE, 1); | 1074 | write_reg_dma(nandc, NAND_DEV_CMD1_RESTORE, 1, 0); |
699 | write_reg_dma(nandc, NAND_DEV_CMD_VLD_RESTORE, 1); | 1075 | write_reg_dma(nandc, NAND_DEV_CMD_VLD_RESTORE, 1, NAND_BAM_NEXT_SGL); |
700 | 1076 | ||
701 | return 0; | 1077 | return 0; |
702 | } | 1078 | } |
@@ -718,14 +1094,14 @@ static int erase_block(struct qcom_nand_host *host, int page_addr) | |||
718 | nandc_set_reg(nandc, NAND_FLASH_STATUS, host->clrflashstatus); | 1094 | nandc_set_reg(nandc, NAND_FLASH_STATUS, host->clrflashstatus); |
719 | nandc_set_reg(nandc, NAND_READ_STATUS, host->clrreadstatus); | 1095 | nandc_set_reg(nandc, NAND_READ_STATUS, host->clrreadstatus); |
720 | 1096 | ||
721 | write_reg_dma(nandc, NAND_FLASH_CMD, 3); | 1097 | write_reg_dma(nandc, NAND_FLASH_CMD, 3, NAND_BAM_NEXT_SGL); |
722 | write_reg_dma(nandc, NAND_DEV0_CFG0, 2); | 1098 | write_reg_dma(nandc, NAND_DEV0_CFG0, 2, NAND_BAM_NEXT_SGL); |
723 | write_reg_dma(nandc, NAND_EXEC_CMD, 1); | 1099 | write_reg_dma(nandc, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); |
724 | 1100 | ||
725 | read_reg_dma(nandc, NAND_FLASH_STATUS, 1); | 1101 | read_reg_dma(nandc, NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL); |
726 | 1102 | ||
727 | write_reg_dma(nandc, NAND_FLASH_STATUS, 1); | 1103 | write_reg_dma(nandc, NAND_FLASH_STATUS, 1, 0); |
728 | write_reg_dma(nandc, NAND_READ_STATUS, 1); | 1104 | write_reg_dma(nandc, NAND_READ_STATUS, 1, NAND_BAM_NEXT_SGL); |
729 | 1105 | ||
730 | return 0; | 1106 | return 0; |
731 | } | 1107 | } |
@@ -742,13 +1118,14 @@ static int read_id(struct qcom_nand_host *host, int column) | |||
742 | nandc_set_reg(nandc, NAND_FLASH_CMD, FETCH_ID); | 1118 | nandc_set_reg(nandc, NAND_FLASH_CMD, FETCH_ID); |
743 | nandc_set_reg(nandc, NAND_ADDR0, column); | 1119 | nandc_set_reg(nandc, NAND_ADDR0, column); |
744 | nandc_set_reg(nandc, NAND_ADDR1, 0); | 1120 | nandc_set_reg(nandc, NAND_ADDR1, 0); |
745 | nandc_set_reg(nandc, NAND_FLASH_CHIP_SELECT, DM_EN); | 1121 | nandc_set_reg(nandc, NAND_FLASH_CHIP_SELECT, |
1122 | nandc->props->is_bam ? 0 : DM_EN); | ||
746 | nandc_set_reg(nandc, NAND_EXEC_CMD, 1); | 1123 | nandc_set_reg(nandc, NAND_EXEC_CMD, 1); |
747 | 1124 | ||
748 | write_reg_dma(nandc, NAND_FLASH_CMD, 4); | 1125 | write_reg_dma(nandc, NAND_FLASH_CMD, 4, NAND_BAM_NEXT_SGL); |
749 | write_reg_dma(nandc, NAND_EXEC_CMD, 1); | 1126 | write_reg_dma(nandc, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); |
750 | 1127 | ||
751 | read_reg_dma(nandc, NAND_READ_ID, 1); | 1128 | read_reg_dma(nandc, NAND_READ_ID, 1, NAND_BAM_NEXT_SGL); |
752 | 1129 | ||
753 | return 0; | 1130 | return 0; |
754 | } | 1131 | } |
@@ -762,10 +1139,10 @@ static int reset(struct qcom_nand_host *host) | |||
762 | nandc_set_reg(nandc, NAND_FLASH_CMD, RESET_DEVICE); | 1139 | nandc_set_reg(nandc, NAND_FLASH_CMD, RESET_DEVICE); |
763 | nandc_set_reg(nandc, NAND_EXEC_CMD, 1); | 1140 | nandc_set_reg(nandc, NAND_EXEC_CMD, 1); |
764 | 1141 | ||
765 | write_reg_dma(nandc, NAND_FLASH_CMD, 1); | 1142 | write_reg_dma(nandc, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL); |
766 | write_reg_dma(nandc, NAND_EXEC_CMD, 1); | 1143 | write_reg_dma(nandc, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); |
767 | 1144 | ||
768 | read_reg_dma(nandc, NAND_FLASH_STATUS, 1); | 1145 | read_reg_dma(nandc, NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL); |
769 | 1146 | ||
770 | return 0; | 1147 | return 0; |
771 | } | 1148 | } |
@@ -775,12 +1152,43 @@ static int submit_descs(struct qcom_nand_controller *nandc) | |||
775 | { | 1152 | { |
776 | struct desc_info *desc; | 1153 | struct desc_info *desc; |
777 | dma_cookie_t cookie = 0; | 1154 | dma_cookie_t cookie = 0; |
1155 | struct bam_transaction *bam_txn = nandc->bam_txn; | ||
1156 | int r; | ||
1157 | |||
1158 | if (nandc->props->is_bam) { | ||
1159 | if (bam_txn->rx_sgl_pos > bam_txn->rx_sgl_start) { | ||
1160 | r = prepare_bam_async_desc(nandc, nandc->rx_chan, 0); | ||
1161 | if (r) | ||
1162 | return r; | ||
1163 | } | ||
1164 | |||
1165 | if (bam_txn->tx_sgl_pos > bam_txn->tx_sgl_start) { | ||
1166 | r = prepare_bam_async_desc(nandc, nandc->tx_chan, | ||
1167 | DMA_PREP_INTERRUPT); | ||
1168 | if (r) | ||
1169 | return r; | ||
1170 | } | ||
1171 | |||
1172 | if (bam_txn->cmd_sgl_pos > bam_txn->cmd_sgl_start) { | ||
1173 | r = prepare_bam_async_desc(nandc, nandc->cmd_chan, 0); | ||
1174 | if (r) | ||
1175 | return r; | ||
1176 | } | ||
1177 | } | ||
778 | 1178 | ||
779 | list_for_each_entry(desc, &nandc->desc_list, node) | 1179 | list_for_each_entry(desc, &nandc->desc_list, node) |
780 | cookie = dmaengine_submit(desc->dma_desc); | 1180 | cookie = dmaengine_submit(desc->dma_desc); |
781 | 1181 | ||
782 | if (dma_sync_wait(nandc->chan, cookie) != DMA_COMPLETE) | 1182 | if (nandc->props->is_bam) { |
783 | return -ETIMEDOUT; | 1183 | dma_async_issue_pending(nandc->tx_chan); |
1184 | dma_async_issue_pending(nandc->rx_chan); | ||
1185 | |||
1186 | if (dma_sync_wait(nandc->cmd_chan, cookie) != DMA_COMPLETE) | ||
1187 | return -ETIMEDOUT; | ||
1188 | } else { | ||
1189 | if (dma_sync_wait(nandc->chan, cookie) != DMA_COMPLETE) | ||
1190 | return -ETIMEDOUT; | ||
1191 | } | ||
784 | 1192 | ||
785 | return 0; | 1193 | return 0; |
786 | } | 1194 | } |
@@ -791,7 +1199,14 @@ static void free_descs(struct qcom_nand_controller *nandc) | |||
791 | 1199 | ||
792 | list_for_each_entry_safe(desc, n, &nandc->desc_list, node) { | 1200 | list_for_each_entry_safe(desc, n, &nandc->desc_list, node) { |
793 | list_del(&desc->node); | 1201 | list_del(&desc->node); |
794 | dma_unmap_sg(nandc->dev, &desc->sgl, 1, desc->dir); | 1202 | |
1203 | if (nandc->props->is_bam) | ||
1204 | dma_unmap_sg(nandc->dev, desc->bam_sgl, | ||
1205 | desc->sgl_cnt, desc->dir); | ||
1206 | else | ||
1207 | dma_unmap_sg(nandc->dev, &desc->adm_sgl, 1, | ||
1208 | desc->dir); | ||
1209 | |||
795 | kfree(desc); | 1210 | kfree(desc); |
796 | } | 1211 | } |
797 | } | 1212 | } |
@@ -800,8 +1215,7 @@ static void free_descs(struct qcom_nand_controller *nandc) | |||
800 | static void clear_read_regs(struct qcom_nand_controller *nandc) | 1215 | static void clear_read_regs(struct qcom_nand_controller *nandc) |
801 | { | 1216 | { |
802 | nandc->reg_read_pos = 0; | 1217 | nandc->reg_read_pos = 0; |
803 | memset(nandc->reg_read_buf, 0, | 1218 | nandc_read_buffer_sync(nandc, false); |
804 | MAX_REG_RD * sizeof(*nandc->reg_read_buf)); | ||
805 | } | 1219 | } |
806 | 1220 | ||
807 | static void pre_command(struct qcom_nand_host *host, int command) | 1221 | static void pre_command(struct qcom_nand_host *host, int command) |
@@ -815,6 +1229,10 @@ static void pre_command(struct qcom_nand_host *host, int command) | |||
815 | host->last_command = command; | 1229 | host->last_command = command; |
816 | 1230 | ||
817 | clear_read_regs(nandc); | 1231 | clear_read_regs(nandc); |
1232 | |||
1233 | if (command == NAND_CMD_RESET || command == NAND_CMD_READID || | ||
1234 | command == NAND_CMD_PARAM || command == NAND_CMD_ERASE1) | ||
1235 | clear_bam_transaction(nandc); | ||
818 | } | 1236 | } |
819 | 1237 | ||
820 | /* | 1238 | /* |
@@ -831,6 +1249,7 @@ static void parse_erase_write_errors(struct qcom_nand_host *host, int command) | |||
831 | int i; | 1249 | int i; |
832 | 1250 | ||
833 | num_cw = command == NAND_CMD_PAGEPROG ? ecc->steps : 1; | 1251 | num_cw = command == NAND_CMD_PAGEPROG ? ecc->steps : 1; |
1252 | nandc_read_buffer_sync(nandc, true); | ||
834 | 1253 | ||
835 | for (i = 0; i < num_cw; i++) { | 1254 | for (i = 0; i < num_cw; i++) { |
836 | u32 flash_status = le32_to_cpu(nandc->reg_read_buf[i]); | 1255 | u32 flash_status = le32_to_cpu(nandc->reg_read_buf[i]); |
@@ -852,6 +1271,7 @@ static void post_command(struct qcom_nand_host *host, int command) | |||
852 | 1271 | ||
853 | switch (command) { | 1272 | switch (command) { |
854 | case NAND_CMD_READID: | 1273 | case NAND_CMD_READID: |
1274 | nandc_read_buffer_sync(nandc, true); | ||
855 | memcpy(nandc->data_buffer, nandc->reg_read_buf, | 1275 | memcpy(nandc->data_buffer, nandc->reg_read_buf, |
856 | nandc->buf_count); | 1276 | nandc->buf_count); |
857 | break; | 1277 | break; |
@@ -1015,6 +1435,7 @@ static int parse_read_errors(struct qcom_nand_host *host, u8 *data_buf, | |||
1015 | int i; | 1435 | int i; |
1016 | 1436 | ||
1017 | buf = (struct read_stats *)nandc->reg_read_buf; | 1437 | buf = (struct read_stats *)nandc->reg_read_buf; |
1438 | nandc_read_buffer_sync(nandc, true); | ||
1018 | 1439 | ||
1019 | for (i = 0; i < ecc->steps; i++, buf++) { | 1440 | for (i = 0; i < ecc->steps; i++, buf++) { |
1020 | u32 flash, buffer, erased_cw; | 1441 | u32 flash, buffer, erased_cw; |
@@ -1102,6 +1523,8 @@ static int read_page_ecc(struct qcom_nand_host *host, u8 *data_buf, | |||
1102 | struct nand_ecc_ctrl *ecc = &chip->ecc; | 1523 | struct nand_ecc_ctrl *ecc = &chip->ecc; |
1103 | int i, ret; | 1524 | int i, ret; |
1104 | 1525 | ||
1526 | config_nand_page_read(nandc); | ||
1527 | |||
1105 | /* queue cmd descs for each codeword */ | 1528 | /* queue cmd descs for each codeword */ |
1106 | for (i = 0; i < ecc->steps; i++) { | 1529 | for (i = 0; i < ecc->steps; i++) { |
1107 | int data_size, oob_size; | 1530 | int data_size, oob_size; |
@@ -1115,11 +1538,24 @@ static int read_page_ecc(struct qcom_nand_host *host, u8 *data_buf, | |||
1115 | oob_size = host->ecc_bytes_hw + host->spare_bytes; | 1538 | oob_size = host->ecc_bytes_hw + host->spare_bytes; |
1116 | } | 1539 | } |
1117 | 1540 | ||
1118 | config_cw_read(nandc); | 1541 | if (nandc->props->is_bam) { |
1542 | if (data_buf && oob_buf) { | ||
1543 | nandc_set_read_loc(nandc, 0, 0, data_size, 0); | ||
1544 | nandc_set_read_loc(nandc, 1, data_size, | ||
1545 | oob_size, 1); | ||
1546 | } else if (data_buf) { | ||
1547 | nandc_set_read_loc(nandc, 0, 0, data_size, 1); | ||
1548 | } else { | ||
1549 | nandc_set_read_loc(nandc, 0, data_size, | ||
1550 | oob_size, 1); | ||
1551 | } | ||
1552 | } | ||
1553 | |||
1554 | config_nand_cw_read(nandc); | ||
1119 | 1555 | ||
1120 | if (data_buf) | 1556 | if (data_buf) |
1121 | read_data_dma(nandc, FLASH_BUF_ACC, data_buf, | 1557 | read_data_dma(nandc, FLASH_BUF_ACC, data_buf, |
1122 | data_size); | 1558 | data_size, 0); |
1123 | 1559 | ||
1124 | /* | 1560 | /* |
1125 | * when ecc is enabled, the controller doesn't read the real | 1561 | * when ecc is enabled, the controller doesn't read the real |
@@ -1135,7 +1571,7 @@ static int read_page_ecc(struct qcom_nand_host *host, u8 *data_buf, | |||
1135 | *oob_buf++ = 0xff; | 1571 | *oob_buf++ = 0xff; |
1136 | 1572 | ||
1137 | read_data_dma(nandc, FLASH_BUF_ACC + data_size, | 1573 | read_data_dma(nandc, FLASH_BUF_ACC + data_size, |
1138 | oob_buf, oob_size); | 1574 | oob_buf, oob_size, 0); |
1139 | } | 1575 | } |
1140 | 1576 | ||
1141 | if (data_buf) | 1577 | if (data_buf) |
@@ -1175,9 +1611,9 @@ static int copy_last_cw(struct qcom_nand_host *host, int page) | |||
1175 | set_address(host, host->cw_size * (ecc->steps - 1), page); | 1611 | set_address(host, host->cw_size * (ecc->steps - 1), page); |
1176 | update_rw_regs(host, 1, true); | 1612 | update_rw_regs(host, 1, true); |
1177 | 1613 | ||
1178 | config_cw_read(nandc); | 1614 | config_nand_single_cw_page_read(nandc); |
1179 | 1615 | ||
1180 | read_data_dma(nandc, FLASH_BUF_ACC, nandc->data_buffer, size); | 1616 | read_data_dma(nandc, FLASH_BUF_ACC, nandc->data_buffer, size, 0); |
1181 | 1617 | ||
1182 | ret = submit_descs(nandc); | 1618 | ret = submit_descs(nandc); |
1183 | if (ret) | 1619 | if (ret) |
@@ -1200,6 +1636,7 @@ static int qcom_nandc_read_page(struct mtd_info *mtd, struct nand_chip *chip, | |||
1200 | data_buf = buf; | 1636 | data_buf = buf; |
1201 | oob_buf = oob_required ? chip->oob_poi : NULL; | 1637 | oob_buf = oob_required ? chip->oob_poi : NULL; |
1202 | 1638 | ||
1639 | clear_bam_transaction(nandc); | ||
1203 | ret = read_page_ecc(host, data_buf, oob_buf); | 1640 | ret = read_page_ecc(host, data_buf, oob_buf); |
1204 | if (ret) { | 1641 | if (ret) { |
1205 | dev_err(nandc->dev, "failure to read page\n"); | 1642 | dev_err(nandc->dev, "failure to read page\n"); |
@@ -1219,12 +1656,16 @@ static int qcom_nandc_read_page_raw(struct mtd_info *mtd, | |||
1219 | u8 *data_buf, *oob_buf; | 1656 | u8 *data_buf, *oob_buf; |
1220 | struct nand_ecc_ctrl *ecc = &chip->ecc; | 1657 | struct nand_ecc_ctrl *ecc = &chip->ecc; |
1221 | int i, ret; | 1658 | int i, ret; |
1659 | int read_loc; | ||
1222 | 1660 | ||
1223 | data_buf = buf; | 1661 | data_buf = buf; |
1224 | oob_buf = chip->oob_poi; | 1662 | oob_buf = chip->oob_poi; |
1225 | 1663 | ||
1226 | host->use_ecc = false; | 1664 | host->use_ecc = false; |
1665 | |||
1666 | clear_bam_transaction(nandc); | ||
1227 | update_rw_regs(host, ecc->steps, true); | 1667 | update_rw_regs(host, ecc->steps, true); |
1668 | config_nand_page_read(nandc); | ||
1228 | 1669 | ||
1229 | for (i = 0; i < ecc->steps; i++) { | 1670 | for (i = 0; i < ecc->steps; i++) { |
1230 | int data_size1, data_size2, oob_size1, oob_size2; | 1671 | int data_size1, data_size2, oob_size1, oob_size2; |
@@ -1243,21 +1684,35 @@ static int qcom_nandc_read_page_raw(struct mtd_info *mtd, | |||
1243 | oob_size2 = host->ecc_bytes_hw + host->spare_bytes; | 1684 | oob_size2 = host->ecc_bytes_hw + host->spare_bytes; |
1244 | } | 1685 | } |
1245 | 1686 | ||
1246 | config_cw_read(nandc); | 1687 | if (nandc->props->is_bam) { |
1688 | read_loc = 0; | ||
1689 | nandc_set_read_loc(nandc, 0, read_loc, data_size1, 0); | ||
1690 | read_loc += data_size1; | ||
1691 | |||
1692 | nandc_set_read_loc(nandc, 1, read_loc, oob_size1, 0); | ||
1693 | read_loc += oob_size1; | ||
1694 | |||
1695 | nandc_set_read_loc(nandc, 2, read_loc, data_size2, 0); | ||
1696 | read_loc += data_size2; | ||
1247 | 1697 | ||
1248 | read_data_dma(nandc, reg_off, data_buf, data_size1); | 1698 | nandc_set_read_loc(nandc, 3, read_loc, oob_size2, 1); |
1699 | } | ||
1700 | |||
1701 | config_nand_cw_read(nandc); | ||
1702 | |||
1703 | read_data_dma(nandc, reg_off, data_buf, data_size1, 0); | ||
1249 | reg_off += data_size1; | 1704 | reg_off += data_size1; |
1250 | data_buf += data_size1; | 1705 | data_buf += data_size1; |
1251 | 1706 | ||
1252 | read_data_dma(nandc, reg_off, oob_buf, oob_size1); | 1707 | read_data_dma(nandc, reg_off, oob_buf, oob_size1, 0); |
1253 | reg_off += oob_size1; | 1708 | reg_off += oob_size1; |
1254 | oob_buf += oob_size1; | 1709 | oob_buf += oob_size1; |
1255 | 1710 | ||
1256 | read_data_dma(nandc, reg_off, data_buf, data_size2); | 1711 | read_data_dma(nandc, reg_off, data_buf, data_size2, 0); |
1257 | reg_off += data_size2; | 1712 | reg_off += data_size2; |
1258 | data_buf += data_size2; | 1713 | data_buf += data_size2; |
1259 | 1714 | ||
1260 | read_data_dma(nandc, reg_off, oob_buf, oob_size2); | 1715 | read_data_dma(nandc, reg_off, oob_buf, oob_size2, 0); |
1261 | oob_buf += oob_size2; | 1716 | oob_buf += oob_size2; |
1262 | } | 1717 | } |
1263 | 1718 | ||
@@ -1280,6 +1735,7 @@ static int qcom_nandc_read_oob(struct mtd_info *mtd, struct nand_chip *chip, | |||
1280 | int ret; | 1735 | int ret; |
1281 | 1736 | ||
1282 | clear_read_regs(nandc); | 1737 | clear_read_regs(nandc); |
1738 | clear_bam_transaction(nandc); | ||
1283 | 1739 | ||
1284 | host->use_ecc = true; | 1740 | host->use_ecc = true; |
1285 | set_address(host, 0, page); | 1741 | set_address(host, 0, page); |
@@ -1303,12 +1759,14 @@ static int qcom_nandc_write_page(struct mtd_info *mtd, struct nand_chip *chip, | |||
1303 | int i, ret; | 1759 | int i, ret; |
1304 | 1760 | ||
1305 | clear_read_regs(nandc); | 1761 | clear_read_regs(nandc); |
1762 | clear_bam_transaction(nandc); | ||
1306 | 1763 | ||
1307 | data_buf = (u8 *)buf; | 1764 | data_buf = (u8 *)buf; |
1308 | oob_buf = chip->oob_poi; | 1765 | oob_buf = chip->oob_poi; |
1309 | 1766 | ||
1310 | host->use_ecc = true; | 1767 | host->use_ecc = true; |
1311 | update_rw_regs(host, ecc->steps, false); | 1768 | update_rw_regs(host, ecc->steps, false); |
1769 | config_nand_page_write(nandc); | ||
1312 | 1770 | ||
1313 | for (i = 0; i < ecc->steps; i++) { | 1771 | for (i = 0; i < ecc->steps; i++) { |
1314 | int data_size, oob_size; | 1772 | int data_size, oob_size; |
@@ -1322,9 +1780,9 @@ static int qcom_nandc_write_page(struct mtd_info *mtd, struct nand_chip *chip, | |||
1322 | oob_size = ecc->bytes; | 1780 | oob_size = ecc->bytes; |
1323 | } | 1781 | } |
1324 | 1782 | ||
1325 | config_cw_write_pre(nandc); | ||
1326 | 1783 | ||
1327 | write_data_dma(nandc, FLASH_BUF_ACC, data_buf, data_size); | 1784 | write_data_dma(nandc, FLASH_BUF_ACC, data_buf, data_size, |
1785 | i == (ecc->steps - 1) ? NAND_BAM_NO_EOT : 0); | ||
1328 | 1786 | ||
1329 | /* | 1787 | /* |
1330 | * when ECC is enabled, we don't really need to write anything | 1788 | * when ECC is enabled, we don't really need to write anything |
@@ -1337,10 +1795,10 @@ static int qcom_nandc_write_page(struct mtd_info *mtd, struct nand_chip *chip, | |||
1337 | oob_buf += host->bbm_size; | 1795 | oob_buf += host->bbm_size; |
1338 | 1796 | ||
1339 | write_data_dma(nandc, FLASH_BUF_ACC + data_size, | 1797 | write_data_dma(nandc, FLASH_BUF_ACC + data_size, |
1340 | oob_buf, oob_size); | 1798 | oob_buf, oob_size, 0); |
1341 | } | 1799 | } |
1342 | 1800 | ||
1343 | config_cw_write_post(nandc); | 1801 | config_nand_cw_write(nandc); |
1344 | 1802 | ||
1345 | data_buf += data_size; | 1803 | data_buf += data_size; |
1346 | oob_buf += oob_size; | 1804 | oob_buf += oob_size; |
@@ -1367,12 +1825,14 @@ static int qcom_nandc_write_page_raw(struct mtd_info *mtd, | |||
1367 | int i, ret; | 1825 | int i, ret; |
1368 | 1826 | ||
1369 | clear_read_regs(nandc); | 1827 | clear_read_regs(nandc); |
1828 | clear_bam_transaction(nandc); | ||
1370 | 1829 | ||
1371 | data_buf = (u8 *)buf; | 1830 | data_buf = (u8 *)buf; |
1372 | oob_buf = chip->oob_poi; | 1831 | oob_buf = chip->oob_poi; |
1373 | 1832 | ||
1374 | host->use_ecc = false; | 1833 | host->use_ecc = false; |
1375 | update_rw_regs(host, ecc->steps, false); | 1834 | update_rw_regs(host, ecc->steps, false); |
1835 | config_nand_page_write(nandc); | ||
1376 | 1836 | ||
1377 | for (i = 0; i < ecc->steps; i++) { | 1837 | for (i = 0; i < ecc->steps; i++) { |
1378 | int data_size1, data_size2, oob_size1, oob_size2; | 1838 | int data_size1, data_size2, oob_size1, oob_size2; |
@@ -1391,24 +1851,25 @@ static int qcom_nandc_write_page_raw(struct mtd_info *mtd, | |||
1391 | oob_size2 = host->ecc_bytes_hw + host->spare_bytes; | 1851 | oob_size2 = host->ecc_bytes_hw + host->spare_bytes; |
1392 | } | 1852 | } |
1393 | 1853 | ||
1394 | config_cw_write_pre(nandc); | 1854 | write_data_dma(nandc, reg_off, data_buf, data_size1, |
1395 | 1855 | NAND_BAM_NO_EOT); | |
1396 | write_data_dma(nandc, reg_off, data_buf, data_size1); | ||
1397 | reg_off += data_size1; | 1856 | reg_off += data_size1; |
1398 | data_buf += data_size1; | 1857 | data_buf += data_size1; |
1399 | 1858 | ||
1400 | write_data_dma(nandc, reg_off, oob_buf, oob_size1); | 1859 | write_data_dma(nandc, reg_off, oob_buf, oob_size1, |
1860 | NAND_BAM_NO_EOT); | ||
1401 | reg_off += oob_size1; | 1861 | reg_off += oob_size1; |
1402 | oob_buf += oob_size1; | 1862 | oob_buf += oob_size1; |
1403 | 1863 | ||
1404 | write_data_dma(nandc, reg_off, data_buf, data_size2); | 1864 | write_data_dma(nandc, reg_off, data_buf, data_size2, |
1865 | NAND_BAM_NO_EOT); | ||
1405 | reg_off += data_size2; | 1866 | reg_off += data_size2; |
1406 | data_buf += data_size2; | 1867 | data_buf += data_size2; |
1407 | 1868 | ||
1408 | write_data_dma(nandc, reg_off, oob_buf, oob_size2); | 1869 | write_data_dma(nandc, reg_off, oob_buf, oob_size2, 0); |
1409 | oob_buf += oob_size2; | 1870 | oob_buf += oob_size2; |
1410 | 1871 | ||
1411 | config_cw_write_post(nandc); | 1872 | config_nand_cw_write(nandc); |
1412 | } | 1873 | } |
1413 | 1874 | ||
1414 | ret = submit_descs(nandc); | 1875 | ret = submit_descs(nandc); |
@@ -1441,11 +1902,13 @@ static int qcom_nandc_write_oob(struct mtd_info *mtd, struct nand_chip *chip, | |||
1441 | 1902 | ||
1442 | host->use_ecc = true; | 1903 | host->use_ecc = true; |
1443 | 1904 | ||
1905 | clear_bam_transaction(nandc); | ||
1444 | ret = copy_last_cw(host, page); | 1906 | ret = copy_last_cw(host, page); |
1445 | if (ret) | 1907 | if (ret) |
1446 | return ret; | 1908 | return ret; |
1447 | 1909 | ||
1448 | clear_read_regs(nandc); | 1910 | clear_read_regs(nandc); |
1911 | clear_bam_transaction(nandc); | ||
1449 | 1912 | ||
1450 | /* calculate the data and oob size for the last codeword/step */ | 1913 | /* calculate the data and oob size for the last codeword/step */ |
1451 | data_size = ecc->size - ((ecc->steps - 1) << 2); | 1914 | data_size = ecc->size - ((ecc->steps - 1) << 2); |
@@ -1458,10 +1921,10 @@ static int qcom_nandc_write_oob(struct mtd_info *mtd, struct nand_chip *chip, | |||
1458 | set_address(host, host->cw_size * (ecc->steps - 1), page); | 1921 | set_address(host, host->cw_size * (ecc->steps - 1), page); |
1459 | update_rw_regs(host, 1, false); | 1922 | update_rw_regs(host, 1, false); |
1460 | 1923 | ||
1461 | config_cw_write_pre(nandc); | 1924 | config_nand_page_write(nandc); |
1462 | write_data_dma(nandc, FLASH_BUF_ACC, nandc->data_buffer, | 1925 | write_data_dma(nandc, FLASH_BUF_ACC, |
1463 | data_size + oob_size); | 1926 | nandc->data_buffer, data_size + oob_size, 0); |
1464 | config_cw_write_post(nandc); | 1927 | config_nand_cw_write(nandc); |
1465 | 1928 | ||
1466 | ret = submit_descs(nandc); | 1929 | ret = submit_descs(nandc); |
1467 | 1930 | ||
@@ -1498,6 +1961,7 @@ static int qcom_nandc_block_bad(struct mtd_info *mtd, loff_t ofs) | |||
1498 | */ | 1961 | */ |
1499 | host->use_ecc = false; | 1962 | host->use_ecc = false; |
1500 | 1963 | ||
1964 | clear_bam_transaction(nandc); | ||
1501 | ret = copy_last_cw(host, page); | 1965 | ret = copy_last_cw(host, page); |
1502 | if (ret) | 1966 | if (ret) |
1503 | goto err; | 1967 | goto err; |
@@ -1528,6 +1992,7 @@ static int qcom_nandc_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
1528 | int page, ret, status = 0; | 1992 | int page, ret, status = 0; |
1529 | 1993 | ||
1530 | clear_read_regs(nandc); | 1994 | clear_read_regs(nandc); |
1995 | clear_bam_transaction(nandc); | ||
1531 | 1996 | ||
1532 | /* | 1997 | /* |
1533 | * to mark the BBM as bad, we flash the entire last codeword with 0s. | 1998 | * to mark the BBM as bad, we flash the entire last codeword with 0s. |
@@ -1543,9 +2008,10 @@ static int qcom_nandc_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
1543 | set_address(host, host->cw_size * (ecc->steps - 1), page); | 2008 | set_address(host, host->cw_size * (ecc->steps - 1), page); |
1544 | update_rw_regs(host, 1, false); | 2009 | update_rw_regs(host, 1, false); |
1545 | 2010 | ||
1546 | config_cw_write_pre(nandc); | 2011 | config_nand_page_write(nandc); |
1547 | write_data_dma(nandc, FLASH_BUF_ACC, nandc->data_buffer, host->cw_size); | 2012 | write_data_dma(nandc, FLASH_BUF_ACC, |
1548 | config_cw_write_post(nandc); | 2013 | nandc->data_buffer, host->cw_size, 0); |
2014 | config_nand_cw_write(nandc); | ||
1549 | 2015 | ||
1550 | ret = submit_descs(nandc); | 2016 | ret = submit_descs(nandc); |
1551 | 2017 | ||
@@ -1794,7 +2260,7 @@ static int qcom_nand_host_setup(struct qcom_nand_host *host) | |||
1794 | * uses lesser bytes for ECC. If RS is used, the ECC bytes is | 2260 | * uses lesser bytes for ECC. If RS is used, the ECC bytes is |
1795 | * always 10 bytes | 2261 | * always 10 bytes |
1796 | */ | 2262 | */ |
1797 | if (nandc->ecc_modes & ECC_BCH_4BIT) { | 2263 | if (nandc->props->ecc_modes & ECC_BCH_4BIT) { |
1798 | /* BCH */ | 2264 | /* BCH */ |
1799 | host->bch_enabled = true; | 2265 | host->bch_enabled = true; |
1800 | ecc_mode = 0; | 2266 | ecc_mode = 0; |
@@ -1842,6 +2308,8 @@ static int qcom_nand_host_setup(struct qcom_nand_host *host) | |||
1842 | mtd_set_ooblayout(mtd, &qcom_nand_ooblayout_ops); | 2308 | mtd_set_ooblayout(mtd, &qcom_nand_ooblayout_ops); |
1843 | 2309 | ||
1844 | cwperpage = mtd->writesize / ecc->size; | 2310 | cwperpage = mtd->writesize / ecc->size; |
2311 | nandc->max_cwperpage = max_t(unsigned int, nandc->max_cwperpage, | ||
2312 | cwperpage); | ||
1845 | 2313 | ||
1846 | /* | 2314 | /* |
1847 | * DATA_UD_BYTES varies based on whether the read/write command protects | 2315 | * DATA_UD_BYTES varies based on whether the read/write command protects |
@@ -1893,7 +2361,7 @@ static int qcom_nand_host_setup(struct qcom_nand_host *host) | |||
1893 | | wide_bus << WIDE_FLASH | 2361 | | wide_bus << WIDE_FLASH |
1894 | | 1 << DEV0_CFG1_ECC_DISABLE; | 2362 | | 1 << DEV0_CFG1_ECC_DISABLE; |
1895 | 2363 | ||
1896 | host->ecc_bch_cfg = host->bch_enabled << ECC_CFG_ECC_DISABLE | 2364 | host->ecc_bch_cfg = !host->bch_enabled << ECC_CFG_ECC_DISABLE |
1897 | | 0 << ECC_SW_RESET | 2365 | | 0 << ECC_SW_RESET |
1898 | | host->cw_data << ECC_NUM_DATA_BYTES | 2366 | | host->cw_data << ECC_NUM_DATA_BYTES |
1899 | | 1 << ECC_FORCE_CLK_OPEN | 2367 | | 1 << ECC_FORCE_CLK_OPEN |
@@ -1904,6 +2372,10 @@ static int qcom_nand_host_setup(struct qcom_nand_host *host) | |||
1904 | 2372 | ||
1905 | host->clrflashstatus = FS_READY_BSY_N; | 2373 | host->clrflashstatus = FS_READY_BSY_N; |
1906 | host->clrreadstatus = 0xc0; | 2374 | host->clrreadstatus = 0xc0; |
2375 | nandc->regs->erased_cw_detect_cfg_clr = | ||
2376 | cpu_to_le32(CLR_ERASED_PAGE_DET); | ||
2377 | nandc->regs->erased_cw_detect_cfg_set = | ||
2378 | cpu_to_le32(SET_ERASED_PAGE_DET); | ||
1907 | 2379 | ||
1908 | dev_dbg(nandc->dev, | 2380 | dev_dbg(nandc->dev, |
1909 | "cfg0 %x cfg1 %x ecc_buf_cfg %x ecc_bch cfg %x cw_size %d cw_data %d strength %d parity_bytes %d steps %d\n", | 2381 | "cfg0 %x cfg1 %x ecc_buf_cfg %x ecc_bch cfg %x cw_size %d cw_data %d strength %d parity_bytes %d steps %d\n", |
@@ -1948,10 +2420,55 @@ static int qcom_nandc_alloc(struct qcom_nand_controller *nandc) | |||
1948 | if (!nandc->reg_read_buf) | 2420 | if (!nandc->reg_read_buf) |
1949 | return -ENOMEM; | 2421 | return -ENOMEM; |
1950 | 2422 | ||
1951 | nandc->chan = dma_request_slave_channel(nandc->dev, "rxtx"); | 2423 | if (nandc->props->is_bam) { |
1952 | if (!nandc->chan) { | 2424 | nandc->reg_read_dma = |
1953 | dev_err(nandc->dev, "failed to request slave channel\n"); | 2425 | dma_map_single(nandc->dev, nandc->reg_read_buf, |
1954 | return -ENODEV; | 2426 | MAX_REG_RD * |
2427 | sizeof(*nandc->reg_read_buf), | ||
2428 | DMA_FROM_DEVICE); | ||
2429 | if (dma_mapping_error(nandc->dev, nandc->reg_read_dma)) { | ||
2430 | dev_err(nandc->dev, "failed to DMA MAP reg buffer\n"); | ||
2431 | return -EIO; | ||
2432 | } | ||
2433 | |||
2434 | nandc->tx_chan = dma_request_slave_channel(nandc->dev, "tx"); | ||
2435 | if (!nandc->tx_chan) { | ||
2436 | dev_err(nandc->dev, "failed to request tx channel\n"); | ||
2437 | return -ENODEV; | ||
2438 | } | ||
2439 | |||
2440 | nandc->rx_chan = dma_request_slave_channel(nandc->dev, "rx"); | ||
2441 | if (!nandc->rx_chan) { | ||
2442 | dev_err(nandc->dev, "failed to request rx channel\n"); | ||
2443 | return -ENODEV; | ||
2444 | } | ||
2445 | |||
2446 | nandc->cmd_chan = dma_request_slave_channel(nandc->dev, "cmd"); | ||
2447 | if (!nandc->cmd_chan) { | ||
2448 | dev_err(nandc->dev, "failed to request cmd channel\n"); | ||
2449 | return -ENODEV; | ||
2450 | } | ||
2451 | |||
2452 | /* | ||
2453 | * Initially allocate BAM transaction to read ONFI param page. | ||
2454 | * After detecting all the devices, this BAM transaction will | ||
2455 | * be freed and the next BAM tranasction will be allocated with | ||
2456 | * maximum codeword size | ||
2457 | */ | ||
2458 | nandc->max_cwperpage = 1; | ||
2459 | nandc->bam_txn = alloc_bam_transaction(nandc); | ||
2460 | if (!nandc->bam_txn) { | ||
2461 | dev_err(nandc->dev, | ||
2462 | "failed to allocate bam transaction\n"); | ||
2463 | return -ENOMEM; | ||
2464 | } | ||
2465 | } else { | ||
2466 | nandc->chan = dma_request_slave_channel(nandc->dev, "rxtx"); | ||
2467 | if (!nandc->chan) { | ||
2468 | dev_err(nandc->dev, | ||
2469 | "failed to request slave channel\n"); | ||
2470 | return -ENODEV; | ||
2471 | } | ||
1955 | } | 2472 | } |
1956 | 2473 | ||
1957 | INIT_LIST_HEAD(&nandc->desc_list); | 2474 | INIT_LIST_HEAD(&nandc->desc_list); |
@@ -1964,21 +2481,48 @@ static int qcom_nandc_alloc(struct qcom_nand_controller *nandc) | |||
1964 | 2481 | ||
1965 | static void qcom_nandc_unalloc(struct qcom_nand_controller *nandc) | 2482 | static void qcom_nandc_unalloc(struct qcom_nand_controller *nandc) |
1966 | { | 2483 | { |
1967 | dma_release_channel(nandc->chan); | 2484 | if (nandc->props->is_bam) { |
2485 | if (!dma_mapping_error(nandc->dev, nandc->reg_read_dma)) | ||
2486 | dma_unmap_single(nandc->dev, nandc->reg_read_dma, | ||
2487 | MAX_REG_RD * | ||
2488 | sizeof(*nandc->reg_read_buf), | ||
2489 | DMA_FROM_DEVICE); | ||
2490 | |||
2491 | if (nandc->tx_chan) | ||
2492 | dma_release_channel(nandc->tx_chan); | ||
2493 | |||
2494 | if (nandc->rx_chan) | ||
2495 | dma_release_channel(nandc->rx_chan); | ||
2496 | |||
2497 | if (nandc->cmd_chan) | ||
2498 | dma_release_channel(nandc->cmd_chan); | ||
2499 | } else { | ||
2500 | if (nandc->chan) | ||
2501 | dma_release_channel(nandc->chan); | ||
2502 | } | ||
1968 | } | 2503 | } |
1969 | 2504 | ||
1970 | /* one time setup of a few nand controller registers */ | 2505 | /* one time setup of a few nand controller registers */ |
1971 | static int qcom_nandc_setup(struct qcom_nand_controller *nandc) | 2506 | static int qcom_nandc_setup(struct qcom_nand_controller *nandc) |
1972 | { | 2507 | { |
2508 | u32 nand_ctrl; | ||
2509 | |||
1973 | /* kill onenand */ | 2510 | /* kill onenand */ |
1974 | nandc_write(nandc, SFLASHC_BURST_CFG, 0); | 2511 | nandc_write(nandc, SFLASHC_BURST_CFG, 0); |
2512 | nandc_write(nandc, dev_cmd_reg_addr(nandc, NAND_DEV_CMD_VLD), | ||
2513 | NAND_DEV_CMD_VLD_VAL); | ||
1975 | 2514 | ||
1976 | /* enable ADM DMA */ | 2515 | /* enable ADM or BAM DMA */ |
1977 | nandc_write(nandc, NAND_FLASH_CHIP_SELECT, DM_EN); | 2516 | if (nandc->props->is_bam) { |
2517 | nand_ctrl = nandc_read(nandc, NAND_CTRL); | ||
2518 | nandc_write(nandc, NAND_CTRL, nand_ctrl | BAM_MODE_EN); | ||
2519 | } else { | ||
2520 | nandc_write(nandc, NAND_FLASH_CHIP_SELECT, DM_EN); | ||
2521 | } | ||
1978 | 2522 | ||
1979 | /* save the original values of these registers */ | 2523 | /* save the original values of these registers */ |
1980 | nandc->cmd1 = nandc_read(nandc, NAND_DEV_CMD1); | 2524 | nandc->cmd1 = nandc_read(nandc, dev_cmd_reg_addr(nandc, NAND_DEV_CMD1)); |
1981 | nandc->vld = nandc_read(nandc, NAND_DEV_CMD_VLD); | 2525 | nandc->vld = NAND_DEV_CMD_VLD_VAL; |
1982 | 2526 | ||
1983 | return 0; | 2527 | return 0; |
1984 | } | 2528 | } |
@@ -2034,14 +2578,77 @@ static int qcom_nand_host_init(struct qcom_nand_controller *nandc, | |||
2034 | return ret; | 2578 | return ret; |
2035 | 2579 | ||
2036 | ret = qcom_nand_host_setup(host); | 2580 | ret = qcom_nand_host_setup(host); |
2037 | if (ret) | 2581 | |
2038 | return ret; | 2582 | return ret; |
2583 | } | ||
2584 | |||
2585 | static int qcom_nand_mtd_register(struct qcom_nand_controller *nandc, | ||
2586 | struct qcom_nand_host *host, | ||
2587 | struct device_node *dn) | ||
2588 | { | ||
2589 | struct nand_chip *chip = &host->chip; | ||
2590 | struct mtd_info *mtd = nand_to_mtd(chip); | ||
2591 | int ret; | ||
2039 | 2592 | ||
2040 | ret = nand_scan_tail(mtd); | 2593 | ret = nand_scan_tail(mtd); |
2041 | if (ret) | 2594 | if (ret) |
2042 | return ret; | 2595 | return ret; |
2043 | 2596 | ||
2044 | return mtd_device_register(mtd, NULL, 0); | 2597 | ret = mtd_device_register(mtd, NULL, 0); |
2598 | if (ret) | ||
2599 | nand_cleanup(mtd_to_nand(mtd)); | ||
2600 | |||
2601 | return ret; | ||
2602 | } | ||
2603 | |||
2604 | static int qcom_probe_nand_devices(struct qcom_nand_controller *nandc) | ||
2605 | { | ||
2606 | struct device *dev = nandc->dev; | ||
2607 | struct device_node *dn = dev->of_node, *child; | ||
2608 | struct qcom_nand_host *host, *tmp; | ||
2609 | int ret; | ||
2610 | |||
2611 | for_each_available_child_of_node(dn, child) { | ||
2612 | host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL); | ||
2613 | if (!host) { | ||
2614 | of_node_put(child); | ||
2615 | return -ENOMEM; | ||
2616 | } | ||
2617 | |||
2618 | ret = qcom_nand_host_init(nandc, host, child); | ||
2619 | if (ret) { | ||
2620 | devm_kfree(dev, host); | ||
2621 | continue; | ||
2622 | } | ||
2623 | |||
2624 | list_add_tail(&host->node, &nandc->host_list); | ||
2625 | } | ||
2626 | |||
2627 | if (list_empty(&nandc->host_list)) | ||
2628 | return -ENODEV; | ||
2629 | |||
2630 | if (nandc->props->is_bam) { | ||
2631 | free_bam_transaction(nandc); | ||
2632 | nandc->bam_txn = alloc_bam_transaction(nandc); | ||
2633 | if (!nandc->bam_txn) { | ||
2634 | dev_err(nandc->dev, | ||
2635 | "failed to allocate bam transaction\n"); | ||
2636 | return -ENOMEM; | ||
2637 | } | ||
2638 | } | ||
2639 | |||
2640 | list_for_each_entry_safe(host, tmp, &nandc->host_list, node) { | ||
2641 | ret = qcom_nand_mtd_register(nandc, host, child); | ||
2642 | if (ret) { | ||
2643 | list_del(&host->node); | ||
2644 | devm_kfree(dev, host); | ||
2645 | } | ||
2646 | } | ||
2647 | |||
2648 | if (list_empty(&nandc->host_list)) | ||
2649 | return -ENODEV; | ||
2650 | |||
2651 | return 0; | ||
2045 | } | 2652 | } |
2046 | 2653 | ||
2047 | /* parse custom DT properties here */ | 2654 | /* parse custom DT properties here */ |
@@ -2051,16 +2658,20 @@ static int qcom_nandc_parse_dt(struct platform_device *pdev) | |||
2051 | struct device_node *np = nandc->dev->of_node; | 2658 | struct device_node *np = nandc->dev->of_node; |
2052 | int ret; | 2659 | int ret; |
2053 | 2660 | ||
2054 | ret = of_property_read_u32(np, "qcom,cmd-crci", &nandc->cmd_crci); | 2661 | if (!nandc->props->is_bam) { |
2055 | if (ret) { | 2662 | ret = of_property_read_u32(np, "qcom,cmd-crci", |
2056 | dev_err(nandc->dev, "command CRCI unspecified\n"); | 2663 | &nandc->cmd_crci); |
2057 | return ret; | 2664 | if (ret) { |
2058 | } | 2665 | dev_err(nandc->dev, "command CRCI unspecified\n"); |
2666 | return ret; | ||
2667 | } | ||
2059 | 2668 | ||
2060 | ret = of_property_read_u32(np, "qcom,data-crci", &nandc->data_crci); | 2669 | ret = of_property_read_u32(np, "qcom,data-crci", |
2061 | if (ret) { | 2670 | &nandc->data_crci); |
2062 | dev_err(nandc->dev, "data CRCI unspecified\n"); | 2671 | if (ret) { |
2063 | return ret; | 2672 | dev_err(nandc->dev, "data CRCI unspecified\n"); |
2673 | return ret; | ||
2674 | } | ||
2064 | } | 2675 | } |
2065 | 2676 | ||
2066 | return 0; | 2677 | return 0; |
@@ -2069,10 +2680,8 @@ static int qcom_nandc_parse_dt(struct platform_device *pdev) | |||
2069 | static int qcom_nandc_probe(struct platform_device *pdev) | 2680 | static int qcom_nandc_probe(struct platform_device *pdev) |
2070 | { | 2681 | { |
2071 | struct qcom_nand_controller *nandc; | 2682 | struct qcom_nand_controller *nandc; |
2072 | struct qcom_nand_host *host; | ||
2073 | const void *dev_data; | 2683 | const void *dev_data; |
2074 | struct device *dev = &pdev->dev; | 2684 | struct device *dev = &pdev->dev; |
2075 | struct device_node *dn = dev->of_node, *child; | ||
2076 | struct resource *res; | 2685 | struct resource *res; |
2077 | int ret; | 2686 | int ret; |
2078 | 2687 | ||
@@ -2089,7 +2698,7 @@ static int qcom_nandc_probe(struct platform_device *pdev) | |||
2089 | return -ENODEV; | 2698 | return -ENODEV; |
2090 | } | 2699 | } |
2091 | 2700 | ||
2092 | nandc->ecc_modes = (unsigned long)dev_data; | 2701 | nandc->props = dev_data; |
2093 | 2702 | ||
2094 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 2703 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
2095 | nandc->base = devm_ioremap_resource(dev, res); | 2704 | nandc->base = devm_ioremap_resource(dev, res); |
@@ -2112,7 +2721,7 @@ static int qcom_nandc_probe(struct platform_device *pdev) | |||
2112 | 2721 | ||
2113 | ret = qcom_nandc_alloc(nandc); | 2722 | ret = qcom_nandc_alloc(nandc); |
2114 | if (ret) | 2723 | if (ret) |
2115 | return ret; | 2724 | goto err_core_clk; |
2116 | 2725 | ||
2117 | ret = clk_prepare_enable(nandc->core_clk); | 2726 | ret = clk_prepare_enable(nandc->core_clk); |
2118 | if (ret) | 2727 | if (ret) |
@@ -2126,35 +2735,12 @@ static int qcom_nandc_probe(struct platform_device *pdev) | |||
2126 | if (ret) | 2735 | if (ret) |
2127 | goto err_setup; | 2736 | goto err_setup; |
2128 | 2737 | ||
2129 | for_each_available_child_of_node(dn, child) { | 2738 | ret = qcom_probe_nand_devices(nandc); |
2130 | if (of_device_is_compatible(child, "qcom,nandcs")) { | 2739 | if (ret) |
2131 | host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL); | 2740 | goto err_setup; |
2132 | if (!host) { | ||
2133 | of_node_put(child); | ||
2134 | ret = -ENOMEM; | ||
2135 | goto err_cs_init; | ||
2136 | } | ||
2137 | |||
2138 | ret = qcom_nand_host_init(nandc, host, child); | ||
2139 | if (ret) { | ||
2140 | devm_kfree(dev, host); | ||
2141 | continue; | ||
2142 | } | ||
2143 | |||
2144 | list_add_tail(&host->node, &nandc->host_list); | ||
2145 | } | ||
2146 | } | ||
2147 | |||
2148 | if (list_empty(&nandc->host_list)) { | ||
2149 | ret = -ENODEV; | ||
2150 | goto err_cs_init; | ||
2151 | } | ||
2152 | 2741 | ||
2153 | return 0; | 2742 | return 0; |
2154 | 2743 | ||
2155 | err_cs_init: | ||
2156 | list_for_each_entry(host, &nandc->host_list, node) | ||
2157 | nand_release(nand_to_mtd(&host->chip)); | ||
2158 | err_setup: | 2744 | err_setup: |
2159 | clk_disable_unprepare(nandc->aon_clk); | 2745 | clk_disable_unprepare(nandc->aon_clk); |
2160 | err_aon_clk: | 2746 | err_aon_clk: |
@@ -2181,15 +2767,40 @@ static int qcom_nandc_remove(struct platform_device *pdev) | |||
2181 | return 0; | 2767 | return 0; |
2182 | } | 2768 | } |
2183 | 2769 | ||
2184 | #define EBI2_NANDC_ECC_MODES (ECC_RS_4BIT | ECC_BCH_8BIT) | 2770 | static const struct qcom_nandc_props ipq806x_nandc_props = { |
2771 | .ecc_modes = (ECC_RS_4BIT | ECC_BCH_8BIT), | ||
2772 | .is_bam = false, | ||
2773 | .dev_cmd_reg_start = 0x0, | ||
2774 | }; | ||
2775 | |||
2776 | static const struct qcom_nandc_props ipq4019_nandc_props = { | ||
2777 | .ecc_modes = (ECC_BCH_4BIT | ECC_BCH_8BIT), | ||
2778 | .is_bam = true, | ||
2779 | .dev_cmd_reg_start = 0x0, | ||
2780 | }; | ||
2781 | |||
2782 | static const struct qcom_nandc_props ipq8074_nandc_props = { | ||
2783 | .ecc_modes = (ECC_BCH_4BIT | ECC_BCH_8BIT), | ||
2784 | .is_bam = true, | ||
2785 | .dev_cmd_reg_start = 0x7000, | ||
2786 | }; | ||
2185 | 2787 | ||
2186 | /* | 2788 | /* |
2187 | * data will hold a struct pointer containing more differences once we support | 2789 | * data will hold a struct pointer containing more differences once we support |
2188 | * more controller variants | 2790 | * more controller variants |
2189 | */ | 2791 | */ |
2190 | static const struct of_device_id qcom_nandc_of_match[] = { | 2792 | static const struct of_device_id qcom_nandc_of_match[] = { |
2191 | { .compatible = "qcom,ipq806x-nand", | 2793 | { |
2192 | .data = (void *)EBI2_NANDC_ECC_MODES, | 2794 | .compatible = "qcom,ipq806x-nand", |
2795 | .data = &ipq806x_nandc_props, | ||
2796 | }, | ||
2797 | { | ||
2798 | .compatible = "qcom,ipq4019-nand", | ||
2799 | .data = &ipq4019_nandc_props, | ||
2800 | }, | ||
2801 | { | ||
2802 | .compatible = "qcom,ipq8074-nand", | ||
2803 | .data = &ipq8074_nandc_props, | ||
2193 | }, | 2804 | }, |
2194 | {} | 2805 | {} |
2195 | }; | 2806 | }; |
diff --git a/drivers/mtd/nand/r852.h b/drivers/mtd/nand/r852.h index d042ddb71a8b..8713c57f6207 100644 --- a/drivers/mtd/nand/r852.h +++ b/drivers/mtd/nand/r852.h | |||
@@ -10,7 +10,7 @@ | |||
10 | #include <linux/pci.h> | 10 | #include <linux/pci.h> |
11 | #include <linux/completion.h> | 11 | #include <linux/completion.h> |
12 | #include <linux/workqueue.h> | 12 | #include <linux/workqueue.h> |
13 | #include <linux/mtd/nand.h> | 13 | #include <linux/mtd/rawnand.h> |
14 | #include <linux/spinlock.h> | 14 | #include <linux/spinlock.h> |
15 | 15 | ||
16 | 16 | ||
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c index 9e0c849607b9..4c383eeec6f6 100644 --- a/drivers/mtd/nand/s3c2410.c +++ b/drivers/mtd/nand/s3c2410.c | |||
@@ -43,7 +43,7 @@ | |||
43 | #include <linux/of_device.h> | 43 | #include <linux/of_device.h> |
44 | 44 | ||
45 | #include <linux/mtd/mtd.h> | 45 | #include <linux/mtd/mtd.h> |
46 | #include <linux/mtd/nand.h> | 46 | #include <linux/mtd/rawnand.h> |
47 | #include <linux/mtd/nand_ecc.h> | 47 | #include <linux/mtd/nand_ecc.h> |
48 | #include <linux/mtd/partitions.h> | 48 | #include <linux/mtd/partitions.h> |
49 | 49 | ||
diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c index 891ac7b99305..e7f3c98487e6 100644 --- a/drivers/mtd/nand/sh_flctl.c +++ b/drivers/mtd/nand/sh_flctl.c | |||
@@ -38,7 +38,7 @@ | |||
38 | #include <linux/string.h> | 38 | #include <linux/string.h> |
39 | 39 | ||
40 | #include <linux/mtd/mtd.h> | 40 | #include <linux/mtd/mtd.h> |
41 | #include <linux/mtd/nand.h> | 41 | #include <linux/mtd/rawnand.h> |
42 | #include <linux/mtd/partitions.h> | 42 | #include <linux/mtd/partitions.h> |
43 | #include <linux/mtd/sh_flctl.h> | 43 | #include <linux/mtd/sh_flctl.h> |
44 | 44 | ||
@@ -411,7 +411,7 @@ static int flctl_dma_fifo0_transfer(struct sh_flctl *flctl, unsigned long *buf, | |||
411 | 411 | ||
412 | dma_addr = dma_map_single(chan->device->dev, buf, len, dir); | 412 | dma_addr = dma_map_single(chan->device->dev, buf, len, dir); |
413 | 413 | ||
414 | if (dma_addr) | 414 | if (!dma_mapping_error(chan->device->dev, dma_addr)) |
415 | desc = dmaengine_prep_slave_single(chan, dma_addr, len, | 415 | desc = dmaengine_prep_slave_single(chan, dma_addr, len, |
416 | tr_dir, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); | 416 | tr_dir, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
417 | 417 | ||
@@ -1141,8 +1141,8 @@ static int flctl_probe(struct platform_device *pdev) | |||
1141 | 1141 | ||
1142 | irq = platform_get_irq(pdev, 0); | 1142 | irq = platform_get_irq(pdev, 0); |
1143 | if (irq < 0) { | 1143 | if (irq < 0) { |
1144 | dev_err(&pdev->dev, "failed to get flste irq data\n"); | 1144 | dev_err(&pdev->dev, "failed to get flste irq data: %d\n", irq); |
1145 | return -ENXIO; | 1145 | return irq; |
1146 | } | 1146 | } |
1147 | 1147 | ||
1148 | ret = devm_request_irq(&pdev->dev, irq, flctl_handle_flste, IRQF_SHARED, | 1148 | ret = devm_request_irq(&pdev->dev, irq, flctl_handle_flste, IRQF_SHARED, |
diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c index 064ca1757589..f59c455d9f51 100644 --- a/drivers/mtd/nand/sharpsl.c +++ b/drivers/mtd/nand/sharpsl.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
19 | #include <linux/mtd/mtd.h> | 19 | #include <linux/mtd/mtd.h> |
20 | #include <linux/mtd/nand.h> | 20 | #include <linux/mtd/rawnand.h> |
21 | #include <linux/mtd/nand_ecc.h> | 21 | #include <linux/mtd/nand_ecc.h> |
22 | #include <linux/mtd/partitions.h> | 22 | #include <linux/mtd/partitions.h> |
23 | #include <linux/mtd/sharpsl.h> | 23 | #include <linux/mtd/sharpsl.h> |
@@ -183,7 +183,7 @@ static int sharpsl_nand_probe(struct platform_device *pdev) | |||
183 | /* Register the partitions */ | 183 | /* Register the partitions */ |
184 | mtd->name = "sharpsl-nand"; | 184 | mtd->name = "sharpsl-nand"; |
185 | 185 | ||
186 | err = mtd_device_parse_register(mtd, NULL, NULL, | 186 | err = mtd_device_parse_register(mtd, data->part_parsers, NULL, |
187 | data->partitions, data->nr_partitions); | 187 | data->partitions, data->nr_partitions); |
188 | if (err) | 188 | if (err) |
189 | goto err_add; | 189 | goto err_add; |
diff --git a/drivers/mtd/nand/sm_common.c b/drivers/mtd/nand/sm_common.c index 5939dff253c2..c378705c6e2b 100644 --- a/drivers/mtd/nand/sm_common.c +++ b/drivers/mtd/nand/sm_common.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
8 | */ | 8 | */ |
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
10 | #include <linux/mtd/nand.h> | 10 | #include <linux/mtd/rawnand.h> |
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/sizes.h> | 12 | #include <linux/sizes.h> |
13 | #include "sm_common.h" | 13 | #include "sm_common.h" |
diff --git a/drivers/mtd/nand/socrates_nand.c b/drivers/mtd/nand/socrates_nand.c index 72369bd079af..575997d0ef8a 100644 --- a/drivers/mtd/nand/socrates_nand.c +++ b/drivers/mtd/nand/socrates_nand.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/mtd/mtd.h> | 15 | #include <linux/mtd/mtd.h> |
16 | #include <linux/mtd/nand.h> | 16 | #include <linux/mtd/rawnand.h> |
17 | #include <linux/mtd/partitions.h> | 17 | #include <linux/mtd/partitions.h> |
18 | #include <linux/of_address.h> | 18 | #include <linux/of_address.h> |
19 | #include <linux/of_platform.h> | 19 | #include <linux/of_platform.h> |
diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c index 6abd142b1324..82244be3e766 100644 --- a/drivers/mtd/nand/sunxi_nand.c +++ b/drivers/mtd/nand/sunxi_nand.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include <linux/of_device.h> | 31 | #include <linux/of_device.h> |
32 | #include <linux/of_gpio.h> | 32 | #include <linux/of_gpio.h> |
33 | #include <linux/mtd/mtd.h> | 33 | #include <linux/mtd/mtd.h> |
34 | #include <linux/mtd/nand.h> | 34 | #include <linux/mtd/rawnand.h> |
35 | #include <linux/mtd/partitions.h> | 35 | #include <linux/mtd/partitions.h> |
36 | #include <linux/clk.h> | 36 | #include <linux/clk.h> |
37 | #include <linux/delay.h> | 37 | #include <linux/delay.h> |
@@ -2212,7 +2212,7 @@ static int sunxi_nfc_probe(struct platform_device *pdev) | |||
2212 | if (ret) | 2212 | if (ret) |
2213 | goto out_ahb_clk_unprepare; | 2213 | goto out_ahb_clk_unprepare; |
2214 | 2214 | ||
2215 | nfc->reset = devm_reset_control_get_optional(dev, "ahb"); | 2215 | nfc->reset = devm_reset_control_get_optional_exclusive(dev, "ahb"); |
2216 | if (IS_ERR(nfc->reset)) { | 2216 | if (IS_ERR(nfc->reset)) { |
2217 | ret = PTR_ERR(nfc->reset); | 2217 | ret = PTR_ERR(nfc->reset); |
2218 | goto out_mod_clk_unprepare; | 2218 | goto out_mod_clk_unprepare; |
diff --git a/drivers/mtd/nand/tango_nand.c b/drivers/mtd/nand/tango_nand.c index 9d40b793b1c4..766906f03943 100644 --- a/drivers/mtd/nand/tango_nand.c +++ b/drivers/mtd/nand/tango_nand.c | |||
@@ -11,7 +11,7 @@ | |||
11 | #include <linux/clk.h> | 11 | #include <linux/clk.h> |
12 | #include <linux/iopoll.h> | 12 | #include <linux/iopoll.h> |
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/mtd/nand.h> | 14 | #include <linux/mtd/rawnand.h> |
15 | #include <linux/dmaengine.h> | 15 | #include <linux/dmaengine.h> |
16 | #include <linux/dma-mapping.h> | 16 | #include <linux/dma-mapping.h> |
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
diff --git a/drivers/mtd/nand/tmio_nand.c b/drivers/mtd/nand/tmio_nand.c index fc5e773f8b60..84dbf32332e1 100644 --- a/drivers/mtd/nand/tmio_nand.c +++ b/drivers/mtd/nand/tmio_nand.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #include <linux/interrupt.h> | 34 | #include <linux/interrupt.h> |
35 | #include <linux/ioport.h> | 35 | #include <linux/ioport.h> |
36 | #include <linux/mtd/mtd.h> | 36 | #include <linux/mtd/mtd.h> |
37 | #include <linux/mtd/nand.h> | 37 | #include <linux/mtd/rawnand.h> |
38 | #include <linux/mtd/nand_ecc.h> | 38 | #include <linux/mtd/nand_ecc.h> |
39 | #include <linux/mtd/partitions.h> | 39 | #include <linux/mtd/partitions.h> |
40 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
@@ -440,7 +440,9 @@ static int tmio_probe(struct platform_device *dev) | |||
440 | goto err_irq; | 440 | goto err_irq; |
441 | 441 | ||
442 | /* Register the partitions */ | 442 | /* Register the partitions */ |
443 | retval = mtd_device_parse_register(mtd, NULL, NULL, | 443 | retval = mtd_device_parse_register(mtd, |
444 | data ? data->part_parsers : NULL, | ||
445 | NULL, | ||
444 | data ? data->partition : NULL, | 446 | data ? data->partition : NULL, |
445 | data ? data->num_partitions : 0); | 447 | data ? data->num_partitions : 0); |
446 | if (!retval) | 448 | if (!retval) |
diff --git a/drivers/mtd/nand/txx9ndfmc.c b/drivers/mtd/nand/txx9ndfmc.c index 0a14fda2e41b..b567d212fe7d 100644 --- a/drivers/mtd/nand/txx9ndfmc.c +++ b/drivers/mtd/nand/txx9ndfmc.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
18 | #include <linux/mtd/mtd.h> | 18 | #include <linux/mtd/mtd.h> |
19 | #include <linux/mtd/nand.h> | 19 | #include <linux/mtd/rawnand.h> |
20 | #include <linux/mtd/nand_ecc.h> | 20 | #include <linux/mtd/nand_ecc.h> |
21 | #include <linux/mtd/partitions.h> | 21 | #include <linux/mtd/partitions.h> |
22 | #include <linux/io.h> | 22 | #include <linux/io.h> |
diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c index 744ab10e8962..8037d4b48a05 100644 --- a/drivers/mtd/nand/vf610_nfc.c +++ b/drivers/mtd/nand/vf610_nfc.c | |||
@@ -31,10 +31,9 @@ | |||
31 | #include <linux/interrupt.h> | 31 | #include <linux/interrupt.h> |
32 | #include <linux/io.h> | 32 | #include <linux/io.h> |
33 | #include <linux/mtd/mtd.h> | 33 | #include <linux/mtd/mtd.h> |
34 | #include <linux/mtd/nand.h> | 34 | #include <linux/mtd/rawnand.h> |
35 | #include <linux/mtd/partitions.h> | 35 | #include <linux/mtd/partitions.h> |
36 | #include <linux/of_device.h> | 36 | #include <linux/of_device.h> |
37 | #include <linux/pinctrl/consumer.h> | ||
38 | #include <linux/platform_device.h> | 37 | #include <linux/platform_device.h> |
39 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
40 | 39 | ||
@@ -814,12 +813,14 @@ static int vf610_nfc_suspend(struct device *dev) | |||
814 | 813 | ||
815 | static int vf610_nfc_resume(struct device *dev) | 814 | static int vf610_nfc_resume(struct device *dev) |
816 | { | 815 | { |
816 | int err; | ||
817 | |||
817 | struct mtd_info *mtd = dev_get_drvdata(dev); | 818 | struct mtd_info *mtd = dev_get_drvdata(dev); |
818 | struct vf610_nfc *nfc = mtd_to_nfc(mtd); | 819 | struct vf610_nfc *nfc = mtd_to_nfc(mtd); |
819 | 820 | ||
820 | pinctrl_pm_select_default_state(dev); | 821 | err = clk_prepare_enable(nfc->clk); |
821 | 822 | if (err) | |
822 | clk_prepare_enable(nfc->clk); | 823 | return err; |
823 | 824 | ||
824 | vf610_nfc_preinit_controller(nfc); | 825 | vf610_nfc_preinit_controller(nfc); |
825 | vf610_nfc_init_controller(nfc); | 826 | vf610_nfc_init_controller(nfc); |
diff --git a/drivers/mtd/nand/xway_nand.c b/drivers/mtd/nand/xway_nand.c index ddee4005248c..9926b4e3d69d 100644 --- a/drivers/mtd/nand/xway_nand.c +++ b/drivers/mtd/nand/xway_nand.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * Copyright © 2016 Hauke Mehrtens <hauke@hauke-m.de> | 7 | * Copyright © 2016 Hauke Mehrtens <hauke@hauke-m.de> |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <linux/mtd/nand.h> | 10 | #include <linux/mtd/rawnand.h> |
11 | #include <linux/of_gpio.h> | 11 | #include <linux/of_gpio.h> |
12 | #include <linux/of_platform.h> | 12 | #include <linux/of_platform.h> |
13 | 13 | ||
diff --git a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c index e21161353e76..1f1a61168b3d 100644 --- a/drivers/mtd/nftlcore.c +++ b/drivers/mtd/nftlcore.c | |||
@@ -34,7 +34,7 @@ | |||
34 | 34 | ||
35 | #include <linux/kmod.h> | 35 | #include <linux/kmod.h> |
36 | #include <linux/mtd/mtd.h> | 36 | #include <linux/mtd/mtd.h> |
37 | #include <linux/mtd/nand.h> | 37 | #include <linux/mtd/rawnand.h> |
38 | #include <linux/mtd/nftl.h> | 38 | #include <linux/mtd/nftl.h> |
39 | #include <linux/mtd/blktrans.h> | 39 | #include <linux/mtd/blktrans.h> |
40 | 40 | ||
diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c index a5dfbfbebfca..184c8fbfe465 100644 --- a/drivers/mtd/nftlmount.c +++ b/drivers/mtd/nftlmount.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/delay.h> | 25 | #include <linux/delay.h> |
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | #include <linux/mtd/mtd.h> | 27 | #include <linux/mtd/mtd.h> |
28 | #include <linux/mtd/nand.h> | 28 | #include <linux/mtd/rawnand.h> |
29 | #include <linux/mtd/nftl.h> | 29 | #include <linux/mtd/nftl.h> |
30 | 30 | ||
31 | #define SECTORSIZE 512 | 31 | #define SECTORSIZE 512 |
diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c index 2861c7079d7b..6bdf4e525677 100644 --- a/drivers/mtd/ofpart.c +++ b/drivers/mtd/ofpart.c | |||
@@ -50,8 +50,8 @@ static int parse_ofpart_partitions(struct mtd_info *master, | |||
50 | * when using another parser), so don't be louder than | 50 | * when using another parser), so don't be louder than |
51 | * KERN_DEBUG | 51 | * KERN_DEBUG |
52 | */ | 52 | */ |
53 | pr_debug("%s: 'partitions' subnode not found on %s. Trying to parse direct subnodes as partitions.\n", | 53 | pr_debug("%s: 'partitions' subnode not found on %pOF. Trying to parse direct subnodes as partitions.\n", |
54 | master->name, mtd_node->full_name); | 54 | master->name, mtd_node); |
55 | ofpart_node = mtd_node; | 55 | ofpart_node = mtd_node; |
56 | dedicated = false; | 56 | dedicated = false; |
57 | } else if (!of_device_is_compatible(ofpart_node, "fixed-partitions")) { | 57 | } else if (!of_device_is_compatible(ofpart_node, "fixed-partitions")) { |
@@ -87,9 +87,9 @@ static int parse_ofpart_partitions(struct mtd_info *master, | |||
87 | reg = of_get_property(pp, "reg", &len); | 87 | reg = of_get_property(pp, "reg", &len); |
88 | if (!reg) { | 88 | if (!reg) { |
89 | if (dedicated) { | 89 | if (dedicated) { |
90 | pr_debug("%s: ofpart partition %s (%s) missing reg property.\n", | 90 | pr_debug("%s: ofpart partition %pOF (%pOF) missing reg property.\n", |
91 | master->name, pp->full_name, | 91 | master->name, pp, |
92 | mtd_node->full_name); | 92 | mtd_node); |
93 | goto ofpart_fail; | 93 | goto ofpart_fail; |
94 | } else { | 94 | } else { |
95 | nr_parts--; | 95 | nr_parts--; |
@@ -100,9 +100,9 @@ static int parse_ofpart_partitions(struct mtd_info *master, | |||
100 | a_cells = of_n_addr_cells(pp); | 100 | a_cells = of_n_addr_cells(pp); |
101 | s_cells = of_n_size_cells(pp); | 101 | s_cells = of_n_size_cells(pp); |
102 | if (len / 4 != a_cells + s_cells) { | 102 | if (len / 4 != a_cells + s_cells) { |
103 | pr_debug("%s: ofpart partition %s (%s) error parsing reg property.\n", | 103 | pr_debug("%s: ofpart partition %pOF (%pOF) error parsing reg property.\n", |
104 | master->name, pp->full_name, | 104 | master->name, pp, |
105 | mtd_node->full_name); | 105 | mtd_node); |
106 | goto ofpart_fail; | 106 | goto ofpart_fail; |
107 | } | 107 | } |
108 | 108 | ||
@@ -131,8 +131,8 @@ static int parse_ofpart_partitions(struct mtd_info *master, | |||
131 | return nr_parts; | 131 | return nr_parts; |
132 | 132 | ||
133 | ofpart_fail: | 133 | ofpart_fail: |
134 | pr_err("%s: error parsing ofpart partition %s (%s)\n", | 134 | pr_err("%s: error parsing ofpart partition %pOF (%pOF)\n", |
135 | master->name, pp->full_name, mtd_node->full_name); | 135 | master->name, pp, mtd_node); |
136 | ret = -EINVAL; | 136 | ret = -EINVAL; |
137 | ofpart_none: | 137 | ofpart_none: |
138 | of_node_put(pp); | 138 | of_node_put(pp); |
@@ -166,8 +166,7 @@ static int parse_ofoldpart_partitions(struct mtd_info *master, | |||
166 | if (!part) | 166 | if (!part) |
167 | return 0; /* No partitions found */ | 167 | return 0; /* No partitions found */ |
168 | 168 | ||
169 | pr_warn("Device tree uses obsolete partition map binding: %s\n", | 169 | pr_warn("Device tree uses obsolete partition map binding: %pOF\n", dp); |
170 | dp->full_name); | ||
171 | 170 | ||
172 | nr_parts = plen / sizeof(part[0]); | 171 | nr_parts = plen / sizeof(part[0]); |
173 | 172 | ||
diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig index 293c8a4d1e49..69c638dd0484 100644 --- a/drivers/mtd/spi-nor/Kconfig +++ b/drivers/mtd/spi-nor/Kconfig | |||
@@ -89,6 +89,22 @@ config SPI_NXP_SPIFI | |||
89 | config SPI_INTEL_SPI | 89 | config SPI_INTEL_SPI |
90 | tristate | 90 | tristate |
91 | 91 | ||
92 | config SPI_INTEL_SPI_PCI | ||
93 | tristate "Intel PCH/PCU SPI flash PCI driver" if EXPERT | ||
94 | depends on X86 && PCI | ||
95 | select SPI_INTEL_SPI | ||
96 | help | ||
97 | This enables PCI support for the Intel PCH/PCU SPI controller in | ||
98 | master mode. This controller is present in modern Intel hardware | ||
99 | and is used to hold BIOS and other persistent settings. Using | ||
100 | this driver it is possible to upgrade BIOS directly from Linux. | ||
101 | |||
102 | Say N here unless you know what you are doing. Overwriting the | ||
103 | SPI flash may render the system unbootable. | ||
104 | |||
105 | To compile this driver as a module, choose M here: the module | ||
106 | will be called intel-spi-pci. | ||
107 | |||
92 | config SPI_INTEL_SPI_PLATFORM | 108 | config SPI_INTEL_SPI_PLATFORM |
93 | tristate "Intel PCH/PCU SPI flash platform driver" if EXPERT | 109 | tristate "Intel PCH/PCU SPI flash platform driver" if EXPERT |
94 | depends on X86 | 110 | depends on X86 |
diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile index 285aab86c7ca..7d84c5108e17 100644 --- a/drivers/mtd/spi-nor/Makefile +++ b/drivers/mtd/spi-nor/Makefile | |||
@@ -7,5 +7,6 @@ obj-$(CONFIG_SPI_HISI_SFC) += hisi-sfc.o | |||
7 | obj-$(CONFIG_MTD_MT81xx_NOR) += mtk-quadspi.o | 7 | obj-$(CONFIG_MTD_MT81xx_NOR) += mtk-quadspi.o |
8 | obj-$(CONFIG_SPI_NXP_SPIFI) += nxp-spifi.o | 8 | obj-$(CONFIG_SPI_NXP_SPIFI) += nxp-spifi.o |
9 | obj-$(CONFIG_SPI_INTEL_SPI) += intel-spi.o | 9 | obj-$(CONFIG_SPI_INTEL_SPI) += intel-spi.o |
10 | obj-$(CONFIG_SPI_INTEL_SPI_PCI) += intel-spi-pci.o | ||
10 | obj-$(CONFIG_SPI_INTEL_SPI_PLATFORM) += intel-spi-platform.o | 11 | obj-$(CONFIG_SPI_INTEL_SPI_PLATFORM) += intel-spi-platform.o |
11 | obj-$(CONFIG_SPI_STM32_QUADSPI) += stm32-quadspi.o \ No newline at end of file | 12 | obj-$(CONFIG_SPI_STM32_QUADSPI) += stm32-quadspi.o |
diff --git a/drivers/mtd/spi-nor/aspeed-smc.c b/drivers/mtd/spi-nor/aspeed-smc.c index 0106357421bd..8d3cbe27efb6 100644 --- a/drivers/mtd/spi-nor/aspeed-smc.c +++ b/drivers/mtd/spi-nor/aspeed-smc.c | |||
@@ -621,19 +621,18 @@ static void aspeed_smc_chip_set_type(struct aspeed_smc_chip *chip, int type) | |||
621 | } | 621 | } |
622 | 622 | ||
623 | /* | 623 | /* |
624 | * The AST2500 FMC flash controller should be strapped by hardware, or | 624 | * The first chip of the AST2500 FMC flash controller is strapped by |
625 | * autodetected, but the AST2500 SPI flash needs to be set. | 625 | * hardware, or autodetected, but other chips need to be set. Enforce |
626 | * the 4B setting for all chips. | ||
626 | */ | 627 | */ |
627 | static void aspeed_smc_chip_set_4b(struct aspeed_smc_chip *chip) | 628 | static void aspeed_smc_chip_set_4b(struct aspeed_smc_chip *chip) |
628 | { | 629 | { |
629 | struct aspeed_smc_controller *controller = chip->controller; | 630 | struct aspeed_smc_controller *controller = chip->controller; |
630 | u32 reg; | 631 | u32 reg; |
631 | 632 | ||
632 | if (chip->controller->info == &spi_2500_info) { | 633 | reg = readl(controller->regs + CE_CONTROL_REG); |
633 | reg = readl(controller->regs + CE_CONTROL_REG); | 634 | reg |= 1 << chip->cs; |
634 | reg |= 1 << chip->cs; | 635 | writel(reg, controller->regs + CE_CONTROL_REG); |
635 | writel(reg, controller->regs + CE_CONTROL_REG); | ||
636 | } | ||
637 | } | 636 | } |
638 | 637 | ||
639 | /* | 638 | /* |
diff --git a/drivers/mtd/spi-nor/atmel-quadspi.c b/drivers/mtd/spi-nor/atmel-quadspi.c index ba76fa8f2031..6c5708bacad8 100644 --- a/drivers/mtd/spi-nor/atmel-quadspi.c +++ b/drivers/mtd/spi-nor/atmel-quadspi.c | |||
@@ -35,7 +35,6 @@ | |||
35 | 35 | ||
36 | #include <linux/io.h> | 36 | #include <linux/io.h> |
37 | #include <linux/gpio.h> | 37 | #include <linux/gpio.h> |
38 | #include <linux/pinctrl/consumer.h> | ||
39 | 38 | ||
40 | /* QSPI register offsets */ | 39 | /* QSPI register offsets */ |
41 | #define QSPI_CR 0x0000 /* Control Register */ | 40 | #define QSPI_CR 0x0000 /* Control Register */ |
diff --git a/drivers/mtd/spi-nor/hisi-sfc.c b/drivers/mtd/spi-nor/hisi-sfc.c index d1106832b9d5..04f9fb5cd9b6 100644 --- a/drivers/mtd/spi-nor/hisi-sfc.c +++ b/drivers/mtd/spi-nor/hisi-sfc.c | |||
@@ -355,16 +355,16 @@ static int hisi_spi_nor_register(struct device_node *np, | |||
355 | 355 | ||
356 | ret = of_property_read_u32(np, "reg", &priv->chipselect); | 356 | ret = of_property_read_u32(np, "reg", &priv->chipselect); |
357 | if (ret) { | 357 | if (ret) { |
358 | dev_err(dev, "There's no reg property for %s\n", | 358 | dev_err(dev, "There's no reg property for %pOF\n", |
359 | np->full_name); | 359 | np); |
360 | return ret; | 360 | return ret; |
361 | } | 361 | } |
362 | 362 | ||
363 | ret = of_property_read_u32(np, "spi-max-frequency", | 363 | ret = of_property_read_u32(np, "spi-max-frequency", |
364 | &priv->clkrate); | 364 | &priv->clkrate); |
365 | if (ret) { | 365 | if (ret) { |
366 | dev_err(dev, "There's no spi-max-frequency property for %s\n", | 366 | dev_err(dev, "There's no spi-max-frequency property for %pOF\n", |
367 | np->full_name); | 367 | np); |
368 | return ret; | 368 | return ret; |
369 | } | 369 | } |
370 | priv->host = host; | 370 | priv->host = host; |
diff --git a/drivers/mtd/spi-nor/intel-spi-pci.c b/drivers/mtd/spi-nor/intel-spi-pci.c new file mode 100644 index 000000000000..e82652335ede --- /dev/null +++ b/drivers/mtd/spi-nor/intel-spi-pci.c | |||
@@ -0,0 +1,82 @@ | |||
1 | /* | ||
2 | * Intel PCH/PCU SPI flash PCI driver. | ||
3 | * | ||
4 | * Copyright (C) 2016, Intel Corporation | ||
5 | * Author: Mika Westerberg <mika.westerberg@linux.intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/ioport.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/pci.h> | ||
16 | |||
17 | #include "intel-spi.h" | ||
18 | |||
19 | #define BCR 0xdc | ||
20 | #define BCR_WPD BIT(0) | ||
21 | |||
22 | static const struct intel_spi_boardinfo bxt_info = { | ||
23 | .type = INTEL_SPI_BXT, | ||
24 | }; | ||
25 | |||
26 | static int intel_spi_pci_probe(struct pci_dev *pdev, | ||
27 | const struct pci_device_id *id) | ||
28 | { | ||
29 | struct intel_spi_boardinfo *info; | ||
30 | struct intel_spi *ispi; | ||
31 | u32 bcr; | ||
32 | int ret; | ||
33 | |||
34 | ret = pcim_enable_device(pdev); | ||
35 | if (ret) | ||
36 | return ret; | ||
37 | |||
38 | info = devm_kmemdup(&pdev->dev, (void *)id->driver_data, sizeof(*info), | ||
39 | GFP_KERNEL); | ||
40 | if (!info) | ||
41 | return -ENOMEM; | ||
42 | |||
43 | /* Try to make the chip read/write */ | ||
44 | pci_read_config_dword(pdev, BCR, &bcr); | ||
45 | if (!(bcr & BCR_WPD)) { | ||
46 | bcr |= BCR_WPD; | ||
47 | pci_write_config_dword(pdev, BCR, bcr); | ||
48 | pci_read_config_dword(pdev, BCR, &bcr); | ||
49 | } | ||
50 | info->writeable = !!(bcr & BCR_WPD); | ||
51 | |||
52 | ispi = intel_spi_probe(&pdev->dev, &pdev->resource[0], info); | ||
53 | if (IS_ERR(ispi)) | ||
54 | return PTR_ERR(ispi); | ||
55 | |||
56 | pci_set_drvdata(pdev, ispi); | ||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | static void intel_spi_pci_remove(struct pci_dev *pdev) | ||
61 | { | ||
62 | intel_spi_remove(pci_get_drvdata(pdev)); | ||
63 | } | ||
64 | |||
65 | static const struct pci_device_id intel_spi_pci_ids[] = { | ||
66 | { PCI_VDEVICE(INTEL, 0x19e0), (unsigned long)&bxt_info }, | ||
67 | { }, | ||
68 | }; | ||
69 | MODULE_DEVICE_TABLE(pci, intel_spi_pci_ids); | ||
70 | |||
71 | static struct pci_driver intel_spi_pci_driver = { | ||
72 | .name = "intel-spi", | ||
73 | .id_table = intel_spi_pci_ids, | ||
74 | .probe = intel_spi_pci_probe, | ||
75 | .remove = intel_spi_pci_remove, | ||
76 | }; | ||
77 | |||
78 | module_pci_driver(intel_spi_pci_driver); | ||
79 | |||
80 | MODULE_DESCRIPTION("Intel PCH/PCU SPI flash PCI driver"); | ||
81 | MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>"); | ||
82 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/mtd/spi-nor/mtk-quadspi.c b/drivers/mtd/spi-nor/mtk-quadspi.c index 8a20ec4991c8..c258c7adf1c5 100644 --- a/drivers/mtd/spi-nor/mtk-quadspi.c +++ b/drivers/mtd/spi-nor/mtk-quadspi.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <linux/mutex.h> | 24 | #include <linux/mutex.h> |
25 | #include <linux/of.h> | 25 | #include <linux/of.h> |
26 | #include <linux/of_device.h> | 26 | #include <linux/of_device.h> |
27 | #include <linux/pinctrl/consumer.h> | ||
28 | #include <linux/platform_device.h> | 27 | #include <linux/platform_device.h> |
29 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
30 | #include <linux/mtd/mtd.h> | 29 | #include <linux/mtd/mtd.h> |
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 1413828ff1fb..cf1d4a15e10a 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/mutex.h> | 17 | #include <linux/mutex.h> |
18 | #include <linux/math64.h> | 18 | #include <linux/math64.h> |
19 | #include <linux/sizes.h> | 19 | #include <linux/sizes.h> |
20 | #include <linux/slab.h> | ||
20 | 21 | ||
21 | #include <linux/mtd/mtd.h> | 22 | #include <linux/mtd/mtd.h> |
22 | #include <linux/of_platform.h> | 23 | #include <linux/of_platform.h> |
@@ -86,6 +87,8 @@ struct flash_info { | |||
86 | * to support memory size above 128Mib. | 87 | * to support memory size above 128Mib. |
87 | */ | 88 | */ |
88 | #define NO_CHIP_ERASE BIT(12) /* Chip does not support chip erase */ | 89 | #define NO_CHIP_ERASE BIT(12) /* Chip does not support chip erase */ |
90 | #define SPI_NOR_SKIP_SFDP BIT(13) /* Skip parsing of SFDP tables */ | ||
91 | #define USE_CLSR BIT(14) /* use CLSR command */ | ||
89 | }; | 92 | }; |
90 | 93 | ||
91 | #define JEDEC_MFR(info) ((info)->id[0]) | 94 | #define JEDEC_MFR(info) ((info)->id[0]) |
@@ -306,8 +309,18 @@ static inline int spi_nor_sr_ready(struct spi_nor *nor) | |||
306 | int sr = read_sr(nor); | 309 | int sr = read_sr(nor); |
307 | if (sr < 0) | 310 | if (sr < 0) |
308 | return sr; | 311 | return sr; |
309 | else | 312 | |
310 | return !(sr & SR_WIP); | 313 | if (nor->flags & SNOR_F_USE_CLSR && sr & (SR_E_ERR | SR_P_ERR)) { |
314 | if (sr & SR_E_ERR) | ||
315 | dev_err(nor->dev, "Erase Error occurred\n"); | ||
316 | else | ||
317 | dev_err(nor->dev, "Programming Error occurred\n"); | ||
318 | |||
319 | nor->write_reg(nor, SPINOR_OP_CLSR, NULL, 0); | ||
320 | return -EIO; | ||
321 | } | ||
322 | |||
323 | return !(sr & SR_WIP); | ||
311 | } | 324 | } |
312 | 325 | ||
313 | static inline int spi_nor_fsr_ready(struct spi_nor *nor) | 326 | static inline int spi_nor_fsr_ready(struct spi_nor *nor) |
@@ -1041,15 +1054,15 @@ static const struct flash_info spi_nor_ids[] = { | |||
1041 | */ | 1054 | */ |
1042 | { "s25sl032p", INFO(0x010215, 0x4d00, 64 * 1024, 64, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, | 1055 | { "s25sl032p", INFO(0x010215, 0x4d00, 64 * 1024, 64, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, |
1043 | { "s25sl064p", INFO(0x010216, 0x4d00, 64 * 1024, 128, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, | 1056 | { "s25sl064p", INFO(0x010216, 0x4d00, 64 * 1024, 128, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, |
1044 | { "s25fl256s0", INFO(0x010219, 0x4d00, 256 * 1024, 128, 0) }, | 1057 | { "s25fl256s0", INFO(0x010219, 0x4d00, 256 * 1024, 128, USE_CLSR) }, |
1045 | { "s25fl256s1", INFO(0x010219, 0x4d01, 64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, | 1058 | { "s25fl256s1", INFO(0x010219, 0x4d01, 64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR) }, |
1046 | { "s25fl512s", INFO(0x010220, 0x4d00, 256 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, | 1059 | { "s25fl512s", INFO(0x010220, 0x4d00, 256 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR) }, |
1047 | { "s70fl01gs", INFO(0x010221, 0x4d00, 256 * 1024, 256, 0) }, | 1060 | { "s70fl01gs", INFO(0x010221, 0x4d00, 256 * 1024, 256, 0) }, |
1048 | { "s25sl12800", INFO(0x012018, 0x0300, 256 * 1024, 64, 0) }, | 1061 | { "s25sl12800", INFO(0x012018, 0x0300, 256 * 1024, 64, 0) }, |
1049 | { "s25sl12801", INFO(0x012018, 0x0301, 64 * 1024, 256, 0) }, | 1062 | { "s25sl12801", INFO(0x012018, 0x0301, 64 * 1024, 256, 0) }, |
1050 | { "s25fl128s", INFO6(0x012018, 0x4d0180, 64 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, | 1063 | { "s25fl128s", INFO6(0x012018, 0x4d0180, 64 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR) }, |
1051 | { "s25fl129p0", INFO(0x012018, 0x4d00, 256 * 1024, 64, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, | 1064 | { "s25fl129p0", INFO(0x012018, 0x4d00, 256 * 1024, 64, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR) }, |
1052 | { "s25fl129p1", INFO(0x012018, 0x4d01, 64 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, | 1065 | { "s25fl129p1", INFO(0x012018, 0x4d01, 64 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR) }, |
1053 | { "s25sl004a", INFO(0x010212, 0, 64 * 1024, 8, 0) }, | 1066 | { "s25sl004a", INFO(0x010212, 0, 64 * 1024, 8, 0) }, |
1054 | { "s25sl008a", INFO(0x010213, 0, 64 * 1024, 16, 0) }, | 1067 | { "s25sl008a", INFO(0x010213, 0, 64 * 1024, 16, 0) }, |
1055 | { "s25sl016a", INFO(0x010214, 0, 64 * 1024, 32, 0) }, | 1068 | { "s25sl016a", INFO(0x010214, 0, 64 * 1024, 32, 0) }, |
@@ -1079,6 +1092,7 @@ static const struct flash_info spi_nor_ids[] = { | |||
1079 | { "sst25wf040b", INFO(0x621613, 0, 64 * 1024, 8, SECT_4K) }, | 1092 | { "sst25wf040b", INFO(0x621613, 0, 64 * 1024, 8, SECT_4K) }, |
1080 | { "sst25wf040", INFO(0xbf2504, 0, 64 * 1024, 8, SECT_4K | SST_WRITE) }, | 1093 | { "sst25wf040", INFO(0xbf2504, 0, 64 * 1024, 8, SECT_4K | SST_WRITE) }, |
1081 | { "sst25wf080", INFO(0xbf2505, 0, 64 * 1024, 16, SECT_4K | SST_WRITE) }, | 1094 | { "sst25wf080", INFO(0xbf2505, 0, 64 * 1024, 16, SECT_4K | SST_WRITE) }, |
1095 | { "sst26vf064b", INFO(0xbf2643, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, | ||
1082 | 1096 | ||
1083 | /* ST Microelectronics -- newer production may have feature updates */ | 1097 | /* ST Microelectronics -- newer production may have feature updates */ |
1084 | { "m25p05", INFO(0x202010, 0, 32 * 1024, 2, 0) }, | 1098 | { "m25p05", INFO(0x202010, 0, 32 * 1024, 2, 0) }, |
@@ -1380,6 +1394,16 @@ write_err: | |||
1380 | return ret; | 1394 | return ret; |
1381 | } | 1395 | } |
1382 | 1396 | ||
1397 | /** | ||
1398 | * macronix_quad_enable() - set QE bit in Status Register. | ||
1399 | * @nor: pointer to a 'struct spi_nor' | ||
1400 | * | ||
1401 | * Set the Quad Enable (QE) bit in the Status Register. | ||
1402 | * | ||
1403 | * bit 6 of the Status Register is the QE bit for Macronix like QSPI memories. | ||
1404 | * | ||
1405 | * Return: 0 on success, -errno otherwise. | ||
1406 | */ | ||
1383 | static int macronix_quad_enable(struct spi_nor *nor) | 1407 | static int macronix_quad_enable(struct spi_nor *nor) |
1384 | { | 1408 | { |
1385 | int ret, val; | 1409 | int ret, val; |
@@ -1413,22 +1437,13 @@ static int macronix_quad_enable(struct spi_nor *nor) | |||
1413 | * second byte will be written to the configuration register. | 1437 | * second byte will be written to the configuration register. |
1414 | * Return negative if error occurred. | 1438 | * Return negative if error occurred. |
1415 | */ | 1439 | */ |
1416 | static int write_sr_cr(struct spi_nor *nor, u16 val) | 1440 | static int write_sr_cr(struct spi_nor *nor, u8 *sr_cr) |
1417 | { | ||
1418 | nor->cmd_buf[0] = val & 0xff; | ||
1419 | nor->cmd_buf[1] = (val >> 8); | ||
1420 | |||
1421 | return nor->write_reg(nor, SPINOR_OP_WRSR, nor->cmd_buf, 2); | ||
1422 | } | ||
1423 | |||
1424 | static int spansion_quad_enable(struct spi_nor *nor) | ||
1425 | { | 1441 | { |
1426 | int ret; | 1442 | int ret; |
1427 | int quad_en = CR_QUAD_EN_SPAN << 8; | ||
1428 | 1443 | ||
1429 | write_enable(nor); | 1444 | write_enable(nor); |
1430 | 1445 | ||
1431 | ret = write_sr_cr(nor, quad_en); | 1446 | ret = nor->write_reg(nor, SPINOR_OP_WRSR, sr_cr, 2); |
1432 | if (ret < 0) { | 1447 | if (ret < 0) { |
1433 | dev_err(nor->dev, | 1448 | dev_err(nor->dev, |
1434 | "error while writing configuration register\n"); | 1449 | "error while writing configuration register\n"); |
@@ -1442,6 +1457,41 @@ static int spansion_quad_enable(struct spi_nor *nor) | |||
1442 | return ret; | 1457 | return ret; |
1443 | } | 1458 | } |
1444 | 1459 | ||
1460 | return 0; | ||
1461 | } | ||
1462 | |||
1463 | /** | ||
1464 | * spansion_quad_enable() - set QE bit in Configuraiton Register. | ||
1465 | * @nor: pointer to a 'struct spi_nor' | ||
1466 | * | ||
1467 | * Set the Quad Enable (QE) bit in the Configuration Register. | ||
1468 | * This function is kept for legacy purpose because it has been used for a | ||
1469 | * long time without anybody complaining but it should be considered as | ||
1470 | * deprecated and maybe buggy. | ||
1471 | * First, this function doesn't care about the previous values of the Status | ||
1472 | * and Configuration Registers when it sets the QE bit (bit 1) in the | ||
1473 | * Configuration Register: all other bits are cleared, which may have unwanted | ||
1474 | * side effects like removing some block protections. | ||
1475 | * Secondly, it uses the Read Configuration Register (35h) instruction though | ||
1476 | * some very old and few memories don't support this instruction. If a pull-up | ||
1477 | * resistor is present on the MISO/IO1 line, we might still be able to pass the | ||
1478 | * "read back" test because the QSPI memory doesn't recognize the command, | ||
1479 | * so leaves the MISO/IO1 line state unchanged, hence read_cr() returns 0xFF. | ||
1480 | * | ||
1481 | * bit 1 of the Configuration Register is the QE bit for Spansion like QSPI | ||
1482 | * memories. | ||
1483 | * | ||
1484 | * Return: 0 on success, -errno otherwise. | ||
1485 | */ | ||
1486 | static int spansion_quad_enable(struct spi_nor *nor) | ||
1487 | { | ||
1488 | u8 sr_cr[2] = {0, CR_QUAD_EN_SPAN}; | ||
1489 | int ret; | ||
1490 | |||
1491 | ret = write_sr_cr(nor, sr_cr); | ||
1492 | if (ret) | ||
1493 | return ret; | ||
1494 | |||
1445 | /* read back and check it */ | 1495 | /* read back and check it */ |
1446 | ret = read_cr(nor); | 1496 | ret = read_cr(nor); |
1447 | if (!(ret > 0 && (ret & CR_QUAD_EN_SPAN))) { | 1497 | if (!(ret > 0 && (ret & CR_QUAD_EN_SPAN))) { |
@@ -1452,6 +1502,140 @@ static int spansion_quad_enable(struct spi_nor *nor) | |||
1452 | return 0; | 1502 | return 0; |
1453 | } | 1503 | } |
1454 | 1504 | ||
1505 | /** | ||
1506 | * spansion_no_read_cr_quad_enable() - set QE bit in Configuration Register. | ||
1507 | * @nor: pointer to a 'struct spi_nor' | ||
1508 | * | ||
1509 | * Set the Quad Enable (QE) bit in the Configuration Register. | ||
1510 | * This function should be used with QSPI memories not supporting the Read | ||
1511 | * Configuration Register (35h) instruction. | ||
1512 | * | ||
1513 | * bit 1 of the Configuration Register is the QE bit for Spansion like QSPI | ||
1514 | * memories. | ||
1515 | * | ||
1516 | * Return: 0 on success, -errno otherwise. | ||
1517 | */ | ||
1518 | static int spansion_no_read_cr_quad_enable(struct spi_nor *nor) | ||
1519 | { | ||
1520 | u8 sr_cr[2]; | ||
1521 | int ret; | ||
1522 | |||
1523 | /* Keep the current value of the Status Register. */ | ||
1524 | ret = read_sr(nor); | ||
1525 | if (ret < 0) { | ||
1526 | dev_err(nor->dev, "error while reading status register\n"); | ||
1527 | return -EINVAL; | ||
1528 | } | ||
1529 | sr_cr[0] = ret; | ||
1530 | sr_cr[1] = CR_QUAD_EN_SPAN; | ||
1531 | |||
1532 | return write_sr_cr(nor, sr_cr); | ||
1533 | } | ||
1534 | |||
1535 | /** | ||
1536 | * spansion_read_cr_quad_enable() - set QE bit in Configuration Register. | ||
1537 | * @nor: pointer to a 'struct spi_nor' | ||
1538 | * | ||
1539 | * Set the Quad Enable (QE) bit in the Configuration Register. | ||
1540 | * This function should be used with QSPI memories supporting the Read | ||
1541 | * Configuration Register (35h) instruction. | ||
1542 | * | ||
1543 | * bit 1 of the Configuration Register is the QE bit for Spansion like QSPI | ||
1544 | * memories. | ||
1545 | * | ||
1546 | * Return: 0 on success, -errno otherwise. | ||
1547 | */ | ||
1548 | static int spansion_read_cr_quad_enable(struct spi_nor *nor) | ||
1549 | { | ||
1550 | struct device *dev = nor->dev; | ||
1551 | u8 sr_cr[2]; | ||
1552 | int ret; | ||
1553 | |||
1554 | /* Check current Quad Enable bit value. */ | ||
1555 | ret = read_cr(nor); | ||
1556 | if (ret < 0) { | ||
1557 | dev_err(dev, "error while reading configuration register\n"); | ||
1558 | return -EINVAL; | ||
1559 | } | ||
1560 | |||
1561 | if (ret & CR_QUAD_EN_SPAN) | ||
1562 | return 0; | ||
1563 | |||
1564 | sr_cr[1] = ret | CR_QUAD_EN_SPAN; | ||
1565 | |||
1566 | /* Keep the current value of the Status Register. */ | ||
1567 | ret = read_sr(nor); | ||
1568 | if (ret < 0) { | ||
1569 | dev_err(dev, "error while reading status register\n"); | ||
1570 | return -EINVAL; | ||
1571 | } | ||
1572 | sr_cr[0] = ret; | ||
1573 | |||
1574 | ret = write_sr_cr(nor, sr_cr); | ||
1575 | if (ret) | ||
1576 | return ret; | ||
1577 | |||
1578 | /* Read back and check it. */ | ||
1579 | ret = read_cr(nor); | ||
1580 | if (!(ret > 0 && (ret & CR_QUAD_EN_SPAN))) { | ||
1581 | dev_err(nor->dev, "Spansion Quad bit not set\n"); | ||
1582 | return -EINVAL; | ||
1583 | } | ||
1584 | |||
1585 | return 0; | ||
1586 | } | ||
1587 | |||
1588 | /** | ||
1589 | * sr2_bit7_quad_enable() - set QE bit in Status Register 2. | ||
1590 | * @nor: pointer to a 'struct spi_nor' | ||
1591 | * | ||
1592 | * Set the Quad Enable (QE) bit in the Status Register 2. | ||
1593 | * | ||
1594 | * This is one of the procedures to set the QE bit described in the SFDP | ||
1595 | * (JESD216 rev B) specification but no manufacturer using this procedure has | ||
1596 | * been identified yet, hence the name of the function. | ||
1597 | * | ||
1598 | * Return: 0 on success, -errno otherwise. | ||
1599 | */ | ||
1600 | static int sr2_bit7_quad_enable(struct spi_nor *nor) | ||
1601 | { | ||
1602 | u8 sr2; | ||
1603 | int ret; | ||
1604 | |||
1605 | /* Check current Quad Enable bit value. */ | ||
1606 | ret = nor->read_reg(nor, SPINOR_OP_RDSR2, &sr2, 1); | ||
1607 | if (ret) | ||
1608 | return ret; | ||
1609 | if (sr2 & SR2_QUAD_EN_BIT7) | ||
1610 | return 0; | ||
1611 | |||
1612 | /* Update the Quad Enable bit. */ | ||
1613 | sr2 |= SR2_QUAD_EN_BIT7; | ||
1614 | |||
1615 | write_enable(nor); | ||
1616 | |||
1617 | ret = nor->write_reg(nor, SPINOR_OP_WRSR2, &sr2, 1); | ||
1618 | if (ret < 0) { | ||
1619 | dev_err(nor->dev, "error while writing status register 2\n"); | ||
1620 | return -EINVAL; | ||
1621 | } | ||
1622 | |||
1623 | ret = spi_nor_wait_till_ready(nor); | ||
1624 | if (ret < 0) { | ||
1625 | dev_err(nor->dev, "timeout while writing status register 2\n"); | ||
1626 | return ret; | ||
1627 | } | ||
1628 | |||
1629 | /* Read back and check it. */ | ||
1630 | ret = nor->read_reg(nor, SPINOR_OP_RDSR2, &sr2, 1); | ||
1631 | if (!(ret > 0 && (sr2 & SR2_QUAD_EN_BIT7))) { | ||
1632 | dev_err(nor->dev, "SR2 Quad bit not set\n"); | ||
1633 | return -EINVAL; | ||
1634 | } | ||
1635 | |||
1636 | return 0; | ||
1637 | } | ||
1638 | |||
1455 | static int spi_nor_check(struct spi_nor *nor) | 1639 | static int spi_nor_check(struct spi_nor *nor) |
1456 | { | 1640 | { |
1457 | if (!nor->dev || !nor->read || !nor->write || | 1641 | if (!nor->dev || !nor->read || !nor->write || |
@@ -1591,6 +1775,560 @@ spi_nor_set_pp_settings(struct spi_nor_pp_command *pp, | |||
1591 | pp->proto = proto; | 1775 | pp->proto = proto; |
1592 | } | 1776 | } |
1593 | 1777 | ||
1778 | /* | ||
1779 | * Serial Flash Discoverable Parameters (SFDP) parsing. | ||
1780 | */ | ||
1781 | |||
1782 | /** | ||
1783 | * spi_nor_read_sfdp() - read Serial Flash Discoverable Parameters. | ||
1784 | * @nor: pointer to a 'struct spi_nor' | ||
1785 | * @addr: offset in the SFDP area to start reading data from | ||
1786 | * @len: number of bytes to read | ||
1787 | * @buf: buffer where the SFDP data are copied into | ||
1788 | * | ||
1789 | * Whatever the actual numbers of bytes for address and dummy cycles are | ||
1790 | * for (Fast) Read commands, the Read SFDP (5Ah) instruction is always | ||
1791 | * followed by a 3-byte address and 8 dummy clock cycles. | ||
1792 | * | ||
1793 | * Return: 0 on success, -errno otherwise. | ||
1794 | */ | ||
1795 | static int spi_nor_read_sfdp(struct spi_nor *nor, u32 addr, | ||
1796 | size_t len, void *buf) | ||
1797 | { | ||
1798 | u8 addr_width, read_opcode, read_dummy; | ||
1799 | int ret; | ||
1800 | |||
1801 | read_opcode = nor->read_opcode; | ||
1802 | addr_width = nor->addr_width; | ||
1803 | read_dummy = nor->read_dummy; | ||
1804 | |||
1805 | nor->read_opcode = SPINOR_OP_RDSFDP; | ||
1806 | nor->addr_width = 3; | ||
1807 | nor->read_dummy = 8; | ||
1808 | |||
1809 | while (len) { | ||
1810 | ret = nor->read(nor, addr, len, (u8 *)buf); | ||
1811 | if (!ret || ret > len) { | ||
1812 | ret = -EIO; | ||
1813 | goto read_err; | ||
1814 | } | ||
1815 | if (ret < 0) | ||
1816 | goto read_err; | ||
1817 | |||
1818 | buf += ret; | ||
1819 | addr += ret; | ||
1820 | len -= ret; | ||
1821 | } | ||
1822 | ret = 0; | ||
1823 | |||
1824 | read_err: | ||
1825 | nor->read_opcode = read_opcode; | ||
1826 | nor->addr_width = addr_width; | ||
1827 | nor->read_dummy = read_dummy; | ||
1828 | |||
1829 | return ret; | ||
1830 | } | ||
1831 | |||
1832 | struct sfdp_parameter_header { | ||
1833 | u8 id_lsb; | ||
1834 | u8 minor; | ||
1835 | u8 major; | ||
1836 | u8 length; /* in double words */ | ||
1837 | u8 parameter_table_pointer[3]; /* byte address */ | ||
1838 | u8 id_msb; | ||
1839 | }; | ||
1840 | |||
1841 | #define SFDP_PARAM_HEADER_ID(p) (((p)->id_msb << 8) | (p)->id_lsb) | ||
1842 | #define SFDP_PARAM_HEADER_PTP(p) \ | ||
1843 | (((p)->parameter_table_pointer[2] << 16) | \ | ||
1844 | ((p)->parameter_table_pointer[1] << 8) | \ | ||
1845 | ((p)->parameter_table_pointer[0] << 0)) | ||
1846 | |||
1847 | #define SFDP_BFPT_ID 0xff00 /* Basic Flash Parameter Table */ | ||
1848 | #define SFDP_SECTOR_MAP_ID 0xff81 /* Sector Map Table */ | ||
1849 | |||
1850 | #define SFDP_SIGNATURE 0x50444653U | ||
1851 | #define SFDP_JESD216_MAJOR 1 | ||
1852 | #define SFDP_JESD216_MINOR 0 | ||
1853 | #define SFDP_JESD216A_MINOR 5 | ||
1854 | #define SFDP_JESD216B_MINOR 6 | ||
1855 | |||
1856 | struct sfdp_header { | ||
1857 | u32 signature; /* Ox50444653U <=> "SFDP" */ | ||
1858 | u8 minor; | ||
1859 | u8 major; | ||
1860 | u8 nph; /* 0-base number of parameter headers */ | ||
1861 | u8 unused; | ||
1862 | |||
1863 | /* Basic Flash Parameter Table. */ | ||
1864 | struct sfdp_parameter_header bfpt_header; | ||
1865 | }; | ||
1866 | |||
1867 | /* Basic Flash Parameter Table */ | ||
1868 | |||
1869 | /* | ||
1870 | * JESD216 rev B defines a Basic Flash Parameter Table of 16 DWORDs. | ||
1871 | * They are indexed from 1 but C arrays are indexed from 0. | ||
1872 | */ | ||
1873 | #define BFPT_DWORD(i) ((i) - 1) | ||
1874 | #define BFPT_DWORD_MAX 16 | ||
1875 | |||
1876 | /* The first version of JESB216 defined only 9 DWORDs. */ | ||
1877 | #define BFPT_DWORD_MAX_JESD216 9 | ||
1878 | |||
1879 | /* 1st DWORD. */ | ||
1880 | #define BFPT_DWORD1_FAST_READ_1_1_2 BIT(16) | ||
1881 | #define BFPT_DWORD1_ADDRESS_BYTES_MASK GENMASK(18, 17) | ||
1882 | #define BFPT_DWORD1_ADDRESS_BYTES_3_ONLY (0x0UL << 17) | ||
1883 | #define BFPT_DWORD1_ADDRESS_BYTES_3_OR_4 (0x1UL << 17) | ||
1884 | #define BFPT_DWORD1_ADDRESS_BYTES_4_ONLY (0x2UL << 17) | ||
1885 | #define BFPT_DWORD1_DTR BIT(19) | ||
1886 | #define BFPT_DWORD1_FAST_READ_1_2_2 BIT(20) | ||
1887 | #define BFPT_DWORD1_FAST_READ_1_4_4 BIT(21) | ||
1888 | #define BFPT_DWORD1_FAST_READ_1_1_4 BIT(22) | ||
1889 | |||
1890 | /* 5th DWORD. */ | ||
1891 | #define BFPT_DWORD5_FAST_READ_2_2_2 BIT(0) | ||
1892 | #define BFPT_DWORD5_FAST_READ_4_4_4 BIT(4) | ||
1893 | |||
1894 | /* 11th DWORD. */ | ||
1895 | #define BFPT_DWORD11_PAGE_SIZE_SHIFT 4 | ||
1896 | #define BFPT_DWORD11_PAGE_SIZE_MASK GENMASK(7, 4) | ||
1897 | |||
1898 | /* 15th DWORD. */ | ||
1899 | |||
1900 | /* | ||
1901 | * (from JESD216 rev B) | ||
1902 | * Quad Enable Requirements (QER): | ||
1903 | * - 000b: Device does not have a QE bit. Device detects 1-1-4 and 1-4-4 | ||
1904 | * reads based on instruction. DQ3/HOLD# functions are hold during | ||
1905 | * instruction phase. | ||
1906 | * - 001b: QE is bit 1 of status register 2. It is set via Write Status with | ||
1907 | * two data bytes where bit 1 of the second byte is one. | ||
1908 | * [...] | ||
1909 | * Writing only one byte to the status register has the side-effect of | ||
1910 | * clearing status register 2, including the QE bit. The 100b code is | ||
1911 | * used if writing one byte to the status register does not modify | ||
1912 | * status register 2. | ||
1913 | * - 010b: QE is bit 6 of status register 1. It is set via Write Status with | ||
1914 | * one data byte where bit 6 is one. | ||
1915 | * [...] | ||
1916 | * - 011b: QE is bit 7 of status register 2. It is set via Write status | ||
1917 | * register 2 instruction 3Eh with one data byte where bit 7 is one. | ||
1918 | * [...] | ||
1919 | * The status register 2 is read using instruction 3Fh. | ||
1920 | * - 100b: QE is bit 1 of status register 2. It is set via Write Status with | ||
1921 | * two data bytes where bit 1 of the second byte is one. | ||
1922 | * [...] | ||
1923 | * In contrast to the 001b code, writing one byte to the status | ||
1924 | * register does not modify status register 2. | ||
1925 | * - 101b: QE is bit 1 of status register 2. Status register 1 is read using | ||
1926 | * Read Status instruction 05h. Status register2 is read using | ||
1927 | * instruction 35h. QE is set via Writ Status instruction 01h with | ||
1928 | * two data bytes where bit 1 of the second byte is one. | ||
1929 | * [...] | ||
1930 | */ | ||
1931 | #define BFPT_DWORD15_QER_MASK GENMASK(22, 20) | ||
1932 | #define BFPT_DWORD15_QER_NONE (0x0UL << 20) /* Micron */ | ||
1933 | #define BFPT_DWORD15_QER_SR2_BIT1_BUGGY (0x1UL << 20) | ||
1934 | #define BFPT_DWORD15_QER_SR1_BIT6 (0x2UL << 20) /* Macronix */ | ||
1935 | #define BFPT_DWORD15_QER_SR2_BIT7 (0x3UL << 20) | ||
1936 | #define BFPT_DWORD15_QER_SR2_BIT1_NO_RD (0x4UL << 20) | ||
1937 | #define BFPT_DWORD15_QER_SR2_BIT1 (0x5UL << 20) /* Spansion */ | ||
1938 | |||
1939 | struct sfdp_bfpt { | ||
1940 | u32 dwords[BFPT_DWORD_MAX]; | ||
1941 | }; | ||
1942 | |||
1943 | /* Fast Read settings. */ | ||
1944 | |||
1945 | static inline void | ||
1946 | spi_nor_set_read_settings_from_bfpt(struct spi_nor_read_command *read, | ||
1947 | u16 half, | ||
1948 | enum spi_nor_protocol proto) | ||
1949 | { | ||
1950 | read->num_mode_clocks = (half >> 5) & 0x07; | ||
1951 | read->num_wait_states = (half >> 0) & 0x1f; | ||
1952 | read->opcode = (half >> 8) & 0xff; | ||
1953 | read->proto = proto; | ||
1954 | } | ||
1955 | |||
1956 | struct sfdp_bfpt_read { | ||
1957 | /* The Fast Read x-y-z hardware capability in params->hwcaps.mask. */ | ||
1958 | u32 hwcaps; | ||
1959 | |||
1960 | /* | ||
1961 | * The <supported_bit> bit in <supported_dword> BFPT DWORD tells us | ||
1962 | * whether the Fast Read x-y-z command is supported. | ||
1963 | */ | ||
1964 | u32 supported_dword; | ||
1965 | u32 supported_bit; | ||
1966 | |||
1967 | /* | ||
1968 | * The half-word at offset <setting_shift> in <setting_dword> BFPT DWORD | ||
1969 | * encodes the op code, the number of mode clocks and the number of wait | ||
1970 | * states to be used by Fast Read x-y-z command. | ||
1971 | */ | ||
1972 | u32 settings_dword; | ||
1973 | u32 settings_shift; | ||
1974 | |||
1975 | /* The SPI protocol for this Fast Read x-y-z command. */ | ||
1976 | enum spi_nor_protocol proto; | ||
1977 | }; | ||
1978 | |||
1979 | static const struct sfdp_bfpt_read sfdp_bfpt_reads[] = { | ||
1980 | /* Fast Read 1-1-2 */ | ||
1981 | { | ||
1982 | SNOR_HWCAPS_READ_1_1_2, | ||
1983 | BFPT_DWORD(1), BIT(16), /* Supported bit */ | ||
1984 | BFPT_DWORD(4), 0, /* Settings */ | ||
1985 | SNOR_PROTO_1_1_2, | ||
1986 | }, | ||
1987 | |||
1988 | /* Fast Read 1-2-2 */ | ||
1989 | { | ||
1990 | SNOR_HWCAPS_READ_1_2_2, | ||
1991 | BFPT_DWORD(1), BIT(20), /* Supported bit */ | ||
1992 | BFPT_DWORD(4), 16, /* Settings */ | ||
1993 | SNOR_PROTO_1_2_2, | ||
1994 | }, | ||
1995 | |||
1996 | /* Fast Read 2-2-2 */ | ||
1997 | { | ||
1998 | SNOR_HWCAPS_READ_2_2_2, | ||
1999 | BFPT_DWORD(5), BIT(0), /* Supported bit */ | ||
2000 | BFPT_DWORD(6), 16, /* Settings */ | ||
2001 | SNOR_PROTO_2_2_2, | ||
2002 | }, | ||
2003 | |||
2004 | /* Fast Read 1-1-4 */ | ||
2005 | { | ||
2006 | SNOR_HWCAPS_READ_1_1_4, | ||
2007 | BFPT_DWORD(1), BIT(22), /* Supported bit */ | ||
2008 | BFPT_DWORD(3), 16, /* Settings */ | ||
2009 | SNOR_PROTO_1_1_4, | ||
2010 | }, | ||
2011 | |||
2012 | /* Fast Read 1-4-4 */ | ||
2013 | { | ||
2014 | SNOR_HWCAPS_READ_1_4_4, | ||
2015 | BFPT_DWORD(1), BIT(21), /* Supported bit */ | ||
2016 | BFPT_DWORD(3), 0, /* Settings */ | ||
2017 | SNOR_PROTO_1_4_4, | ||
2018 | }, | ||
2019 | |||
2020 | /* Fast Read 4-4-4 */ | ||
2021 | { | ||
2022 | SNOR_HWCAPS_READ_4_4_4, | ||
2023 | BFPT_DWORD(5), BIT(4), /* Supported bit */ | ||
2024 | BFPT_DWORD(7), 16, /* Settings */ | ||
2025 | SNOR_PROTO_4_4_4, | ||
2026 | }, | ||
2027 | }; | ||
2028 | |||
2029 | struct sfdp_bfpt_erase { | ||
2030 | /* | ||
2031 | * The half-word at offset <shift> in DWORD <dwoard> encodes the | ||
2032 | * op code and erase sector size to be used by Sector Erase commands. | ||
2033 | */ | ||
2034 | u32 dword; | ||
2035 | u32 shift; | ||
2036 | }; | ||
2037 | |||
2038 | static const struct sfdp_bfpt_erase sfdp_bfpt_erases[] = { | ||
2039 | /* Erase Type 1 in DWORD8 bits[15:0] */ | ||
2040 | {BFPT_DWORD(8), 0}, | ||
2041 | |||
2042 | /* Erase Type 2 in DWORD8 bits[31:16] */ | ||
2043 | {BFPT_DWORD(8), 16}, | ||
2044 | |||
2045 | /* Erase Type 3 in DWORD9 bits[15:0] */ | ||
2046 | {BFPT_DWORD(9), 0}, | ||
2047 | |||
2048 | /* Erase Type 4 in DWORD9 bits[31:16] */ | ||
2049 | {BFPT_DWORD(9), 16}, | ||
2050 | }; | ||
2051 | |||
2052 | static int spi_nor_hwcaps_read2cmd(u32 hwcaps); | ||
2053 | |||
2054 | /** | ||
2055 | * spi_nor_parse_bfpt() - read and parse the Basic Flash Parameter Table. | ||
2056 | * @nor: pointer to a 'struct spi_nor' | ||
2057 | * @bfpt_header: pointer to the 'struct sfdp_parameter_header' describing | ||
2058 | * the Basic Flash Parameter Table length and version | ||
2059 | * @params: pointer to the 'struct spi_nor_flash_parameter' to be | ||
2060 | * filled | ||
2061 | * | ||
2062 | * The Basic Flash Parameter Table is the main and only mandatory table as | ||
2063 | * defined by the SFDP (JESD216) specification. | ||
2064 | * It provides us with the total size (memory density) of the data array and | ||
2065 | * the number of address bytes for Fast Read, Page Program and Sector Erase | ||
2066 | * commands. | ||
2067 | * For Fast READ commands, it also gives the number of mode clock cycles and | ||
2068 | * wait states (regrouped in the number of dummy clock cycles) for each | ||
2069 | * supported instruction op code. | ||
2070 | * For Page Program, the page size is now available since JESD216 rev A, however | ||
2071 | * the supported instruction op codes are still not provided. | ||
2072 | * For Sector Erase commands, this table stores the supported instruction op | ||
2073 | * codes and the associated sector sizes. | ||
2074 | * Finally, the Quad Enable Requirements (QER) are also available since JESD216 | ||
2075 | * rev A. The QER bits encode the manufacturer dependent procedure to be | ||
2076 | * executed to set the Quad Enable (QE) bit in some internal register of the | ||
2077 | * Quad SPI memory. Indeed the QE bit, when it exists, must be set before | ||
2078 | * sending any Quad SPI command to the memory. Actually, setting the QE bit | ||
2079 | * tells the memory to reassign its WP# and HOLD#/RESET# pins to functions IO2 | ||
2080 | * and IO3 hence enabling 4 (Quad) I/O lines. | ||
2081 | * | ||
2082 | * Return: 0 on success, -errno otherwise. | ||
2083 | */ | ||
2084 | static int spi_nor_parse_bfpt(struct spi_nor *nor, | ||
2085 | const struct sfdp_parameter_header *bfpt_header, | ||
2086 | struct spi_nor_flash_parameter *params) | ||
2087 | { | ||
2088 | struct mtd_info *mtd = &nor->mtd; | ||
2089 | struct sfdp_bfpt bfpt; | ||
2090 | size_t len; | ||
2091 | int i, cmd, err; | ||
2092 | u32 addr; | ||
2093 | u16 half; | ||
2094 | |||
2095 | /* JESD216 Basic Flash Parameter Table length is at least 9 DWORDs. */ | ||
2096 | if (bfpt_header->length < BFPT_DWORD_MAX_JESD216) | ||
2097 | return -EINVAL; | ||
2098 | |||
2099 | /* Read the Basic Flash Parameter Table. */ | ||
2100 | len = min_t(size_t, sizeof(bfpt), | ||
2101 | bfpt_header->length * sizeof(u32)); | ||
2102 | addr = SFDP_PARAM_HEADER_PTP(bfpt_header); | ||
2103 | memset(&bfpt, 0, sizeof(bfpt)); | ||
2104 | err = spi_nor_read_sfdp(nor, addr, len, &bfpt); | ||
2105 | if (err < 0) | ||
2106 | return err; | ||
2107 | |||
2108 | /* Fix endianness of the BFPT DWORDs. */ | ||
2109 | for (i = 0; i < BFPT_DWORD_MAX; i++) | ||
2110 | bfpt.dwords[i] = le32_to_cpu(bfpt.dwords[i]); | ||
2111 | |||
2112 | /* Number of address bytes. */ | ||
2113 | switch (bfpt.dwords[BFPT_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) { | ||
2114 | case BFPT_DWORD1_ADDRESS_BYTES_3_ONLY: | ||
2115 | nor->addr_width = 3; | ||
2116 | break; | ||
2117 | |||
2118 | case BFPT_DWORD1_ADDRESS_BYTES_4_ONLY: | ||
2119 | nor->addr_width = 4; | ||
2120 | break; | ||
2121 | |||
2122 | default: | ||
2123 | break; | ||
2124 | } | ||
2125 | |||
2126 | /* Flash Memory Density (in bits). */ | ||
2127 | params->size = bfpt.dwords[BFPT_DWORD(2)]; | ||
2128 | if (params->size & BIT(31)) { | ||
2129 | params->size &= ~BIT(31); | ||
2130 | params->size = 1ULL << params->size; | ||
2131 | } else { | ||
2132 | params->size++; | ||
2133 | } | ||
2134 | params->size >>= 3; /* Convert to bytes. */ | ||
2135 | |||
2136 | /* Fast Read settings. */ | ||
2137 | for (i = 0; i < ARRAY_SIZE(sfdp_bfpt_reads); i++) { | ||
2138 | const struct sfdp_bfpt_read *rd = &sfdp_bfpt_reads[i]; | ||
2139 | struct spi_nor_read_command *read; | ||
2140 | |||
2141 | if (!(bfpt.dwords[rd->supported_dword] & rd->supported_bit)) { | ||
2142 | params->hwcaps.mask &= ~rd->hwcaps; | ||
2143 | continue; | ||
2144 | } | ||
2145 | |||
2146 | params->hwcaps.mask |= rd->hwcaps; | ||
2147 | cmd = spi_nor_hwcaps_read2cmd(rd->hwcaps); | ||
2148 | read = ¶ms->reads[cmd]; | ||
2149 | half = bfpt.dwords[rd->settings_dword] >> rd->settings_shift; | ||
2150 | spi_nor_set_read_settings_from_bfpt(read, half, rd->proto); | ||
2151 | } | ||
2152 | |||
2153 | /* Sector Erase settings. */ | ||
2154 | for (i = 0; i < ARRAY_SIZE(sfdp_bfpt_erases); i++) { | ||
2155 | const struct sfdp_bfpt_erase *er = &sfdp_bfpt_erases[i]; | ||
2156 | u32 erasesize; | ||
2157 | u8 opcode; | ||
2158 | |||
2159 | half = bfpt.dwords[er->dword] >> er->shift; | ||
2160 | erasesize = half & 0xff; | ||
2161 | |||
2162 | /* erasesize == 0 means this Erase Type is not supported. */ | ||
2163 | if (!erasesize) | ||
2164 | continue; | ||
2165 | |||
2166 | erasesize = 1U << erasesize; | ||
2167 | opcode = (half >> 8) & 0xff; | ||
2168 | #ifdef CONFIG_MTD_SPI_NOR_USE_4K_SECTORS | ||
2169 | if (erasesize == SZ_4K) { | ||
2170 | nor->erase_opcode = opcode; | ||
2171 | mtd->erasesize = erasesize; | ||
2172 | break; | ||
2173 | } | ||
2174 | #endif | ||
2175 | if (!mtd->erasesize || mtd->erasesize < erasesize) { | ||
2176 | nor->erase_opcode = opcode; | ||
2177 | mtd->erasesize = erasesize; | ||
2178 | } | ||
2179 | } | ||
2180 | |||
2181 | /* Stop here if not JESD216 rev A or later. */ | ||
2182 | if (bfpt_header->length < BFPT_DWORD_MAX) | ||
2183 | return 0; | ||
2184 | |||
2185 | /* Page size: this field specifies 'N' so the page size = 2^N bytes. */ | ||
2186 | params->page_size = bfpt.dwords[BFPT_DWORD(11)]; | ||
2187 | params->page_size &= BFPT_DWORD11_PAGE_SIZE_MASK; | ||
2188 | params->page_size >>= BFPT_DWORD11_PAGE_SIZE_SHIFT; | ||
2189 | params->page_size = 1U << params->page_size; | ||
2190 | |||
2191 | /* Quad Enable Requirements. */ | ||
2192 | switch (bfpt.dwords[BFPT_DWORD(15)] & BFPT_DWORD15_QER_MASK) { | ||
2193 | case BFPT_DWORD15_QER_NONE: | ||
2194 | params->quad_enable = NULL; | ||
2195 | break; | ||
2196 | |||
2197 | case BFPT_DWORD15_QER_SR2_BIT1_BUGGY: | ||
2198 | case BFPT_DWORD15_QER_SR2_BIT1_NO_RD: | ||
2199 | params->quad_enable = spansion_no_read_cr_quad_enable; | ||
2200 | break; | ||
2201 | |||
2202 | case BFPT_DWORD15_QER_SR1_BIT6: | ||
2203 | params->quad_enable = macronix_quad_enable; | ||
2204 | break; | ||
2205 | |||
2206 | case BFPT_DWORD15_QER_SR2_BIT7: | ||
2207 | params->quad_enable = sr2_bit7_quad_enable; | ||
2208 | break; | ||
2209 | |||
2210 | case BFPT_DWORD15_QER_SR2_BIT1: | ||
2211 | params->quad_enable = spansion_read_cr_quad_enable; | ||
2212 | break; | ||
2213 | |||
2214 | default: | ||
2215 | return -EINVAL; | ||
2216 | } | ||
2217 | |||
2218 | return 0; | ||
2219 | } | ||
2220 | |||
2221 | /** | ||
2222 | * spi_nor_parse_sfdp() - parse the Serial Flash Discoverable Parameters. | ||
2223 | * @nor: pointer to a 'struct spi_nor' | ||
2224 | * @params: pointer to the 'struct spi_nor_flash_parameter' to be | ||
2225 | * filled | ||
2226 | * | ||
2227 | * The Serial Flash Discoverable Parameters are described by the JEDEC JESD216 | ||
2228 | * specification. This is a standard which tends to supported by almost all | ||
2229 | * (Q)SPI memory manufacturers. Those hard-coded tables allow us to learn at | ||
2230 | * runtime the main parameters needed to perform basic SPI flash operations such | ||
2231 | * as Fast Read, Page Program or Sector Erase commands. | ||
2232 | * | ||
2233 | * Return: 0 on success, -errno otherwise. | ||
2234 | */ | ||
2235 | static int spi_nor_parse_sfdp(struct spi_nor *nor, | ||
2236 | struct spi_nor_flash_parameter *params) | ||
2237 | { | ||
2238 | const struct sfdp_parameter_header *param_header, *bfpt_header; | ||
2239 | struct sfdp_parameter_header *param_headers = NULL; | ||
2240 | struct sfdp_header header; | ||
2241 | struct device *dev = nor->dev; | ||
2242 | size_t psize; | ||
2243 | int i, err; | ||
2244 | |||
2245 | /* Get the SFDP header. */ | ||
2246 | err = spi_nor_read_sfdp(nor, 0, sizeof(header), &header); | ||
2247 | if (err < 0) | ||
2248 | return err; | ||
2249 | |||
2250 | /* Check the SFDP header version. */ | ||
2251 | if (le32_to_cpu(header.signature) != SFDP_SIGNATURE || | ||
2252 | header.major != SFDP_JESD216_MAJOR || | ||
2253 | header.minor < SFDP_JESD216_MINOR) | ||
2254 | return -EINVAL; | ||
2255 | |||
2256 | /* | ||
2257 | * Verify that the first and only mandatory parameter header is a | ||
2258 | * Basic Flash Parameter Table header as specified in JESD216. | ||
2259 | */ | ||
2260 | bfpt_header = &header.bfpt_header; | ||
2261 | if (SFDP_PARAM_HEADER_ID(bfpt_header) != SFDP_BFPT_ID || | ||
2262 | bfpt_header->major != SFDP_JESD216_MAJOR) | ||
2263 | return -EINVAL; | ||
2264 | |||
2265 | /* | ||
2266 | * Allocate memory then read all parameter headers with a single | ||
2267 | * Read SFDP command. These parameter headers will actually be parsed | ||
2268 | * twice: a first time to get the latest revision of the basic flash | ||
2269 | * parameter table, then a second time to handle the supported optional | ||
2270 | * tables. | ||
2271 | * Hence we read the parameter headers once for all to reduce the | ||
2272 | * processing time. Also we use kmalloc() instead of devm_kmalloc() | ||
2273 | * because we don't need to keep these parameter headers: the allocated | ||
2274 | * memory is always released with kfree() before exiting this function. | ||
2275 | */ | ||
2276 | if (header.nph) { | ||
2277 | psize = header.nph * sizeof(*param_headers); | ||
2278 | |||
2279 | param_headers = kmalloc(psize, GFP_KERNEL); | ||
2280 | if (!param_headers) | ||
2281 | return -ENOMEM; | ||
2282 | |||
2283 | err = spi_nor_read_sfdp(nor, sizeof(header), | ||
2284 | psize, param_headers); | ||
2285 | if (err < 0) { | ||
2286 | dev_err(dev, "failed to read SFDP parameter headers\n"); | ||
2287 | goto exit; | ||
2288 | } | ||
2289 | } | ||
2290 | |||
2291 | /* | ||
2292 | * Check other parameter headers to get the latest revision of | ||
2293 | * the basic flash parameter table. | ||
2294 | */ | ||
2295 | for (i = 0; i < header.nph; i++) { | ||
2296 | param_header = ¶m_headers[i]; | ||
2297 | |||
2298 | if (SFDP_PARAM_HEADER_ID(param_header) == SFDP_BFPT_ID && | ||
2299 | param_header->major == SFDP_JESD216_MAJOR && | ||
2300 | (param_header->minor > bfpt_header->minor || | ||
2301 | (param_header->minor == bfpt_header->minor && | ||
2302 | param_header->length > bfpt_header->length))) | ||
2303 | bfpt_header = param_header; | ||
2304 | } | ||
2305 | |||
2306 | err = spi_nor_parse_bfpt(nor, bfpt_header, params); | ||
2307 | if (err) | ||
2308 | goto exit; | ||
2309 | |||
2310 | /* Parse other parameter headers. */ | ||
2311 | for (i = 0; i < header.nph; i++) { | ||
2312 | param_header = ¶m_headers[i]; | ||
2313 | |||
2314 | switch (SFDP_PARAM_HEADER_ID(param_header)) { | ||
2315 | case SFDP_SECTOR_MAP_ID: | ||
2316 | dev_info(dev, "non-uniform erase sector maps are not supported yet.\n"); | ||
2317 | break; | ||
2318 | |||
2319 | default: | ||
2320 | break; | ||
2321 | } | ||
2322 | |||
2323 | if (err) | ||
2324 | goto exit; | ||
2325 | } | ||
2326 | |||
2327 | exit: | ||
2328 | kfree(param_headers); | ||
2329 | return err; | ||
2330 | } | ||
2331 | |||
1594 | static int spi_nor_init_params(struct spi_nor *nor, | 2332 | static int spi_nor_init_params(struct spi_nor *nor, |
1595 | const struct flash_info *info, | 2333 | const struct flash_info *info, |
1596 | struct spi_nor_flash_parameter *params) | 2334 | struct spi_nor_flash_parameter *params) |
@@ -1646,11 +2384,28 @@ static int spi_nor_init_params(struct spi_nor *nor, | |||
1646 | break; | 2384 | break; |
1647 | 2385 | ||
1648 | default: | 2386 | default: |
2387 | /* Kept only for backward compatibility purpose. */ | ||
1649 | params->quad_enable = spansion_quad_enable; | 2388 | params->quad_enable = spansion_quad_enable; |
1650 | break; | 2389 | break; |
1651 | } | 2390 | } |
1652 | } | 2391 | } |
1653 | 2392 | ||
2393 | /* Override the parameters with data read from SFDP tables. */ | ||
2394 | nor->addr_width = 0; | ||
2395 | nor->mtd.erasesize = 0; | ||
2396 | if ((info->flags & (SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)) && | ||
2397 | !(info->flags & SPI_NOR_SKIP_SFDP)) { | ||
2398 | struct spi_nor_flash_parameter sfdp_params; | ||
2399 | |||
2400 | memcpy(&sfdp_params, params, sizeof(sfdp_params)); | ||
2401 | if (spi_nor_parse_sfdp(nor, &sfdp_params)) { | ||
2402 | nor->addr_width = 0; | ||
2403 | nor->mtd.erasesize = 0; | ||
2404 | } else { | ||
2405 | memcpy(params, &sfdp_params, sizeof(*params)); | ||
2406 | } | ||
2407 | } | ||
2408 | |||
1654 | return 0; | 2409 | return 0; |
1655 | } | 2410 | } |
1656 | 2411 | ||
@@ -1762,6 +2517,10 @@ static int spi_nor_select_erase(struct spi_nor *nor, | |||
1762 | { | 2517 | { |
1763 | struct mtd_info *mtd = &nor->mtd; | 2518 | struct mtd_info *mtd = &nor->mtd; |
1764 | 2519 | ||
2520 | /* Do nothing if already configured from SFDP. */ | ||
2521 | if (mtd->erasesize) | ||
2522 | return 0; | ||
2523 | |||
1765 | #ifdef CONFIG_MTD_SPI_NOR_USE_4K_SECTORS | 2524 | #ifdef CONFIG_MTD_SPI_NOR_USE_4K_SECTORS |
1766 | /* prefer "small sector" erase if possible */ | 2525 | /* prefer "small sector" erase if possible */ |
1767 | if (info->flags & SECT_4K) { | 2526 | if (info->flags & SECT_4K) { |
@@ -1960,6 +2719,8 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, | |||
1960 | nor->flags |= SNOR_F_HAS_SR_TB; | 2719 | nor->flags |= SNOR_F_HAS_SR_TB; |
1961 | if (info->flags & NO_CHIP_ERASE) | 2720 | if (info->flags & NO_CHIP_ERASE) |
1962 | nor->flags |= SNOR_F_NO_OP_CHIP_ERASE; | 2721 | nor->flags |= SNOR_F_NO_OP_CHIP_ERASE; |
2722 | if (info->flags & USE_CLSR) | ||
2723 | nor->flags |= SNOR_F_USE_CLSR; | ||
1963 | 2724 | ||
1964 | if (info->flags & SPI_NOR_NO_ERASE) | 2725 | if (info->flags & SPI_NOR_NO_ERASE) |
1965 | mtd->flags |= MTD_NO_ERASE; | 2726 | mtd->flags |= MTD_NO_ERASE; |
@@ -1994,9 +2755,11 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, | |||
1994 | if (ret) | 2755 | if (ret) |
1995 | return ret; | 2756 | return ret; |
1996 | 2757 | ||
1997 | if (info->addr_width) | 2758 | if (nor->addr_width) { |
2759 | /* already configured from SFDP */ | ||
2760 | } else if (info->addr_width) { | ||
1998 | nor->addr_width = info->addr_width; | 2761 | nor->addr_width = info->addr_width; |
1999 | else if (mtd->size > 0x1000000) { | 2762 | } else if (mtd->size > 0x1000000) { |
2000 | /* enable 4-byte addressing if the device exceeds 16MiB */ | 2763 | /* enable 4-byte addressing if the device exceeds 16MiB */ |
2001 | nor->addr_width = 4; | 2764 | nor->addr_width = 4; |
2002 | if (JEDEC_MFR(info) == SNOR_MFR_SPANSION || | 2765 | if (JEDEC_MFR(info) == SNOR_MFR_SPANSION || |
diff --git a/drivers/mtd/ssfdc.c b/drivers/mtd/ssfdc.c index 41b13d1cdcc4..95f0bf95f095 100644 --- a/drivers/mtd/ssfdc.c +++ b/drivers/mtd/ssfdc.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/hdreg.h> | 17 | #include <linux/hdreg.h> |
18 | #include <linux/mtd/mtd.h> | 18 | #include <linux/mtd/mtd.h> |
19 | #include <linux/mtd/nand.h> | 19 | #include <linux/mtd/rawnand.h> |
20 | #include <linux/mtd/blktrans.h> | 20 | #include <linux/mtd/blktrans.h> |
21 | 21 | ||
22 | struct ssfdcr_record { | 22 | struct ssfdcr_record { |
diff --git a/drivers/mtd/tests/nandbiterrs.c b/drivers/mtd/tests/nandbiterrs.c index f26dec896afa..5f03b8c885a9 100644 --- a/drivers/mtd/tests/nandbiterrs.c +++ b/drivers/mtd/tests/nandbiterrs.c | |||
@@ -47,7 +47,7 @@ | |||
47 | #include <linux/moduleparam.h> | 47 | #include <linux/moduleparam.h> |
48 | #include <linux/mtd/mtd.h> | 48 | #include <linux/mtd/mtd.h> |
49 | #include <linux/err.h> | 49 | #include <linux/err.h> |
50 | #include <linux/mtd/nand.h> | 50 | #include <linux/mtd/rawnand.h> |
51 | #include <linux/slab.h> | 51 | #include <linux/slab.h> |
52 | #include "mtd_test.h" | 52 | #include "mtd_test.h" |
53 | 53 | ||
diff --git a/drivers/staging/mt29f_spinand/mt29f_spinand.c b/drivers/staging/mt29f_spinand/mt29f_spinand.c index a4e3ae8f0c85..13eaf16ecd16 100644 --- a/drivers/staging/mt29f_spinand/mt29f_spinand.c +++ b/drivers/staging/mt29f_spinand/mt29f_spinand.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
19 | #include <linux/mtd/mtd.h> | 19 | #include <linux/mtd/mtd.h> |
20 | #include <linux/mtd/partitions.h> | 20 | #include <linux/mtd/partitions.h> |
21 | #include <linux/mtd/nand.h> | 21 | #include <linux/mtd/rawnand.h> |
22 | #include <linux/spi/spi.h> | 22 | #include <linux/spi/spi.h> |
23 | 23 | ||
24 | #include "mt29f_spinand.h" | 24 | #include "mt29f_spinand.h" |
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c index b25d28a21212..48d9522e209c 100644 --- a/fs/jffs2/wbuf.c +++ b/fs/jffs2/wbuf.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/mtd/mtd.h> | 18 | #include <linux/mtd/mtd.h> |
19 | #include <linux/crc32.h> | 19 | #include <linux/crc32.h> |
20 | #include <linux/mtd/nand.h> | 20 | #include <linux/mtd/rawnand.h> |
21 | #include <linux/jiffies.h> | 21 | #include <linux/jiffies.h> |
22 | #include <linux/sched.h> | 22 | #include <linux/sched.h> |
23 | #include <linux/writeback.h> | 23 | #include <linux/writeback.h> |
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 9fdb54a95976..8acfc1e099e1 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h | |||
@@ -216,6 +216,7 @@ | |||
216 | * .data section | 216 | * .data section |
217 | */ | 217 | */ |
218 | #define DATA_DATA \ | 218 | #define DATA_DATA \ |
219 | *(.xiptext) \ | ||
219 | *(DATA_MAIN) \ | 220 | *(DATA_MAIN) \ |
220 | *(.ref.data) \ | 221 | *(.ref.data) \ |
221 | *(.data..shared_aligned) /* percpu related */ \ | 222 | *(.data..shared_aligned) /* percpu related */ \ |
diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h index b572955e6de6..15646740e2a8 100644 --- a/include/linux/mfd/tmio.h +++ b/include/linux/mfd/tmio.h | |||
@@ -144,6 +144,7 @@ struct tmio_nand_data { | |||
144 | struct nand_bbt_descr *badblock_pattern; | 144 | struct nand_bbt_descr *badblock_pattern; |
145 | struct mtd_partition *partition; | 145 | struct mtd_partition *partition; |
146 | unsigned int num_partitions; | 146 | unsigned int num_partitions; |
147 | const char *const *part_parsers; | ||
147 | }; | 148 | }; |
148 | 149 | ||
149 | #define FBIO_TMIO_ACC_WRITE 0x7C639300 | 150 | #define FBIO_TMIO_ACC_WRITE 0x7C639300 |
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index f8a2ef239c60..6cd0f6b7658b 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h | |||
@@ -206,6 +206,15 @@ struct mtd_pairing_scheme { | |||
206 | 206 | ||
207 | struct module; /* only needed for owner field in mtd_info */ | 207 | struct module; /* only needed for owner field in mtd_info */ |
208 | 208 | ||
209 | /** | ||
210 | * struct mtd_debug_info - debugging information for an MTD device. | ||
211 | * | ||
212 | * @dfs_dir: direntry object of the MTD device debugfs directory | ||
213 | */ | ||
214 | struct mtd_debug_info { | ||
215 | struct dentry *dfs_dir; | ||
216 | }; | ||
217 | |||
209 | struct mtd_info { | 218 | struct mtd_info { |
210 | u_char type; | 219 | u_char type; |
211 | uint32_t flags; | 220 | uint32_t flags; |
@@ -346,6 +355,7 @@ struct mtd_info { | |||
346 | struct module *owner; | 355 | struct module *owner; |
347 | struct device dev; | 356 | struct device dev; |
348 | int usecount; | 357 | int usecount; |
358 | struct mtd_debug_info dbg; | ||
349 | }; | 359 | }; |
350 | 360 | ||
351 | int mtd_ooblayout_ecc(struct mtd_info *mtd, int section, | 361 | int mtd_ooblayout_ecc(struct mtd_info *mtd, int section, |
diff --git a/include/linux/mtd/nand-gpio.h b/include/linux/mtd/nand-gpio.h index 51534e50f7fc..be4f45d89be2 100644 --- a/include/linux/mtd/nand-gpio.h +++ b/include/linux/mtd/nand-gpio.h | |||
@@ -1,7 +1,7 @@ | |||
1 | #ifndef __LINUX_MTD_NAND_GPIO_H | 1 | #ifndef __LINUX_MTD_NAND_GPIO_H |
2 | #define __LINUX_MTD_NAND_GPIO_H | 2 | #define __LINUX_MTD_NAND_GPIO_H |
3 | 3 | ||
4 | #include <linux/mtd/nand.h> | 4 | #include <linux/mtd/rawnand.h> |
5 | 5 | ||
6 | struct gpio_nand_platdata { | 6 | struct gpio_nand_platdata { |
7 | int gpio_nce; | 7 | int gpio_nce; |
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/rawnand.h index 5216d2eb2289..2b05f4273bab 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/rawnand.h | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * linux/include/linux/mtd/nand.h | ||
3 | * | ||
4 | * Copyright © 2000-2010 David Woodhouse <dwmw2@infradead.org> | 2 | * Copyright © 2000-2010 David Woodhouse <dwmw2@infradead.org> |
5 | * Steven J. Hill <sjhill@realitydiluted.com> | 3 | * Steven J. Hill <sjhill@realitydiluted.com> |
6 | * Thomas Gleixner <tglx@linutronix.de> | 4 | * Thomas Gleixner <tglx@linutronix.de> |
@@ -15,8 +13,8 @@ | |||
15 | * Changelog: | 13 | * Changelog: |
16 | * See git changelog. | 14 | * See git changelog. |
17 | */ | 15 | */ |
18 | #ifndef __LINUX_MTD_NAND_H | 16 | #ifndef __LINUX_MTD_RAWNAND_H |
19 | #define __LINUX_MTD_NAND_H | 17 | #define __LINUX_MTD_RAWNAND_H |
20 | 18 | ||
21 | #include <linux/wait.h> | 19 | #include <linux/wait.h> |
22 | #include <linux/spinlock.h> | 20 | #include <linux/spinlock.h> |
@@ -44,12 +42,6 @@ void nand_release(struct mtd_info *mtd); | |||
44 | /* Internal helper for board drivers which need to override command function */ | 42 | /* Internal helper for board drivers which need to override command function */ |
45 | void nand_wait_ready(struct mtd_info *mtd); | 43 | void nand_wait_ready(struct mtd_info *mtd); |
46 | 44 | ||
47 | /* locks all blocks present in the device */ | ||
48 | int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len); | ||
49 | |||
50 | /* unlocks specified locked blocks */ | ||
51 | int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len); | ||
52 | |||
53 | /* The maximum number of NAND chips in an array */ | 45 | /* The maximum number of NAND chips in an array */ |
54 | #define NAND_MAX_CHIPS 8 | 46 | #define NAND_MAX_CHIPS 8 |
55 | 47 | ||
@@ -89,10 +81,6 @@ int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len); | |||
89 | #define NAND_CMD_SET_FEATURES 0xef | 81 | #define NAND_CMD_SET_FEATURES 0xef |
90 | #define NAND_CMD_RESET 0xff | 82 | #define NAND_CMD_RESET 0xff |
91 | 83 | ||
92 | #define NAND_CMD_LOCK 0x2a | ||
93 | #define NAND_CMD_UNLOCK1 0x23 | ||
94 | #define NAND_CMD_UNLOCK2 0x24 | ||
95 | |||
96 | /* Extended commands for large page devices */ | 84 | /* Extended commands for large page devices */ |
97 | #define NAND_CMD_READSTART 0x30 | 85 | #define NAND_CMD_READSTART 0x30 |
98 | #define NAND_CMD_RNDOUTSTART 0xE0 | 86 | #define NAND_CMD_RNDOUTSTART 0xE0 |
@@ -449,14 +437,16 @@ struct nand_jedec_params { | |||
449 | __le16 crc; | 437 | __le16 crc; |
450 | } __packed; | 438 | } __packed; |
451 | 439 | ||
440 | /* The maximum expected count of bytes in the NAND ID sequence */ | ||
441 | #define NAND_MAX_ID_LEN 8 | ||
442 | |||
452 | /** | 443 | /** |
453 | * struct nand_id - NAND id structure | 444 | * struct nand_id - NAND id structure |
454 | * @data: buffer containing the id bytes. Currently 8 bytes large, but can | 445 | * @data: buffer containing the id bytes. |
455 | * be extended if required. | ||
456 | * @len: ID length. | 446 | * @len: ID length. |
457 | */ | 447 | */ |
458 | struct nand_id { | 448 | struct nand_id { |
459 | u8 data[8]; | 449 | u8 data[NAND_MAX_ID_LEN]; |
460 | int len; | 450 | int len; |
461 | }; | 451 | }; |
462 | 452 | ||
@@ -1028,8 +1018,6 @@ static inline void *nand_get_manufacturer_data(struct nand_chip *chip) | |||
1028 | #define NAND_MFR_ATO 0x9b | 1018 | #define NAND_MFR_ATO 0x9b |
1029 | #define NAND_MFR_WINBOND 0xef | 1019 | #define NAND_MFR_WINBOND 0xef |
1030 | 1020 | ||
1031 | /* The maximum expected count of bytes in the NAND ID sequence */ | ||
1032 | #define NAND_MAX_ID_LEN 8 | ||
1033 | 1021 | ||
1034 | /* | 1022 | /* |
1035 | * A helper for defining older NAND chips where the second ID byte fully | 1023 | * A helper for defining older NAND chips where the second ID byte fully |
@@ -1246,6 +1234,8 @@ int onfi_init_data_interface(struct nand_chip *chip, | |||
1246 | */ | 1234 | */ |
1247 | static inline bool nand_is_slc(struct nand_chip *chip) | 1235 | static inline bool nand_is_slc(struct nand_chip *chip) |
1248 | { | 1236 | { |
1237 | WARN(chip->bits_per_cell == 0, | ||
1238 | "chip->bits_per_cell is used uninitialized\n"); | ||
1249 | return chip->bits_per_cell == 1; | 1239 | return chip->bits_per_cell == 1; |
1250 | } | 1240 | } |
1251 | 1241 | ||
@@ -1328,4 +1318,4 @@ void nand_cleanup(struct nand_chip *chip); | |||
1328 | 1318 | ||
1329 | /* Default extended ID decoding function */ | 1319 | /* Default extended ID decoding function */ |
1330 | void nand_decode_ext_id(struct nand_chip *chip); | 1320 | void nand_decode_ext_id(struct nand_chip *chip); |
1331 | #endif /* __LINUX_MTD_NAND_H */ | 1321 | #endif /* __LINUX_MTD_RAWNAND_H */ |
diff --git a/include/linux/mtd/sh_flctl.h b/include/linux/mtd/sh_flctl.h index 2251add65fa7..c759d403cbc0 100644 --- a/include/linux/mtd/sh_flctl.h +++ b/include/linux/mtd/sh_flctl.h | |||
@@ -22,7 +22,7 @@ | |||
22 | 22 | ||
23 | #include <linux/completion.h> | 23 | #include <linux/completion.h> |
24 | #include <linux/mtd/mtd.h> | 24 | #include <linux/mtd/mtd.h> |
25 | #include <linux/mtd/nand.h> | 25 | #include <linux/mtd/rawnand.h> |
26 | #include <linux/mtd/partitions.h> | 26 | #include <linux/mtd/partitions.h> |
27 | #include <linux/pm_qos.h> | 27 | #include <linux/pm_qos.h> |
28 | 28 | ||
diff --git a/include/linux/mtd/sharpsl.h b/include/linux/mtd/sharpsl.h index 65e91d0fa981..e1845fc4afbd 100644 --- a/include/linux/mtd/sharpsl.h +++ b/include/linux/mtd/sharpsl.h | |||
@@ -8,7 +8,7 @@ | |||
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/mtd/nand.h> | 11 | #include <linux/mtd/rawnand.h> |
12 | #include <linux/mtd/nand_ecc.h> | 12 | #include <linux/mtd/nand_ecc.h> |
13 | #include <linux/mtd/partitions.h> | 13 | #include <linux/mtd/partitions.h> |
14 | 14 | ||
@@ -17,4 +17,5 @@ struct sharpsl_nand_platform_data { | |||
17 | const struct mtd_ooblayout_ops *ecc_layout; | 17 | const struct mtd_ooblayout_ops *ecc_layout; |
18 | struct mtd_partition *partitions; | 18 | struct mtd_partition *partitions; |
19 | unsigned int nr_partitions; | 19 | unsigned int nr_partitions; |
20 | const char *const *part_parsers; | ||
20 | }; | 21 | }; |
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 55faa2f07cca..1f0a7fc7772f 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h | |||
@@ -41,6 +41,8 @@ | |||
41 | #define SPINOR_OP_WREN 0x06 /* Write enable */ | 41 | #define SPINOR_OP_WREN 0x06 /* Write enable */ |
42 | #define SPINOR_OP_RDSR 0x05 /* Read status register */ | 42 | #define SPINOR_OP_RDSR 0x05 /* Read status register */ |
43 | #define SPINOR_OP_WRSR 0x01 /* Write status register 1 byte */ | 43 | #define SPINOR_OP_WRSR 0x01 /* Write status register 1 byte */ |
44 | #define SPINOR_OP_RDSR2 0x3f /* Read status register 2 */ | ||
45 | #define SPINOR_OP_WRSR2 0x3e /* Write status register 2 */ | ||
44 | #define SPINOR_OP_READ 0x03 /* Read data bytes (low frequency) */ | 46 | #define SPINOR_OP_READ 0x03 /* Read data bytes (low frequency) */ |
45 | #define SPINOR_OP_READ_FAST 0x0b /* Read data bytes (high frequency) */ | 47 | #define SPINOR_OP_READ_FAST 0x0b /* Read data bytes (high frequency) */ |
46 | #define SPINOR_OP_READ_1_1_2 0x3b /* Read data bytes (Dual Output SPI) */ | 48 | #define SPINOR_OP_READ_1_1_2 0x3b /* Read data bytes (Dual Output SPI) */ |
@@ -56,6 +58,7 @@ | |||
56 | #define SPINOR_OP_CHIP_ERASE 0xc7 /* Erase whole flash chip */ | 58 | #define SPINOR_OP_CHIP_ERASE 0xc7 /* Erase whole flash chip */ |
57 | #define SPINOR_OP_SE 0xd8 /* Sector erase (usually 64KiB) */ | 59 | #define SPINOR_OP_SE 0xd8 /* Sector erase (usually 64KiB) */ |
58 | #define SPINOR_OP_RDID 0x9f /* Read JEDEC ID */ | 60 | #define SPINOR_OP_RDID 0x9f /* Read JEDEC ID */ |
61 | #define SPINOR_OP_RDSFDP 0x5a /* Read SFDP */ | ||
59 | #define SPINOR_OP_RDCR 0x35 /* Read configuration register */ | 62 | #define SPINOR_OP_RDCR 0x35 /* Read configuration register */ |
60 | #define SPINOR_OP_RDFSR 0x70 /* Read flag status register */ | 63 | #define SPINOR_OP_RDFSR 0x70 /* Read flag status register */ |
61 | 64 | ||
@@ -102,6 +105,7 @@ | |||
102 | 105 | ||
103 | /* Used for Spansion flashes only. */ | 106 | /* Used for Spansion flashes only. */ |
104 | #define SPINOR_OP_BRWR 0x17 /* Bank register write */ | 107 | #define SPINOR_OP_BRWR 0x17 /* Bank register write */ |
108 | #define SPINOR_OP_CLSR 0x30 /* Clear status register 1 */ | ||
105 | 109 | ||
106 | /* Used for Micron flashes only. */ | 110 | /* Used for Micron flashes only. */ |
107 | #define SPINOR_OP_RD_EVCR 0x65 /* Read EVCR register */ | 111 | #define SPINOR_OP_RD_EVCR 0x65 /* Read EVCR register */ |
@@ -116,6 +120,9 @@ | |||
116 | #define SR_BP2 BIT(4) /* Block protect 2 */ | 120 | #define SR_BP2 BIT(4) /* Block protect 2 */ |
117 | #define SR_TB BIT(5) /* Top/Bottom protect */ | 121 | #define SR_TB BIT(5) /* Top/Bottom protect */ |
118 | #define SR_SRWD BIT(7) /* SR write protect */ | 122 | #define SR_SRWD BIT(7) /* SR write protect */ |
123 | /* Spansion/Cypress specific status bits */ | ||
124 | #define SR_E_ERR BIT(5) | ||
125 | #define SR_P_ERR BIT(6) | ||
119 | 126 | ||
120 | #define SR_QUAD_EN_MX BIT(6) /* Macronix Quad I/O */ | 127 | #define SR_QUAD_EN_MX BIT(6) /* Macronix Quad I/O */ |
121 | 128 | ||
@@ -128,6 +135,9 @@ | |||
128 | /* Configuration Register bits. */ | 135 | /* Configuration Register bits. */ |
129 | #define CR_QUAD_EN_SPAN BIT(1) /* Spansion Quad I/O */ | 136 | #define CR_QUAD_EN_SPAN BIT(1) /* Spansion Quad I/O */ |
130 | 137 | ||
138 | /* Status Register 2 bits. */ | ||
139 | #define SR2_QUAD_EN_BIT7 BIT(7) | ||
140 | |||
131 | /* Supported SPI protocols */ | 141 | /* Supported SPI protocols */ |
132 | #define SNOR_PROTO_INST_MASK GENMASK(23, 16) | 142 | #define SNOR_PROTO_INST_MASK GENMASK(23, 16) |
133 | #define SNOR_PROTO_INST_SHIFT 16 | 143 | #define SNOR_PROTO_INST_SHIFT 16 |
@@ -218,6 +228,7 @@ enum spi_nor_option_flags { | |||
218 | SNOR_F_NO_OP_CHIP_ERASE = BIT(2), | 228 | SNOR_F_NO_OP_CHIP_ERASE = BIT(2), |
219 | SNOR_F_S3AN_ADDR_DEFAULT = BIT(3), | 229 | SNOR_F_S3AN_ADDR_DEFAULT = BIT(3), |
220 | SNOR_F_READY_XSR_RDY = BIT(4), | 230 | SNOR_F_READY_XSR_RDY = BIT(4), |
231 | SNOR_F_USE_CLSR = BIT(5), | ||
221 | }; | 232 | }; |
222 | 233 | ||
223 | /** | 234 | /** |
diff --git a/include/linux/mtd/xip.h b/include/linux/mtd/xip.h index abed4dec5c2f..e373690cce0a 100644 --- a/include/linux/mtd/xip.h +++ b/include/linux/mtd/xip.h | |||
@@ -30,7 +30,9 @@ | |||
30 | * obviously not be running from flash. The __xipram is therefore marking | 30 | * obviously not be running from flash. The __xipram is therefore marking |
31 | * those functions so they get relocated to ram. | 31 | * those functions so they get relocated to ram. |
32 | */ | 32 | */ |
33 | #define __xipram noinline __attribute__ ((__section__ (".data"))) | 33 | #ifdef CONFIG_XIP_KERNEL |
34 | #define __xipram noinline __attribute__ ((__section__ (".xiptext"))) | ||
35 | #endif | ||
34 | 36 | ||
35 | /* | 37 | /* |
36 | * Each architecture has to provide the following macros. They must access | 38 | * Each architecture has to provide the following macros. They must access |
@@ -90,10 +92,10 @@ | |||
90 | #define xip_cpu_idle() do { } while (0) | 92 | #define xip_cpu_idle() do { } while (0) |
91 | #endif | 93 | #endif |
92 | 94 | ||
93 | #else | 95 | #endif /* CONFIG_MTD_XIP */ |
94 | 96 | ||
97 | #ifndef __xipram | ||
95 | #define __xipram | 98 | #define __xipram |
96 | 99 | #endif | |
97 | #endif /* CONFIG_MTD_XIP */ | ||
98 | 100 | ||
99 | #endif /* __LINUX_MTD_XIP_H__ */ | 101 | #endif /* __LINUX_MTD_XIP_H__ */ |
diff --git a/include/linux/platform_data/mtd-davinci.h b/include/linux/platform_data/mtd-davinci.h index 1cf555aef896..f1a2cf655bdb 100644 --- a/include/linux/platform_data/mtd-davinci.h +++ b/include/linux/platform_data/mtd-davinci.h | |||
@@ -28,7 +28,7 @@ | |||
28 | #ifndef __ARCH_ARM_DAVINCI_NAND_H | 28 | #ifndef __ARCH_ARM_DAVINCI_NAND_H |
29 | #define __ARCH_ARM_DAVINCI_NAND_H | 29 | #define __ARCH_ARM_DAVINCI_NAND_H |
30 | 30 | ||
31 | #include <linux/mtd/nand.h> | 31 | #include <linux/mtd/rawnand.h> |
32 | 32 | ||
33 | #define NANDFCR_OFFSET 0x60 | 33 | #define NANDFCR_OFFSET 0x60 |
34 | #define NANDFSR_OFFSET 0x64 | 34 | #define NANDFSR_OFFSET 0x64 |
diff --git a/include/linux/platform_data/mtd-nand-s3c2410.h b/include/linux/platform_data/mtd-nand-s3c2410.h index f01659026b26..f8c553f92655 100644 --- a/include/linux/platform_data/mtd-nand-s3c2410.h +++ b/include/linux/platform_data/mtd-nand-s3c2410.h | |||
@@ -12,7 +12,7 @@ | |||
12 | #ifndef __MTD_NAND_S3C2410_H | 12 | #ifndef __MTD_NAND_S3C2410_H |
13 | #define __MTD_NAND_S3C2410_H | 13 | #define __MTD_NAND_S3C2410_H |
14 | 14 | ||
15 | #include <linux/mtd/nand.h> | 15 | #include <linux/mtd/rawnand.h> |
16 | 16 | ||
17 | /** | 17 | /** |
18 | * struct s3c2410_nand_set - define a set of one or more nand chips | 18 | * struct s3c2410_nand_set - define a set of one or more nand chips |