1. 27 7月, 2021 1 次提交
    • M
      spi: imx: mx51-ecspi: Fix low-speed CONFIGREG delay calculation · 53ca18ac
      Marek Vasut 提交于
      The spi_imx->spi_bus_clk may be uninitialized and thus also zero in
      mx51_ecspi_prepare_message(), which would lead to division by zero
      in kernel. Since bitbang .setup_transfer callback which initializes
      the spi_imx->spi_bus_clk is called after bitbang prepare_message
      callback, iterate over all the transfers in spi_message, find the
      one with lowest bus frequency, and use that bus frequency for the
      delay calculation.
      
      Note that it is not possible to move this CONFIGREG delay back into
      the .setup_transfer callback, because that is invoked too late, after
      the GPIO chipselects were already configured.
      
      Fixes: 135cbd37 ("spi: imx: mx51-ecspi: Reinstate low-speed CONFIGREG delay")
      Signed-off-by: NMarek Vasut <marex@denx.de>
      Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Cc: Mark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20210726100102.5188-1-marex@denx.deSigned-off-by: NMark Brown <broonie@kernel.org>
      53ca18ac
  2. 07 7月, 2021 1 次提交
  3. 09 4月, 2021 1 次提交
  4. 25 3月, 2021 1 次提交
  5. 17 3月, 2021 1 次提交
  6. 19 1月, 2021 1 次提交
  7. 24 11月, 2020 1 次提交
  8. 18 11月, 2020 1 次提交
  9. 10 11月, 2020 1 次提交
  10. 24 10月, 2020 1 次提交
  11. 05 10月, 2020 1 次提交
  12. 24 9月, 2020 1 次提交
  13. 21 8月, 2020 1 次提交
  14. 19 8月, 2020 1 次提交
  15. 27 7月, 2020 1 次提交
  16. 14 7月, 2020 1 次提交
    • L
      spi: imx/fsl-lpspi: Convert to GPIO descriptors · 8cdcd8ae
      Linus Walleij 提交于
      This converts the two Freescale i.MX SPI drivers
      Freescale i.MX (CONFIG_SPI_IMX) and Freescale i.MX LPSPI
      (CONFIG_SPI_FSL_LPSPI) to use GPIO descriptors handled in
      the SPI core for GPIO chip selects whether defined in
      the device tree or a board file.
      
      The reason why both are converted at the same time is
      that they were both using the same platform data and
      platform device population helpers when using
      board files intertwining the code so this gives a cleaner
      cut.
      
      The platform device creation was passing a platform data
      container from each boardfile down to the driver using
      struct spi_imx_master from <linux/platform_data/spi-imx.h>,
      but this was only conveying the number of chipselects and
      an int * array of the chipselect GPIO numbers.
      
      The imx27 and imx31 platforms had code passing the
      now-unused platform data when creating the platform devices,
      this has been repurposed to pass around GPIO descriptor
      tables. The platform data struct that was just passing an
      array of integers and number of chip selects for the GPIO
      lines has been removed.
      
      The number of chipselects used to be passed from the board
      file, because this number also limits the number of native
      chipselects that the platform can use. To deal with this we
      just augment the i.MX (CONFIG_SPI_IMX) driver to support 3
      chipselects if the platform does not define "num-cs" as a
      device property (such as from the device tree). This covers
      all the legacy boards as these use <= 3 native chip selects
      (or GPIO lines, and in that case the number of chip selects
      is determined by the core from the number of available
      GPIO lines). Any new boards should use device tree, so
      this is a reasonable simplification to cover all old
      boards.
      
      The LPSPI driver never assigned the number of chipselects
      and thus always fall back to the core default of 1 chip
      select if no GPIOs are defined in the device tree.
      
      The Freescale i.MX driver was already partly utilizing
      the SPI core to obtain the GPIO numbers from the device tree,
      so this completes the transtion to let the core handle all
      of it.
      
      All board files and the core i.MX boardfile registration
      code is augmented to account for these changes.
      
      This has been compile-tested with the imx_v4_v5_defconfig
      and the imx_v6_v7_defconfig.
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      Acked-by: NShawn Guo <shawnguo@kernel.org>
      Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Cc: Robin Gong <yibin.gong@nxp.com>
      Cc: Trent Piepho <tpiepho@impinj.com>
      Cc: Clark Wang <xiaoning.wang@nxp.com>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Cc: Sascha Hauer <s.hauer@pengutronix.de>
      Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
      Cc: Fabio Estevam <festevam@gmail.com>
      Cc: NXP Linux Team <linux-imx@nxp.com>
      Link: https://lore.kernel.org/r/20200625200252.207614-1-linus.walleij@linaro.orgSigned-off-by: NMark Brown <broonie@kernel.org>
      8cdcd8ae
  17. 23 6月, 2020 1 次提交
  18. 28 5月, 2020 1 次提交
  19. 26 12月, 2019 1 次提交
  20. 15 11月, 2019 1 次提交
  21. 13 3月, 2019 1 次提交
    • T
      spi: imx: stop buffer overflow in RX FIFO flush · c842749e
      Trent Piepho 提交于
      Commit 71abd290 ("spi: imx: Add support for SPI Slave mode") added
      an RX FIFO flush before start of a transfer.  In slave mode, the master
      may have sent more data than expected and this data will still be in the
      RX FIFO at the start of the next transfer, and so needs to be flushed.
      
      However, the code to do the flush was accidentally saving this data into
      the previous transfer's RX buffer, clobbering the contents of whatever
      followed that buffer.
      
      Change it to empty the FIFO and throw away the data.  Every one of the
      RX functions for the different eCSPI versions and modes reads the RX
      FIFO data using the same readl() call, so just use that, rather than
      using the spi_imx->rx function pointer and making sure all the different
      rx functions have a working "throw away" mode.
      
      There is another issue, which affects master mode when switching from
      DMA to PIO.  There can be extra data in the RX FIFO which triggers this
      flush code, causing memory corruption in the same manner.  I don't know
      why this data is unexpectedly in the FIFO.  It's likely there is a
      different bug or erratum responsible for that.  But regardless of that,
      I think this is proper fix the for bug at hand here.
      
      Fixes: 71abd290 ("spi: imx: Add support for SPI Slave mode")
      Cc: Jiada Wang <jiada_wang@mentor.com>
      Cc: Fabio Estevam <festevam@gmail.com>
      Cc: Stefan Agner <stefan@agner.ch>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Signed-off-by: NTrent Piepho <tpiepho@impinj.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      c842749e
  22. 12 3月, 2019 1 次提交
    • T
      spi: imx: add module parameter to control DMA use · 0a9c8998
      Trent Piepho 提交于
      Add the boolean module parameter "use_dma" to control the use of DMA by
      the driver.  There are about two dozen other drivers with a "use_dma"
      parameter of some sort.
      
      DMA may allow faster and more efficient transfers than using PIO, but it
      also adds overhead for small transfers.
      
      High speed receive operations may be less likely to have issues with
      FIFO overflow when using DMA than when using PIO.
      
      The eCSPI appears to insert a 4 bit pause after each word in DMA mode,
      not done in PIO mode, which can make DMA transfers 50% slower than PIO.
      
      In some cases DMA may be a net win while in others PIO might be.  It
      depends on the application.  So allow DMA to be enabled or disabled at
      the driver level.  The default will be to have it enabled when possible.
      Signed-off-by: NTrent Piepho <tpiepho@impinj.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      0a9c8998
  23. 11 12月, 2018 5 次提交
  24. 13 10月, 2018 3 次提交
    • R
      spi: imx: use PIO mode if size is small · 133eb8e3
      Robin Gong 提交于
      Use PIO mode instead if size is smaller than fifo size, since
      dma may be less efficient.
      Signed-off-by: NRobin Gong <yibin.gong@nxp.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      133eb8e3
    • R
      spi: imx: correct wml as the last sg length · 5ba5a373
      Robin Gong 提交于
      Correct wml as the last rx sg length instead of the whole transfer
      length. Otherwise, mtd_stresstest will be failed as below:
      
      insmod mtd_stresstest.ko dev=0
      =================================================
      mtd_stresstest: MTD device: 0
      mtd_stresstest: not NAND flash, assume page size is 512 bytes.
      mtd_stresstest: MTD device size 4194304, eraseblock size 65536, page size 512, count of eraseblocks 64, pa0
      mtd_stresstest: doing operations
      mtd_stresstest: 0 operations done
      mtd_test: mtd_read from 1ff532, size 880
      mtd_test: mtd_read from 20c267, size 64998
      spi_master spi0: I/O Error in DMA RX
      m25p80 spi0.0: SPI transfer failed: -110
      spi_master spi0: failed to transfer one message from queue
      mtd_test: error: read failed at 0x20c267
      mtd_stresstest: error -110 occurred
      =================================================
      insmod: ERROR: could not insert module mtd_stresstest.ko: Connection timed out
      Signed-off-by: NRobin Gong <yibin.gong@nxp.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      5ba5a373
    • R
      spi: imx: move wml setting to later than setup_transfer · 987a2dfe
      Robin Gong 提交于
      Current dynamic burst length is based on the whole transfer length,
      that's ok if there is only one sg, but is not right in case multi sgs
      in one transfer,because the tail data should be based on the last sg
      length instead of the whole transfer length. Move wml setting for DMA
      to the later place, thus, the next patch could get the right last sg
      length for wml setting. This patch is a preparation one, no any
      function change involved.
      Signed-off-by: NRobin Gong <yibin.gong@nxp.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      987a2dfe
  25. 24 7月, 2018 5 次提交
  26. 13 6月, 2018 1 次提交
    • K
      treewide: devm_kzalloc() -> devm_kcalloc() · a86854d0
      Kees Cook 提交于
      The devm_kzalloc() function has a 2-factor argument form, devm_kcalloc().
      This patch replaces cases of:
      
              devm_kzalloc(handle, a * b, gfp)
      
      with:
              devm_kcalloc(handle, a * b, gfp)
      
      as well as handling cases of:
      
              devm_kzalloc(handle, a * b * c, gfp)
      
      with:
      
              devm_kzalloc(handle, array3_size(a, b, c), gfp)
      
      as it's slightly less ugly than:
      
              devm_kcalloc(handle, array_size(a, b), c, gfp)
      
      This does, however, attempt to ignore constant size factors like:
      
              devm_kzalloc(handle, 4 * 1024, gfp)
      
      though any constants defined via macros get caught up in the conversion.
      
      Any factors with a sizeof() of "unsigned char", "char", and "u8" were
      dropped, since they're redundant.
      
      Some manual whitespace fixes were needed in this patch, as Coccinelle
      really liked to write "=devm_kcalloc..." instead of "= devm_kcalloc...".
      
      The Coccinelle script used for this was:
      
      // Fix redundant parens around sizeof().
      @@
      expression HANDLE;
      type TYPE;
      expression THING, E;
      @@
      
      (
        devm_kzalloc(HANDLE,
      -	(sizeof(TYPE)) * E
      +	sizeof(TYPE) * E
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	(sizeof(THING)) * E
      +	sizeof(THING) * E
        , ...)
      )
      
      // Drop single-byte sizes and redundant parens.
      @@
      expression HANDLE;
      expression COUNT;
      typedef u8;
      typedef __u8;
      @@
      
      (
        devm_kzalloc(HANDLE,
      -	sizeof(u8) * (COUNT)
      +	COUNT
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(__u8) * (COUNT)
      +	COUNT
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(char) * (COUNT)
      +	COUNT
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(unsigned char) * (COUNT)
      +	COUNT
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(u8) * COUNT
      +	COUNT
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(__u8) * COUNT
      +	COUNT
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(char) * COUNT
      +	COUNT
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(unsigned char) * COUNT
      +	COUNT
        , ...)
      )
      
      // 2-factor product with sizeof(type/expression) and identifier or constant.
      @@
      expression HANDLE;
      type TYPE;
      expression THING;
      identifier COUNT_ID;
      constant COUNT_CONST;
      @@
      
      (
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(TYPE) * (COUNT_ID)
      +	COUNT_ID, sizeof(TYPE)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(TYPE) * COUNT_ID
      +	COUNT_ID, sizeof(TYPE)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(TYPE) * (COUNT_CONST)
      +	COUNT_CONST, sizeof(TYPE)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(TYPE) * COUNT_CONST
      +	COUNT_CONST, sizeof(TYPE)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(THING) * (COUNT_ID)
      +	COUNT_ID, sizeof(THING)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(THING) * COUNT_ID
      +	COUNT_ID, sizeof(THING)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(THING) * (COUNT_CONST)
      +	COUNT_CONST, sizeof(THING)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(THING) * COUNT_CONST
      +	COUNT_CONST, sizeof(THING)
        , ...)
      )
      
      // 2-factor product, only identifiers.
      @@
      expression HANDLE;
      identifier SIZE, COUNT;
      @@
      
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	SIZE * COUNT
      +	COUNT, SIZE
        , ...)
      
      // 3-factor product with 1 sizeof(type) or sizeof(expression), with
      // redundant parens removed.
      @@
      expression HANDLE;
      expression THING;
      identifier STRIDE, COUNT;
      type TYPE;
      @@
      
      (
        devm_kzalloc(HANDLE,
      -	sizeof(TYPE) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(TYPE) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(TYPE) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(TYPE) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(THING) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(THING) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(THING) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(THING) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      )
      
      // 3-factor product with 2 sizeof(variable), with redundant parens removed.
      @@
      expression HANDLE;
      expression THING1, THING2;
      identifier COUNT;
      type TYPE1, TYPE2;
      @@
      
      (
        devm_kzalloc(HANDLE,
      -	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(THING1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(THING1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(TYPE1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      )
      
      // 3-factor product, only identifiers, with redundant parens removed.
      @@
      expression HANDLE;
      identifier STRIDE, SIZE, COUNT;
      @@
      
      (
        devm_kzalloc(HANDLE,
      -	(COUNT) * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	COUNT * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	COUNT * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	(COUNT) * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	COUNT * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	(COUNT) * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	(COUNT) * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	COUNT * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      )
      
      // Any remaining multi-factor products, first at least 3-factor products,
      // when they're not all constants...
      @@
      expression HANDLE;
      expression E1, E2, E3;
      constant C1, C2, C3;
      @@
      
      (
        devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
      |
        devm_kzalloc(HANDLE,
      -	(E1) * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	(E1) * (E2) * E3
      +	array3_size(E1, E2, E3)
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	(E1) * (E2) * (E3)
      +	array3_size(E1, E2, E3)
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	E1 * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      )
      
      // And then all remaining 2 factors products when they're not all constants,
      // keeping sizeof() as the second factor argument.
      @@
      expression HANDLE;
      expression THING, E1, E2;
      type TYPE;
      constant C1, C2, C3;
      @@
      
      (
        devm_kzalloc(HANDLE, sizeof(THING) * C2, ...)
      |
        devm_kzalloc(HANDLE, sizeof(TYPE) * C2, ...)
      |
        devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
      |
        devm_kzalloc(HANDLE, C1 * C2, ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(TYPE) * (E2)
      +	E2, sizeof(TYPE)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(TYPE) * E2
      +	E2, sizeof(TYPE)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(THING) * (E2)
      +	E2, sizeof(THING)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(THING) * E2
      +	E2, sizeof(THING)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	(E1) * E2
      +	E1, E2
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	(E1) * (E2)
      +	E1, E2
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	E1 * E2
      +	E1, E2
        , ...)
      )
      Signed-off-by: NKees Cook <keescook@chromium.org>
      a86854d0
  27. 03 5月, 2018 1 次提交
  28. 13 4月, 2018 1 次提交
  29. 08 1月, 2018 1 次提交
  30. 11 11月, 2017 1 次提交
    • T
      spi: imx: Don't require platform data chipselect array · ffd4db9e
      Trent Piepho 提交于
      If the array is not present, assume all chip selects are native.  This
      is the standard behavior for SPI masters configured via the device
      tree and the behavior of this driver as well when it is configured via
      device tree.
      
      This reduces platform data vs DT differences and allows most of the
      platform data based boards to remove their chip select arrays.
      
      CC: Shawn Guo <shawnguo@kernel.org>
      CC: Sascha Hauer <kernel@pengutronix.de>
      CC: Fabio Estevam <fabio.estevam@nxp.com>
      CC: Mark Brown <broonie@kernel.org>
      Signed-off-by: NTrent Piepho <tpiepho@impinj.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      ffd4db9e