1. 26 5月, 2014 1 次提交
  2. 15 4月, 2014 1 次提交
    • H
      spi: core: Increase timeout value · eee668a9
      Harini Katakam 提交于
      The existing timeout value in wait_for_completion_timeout is
      calculated from the transfer length and speed with tolerance of 10msec.
      This is too low because this is used for error conditions such as
      hardware hang etc.
      The xfer->speed_hz considered may not be the actual speed set
      because the best clock divisor is chosen from a limited set such that
      the actual speed <= requested speed. This will lead to timeout being
      less than actual transfer time.
      Considering acceptable latencies, this timeout can be set to a
      value double the expected transfer plus 100 msecs.
      This patch adds the same in the core.
      Signed-off-by: NHarini Katakam <harinik@xilinx.com>
      Signed-off-by: NMark Brown <broonie@linaro.org>
      eee668a9
  3. 30 3月, 2014 1 次提交
  4. 26 3月, 2014 1 次提交
    • M
      spi: Do not require a completion · 1e25cd47
      Mark Brown 提交于
      There is no real reason why we require transfers to have a completion and
      the only user of the completion now checks to see if one has been provided
      before using it so stop enforcing this. This makes it more convenient for
      drivers to chain multiple asynchronous transfers together.
      Signed-off-by: NMark Brown <broonie@linaro.org>
      1e25cd47
  5. 17 3月, 2014 1 次提交
  6. 04 3月, 2014 1 次提交
  7. 23 2月, 2014 1 次提交
  8. 22 2月, 2014 1 次提交
  9. 14 2月, 2014 1 次提交
  10. 13 2月, 2014 1 次提交
  11. 10 2月, 2014 1 次提交
    • A
      spi: core: Set max_speed_hz of spi_device default to max_speed_hz of controller · 052eb2d4
      Axel Lin 提交于
      In __spi_validate(), xfer->speed_hz is set to be spi->max_speed_hz if it is not
      set for this transfer. However, if spi->max_speed_hz is also not set,
      xfer->speed_hz is 0. Some drivers (e.g. au1550, tegra114, tegra20-sflash,
      tegra20-slink, etc.) then use below code to avoid setting xfer->speed_hz to 0.
      
              /* Set speed to the spi max fequency if spi device has not set */
              spi->max_speed_hz = spi->max_speed_hz ? : tspi->spi_max_frequency;
      
      Let's handle it in spi core.
      If spi->max_speed_hz is not set, make it default to spi->master->max_speed_hz.
      So In __spi_validate() if both xfer->speed_hz and spi->max_speed_hz are not set,
      xfer->speed_hz will be set to spi->master->max_speed_hz.
      Signed-off-by: NAxel Lin <axel.lin@ingics.com>
      Signed-off-by: NMark Brown <broonie@linaro.org>
      052eb2d4
  12. 05 2月, 2014 2 次提交
    • M
      spi: Make core DMA mapping functions generate scatterlists · 6ad45a27
      Mark Brown 提交于
      We cannot unconditionally use dma_map_single() to map data for use with
      SPI since transfers may exceed a page and virtual addresses may not be
      provided with physically contiguous pages. Further, addresses allocated
      using vmalloc() need to be mapped differently to other addresses.
      
      Currently only the MXS driver handles all this, a few drivers do handle
      the possibility that buffers may not be physically contiguous which is
      the main potential problem but many don't even do that. Factoring this
      out into the core will make it easier for drivers to do a good job so if
      the driver is using the core DMA code then generate a scatterlist
      instead of mapping to a single address so do that.
      
      This code is mainly based on a combination of the existing code in the MXS
      and PXA2xx drivers. In future we should be able to extend it to allow the
      core to concatenate adjacent transfers if they are compatible, improving
      performance.
      
      Currently for simplicity clients are not allowed to use the scatterlist
      when they do DMA mapping, in the future the existing single address
      mappings will be replaced with use of the scatterlist most likely as
      part of pre-verifying transfers.
      
      This change makes it mandatory to use scatterlists when using the core DMA
      mapping so update the s3c64xx driver to do this when used with dmaengine.
      Doing so makes the code more ugly but it is expected that the old s3c-dma
      code can be removed very soon.
      Signed-off-by: NMark Brown <broonie@linaro.org>
      6ad45a27
    • M
      spi: Provide core support for full duplex devices · 3a2eba9b
      Mark Brown 提交于
      It is fairly common for SPI devices to require that one or both transfer
      directions is always active. Currently drivers open code this in various
      ways with varying degrees of efficiency. Start factoring this out by
      providing flags SPI_MASTER_MUST_TX and SPI_MASTER_MUST_RX. These will cause
      the core to provide buffers for the requested direction if none are
      specified in the underlying transfer.
      
      Currently this is fairly inefficient since we actually allocate a data
      buffer which may get large, support for mapping transfers using a
      scatterlist will allow us to avoid this for DMA based transfers.
      Signed-off-by: NMark Brown <broonie@linaro.org>
      3a2eba9b
  13. 03 2月, 2014 2 次提交
    • M
      spi: Provide core support for DMA mapping transfers · 99adef31
      Mark Brown 提交于
      The process of DMA mapping buffers for SPI transfers does not vary between
      devices so in order to save duplication of code in drivers this can be
      factored out into the core, allowing it to be integrated with the work that
      is being done on factoring out the common elements from the data path
      including more sharing of dmaengine code.
      
      In order to use this masters need to provide a can_dma() operation and while
      the hardware is prepared they should ensure that DMA channels are provided
      in tx_dma and rx_dma. The core will then ensure that the buffers are mapped
      for DMA prior to calling transfer_one_message().
      
      Currently the cleanup on error is not complete, this needs to be improved.
      Signed-off-by: NMark Brown <broonie@linaro.org>
      99adef31
    • M
      spi: Add a timeout when waiting for transfers · 16a0ce4e
      Mark Brown 提交于
      Don't wait indefinitely for transfers to complete but time out after 10ms
      more than we expect the transfer to take on the wire.
      Signed-off-by: NMark Brown <broonie@linaro.org>
      16a0ce4e
  14. 29 1月, 2014 1 次提交
    • G
      spi: Fix crash with double message finalisation on error handling · 1f802f82
      Geert Uytterhoeven 提交于
      This reverts commit e120cc0d.
      
      It causes a NULL pointer dereference with drivers using the generic
      spi_transfer_one_message(), which always calls
      spi_finalize_current_message(), which zeroes master->cur_msg.
      
      Drivers implementing transfer_one_message() theirselves must always call
      spi_finalize_current_message(), even if the transfer failed:
      
       * @transfer_one_message: the subsystem calls the driver to transfer a single
       *      message while queuing transfers that arrive in the meantime. When the
       *      driver is finished with this message, it must call
       *      spi_finalize_current_message() so the subsystem can issue the next
       *      transfer
      Signed-off-by: NGeert Uytterhoeven <geert+renesas@linux-m68k.org>
      Signed-off-by: NMark Brown <broonie@linaro.org>
      1f802f82
  15. 22 1月, 2014 2 次提交
  16. 17 1月, 2014 1 次提交
    • Z
      ACPI: fix module autoloading for ACPI enumerated devices · 8c4ff6d0
      Zhang Rui 提交于
      ACPI enumerated devices has ACPI style _HID and _CID strings,
      all of these strings can be used for both driver loading and matching.
      
      Currently, in Platform, I2C and SPI bus, the ACPI style driver matching
      is supported by invoking acpi_driver_match_device() in bus .match() callback.
      But, the module autoloading is still broken.
      
      For example, there is any ACPI device with _HID "INTABCD" that is
      enumerated to platform bus, and we have a driver that can probe it.
      
      The driver exports its module_alias as "acpi:INTABCD" use the following code
      static const struct acpi_device_id xxx_acpi_match[] = {
              { "INTABCD", 0 },
              { }
      };
      MODULE_DEVICE_TABLE(acpi, xxx_acpi_match);
      
      But, unfortunately, the device' modalias is shown as "platform:INTABCD:00",
      please refer to modalias_show() and platform_uevent() in
      drivers/base/platform.c.
      This results in that the driver will not be loaded automatically when the
      device node is created, because their modalias do not match.
      
      This also applies to I2C and SPI bus.
      
      With this patch, the device' modalias will be shown as "acpi:INTABCD" as well.
      Signed-off-by: NZhang Rui <rui.zhang@intel.com>
      Acked-by: NMark Brown <broonie@linaro.org>
      Acked-by: NWolfram Sang <wsa@the-dreams.de>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      8c4ff6d0
  17. 13 1月, 2014 1 次提交
  18. 09 1月, 2014 2 次提交
  19. 06 1月, 2014 1 次提交
    • D
      spidev: fix hang when transfer_one_message fails · e120cc0d
      Daniel Santos 提交于
      This corrects a problem in spi_pump_messages() that leads to an spi
      message hanging forever when a call to transfer_one_message() fails.
      This failure occurs in my MCP2210 driver when the cs_change bit is set
      on the last transfer in a message, an operation which the hardware does
      not support.
      
      Rationale
      Since the transfer_one_message() returns an int, we must presume that it
      may fail.  If transfer_one_message() should never fail, it should return
      void.  Thus, calls to transfer_one_message() should properly manage a
      failure.
      
      Fixes: ffbbdd21 (spi: create a message queueing infrastructure)
      Signed-off-by: NDaniel Santos <daniel.santos@pobox.com>
      Signed-off-by: NMark Brown <broonie@linaro.org>
      Cc: stable@vger.kernel.org
      e120cc0d
  20. 02 1月, 2014 1 次提交
  21. 30 12月, 2013 1 次提交
  22. 24 11月, 2013 1 次提交
    • M
      spi: Factor validation and initialisation of messages outside lock · 90808738
      Mark Brown 提交于
      Currently we do a bunch of per-message validation and initialisation in
      __spi_async() which is called with the bus lock held. Since none of this
      validation depends on the current bus status there's no need to hold the
      lock to do it so split it out into a separate __spi_validate() function
      which is called prior to taking the bus lock.
      
      This could be slightly neater but keep things simple for now to show the
      code motion clearly.
      
      Based on observations from Martin Sperl.
      Signed-off-by: NMark Brown <broonie@linaro.org>
      90808738
  23. 22 11月, 2013 1 次提交
    • S
      spi: core: invert success test in devm_spi_register_master · 4b92894e
      Stephen Warren 提交于
      devres_add() should be called when the action to be undone succeeded,
      not when it failed. Fix the inverted test in devm_spi_register_master()
      which was doing the opposite.
      
      The user-visible issue without this fix is:
      insmod spi-tegra114.ko
        Assume there's an MTD device on that SPI bus, which creates /dev/mtd0.
      rmmod spi-tegra114
        Doesn't remove devices on the SPI bus.
      insmod spi-tegra114.ko
        Creates a duplicate SPI device which creates /dev/mtd1.
      hexdump -C /dev/mtd0
        That's the old device, which uses an SPI bus hosted by a non-existent
        module, which causes the oops below.
      
      Unable to handle kernel paging request at virtual address bf0017c0
      pgd = c0004000
      [bf0017c0] *pgd=ad51b811, *pte=00000000, *ppte=00000000
      Internal error: Oops: 80000007 [#1] PREEMPT SMP ARM
      ...
      PC is at 0xbf0017c0
      LR is at spi_pump_messages+0x15c/0x204
      pc : [<bf0017c0>] lr : [<c02f0af8>] psr: 60000113
      ...
      
      Fixes: 666d5b4c ("spi: core: Add devm_spi_register_master()")
      Signed-off-by: NStephen Warren <swarren@nvidia.com>
      Signed-off-by: NMark Brown <broonie@linaro.org>
      4b92894e
  24. 15 11月, 2013 3 次提交
    • W
      tree-wide: use reinit_completion instead of INIT_COMPLETION · 16735d02
      Wolfram Sang 提交于
      Use this new function to make code more comprehensible, since we are
      reinitialzing the completion, not initializing.
      
      [akpm@linux-foundation.org: linux-next resyncs]
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      Acked-by: Linus Walleij <linus.walleij@linaro.org> (personally at LCE13)
      Cc: Ingo Molnar <mingo@kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      16735d02
    • J
      spi: Use stable dev_name for ACPI enumerated SPI slaves · e13ac47b
      Jarkko Nikula 提交于
      Current spi bus_num.chip_select "spix.y" based device naming scheme may not
      be stable enough to be used in name based matching, for instance within
      ALSA SoC subsystem.
      
      This can be problem in PC kind of platforms if there are changes in SPI bus
      configuration, amount of busses or probe order.
      
      This patch addresses the problem by using the ACPI device name with
      "spi-" prefix for ACPI enumerated SPI slave. For them device name
      "spix.y" becomes "spi-INTABCD:ij".
      Signed-off-by: NJarkko Nikula <jarkko.nikula@linux.intel.com>
      Acked-by: NMark Brown <broonie@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      e13ac47b
    • R
      ACPI / driver core: Store an ACPI device pointer in struct acpi_dev_node · 7b199811
      Rafael J. Wysocki 提交于
      Modify struct acpi_dev_node to contain a pointer to struct acpi_device
      associated with the given device object (that is, its ACPI companion
      device) instead of an ACPI handle corresponding to it.  Introduce two
      new macros for manipulating that pointer in a CONFIG_ACPI-safe way,
      ACPI_COMPANION() and ACPI_COMPANION_SET(), and rework the
      ACPI_HANDLE() macro to take the above changes into account.
      Drop the ACPI_HANDLE_SET() macro entirely and rework its users to
      use ACPI_COMPANION_SET() instead.  For some of them who used to
      pass the result of acpi_get_child() directly to ACPI_HANDLE_SET()
      introduce a helper routine acpi_preset_companion() doing an
      equivalent thing.
      
      The main motivation for doing this is that there are things
      represented by struct acpi_device objects that don't have valid
      ACPI handles (so called fixed ACPI hardware features, such as
      power and sleep buttons) and we would like to create platform
      device objects for them and "glue" them to their ACPI companions
      in the usual way (which currently is impossible due to the
      lack of valid ACPI handles).  However, there are more reasons
      why it may be useful.
      
      First, struct acpi_device pointers allow of much better type checking
      than void pointers which are ACPI handles, so it should be more
      difficult to write buggy code using modified struct acpi_dev_node
      and the new macros.  Second, the change should help to reduce (over
      time) the number of places in which the result of ACPI_HANDLE() is
      passed to acpi_bus_get_device() in order to obtain a pointer to the
      struct acpi_device associated with the given "physical" device,
      because now that pointer is returned by ACPI_COMPANION() directly.
      Finally, the change should make it easier to write generic code that
      will build both for CONFIG_ACPI set and unset without adding explicit
      compiler directives to it.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com> # on Haswell
      Reviewed-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Reviewed-by: Aaron Lu <aaron.lu@intel.com> # for ATA and SDIO part
      7b199811
  25. 15 10月, 2013 1 次提交
    • J
      spi: Fix checkpatch issue · 5fe5f05e
      Jingoo Han 提交于
      Fix the following checkpatch error and warnings.
      
        ERROR: space required after that ',' (ctx:VxV)
        WARNING: quoted string split across lines
        WARNING: max() should probably be max_t(int, nb, master->num_chipselect)
        WARNING: sizeof *spi should be sizeof(*spi)
        WARNING: sizeof *master should be sizeof(*master)
        WARNING: sizeof x should be sizeof(x)
      Signed-off-by: NJingoo Han <jg1.han@samsung.com>
      Signed-off-by: NMark Brown <broonie@linaro.org>
      5fe5f05e
  26. 12 10月, 2013 2 次提交
    • M
      spi: Provide common spi_message processing loop · b158935f
      Mark Brown 提交于
      The loops which SPI controller drivers use to process the list of transfers
      in a spi_message are typically very similar and have some error prone areas
      such as the handling of /CS. Help simplify drivers by factoring this code
      out into the core - if drivers provide a transfer_one() function instead
      of a transfer_one_message() function the core will handle processing at the
      message level.
      
      /CS can be controlled by either setting cs_gpio or providing a set_cs
      function. If this is not possible for hardware reasons then both can be
      omitted and the driver should continue to implement manual /CS handling.
      
      This is a first step in refactoring and it is expected that there will be
      further enhancements, for example factoring out of the mapping of transfers
      for DMA and the initiation and completion of interrupt driven transfers.
      Signed-off-by: NMark Brown <broonie@linaro.org>
      b158935f
    • M
      spi: Provide per-message prepare and unprepare operations · 2841a5fc
      Mark Brown 提交于
      Many SPI drivers perform setup and tear down on every message, usually
      doing things like DMA mapping the message. Provide hooks for them to use
      to provide such operations.
      
      This is of limited value for drivers that implement transfer_one_message()
      but will be of much greater utility with future factoring out of standard
      implementations of that function.
      Signed-off-by: NMark Brown <broonie@linaro.org>
      2841a5fc
  27. 11 10月, 2013 2 次提交
  28. 08 10月, 2013 2 次提交
  29. 27 9月, 2013 2 次提交
  30. 17 9月, 2013 1 次提交