1. 10 Mar, 2016 3 commits
    • Archit Taneja's avatar
      mtd: nand: Qualcomm NAND controller driver · c76b78d8
      Archit Taneja authored
      The Qualcomm NAND controller is found in SoCs like IPQ806x, MSM7xx,
      MDM9x15 series.
      
      It exists as a sub block inside the IPs EBI2 (External Bus Interface 2)
      and QPIC (Qualcomm Parallel Interface Controller). These IPs provide a
      broader interface for external slow peripheral devices such as LCD and
      NAND/NOR flash memory or SRAM like interfaces.
      
      We add support for the NAND controller found within EBI2. For the SoCs
      of our interest, we only use the NAND controller within EBI2. Therefore,
      it's safe for us to assume that the NAND controller is a standalone block
      within the SoC.
      
      The controller supports 512B, 2kB, 4kB and 8kB page 8-bit and 16-bit NAND
      flash devices. It contains a HW ECC block that supports BCH ECC (4, 8 and
      16 bit correction/step) and RS ECC(4 bit correction/step) that covers main
      and spare data. The controller contains an internal 512 byte page buffer
      to which we read/write via DMA. The EBI2 type NAND controller uses ADM DMA
      for register read/write and data transfers. The controller performs page
      reads and writes at a codeword/step level of 512 bytes. It can support up
      to 2 external chips of different configurations.
      
      The driver prepares register read and write configuration descriptors for
      each codeword, followed by data descriptors to read or write data from the
      controller's internal buffer. It uses a single ADM DMA channel that we get
      via dmaengine API. The controller requires 2 ADM CRCIs for command and
      data flow control. These are passed via DT.
      
      The ecc layout used by the controller is syndrome like, but we can't use
      the standard syndrome ecc ops because of several reasons. First, the amount
      of data bytes covered by ecc isn't same in each step. Second, writing to
      free oob space requires us writing to the entire step in which the oob
      lies. This forces us to create our own ecc ops.
      
      One more difference is how the controller accesses the bad block marker.
      The controller ignores reading the marker when ECC is enabled. ECC needs
      to be explicity disabled to read or write to the bad block marker. The
      nand_bbt helpers library hence can't access BBMs for the controller.
      For now, we skip the creation of BBT and populate chip->block_bad and
      chip->block_markbad helpers instead.
      Reviewed-by: default avatarAndy Gross <agross@codeaurora.org>
      Signed-off-by: default avatarStephen Boyd <sboyd@codeaurora.org>
      Signed-off-by: default avatarArchit Taneja <architt@codeaurora.org>
      Reviewed-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      c76b78d8
    • Archit Taneja's avatar
      dt/bindings: qcom_nandc: Add DT bindings · 438524c6
      Archit Taneja authored
      Add DT bindings document for the Qualcomm NAND controller driver.
      Reviewed-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarArchit Taneja <architt@codeaurora.org>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      438524c6
    • Archit Taneja's avatar
      mtd: nand: don't select chip in nand_chip's block_bad op · 9f3e0429
      Archit Taneja authored
      One of the arguments passed to struct nand_chip's block_bad op is
      'getchip', which, if true, is supposed to get and select the nand device,
      and later unselect and release the device.
      
      This op is intended to be replaceable by drivers. The drivers shouldn't
      be responsible for selecting/unselecting chip. Like other ops, the chip
      should already be selected before the block_bad op is called.
      
      Remove the getchip argument from the block_bad op and
      nand_block_checkbad. Move the chip selection to nand_block_isbad, since it
      is the only caller to nand_block_checkbad which requires chip selection.
      
      Modify nand_block_bad (the default function for the op) such that it
      doesn't select the chip.
      
      Remove the getchip argument from the bad_block funcs in cafe_nand,
      diskonchip and docg4 drivers.
      Reviewed-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
      Signed-off-by: default avatarArchit Taneja <architt@codeaurora.org>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      9f3e0429
  2. 08 Mar, 2016 12 commits
  3. 07 Mar, 2016 9 commits
  4. 05 Mar, 2016 3 commits
  5. 29 Feb, 2016 2 commits
    • David Woodhouse's avatar
      jffs2: Improve post-mount CRC scan efficiency · 5817b9dc
      David Woodhouse authored
      We need to finish doing the CRC checks before we can allow writes to
      happen, and we currently process the inodes in order. This means a call
      to jffs2_get_ino_cache() for each possible inode# up to c->highest_ino.
      
      There may be a lot of lookups which fail, if the inode# space is used
      sparsely. And the inode# space is *often* used sparsely, if a file
      system contains a lot of stuff that was put there in the original
      image, followed by lots of creation and deletion of new files.
      
      Instead of processing them numerically with a lookup each time, just
      walk the hash buckets instead.
      
      [fix locking typo reported by Dan Carpenter]
      Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
      5817b9dc
    • Florian Fainelli's avatar
      mtd: brcmnand: Fix v7.1 register offsets · d267aefc
      Florian Fainelli authored
      The BRCMNAND controller revision 7.1 is almost 100% compatible with the
      previous v6.0 register offset layout, except for the Correctable Error
      Reporting Threshold registers. Fix this by adding another table with the
      correct offsets for CORR_THRESHOLD and CORR_THRESHOLD_EXT.
      
      Fixes: 27c5b17c ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller")
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      d267aefc
  6. 24 Feb, 2016 1 commit
  7. 12 Feb, 2016 10 commits
    • Cyrille Pitchen's avatar
      mtd: spi-nor: remove micron_quad_enable() · 3b5394a3
      Cyrille Pitchen authored
      This patch remove the micron_quad_enable() function which force the Quad
      SPI mode. However, once this mode is enabled, the Micron memory expect ALL
      commands to use the SPI 4-4-4 protocol. Hence a failure does occur when
      calling spi_nor_wait_till_ready() right after the update of the Enhanced
      Volatile Configuration Register (EVCR) in the micron_quad_enable() as
      the SPI controller driver is not aware about the protocol change.
      
      Since there is almost no performance increase using Fast Read 4-4-4
      commands instead of Fast Read 1-1-4 commands, we rather keep on using the
      Extended SPI mode than enabling the Quad SPI mode.
      
      Let's take the example of the pretty standard use of 8 dummy cycles during
      Fast Read operations on 64KB erase sectors:
      
      Fast Read 1-1-4 requires 8 cycles for the command, then 24 cycles for the
      3byte address followed by 8 dummy clock cycles and finally 65536*2 cycles
      for the read data; so 131112 clock cycles.
      
      On the other hand the Fast Read 4-4-4 would require 2 cycles for the
      command, then 6 cycles for the 3byte address followed by 8 dummy clock
      cycles and finally 65536*2 cycles for the read data. So 131088 clock
      cycles. The theorical bandwidth increase is 0.0%.
      
      Now using Fast Read operations on 512byte pages:
      Fast Read 1-1-4 needs 8+24+8+(512*2) = 1064 clock cycles whereas Fast
      Read 4-4-4 would requires 2+6+8+(512*2) = 1040 clock cycles. Hence the
      theorical bandwidth increase is 2.3%.
      Consecutive reads for non sequential pages is not a relevant use case so
      The Quad SPI mode is not worth it.
      
      mtd_speedtest seems to confirm these figures.
      Signed-off-by: default avatarCyrille Pitchen <cyrille.pitchen@atmel.com>
      Fixes: 548cd3ab ("mtd: spi-nor: Add quad I/O support for Micron SPI NOR")
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      3b5394a3
    • Sascha Hauer's avatar
      mtd: spi-nor: Add support for s25fl116k · c0826679
      Sascha Hauer authored
      The Spansion s25fl116k is a 16MBit NOR Flash supporting dual and
      quad read operations.
      Signed-off-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      c0826679
    • Thomas Petazzoni's avatar
      mtd: nand: pxa3xx_nand: add support for partial chunks · c2cdace7
      Thomas Petazzoni authored
      This commit is needed to properly support the 8-bits ECC configuration
      with 4KB pages.
      
      When pages larger than 2 KB are used on platforms using the PXA3xx
      NAND controller, the reading/programming operations need to be split
      in chunks of 2 KBs or less because the controller FIFO is limited to
      about 2 KB (i.e a bit more than 2 KB to accommodate OOB data). Due to
      this requirement, the data layout on NAND is a bit strange, with ECC
      interleaved with data, at the end of each chunk.
      
      When a 4-bits ECC configuration is used with 4 KB pages, the physical
      data layout on the NAND looks like this:
      
      | 2048 data | 32 spare | 30 ECC | 2048 data | 32 spare | 30 ECC |
      
      So the data chunks have an equal size, 2080 bytes for each chunk,
      which the driver supports properly.
      
      When a 8-bits ECC configuration is used with 4KB pages, the physical
      data layout on the NAND looks like this:
      
      | 1024 data | 30 ECC | 1024 data | 30 ECC | 1024 data | 30 ECC | 1024 data | 30 ECC | 64 spare | 30 ECC |
      
      So, the spare area is stored in its own chunk, which has a different
      size than the other chunks. Since OOB is not used by UBIFS, the initial
      implementation of the driver has chosen to not support reading this
      additional "spare" chunk of data.
      
      Unfortunately, Marvell has chosen to store the BBT signature in the
      OOB area. Therefore, if the driver doesn't read this spare area, Linux
      has no way of finding the BBT. It thinks there is no BBT, and rewrites
      one, which U-Boot does not recognize, causing compatibility problems
      between the bootloader and the kernel in terms of NAND usage.
      
      To fix this, this commit implements the support for reading a partial
      last chunk. This support is currently only useful for the case of 8
      bits ECC with 4 KB pages, but it will be useful in the future to
      enable other configurations such as 12 bits and 16 bits ECC with 4 KB
      pages, or 8 bits ECC with 8 KB pages, etc. All those configurations
      have a "last" chunk that doesn't have the same size as the other
      chunks.
      
      In order to implement reading of the last chunk, this commit:
      
       - Adds a number of new fields to the pxa3xx_nand_info to describe how
         many full chunks and how many chunks we have, the size of full
         chunks and partial chunks, both in terms of data area and spare
         area.
      
       - Fills in the step_chunk_size and step_spare_size variables to
         describe how much data and spare should be read/written for the
         current read/program step.
      
       - Reworks the state machine to accommodate doing the additional read
         or program step when a last partial chunk is used.
      
      This commit has been tested on a Marvell Armada 398 DB board, with a
      4KB page NAND, tested in both 4 bits ECC and 8 bits ECC
      configurations. Robert Jarzmik has tested on some PXA platforms.
      Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Tested-by: default avatarRobert Jarzmik <robert.jarzmik@free.fr>
      Acked-by: default avatarEzequiel Garcia <ezequiel@vanguardiasur.com.ar>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      c2cdace7
    • Linus Walleij's avatar
      mtd: map: fix .set_vpp() documentation · 95a001f2
      Linus Walleij authored
      As of commit 876fe76d
      "mtd: maps: physmap: Add reference counter to set_vpp()"
      the comment in the header file is incorrect and misleading.
      Fix it up.
      
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Paul Parsons <lost.distance@yahoo.com>
      Fixes: 876fe76d ("mtd: maps: physmap: Add reference counter to set_vpp()")
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      95a001f2
    • Simon Arlott's avatar
      mtd: bcm63xxpart: Move NOR flash layout to a separate function · 4110fdd2
      Simon Arlott authored
      Move the NOR flash layout to a separate function to allow the NAND flash
      layout to be supported.
      Signed-off-by: default avatarSimon Arlott <simon@fire.lp0.eu>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      4110fdd2
    • Simon Arlott's avatar
      mtd: bcm63xxpart: Null terminate and validate conversion of flash strings · 2c4fd433
      Simon Arlott authored
      Strings read from flash could be missing null termination characters, or
      not contain valid integers.
      
      Null terminate the strings and check for errors when converting them to
      integers.
      
      Also validate that the addresses are at least BCM963XX_EXTENDED_SIZE
      because this will be subtracted from them.
      Signed-off-by: default avatarSimon Arlott <simon@fire.lp0.eu>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      2c4fd433
    • Simon Arlott's avatar
      mtd: bcm63xxpart: Extract read of image tag to separate function · 7fffa694
      Simon Arlott authored
      Extract image tag reading and CRC check to a separate function.
      Signed-off-by: default avatarSimon Arlott <simon@fire.lp0.eu>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      7fffa694
    • Simon Arlott's avatar
      mtd: bcm63xxpart: Remove dependency on mach-bcm63xx · 436e94a6
      Simon Arlott authored
      Read nvram directly from flash instead of using the in-memory copy that
      mach-bcm63xx has, to remove the dependency on mach-bcm63xx and allow the
      parser to work on bmips too.
      
      Rename remaining BCM63XX defines to BCM963XX as these are properties of
      the flash layout on the board.
      
      BCM963XX_DEFAULT_PSI_SIZE changes from SZ_64K to 64 because it will be
      multiplied by SZ_1K later on.
      Signed-off-by: default avatarSimon Arlott <simon@fire.lp0.eu>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      436e94a6
    • Romain Izard's avatar
      mtd: atmel_nand: Support 32-bit ECC strength · 94248462
      Romain Izard authored
      As the SAMA5D2 controller supports the 32-bit ECC strength, accept it
      as a valid setting when required by the device tree or the NAND
      parameter page.
      
      Then configure the controller to use this new setting.
      
      For the binding:
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarRomain Izard <romain.izard.pro@gmail.com>
      Tested-by: default avatarWenyou Yang <wenyou.yang@atmel.com>
      Reviewed-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      94248462
    • Romain Izard's avatar
      mtd: atmel_nand: Support PMECC on SAMA5D2 · 55750756
      Romain Izard authored
      Starting with the SAMA5D2, there is a new revision of the Atmel PMECC
      controller that can correct 32 bits in each sector. This controller is
      not 100% compatible with the previous revision that corrected a maximum
      of 24 bits by sector, as some register addresses overlap.
      
      Using information from the device tree, we can configure the driver to
      work with both versions.
      
      For the binding:
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Tested-by: default avatarWenyou Yang <wenyou.yang@atmel.com>
      Reviewed-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
      Signed-off-by: default avatarRomain Izard <romain.izard.pro@gmail.com>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      55750756