Commit Graph

1835 Commits

Author SHA1 Message Date
Trent Piepho
a560943ead spi: spi-mxs: Don't set clock for each xfer
mxs_spi_setup_transfer() would set the SSP SCK rate every time it was
called, which is before every transfer.  It is uncommon for the SCK rate to
change between transfers (or at all of that matter) and this causes many
unnecessary reprogrammings of the clock registers.

Code changed to only set the rate when it changes.  This significantly
speeds up short SPI messages, especially messages made up of many transfers,
as the calculation of the clock divisors is rather costly.  On an iMX287,
using spidev with messages that consist of 511 transfers of 4 bytes each at
an SCK of 48 MHz, the effective transfer rate more than doubles from about
290 KB/sec to 600 KB/sec!

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-18 01:00:32 +01:00
Trent Piepho
aa9e0c6feb spi: spi-mxs: Clean up setup_transfer function
It can't be called with a NULL transfer anymore so it can be simplified
to not check for that.

Fix indention of line-wrapped code to Linux standard.

The transfer pointer can be const.

It's not necessary to check if the spi_transfer's speed_hz is zero, as
the spi core also fills it in from the spi_device.  However, the spi
core does not check if spi_device's speed is zero so we have to do
that still.

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-18 01:00:32 +01:00
Trent Piepho
d426eadb1e spi: spi-mxs: Remove check of spi mode bits
The spi core already checks for a slave setting mode bits that we
didn't list as supported when the master was registered.  There is no
need to do it again in the master driver.

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-18 01:00:31 +01:00
Trent Piepho
9c97e3421f spi: spi-mxs: Fix race in setup method
Despite many warnings in the SPI documentation and code, the spi-mxs
driver sets shared chip registers in the ->setup method.  This method can
be called when transfers are in progress on other slaves controlled by the
master.  Setting registers or any other shared state will corrupt those
transfers.

So fix mxs_spi_setup() to not call mxs_spi_setup_transfer().
mxs_spi_setup_transfer() is already called for each transfer when they
are actually performed in mxs_spi_transfer_one(), so the call in
mxs_spi_setup() isn't necessary to setup anything.

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-18 01:00:31 +01:00
Trent Piepho
1a33073fcf spi: spi-mxs: Remove bogus setting of ssp clk rate field
The ssp struct has a clock rate field, to provide the actual value, in Hz,
of the SSP output clock (the rate of SSP_SCK) after mxs_ssp_set_clk_rate()
is called.  It is set by mxs_ssp_set_clk_rate(), for SSP using drivers (like
SPI and MMC) to *read* if they want to know the actual clock rate.  The SPI
driver isn't supposed to *write* to it.

For some reason the spi-mxs driver decides to write to this field on init,
and sets it to the value of the SSP input clock (clk_sspN, from the MXS
clocking block) in kHz.  It shouldn't be setting the value, and certainly
shouldn't be setting it with the wrong clock in the wrong units.

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-18 01:00:31 +01:00
Trent Piepho
210f65fedf spi: spi-mxs: Remove full duplex check, spi core already does it
Because the driver sets the SPI_MASTER_HALF_DUPLEX flag, the spi core
will check transfers to insure they are not full duplex.  It's not
necessary to check that in the spi-mxs driver as well.

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-18 01:00:30 +01:00
Trent Piepho
0b782f70b5 spi: spi-mxs: Fix chip select control bits in DMA mode
In DMA mode the chip select control bits would be ORed into the CTRL0
register without first clearing the bits.  This means that after
addressing slave 1, the CTRL0 bit to address slave 1 would be still be
set when addressing slave 0, resulting in slave 1 continuing to be
addressed.

The message handling function would pass the CS value to the txrx
function, which would re-program the bits on each transfer in the
message.  The selected CS does not change during a message so this is
inefficient.  It also means there are two different sets of code for
selecting the CS, one for PIO that worked and one for DMA that didn't.

