Commit b5e16170 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-linus-20170713' of git://git.infradead.org/linux-mtd

Pull MTD updates from Brian Norris:
 "General updates:
   - Cleanups and additional flash support for "dataflash" driver
   - new driver for mchp23k256 SPI SRAM device
   - improve handling of MTDs without eraseblocks (i.e., MTD_NO_ERASE)
   - refactor and improve "sub-partition" handling with TRX partition
     parser; partitions can now be created as sub-partitions of another
     partition

  SPINOR updates, from Cyrille Pitchen and Marek Vasut:
   - introduce support to the SPI 1-2-2 and 1-4-4 protocols.
   - introduce support to the Double Data Rate (DDR) mode.
   - introduce support to the Octo SPI protocols.
   - add support to new memory parts for Spansion, Macronix and Winbond.
   - add fixes for the Aspeed, STM32 and Cadence QSPI controler drivers.
   - clean up the st_spi_fsm driver.

  NAND updates, from Boris Brezillon:
   - addition of on-die ECC support to Micron driver
   - addition of helpers to help drivers choose most appropriate ECC
     settings
   - deletion of dead-code (cached programming and ->errstat() hook)
   - make sure drivers that do not support the SET/GET FEATURES command
     return ENOTSUPP use a dummy ->set/get_features implementation
     returning -ENOTSUPP (required for Micron on-die ECC)
   - change the semantic of ecc->write_page() for drivers setting the
     NAND_ECC_CUSTOM_PAGE_ACCESS flag
   - support exiting 'GET STATUS' command in default ->cmdfunc()
     implementations
   - change the prototype of ->setup_data_interface()

  A bunch of driver related changes:
   - various cleanup, fixes and improvements of the MTK driver
   - OMAP DT bindings fixes
   - support for ->setup_data_interface() in the fsmc driver
   - support for imx7 in the gpmi driver
   - finalization of the denali driver rework (thanks to Masahiro for
     the work he's done on this driver)
   - fix "bitflips in erased pages" handling in the ifc driver
   - addition of PM ops and dynamic timing configuration to the atmel
     driver"

* tag 'for-linus-20170713' of git://git.infradead.org/linux-mtd: (118 commits)
  Documentation: ABI: mtd: describe "offset" more precisely
  mtd: Fix check in mtd_unpoint()
  mtd: nand: mtk: release lock on error path
  mtd: st_spi_fsm: remove SPINOR_OP_RDSR2 and use SPINOR_OP_RDCR instead
  mtd: spi-nor: cqspi: remove duplicate const
  mtd: spi-nor: Add support for Spansion S25FL064L
  mtd: spi-nor: Add support for mx66u51235f
  mtd: nand: mtk: add ->setup_data_interface() hook
  mtd: nand: mtk: remove unneeded mtk_ecc_hw_init from mtk_ecc_resume
  mtd: nand: mtk: remove unneeded mtk_nfc_hw_init from mtk_nfc_resume
  mtd: nand: mtk: disable ecc irq when writing page with hwecc
  mtd: nand: mtk: fix incorrect register setting order about ecc irq
  mtd: partitions: fixup some allocate_partition() whitespace
  mtd: parsers: trx: fix pr_err format for printing offset
  MAINTAINERS: Update SPI NOR subsystem git repositories
  mtd: extract TRX parser out of bcm47xxpart into a separated module
  mtd: partitions: add support for partition parsers
  mtd: partitions: add support for subpartitions
  mtd: partitions: rename "master" to the "parent" where appropriate
  mtd: partitions: remove sysfs files when deleting all master's partitions
  ...
parents da16dd97 7d84120b
...@@ -229,6 +229,6 @@ KernelVersion: 4.1 ...@@ -229,6 +229,6 @@ KernelVersion: 4.1
Contact: linux-mtd@lists.infradead.org Contact: linux-mtd@lists.infradead.org
Description: Description:
For a partition, the offset of that partition from the start For a partition, the offset of that partition from the start
of the master device in bytes. This attribute is absent on of the parent (another partition or a flash device) in bytes.
main devices, so it can be used to distinguish between This attribute is absent on flash devices, so it can be used
partitions and devices that aren't partitions. to distinguish them from partitions.
...@@ -3,10 +3,23 @@ ...@@ -3,10 +3,23 @@
Required properties: Required properties:
- compatible : should be one of the following: - compatible : should be one of the following:
"altr,socfpga-denali-nand" - for Altera SOCFPGA "altr,socfpga-denali-nand" - for Altera SOCFPGA
"socionext,uniphier-denali-nand-v5a" - for Socionext UniPhier (v5a)
"socionext,uniphier-denali-nand-v5b" - for Socionext UniPhier (v5b)
- reg : should contain registers location and length for data and reg. - reg : should contain registers location and length for data and reg.
- reg-names: Should contain the reg names "nand_data" and "denali_reg" - reg-names: Should contain the reg names "nand_data" and "denali_reg"
- interrupts : The interrupt number. - interrupts : The interrupt number.
Optional properties:
- nand-ecc-step-size: see nand.txt for details. If present, the value must be
512 for "altr,socfpga-denali-nand"
1024 for "socionext,uniphier-denali-nand-v5a"
1024 for "socionext,uniphier-denali-nand-v5b"
- nand-ecc-strength: see nand.txt for details. Valid values are:
8, 15 for "altr,socfpga-denali-nand"
8, 16, 24 for "socionext,uniphier-denali-nand-v5a"
8, 16 for "socionext,uniphier-denali-nand-v5b"
- nand-ecc-maximize: see nand.txt for details
The device tree may optionally contain sub-nodes describing partitions of the The device tree may optionally contain sub-nodes describing partitions of the
address space. See partition.txt for more detail. address space. See partition.txt for more detail.
......
Error location module Error location module
Required properties: Required properties:
- compatible: Must be "ti,am33xx-elm" - compatible: Must be "ti,am3352-elm"
- reg: physical base address and size of the registers map. - reg: physical base address and size of the registers map.
- interrupts: Interrupt number for the elm. - interrupts: Interrupt number for the elm.
......
...@@ -5,7 +5,7 @@ the GPMC controller with a name of "nand". ...@@ -5,7 +5,7 @@ the GPMC controller with a name of "nand".
All timing relevant properties as well as generic gpmc child properties are All timing relevant properties as well as generic gpmc child properties are
explained in a separate documents - please refer to explained in a separate documents - please refer to
Documentation/devicetree/bindings/bus/ti-gpmc.txt Documentation/devicetree/bindings/memory-controllers/omap-gpmc.txt
For NAND specific properties such as ECC modes or bus width, please refer to For NAND specific properties such as ECC modes or bus width, please refer to
Documentation/devicetree/bindings/mtd/nand.txt Documentation/devicetree/bindings/mtd/nand.txt
......
...@@ -5,7 +5,7 @@ child nodes of the GPMC controller with a name of "nor". ...@@ -5,7 +5,7 @@ child nodes of the GPMC controller with a name of "nor".
All timing relevant properties as well as generic GPMC child properties are All timing relevant properties as well as generic GPMC child properties are
explained in a separate documents. Please refer to explained in a separate documents. Please refer to
Documentation/devicetree/bindings/bus/ti-gpmc.txt Documentation/devicetree/bindings/memory-controllers/omap-gpmc.txt
Required properties: Required properties:
- bank-width: Width of NOR flash in bytes. GPMC supports 8-bit and - bank-width: Width of NOR flash in bytes. GPMC supports 8-bit and
...@@ -28,7 +28,7 @@ Required properties: ...@@ -28,7 +28,7 @@ Required properties:
Optional properties: Optional properties:
- gpmc,XXX Additional GPMC timings and settings parameters. See - gpmc,XXX Additional GPMC timings and settings parameters. See
Documentation/devicetree/bindings/bus/ti-gpmc.txt Documentation/devicetree/bindings/memory-controllers/omap-gpmc.txt
Optional properties for partition table parsing: Optional properties for partition table parsing:
- #address-cells: should be set to 1 - #address-cells: should be set to 1
......
...@@ -5,7 +5,7 @@ the GPMC controller with a name of "onenand". ...@@ -5,7 +5,7 @@ the GPMC controller with a name of "onenand".
All timing relevant properties as well as generic gpmc child properties are All timing relevant properties as well as generic gpmc child properties are
explained in a separate documents - please refer to explained in a separate documents - please refer to
Documentation/devicetree/bindings/bus/ti-gpmc.txt Documentation/devicetree/bindings/memory-controllers/omap-gpmc.txt
Required properties: Required properties:
......
...@@ -4,7 +4,12 @@ The GPMI nand controller provides an interface to control the ...@@ -4,7 +4,12 @@ The GPMI nand controller provides an interface to control the
NAND flash chips. NAND flash chips.
Required properties: Required properties:
- compatible : should be "fsl,<chip>-gpmi-nand" - compatible : should be "fsl,<chip>-gpmi-nand", chip can be:
* imx23
* imx28
* imx6q
* imx6sx
* imx7d
- reg : should contain registers location and length for gpmi and bch. - reg : should contain registers location and length for gpmi and bch.
- reg-names: Should contain the reg names "gpmi-nand" and "bch" - reg-names: Should contain the reg names "gpmi-nand" and "bch"
- interrupts : BCH interrupt number. - interrupts : BCH interrupt number.
...@@ -13,6 +18,13 @@ Required properties: ...@@ -13,6 +18,13 @@ Required properties:
and GPMI DMA channel ID. and GPMI DMA channel ID.
Refer to dma.txt and fsl-mxs-dma.txt for details. Refer to dma.txt and fsl-mxs-dma.txt for details.
- dma-names: Must be "rx-tx". - dma-names: Must be "rx-tx".
- clocks : clocks phandle and clock specifier corresponding to each clock
specified in clock-names.
- clock-names : The "gpmi_io" clock is always required. Which clocks are
exactly required depends on chip:
* imx23/imx28 : "gpmi_io"
* imx6q/sx : "gpmi_io", "gpmi_apb", "gpmi_bch", "gpmi_bch_apb", "per1_bch"
* imx7d : "gpmi_io", "gpmi_bch_apb"
Optional properties: Optional properties:
- nand-on-flash-bbt: boolean to enable on flash bbt option if not - nand-on-flash-bbt: boolean to enable on flash bbt option if not
......
* MTD SPI driver for Microchip 23K256 (and similar) serial SRAM
Required properties:
- #address-cells, #size-cells : Must be present if the device has sub-nodes
representing partitions.
- compatible : Must be one of "microchip,mchp23k256" or "microchip,mchp23lcv1024"
- reg : Chip-Select number
- spi-max-frequency : Maximum frequency of the SPI bus the chip can operate at
Example:
spi-sram@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "microchip,mchp23k256";
reg = <0>;
spi-max-frequency = <20000000>;
};
...@@ -12,7 +12,8 @@ tree nodes. ...@@ -12,7 +12,8 @@ tree nodes.
The first part of NFC is NAND Controller Interface (NFI) HW. The first part of NFC is NAND Controller Interface (NFI) HW.
Required NFI properties: Required NFI properties:
- compatible: Should be "mediatek,mtxxxx-nfc". - compatible: Should be one of "mediatek,mt2701-nfc",
"mediatek,mt2712-nfc".
- reg: Base physical address and size of NFI. - reg: Base physical address and size of NFI.
- interrupts: Interrupts of NFI. - interrupts: Interrupts of NFI.
- clocks: NFI required clocks. - clocks: NFI required clocks.
...@@ -141,7 +142,7 @@ Example: ...@@ -141,7 +142,7 @@ Example:
============== ==============
Required BCH properties: Required BCH properties:
- compatible: Should be "mediatek,mtxxxx-ecc". - compatible: Should be one of "mediatek,mt2701-ecc", "mediatek,mt2712-ecc".
- reg: Base physical address and size of ECC. - reg: Base physical address and size of ECC.
- interrupts: Interrupts of ECC. - interrupts: Interrupts of ECC.
- clocks: ECC required clocks. - clocks: ECC required clocks.
......
...@@ -21,7 +21,7 @@ Optional NAND chip properties: ...@@ -21,7 +21,7 @@ Optional NAND chip properties:
- nand-ecc-mode : String, operation mode of the NAND ecc mode. - nand-ecc-mode : String, operation mode of the NAND ecc mode.
Supported values are: "none", "soft", "hw", "hw_syndrome", Supported values are: "none", "soft", "hw", "hw_syndrome",
"hw_oob_first". "hw_oob_first", "on-die".
Deprecated values: Deprecated values:
"soft_bch": use "soft" and nand-ecc-algo instead "soft_bch": use "soft" and nand-ecc-algo instead
- nand-ecc-algo: string, algorithm of NAND ECC. - nand-ecc-algo: string, algorithm of NAND ECC.
......
Representing flash partitions in devicetree Flash partitions in device tree
===============================
Partitions can be represented by sub-nodes of an mtd device. This can be used Flash devices can be partitioned into one or more functional ranges (e.g. "boot
code", "nvram", "kernel").
Different devices may be partitioned in a different ways. Some may use a fixed
flash layout set at production time. Some may use on-flash table that describes
the geometry and naming/purpose of each functional region. It is also possible
to see these methods mixed.
To assist system software in locating partitions, we allow describing which
method is used for a given flash device. To describe the method there should be
a subnode of the flash device that is named 'partitions'. It must have a
'compatible' property, which is used to identify the method to use.
We currently only document a binding for fixed layouts.
Fixed Partitions
================
Partitions can be represented by sub-nodes of a flash device. This can be used
on platforms which have strong conventions about which portions of a flash are on platforms which have strong conventions about which portions of a flash are
used for what purposes, but which don't use an on-flash partition table such used for what purposes, but which don't use an on-flash partition table such
as RedBoot. as RedBoot.
The partition table should be a subnode of the mtd node and should be named The partition table should be a subnode of the flash node and should be named
'partitions'. This node should have the following property: 'partitions'. This node should have the following property:
- compatible : (required) must be "fixed-partitions" - compatible : (required) must be "fixed-partitions"
Partitions are then defined in subnodes of the partitions node. Partitions are then defined in subnodes of the partitions node.
For backwards compatibility partitions as direct subnodes of the mtd device are For backwards compatibility partitions as direct subnodes of the flash device are
supported. This use is discouraged. supported. This use is discouraged.
NOTE: also for backwards compatibility, direct subnodes that have a compatible NOTE: also for backwards compatibility, direct subnodes that have a compatible
string are not considered partitions, as they may be used for other bindings. string are not considered partitions, as they may be used for other bindings.
#address-cells & #size-cells must both be present in the partitions subnode of the #address-cells & #size-cells must both be present in the partitions subnode of the
mtd device. There are two valid values for both: flash device. There are two valid values for both:
<1>: for partitions that require a single 32-bit cell to represent their <1>: for partitions that require a single 32-bit cell to represent their
size/address (aka the value is below 4 GiB) size/address (aka the value is below 4 GiB)
<2>: for partitions that require two 32-bit cells to represent their <2>: for partitions that require two 32-bit cells to represent their
size/address (aka the value is 4 GiB or greater). size/address (aka the value is 4 GiB or greater).
Required properties: Required properties:
- reg : The partition's offset and size within the mtd bank. - reg : The partition's offset and size within the flash
Optional properties: Optional properties:
- label : The label / name for this partition. If omitted, the label is taken - label : The label / name for this partition. If omitted, the label is taken
......
...@@ -9,7 +9,7 @@ the GPMC controller with an "ethernet" name. ...@@ -9,7 +9,7 @@ the GPMC controller with an "ethernet" name.
All timing relevant properties as well as generic GPMC child properties are All timing relevant properties as well as generic GPMC child properties are
explained in a separate documents. Please refer to explained in a separate documents. Please refer to
Documentation/devicetree/bindings/bus/ti-gpmc.txt Documentation/devicetree/bindings/memory-controllers/omap-gpmc.txt
For the properties relevant to the ethernet controller connected to the GPMC For the properties relevant to the ethernet controller connected to the GPMC
refer to the binding documentation of the device. For example, the documentation refer to the binding documentation of the device. For example, the documentation
...@@ -43,7 +43,7 @@ Required properties: ...@@ -43,7 +43,7 @@ Required properties:
Optional properties: Optional properties:
- gpmc,XXX Additional GPMC timings and settings parameters. See - gpmc,XXX Additional GPMC timings and settings parameters. See
Documentation/devicetree/bindings/bus/ti-gpmc.txt Documentation/devicetree/bindings/memory-controllers/omap-gpmc.txt
Example: Example:
......
...@@ -3974,6 +3974,12 @@ M: Pali Rohár <pali.rohar@gmail.com> ...@@ -3974,6 +3974,12 @@ M: Pali Rohár <pali.rohar@gmail.com>
S: Maintained S: Maintained
F: drivers/platform/x86/dell-wmi.c F: drivers/platform/x86/dell-wmi.c
DENALI NAND DRIVER
M: Masahiro Yamada <yamada.masahiro@socionext.com>
L: linux-mtd@lists.infradead.org
S: Supported
F: drivers/mtd/nand/denali*
DESIGNWARE USB2 DRD IP DRIVER DESIGNWARE USB2 DRD IP DRIVER
M: John Youn <johnyoun@synopsys.com> M: John Youn <johnyoun@synopsys.com>
L: linux-usb@vger.kernel.org L: linux-usb@vger.kernel.org
...@@ -12464,7 +12470,8 @@ M: Marek Vasut <marek.vasut@gmail.com> ...@@ -12464,7 +12470,8 @@ M: Marek Vasut <marek.vasut@gmail.com>
L: linux-mtd@lists.infradead.org L: linux-mtd@lists.infradead.org
W: http://www.linux-mtd.infradead.org/ W: http://www.linux-mtd.infradead.org/
Q: http://patchwork.ozlabs.org/project/linux-mtd/list/ Q: http://patchwork.ozlabs.org/project/linux-mtd/list/
T: git git://github.com/spi-nor/linux.git T: git git://git.infradead.org/linux-mtd.git spi-nor/fixes
T: git git://git.infradead.org/l2-mtd.git spi-nor/next
S: Maintained S: Maintained
F: drivers/mtd/spi-nor/ F: drivers/mtd/spi-nor/
F: include/linux/mtd/spi-nor.h F: include/linux/mtd/spi-nor.h
......
...@@ -155,6 +155,10 @@ config MTD_BCM47XX_PARTS ...@@ -155,6 +155,10 @@ config MTD_BCM47XX_PARTS
This provides partitions parser for devices based on BCM47xx This provides partitions parser for devices based on BCM47xx
boards. boards.
menu "Partition parsers"
source "drivers/mtd/parsers/Kconfig"
endmenu
comment "User Modules And Translation Layers" comment "User Modules And Translation Layers"
# #
......
...@@ -13,6 +13,7 @@ obj-$(CONFIG_MTD_AFS_PARTS) += afs.o ...@@ -13,6 +13,7 @@ obj-$(CONFIG_MTD_AFS_PARTS) += afs.o
obj-$(CONFIG_MTD_AR7_PARTS) += ar7part.o obj-$(CONFIG_MTD_AR7_PARTS) += ar7part.o
obj-$(CONFIG_MTD_BCM63XX_PARTS) += bcm63xxpart.o obj-$(CONFIG_MTD_BCM63XX_PARTS) += bcm63xxpart.o
obj-$(CONFIG_MTD_BCM47XX_PARTS) += bcm47xxpart.o obj-$(CONFIG_MTD_BCM47XX_PARTS) += bcm47xxpart.o
obj-y += parsers/
# 'Users' - code which presents functionality to userspace. # 'Users' - code which presents functionality to userspace.
obj-$(CONFIG_MTD_BLKDEVS) += mtd_blkdevs.o obj-$(CONFIG_MTD_BLKDEVS) += mtd_blkdevs.o
......
...@@ -43,7 +43,8 @@ ...@@ -43,7 +43,8 @@
#define ML_MAGIC2 0x26594131 #define ML_MAGIC2 0x26594131
#define TRX_MAGIC 0x30524448 #define TRX_MAGIC 0x30524448
#define SHSQ_MAGIC 0x71736873 /* shsq (weird ZTE H218N endianness) */ #define SHSQ_MAGIC 0x71736873 /* shsq (weird ZTE H218N endianness) */
#define UBI_EC_MAGIC 0x23494255 /* UBI# */
static const char * const trx_types[] = { "trx", NULL };
struct trx_header { struct trx_header {
uint32_t magic; uint32_t magic;
...@@ -62,89 +63,6 @@ static void bcm47xxpart_add_part(struct mtd_partition *part, const char *name, ...@@ -62,89 +63,6 @@ static void bcm47xxpart_add_part(struct mtd_partition *part, const char *name,
part->mask_flags = mask_flags; part->mask_flags = mask_flags;
} }
static const char *bcm47xxpart_trx_data_part_name(struct mtd_info *master,
size_t offset)
{
uint32_t buf;
size_t bytes_read;
int err;
err = mtd_read(master, offset, sizeof(buf), &bytes_read,
(uint8_t *)&buf);
if (err && !mtd_is_bitflip(err)) {
pr_err("mtd_read error while parsing (offset: 0x%X): %d\n",
offset, err);
goto out_default;
}
if (buf == UBI_EC_MAGIC)
return "ubi";
out_default:
return "rootfs";
}
static int bcm47xxpart_parse_trx(struct mtd_info *master,
struct mtd_partition *trx,
struct mtd_partition *parts,
size_t parts_len)
{
struct trx_header header;
size_t bytes_read;
int curr_part = 0;
int i, err;
if (parts_len < 3) {
pr_warn("No enough space to add TRX partitions!\n");
return -ENOMEM;
}
err = mtd_read(master, trx->offset, sizeof(header), &bytes_read,
(uint8_t *)&header);
if (err && !mtd_is_bitflip(err)) {
pr_err("mtd_read error while reading TRX header: %d\n", err);
return err;
}
i = 0;
/* We have LZMA loader if offset[2] points to sth */
if (header.offset[2]) {
bcm47xxpart_add_part(&parts[curr_part++], "loader",
trx->offset + header.offset[i], 0);
i++;
}
if (header.offset[i]) {
bcm47xxpart_add_part(&parts[curr_part++], "linux",
trx->offset + header.offset[i], 0);
i++;
}
if (header.offset[i]) {
size_t offset = trx->offset + header.offset[i];
const char *name = bcm47xxpart_trx_data_part_name(master,
offset);
bcm47xxpart_add_part(&parts[curr_part++], name, offset, 0);
i++;
}
/*
* Assume that every partition ends at the beginning of the one it is
* followed by.
*/
for (i = 0; i < curr_part; i++) {
u64 next_part_offset = (i < curr_part - 1) ?
parts[i + 1].offset :
trx->offset + trx->size;
parts[i].size = next_part_offset - parts[i].offset;
}
return curr_part;
}
/** /**
* bcm47xxpart_bootpartition - gets index of TRX partition used by bootloader * bcm47xxpart_bootpartition - gets index of TRX partition used by bootloader
* *
...@@ -362,17 +280,10 @@ static int bcm47xxpart_parse(struct mtd_info *master, ...@@ -362,17 +280,10 @@ static int bcm47xxpart_parse(struct mtd_info *master,
for (i = 0; i < trx_num; i++) { for (i = 0; i < trx_num; i++) {
struct mtd_partition *trx = &parts[trx_parts[i]]; struct mtd_partition *trx = &parts[trx_parts[i]];
if (i == bcm47xxpart_bootpartition()) { if (i == bcm47xxpart_bootpartition())
int num_parts; trx->types = trx_types;
else
num_parts = bcm47xxpart_parse_trx(master, trx,
parts + curr_part,
BCM47XXPART_MAX_PARTS - curr_part);
if (num_parts > 0)
curr_part += num_parts;
} else {
trx->name = "failsafe"; trx->name = "failsafe";
}
} }
*pparts = parts; *pparts = parts;
......
...@@ -666,7 +666,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs, ...@@ -666,7 +666,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
size_t totlen = 0, thislen; size_t totlen = 0, thislen;
int ret = 0; int ret = 0;
size_t buflen = 0; size_t buflen = 0;
static char *buffer; char *buffer;
if (!ECCBUF_SIZE) { if (!ECCBUF_SIZE) {
/* We should fall back to a general writev implementation. /* We should fall back to a general writev implementation.
......
...@@ -95,6 +95,16 @@ config MTD_M25P80 ...@@ -95,6 +95,16 @@ config MTD_M25P80
if you want to specify device partitioning or to use a device which if you want to specify device partitioning or to use a device which
doesn't support the JEDEC ID instruction. doesn't support the JEDEC ID instruction.
config MTD_MCHP23K256
tristate "Microchip 23K256 SRAM"
depends on SPI_MASTER
help
This enables access to Microchip 23K256 SRAM chips, using SPI.
Set up your spi devices with the right board-specific
platform data, or a device tree description if you want to
specify device partitioning
config MTD_SPEAR_SMI config MTD_SPEAR_SMI
tristate "SPEAR MTD NOR Support through SMI controller" tristate "SPEAR MTD NOR Support through SMI controller"
depends on PLAT_SPEAR depends on PLAT_SPEAR
......
...@@ -12,6 +12,7 @@ obj-$(CONFIG_MTD_LART) += lart.o ...@@ -12,6 +12,7 @@ obj-$(CONFIG_MTD_LART) += lart.o
obj-$(CONFIG_MTD_BLOCK2MTD) += block2mtd.o obj-$(CONFIG_MTD_BLOCK2MTD) += block2mtd.o
obj-$(CONFIG_MTD_DATAFLASH) += mtd_dataflash.o obj-$(CONFIG_MTD_DATAFLASH) += mtd_dataflash.o
obj-$(CONFIG_MTD_M25P80) += m25p80.o obj-$(CONFIG_MTD_M25P80) += m25p80.o
obj-$(CONFIG_MTD_MCHP23K256) += mchp23k256.o
obj-$(CONFIG_MTD_SPEAR_SMI) += spear_smi.o obj-$(CONFIG_MTD_SPEAR_SMI) += spear_smi.o
obj-$(CONFIG_MTD_SST25L) += sst25l.o obj-$(CONFIG_MTD_SST25L) += sst25l.o
obj-$(CONFIG_MTD_BCM47XXSFLASH) += bcm47xxsflash.o obj-$(CONFIG_MTD_BCM47XXSFLASH) += bcm47xxsflash.o
......
...@@ -78,11 +78,17 @@ static ssize_t m25p80_write(struct spi_nor *nor, loff_t to, size_t len, ...@@ -78,11 +78,17 @@ static ssize_t m25p80_write(struct spi_nor *nor, loff_t to, size_t len,
{ {
struct m25p *flash = nor->priv; struct m25p *flash = nor->priv;
struct spi_device *spi = flash->spi; struct spi_device *spi = flash->spi;
struct spi_transfer t[2] = {}; unsigned int inst_nbits, addr_nbits, data_nbits, data_idx;
struct spi_transfer t[3] = {};
struct spi_message m; struct spi_message m;
int cmd_sz = m25p_cmdsz(nor); int cmd_sz = m25p_cmdsz(nor);
ssize_t ret; ssize_t ret;
/* get transfer protocols. */
inst_nbits = spi_nor_get_protocol_inst_nbits(nor->write_proto);
addr_nbits = spi_nor_get_protocol_addr_nbits(nor->write_proto);
data_nbits = spi_nor_get_protocol_data_nbits(nor->write_proto);
spi_message_init(&m); spi_message_init(&m);
if (nor->program_opcode == SPINOR_OP_AAI_WP && nor->sst_write_second) if (nor->program_opcode == SPINOR_OP_AAI_WP && nor->sst_write_second)
...@@ -92,12 +98,27 @@ static ssize_t m25p80_write(struct spi_nor *nor, loff_t to, size_t len, ...@@ -92,12 +98,27 @@ static ssize_t m25p80_write(struct spi_nor *nor, loff_t to, size_t len,
m25p_addr2cmd(nor, to, flash->command); m25p_addr2cmd(nor, to, flash->command);
t[0].tx_buf = flash->command; t[0].tx_buf = flash->command;
t[0].tx_nbits = inst_nbits;
t[0].len = cmd_sz; t[0].len = cmd_sz;
spi_message_add_tail(&t[0], &m); spi_message_add_tail(&t[0], &m);
t[1].tx_buf = buf; /* split the op code and address bytes into two transfers if needed. */
t[1].len = len; data_idx = 1;
spi_message_add_tail(&t[1], &m); if (addr_nbits != inst_nbits) {
t[0].len = 1;
t[1].tx_buf = &flash->command[1];
t[1].tx_nbits = addr_nbits;
t[1].len = cmd_sz - 1;
spi_message_add_tail(&t[1], &m);
data_idx = 2;
}
t[data_idx].tx_buf = buf;
t[data_idx].tx_nbits = data_nbits;
t[data_idx].len = len;
spi_message_add_tail(&t[data_idx], &m);
ret = spi_sync(spi, &m); ret = spi_sync(spi, &m);
if (ret) if (ret)
...@@ -109,18 +130,6 @@ static ssize_t m25p80_write(struct spi_nor *nor, loff_t to, size_t len, ...@@ -109,18 +130,6 @@ static ssize_t m25p80_write(struct spi_nor *nor, loff_t to, size_t len,
return ret; return ret;
} }
static inline unsigned int m25p80_rx_nbits(struct spi_nor *nor)
{
switch (nor->flash_read) {
case SPI_NOR_DUAL:
return 2;
case SPI_NOR_QUAD:
return 4;
default:
return 0;
}
}
/* /*
* Read an address range from the nor chip. The address range * Read an address range from the nor chip. The address range
* may be any size provided it is within the physical boundaries. * may be any size provided it is within the physical boundaries.
...@@ -130,13 +139,20 @@ static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len, ...@@ -130,13 +139,20 @@ static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
{ {
struct m25p *flash = nor->priv; struct m25p *flash = nor->priv;
struct spi_device *spi = flash->spi; struct spi_device *spi = flash->spi;
struct spi_transfer t[2]; unsigned int inst_nbits, addr_nbits, data_nbits, data_idx;
struct spi_transfer t[3];
struct spi_message m; struct spi_message m;
unsigned int dummy = nor->read_dummy; unsigned int dummy = nor->read_dummy;
ssize_t ret; ssize_t ret;
int cmd_sz;
/* get transfer protocols. */
inst_nbits = spi_nor_get_protocol_inst_nbits(nor->read_proto);
addr_nbits = spi_nor_get_protocol_addr_nbits(nor->read_proto);
data_nbits = spi_nor_get_protocol_data_nbits(nor->read_proto);
/* convert the dummy cycles to the number of bytes */ /* convert the dummy cycles to the number of bytes */
dummy /= 8; dummy = (dummy * addr_nbits) / 8;
if (spi_flash_read_supported(spi)) { if (spi_flash_read_supported(spi)) {
struct spi_flash_read_message msg; struct spi_flash_read_message msg;
...@@ -149,10 +165,9 @@ static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len, ...@@ -149,10 +165,9 @@ static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
msg.read_opcode = nor->read_opcode; msg.read_opcode = nor->read_opcode;
msg.addr_width = nor->addr_width; msg.addr_width = nor->addr_width;
msg.dummy_bytes = dummy; msg.dummy_bytes = dummy;
/* TODO: Support other combinations */ msg.opcode_nbits = inst_nbits;
msg.opcode_nbits = SPI_NBITS_SINGLE; msg.addr_nbits = addr_nbits;
msg.addr_nbits = SPI_NBITS_SINGLE; msg.data_nbits = data_nbits;
msg.data_nbits = m25p80_rx_nbits(nor);
ret = spi_flash_read(spi, &msg); ret = spi_flash_read(spi, &msg);
if (ret < 0) if (ret < 0)
...@@ -167,20 +182,45 @@ static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len, ...@@ -167,20 +182,45 @@ static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
m25p_addr2cmd(nor, from, flash->command); m25p_addr2cmd(nor, from, flash->command);
t[0].tx_buf = flash->command; t[0].tx_buf = flash->command;
t[0].tx_nbits = inst_nbits;
t[0].len = m25p_cmdsz(nor) + dummy; t[0].len = m25p_cmdsz(nor) + dummy;
spi_message_add_tail(&t[0], &m); spi_message_add_tail(&t[0], &m);
t[1].rx_buf = buf; /*
t[1].rx_nbits = m25p80_rx_nbits(nor); * Set all dummy/mode cycle bits to avoid sending some manufacturer
t[1].len = min3(len, spi_max_transfer_size(spi), * specific pattern, which might make the memory enter its Continuous
spi_max_message_size(spi) - t[0].len); * Read mode by mistake.
spi_message_add_tail(&t[1], &m); * Based on the different mode cycle bit patterns listed and described
* in the JESD216B specification, the 0xff value works for all memories
* and all manufacturers.
*/
cmd_sz = t[0].len;
memset(flash->command + cmd_sz - dummy, 0xff, dummy);
/* split the op code and address bytes into two transfers if needed. */
data_idx = 1;
if (addr_nbits != inst_nbits) {
t[0].len = 1;
t[1].tx_buf = &flash->command[1];
t[1].tx_nbits = addr_nbits;
t[1].len = cmd_sz - 1;
spi_message_add_tail(&t[1], &m);
data_idx = 2;
}
t[data_idx].rx_buf = buf;
t[data_idx].rx_nbits = data_nbits;
t[data_idx].len = min3(len, spi_max_transfer_size(spi),
spi_max_message_size(spi) - cmd_sz);
spi_message_add_tail(&t[data_idx], &m);
ret = spi_sync(spi, &m); ret = spi_sync(spi, &m);
if (ret) if (ret)
return ret; return ret;
ret = m.actual_length - m25p_cmdsz(nor) - dummy; ret = m.actual_length - cmd_sz;
if (ret < 0) if (ret < 0)
return -EIO; return -EIO;
return ret; return ret;
...@@ -196,7 +236,11 @@ static int m25p_probe(struct spi_device *spi) ...@@ -196,7 +236,11 @@ static int m25p_probe(struct spi_device *spi)
struct flash_platform_data *data; struct flash_platform_data *data;
struct m25p *flash; struct m25p *flash;
struct spi_nor *nor; struct spi_nor *nor;
enum read_mode mode = SPI_NOR_NORMAL; struct spi_nor_hwcaps hwcaps = {
.mask = SNOR_HWCAPS_READ |
SNOR_HWCAPS_READ_FAST |
SNOR_HWCAPS_PP,
};
char *flash_name; char *flash_name;
int ret; int ret;
...@@ -221,10 +265,19 @@ static int m25p_probe(struct spi_device *spi) ...@@ -221,10 +265,19 @@ static int m25p_probe(struct spi_device *spi)
spi_set_drvdata(spi, flash); spi_set_drvdata(spi, flash);
flash->spi = spi; flash->spi = spi;
if (spi->mode & SPI_RX_QUAD) if (spi->mode & SPI_RX_QUAD) {
mode = SPI_NOR_QUAD; hwcaps.mask |= SNOR_HWCAPS_READ_1_1_4;
else if (spi->mode & SPI_RX_DUAL)
mode = SPI_NOR_DUAL; if (spi->mode & SPI_TX_QUAD)
hwcaps.mask |= (SNOR_HWCAPS_READ_1_4_4 |
SNOR_HWCAPS_PP_1_1_4 |
SNOR_HWCAPS_PP_1_4_4);
} else if (spi->mode & SPI_RX_DUAL) {
hwcaps.mask |= SNOR_HWCAPS_READ_1_1_2;
if (spi->mode & SPI_TX_DUAL)
hwcaps.mask |= SNOR_HWCAPS_READ_1_2_2;
}
if (data && data->name) if (data && data->name)
nor->mtd.name = data->name; nor->mtd.name = data->name;
...@@ -241,7 +294,7 @@ static int m25p_probe(struct spi_device *spi) ...@@ -241,7 +294,7 @@ static int m25p_probe(struct spi_device *spi)
else else
flash_name = spi->modalias; flash_name = spi->modalias;
ret = spi_nor_scan(nor, flash_name, mode); ret = spi_nor_scan(nor, flash_name, &hwcaps);
if (ret) if (ret)
return ret; return ret;
......
/*
* mchp23k256.c
*
* Driver for Microchip 23k256 SPI RAM chips
*
* Copyright © 2016 Andrew Lunn <andrew@lunn.ch>
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/
#include <linux/device.h>
#include <linux/module.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/mutex.h>
#include <linux/sched.h>
#include <linux/sizes.h>
#include <linux/spi/flash.h>
#include <linux/spi/spi.h>
#include <linux/of_device.h>
#define MAX_CMD_SIZE 4
struct mchp23_caps {
u8 addr_width;
unsigned int size;
};
struct mchp23k256_flash {
struct spi_device *spi;
struct mutex lock;
struct mtd_info mtd;
const struct mchp23_caps *caps;
};
#define MCHP23K256_CMD_WRITE_STATUS 0x01
#define MCHP23K256_CMD_WRITE 0x02
#define MCHP23K256_CMD_READ 0x03
#define MCHP23K256_MODE_SEQ BIT(6)
#define to_mchp23k256_flash(x) container_of(x, struct mchp23k256_flash, mtd)
static void mchp23k256_addr2cmd(struct mchp23k256_flash *flash,
unsigned int addr, u8 *cmd)
{
int i;
/*
* Address is sent in big endian (MSB first) and we skip
* the first entry of the cmd array which contains the cmd
* opcode.
*/
for (i = flash->caps->addr_width; i > 0; i--, addr >>= 8)
cmd[i] = addr;
}
static int mchp23k256_cmdsz(struct mchp23k256_flash *flash)
{
return 1 + flash->caps->addr_width;
}
static int mchp23k256_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const unsigned char *buf)
{
struct mchp23k256_flash *flash = to_mchp23k256_flash(mtd);
struct spi_transfer transfer[2] = {};
struct spi_message message;
unsigned char command[MAX_CMD_SIZE];
spi_message_init(&message);
command[0] = MCHP23K256_CMD_WRITE;
mchp23k256_addr2cmd(flash, to, command);
transfer[0].tx_buf = command;
transfer[0].len = mchp23k256_cmdsz(flash);
spi_message_add_tail(&transfer[0], &message);
transfer[1].tx_buf = buf;
transfer[1].len = len;
spi_message_add_tail(&transfer[1], &message);
mutex_lock(&flash->lock);
spi_sync(flash->spi, &message);
if (retlen && message.actual_length > sizeof(command))
*retlen += message.actual_length - sizeof(command);
mutex_unlock(&flash->lock);
return 0;
}
static int mchp23k256_read(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, unsigned char *buf)
{
struct mchp23k256_flash *flash = to_mchp23k256_flash(mtd);
struct spi_transfer transfer[2] = {};
struct spi_message message;
unsigned char command[MAX_CMD_SIZE];
spi_message_init(&message);
memset(&transfer, 0, sizeof(transfer));
command[0] = MCHP23K256_CMD_READ;
mchp23k256_addr2cmd(flash, from, command);
transfer[0].tx_buf = command;
transfer[0].len = mchp23k256_cmdsz(flash);
spi_message_add_tail(&transfer[0], &message);
transfer[1].rx_buf = buf;
transfer[1].len = len;
spi_message_add_tail(&transfer[1], &message);
mutex_lock(&flash->lock);
spi_sync(flash->spi, &message);
if (retlen && message.actual_length > sizeof(command))
*retlen += message.actual_length - sizeof(command);
mutex_unlock(&flash->lock);
return 0;
}
/*
* Set the device into sequential mode. This allows read/writes to the
* entire SRAM in a single operation
*/
static int mchp23k256_set_mode(struct spi_device *spi)
{
struct spi_transfer transfer = {};
struct spi_message message;
unsigned char command[2];
spi_message_init(&message);
command[0] = MCHP23K256_CMD_WRITE_STATUS;
command[1] = MCHP23K256_MODE_SEQ;
transfer.tx_buf = command;
transfer.len = sizeof(command);
spi_message_add_tail(&transfer, &message);
return spi_sync(spi, &message);
}
static const struct mchp23_caps mchp23k256_caps = {
.size = SZ_32K,
.addr_width = 2,
};
static const struct mchp23_caps mchp23lcv1024_caps = {
.size = SZ_128K,
.addr_width = 3,
};
static int mchp23k256_probe(struct spi_device *spi)
{
struct mchp23k256_flash *flash;
struct flash_platform_data *data;
int err;
flash = devm_kzalloc(&spi->dev, sizeof(*flash), GFP_KERNEL);
if (!flash)
return -ENOMEM;
flash->spi = spi;
mutex_init(&flash->lock);
spi_set_drvdata(spi, flash);
err = mchp23k256_set_mode(spi);
if (err)
return err;
data = dev_get_platdata(&spi->dev);
flash->caps = of_device_get_match_data(&spi->dev);
if (!flash->caps)
flash->caps = &mchp23k256_caps;
mtd_set_of_node(&flash->mtd, spi->dev.of_node);
flash->mtd.dev.parent = &spi->dev;
flash->mtd.type = MTD_RAM;
flash->mtd.flags = MTD_CAP_RAM;
flash->mtd.writesize = 1;
flash->mtd.size = flash->caps->size;
flash->mtd._read = mchp23k256_read;
flash->mtd._write = mchp23k256_write;
err = mtd_device_register(&flash->mtd, data ? data->parts : NULL,
data ? data->nr_parts : 0);
if (err)
return err;
return 0;
}
static int mchp23k256_remove(struct spi_device *spi)
{
struct mchp23k256_flash *flash = spi_get_drvdata(spi);
return mtd_device_unregister(&flash->mtd);
}
static const struct of_device_id mchp23k256_of_table[] = {
{
.compatible = "microchip,mchp23k256",
.data = &mchp23k256_caps,
},
{
.compatible = "microchip,mchp23lcv1024",
.data = &mchp23lcv1024_caps,
},
{}
};
MODULE_DEVICE_TABLE(of, mchp23k256_of_table);
static struct spi_driver mchp23k256_driver = {
.driver = {
.name = "mchp23k256",
.of_match_table = of_match_ptr(mchp23k256_of_table),
},
.probe = mchp23k256_probe,
.remove = mchp23k256_remove,
};
module_spi_driver(mchp23k256_driver);
MODULE_DESCRIPTION("MTD SPI driver for MCHP23K256 RAM chips");
MODULE_AUTHOR("Andrew Lunn <andre@lunn.ch>");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("spi:mchp23k256");
This diff is collapsed.
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#define _MTD_SERIAL_FLASH_CMDS_H #define _MTD_SERIAL_FLASH_CMDS_H
/* Generic Flash Commands/OPCODEs */ /* Generic Flash Commands/OPCODEs */
#define SPINOR_OP_RDSR2 0x35
#define SPINOR_OP_WRVCR 0x81 #define SPINOR_OP_WRVCR 0x81
#define SPINOR_OP_RDVCR 0x85 #define SPINOR_OP_RDVCR 0x85
......
...@@ -1445,7 +1445,7 @@ static int stfsm_s25fl_config(struct stfsm *fsm) ...@@ -1445,7 +1445,7 @@ static int stfsm_s25fl_config(struct stfsm *fsm)
} }
/* Check status of 'QE' bit, update if required. */ /* Check status of 'QE' bit, update if required. */
stfsm_read_status(fsm, SPINOR_OP_RDSR2, &cr1, 1); stfsm_read_status(fsm, SPINOR_OP_RDCR, &cr1, 1);
data_pads = ((fsm->stfsm_seq_read.seq_cfg >> 16) & 0x3) + 1; data_pads = ((fsm->stfsm_seq_read.seq_cfg >> 16) & 0x3) + 1;
if (data_pads == 4) { if (data_pads == 4) {
if (!(cr1 & STFSM_S25FL_CONFIG_QE)) { if (!(cr1 & STFSM_S25FL_CONFIG_QE)) {
...@@ -1490,7 +1490,7 @@ static int stfsm_w25q_config(struct stfsm *fsm) ...@@ -1490,7 +1490,7 @@ static int stfsm_w25q_config(struct stfsm *fsm)
return ret; return ret;
/* Check status of 'QE' bit, update if required. */ /* Check status of 'QE' bit, update if required. */
stfsm_read_status(fsm, SPINOR_OP_RDSR2, &sr2, 1); stfsm_read_status(fsm, SPINOR_OP_RDCR, &sr2, 1);
data_pads = ((fsm->stfsm_seq_read.seq_cfg >> 16) & 0x3) + 1; data_pads = ((fsm->stfsm_seq_read.seq_cfg >> 16) & 0x3) + 1;
if (data_pads == 4) { if (data_pads == 4) {
if (!(sr2 & W25Q_STATUS_QE)) { if (!(sr2 & W25Q_STATUS_QE)) {
......
...@@ -59,7 +59,7 @@ int of_flash_probe_gemini(struct platform_device *pdev, ...@@ -59,7 +59,7 @@ int of_flash_probe_gemini(struct platform_device *pdev,
struct device_node *np, struct device_node *np,
struct map_info *map) struct map_info *map)
{ {
static struct regmap *rmap; struct regmap *rmap;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
u32 val; u32 val;
int ret; int ret;
......
...@@ -991,7 +991,7 @@ EXPORT_SYMBOL_GPL(mtd_point); ...@@ -991,7 +991,7 @@ EXPORT_SYMBOL_GPL(mtd_point);
/* We probably shouldn't allow XIP if the unpoint isn't a NULL */ /* We probably shouldn't allow XIP if the unpoint isn't a NULL */
int mtd_unpoint(struct mtd_info *mtd, loff_t from, size_t len) int mtd_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
{ {
if (!mtd->_point) if (!mtd->_unpoint)
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (from < 0 || from >= mtd->size || len > mtd->size - from) if (from < 0 || from >= mtd->size || len > mtd->size - from)
return -EINVAL; return -EINVAL;
......
This diff is collapsed.
...@@ -308,6 +308,7 @@ config MTD_NAND_CS553X ...@@ -308,6 +308,7 @@ config MTD_NAND_CS553X
config MTD_NAND_ATMEL config MTD_NAND_ATMEL
tristate "Support for NAND Flash / SmartMedia on AT91" tristate "Support for NAND Flash / SmartMedia on AT91"
depends on ARCH_AT91 depends on ARCH_AT91
select MFD_ATMEL_SMC
help help
Enables support for NAND Flash / Smart Media Card interface Enables support for NAND Flash / Smart Media Card interface
on Atmel AT91 processors. on Atmel AT91 processors.
...@@ -542,6 +543,7 @@ config MTD_NAND_SUNXI ...@@ -542,6 +543,7 @@ config MTD_NAND_SUNXI
config MTD_NAND_HISI504 config MTD_NAND_HISI504
tristate "Support for NAND controller on Hisilicon SoC Hip04" tristate "Support for NAND controller on Hisilicon SoC Hip04"
depends on ARCH_HISI || COMPILE_TEST
depends on HAS_DMA depends on HAS_DMA
help help
Enables support for NAND controller on Hisilicon SoC Hip04. Enables support for NAND controller on Hisilicon SoC Hip04.
...@@ -555,6 +557,7 @@ config MTD_NAND_QCOM ...@@ -555,6 +557,7 @@ config MTD_NAND_QCOM
config MTD_NAND_MTK config MTD_NAND_MTK
tristate "Support for NAND controller on MTK SoCs" tristate "Support for NAND controller on MTK SoCs"
depends on ARCH_MEDIATEK || COMPILE_TEST
depends on HAS_DMA depends on HAS_DMA
help help
Enables support for NAND controller on MTK SoCs. Enables support for NAND controller on MTK SoCs.
......
This diff is collapsed.
...@@ -392,6 +392,8 @@ int bcm47xxnflash_ops_bcm4706_init(struct bcm47xxnflash *b47n) ...@@ -392,6 +392,8 @@ int bcm47xxnflash_ops_bcm4706_init(struct bcm47xxnflash *b47n)
b47n->nand_chip.read_byte = bcm47xxnflash_ops_bcm4706_read_byte; b47n->nand_chip.read_byte = bcm47xxnflash_ops_bcm4706_read_byte;
b47n->nand_chip.read_buf = bcm47xxnflash_ops_bcm4706_read_buf; b47n->nand_chip.read_buf = bcm47xxnflash_ops_bcm4706_read_buf;
b47n->nand_chip.write_buf = bcm47xxnflash_ops_bcm4706_write_buf; b47n->nand_chip.write_buf = bcm47xxnflash_ops_bcm4706_write_buf;
b47n->nand_chip.onfi_set_features = nand_onfi_get_set_features_notsupp;
b47n->nand_chip.onfi_get_features = nand_onfi_get_set_features_notsupp;
nand_chip->chip_delay = 50; nand_chip->chip_delay = 50;
b47n->nand_chip.bbt_options = NAND_BBT_USE_FLASH; b47n->nand_chip.bbt_options = NAND_BBT_USE_FLASH;
......
...@@ -654,6 +654,8 @@ static int cafe_nand_probe(struct pci_dev *pdev, ...@@ -654,6 +654,8 @@ static int cafe_nand_probe(struct pci_dev *pdev,
cafe->nand.read_buf = cafe_read_buf; cafe->nand.read_buf = cafe_read_buf;
cafe->nand.write_buf = cafe_write_buf; cafe->nand.write_buf = cafe_write_buf;
cafe->nand.select_chip = cafe_select_chip; cafe->nand.select_chip = cafe_select_chip;
cafe->nand.onfi_set_features = nand_onfi_get_set_features_notsupp;
cafe->nand.onfi_get_features = nand_onfi_get_set_features_notsupp;
cafe->nand.chip_delay = 0; cafe->nand.chip_delay = 0;
......
...@@ -771,11 +771,14 @@ static int nand_davinci_probe(struct platform_device *pdev) ...@@ -771,11 +771,14 @@ static int nand_davinci_probe(struct platform_device *pdev)
info->chip.ecc.hwctl = nand_davinci_hwctl_4bit; info->chip.ecc.hwctl = nand_davinci_hwctl_4bit;
info->chip.ecc.bytes = 10; info->chip.ecc.bytes = 10;
info->chip.ecc.options = NAND_ECC_GENERIC_ERASED_CHECK; info->chip.ecc.options = NAND_ECC_GENERIC_ERASED_CHECK;
info->chip.ecc.algo = NAND_ECC_BCH;
} else { } else {
/* 1bit ecc hamming */
info->chip.ecc.calculate = nand_davinci_calculate_1bit; info->chip.ecc.calculate = nand_davinci_calculate_1bit;
info->chip.ecc.correct = nand_davinci_correct_1bit; info->chip.ecc.correct = nand_davinci_correct_1bit;
info->chip.ecc.hwctl = nand_davinci_hwctl_1bit; info->chip.ecc.hwctl = nand_davinci_hwctl_1bit;
info->chip.ecc.bytes = 3; info->chip.ecc.bytes = 3;
info->chip.ecc.algo = NAND_ECC_HAMMING;
} }
info->chip.ecc.size = 512; info->chip.ecc.size = 512;
info->chip.ecc.strength = pdata->ecc_bits; info->chip.ecc.strength = pdata->ecc_bits;
......
This diff is collapsed.
This diff is collapsed.
...@@ -32,10 +32,31 @@ struct denali_dt { ...@@ -32,10 +32,31 @@ struct denali_dt {
struct denali_dt_data { struct denali_dt_data {
unsigned int revision; unsigned int revision;
unsigned int caps; unsigned int caps;
const struct nand_ecc_caps *ecc_caps;
}; };
NAND_ECC_CAPS_SINGLE(denali_socfpga_ecc_caps, denali_calc_ecc_bytes,
512, 8, 15);
static const struct denali_dt_data denali_socfpga_data = { static const struct denali_dt_data denali_socfpga_data = {
.caps = DENALI_CAP_HW_ECC_FIXUP, .caps = DENALI_CAP_HW_ECC_FIXUP,
.ecc_caps = &denali_socfpga_ecc_caps,
};
NAND_ECC_CAPS_SINGLE(denali_uniphier_v5a_ecc_caps, denali_calc_ecc_bytes,
1024, 8, 16, 24);
static const struct denali_dt_data denali_uniphier_v5a_data = {
.caps = DENALI_CAP_HW_ECC_FIXUP |
DENALI_CAP_DMA_64BIT,
.ecc_caps = &denali_uniphier_v5a_ecc_caps,
};
NAND_ECC_CAPS_SINGLE(denali_uniphier_v5b_ecc_caps, denali_calc_ecc_bytes,
1024, 8, 16);
static const struct denali_dt_data denali_uniphier_v5b_data = {
.revision = 0x0501,
.caps = DENALI_CAP_HW_ECC_FIXUP |
DENALI_CAP_DMA_64BIT,
.ecc_caps = &denali_uniphier_v5b_ecc_caps,
}; };
static const struct of_device_id denali_nand_dt_ids[] = { static const struct of_device_id denali_nand_dt_ids[] = {
...@@ -43,13 +64,21 @@ static const struct of_device_id denali_nand_dt_ids[] = { ...@@ -43,13 +64,21 @@ static const struct of_device_id denali_nand_dt_ids[] = {
.compatible = "altr,socfpga-denali-nand", .compatible = "altr,socfpga-denali-nand",
.data = &denali_socfpga_data, .data = &denali_socfpga_data,
}, },
{
.compatible = "socionext,uniphier-denali-nand-v5a",
.data = &denali_uniphier_v5a_data,
},
{
.compatible = "socionext,uniphier-denali-nand-v5b",
.data = &denali_uniphier_v5b_data,
},
{ /* sentinel */ } { /* sentinel */ }
}; };
MODULE_DEVICE_TABLE(of, denali_nand_dt_ids); MODULE_DEVICE_TABLE(of, denali_nand_dt_ids);
static int denali_dt_probe(struct platform_device *pdev) static int denali_dt_probe(struct platform_device *pdev)
{ {
struct resource *denali_reg, *nand_data; struct resource *res;
struct denali_dt *dt; struct denali_dt *dt;
const struct denali_dt_data *data; const struct denali_dt_data *data;
struct denali_nand_info *denali; struct denali_nand_info *denali;
...@@ -64,9 +93,9 @@ static int denali_dt_probe(struct platform_device *pdev) ...@@ -64,9 +93,9 @@ static int denali_dt_probe(struct platform_device *pdev)
if (data) { if (data) {
denali->revision = data->revision; denali->revision = data->revision;
denali->caps = data->caps; denali->caps = data->caps;
denali->ecc_caps = data->ecc_caps;
} }
denali->platform = DT;
denali->dev = &pdev->dev; denali->dev = &pdev->dev;
denali->irq = platform_get_irq(pdev, 0); denali->irq = platform_get_irq(pdev, 0);
if (denali->irq < 0) { if (denali->irq < 0) {
...@@ -74,17 +103,15 @@ static int denali_dt_probe(struct platform_device *pdev) ...@@ -74,17 +103,15 @@ static int denali_dt_probe(struct platform_device *pdev)
return denali->irq; return denali->irq;
} }
denali_reg = platform_get_resource_byname(pdev, IORESOURCE_MEM, res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "denali_reg");
"denali_reg"); denali->reg = devm_ioremap_resource(&pdev->dev, res);
denali->flash_reg = devm_ioremap_resource(&pdev->dev, denali_reg); if (IS_ERR(denali->reg))
if (IS_ERR(denali->flash_reg)) return PTR_ERR(denali->reg);
return PTR_ERR(denali->flash_reg);
nand_data = platform_get_resource_byname(pdev, IORESOURCE_MEM, res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_data");
"nand_data"); denali->host = devm_ioremap_resource(&pdev->dev, res);
denali->flash_mem = devm_ioremap_resource(&pdev->dev, nand_data); if (IS_ERR(denali->host))
if (IS_ERR(denali->flash_mem)) return PTR_ERR(denali->host);
return PTR_ERR(denali->flash_mem);
dt->clk = devm_clk_get(&pdev->dev, NULL); dt->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(dt->clk)) { if (IS_ERR(dt->clk)) {
...@@ -93,6 +120,8 @@ static int denali_dt_probe(struct platform_device *pdev) ...@@ -93,6 +120,8 @@ static int denali_dt_probe(struct platform_device *pdev)
} }
clk_prepare_enable(dt->clk); clk_prepare_enable(dt->clk);
denali->clk_x_rate = clk_get_rate(dt->clk);
ret = denali_init(denali); ret = denali_init(denali);
if (ret) if (ret)
goto out_disable_clk; goto out_disable_clk;
......
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
#define DENALI_NAND_NAME "denali-nand-pci" #define DENALI_NAND_NAME "denali-nand-pci"
#define INTEL_CE4100 1
#define INTEL_MRST 2
/* List of platforms this NAND controller has be integrated into */ /* List of platforms this NAND controller has be integrated into */
static const struct pci_device_id denali_pci_ids[] = { static const struct pci_device_id denali_pci_ids[] = {
{ PCI_VDEVICE(INTEL, 0x0701), INTEL_CE4100 }, { PCI_VDEVICE(INTEL, 0x0701), INTEL_CE4100 },
...@@ -27,6 +30,8 @@ static const struct pci_device_id denali_pci_ids[] = { ...@@ -27,6 +30,8 @@ static const struct pci_device_id denali_pci_ids[] = {
}; };
MODULE_DEVICE_TABLE(pci, denali_pci_ids); MODULE_DEVICE_TABLE(pci, denali_pci_ids);
NAND_ECC_CAPS_SINGLE(denali_pci_ecc_caps, denali_calc_ecc_bytes, 512, 8, 15);
static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
{ {
int ret; int ret;
...@@ -45,13 +50,11 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) ...@@ -45,13 +50,11 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
} }
if (id->driver_data == INTEL_CE4100) { if (id->driver_data == INTEL_CE4100) {
denali->platform = INTEL_CE4100;
mem_base = pci_resource_start(dev, 0); mem_base = pci_resource_start(dev, 0);
mem_len = pci_resource_len(dev, 1); mem_len = pci_resource_len(dev, 1);
csr_base = pci_resource_start(dev, 1); csr_base = pci_resource_start(dev, 1);
csr_len = pci_resource_len(dev, 1); csr_len = pci_resource_len(dev, 1);
} else { } else {
denali->platform = INTEL_MRST;
csr_base = pci_resource_start(dev, 0); csr_base = pci_resource_start(dev, 0);
csr_len = pci_resource_len(dev, 0); csr_len = pci_resource_len(dev, 0);
mem_base = pci_resource_start(dev, 1); mem_base = pci_resource_start(dev, 1);
...@@ -65,6 +68,9 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) ...@@ -65,6 +68,9 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
pci_set_master(dev); pci_set_master(dev);
denali->dev = &dev->dev; denali->dev = &dev->dev;
denali->irq = dev->irq; denali->irq = dev->irq;
denali->ecc_caps = &denali_pci_ecc_caps;
denali->nand.ecc.options |= NAND_ECC_MAXIMIZE;
denali->clk_x_rate = 200000000; /* 200 MHz */
ret = pci_request_regions(dev, DENALI_NAND_NAME); ret = pci_request_regions(dev, DENALI_NAND_NAME);
if (ret) { if (ret) {
...@@ -72,14 +78,14 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) ...@@ -72,14 +78,14 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
return ret; return ret;
} }
denali->flash_reg = ioremap_nocache(csr_base, csr_len); denali->reg = ioremap_nocache(csr_base, csr_len);
if (!denali->flash_reg) { if (!denali->reg) {
dev_err(&dev->dev, "Spectra: Unable to remap memory region\n"); dev_err(&dev->dev, "Spectra: Unable to remap memory region\n");
return -ENOMEM; return -ENOMEM;
} }
denali->flash_mem = ioremap_nocache(mem_base, mem_len); denali->host = ioremap_nocache(mem_base, mem_len);
if (!denali->flash_mem) { if (!denali->host) {
dev_err(&dev->dev, "Spectra: ioremap_nocache failed!"); dev_err(&dev->dev, "Spectra: ioremap_nocache failed!");
ret = -ENOMEM; ret = -ENOMEM;
goto failed_remap_reg; goto failed_remap_reg;
...@@ -94,9 +100,9 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) ...@@ -94,9 +100,9 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
return 0; return 0;
failed_remap_mem: failed_remap_mem:
iounmap(denali->flash_mem); iounmap(denali->host);
failed_remap_reg: failed_remap_reg:
iounmap(denali->flash_reg); iounmap(denali->reg);
return ret; return ret;
} }
...@@ -106,8 +112,8 @@ static void denali_pci_remove(struct pci_dev *dev) ...@@ -106,8 +112,8 @@ static void denali_pci_remove(struct pci_dev *dev)
struct denali_nand_info *denali = pci_get_drvdata(dev); struct denali_nand_info *denali = pci_get_drvdata(dev);
denali_remove(denali); denali_remove(denali);
iounmap(denali->flash_reg); iounmap(denali->reg);
iounmap(denali->flash_mem); iounmap(denali->host);
} }
static struct pci_driver denali_pci_driver = { static struct pci_driver denali_pci_driver = {
......
...@@ -1260,6 +1260,8 @@ static void __init init_mtd_structs(struct mtd_info *mtd) ...@@ -1260,6 +1260,8 @@ static void __init init_mtd_structs(struct mtd_info *mtd)
nand->read_buf = docg4_read_buf; nand->read_buf = docg4_read_buf;
nand->write_buf = docg4_write_buf16; nand->write_buf = docg4_write_buf16;
nand->erase = docg4_erase_block; nand->erase = docg4_erase_block;
nand->onfi_set_features = nand_onfi_get_set_features_notsupp;
nand->onfi_get_features = nand_onfi_get_set_features_notsupp;
nand->ecc.read_page = docg4_read_page; nand->ecc.read_page = docg4_read_page;
nand->ecc.write_page = docg4_write_page; nand->ecc.write_page = docg4_write_page;
nand->ecc.read_page_raw = docg4_read_page_raw; nand->ecc.read_page_raw = docg4_read_page_raw;
......
...@@ -775,6 +775,8 @@ static int fsl_elbc_chip_init(struct fsl_elbc_mtd *priv) ...@@ -775,6 +775,8 @@ static int fsl_elbc_chip_init(struct fsl_elbc_mtd *priv)
chip->select_chip = fsl_elbc_select_chip; chip->select_chip = fsl_elbc_select_chip;
chip->cmdfunc = fsl_elbc_cmdfunc; chip->cmdfunc = fsl_elbc_cmdfunc;
chip->waitfunc = fsl_elbc_wait; chip->waitfunc = fsl_elbc_wait;
chip->onfi_set_features = nand_onfi_get_set_features_notsupp;
chip->onfi_get_features = nand_onfi_get_set_features_notsupp;
chip->bbt_td = &bbt_main_descr; chip->bbt_td = &bbt_main_descr;
chip->bbt_md = &bbt_mirror_descr; chip->bbt_md = &bbt_mirror_descr;
......
This diff is collapsed.
This diff is collapsed.
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "gpmi-regs.h" #include "gpmi-regs.h"
#include "bch-regs.h" #include "bch-regs.h"
static struct timing_threshod timing_default_threshold = { static struct timing_threshold timing_default_threshold = {
.max_data_setup_cycles = (BM_GPMI_TIMING0_DATA_SETUP >> .max_data_setup_cycles = (BM_GPMI_TIMING0_DATA_SETUP >>
BP_GPMI_TIMING0_DATA_SETUP), BP_GPMI_TIMING0_DATA_SETUP),
.internal_data_setup_in_ns = 0, .internal_data_setup_in_ns = 0,
...@@ -329,7 +329,7 @@ static unsigned int ns_to_cycles(unsigned int time, ...@@ -329,7 +329,7 @@ static unsigned int ns_to_cycles(unsigned int time,
static int gpmi_nfc_compute_hardware_timing(struct gpmi_nand_data *this, static int gpmi_nfc_compute_hardware_timing(struct gpmi_nand_data *this,
struct gpmi_nfc_hardware_timing *hw) struct gpmi_nfc_hardware_timing *hw)
{ {
struct timing_threshod *nfc = &timing_default_threshold; struct timing_threshold *nfc = &timing_default_threshold;
struct resources *r = &this->resources; struct resources *r = &this->resources;
struct nand_chip *nand = &this->nand; struct nand_chip *nand = &this->nand;
struct nand_timing target = this->timing; struct nand_timing target = this->timing;
...@@ -932,7 +932,7 @@ static int enable_edo_mode(struct gpmi_nand_data *this, int mode) ...@@ -932,7 +932,7 @@ static int enable_edo_mode(struct gpmi_nand_data *this, int mode)
nand->select_chip(mtd, 0); nand->select_chip(mtd, 0);
/* [1] send SET FEATURE commond to NAND */ /* [1] send SET FEATURE command to NAND */
feature[0] = mode; feature[0] = mode;
ret = nand->onfi_set_features(mtd, nand, ret = nand->onfi_set_features(mtd, nand,
ONFI_FEATURE_ADDR_TIMING_MODE, feature); ONFI_FEATURE_ADDR_TIMING_MODE, feature);
......
This diff is collapsed.
This diff is collapsed.
...@@ -764,6 +764,8 @@ static int hisi_nfc_probe(struct platform_device *pdev) ...@@ -764,6 +764,8 @@ static int hisi_nfc_probe(struct platform_device *pdev)
chip->write_buf = hisi_nfc_write_buf; chip->write_buf = hisi_nfc_write_buf;
chip->read_buf = hisi_nfc_read_buf; chip->read_buf = hisi_nfc_read_buf;
chip->chip_delay = HINFC504_CHIP_DELAY; chip->chip_delay = HINFC504_CHIP_DELAY;
chip->onfi_set_features = nand_onfi_get_set_features_notsupp;
chip->onfi_get_features = nand_onfi_get_set_features_notsupp;
hisi_nfc_host_init(host); hisi_nfc_host_init(host);
......
...@@ -205,7 +205,7 @@ static int jz4780_nand_init_ecc(struct jz4780_nand_chip *nand, struct device *de ...@@ -205,7 +205,7 @@ static int jz4780_nand_init_ecc(struct jz4780_nand_chip *nand, struct device *de
return -EINVAL; return -EINVAL;
} }
mtd->ooblayout = &nand_ooblayout_lp_ops; mtd_set_ooblayout(mtd, &nand_ooblayout_lp_ops);
return 0; return 0;
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment