Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'mtd/for-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux

Pull mtd updates from
"Core MTD changes:
- otp:
- Put factory OTP/NVRAM into the entropy pool
- Clean up on error in mtd_otp_nvmem_add()

MTD devices changes:
- sm_ftl: Fix typos in comments
- Use SPDX license headers
- pismo: Switch back to use i2c_driver's .probe()
- mtdpart: Drop useless LIST_HEAD
- st_spi_fsm: Use the devm_clk_get_enabled() helper function

DT binding changes:
- partitions:
- Include TP-Link SafeLoader in allowed list
- Add missing type for "linux,rootfs"
- Extend the nand node names filter
- Create a file for raw NAND chip properties
- Mark nand-ecc-placement deprecated
- Describe nand-ecc-mode
- Prevent NAND chip unevaluated properties in all NAND bindings with
a NAND chip reference.
- Qcom: Fix a property position
- Marvell: Convert to YAML DT schema

Raw NAND chip drivers changes:
- Macronix: OTP access for MX30LFxG18AC
- Add basic Sandisk manufacturer ops
- Add support for Sandisk SDTNQGAMA

Raw NAND controller driver changes:
- Meson:
- Replace integer consts with proper defines
- Allow waiting w/o wired ready/busy pin
- Check buffer length validity
- Fix unaligned DMA buffers handling
- dt-bindings: Fix 'nand-rb' property
- Arasan: Revert "mtd: rawnand: arasan: Prevent an unsupported
configuration" as this limitation is no longer true thanks to the
recent efforts in improving the clocks support in this driver

SPI-NAND changes:
- Gigadevice: add support for GD5F2GQ5xExxH
- Macronix: Add support for serial NAND flashes"

* tag 'mtd/for-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux: (38 commits)
dt-bindings: mtd: marvell-nand: Convert to YAML DT scheme
dt-bindings: mtd: ti,am654: Prevent unevaluated properties
dt-bindings: mtd: mediatek: Prevent NAND chip unevaluated properties
dt-bindings: mtd: mediatek: Reference raw-nand-chip.yaml
dt-bindings: mtd: stm32: Prevent NAND chip unevaluated properties
dt-bindings: mtd: rockchip: Prevent NAND chip unevaluated properties
dt-bindings: mtd: intel: Prevent NAND chip unevaluated properties
dt-bindings: mtd: denali: Prevent NAND chip unevaluated properties
dt-bindings: mtd: brcmnand: Prevent NAND chip unevaluated properties
dt-bindings: mtd: meson: Prevent NAND chip unevaluated properties
dt-bindings: mtd: sunxi: Prevent NAND chip unevaluated properties
dt-bindings: mtd: ingenic: Prevent NAND chip unevaluated properties
dt-bindings: mtd: qcom: Prevent NAND chip unevaluated properties
dt-bindings: mtd: qcom: Fix a property position
dt-bindings: mtd: Describe nand-ecc-mode
dt-bindings: mtd: Mark nand-ecc-placement deprecated
dt-bindings: mtd: Create a file for raw NAND chip properties
dt-bindings: mtd: Accept nand related node names
mtd: sm_ftl: Fix typos in comments
mtd: otp: clean up on error in mtd_otp_nvmem_add()
...