Change the code to set the CS bits in the message handling function
once.  Now the DMA and PIO txrx functions don't need to care about CS
at all.

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-18 01:00:30 +01:00
Trent Piepho
df23286e57 spi: spi-mxs: Fix extra CS pulses and read mode in multi-transfer messages
There are two bits which control the CS line in the CTRL0 register:
LOCK_CS and IGNORE_CRC.  The latter would be better named DEASSERT_CS
in SPI mode.

Setting DEASSERT_CS causes CS to be de-asserted at the end of the transfer.
It should normally be set only for the final segment of the final transfer.
The DMA code explicitly sets it in this case, but because it never clears
the bit from the ctrl0 register, it will remain set for all transfers in
subsequent messages.  This results in a CS pulse between transfers.

There is a similar problem with the read mode bit never being cleared
in DMA mode.

This patch fixes DEASSERT_CS and READ being left on in DMA mode.

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-18 01:00:30 +01:00
Trent Piepho
28cad12588 spi: spi-mxs: Change flag arguments in txrx functions to bit flags
There are three flag arguments to the PIO and DMA txrx functions.  Two
are passed as pointers to integers, even though they are input only
and not modified, which makes no sense to do.  The third is passed as
an integer.

The compiler must use an argument register or stack variable for each
flag this way.  Using bitflags in a single flag argument is more
efficient and produces smaller code, since all the flags can fit in a
single register.  And all the flag arguments get cumbersome,
especially when more are added for things like GPIO chipselects.

The "first" flag is never used, so can just be deleted.

The "last" flag is renamed to DEASSERT_CS, since that's really what it
does.  The spi_transfer cs_change flag means that CS might be
de-asserted on a transfer which is not last and not de-assert on the
last transfer, so it is not which transfer is the last we need to know
but rather the transfers after which CS should be de-asserted.

This also extends the driver to not ignore cs_change when setting the
DEASSERT_CS nee "last" flag.

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-18 01:00:29 +01:00
Trent Piepho
75e73fa248 spi: spi-mxs: Always clear INGORE_CRC, to keep CS asserted
INGORE_CRC, better named DEASSERT_CS, should be cleared on all tranfers
except the last.  So instead of only clearing it on the first transfer, we
can just always clear it.  It will set on the last transfer.

This removes the only use of the "first" flag in the transfer functions, so
that flag can be then be removed.

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-18 01:00:29 +01:00
Trent Piepho
f5bc7384dc spi: spi-mxs: Remove mxs_spi_enable and mxs_spi_disable
These functions consist of nothing but one single writel call and are
only called once.  And the names really aren't accurate or clear,
since they don't enable or disble SPI.  Rather they set the bit that
controls the state of CS at the end of transfer.  It easier to follow
the code to just set this bit with a writel() along with all the other
bits being set in the same function.

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-18 01:00:29 +01:00
Trent Piepho
58f46e41c1 spi: spi-mxs: Always set LOCK_CS
There are two bits which control the CS line in the CTRL0 register:
LOCK_CS and IGNORE_CRC.  The latter would be better named DEASSERT_CS
in SPI mode.

LOCK_CS keeps CS asserted though the entire transfer.  This should
always be set.  The DMA code will always set it, explicitly on the
first segment of the first transfer, and then implicitly on all the
rest by never clearing the bit from the value read from the ctrl0
register.

The PIO code will explicitly set it for the first transfer, leave it
set for intermediate transfers, and then clear it for the final
transfer.  It should not clear it.

The only reason to not set LOCK_CS would be to attempt an altered
protocol where CS pulses between each word.  Though don't get your
hopes up if you want to do this, as the hardware doesn't appear to do
this in any sane manner.  It appears to be related to the hardware
FIFO fill level.

The code can be simplified by just setting LOCK_CS once and then not
needing to deal with it at all in the PIO and DMA transfer functions.

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-18 01:00:28 +01:00
Krzysztof Kozlowski
7b8f7eef1a spi/s3c64xx: Add missing pm_runtime_put on setup fail
pm_runtime_put() wasn't called if clock rate could not be set up in
s3c64xx_spi_setup() leading to invalid count of device pm_runtime usage.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-18 00:34:09 +01:00
Krzysztof Kozlowski
3833825011 spi/s3c64xx: Add missing pm_runtime_set_active() call in probe()
Mark device as PM runtime active during initialization to reflect
actual device power/clocks state. This reduces the enable count for SPI
bus controller gate clock so it can be disabled when the bus controller
is not used.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-18 00:33:11 +01:00
Mark Brown
f178e3dec7 spi/tegra20-slink: Move first transfer preparation to prepare_message
This is more idiomatic for the factored out message processing and gives a
small simplification of the code since we always set the per-transfer
parameters in the same fashion.

