1. 09 10月, 2018 1 次提交
    • T
      mtd: spi-nor: add support to non-uniform SFDP SPI NOR flash memories · 5390a8df
      Tudor Ambarus 提交于
      Based on Cyrille Pitchen's patch https://lkml.org/lkml/2017/3/22/935.
      
      This patch is a transitional patch in introducing  the support of
      SFDP SPI memories with non-uniform erase sizes like Spansion s25fs512s.
      Non-uniform erase maps will be used later when initialized based on the
      SFDP data.
      
      Introduce the memory erase map which splits the memory array into one
      or many erase regions. Each erase region supports up to 4 erase types,
      as defined by the JEDEC JESD216B (SFDP) specification.
      
      To be backward compatible, the erase map of uniform SPI NOR flash memories
      is initialized so it contains only one erase region and this erase region
      supports only one erase command. Hence a single size is used to erase any
      sector/block of the memory.
      
      Besides, since the algorithm used to erase sectors on non-uniform SPI NOR
      flash memories is quite expensive, when possible, the erase map is tuned
      to come back to the uniform case.
      
      The 'erase with the best command, move forward and repeat' approach was
      suggested by Cristian Birsan in a brainstorm session, so:
      Suggested-by: NCristian Birsan <cristian.birsan@microchip.com>
      Signed-off-by: NTudor Ambarus <tudor.ambarus@microchip.com>
      Reviewed-by: NMarek Vasut <marek.vasut@gmail.com>
      Signed-off-by: NBoris Brezillon <boris.brezillon@bootlin.com>
      5390a8df
  2. 01 8月, 2018 2 次提交
    • M
      mtd: rawnand: allocate dynamically ONFI parameters during detection · 3d3fe3c0
      Miquel Raynal 提交于
      Now that it is possible to do dynamic allocations during the
      identification phase, convert the onfi_params structure (which is only
      needed with ONFI compliant chips) into a pointer that will be allocated
      only if needed.
      Signed-off-by: NMiquel Raynal <miquel.raynal@bootlin.com>
      Reviewed-by: NBoris Brezillon <boris.brezillon@bootlin.com>
      3d3fe3c0
    • B
      mtd: spi-nor: only apply reset hacks to broken hardware · bb276262
      Brian Norris 提交于
      Commit 59b356ff ("mtd: m25p80: restore the status of SPI flash when
      exiting") is the latest from a long history of attempts to add reboot
      handling to handle stateful addressing modes on SPI flash. Some prior
      mostly-related discussions:
      
      http://lists.infradead.org/pipermail/linux-mtd/2013-March/046343.html
      [PATCH 1/3] mtd: m25p80: utilize dedicated 4-byte addressing commands
      
      http://lists.infradead.org/pipermail/barebox/2014-September/020682.html
      [RFC] MTD m25p80 3-byte addressing and boot problem
      
      http://lists.infradead.org/pipermail/linux-mtd/2015-February/057683.html
      [PATCH 2/2] m25p80: if supported put chip to deep power down if not used
      
      Previously, attempts to add reboot-time software reset handling were
      rejected, but the latest attempt was not.
      
      Quick summary of the problem:
      Some systems (e.g., boot ROM or bootloader) assume that they can read
      initial boot code from their SPI flash using 3-byte addressing. If the
      flash is left in 4-byte mode after reset, these systems won't boot. The
      above patch provided a shutdown/remove hook to attempt to reset the
      addressing mode before we reboot. Notably, this patch misses out on
      huge classes of unexpected reboots (e.g., crashes, watchdog resets).
      
      Unfortunately, it is essentially impossible to solve this problem 100%:
      if your system doesn't know how to reset the SPI flash to power-on
      defaults at initialization time, no amount of software can really rescue
      you -- there will always be a chance of some unexpected reset that
      leaves your flash in an addressing mode that your boot sequence didn't
      expect.
      
      While it is not directly harmful to perform hacks like the
      aforementioned commit on all 4-byte addressing flash, a
      properly-designed system should not need the hack -- and in fact,
      providing this hack may mask the fact that a given system is indeed
      broken. So this patch attempts to apply this unsound hack more narrowly,
      providing a strong suggestion to developers and system designers that
      this is truly a hack. With luck, system designers can catch their errors
      early on in their development cycle, rather than applying this hack long
      term. But apparently enough systems are out in the wild that we still
      have to provide this hack.
      
      Document a new device tree property to denote systems that do not have a
      proper hardware (or software) reset mechanism, and apply the hack (with
      a loud warning) only in this case.
      Signed-off-by: NBrian Norris <computersforpeace@gmail.com>
      Reviewed-by: NGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: NBoris Brezillon <boris.brezillon@bootlin.com>
      bb276262
  3. 31 7月, 2018 5 次提交
    • M
      mtd: rawnand: allocate model parameter dynamically · 2023f1fa
      Miquel Raynal 提交于
      Thanks to the migration of all drivers to use nand_scan() and the
      related nand_controller_ops, we can now allocate data during the
      detection phase. Let's do it first for the NAND model parameter which
      is allocated in nand_detect().
      Signed-off-by: NMiquel Raynal <miquel.raynal@bootlin.com>
      Reviewed-by: NBoris Brezillon <boris.brezillon@bootlin.com>
      2023f1fa
    • M
      mtd: rawnand: do not export nand_scan_[ident|tail]() anymore · 98732da1
      Miquel Raynal 提交于
      Both nand_scan_ident() and nand_scan_tail() helpers used to be called
      directly from controller drivers that needed to tweak some ECC-related
      parameters before nand_scan_tail(). This separation prevented dynamic
      allocations during the phase of NAND identification, which was
      inconvenient.
      
      All controller drivers have been moved to use nand_scan(), in
      conjunction with the chip->ecc.[attach|detach]_chip() hooks that
      actually do the required tweaking sequence between both ident/tail
      calls, allowing programmers to use dynamic allocation as they need all
      across the scanning sequence.
      
      Declare nand_scan_[ident|tail]() statically now.
      Signed-off-by: NMiquel Raynal <miquel.raynal@bootlin.com>
      Reviewed-by: NBoris Brezillon <boris.brezillon@bootlin.com>
      98732da1
    • M
      mtd: rawnand: add hooks that may be called during nand_scan() · 05b54c7b
      Miquel Raynal 提交于
      In order to remove the limitation that forbids dynamic allocation in
      nand_scan_ident(), we must create a path that will be the same for all
      controller drivers. The idea is to use nand_scan() instead of the widely
      used nand_scan_ident()/nand_scan_tail() couple. In order to achieve
      this, controller drivers will need to adjust some parameters between
      these two functions depending on the NAND chip wired on them.
      
      This takes the form of two new hooks (->{attach,detach}_chip()) that are
      placed in a new nand_controller_ops structure, which is then attached
      to the nand_controller object at driver initialization time.
      ->attach_chip() is called between nand_scan_ident() and
      nand_scan_tail(), and ->detach_chip() is called in the error path of
      nand_scan() and in nand_cleanup().
      
      Note that some NAND controller drivers don't have a dedicated
      nand_controller object and instead rely on the default/dummy one
      embedded in nand_chip. If you're in this case and still want to
      initialize the controller ops, you'll have to manipulate
      chip->dummy_controller directly.
      
      Last but not least, it's worth mentioning that we plan to move some of
      the controller related hooks placed in nand_chip into
      nand_controller_ops to make the separation between NAND chip and NAND
      controller methods clearer.
      Signed-off-by: NMiquel Raynal <miquel.raynal@bootlin.com>
      Acked-by: NBoris Brezillon <boris.brezillon@bootlin.com>
      05b54c7b
    • M
      mtd: rawnand: better name for the controller structure · 7da45139
      Miquel Raynal 提交于
      In the raw NAND core, a NAND chip is described by a nand_chip structure,
      while a NAND controller is described with a nand_hw_control structure
      which is not very meaningful.
      
      Rename this structure nand_controller.
      
      As the structure gets renamed, it is logical to also rename the core
      function initializing it from nand_hw_control_init() to
      nand_controller_init().
      
      Lastly, the 'hwcontrol' entry of the nand_chip structure is not
      meaningful neither while it has the role of fallback when no controller
      structure is provided by the driver (the controller driver is dumb and
      can only control a single chip). Thus, it is renamed dummy_controller.
      Signed-off-by: NMiquel Raynal <miquel.raynal@bootlin.com>
      Acked-by: NBoris Brezillon <boris.brezillon@bootlin.com>
      7da45139
    • M
      mtd: rawnand: make subop helpers return unsigned values · 760c435e
      Miquel Raynal 提交于
      A report from Colin Ian King pointed a CoverityScan issue where error
      values on these helpers where not checked in the drivers. These
      helpers can error out only in case of a software bug in driver code,
      not because of a runtime/hardware error. Hence, let's WARN_ON() in this
      case and return 0 which is harmless anyway.
      
      Fixes: 8878b126 ("mtd: nand: add ->exec_op() implementation")
      Signed-off-by: NMiquel Raynal <miquel.raynal@bootlin.com>
      Reviewed-by: NBoris Brezillon <boris.brezillon@bootlin.com>
      Signed-off-by: NMiquel Raynal <miquel.raynal@bootlin.com>
      760c435e
  4. 20 7月, 2018 2 次提交
  5. 18 7月, 2018 12 次提交
  6. 02 7月, 2018 4 次提交
  7. 01 6月, 2018 1 次提交
  8. 15 5月, 2018 1 次提交
  9. 14 5月, 2018 1 次提交
  10. 09 5月, 2018 1 次提交
    • M
      mtd: rawnand.h: use nested union kernel-doc markups · a6766880
      Mauro Carvalho Chehab 提交于
      Gets rid of those warnings and better document the parameters.
      
        ./include/linux/mtd/rawnand.h:752: warning: Function parameter or member 'timings.sdr' not described in 'nand_data_interface'
        ./include/linux/mtd/rawnand.h:817: warning: Function parameter or member 'buf' not described in 'nand_op_data_instr'
        ./include/linux/mtd/rawnand.h:817: warning: Function parameter or member 'buf.in' not described in 'nand_op_data_instr'
        ./include/linux/mtd/rawnand.h:817: warning: Function parameter or member 'buf.out' not described in 'nand_op_data_instr'
        ./include/linux/mtd/rawnand.h:863: warning: Function parameter or member 'ctx' not described in 'nand_op_instr'
        ./include/linux/mtd/rawnand.h:863: warning: Function parameter or member 'ctx.cmd' not described in 'nand_op_instr'
        ./include/linux/mtd/rawnand.h:863: warning: Function parameter or member 'ctx.addr' not described in 'nand_op_instr'
        ./include/linux/mtd/rawnand.h:863: warning: Function parameter or member 'ctx.data' not described in 'nand_op_instr'
        ./include/linux/mtd/rawnand.h:863: warning: Function parameter or member 'ctx.waitrdy' not described in 'nand_op_instr'
        ./include/linux/mtd/rawnand.h:1010: warning: Function parameter or member 'ctx' not described in 'nand_op_parser_pattern_elem'
        ./include/linux/mtd/rawnand.h:1010: warning: Function parameter or member 'ctx.addr' not described in 'nand_op_parser_pattern_elem'
        ./include/linux/mtd/rawnand.h:1010: warning: Function parameter or member 'ctx.data' not described in 'nand_op_parser_pattern_elem'
        ./include/linux/mtd/rawnand.h:1313: warning: Function parameter or member 'manufacturer.desc' not described in 'nand_chip'
        ./include/linux/mtd/rawnand.h:1313: warning: Function parameter or member 'manufacturer.priv' not described in 'nand_chip'
      
        ./include/linux/mtd/rawnand.h:848: WARNING: Unexpected indentation.
      Signed-off-by: NMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: NMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: NBoris Brezillon <boris.brezillon@bootlin.com>
      a6766880
  11. 29 4月, 2018 1 次提交
  12. 24 4月, 2018 1 次提交
  13. 21 4月, 2018 1 次提交
    • N
      mtd: spi-nor: clear Winbond Extended Address Reg on switch to 3-byte addressing. · f134fbbb
      NeilBrown 提交于
      Winbond spi-nor flash 32MB and larger have an 'Extended Address
      Register' as one option for addressing beyond 16MB (Macronix
      has the same concept, Spansion has EXTADD bits in the Bank Address
      Register).
      
      According to section
         8.2.7 Write Extended Address Register (C5h)
      
      of the Winbond W25Q256FV data sheet (256M-BIT SPI flash)
      
         The Extended Address Register is only effective when the device is
         in the 3-Byte Address Mode.  When the device operates in the 4-Byte
         Address Mode (ADS=1), any command with address input of A31-A24
         will replace the Extended Address Register values. It is
         recommended to check and update the Extended Address Register if
         necessary when the device is switched from 4-Byte to 3-Byte Address
         Mode.
      
      So the documentation suggests clearing the EAR after switching to
      3-byte mode.  Experimentation shows that the EAR is *always* one after
      the switch to 3-byte mode, so clearing the EAR is mandatory at
      shutdown for a subsequent 3-byte-addressed reboot to work.
      
      Note that some SOCs (e.g. MT7621) do not assert a reset line at normal
      reboot, so we cannot rely on hardware reset.  The MT7621 does assert a
      reset line at watchdog-reset.
      Acked-by: NMarek Vasut <marek.vasut@gmail.com>
      Signed-off-by: NNeilBrown <neil@brown.name>
      Signed-off-by: NBoris Brezillon <boris.brezillon@bootlin.com>
      f134fbbb
  14. 27 3月, 2018 1 次提交
    • R
      mtd: partitions: add of_match_table parser matching for the "ofpart" type · 5b644aa0
      Rafał Miłecki 提交于
      In order to properly support compatibility strings as described in the
      bindings/mtd/partition.txt "ofpart" type should be treated as an
      indication for looking into OF. MTD should check "compatible" property
      and search for a matching parser rather than blindly trying the one
      supporting "fixed-partitions".
      
      It also means that existing "fixed-partitions" parser should get renamed
      to use a more meaningful name.
      
      This commit achievies that aim by introducing a new mtd_part_of_parse().
      It works by looking for a matching parser for every string in the
      "compatibility" property (starting with the most specific one).
      
      Please note that driver-specified parsers still take a precedence. It's
      assumed that driver providing a parser type has a good reason for that
      (e.g. having platform data with device-specific info). Also doing
      otherwise could break existing setups. The same applies to using default
      parsers (including "cmdlinepart") as some overwrite DT data with cmdline
      argument.
      
      Partition parsers can now provide an of_match_table to enable
      flash<-->parser matching via device tree as documented in the
      mtd/partition.txt.
      
      This support is currently limited to built-in parsers as it uses
      request_module() and friends. This should be sufficient for most cases
      though as compiling parsers as modules isn't a common choice.
      Signed-off-by: NBrian Norris <computersforpeace@gmail.com>
      Signed-off-by: NRafał Miłecki <rafal@milecki.pl>
      Tested-by: NPeter Rosin <peda@axentia.se>
      Reviewed-by: NRichard Weinberger <richard@nod.at>
      Signed-off-by: NBoris Brezillon <boris.brezillon@bootlin.com>
      5b644aa0
  15. 21 3月, 2018 1 次提交
  16. 20 3月, 2018 5 次提交