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 1 次提交
    • 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. 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
  4. 13 12月, 2017 2 次提交
  5. 11 10月, 2017 1 次提交
    • K
      mtd: spi-nor: add spi_nor_init() function · 46dde01f
      Kamal Dasu 提交于
      This patch extracts some chunks from spi_nor_init_params and spi_nor_scan()
       and moves them into a new spi_nor_init() function.
      
      Indeed, spi_nor_init() regroups all the required SPI flash commands to be
      sent to the SPI flash memory before performing any runtime operations
      (Fast Read, Page Program, Sector Erase, ...). Hence spi_nor_init():
      1) removes the flash protection if applicable for certain vendors.
      2) sets the Quad Enable bit, if needed, before using Quad SPI protocols.
      3) makes the memory enter its (stateful) 4-byte address mode, if needed,
         for SPI flash memory > 128Mbits not supporting the 4-byte address
         instruction set.
      
      spi_nor_scan() now ends by calling spi_nor_init() once the probe phase has
      completed. Further patches could also use spi_nor_init() to implement the
      mtd->_resume() handler for the spi-nor framework.
      Signed-off-by: NKamal Dasu <kdasu.kdev@gmail.com>
      Signed-off-by: NCyrille Pitchen <cyrille.pitchen@wedev4u.fr>
      46dde01f
  6. 02 8月, 2017 1 次提交
    • A
      mtd: spi-nor: Recover from Spansion/Cypress errors · c4b3eacc
      Alexander Sverdlin 提交于
      S25FL{128|256|512}S datasheets say:
      "When P_ERR or E_ERR bits are set to one, the WIP bit will remain set to
      one indicating the device remains busy and unable to receive new operation
      commands. A Clear Status Register (CLSR) command must be received to return
      the device to standby mode."
      
      Current spi-nor code works until first error occurs, but write/erase errors
      are not just rare hardware failures, they also occur if user tries to flash
      write-protected areas. After such attempt no SPI command can be executed
      any more and even read fails. This patch adds support for P_ERR and E_ERR
      bits in Status Register 1 (so that operation fails immediately and not
      after a long timeout) and proper recovery from the error condition.
      
      Tested on Spansion S25FS128S, which is supported by S25FL129P entry.
      Signed-off-by: NAlexander Sverdlin <alexander.sverdlin@nokia.com>
      Signed-off-by: NCyrille Pitchen <cyrille.pitchen@wedev4u.fr>
      c4b3eacc
  7. 18 7月, 2017 1 次提交
  8. 16 5月, 2017 3 次提交
    • C
      mtd: spi-nor: introduce Octo SPI protocols · fe488a5e
      Cyrille Pitchen 提交于
      This patch starts adding support to Octo SPI protocols (SPI x-y-8).
      
      Op codes for Fast Read and/or Page Program operations using Octo SPI
      protocols are not known yet (no JEDEC specification has defined them yet)
      but we'd rather introduce the Octo SPI protocols now so it's done as it
      should be.
      Signed-off-by: NCyrille Pitchen <cyrille.pitchen@atmel.com>
      Reviewed-by: NMarek Vasut <marek.vasut@gmail.com>
      fe488a5e
    • C
      mtd: spi-nor: introduce Double Transfer Rate (DTR) SPI protocols · 15f55331
      Cyrille Pitchen 提交于
      This patch introduces support to Double Transfer Rate (DTR) SPI protocols.
      DTR is used only for Fast Read operations.
      
      According to manufacturer datasheets, whatever the number of I/O lines
      used during instruction (x) and address/mode/dummy (y) clock cycles, DTR
      is used only during data (z) clock cycles of SPI x-y-z protocols.
      Signed-off-by: NCyrille Pitchen <cyrille.pitchen@atmel.com>
      Reviewed-by: NMarek Vasut <marek.vasut@gmail.com>
      15f55331
    • C
      mtd: spi-nor: introduce SPI 1-2-2 and SPI 1-4-4 protocols · cfc5604c
      Cyrille Pitchen 提交于
      This patch changes the prototype of spi_nor_scan(): its 3rd parameter
      is replaced by a 'struct spi_nor_hwcaps' pointer, which tells the spi-nor
      framework about the actual hardware capabilities supported by the SPI
      controller and its driver.
      
      Besides, this patch also introduces a new 'struct spi_nor_flash_parameter'
      telling the spi-nor framework about the hardware capabilities supported by
      the SPI flash memory and the associated settings required to use those
      hardware caps.
      
      Then, to improve the readability of spi_nor_scan(), the discovery of the
      memory settings and the memory initialization are now split into two
      dedicated functions.
      
      1 - spi_nor_init_params()
      
      The spi_nor_init_params() function is responsible for initializing the
      'struct spi_nor_flash_parameter'. Currently this structure is filled with
      legacy values but further patches will allow to override some parameter
      values dynamically, for instance by reading the JESD216 Serial Flash
      Discoverable Parameter (SFDP) tables from the SPI memory.
      The spi_nor_init_params() function only deals with the hardware
      capabilities of the SPI flash memory: especially it doesn't care about
      the hardware capabilities supported by the SPI controller.
      
      2 - spi_nor_setup()
      
      The second function is called once the 'struct spi_nor_flash_parameter'
      has been initialized by spi_nor_init_params().
      With both 'struct spi_nor_flash_parameter' and 'struct spi_nor_hwcaps',
      the new argument of spi_nor_scan(), spi_nor_setup() computes the best
      match between hardware caps supported by both the (Q)SPI memory and
      controller hence selecting the relevant settings for (Fast) Read and Page
      Program operations.
      Signed-off-by: NCyrille Pitchen <cyrille.pitchen@atmel.com>
      Reviewed-by: NMarek Vasut <marek.vasut@gmail.com>
      cfc5604c
  9. 10 2月, 2017 2 次提交
  10. 02 6月, 2016 2 次提交
  11. 11 5月, 2016 1 次提交
  12. 08 3月, 2016 1 次提交
  13. 06 1月, 2016 1 次提交
  14. 01 12月, 2015 1 次提交
  15. 20 11月, 2015 1 次提交
  16. 12 11月, 2015 2 次提交
  17. 14 10月, 2015 5 次提交
  18. 22 9月, 2015 1 次提交
  19. 12 9月, 2015 2 次提交
    • J
      mtd: spi-nor: Zap unneeded write_enable from write_reg · f9f3ce83
      Jagan Teki 提交于
      The 'write_enable' argument is unused and unneeded, so remove it from
      the API.
      Signed-off-by: NJagan Teki <jteki@openedev.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Han Xu <han.xu@freescale.com>
      [Brian: fixed for nxp-spifi.c]
      Signed-off-by: NBrian Norris <computersforpeace@gmail.com>
      f9f3ce83
    • M
      mtd: spi-nor: Decouple SPI NOR's device_node from controller device · 11bff0b7
      Marek Vasut 提交于
      The problem this patch is trying to address is such, that SPI NOR flash
      devices attached to a dedicated SPI NOR controller cannot read their
      properties from the associated struct device_node.
      
      A couple of facts first:
      1) Each SPI NOR flash has a struct spi_nor associated with it.
      2) Each SPI NOR flash has certain device properties associated
         with it, for example the OF property 'm25p,fast-read' is a
         good pick. These properties are used by the SPI NOR core to
         select which opcodes are sent to such SPI NOR flash. These
         properties are coming from spi_nor .dev->of_node .
      
      The problem is, that for SPI NOR controllers, the struct spi_nor .dev
      element points to the struct device of the SPI NOR controller, not the
      SPI NOR flash. Therefore, the associated dev->of_node also is the
      one of the controller and therefore the SPI NOR core code is trying to
      parse the SPI NOR controller's properties, not the properties of the
      SPI NOR flash.
      
      Note: The m25p80 driver is not affected, because the controller and
            the flash are the same device, so the associated device_node
            of the controller and the flash are the same.
      
      This patch adjusts the SPI NOR core such that the device_node is not
      picked from spi_nor .dev directly, but from a new separate spi_nor
      .flash_node element. This let's the SPI NOR controller drivers set up
      a different spi_nor .flash_node element for each SPI NOR flash.
      
      This patch also fixes the controller drivers to be compatible with
      this modification and correctly set the spi_nor .flash_node element.
      
      This patch is inspired by 5844feea
      mtd: nand: add common DT init code
      Signed-off-by: NMarek Vasut <marex@denx.de>
      Signed-off-by: NBrian Norris <computersforpeace@gmail.com>
      11bff0b7
  20. 03 9月, 2015 2 次提交
  21. 28 3月, 2015 1 次提交
  22. 08 1月, 2015 1 次提交
    • B
      mtd: spi-nor: Add quad I/O support for Micron SPI NOR · 548cd3ab
      Bean Huo 霍斌斌 (beanhuo) 提交于
      This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.
      
      For Micron SPI NOR flash, enabling or disabling quad I/O protocol can be
      done By two methods, which are to use EVCR (Enhanced Volatile
      Configuration Register) and the ENTER QUAD I/O MODE command. There is no
      difference between these two methods. Unfortunately, for some Micron SPI
      NOR flashes, there no ENTER Quad I/O command (35h), such as n25q064. But
      for all current Micron SPI NOR, if it support quad I/O mode, using EVCR
      definitely be supported. It is a recommended method to enable Quad I/O
      mode by EVCR, Quad I/O protocol bit 7. When EVCR bit 7 is reset to 0,
      the SPI NOR flash will operate in quad I/O mode.
      
      This patch has been tested on N25Q512A and MT25TL256BAA1ESF. Micron SPI
      NOR of spi_nor_ids[] table all support this method.
      Signed-off-by: NBean Huo <beanhuo@micron.com>
      Acked-by: NMarek Vasut <marex@denx.de>
      Signed-off-by: NBrian Norris <computersforpeace@gmail.com>
      548cd3ab
  23. 05 11月, 2014 2 次提交
  24. 22 10月, 2014 2 次提交
    • B
      spi-nor: Remove spi_nor::read_id operation · e66fcf72
      Ben Hutchings 提交于
      There is currently no useful way to override the default
      implementation of this operation.  The returned struct spi_device_id
      must have a pointer to struct flash_info in its private data, but this
      structure is defined inside spi-nor.
      Signed-off-by: NBen Hutchings <ben@decadent.org.uk>
      Signed-off-by: NBrian Norris <computersforpeace@gmail.com>
      e66fcf72
    • B
      mtd: m25p80,spi-nor: Fix module aliases for m25p80 · a5b7616c
      Ben Hutchings 提交于
      m25p80's device ID table is now spi_nor_ids, defined in spi-nor.  The
      MODULE_DEVICE_TABLE() macro doesn't work with extern definitions, but
      its use was also removed at the same time.  Now if m25p80 is built as
      a module it doesn't get the necessary aliases to be loaded
      automatically.
      
      A clean solution to this will involve defining the list of device
      IDs in spi-nor.h and removing struct spi_device_id from the spi-nor
      API, but this is quite a large change.
      
      As a quick fix suitable for stable, copy the device IDs back into
      m25p80.
      
      Fixes: 03e296f6 ("mtd: m25p80: use the SPI nor framework")
      Cc: <stable@vger.kernel.org> # 3.16.x: 32f1b7c8: mtd: move support for struct flash_platform_data into m25p80
      Cc: <stable@vger.kernel.org> # 3.16.x: 90e55b38: mtd: m25p80: get rid of spi_get_device_id
      Cc: <stable@vger.kernel.org> # 3.16.x: 70f3ce05: mtd: spi-nor: make spi_nor_scan() take a chip type name, not spi_device_id
      Cc: <stable@vger.kernel.org> # 3.16.x
      Signed-off-by: NBen Hutchings <ben@decadent.org.uk>
      Signed-off-by: NBrian Norris <computersforpeace@gmail.com>
      a5b7616c
  25. 18 10月, 2014 1 次提交
  26. 12 7月, 2014 1 次提交