Signed-off-by: Mark Brown <broonie@linaro.org>
Tested-by: Stephen Warren <swarren@nvidia.com>
2013-10-17 10:57:48 +01:00
Mark Brown
63fc184cde spi/tegra20-slink: Crude refactoring to use core message parsing
This is a half done conversion with minimal code reorganisation provided
for bisection purposes. A further patch will move the first transfer
preparation into tegra_slink_prepare_message().

The cs_change and udelay handling is removed, these should be
implemented by the framework and in any case are buggy - the two fields
should not be related and the cs_change handling appears to at best only
work the first time it's used in a message.

Signed-off-by: Mark Brown <broonie@linaro.org>
Tested-by: Stephen Warren <swarren@nvidia.com>
2013-10-17 10:57:47 +01:00
Mark Brown
31407478a7 spi/atmel: Convert to devm_ioremap_resource()
This simplifies error handling.

Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-16 23:33:16 +01:00
Mark Brown
381bd9517a Merge remote-tracking branch 'spi/topic/trivial' into spi-atmel
Conflicts (trivial overlapping cleanups):
	drivers/spi/spi-atmel.c
2013-10-16 21:16:41 +01:00
Jarkko Nikula
f6bd03a746 spi: Don't break user-visible strings to multiple source lines in drivers
User-visible strings are more difficult to grep from sources if they are
separated to multiple source lines. This is worse than over 80 columns long
line code style violation.

Fix this by making those to single-line strings or by breaking them between
variables.

