Skip to content
Snippets Groups Projects
  1. Aug 23, 2017
  2. Jun 28, 2017
    • Cyrille Pitchen's avatar
      mtd: st_spi_fsm: remove SPINOR_OP_RDSR2 and use SPINOR_OP_RDCR instead · 9447332f
      Cyrille Pitchen authored
      The 35h instruction op code has two aliases/macro definitions:
      - SPINOR_OP_RDCR from include/linux/mtd/spi-nor.h
      - SPINOR_OP_RDSR2 from drivers/mtd/devices/serial_flash_cmds.h
      
      Actually, some manufacturers name the associated internal register Status
      Register 2 whereas other manufacturers name it Configuration Register
      hence the two different macros for the very same instruction op code.
      
      Since the spi-nor.h file is the reference file for all SPI NOR instruction
      op codes, this patch removes the definition of the SPINOR_OP_RDSR2 macro.
      
      Also the SPINOR_OP_RDSR2 macro will be associated to another instruction
      op code in a further patch so we need to avoid a conflict defining this
      macro twice. Indeed the JESD216 rev B specification, defining the SFDP
      tables, also refers to the 3Eh and 3Fh instruction op codes to write/read
      the Status Register 2 on some SPI NOR flash memories, the 35h op code
      still being used to read the Configuration Regi...
      9447332f
  3. Feb 10, 2017
  4. Nov 12, 2015
  5. Jan 13, 2015
    • Lee Jones's avatar
      mtd: st_spi_fsm: Fix [-Wsign-compare] build warning · a9b679bf
      Lee Jones authored
      
      drivers/mtd/devices/st_spi_fsm.c:1647:17:
        warning: comparison between signed and unsigned integer expressions
      
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      a9b679bf
    • Lee Jones's avatar
      mtd: st_spi_fsm: Obtain and use EMI clock · 69d5af8d
      Lee Jones authored
      
      ST's Common Clk Framework is now available. This patch ensures the FSM
      makes use of it by obtaining and enabling the EMI clock. If system fails
      to provide the EMI clock, we bomb out.
      
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      69d5af8d
    • Lee Jones's avatar
      mtd: st_spi_fsm: Extend fsm_clear_fifo to handle unwanted bytes · 5ecd3ea1
      Lee Jones authored
      
      Under certain conditions, the SPI-FSM Controller can be left in a state where
      the data FIFO is not entirely empty.  This can lead to problems where subsequent
      data transfers appear to have been shifted by a number of unidentified bytes.
      
      One simple example would be an errant FSM sequence which loaded more data to the
      FIFO than was read by the host.  Another more interesting case results from an
      obscure artefact in the FSM Controller.  When switching from data transfers in
      x4 or x2 mode to data transfers in x1 mode, extraneous bytes will appear in the
      FIFO, unless the previous data transfer was a multiple of 32 cycles (i.e. 8
      bytes for x2, and 16 bytes for x4).  This applies equally whether FSM is being
      operated directly by a S/W driver, or by the SPI boot-controller in FSM-Boot
      mode.  Furthermore, data in the FIFO not only survive a transition between
      FSM-Boot and FSM, but also a S/W reset of IP block [1].
      
      By taking certain precautions, it is possible to prevent the driver from causing
      this type of problem (e.g. ensuring that the host and programmed sequence
      agree on the transfer size, and restricting transfer sizes to multiples of
      32-cycles [2]).  However, at the point the driver is loaded, no assumptions can be
      made regarding the state of the FIFO.  Even if previous S/W drivers have behaved
      correctly, it is impossible to control the number of transactions serviced by
      the controller operating in FSM-Boot.
      
      To address this problem, we ensure the FIFO is cleared during initialisation,
      before performing any FSM operations.  Previously, the fsm_clear_fifo() code was
      capable of detecting and clearing any unwanted 32-bit words from the FIFO.  This
      patch extends the capability to handle an arbitrary number of bytes present in
      the FIFO [3].  Now that the issue is better understood, we also remove the calls
      to fsm_clear_fifo() following the fsm_read() and fsm_write() operations.
      
      The process of actually clearing the FIFO deserves a mention.  While the FIFO
      may contain any number of bytes, the SPI_FAST_SEQ_STA register only reports the
      number of complete 32-bit words present.  Furthermore, data can only be drained
      from the FIFO by reading complete 32-bit words.  With this in mind, a two stage
      process is used to the clear the FIFO:
      
          1. Read any complete 32-bit words from the FIFO, as reported by the
                 SPI_FAST_SEQ_STA register.
      
          2. Mop up any remaining bytes.  At this point, it is not known if there
                 are 0, 1, 2, or 3 bytes in the FIFO.  To handle all cases, a dummy
                 FSM sequence is used to load one byte at a time, until a complete
                 32-bit word is formed; at most, 4 bytes will need to be loaded.
      
      [1] Although this issue has existed since early versions of the SPI-FSM
          controller, its full extent only emerged recently as a consequence of the
          targetpacks starting to use FSM-Boot(x4) as the default configuration.
      
      [2] The requirement to restrict transfers to multiples of 32 cycles was found
          empirically back when DUAL and QUAD mode support was added.  The current
          analysis now gives a satisfactory explanation for this requirement.
      
      [3] Theoretically, it is possible for the FIFO to contain an arbitrary number of
          bits.  However, since there are no known use-cases that leave incomplete
          bytes in the FIFO, only words and bytes are considered here.
      
      Signed-off-by: default avatarAngus Clark <angus.clark@st.com>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      5ecd3ea1
  6. Oct 20, 2014
  7. May 21, 2014
  8. Apr 17, 2014
    • Brian Norris's avatar
      mtd: st_spi_fsm: correct type issues · 38e2eee9
      Brian Norris authored
      
      Compile-testing for a 64-bit arch uncovers several bad casts:
      
          In file included from include/linux/linkage.h:4:0,
                           from include/linux/kernel.h:6,
                           from drivers/mtd/devices/st_spi_fsm.c:15:
          drivers/mtd/devices/st_spi_fsm.c: In function ‘stfsm_read_fifo’:
          drivers/mtd/devices/st_spi_fsm.c:758:11: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
            BUG_ON((((uint32_t)buf) & 0x3) || (size & 0x3));
          ...
      
      Use uintptr_t instead of uint32_t, since it's guaranteed to be
      pointer-sized.
      
      We also see this warning, if size_t is not 32 bits wide:
      
          In file included from drivers/mtd/devices/st_spi_fsm.c:15:0:
          drivers/mtd/devices/st_spi_fsm.c: In function ‘stfsm_mtd_write’:
          include/linux/kernel.h:712:17: warning: comparison of distinct pointer types lacks a cast [enabled by default]
            (void) (&_min1 == &_min2);  \
                           ^
          drivers/mtd/devices/st_spi_fsm.c:1704:11: note: in expansion of macro ‘min’
             bytes = min(FLASH_PAGESIZE - page_offs, len);
                     ^
      
      Just use min_t() to force the type conversion, since we don't really
      want to upgrade 'page_offs' and 'bytes' to size_t; they only should be
      handling <= 256 byte offsets.
      
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      Acked-by: default avatarLee Jones <lee.jones@linaro.org>
      38e2eee9
  9. Apr 15, 2014
  10. Mar 20, 2014