+805 -299
+2 -3
Documentation/devicetree/bindings/mtd/allwinner,sun4i-a10-nand.yaml
··· 49 49 patternProperties: 50 50 "^nand@[a-f0-9]$": 51 51 type: object 52 + $ref: raw-nand-chip.yaml 52 53 properties: 53 54 reg: 54 55 minimum: 0 55 56 maximum: 7 56 - 57 - nand-ecc-mode: true 58 57 59 58 nand-ecc-algo: 60 59 const: bch ··· 74 75 minimum: 0 75 76 maximum: 1 76 77 77 - additionalProperties: false 78 + unevaluatedProperties: false 78 79 79 80 required: 80 81 - compatible
+10
Documentation/devicetree/bindings/mtd/amlogic,meson-nand.yaml
··· 40 40 patternProperties: 41 41 "^nand@[0-7]$": 42 42 type: object 43 + $ref: raw-nand-chip.yaml 43 44 properties: 44 45 reg: 45 46 minimum: 0 ··· 58 57 The ECC configurations that can be supported are as follows. 59 58 meson-gxl-nfc 8, 16, 24, 30, 40, 50, 60 60 59 meson-axg-nfc 8 60 + 61 + nand-rb: 62 + maxItems: 1 63 + items: 64 + maximum: 0 65 + 66 + unevaluatedProperties: false 67 + 61 68 62 69 required: 63 70 - compatible ··· 96 87 97 88 nand@0 { 98 89 reg = <0>; 90 + nand-rb = <0>; 99 91 }; 100 92 }; 101 93
+3
Documentation/devicetree/bindings/mtd/brcm,brcmnand.yaml
··· 114 114 patternProperties: 115 115 "^nand@[a-f0-9]$": 116 116 type: object 117 + $ref: raw-nand-chip.yaml 117 118 properties: 118 119 compatible: 119 120 const: brcm,nandcs ··· 136 135 number of available options for its default ECC 137 136 layout. 138 137 $ref: /schemas/types.yaml#/definitions/uint32 138 + 139 + unevaluatedProperties: false 139 140 140 141 allOf: 141 142 - $ref: nand-controller.yaml#
+6 -3
Documentation/devicetree/bindings/mtd/denali,nand.yaml
··· 63 63 minItems: 1 64 64 maxItems: 2 65 65 66 + patternProperties: 67 + "^nand@[a-f0-9]$": 68 + type: object 69 + $ref: raw-nand-chip.yaml 70 + unevaluatedProperties: false 71 + 66 72 allOf: 67 73 - $ref: nand-controller.yaml 68 74 ··· 80 74 then: 81 75 patternProperties: 82 76 "^nand@[a-f0-9]$": 83 - type: object 84 77 properties: 85 78 nand-ecc-strength: 86 79 enum: ··· 97 92 then: 98 93 patternProperties: 99 94 "^nand@[a-f0-9]$": 100 - type: object 101 95 properties: 102 96 nand-ecc-strength: 103 97 enum: ··· 115 111 then: 116 112 patternProperties: 117 113 "^nand@[a-f0-9]$": 118 - type: object 119 114 properties: 120 115 nand-ecc-strength: 121 116 enum:
+4
Documentation/devicetree/bindings/mtd/ingenic,nand.yaml
··· 39 39 patternProperties: 40 40 "^nand@[a-f0-9]$": 41 41 type: object 42 + $ref: raw-nand-chip.yaml 42 43 properties: 44 + 43 45 rb-gpios: 44 46 description: GPIO specifier for the busy pin. 45 47 maxItems: 1 ··· 49 47 wp-gpios: 50 48 description: GPIO specifier for the write-protect pin. 51 49 maxItems: 1 50 + 51 + unevaluatedProperties: false 52 52 53 53 required: 54 54 - compatible
+2 -3
Documentation/devicetree/bindings/mtd/intel,lgm-ebunand.yaml
··· 42 42 patternProperties: 43 43 "^nand@[a-f0-9]$": 44 44 type: object 45 + $ref: raw-nand-chip.yaml 45 46 properties: 46 47 reg: 47 48 minimum: 0 48 49 maximum: 1 49 50 50 - nand-ecc-mode: true 51 - 52 51 nand-ecc-algo: 53 52 const: hw 54 53 55 - additionalProperties: false 54 + unevaluatedProperties: false 56 55 57 56 required: 58 57 - compatible
+226
Documentation/devicetree/bindings/mtd/marvell,nand-controller.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/mtd/marvell,nand-controller.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Marvell NAND Flash Controller (NFC) 8 + 9 + maintainers: 10 + - Miquel Raynal <miquel.raynal@bootlin.com> 11 + 12 + properties: 13 + compatible: 14 + oneOf: 15 + - items: 16 + - const: marvell,armada-8k-nand-controller 17 + - const: marvell,armada370-nand-controller 18 + - enum: 19 + - marvell,armada370-nand-controller 20 + - marvell,pxa3xx-nand-controller 21 + - description: legacy bindings 22 + deprecated: true 23 + enum: 24 + - marvell,armada-8k-nand 25 + - marvell,armada370-nand 26 + - marvell,pxa3xx-nand 27 + 28 + reg: 29 + maxItems: 1 30 + 31 + interrupts: 32 + maxItems: 1 33 + 34 + clocks: 35 + description: 36 + Shall reference the NAND controller clocks, the second one is 37 + is only needed for the Armada 7K/8K SoCs 38 + minItems: 1 39 + maxItems: 2 40 + 41 + clock-names: 42 + minItems: 1 43 + items: 44 + - const: core 45 + - const: reg 46 + 47 + dmas: 48 + maxItems: 1 49 + 50 + dma-names: 51 + items: 52 + - const: data 53 + 54 + marvell,system-controller: 55 + $ref: /schemas/types.yaml#/definitions/phandle 56 + description: Syscon node that handles NAND controller related registers 57 + 58 + patternProperties: 59 + "^nand@[a-f0-9]$": 60 + type: object 61 + $ref: raw-nand-chip.yaml 62 + 63 + properties: 64 + reg: 65 + minimum: 0 66 + maximum: 3 67 + 68 + nand-rb: 69 + items: 70 + - minimum: 0 71 + maximum: 1 72 + 73 + nand-ecc-step-size: 74 + const: 512 75 + 76 + nand-ecc-strength: 77 + enum: [1, 4, 8, 12, 16] 78 + 79 + nand-ecc-mode: 80 + const: hw 81 + 82 + marvell,nand-keep-config: 83 + $ref: /schemas/types.yaml#/definitions/flag 84 + description: 85 + Orders the driver not to take the timings from the core and 86 + leaving them completely untouched. Bootloader timings will then 87 + be used. 88 + 89 + marvell,nand-enable-arbiter: 90 + $ref: /schemas/types.yaml#/definitions/flag 91 + description: 92 + To enable the arbiter, all boards blindly used it, 93 + this bit was set by the bootloader for many boards and even if 94 + it is marked reserved in several datasheets, it might be needed to set 95 + it (otherwise it is harmless). 96 + deprecated: true 97 + 98 + required: 99 + - reg 100 + - nand-rb 101 + 102 + unevaluatedProperties: false 103 + 104 + required: 105 + - compatible 106 + - reg 107 + - interrupts 108 + - clocks 109 + 110 + allOf: 111 + - $ref: nand-controller.yaml# 112 + 113 + - if: 114 + properties: 115 + compatible: 116 + contains: 117 + const: marvell,pxa3xx-nand-controller 118 + then: 119 + required: 120 + - dmas 121 + - dma-names 122 + 123 + - if: 124 + properties: 125 + compatible: 126 + contains: 127 + const: marvell,armada-8k-nand-controller 128 + then: 129 + properties: 130 + clocks: 131 + minItems: 2 132 + 133 + clock-names: 134 + minItems: 2 135 + 136 + required: 137 + - marvell,system-controller 138 + 139 + else: 140 + properties: 141 + clocks: 142 + minItems: 1 143 + 144 + clock-names: 145 + minItems: 1 146 + 147 + 148 + unevaluatedProperties: false 149 + 150 + examples: 151 + - | 152 + #include <dt-bindings/interrupt-controller/arm-gic.h> 153 + nand_controller: nand-controller@d0000 { 154 + compatible = "marvell,armada370-nand-controller"; 155 + reg = <0xd0000 0x54>; 156 + #address-cells = <1>; 157 + #size-cells = <0>; 158 + interrupts = <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>; 159 + clocks = <&coredivclk 0>; 160 + 161 + nand@0 { 162 + reg = <0>; 163 + label = "main-storage"; 164 + nand-rb = <0>; 165 + nand-ecc-mode = "hw"; 166 + marvell,nand-keep-config; 167 + nand-on-flash-bbt; 168 + nand-ecc-strength = <4>; 169 + nand-ecc-step-size = <512>; 170 + 171 + partitions { 172 + compatible = "fixed-partitions"; 173 + #address-cells = <1>; 174 + #size-cells = <1>; 175 + 176 + partition@0 { 177 + label = "Rootfs"; 178 + reg = <0x00000000 0x40000000>; 179 + }; 180 + }; 181 + }; 182 + }; 183 + 184 + - | 185 + cp0_nand_controller: nand-controller@720000 { 186 + compatible = "marvell,armada-8k-nand-controller", 187 + "marvell,armada370-nand-controller"; 188 + reg = <0x720000 0x54>; 189 + #address-cells = <1>; 190 + #size-cells = <0>; 191 + interrupts = <115 IRQ_TYPE_LEVEL_HIGH>; 192 + clock-names = "core", "reg"; 193 + clocks = <&cp0_clk 1 2>, 194 + <&cp0_clk 1 17>; 195 + marvell,system-controller = <&cp0_syscon0>; 196 + 197 + nand@0 { 198 + reg = <0>; 199 + label = "main-storage"; 200 + nand-rb = <0>; 201 + nand-ecc-mode = "hw"; 202 + nand-ecc-strength = <8>; 203 + nand-ecc-step-size = <512>; 204 + }; 205 + }; 206 + 207 + - | 208 + nand-controller@43100000 { 209 + compatible = "marvell,pxa3xx-nand-controller"; 210 + reg = <0x43100000 90>; 211 + interrupts = <45>; 212 + clocks = <&clks 1>; 213 + clock-names = "core"; 214 + dmas = <&pdma 97 3>; 215 + dma-names = "data"; 216 + #address-cells = <1>; 217 + #size-cells = <0>; 218 + nand@0 { 219 + reg = <0>; 220 + nand-rb = <0>; 221 + nand-ecc-mode = "hw"; 222 + marvell,nand-keep-config; 223 + }; 224 + }; 225 + 226 + ...
-126
Documentation/devicetree/bindings/mtd/marvell-nand.txt
··· 1 - Marvell NAND Flash Controller (NFC) 2 - 3 - Required properties: 4 - - compatible: can be one of the following: 5 - * "marvell,armada-8k-nand-controller" 6 - * "marvell,armada370-nand-controller" 7 - * "marvell,pxa3xx-nand-controller" 8 - * "marvell,armada-8k-nand" (deprecated) 9 - * "marvell,armada370-nand" (deprecated) 10 - * "marvell,pxa3xx-nand" (deprecated) 11 - Compatibles marked deprecated support only the old bindings described 12 - at the bottom. 13 - - reg: NAND flash controller memory area. 14 - - #address-cells: shall be set to 1. Encode the NAND CS. 15 - - #size-cells: shall be set to 0. 16 - - interrupts: shall define the NAND controller interrupt. 17 - - clocks: shall reference the NAND controller clocks, the second one is 18 - is only needed for the Armada 7K/8K SoCs 19 - - clock-names: mandatory if there is a second clock, in this case there 20 - should be one clock named "core" and another one named "reg" 21 - - marvell,system-controller: Set to retrieve the syscon node that handles 22 - NAND controller related registers (only required with the 23 - "marvell,armada-8k-nand[-controller]" compatibles). 24 - 25 - Optional properties: 26 - - label: see partition.txt. New platforms shall omit this property. 27 - - dmas: shall reference DMA channel associated to the NAND controller. 28 - This property is only used with "marvell,pxa3xx-nand[-controller]" 29 - compatible strings. 30 - - dma-names: shall be "rxtx". 31 - This property is only used with "marvell,pxa3xx-nand[-controller]" 32 - compatible strings. 33 - 34 - Optional children nodes: 35 - Children nodes represent the available NAND chips. 36 - 37 - Required properties: 38 - - reg: shall contain the native Chip Select ids (0-3). 39 - - nand-rb: see nand-controller.yaml (0-1). 40 - 41 - Optional properties: 42 - - marvell,nand-keep-config: orders the driver not to take the timings 43 - from the core and leaving them completely untouched. Bootloader 44 - timings will then be used. 45 - - label: MTD name. 46 - - nand-on-flash-bbt: see nand-controller.yaml. 47 - - nand-ecc-mode: see nand-controller.yaml. Will use hardware ECC if not specified. 48 - - nand-ecc-algo: see nand-controller.yaml. This property is essentially useful when 49 - not using hardware ECC. Howerver, it may be added when using hardware 50 - ECC for clarification but will be ignored by the driver because ECC 51 - mode is chosen depending on the page size and the strength required by 52 - the NAND chip. This value may be overwritten with nand-ecc-strength 53 - property. 54 - - nand-ecc-strength: see nand-controller.yaml. 55 - - nand-ecc-step-size: see nand-controller.yaml. Marvell's NAND flash controller does 56 - use fixed strength (1-bit for Hamming, 16-bit for BCH), so the actual 57 - step size will shrink or grow in order to fit the required strength. 58 - Step sizes are not completely random for all and follow certain 59 - patterns described in AN-379, "Marvell SoC NFC ECC". 60 - 61 - See Documentation/devicetree/bindings/mtd/nand-controller.yaml for more details on 62 - generic bindings. 63 - 64 - 65 - Example: 66 - nand_controller: nand-controller@d0000 { 67 - compatible = "marvell,armada370-nand-controller"; 68 - reg = <0xd0000 0x54>; 69 - #address-cells = <1>; 70 - #size-cells = <0>; 71 - interrupts = <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>; 72 - clocks = <&coredivclk 0>; 73 - 74 - nand@0 { 75 - reg = <0>; 76 - label = "main-storage"; 77 - nand-rb = <0>; 78 - nand-ecc-mode = "hw"; 79 - marvell,nand-keep-config; 80 - nand-on-flash-bbt; 81 - nand-ecc-strength = <4>; 82 - nand-ecc-step-size = <512>; 83 - 84 - partitions { 85 - compatible = "fixed-partitions"; 86 - #address-cells = <1>; 87 - #size-cells = <1>; 88 - 89 - partition@0 { 90 - label = "Rootfs"; 91 - reg = <0x00000000 0x40000000>; 92 - }; 93 - }; 94 - }; 95 - }; 96 - 97 - 98 - Note on legacy bindings: One can find, in not-updated device trees, 99 - bindings slightly different than described above with other properties 100 - described below as well as the partitions node at the root of a so 101 - called "nand" node (without clear controller/chip separation). 102 - 103 - Legacy properties: 104 - - marvell,nand-enable-arbiter: To enable the arbiter, all boards blindly 105 - used it, this bit was set by the bootloader for many boards and even if 106 - it is marked reserved in several datasheets, it might be needed to set 107 - it (otherwise it is harmless) so whether or not this property is set, 108 - the bit is selected by the driver. 109 - - num-cs: Number of chip-select lines to use, all boards blindly set 1 110 - to this and for a reason, other values would have failed. The value of 111 - this property is ignored. 112 - 113 - Example: 114 - 115 - nand0: nand@43100000 { 116 - compatible = "marvell,pxa3xx-nand"; 117 - reg = <0x43100000 90>; 118 - interrupts = <45>; 119 - dmas = <&pdma 97 0>; 120 - dma-names = "rxtx"; 121 - #address-cells = <1>; 122 - marvell,nand-keep-config; 123 - marvell,nand-enable-arbiter; 124 - num-cs = <1>; 125 - /* Partitions (optional) */ 126 - };
+1 -2
Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml
··· 40 40 41 41 patternProperties: 42 42 "^nand@[a-f0-9]$": 43 - $ref: nand-chip.yaml# 43 + $ref: raw-nand-chip.yaml# 44 44 unevaluatedProperties: false 45 45 properties: 46 46 reg: 47 47 maximum: 1 48 - nand-on-flash-bbt: true 49 48 nand-ecc-mode: 50 49 const: hw 51 50
+1 -1
Documentation/devicetree/bindings/mtd/mtd.yaml
··· 12 12 13 13 properties: 14 14 $nodename: 15 - pattern: "^(flash|.*sram)(@.*)?$" 15 + pattern: "^(flash|.*sram|nand)(@.*)?$" 16 16 17 17 label: 18 18 description:
+2 -83
Documentation/devicetree/bindings/mtd/nand-controller.yaml
··· 16 16 children nodes of the NAND controller. This representation should be 17 17 enforced even for simple controllers supporting only one chip. 18 18 19 - The ECC strength and ECC step size properties define the user 20 - desires in terms of correction capability of a controller. Together, 21 - they request the ECC engine to correct {strength} bit errors per 22 - {size} bytes. 23 - 24 - The interpretation of these parameters is implementation-defined, so 25 - not all implementations must support all possible 26 - combinations. However, implementations are encouraged to further 27 - specify the value(s) they support. 28 - 29 19 properties: 30 20 $nodename: 31 21 pattern: "^nand-controller(@.*)?" ··· 41 51 42 52 patternProperties: 43 53 "^nand@[a-f0-9]$": 44 - $ref: nand-chip.yaml# 45 - 46 - properties: 47 - reg: 48 - description: 49 - Contains the chip-select IDs. 50 - 51 - nand-ecc-placement: 52 - description: 53 - Location of the ECC bytes. This location is unknown by default 54 - but can be explicitly set to "oob", if all ECC bytes are 55 - known to be stored in the OOB area, or "interleaved" if ECC 56 - bytes will be interleaved with regular data in the main area. 57 - $ref: /schemas/types.yaml#/definitions/string 58 - enum: [ oob, interleaved ] 59 - 60 - nand-bus-width: 61 - description: 62 - Bus width to the NAND chip 63 - $ref: /schemas/types.yaml#/definitions/uint32 64 - enum: [8, 16] 65 - default: 8 66 - 67 - nand-on-flash-bbt: 68 - description: 69 - With this property, the OS will search the device for a Bad 70 - Block Table (BBT). If not found, it will create one, reserve 71 - a few blocks at the end of the device to store it and update 72 - it as the device ages. Otherwise, the out-of-band area of a 73 - few pages of all the blocks will be scanned at boot time to 74 - find Bad Block Markers (BBM). These markers will help to 75 - build a volatile BBT in RAM. 76 - $ref: /schemas/types.yaml#/definitions/flag 77 - 78 - nand-ecc-maximize: 79 - description: 80 - Whether or not the ECC strength should be maximized. The 81 - maximum ECC strength is both controller and chip 82 - dependent. The ECC engine has to select the ECC config 83 - providing the best strength and taking the OOB area size 84 - constraint into account. This is particularly useful when 85 - only the in-band area is used by the upper layers, and you 86 - want to make your NAND as reliable as possible. 87 - $ref: /schemas/types.yaml#/definitions/flag 88 - 89 - nand-is-boot-medium: 90 - description: 91 - Whether or not the NAND chip is a boot medium. Drivers might 92 - use this information to select ECC algorithms supported by 93 - the boot ROM or similar restrictions. 94 - $ref: /schemas/types.yaml#/definitions/flag 95 - 96 - nand-rb: 97 - description: 98 - Contains the native Ready/Busy IDs. 99 - $ref: /schemas/types.yaml#/definitions/uint32-array 100 - 101 - rb-gpios: 102 - description: 103 - Contains one or more GPIO descriptor (the numper of descriptor 104 - depends on the number of R/B pins exposed by the flash) for the 105 - Ready/Busy pins. Active state refers to the NAND ready state and 106 - should be set to GPIOD_ACTIVE_HIGH unless the signal is inverted. 107 - 108 - wp-gpios: 109 - description: 110 - Contains one GPIO descriptor for the Write Protect pin. 111 - Active state refers to the NAND Write Protect state and should be 112 - set to GPIOD_ACTIVE_LOW unless the signal is inverted. 113 - maxItems: 1 114 - 115 - required: 116 - - reg 54 + type: object 55 + $ref: raw-nand-chip.yaml# 117 56 118 57 required: 119 58 - "#address-cells"
+1
Documentation/devicetree/bindings/mtd/partitions/partition.yaml
··· 55 55 linux,rootfs: 56 56 description: Marks partition that contains root filesystem to mount and boot 57 57 user space from 58 + type: boolean 58 59 59 60 if: 60 61 not:
+1
Documentation/devicetree/bindings/mtd/partitions/partitions.yaml
··· 21 21 - $ref: linksys,ns-partitions.yaml 22 22 - $ref: qcom,smem-part.yaml 23 23 - $ref: redboot-fis.yaml 24 + - $ref: tplink,safeloader-partitions.yaml 24 25 25 26 properties: 26 27 compatible: true
+29 -16
Documentation/devicetree/bindings/mtd/qcom,nandc.yaml
··· 34 34 patternProperties: 35 35 "^nand@[a-f0-9]$": 36 36 type: object 37 + $ref: raw-nand-chip.yaml 37 38 properties: 39 + 38 40 nand-bus-width: 39 41 const: 8 40 42 ··· 46 44 nand-ecc-step-size: 47 45 enum: 48 46 - 512 47 + 48 + qcom,boot-partitions: 49 + $ref: /schemas/types.yaml#/definitions/uint32-matrix 50 + items: 51 + items: 52 + - description: offset 53 + - description: size 54 + description: 55 + Boot partition use a different layout where the 4 bytes of spare 56 + data are not protected by ECC. Use this to declare these special 57 + partitions by defining first the offset and then the size. 58 + 59 + It's in the form of <offset1 size1 offset2 size2 offset3 ...> 60 + and should be declared in ascending order. 61 + 62 + Refer to the ipq8064 example on how to use this special binding. 63 + 64 + unevaluatedProperties: false 49 65 50 66 allOf: 51 67 - $ref: nand-controller.yaml# ··· 127 107 - qcom,ipq806x-nand 128 108 129 109 then: 130 - properties: 131 - qcom,boot-partitions: 132 - $ref: /schemas/types.yaml#/definitions/uint32-matrix 133 - items: 134 - items: 135 - - description: offset 136 - - description: size 137 - description: 138 - Boot partition use a different layout where the 4 bytes of spare 139 - data are not protected by ECC. Use this to declare these special 140 - partitions by defining first the offset and then the size. 141 - 142 - It's in the form of <offset1 size1 offset2 size2 offset3 ...> 143 - and should be declared in ascending order. 144 - 145 - Refer to the ipq8064 example on how to use this special binding. 110 + patternProperties: 111 + "^nand@[a-f0-9]$": 112 + properties: 113 + qcom,boot-partitions: true 114 + else: 115 + patternProperties: 116 + "^nand@[a-f0-9]$": 117 + properties: 118 + qcom,boot-partitions: false 146 119 147 120 required: 148 121 - compatible
+111
Documentation/devicetree/bindings/mtd/raw-nand-chip.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/mtd/raw-nand-chip.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Raw NAND Chip Common Properties 8 + 9 + maintainers: 10 + - Miquel Raynal <miquel.raynal@bootlin.com> 11 + 12 + allOf: 13 + - $ref: nand-chip.yaml# 14 + 15 + description: | 16 + The ECC strength and ECC step size properties define the user 17 + desires in terms of correction capability of a controller. Together, 18 + they request the ECC engine to correct {strength} bit errors per 19 + {size} bytes for a particular raw NAND chip. 20 + 21 + The interpretation of these parameters is implementation-defined, so 22 + not all implementations must support all possible 23 + combinations. However, implementations are encouraged to further 24 + specify the value(s) they support. 25 + 26 + properties: 27 + $nodename: 28 + pattern: "^nand@[a-f0-9]$" 29 + 30 + reg: 31 + description: 32 + Contains the chip-select IDs. 33 + 34 + nand-ecc-placement: 35 + description: 36 + Location of the ECC bytes. This location is unknown by default 37 + but can be explicitly set to "oob", if all ECC bytes are 38 + known to be stored in the OOB area, or "interleaved" if ECC 39 + bytes will be interleaved with regular data in the main area. 40 + $ref: /schemas/types.yaml#/definitions/string 41 + enum: [ oob, interleaved ] 42 + deprecated: true 43 + 44 + nand-ecc-mode: 45 + description: 46 + Legacy ECC configuration mixing the ECC engine choice and 47 + configuration. 48 + $ref: /schemas/types.yaml#/definitions/string 49 + enum: [none, soft, soft_bch, hw, hw_syndrome, on-die] 50 + deprecated: true 51 + 52 + nand-bus-width: 53 + description: 54 + Bus width to the NAND chip 55 + $ref: /schemas/types.yaml#/definitions/uint32 56 + enum: [8, 16] 57 + default: 8 58 + 59 + nand-on-flash-bbt: 60 + description: 61 + With this property, the OS will search the device for a Bad 62 + Block Table (BBT). If not found, it will create one, reserve 63 + a few blocks at the end of the device to store it and update 64 + it as the device ages. Otherwise, the out-of-band area of a 65 + few pages of all the blocks will be scanned at boot time to 66 + find Bad Block Markers (BBM). These markers will help to 67 + build a volatile BBT in RAM. 68 + $ref: /schemas/types.yaml#/definitions/flag 69 + 70 + nand-ecc-maximize: 71 + description: 72 + Whether or not the ECC strength should be maximized. The 73 + maximum ECC strength is both controller and chip 74 + dependent. The ECC engine has to select the ECC config 75 + providing the best strength and taking the OOB area size 76 + constraint into account. This is particularly useful when 77 + only the in-band area is used by the upper layers, and you 78 + want to make your NAND as reliable as possible. 79 + $ref: /schemas/types.yaml#/definitions/flag 80 + 81 + nand-is-boot-medium: 82 + description: 83 + Whether or not the NAND chip is a boot medium. Drivers might 84 + use this information to select ECC algorithms supported by 85 + the boot ROM or similar restrictions. 86 + $ref: /schemas/types.yaml#/definitions/flag 87 + 88 + nand-rb: 89 + description: 90 + Contains the native Ready/Busy IDs. 91 + $ref: /schemas/types.yaml#/definitions/uint32-array 92 + 93 + rb-gpios: 94 + description: 95 + Contains one or more GPIO descriptor (the numper of descriptor 96 + depends on the number of R/B pins exposed by the flash) for the 97 + Ready/Busy pins. Active state refers to the NAND ready state and 98 + should be set to GPIOD_ACTIVE_HIGH unless the signal is inverted. 99 + 100 + wp-gpios: 101 + description: 102 + Contains one GPIO descriptor for the Write Protect pin. 103 + Active state refers to the NAND Write Protect state and should be 104 + set to GPIOD_ACTIVE_LOW unless the signal is inverted. 105 + maxItems: 1 106 + 107 + required: 108 + - reg 109 + 110 + # This is a generic file other binding inherit from and extend 111 + additionalProperties: true
+3
Documentation/devicetree/bindings/mtd/rockchip,nand-controller.yaml
··· 57 57 patternProperties: 58 58 "^nand@[0-7]$": 59 59 type: object 60 + $ref: raw-nand-chip.yaml 60 61 properties: 61 62 reg: 62 63 minimum: 0 ··· 116 115 RK3326, PX30 117 116 118 117 Only used in combination with 'nand-is-boot-medium'. 118 + 119 + unevaluatedProperties: false 119 120 120 121 required: 121 122 - compatible
+3
Documentation/devicetree/bindings/mtd/st,stm32-fmc2-nand.yaml
··· 37 37 patternProperties: 38 38 "^nand@[a-f0-9]$": 39 39 type: object 40 + $ref: raw-nand-chip.yaml 40 41 properties: 41 42 nand-ecc-step-size: 42 43 const: 512 43 44 44 45 nand-ecc-strength: 45 46 enum: [1, 4, 8] 47 + 48 + unevaluatedProperties: false 46 49 47 50 allOf: 48 51 - $ref: nand-controller.yaml#
+2
Documentation/devicetree/bindings/mtd/ti,am654-hbmc.yaml
··· 30 30 patternProperties: 31 31 "^flash@[0-1],[0-9a-f]+$": 32 32 type: object 33 + $ref: mtd-physmap.yaml 34 + unevaluatedProperties: false 33 35 34 36 required: 35 37 - compatible
-1
MAINTAINERS
··· 12586 12586 M: Miquel Raynal <miquel.raynal@bootlin.com> 12587 12587 L: linux-mtd@lists.infradead.org 12588 12588 S: Maintained 12589 - F: Documentation/devicetree/bindings/mtd/marvell-nand.txt 12590 12589 F: drivers/mtd/nand/raw/marvell_nand.c 12591 12590 12592 12591 MARVELL OCTEON ENDPOINT DRIVER
+2 -1
drivers/mtd/chips/cfi_cmdset_0001.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Common Flash Interface support: 3 4 * Intel Extended Vendor Command Set (ID 0x0001) 4 5 * 5 - * (C) 2000 Red Hat. GPL'd 6 + * (C) 2000 Red Hat. 6 7 * 7 8 * 8 9 * 10/10/2000 Nicolas Pitre <nico@fluxnic.net>
+1 -2
drivers/mtd/chips/cfi_cmdset_0002.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Common Flash Interface support: 3 4 * AMD & Fujitsu Standard Vendor Command Set (ID 0x0002) ··· 17 16 * 25/09/2008 Christopher Moore: TopBottom fixup for many Macronix with CFI V1.0 18 17 * 19 18 * Occasionally maintained by Thayne Harbaugh tharbaugh at lnxi dot com 20 - * 21 - * This code is GPL 22 19 */ 23 20 24 21 #include <linux/module.h>
+2 -1
drivers/mtd/chips/cfi_cmdset_0020.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Common Flash Interface support: 3 4 * ST Advanced Architecture Command Set (ID 0x0020) 4 5 * 5 - * (C) 2000 Red Hat. GPL'd 6 + * (C) 2000 Red Hat. 6 7 * 7 8 * 10/10/2000 Nicolas Pitre <nico@fluxnic.net> 8 9 * - completely revamped method functions so they are aware and
+2 -1
drivers/mtd/chips/cfi_probe.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 Common Flash Interface probe code. 3 - (C) 2000 Red Hat. GPL'd. 4 + (C) 2000 Red Hat. 4 5 */ 5 6 6 7 #include <linux/module.h>
+1 -2
drivers/mtd/chips/cfi_util.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Common Flash Interface support: 3 4 * Generic utility functions not dependent on command set 4 5 * 5 6 * Copyright (C) 2002 Red Hat 6 7 * Copyright (C) 2003 STMicroelectronics Limited 7 - * 8 - * This code is covered by the GPL. 9 8 */ 10 9 11 10 #include <linux/module.h>
+1 -1
drivers/mtd/chips/gen_probe.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Routines common to all CFI-type probes. 3 4 * (C) 2001-2003 Red Hat, Inc. 4 - * GPL'd 5 5 */ 6 6 7 7 #include <linux/kernel.h>
+2 -1
drivers/mtd/chips/jedec_probe.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 Common Flash Interface probe code. 3 - (C) 2000 Red Hat. GPL'd. 4 + (C) 2000 Red Hat. 4 5 See JEDEC (http://www.jedec.org/) standard JESD21C (section 3.5) 5 6 for the standard this probe goes back to. 6 7
+2 -1
drivers/mtd/chips/map_ram.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Common code to handle map devices which are simple RAM 3 - * (C) 2000 Red Hat. GPL'd. 4 + * (C) 2000 Red Hat. 4 5 */ 5 6 6 7 #include <linux/module.h>
+2 -1
drivers/mtd/chips/map_rom.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Common code to handle map devices which are simple ROM 3 - * (C) 2000 Red Hat. GPL'd. 4 + * (C) 2000 Red Hat. 4 5 */ 5 6 6 7 #include <linux/module.h>
+6 -22
drivers/mtd/devices/st_spi_fsm.c
··· 2046 2046 return PTR_ERR(fsm->base); 2047 2047 } 2048 2048 2049 - fsm->clk = devm_clk_get(&pdev->dev, NULL); 2049 + fsm->clk = devm_clk_get_enabled(&pdev->dev, NULL); 2050 2050 if (IS_ERR(fsm->clk)) { 2051 2051 dev_err(fsm->dev, "Couldn't find EMI clock.\n"); 2052 2052 return PTR_ERR(fsm->clk); 2053 - } 2054 - 2055 - ret = clk_prepare_enable(fsm->clk); 2056 - if (ret) { 2057 - dev_err(fsm->dev, "Failed to enable EMI clock.\n"); 2058 - return ret; 2059 2053 } 2060 2054 2061 2055 mutex_init(&fsm->lock); ··· 2057 2063 ret = stfsm_init(fsm); 2058 2064 if (ret) { 2059 2065 dev_err(&pdev->dev, "Failed to initialise FSM Controller\n"); 2060 - goto err_clk_unprepare; 2066 + return ret; 2061 2067 } 2062 2068 2063 2069 stfsm_fetch_platform_configs(pdev); 2064 2070 2065 2071 /* Detect SPI FLASH device */ 2066 2072 info = stfsm_jedec_probe(fsm); 2067 - if (!info) { 2068 - ret = -ENODEV; 2069 - goto err_clk_unprepare; 2070 - } 2073 + if (!info) 2074 + return -ENODEV; 2071 2075 fsm->info = info; 2072 2076 2073 2077 /* Use device size to determine address width */ ··· 2081 2089 else 2082 2090 ret = stfsm_prepare_rwe_seqs_default(fsm); 2083 2091 if (ret) 2084 - goto err_clk_unprepare; 2092 + return ret; 2085 2093 2086 2094 fsm->mtd.name = info->name; 2087 2095 fsm->mtd.dev.parent = &pdev->dev; ··· 2104 2112 (long long)fsm->mtd.size, (long long)(fsm->mtd.size >> 20), 2105 2113 fsm->mtd.erasesize, (fsm->mtd.erasesize >> 10)); 2106 2114 2107 - ret = mtd_device_register(&fsm->mtd, NULL, 0); 2108 - if (ret) { 2109 - err_clk_unprepare: 2110 - clk_disable_unprepare(fsm->clk); 2111 - } 2112 - 2113 - return ret; 2115 + return mtd_device_register(&fsm->mtd, NULL, 0); 2114 2116 } 2115 2117 2116 2118 static int stfsm_remove(struct platform_device *pdev) ··· 2112 2126 struct stfsm *fsm = platform_get_drvdata(pdev); 2113 2127 2114 2128 WARN_ON(mtd_device_unregister(&fsm->mtd)); 2115 - 2116 - clk_disable_unprepare(fsm->clk); 2117 2129 2118 2130 return 0; 2119 2131 }
+1 -1
drivers/mtd/maps/pismo.c
··· 259 259 .driver = { 260 260 .name = "pismo", 261 261 }, 262 - .probe_new = pismo_probe, 262 + .probe = pismo_probe, 263 263 .remove = pismo_remove, 264 264 .id_table = pismo_id, 265 265 };
+21
drivers/mtd/mtdcore.c
··· 23 23 #include <linux/idr.h> 24 24 #include <linux/backing-dev.h> 25 25 #include <linux/gfp.h> 26 + #include <linux/random.h> 26 27 #include <linux/slab.h> 27 28 #include <linux/reboot.h> 28 29 #include <linux/leds.h> ··· 967 966 } 968 967 969 968 if (size > 0) { 969 + /* 970 + * The factory OTP contains thing such as a unique serial 971 + * number and is small, so let's read it out and put it 972 + * into the entropy pool. 973 + */ 974 + void *otp; 975 + 976 + otp = kmalloc(size, GFP_KERNEL); 977 + if (!otp) { 978 + err = -ENOMEM; 979 + goto err; 980 + } 981 + err = mtd_nvmem_fact_otp_reg_read(mtd, 0, otp, size); 982 + if (err < 0) { 983 + kfree(otp); 984 + goto err; 985 + } 986 + add_device_randomness(otp, err); 987 + kfree(otp); 988 + 970 989 nvmem = mtd_otp_nvmem_register(mtd, "factory-otp", size, 971 990 mtd_nvmem_fact_otp_reg_read); 972 991 if (IS_ERR(nvmem)) {
-1
drivers/mtd/mtdpart.c
··· 326 326 static int __del_mtd_partitions(struct mtd_info *mtd) 327 327 { 328 328 struct mtd_info *child, *next; 329 - LIST_HEAD(tmp_list); 330 329 int ret, err = 0; 331 330 332 331 list_for_each_entry_safe(child, next, &mtd->partitions, part.node) {
+1
drivers/mtd/nand/raw/Makefile
··· 67 67 nand-objs += nand_hynix.o 68 68 nand-objs += nand_macronix.o 69 69 nand-objs += nand_micron.o 70 + nand-objs += nand_sandisk.o 70 71 nand-objs += nand_samsung.o 71 72 nand-objs += nand_toshiba.o
-15
drivers/mtd/nand/raw/arasan-nand-controller.c
··· 973 973 nvddr = nand_get_nvddr_timings(conf); 974 974 if (IS_ERR(nvddr)) 975 975 return PTR_ERR(nvddr); 976 - 977 - /* 978 - * The controller only supports data payload requests which are 979 - * a multiple of 4. In practice, most data accesses are 4-byte 980 - * aligned and this is not an issue. However, rounding up will 981 - * simply be refused by the controller if we reached the end of 982 - * the device *and* we are using the NV-DDR interface(!). In 983 - * this situation, unaligned data requests ending at the device 984 - * boundary will confuse the controller and cannot be performed. 985 - * 986 - * This is something that happens in nand_read_subpage() when 987 - * selecting software ECC support and must be avoided. 988 - */ 989 - if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT) 990 - return -ENOTSUPP; 991 976 } else { 992 977 sdr = nand_get_sdr_timings(conf); 993 978 if (IS_ERR(sdr))
+1
drivers/mtd/nand/raw/internals.h
··· 73 73 extern const struct nand_manufacturer_ops macronix_nand_manuf_ops; 74 74 extern const struct nand_manufacturer_ops micron_nand_manuf_ops; 75 75 extern const struct nand_manufacturer_ops samsung_nand_manuf_ops; 76 + extern const struct nand_manufacturer_ops sandisk_nand_manuf_ops; 76 77 extern const struct nand_manufacturer_ops toshiba_nand_manuf_ops; 77 78 78 79 /* MLC pairing schemes */
+125 -9
drivers/mtd/nand/raw/meson_nand.c
··· 38 38 #define NFC_CMD_SCRAMBLER_DISABLE 0 39 39 #define NFC_CMD_SHORTMODE_DISABLE 0 40 40 #define NFC_CMD_RB_INT BIT(14) 41 + #define NFC_CMD_RB_INT_NO_PIN ((0xb << 10) | BIT(18) | BIT(16)) 41 42 42 43 #define NFC_CMD_GET_SIZE(x) (((x) >> 22) & GENMASK(4, 0)) 43 44 ··· 77 76 #define GENCMDIADDRH(aih, addr) ((aih) | (((addr) >> 16) & 0xffff)) 78 77 79 78 #define DMA_DIR(dir) ((dir) ? NFC_CMD_N2M : NFC_CMD_M2N) 79 + #define DMA_ADDR_ALIGN 8 80 80 81 81 #define ECC_CHECK_RETURN_FF (-1) 82 82 ··· 109 107 #define ECC_UNCORRECTABLE 0x3f 110 108 111 109 #define PER_INFO_BYTE 8 110 + 111 + #define NFC_CMD_RAW_LEN GENMASK(13, 0) 112 + 113 + #define NFC_COLUMN_ADDR_0 0 114 + #define NFC_COLUMN_ADDR_1 0 112 115 113 116 struct meson_nfc_nand_chip { 114 117 struct list_head node; ··· 186 179 u32 info_bytes; 187 180 188 181 unsigned long assigned_cs; 182 + bool no_rb_pin; 189 183 }; 190 184 191 185 enum { ··· 288 280 289 281 if (raw) { 290 282 len = mtd->writesize + mtd->oobsize; 291 - cmd = (len & GENMASK(13, 0)) | scrambler | DMA_DIR(dir); 283 + cmd = len | scrambler | DMA_DIR(dir); 292 284 writel(cmd, nfc->reg_base + NFC_REG_CMD); 293 285 return; 294 286 } ··· 400 392 } 401 393 } 402 394 403 - static int meson_nfc_queue_rb(struct meson_nfc *nfc, int timeout_ms) 395 + static int meson_nfc_wait_no_rb_pin(struct meson_nfc *nfc, int timeout_ms, 396 + bool need_cmd_read0) 397 + { 398 + u32 cmd, cfg; 399 + 400 + meson_nfc_cmd_idle(nfc, nfc->timing.twb); 401 + meson_nfc_drain_cmd(nfc); 402 + meson_nfc_wait_cmd_finish(nfc, CMD_FIFO_EMPTY_TIMEOUT); 403 + 404 + cfg = readl(nfc->reg_base + NFC_REG_CFG); 405 + cfg |= NFC_RB_IRQ_EN; 406 + writel(cfg, nfc->reg_base + NFC_REG_CFG); 407 + 408 + reinit_completion(&nfc->completion); 409 + cmd = nfc->param.chip_select | NFC_CMD_CLE | NAND_CMD_STATUS; 410 + writel(cmd, nfc->reg_base + NFC_REG_CMD); 411 + 412 + /* use the max erase time as the maximum clock for waiting R/B */ 413 + cmd = NFC_CMD_RB | NFC_CMD_RB_INT_NO_PIN | nfc->timing.tbers_max; 414 + writel(cmd, nfc->reg_base + NFC_REG_CMD); 415 + 416 + if (!wait_for_completion_timeout(&nfc->completion, 417 + msecs_to_jiffies(timeout_ms))) 418 + return -ETIMEDOUT; 419 + 420 + if (need_cmd_read0) { 421 + cmd = nfc->param.chip_select | NFC_CMD_CLE | NAND_CMD_READ0; 422 + writel(cmd, nfc->reg_base + NFC_REG_CMD); 423 + meson_nfc_drain_cmd(nfc); 424 + meson_nfc_wait_cmd_finish(nfc, CMD_FIFO_EMPTY_TIMEOUT); 425 + } 426 + 427 + return 0; 428 + } 429 + 430 + static int meson_nfc_wait_rb_pin(struct meson_nfc *nfc, int timeout_ms) 404 431 { 405 432 u32 cmd, cfg; 406 433 int ret = 0; ··· 461 418 ret = -1; 462 419 463 420 return ret; 421 + } 422 + 423 + static int meson_nfc_queue_rb(struct meson_nfc *nfc, int timeout_ms, 424 + bool need_cmd_read0) 425 + { 426 + if (nfc->no_rb_pin) { 427 + /* This mode is used when there is no wired R/B pin. 428 + * It works like 'nand_soft_waitrdy()', but instead of 429 + * polling NAND_CMD_STATUS bit in the software loop, 430 + * it will wait for interrupt - controllers checks IO 431 + * bus and when it detects NAND_CMD_STATUS on it, it 432 + * raises interrupt. After interrupt, NAND_CMD_READ0 is 433 + * sent as terminator of the ready waiting procedure if 434 + * needed (for all cases except page programming - this 435 + * is reason of 'need_cmd_read0' flag). 436 + */ 437 + return meson_nfc_wait_no_rb_pin(nfc, timeout_ms, 438 + need_cmd_read0); 439 + } else { 440 + return meson_nfc_wait_rb_pin(nfc, timeout_ms); 441 + } 464 442 } 465 443 466 444 static void meson_nfc_set_user_byte(struct nand_chip *nand, u8 *oob_buf) ··· 608 544 if (ret) 609 545 goto out; 610 546 611 - cmd = NFC_CMD_N2M | (len & GENMASK(13, 0)); 547 + cmd = NFC_CMD_N2M | len; 612 548 writel(cmd, nfc->reg_base + NFC_REG_CMD); 613 549 614 550 meson_nfc_drain_cmd(nfc); ··· 632 568 if (ret) 633 569 return ret; 634 570 635 - cmd = NFC_CMD_M2N | (len & GENMASK(13, 0)); 571 + cmd = NFC_CMD_M2N | len; 636 572 writel(cmd, nfc->reg_base + NFC_REG_CMD); 637 573 638 574 meson_nfc_drain_cmd(nfc); ··· 659 595 cmd0 = in ? NAND_CMD_READ0 : NAND_CMD_SEQIN; 660 596 nfc->cmdfifo.rw.cmd0 = cs | NFC_CMD_CLE | cmd0; 661 597 662 - addrs[0] = cs | NFC_CMD_ALE | 0; 598 + addrs[0] = cs | NFC_CMD_ALE | NFC_COLUMN_ADDR_0; 663 599 if (mtd->writesize <= 512) { 664 600 cmd_num--; 665 601 row_start = 1; 666 602 } else { 667 - addrs[1] = cs | NFC_CMD_ALE | 0; 603 + addrs[1] = cs | NFC_CMD_ALE | NFC_COLUMN_ADDR_1; 668 604 row_start = 2; 669 605 } 670 606 ··· 687 623 if (in) { 688 624 nfc->cmdfifo.rw.cmd1 = cs | NFC_CMD_CLE | NAND_CMD_READSTART; 689 625 writel(nfc->cmdfifo.rw.cmd1, nfc->reg_base + NFC_REG_CMD); 690 - meson_nfc_queue_rb(nfc, PSEC_TO_MSEC(sdr->tR_max)); 626 + meson_nfc_queue_rb(nfc, PSEC_TO_MSEC(sdr->tR_max), true); 691 627 } else { 692 628 meson_nfc_cmd_idle(nfc, nfc->timing.tadl); 693 629 } ··· 733 669 734 670 cmd = nfc->param.chip_select | NFC_CMD_CLE | NAND_CMD_PAGEPROG; 735 671 writel(cmd, nfc->reg_base + NFC_REG_CMD); 736 - meson_nfc_queue_rb(nfc, PSEC_TO_MSEC(sdr->tPROG_max)); 672 + meson_nfc_queue_rb(nfc, PSEC_TO_MSEC(sdr->tPROG_max), false); 737 673 738 674 meson_nfc_dma_buffer_release(nand, data_len, info_len, DMA_TO_DEVICE); 739 675 ··· 906 842 907 843 static bool meson_nfc_is_buffer_dma_safe(const void *buffer) 908 844 { 845 + if ((uintptr_t)buffer % DMA_ADDR_ALIGN) 846 + return false; 847 + 909 848 if (virt_addr_valid(buffer) && (!object_is_on_stack(buffer))) 910 849 return true; 911 850 return false; ··· 966 899 kfree(buf); 967 900 } 968 901 902 + static int meson_nfc_check_op(struct nand_chip *chip, 903 + const struct nand_operation *op) 904 + { 905 + int op_id; 906 + 907 + for (op_id = 0; op_id < op->ninstrs; op_id++) { 908 + const struct nand_op_instr *instr; 909 + 910 + instr = &op->instrs[op_id]; 911 + 912 + switch (instr->type) { 913 + case NAND_OP_DATA_IN_INSTR: 914 + case NAND_OP_DATA_OUT_INSTR: 915 + if (instr->ctx.data.len > NFC_CMD_RAW_LEN) 916 + return -ENOTSUPP; 917 + 918 + break; 919 + default: 920 + break; 921 + } 922 + } 923 + 924 + return 0; 925 + } 926 + 969 927 static int meson_nfc_exec_op(struct nand_chip *nand, 970 928 const struct nand_operation *op, bool check_only) 971 929 { ··· 999 907 const struct nand_op_instr *instr = NULL; 1000 908 void *buf; 1001 909 u32 op_id, delay_idle, cmd; 910 + int err; 1002 911 int i; 912 + 913 + err = meson_nfc_check_op(nand, op); 914 + if (err) 915 + return err; 1003 916 1004 917 if (check_only) 1005 918 return 0; ··· 1049 952 break; 1050 953 1051 954 case NAND_OP_WAITRDY_INSTR: 1052 - meson_nfc_queue_rb(nfc, instr->ctx.waitrdy.timeout_ms); 955 + meson_nfc_queue_rb(nfc, instr->ctx.waitrdy.timeout_ms, 956 + true); 1053 957 if (instr->delay_ns) 1054 958 meson_nfc_cmd_idle(nfc, delay_idle); 1055 959 break; ··· 1279 1181 struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand); 1280 1182 struct mtd_info *mtd = nand_to_mtd(nand); 1281 1183 int nsectors = mtd->writesize / 1024; 1184 + int raw_writesize; 1282 1185 int ret; 1283 1186 1284 1187 if (!mtd->name) { ··· 1289 1190 meson_chip->sels[0]); 1290 1191 if (!mtd->name) 1291 1192 return -ENOMEM; 1193 + } 1194 + 1195 + raw_writesize = mtd->writesize + mtd->oobsize; 1196 + if (raw_writesize > NFC_CMD_RAW_LEN) { 1197 + dev_err(nfc->dev, "too big write size in raw mode: %d > %ld\n", 1198 + raw_writesize, NFC_CMD_RAW_LEN); 1199 + return -EINVAL; 1292 1200 } 1293 1201 1294 1202 if (nand->bbt_options & NAND_BBT_USE_FLASH) ··· 1354 1248 struct mtd_info *mtd; 1355 1249 int ret, i; 1356 1250 u32 tmp, nsels; 1251 + u32 nand_rb_val = 0; 1357 1252 1358 1253 nsels = of_property_count_elems_of_size(np, "reg", sizeof(u32)); 1359 1254 if (!nsels || nsels > MAX_CE_NUM) { ··· 1393 1286 mtd = nand_to_mtd(nand); 1394 1287 mtd->owner = THIS_MODULE; 1395 1288 mtd->dev.parent = dev; 1289 + 1290 + ret = of_property_read_u32(np, "nand-rb", &nand_rb_val); 1291 + if (ret == -EINVAL) 1292 + nfc->no_rb_pin = true; 1293 + else if (ret) 1294 + return ret; 1295 + 1296 + if (nand_rb_val) 1297 + return -EINVAL; 1396 1298 1397 1299 ret = nand_scan(nand, nsels); 1398 1300 if (ret)
+4 -1
drivers/mtd/nand/raw/nand_ids.c
··· 44 44 {"TC58NVG6D2 64G 3.3V 8-bit", 45 45 { .id = {0x98, 0xde, 0x94, 0x82, 0x76, 0x56, 0x04, 0x20} }, 46 46 SZ_8K, SZ_8K, SZ_2M, 0, 8, 640, NAND_ECC_INFO(40, SZ_1K) }, 47 + {"SDTNQGAMA 64G 3.3V 8-bit", 48 + { .id = {0x45, 0xde, 0x94, 0x93, 0x76, 0x57} }, 49 + SZ_16K, SZ_8K, SZ_4M, 0, 6, 1280, NAND_ECC_INFO(40, SZ_1K) }, 47 50 {"SDTNRGAMA 64G 3.3V 8-bit", 48 51 { .id = {0x45, 0xde, 0x94, 0x93, 0x76, 0x50} }, 49 52 SZ_16K, SZ_8K, SZ_4M, 0, 6, 1280, NAND_ECC_INFO(40, SZ_1K) }, ··· 191 188 {NAND_MFR_NATIONAL, "National"}, 192 189 {NAND_MFR_RENESAS, "Renesas"}, 193 190 {NAND_MFR_SAMSUNG, "Samsung", &samsung_nand_manuf_ops}, 194 - {NAND_MFR_SANDISK, "SanDisk"}, 191 + {NAND_MFR_SANDISK, "SanDisk", &sandisk_nand_manuf_ops}, 195 192 {NAND_MFR_STMICRO, "ST Micro"}, 196 193 {NAND_MFR_TOSHIBA, "Toshiba", &toshiba_nand_manuf_ops}, 197 194 {NAND_MFR_WINBOND, "Winbond"},
+167
drivers/mtd/nand/raw/nand_macronix.c
··· 6 6 * Author: Boris Brezillon <boris.brezillon@free-electrons.com> 7 7 */ 8 8 9 + #include <linux/slab.h> 9 10 #include "linux/delay.h" 10 11 #include "internals.h" 11 12 ··· 31 30 MACRONIX_RANDOMIZER_RANDOPT) 32 31 33 32 #define MXIC_CMD_POWER_DOWN 0xB9 33 + 34 + #define ONFI_FEATURE_ADDR_30LFXG18AC_OTP 0x90 35 + #define MACRONIX_30LFXG18AC_OTP_START_PAGE 2 36 + #define MACRONIX_30LFXG18AC_OTP_PAGES 30 37 + #define MACRONIX_30LFXG18AC_OTP_PAGE_SIZE 2112 38 + #define MACRONIX_30LFXG18AC_OTP_SIZE_BYTES \ 39 + (MACRONIX_30LFXG18AC_OTP_PAGES * \ 40 + MACRONIX_30LFXG18AC_OTP_PAGE_SIZE) 41 + 42 + #define MACRONIX_30LFXG18AC_OTP_EN BIT(0) 34 43 35 44 struct nand_onfi_vendor_macronix { 36 45 u8 reserved; ··· 326 315 chip->ops.resume = mxic_nand_resume; 327 316 } 328 317 318 + static int macronix_30lfxg18ac_get_otp_info(struct mtd_info *mtd, size_t len, 319 + size_t *retlen, 320 + struct otp_info *buf) 321 + { 322 + if (len < sizeof(*buf)) 323 + return -EINVAL; 324 + 325 + /* Always report that OTP is unlocked. Reason is that this 326 + * type of flash chip doesn't provide way to check that OTP 327 + * is locked or not: subfeature parameter is implemented as 328 + * volatile register. Technically OTP region could be locked 329 + * and become readonly, but as there is no way to check it, 330 + * don't allow to lock it ('_lock_user_prot_reg' callback 331 + * always returns -EOPNOTSUPP) and thus we report that OTP 332 + * is unlocked. 333 + */ 334 + buf->locked = 0; 335 + buf->start = 0; 336 + buf->length = MACRONIX_30LFXG18AC_OTP_SIZE_BYTES; 337 + 338 + *retlen = sizeof(*buf); 339 + 340 + return 0; 341 + } 342 + 343 + static int macronix_30lfxg18ac_otp_enable(struct nand_chip *nand) 344 + { 345 + u8 feature_buf[ONFI_SUBFEATURE_PARAM_LEN] = { 0 }; 346 + 347 + feature_buf[0] = MACRONIX_30LFXG18AC_OTP_EN; 348 + return nand_set_features(nand, ONFI_FEATURE_ADDR_30LFXG18AC_OTP, 349 + feature_buf); 350 + } 351 + 352 + static int macronix_30lfxg18ac_otp_disable(struct nand_chip *nand) 353 + { 354 + u8 feature_buf[ONFI_SUBFEATURE_PARAM_LEN] = { 0 }; 355 + 356 + return nand_set_features(nand, ONFI_FEATURE_ADDR_30LFXG18AC_OTP, 357 + feature_buf); 358 + } 359 + 360 + static int __macronix_30lfxg18ac_rw_otp(struct mtd_info *mtd, 361 + loff_t offs_in_flash, 362 + size_t len, size_t *retlen, 363 + u_char *buf, bool write) 364 + { 365 + struct nand_chip *nand; 366 + size_t bytes_handled; 367 + off_t offs_in_page; 368 + u64 page; 369 + int ret; 370 + 371 + nand = mtd_to_nand(mtd); 372 + nand_select_target(nand, 0); 373 + 374 + ret = macronix_30lfxg18ac_otp_enable(nand); 375 + if (ret) 376 + goto out_otp; 377 + 378 + page = offs_in_flash; 379 + /* 'page' will be result of division. */ 380 + offs_in_page = do_div(page, MACRONIX_30LFXG18AC_OTP_PAGE_SIZE); 381 + bytes_handled = 0; 382 + 383 + while (bytes_handled < len && 384 + page < MACRONIX_30LFXG18AC_OTP_PAGES) { 385 + size_t bytes_to_handle; 386 + u64 phys_page = page + MACRONIX_30LFXG18AC_OTP_START_PAGE; 387 + 388 + bytes_to_handle = min_t(size_t, len - bytes_handled, 389 + MACRONIX_30LFXG18AC_OTP_PAGE_SIZE - 390 + offs_in_page); 391 + 392 + if (write) 393 + ret = nand_prog_page_op(nand, phys_page, offs_in_page, 394 + &buf[bytes_handled], bytes_to_handle); 395 + else 396 + ret = nand_read_page_op(nand, phys_page, offs_in_page, 397 + &buf[bytes_handled], bytes_to_handle); 398 + if (ret) 399 + goto out_otp; 400 + 401 + bytes_handled += bytes_to_handle; 402 + offs_in_page = 0; 403 + page++; 404 + } 405 + 406 + *retlen = bytes_handled; 407 + 408 + out_otp: 409 + if (ret) 410 + dev_err(&mtd->dev, "failed to perform OTP IO: %i\n", ret); 411 + 412 + ret = macronix_30lfxg18ac_otp_disable(nand); 413 + if (ret) 414 + dev_err(&mtd->dev, "failed to leave OTP mode after %s\n", 415 + write ? "write" : "read"); 416 + 417 + nand_deselect_target(nand); 418 + 419 + return ret; 420 + } 421 + 422 + static int macronix_30lfxg18ac_write_otp(struct mtd_info *mtd, loff_t to, 423 + size_t len, size_t *rlen, 424 + const u_char *buf) 425 + { 426 + return __macronix_30lfxg18ac_rw_otp(mtd, to, len, rlen, (u_char *)buf, 427 + true); 428 + } 429 + 430 + static int macronix_30lfxg18ac_read_otp(struct mtd_info *mtd, loff_t from, 431 + size_t len, size_t *rlen, 432 + u_char *buf) 433 + { 434 + return __macronix_30lfxg18ac_rw_otp(mtd, from, len, rlen, buf, false); 435 + } 436 + 437 + static int macronix_30lfxg18ac_lock_otp(struct mtd_info *mtd, loff_t from, 438 + size_t len) 439 + { 440 + /* See comment in 'macronix_30lfxg18ac_get_otp_info()'. */ 441 + return -EOPNOTSUPP; 442 + } 443 + 444 + static void macronix_nand_setup_otp(struct nand_chip *chip) 445 + { 446 + static const char * const supported_otp_models[] = { 447 + "MX30LF1G18AC", 448 + "MX30LF2G18AC", 449 + "MX30LF4G18AC", 450 + }; 451 + struct mtd_info *mtd; 452 + 453 + if (match_string(supported_otp_models, 454 + ARRAY_SIZE(supported_otp_models), 455 + chip->parameters.model) < 0) 456 + return; 457 + 458 + if (!chip->parameters.supports_set_get_features) 459 + return; 460 + 461 + bitmap_set(chip->parameters.get_feature_list, 462 + ONFI_FEATURE_ADDR_30LFXG18AC_OTP, 1); 463 + bitmap_set(chip->parameters.set_feature_list, 464 + ONFI_FEATURE_ADDR_30LFXG18AC_OTP, 1); 465 + 466 + mtd = nand_to_mtd(chip); 467 + mtd->_get_user_prot_info = macronix_30lfxg18ac_get_otp_info; 468 + mtd->_read_user_prot_reg = macronix_30lfxg18ac_read_otp; 469 + mtd->_write_user_prot_reg = macronix_30lfxg18ac_write_otp; 470 + mtd->_lock_user_prot_reg = macronix_30lfxg18ac_lock_otp; 471 + } 472 + 329 473 static int macronix_nand_init(struct nand_chip *chip) 330 474 { 331 475 if (nand_is_slc(chip)) ··· 490 324 macronix_nand_onfi_init(chip); 491 325 macronix_nand_block_protection_support(chip); 492 326 macronix_nand_deep_power_down_support(chip); 327 + macronix_nand_setup_otp(chip); 493 328 494 329 return 0; 495 330 }
+26
drivers/mtd/nand/raw/nand_sandisk.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + 3 + #include "internals.h" 4 + 5 + static int 6 + sdtnqgama_choose_interface_config(struct nand_chip *chip, 7 + struct nand_interface_config *iface) 8 + { 9 + onfi_fill_interface_config(chip, iface, NAND_SDR_IFACE, 0); 10 + 11 + return nand_choose_best_sdr_timings(chip, iface, NULL); 12 + } 13 + 14 + static int sandisk_nand_init(struct nand_chip *chip) 15 + { 16 + if (!strncmp("SDTNQGAMA", chip->parameters.model, 17 + sizeof("SDTNQGAMA") - 1)) 18 + chip->ops.choose_interface_config = 19 + &sdtnqgama_choose_interface_config; 20 + 21 + return 0; 22 + } 23 + 24 + const struct nand_manufacturer_ops sandisk_nand_manuf_ops = { 25 + .init = sandisk_nand_init, 26 + };
+10
drivers/mtd/nand/spi/gigadevice.c
··· 501 501 SPINAND_HAS_QE_BIT, 502 502 SPINAND_ECCINFO(&gd5fxgqx_variant2_ooblayout, 503 503 gd5fxgq4uexxg_ecc_get_status)), 504 + SPINAND_INFO("GD5F2GQ5xExxH", 505 + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x22), 506 + NAND_MEMORG(1, 2048, 64, 64, 2048, 40, 1, 1, 1), 507 + NAND_ECCREQ(4, 512), 508 + SPINAND_INFO_OP_VARIANTS(&read_cache_variants_2gq5, 509 + &write_cache_variants, 510 + &update_cache_variants), 511 + SPINAND_HAS_QE_BIT, 512 + SPINAND_ECCINFO(&gd5fxgqx_variant2_ooblayout, 513 + gd5fxgq4uexxg_ecc_get_status)), 504 514 }; 505 515 506 516 static const struct spinand_manufacturer_ops gigadevice_spinand_manuf_ops = {
+20
drivers/mtd/nand/spi/macronix.c
··· 299 299 SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, 300 300 mx35lf1ge4ab_ecc_get_status)), 301 301 302 + SPINAND_INFO("MX31LF2GE4BC", 303 + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x2e), 304 + NAND_MEMORG(1, 2048, 64, 64, 2048, 40, 1, 1, 1), 305 + NAND_ECCREQ(8, 512), 306 + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, 307 + &write_cache_variants, 308 + &update_cache_variants), 309 + SPINAND_HAS_QE_BIT, 310 + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, 311 + mx35lf1ge4ab_ecc_get_status)), 312 + SPINAND_INFO("MX3UF2GE4BC", 313 + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xae), 314 + NAND_MEMORG(1, 2048, 64, 64, 2048, 40, 1, 1, 1), 315 + NAND_ECCREQ(8, 512), 316 + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, 317 + &write_cache_variants, 318 + &update_cache_variants), 319 + SPINAND_HAS_QE_BIT, 320 + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, 321 + mx35lf1ge4ab_ecc_get_status)), 302 322 }; 303 323 304 324 static const struct spinand_manufacturer_ops macronix_spinand_manuf_ops = {
+1 -1
drivers/mtd/sm_ftl.c
··· 981 981 /* Update the FTL table */ 982 982 zone->lba_to_phys_table[ftl->cache_block] = write_sector; 983 983 984 - /* Write succesfull, so erase and free the old block */ 984 + /* Write successful, so erase and free the old block */ 985 985 if (block_num > 0) 986 986 sm_erase_block(ftl, zone_num, block_num, 1); 987 987