While at there, convert if (printk_ratelimit()) dev_warn() to use
dev_warn_ratelimited in spi-pxa2xx.c.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-16 19:07:15 +01:00
Jarkko Nikula
a1829d2b76 spi: Add missing newline to dev_ prints in drivers
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-16 19:07:15 +01:00
Sachin Kamat
ecc77773d3 spi: gpio: Include linux/of.h header
'of_match_ptr' is defined in linux/of.h. Include it explicitly.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-16 19:05:47 +01:00
Wei Yongjun
05209f4570 spi: fsl-dspi: add missing clk_disable_unprepare() in dspi_remove()
clock source is prepared and enabled by clk_prepare_enable()
in probe function, but no disable or unprepare in remove.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-15 13:52:40 +01:00
Jingoo Han
95c63cfba7 spi: spidev: Fix checkpatch issue
Fix the following checkpatch warnings.

  WARNING: Use #include <linux/uaccess.h> instead of <asm/uaccess.h>
  WARNING: braces {} are not necessary for any arm of this statement

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-15 13:15:52 +01:00
Jingoo Han
256fbf36d1 spi: txx9: Fix checkpatch issue
Fix the following checkpatch warnings.

  WARNING: space prohibited between function name and open parenthesis '('

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-15 13:14:42 +01:00
Jingoo Han
3cb7b407ce spi: tegra20-slink: Fix checkpatch issue
Fix the following checkpatch warning.

  WARNING: space prohibited before semicolon

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-15 13:14:03 +01:00
Jingoo Han
a29c8ae718 spi: sh-hspi: Fix checkpatch issue
Fix the following checkpatch warning.

  WARNING: space prohibited before semicolon

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-15 13:13:21 +01:00
Jingoo Han
3fed8068fb spi: orion: Fix checkpatch issue
Fix the following checkpatch warnings.

  WARNING: quoted string split across lines
  WARNING: sizeof *spi should be sizeof(*spi)

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-15 13:07:19 +01:00
Jingoo Han
ac8ed236a9 spi: butterfly: Fix checkpatch issue
Fix the following checkpatch errors and warnings.

  ERROR: space required before the open brace '{'
  ERROR: space required after that close brace '}'
  ERROR: space required before the open parenthesis '('
  ERROR: do not use C99 // comments
  WARNING: sizeof *pp should be sizeof(*pp)

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-15 13:04:24 +01:00
Jingoo Han
cff93c58f7 spi: bitbang: Fix checkpatch issue
Fix the following checkpatch warnings

  WARNING: sizeof *cs should be sizeof(*cs)
  WARNING: please, no space before tabs
  WARNING: space prohibited between function name and open parenthesis '('
  WARNING: line over 80 characters

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-14 18:23:48 +01:00
Jingoo Han
01b9e04186 spi: atmel: Fix checkpatch issue
Fix the following checkpatch warning.

  WARNING: quoted string split across lines

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-14 18:23:17 +01:00
Jingoo Han
5fe5f05e22 spi: Fix checkpatch issue
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: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-14 18:22:51 +01:00
Jingoo Han
e0045ebf3b spi: dw-pci: Use dev_info() instead of printk()
Change raw printk() call to dev_info() to provide a better message
to userspace so it can properly identify the device.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-14 18:21:00 +01:00
Jingoo Han
2c067509a1 spi: pl022: Use dev_info() instead of printk()
Change raw printk() call to dev_info() to provide a better message
to userspace so it can properly identify the device.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-14 18:20:10 +01:00
Mark Brown
0732a9d2a1 spi/s3c64xx: Use core message handling
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-11 20:10:17 +01:00
Mark Brown
2cc6e2e0c8 Merge remote-tracking branch 'spi/topic/s3c64xx' into spi-loop 2013-10-11 20:10:13 +01:00
Mark Brown
b158935f70 spi: Provide common spi_message processing loop
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: Mark Brown <broonie@linaro.org>
2013-10-11 20:09:50 +01:00
Mark Brown
6bb9c0e341 spi/s3c64xx: Use prepare_message() and unprepare_message()
This is of very little value in itself but will be useful once the loop
iterating over the transfers is also factored out into the core.

Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-11 20:09:14 +01:00
Mark Brown
2841a5fc37 spi: Provide per-message prepare and unprepare operations
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: Mark Brown <broonie@linaro.org>
2013-10-11 20:09:13 +01:00
Mika Westerberg
33cf00e570 spi: attach/detach SPI device to the ACPI power domain
If the SPI device is enumerated from ACPI namespace (it has an ACPI handle)
it might have ACPI methods that needs to be called in order to transition
the device to different power states (such as _PSx).

We follow what has been done for platform and I2C buses here and attach the
SPI device to the ACPI power domain if the device has an ACPI handle. This
makes sure that the device is powered on when its ->probe() is called.

For non-ACPI devices this patch is a no-op.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Mark Brown <broonie@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-10-11 02:23:14 +02:00
Jarkko Nikula
cf9eb39c6f spi: Fix modalias for ACPI enumerated SPI devices
There is a minor fault about ACPI enumerated SPI devices with their modalias
attribute. Now modalias is set by device instance not by hardware ID.
For example "spi:INTABCD:00", "spi:INTABCD:01" etc.

This means each device instance gets different modalias which does match
with generated modules.alias. Currently this is not problem as matching can
happen also with "acpi:INTABCD" modalias.

Fix this by using ACPI hardware ID.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-10 19:15:47 +01:00
Hiep Cao Minh
cb52c673f8 spi/rspi: Fix 8bit data access, clear buffer
The R8A7790 has QSPI module which added into RSPI together.
The transmit or receive data should be read from or written to
with the longword-, word-, or byte-access width. Modify word-
access to byte-access. In 16-bit data register, QSPI send or
receive datas access from high 8-bit while RSPI send or receive
datas access from low 8-bit on single mode.
Modify to reset transmit-receive buffer data and reading dummy
after data are transmited. RSPI has a TXMD bit on control
register(SPCR) to set transmit-only mode when transmit data or
Full-duplex synchronous mode when receive data. In QSPI the TXMD
bit is not supported, so after transmit data, dummy should be
read and before transmit or receive data the bufer register
should be reset.
This driver is the implementation of send and receive pio only,
DMA is not supported at this time.
Without this patch, it will occur error when transmit and receive

Signed-off-by: Hiep Cao Minh <cm-hiep@jinso.co.jp>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-10 11:23:25 +01:00
Rob Herring
5af5073004 drivers: clean-up prom.h implicit includes
Powerpc is a mess of implicit includes by prom.h. Add the necessary
explicit includes to drivers in preparation of prom.h cleanup.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Acked-by: Grant Likely <grant.likely@linaro.org>
2013-10-09 20:04:04 -05:00
Illia Smyrnov
5db542ed85 spi: omap2-mcspi: Fix FIFO support for transmit-and-receive mode
This patch fixes MCSPI FIFO buffer support when transmit-and-receive
(full duplex) mode is used. In this mode FIFO can be used for RX or
for TX or for both directions. If FIFO used for both directions the buffer
is split into two 32-byte buffers - one for each direction.
Also for full duplex mode both AEL and AFL need to be set in CHCONF0 register.

Signed-off-by: Illia Smyrnov <illia.smyrnov@globallogic.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-09 19:00:58 +01:00
Wolfram Sang
1d82d0c268 spi: spi-txx9: replace platform_driver_probe to support deferred probing
Subsystems like pinctrl and gpio rightfully make use of deferred probing at
core level. Now, deferred drivers won't be retried if they don't have a .probe
function specified in the driver struct. Fix this driver to have that, so the
devices it supports won't get lost in a deferred probe.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-09 12:09:57 +01:00
Wolfram Sang
93e9c90010 spi: spi-omap-uwire: replace platform_driver_probe to support deferred probing
Subsystems like pinctrl and gpio rightfully make use of deferred probing at
core level. Now, deferred drivers won't be retried if they don't have a .probe
function specified in the driver struct. Fix this driver to have that, so the
devices it supports won't get lost in a deferred probe.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-09 12:07:50 +01:00
Wolfram Sang
db9371b853 spi: spi-bfin5xx: replace platform_driver_probe to support deferred probing
Subsystems like pinctrl and gpio rightfully make use of deferred probing at
core level. Now, deferred drivers won't be retried if they don't have a .probe
function specified in the driver struct. Fix this driver to have that, so the
devices it supports won't get lost in a deferred probe.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-09 12:07:32 +01:00
Mark Brown
557667f643 Merge remote-tracking branch 'spi/topic/devm' into spi-bfin 2013-10-09 12:06:34 +01:00
Uwe Kleine-König
6a009e8d88 spi: efm32: drop unused struct and fix size check
The variable efm32_spi_pdata_default origins from an earlier revision of
the patch introducing the driver, its use was dropped because of review
comments but I forgot to also drop the variable itself.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-09 12:00:42 +01:00
Wolfram Sang
75dab1bfbb spi: spi-au1550: replace platform_driver_probe to support deferred probing
Subsystems like pinctrl and gpio rightfully make use of deferred probing at
core level. Now, deferred drivers won't be retried if they don't have a .probe
function specified in the driver struct. Fix this driver to have that, so the
devices it supports won't get lost in a deferred probe.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-09 11:59:03 +01:00
Greg Kroah-Hartman
aa7da564ca spi: convert bus code to use dev_groups
The dev_attrs field of struct bus_type is going away soon, dev_groups
should be used instead.  This converts the spi bus code to use the
correct field.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-08 10:34:56 +01:00
Mark Brown
ebd805cc14 spi/s3c64xx: Factor transfer start out of enable/disable_cs()
The hardware level /CS handling is tied to the start of the data path so
is rolled into the same function as we use to manipulate GPIO /CS. In
order to support factoring out the /CS handling into the core separate the
two and explicitly start transfers separately to the /CS handling.

Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-07 20:04:01 +01:00
Mark Brown
56ec1978ff spi: Provide trace points for message processing
Provide tracepoints for the lifecycle of a message from submission to
completion and for the active time for masters to help with performance
analysis of SPI I/O.

Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-07 20:02:01 +01:00
Mark Brown
fb30a1819a spi/tegra20-slink: Remove unused is_single_xfer check
Currently transfer_one_message() checks to see if the message consists of
a single spi_transfer and tells _start_transfer_one() but it just ignores
this. Don't bother.

Signed-off-by: Mark Brown <broonie@linaro.org>
Acked-by: Laxman Dewangan <ldewangan@nvidia.com>
2013-10-07 19:45:19 +01:00
Mark Brown
ac9fdc8864 Merge remote-tracking branch 'spi/fix/s3c64xx' into spi-linus 2013-10-07 14:51:59 +01:00
Mark Brown
896182ad31 Merge remote-tracking branch 'spi/fix/pxa' into spi-linus 2013-10-07 14:51:59 +01:00
Mark Brown
b242954b3c Merge remote-tracking branch 'spi/fix/mpc512x' into spi-linus 2013-10-07 14:51:58 +01:00
Mark Brown
78e9fa521e Merge remote-tracking branch 'spi/fix/hspi' into spi-linus 2013-10-07 14:51:58 +01:00
Mark Brown
5acb8bb441 Merge remote-tracking branch 'spi/fix/dspi' into spi-linus 2013-10-07 14:51:57 +01:00
Mark Brown
a19be58c9c Merge remote-tracking branch 'spi/fix/clps711x' into spi-linus 2013-10-07 14:51:56 +01:00
Uwe Kleine-König
e6f7563b73 spi: efm32: add spi_bitbang_stop to device remove callback
This call is needed to cleanup the resources requested by
spi_bitbang_start in the probe callback.

Noticed-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-07 14:51:24 +01:00
Mark Brown
77445a14d6 Merge remote-tracking branch 'spi/topic/bitbang' into HEAD 2013-10-07 14:51:17 +01:00
Axel Lin
702a4879ec spi: bitbang: Let spi_bitbang_start() take a reference to master
Many drivers that use bitbang library have a leak on probe error paths.
This is because once a spi_master_get() call succeeds, we need an additional
spi_master_put() call to free the memory.

Fix this issue by moving the code taking a reference to master to
spi_bitbang_start(), so spi_bitbang_start() will take a reference to master on
success. With this change, the caller is responsible for calling
spi_bitbang_stop() to decrement the reference and spi_master_put() as
counterpart of spi_alloc_master() to prevent a memory leak.

So now we have below patten for drivers using bitbang library:

probe:
spi_alloc_master        -> Init reference count to 1
spi_bitbang_start       -> Increment reference count
remove:
spi_bitbang_stop        -> Decrement reference count
spi_master_put          -> Decrement reference count (reference count reaches 0)

Fixup all users accordingly.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Suggested-by: Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
Acked-by: Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-07 14:50:43 +01:00
Sachin Kamat
de8cc234a5 spi: atmel: Fix incorrect error path
'irq' was not released when clk_prepare_enable failed.
Fix it.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-07 12:36:01 +01:00
Mark Brown
dabefd56c6 Merge remote-tracking branch 'spi/topic/devm' into spi-qspi
Conflicts:
	drivers/spi/spi-ti-qspi.c
2013-10-07 12:02:26 +01:00
Sebastian Andrzej Siewior
3b3a80019f spi: ti-qspi: one only one interrupt handler
The here used irq and threaded irq handler is a complete non-sense. After
the status register is read and the source disabled it schedules a thread
(the irq thread) to read the status from the variable, invoke complete()
and then renable the interrupt. Again: schedule a thread which invokes
_only_ complete().
This patch removes this non-sense and we remain with one handler which
invokes complete() if needed.
The device remove path should now disable the interupts.
This has been compile time tested.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Tested-by: Sourav Poddar <sourav.poddar@ti.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-07 11:29:22 +01:00
Mark Brown
2b2322d662 Merge remote-tracking branch 'spi/fix/clps711x' into spi-clps711x
Conflicts:
	drivers/spi/spi-clps711x.c
2013-10-03 17:25:40 +01:00
Sachin Kamat
c70837908d spi: clps711x: Remove redundant label
Remove empty label.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-03 17:01:59 +01:00
Kuninori Morimoto
268d76430d spi/hspi: fixup Runtime PM enable timing
3e00a09d2f
(spi/hspi: Convert to core runtime PM)
enabled master->auto_runtime_pm.
Then, pm_runtime_enable() is required *before*
spi_register_master() calling.
This patch fixed it up.
Kernel will hang up with "spi_master spi0: Failed to power device: -13"
message without this patch.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-10-03 14:08:06 +01:00
Mark Brown
0f5a751ace spi/s3c64xx: Enable GPIO /CS prior to starting hardware
To help with bisection of future refactoring to share more of the code for
handling a spi_message pull the enabling of GPIO based /CS prior to all
the hardware setup for starting a transfer.

Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-30 12:53:39 +01:00
Mark Brown
8c09daa1c9 spi/s3c64xx: Factor transfer start out of enable/disable_cs()
The hardware level /CS handling is tied to the start of the data path so
is rolled into the same function as we use to manipulate GPIO /CS. In
order to support factoring out the /CS handling into the core separate the
two and explicitly start transfers separately to the /CS handling.

Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-30 12:53:38 +01:00
Mark Brown
dd97e26849 spi/s3c64xx: Use core cs_gpio field
Rather than using the driver custom platform data to store the chip select
GPIO use the cs_gpio field provided by the SPI core, supporting future
refectoring.

Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-30 12:53:37 +01:00
Mark Brown
64d930ac11 spi/s3c64xx: Remove unused gpios field from driver data
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-30 12:53:37 +01:00
Mark Brown
8b06d5b857 spi/s3c64xx: Check that clock enables succeed on runtime resume
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-30 12:53:36 +01:00
Mark Brown
67651b29ef spi/s3c64xx: Flush FIFOs prior to cleaning up transfer
Ensure that the FIFOs are fully drained before we deassert /CS or do any
delays that have been requested in order to ensure that the behaviour
visible on the bus matches that which was requested by the caller.

Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-30 12:53:35 +01:00
Trent Piepho
89da4293a7 spi: Use of_property_read_u32
Instead of getting the raw property, checking the length, and doing
endian conversion each time, use the OF function
of_property_read_u32() that does all that.

Error messages are slightly improved with error codes from
of_property_read_u32() for different ways the property may be invalid
(missing, too short, etc.)

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-27 14:53:59 +01:00
Mathias Krause
70fac17cec spi: simplify call to request_module()
request_module() can handle format strings on its own, no need to create
the full module name ourself.

Signed-off-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-27 14:53:52 +01:00
Mark Brown
0cab71e701 Merge remote-tracking branch 'spi/fix/s3c64xx' into spi-s3c64xx
Conflicts:
	drivers/spi/spi-s3c64xx.c
2013-09-27 14:27:56 +01:00
Mark Brown
3e2bd64d24 spi/s3c64xx: Ensure runtime PM is enabled prior to registration
Otherwise we may try to start transfers immediately and then fail to
runtime resume the device causing us not to have clocks enabled.

Signed-off-by: Mark Brown <broonie@linaro.org>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>

Conflicts:
	drivers/spi/spi-s3c64xx.c
2013-09-27 14:26:04 +01:00
Rhyland Klein
f4fade12d5 spi/tegra114: Correct support for cs_change
The tegra114 driver wasn't currently handling the cs_change
functionality. cs_change is meant to invert the decisions of whether
or not to deactivate CS after each transfer. Without cs_change, after
every transfer (other than the last in the message) the normal behavior
is to leave CS active. For the last transfer, normally CS is
deactivated when the transfer is complete.

With cs_change set on a transfer (other than last one) CS would be
deactivated and the next transfer would need to activate it again. If
cs_change was set on the last tranfer in a message, then CS would be
left active when the message compeleted.

Also, this builds in logic so that if a different device tries to start
a transfer while CS is active from a different device, it will abort the
previous transfer and start a new one for the new device.

This splits tegra_spi_start_transfer_one into 2 functions, the new one
being tegra_spi_setup_transfer_one. The setup function is safe to call
on all transfers, sets up for the transfer, and handles the special case
of the first transfer in a message. In this special case, it needs to
know whether or not it needs to activate CS.

This work was based on the spi-atmel driver.

Signed-off-by: Rhyland Klein <rklein@nvidia.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-27 14:22:21 +01:00
Wei Yongjun
0158026ccc spi/clps711x: drop clk_put for devm_clk_get in spi_clps711x_probe()
devm_clk_get() is used so there is no reason to explicitly
call clk_put() in probe or remove functions.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-27 10:49:09 +01:00
Sourav Poddar
633795b992 spi/qspi: Add dual/quad read mode bit.
Add dual/quad read mode bit flag for the master controller.
These check will be used in the spi framework to determine
whether the master controller can do dual/quad read respectively.

Signed-off-by: Sourav Poddar <sourav.poddar@ti.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-26 12:12:04 +01:00
Mateusz Krawczuk
7d5f880b46 spi: s3c64xx: Allow build on all Samsung platforms
Replace all symbols by simple dependency PLAT_SAMSUNG.

Signed-off-by: Mateusz Krawczuk <m.krawczuk@partner.samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-26 12:08:46 +01:00
Jingoo Han
2fe7e4add3 spi: txx9: use devm_spi_register_master()
Use devm_spi_register_master() to make cleanup paths simpler,
and remove a duplicate put.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-26 11:43:10 +01:00
Jingoo Han
7388c03bac spi: ti-qspi: use devm_spi_register_master()
Use devm_spi_register_master() to make cleanup paths simpler,
and remove unnecessary remove().

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-26 11:43:09 +01:00
Jingoo Han
716db5d64f spi: tegra20-slink: use devm_spi_register_master()
Use devm_spi_register_master() to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-26 11:43:08 +01:00
Jingoo Han
f12f7318c4 spi: tegra20-sflash: use devm_spi_register_master()
Use devm_spi_register_master() to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-26 11:43:07 +01:00
Jingoo Han
5c80964396 spi: tegra114: use devm_spi_register_master()
Use devm_spi_register_master() to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-26 11:43:07 +01:00
Jingoo Han
1c43f2ae1e spi: sh-hspi: use devm_spi_register_master()
Use devm_spi_register_master() to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-26 11:42:53 +01:00
Jingoo Han
a807fcd090 spi: pxa2xx: use devm_spi_register_master()
Use devm_spi_register_master() to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-26 11:42:52 +01:00
Jingoo Han
35794a7716 spi: pl022: use devm_spi_register_master()
Use devm_spi_register_master() to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-26 11:42:44 +01:00
Jingoo Han
4bd3d8e36b spi: orion: use devm_spi_register_master()
Use devm_spi_register_master() to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-26 11:42:37 +01:00
Jingoo Han
b95e02b748 spi: omap2-mcspi: use devm_spi_register_master()
Use devm_spi_register_master() to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-26 11:42:36 +01:00
Jingoo Han
5c4c5c7be1 spi: omap-100k: use devm_spi_register_master()
Use devm_spi_register_master() to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-26 11:42:35 +01:00
Jingoo Han
22ad2d8df7 spi: octeon: use devm_spi_register_master()
Use devm_spi_register_master() to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-26 11:42:34 +01:00
Jingoo Han
33e195acf2 spi: mxs: use devm_spi_register_master()
Use devm_spi_register_master() to make cleanup paths simpler,
and remove a duplicate put.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-26 11:42:34 +01:00
Jingoo Han
eaa2429784 spi: mpc512x: use devm_spi_register_master()
Use devm_spi_register_master() to make cleanup paths simpler,
and remove a duplicate put.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-26 11:42:33 +01:00
Jingoo Han
434eaf3b23 spi: ep93xx: use devm_spi_register_master()
Use devm_spi_register_master() to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-26 11:42:32 +01:00
Jingoo Han
c493fc4bbd spi: clps711x: use devm_spi_register_master()
Use devm_spi_register_master() to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-26 11:42:31 +01:00
Jingoo Han
6221df6d88 spi: bfin-v3: use devm_spi_register_master()
Use devm_spi_register_master() to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-26 11:42:23 +01:00
Jingoo Han
bca76931b9 spi: bcm63xx: use devm_spi_register_master()
Use devm_spi_register_master() to make cleanup paths simpler,
and remove a duplicate put.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-26 11:41:18 +01:00