Commit graph

37 commits

Author SHA1 Message Date
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
Mark Brown 85cac43132 Merge remote-tracking branch 'spi/topic/qspi' into spi-next 2013-09-01 13:49:06 +01:00
Mark Brown 68aa4cb337 Merge remote-tracking branch 'spi/topic/pdata' into spi-next 2013-09-01 13:49:03 +01:00
Axel Lin a1216394e6 spi: Use dev_get_drvdata at appropriate places
Use dev_get_drvdata() instead of platform_get_drvdata(to_platform_device(dev)).

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-08-29 13:57:14 +01:00
Jingoo Han 8074cf063e spi: use dev_get_platdata()
Use the wrapper function for retrieving the platform data instead of
accessing dev->platform_data directly.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-08-29 13:56:23 +01:00
Julia Lawall de0fa83c41 spi/spi-{bcm63xx.c,bfin-v3.c}: simplify use of devm_ioremap_resource
Remove unneeded error handling on the result of a call to
platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to
devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n);
  ... when != res
- if (res == NULL) { ... \(goto l;\|return ret;\) }
  ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n);
  e = devm_ioremap_resource(e1, res);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-08-14 17:47:58 +01:00
Mark Brown 5355d96d6f spi/bcm63xx: Convert to core runtime PM
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-07-29 18:00:19 +01:00
Mark Brown 6140b05ca3 Merge remote-tracking branch 'spi/topic/core' into spi-next 2013-06-26 16:20:58 +01:00
Stephen Warren 24778be20f spi: convert drivers to use bits_per_word_mask
Fill in the recently added spi_master.bits_per_word_mask field in as
many drivers as possible. Make related cleanups, such as removing any
redundant error-checking, or empty setup callbacks.

Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
Acked-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-05-29 20:48:17 +01:00
Jingoo Han 89e8773075 spi: remove unnecessary platform_set_drvdata()
The driver core clears the driver data to NULL after device_release
or on probe failure, since commit 0998d06310
(device-core: Ensure drvdata = NULL when no driver is bound).
Thus, it is not needed to manually clear the device driver data to NULL.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Grant Likely <grant.likely@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-05-13 18:00:30 +04:00
Jonas Gorski ab300d1817 spi/bcm63xx: remove unused speed_hz variable
speed_hz is a write only member, so we can safely remove it and its
generation. Also fixes the missing clk_put after getting the periph
clock.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-04-08 13:42:10 +01:00
Jonas Gorski b66c773002 spi/bcm63xx: use devm_ioremap_resource()
Use devm_ioremap_resource() which provides its own error messages.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
Acked-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-12 19:14:48 +00:00
Jonas Gorski 68792e2a19 spi/bcm63xx: inline hz usage in bcm63xx_spi_setup_transfer
bcm63xx_spi_setup_transfer is called from only one place, and that has
t always set, to hz will always be t->speed_hz - just use it directly in
the two places instead of moving it in a local variable.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
Acked-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-12 19:14:48 +00:00
Jonas Gorski c94df49542 spi/bcm63xx: inline bcm63xx_spi_check_transfer
It only does one check, so just do the check directly in the caller.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
Acked-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-12 19:14:47 +00:00
Jonas Gorski 31e4eaaa54 spi/bcm63xx: remove spi chip select validity check
The check would belong in bcm63xx_spi_setup if the spi subsystem
weren't already doing the check for us, so just drop it.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
Acked-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-12 19:14:46 +00:00
Jonas Gorski 58d8bebea5 spi/bcm63xx: simplify bcm63xx_spi_check_transfer
bcm63xx_spi_check_transfer is only called from one place that has
t always set, so directly check the transfer's bits_per_word.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
Acked-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-12 19:14:46 +00:00
Jonas Gorski e2bdae0632 spi/bcm63xx: check spi bits_per_word in spi_setup
Instead of fixing up the bits_per_word (which the spi subsystem already
does for us), check it for supported values.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
Acked-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-12 19:14:45 +00:00
Jonas Gorski 52f83bbd65 spi/bcm63xx: remove unused variable bs from bcm63xx_spi_setup
It is only written, but never read.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
Acked-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-12 19:14:44 +00:00
Jonas Gorski c3db2b0b14 spi/bcm63xx: remove unneeded debug message
The spi subsystem already provides this info in a more extensive
debug print except for the nsecs/bit - which wasn't calculated anyway
and fixed to 0.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
Acked-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-12 19:14:44 +00:00
Jonas Gorski ef9ed4b9c9 spi/bcm63xx: remove duplicated mode bits check
The spi subsystem already checks the mode bits before calling setup.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
Acked-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-12 19:14:38 +00:00
Jonas Gorski 4fbb82a76d spi/bcm63xx: properly prepare clocks before enabling them
Use proper clk_prepare/unprepare calls in preparation for switching
to the generic clock framework.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
Acked-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-12 19:14:35 +00:00
Jonas Gorski b435ff212e spi/bcm63xx: don't disable non enabled clocks in probe error path
When msg_ctl_width is set to an invalid value we try to disable the
clock despite it never being enabled. Fix it by jumping to the correct
label.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
Acked-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-12 19:11:31 +00:00
Kevin Cernekee 4a25b680b1 spi/bcm63xx: Remove unused variable
This fixes the following warning:

drivers/spi/spi-bcm63xx.c: In function 'bcm63xx_spi_setup':
drivers/spi/spi-bcm63xx.c:157:6: warning: unused variable 'ret'

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Acked-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-12 19:11:21 +00:00
Jonas Gorski b17de07606 spi/bcm63xx: work around inability to keep CS up
This SPI controller does not support keeping CS asserted after sending
a transfer.
Since messages expected on this SPI controller are rather short, we can
work around it for normal use cases by sending all transfers at once in
a big full duplex stream.

This means that we cannot change the speed between transfers if they
require CS to be kept asserted, but these would have been rejected
before anyway because of the inability of keeping CS asserted.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2013-02-05 17:14:33 +00:00
Jonas Gorski c0fde3ba0e spi/bcm63xx: reject transfers unable to transfer
The hardware does not support keeping CS asserted after sending one
FIFO buffer worth of data, so reject transfers requiring CS being kept
asserted, either between transers or for a certain time after it,
or exceeding the FIFO size.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
Acked-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2013-02-05 14:44:13 +00:00
Grant Likely fd4a319bc9 spi: Remove HOTPLUG section attributes
CONFIG_HOTPLUG is going away as an option.  As result the __dev*
markings will be going away.

Remove use of __devinit, __devexit_p, __devinitdata, __devinitconst,
and __devexit.

Bill Pemberton has done most of the legwork on this series. I've used
his script to purge the attributes from the drivers/gpio tree.

Reported-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2012-12-07 17:06:43 +00:00
Florian Fainelli b308fb208e spi/bcm63xx: remove useless call to bcm63xx_spi_check_transfer()
Calling bcm63xx_spi_check_transfer() with a NULL argument does not do
anything useful that the core spi code is not doing already, remove
this superfluous call.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-10-17 16:13:25 +09:00
Florian Fainelli 965199573a spi/bcm63xx: add missing spi_master_{resume,suspend} calls to PM callbacks
The PM callbacks implemented by the spi-bcm63xx driver don't call
spi_master_{resume,suspend}, fix that.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-10-17 16:13:25 +09:00
Florian Fainelli 61d1596317 spi/bcm63xx: remove driver version
As Grant Likely reported, this does not make any sense in a mainline kernel
remove that driver version string.

Reported-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-10-17 16:13:24 +09:00
Linus Torvalds 2432cbe4f2 Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus
Pull MIPS fixes from Ralf Baechle:
 "Random fixes across the MIPS tree.  The two hotspots are several bugs
  in the module loader and the ath79 SOC support; also noteworthy is the
  restructuring of the code to synchronize CPU timers across CPUs on
  startup; the old code recently ceased to work due to unrelated
  changes.

  All except one of these patches have sat for a significant time in
  linux-next for testing."

* 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus:
  MIPS: pci-ar724x: avoid data bus error due to a missing PCIe module
  MIPS: Malta: Delete duplicate PCI fixup.
  MIPS: ath79: don't hardcode the unavailability of the DSP ASE
  MIPS: Synchronize MIPS count one CPU at a time
  MIPS: BCM63xx: Fix SPI message control register handling for BCM6338/6348.
  MIPS: Module: Deal with malformed HI16/LO16 relocation sequences.
  MIPS: Fix race condition in module relocation code.
  MIPS: Fix memory leak in error path of HI16/LO16 relocation handling.
  MIPS: MTX-1: Add udelay to mtx1_pci_idsel
  MIPS: ath79: select HAVE_CLK
  MIPS: ath79: Use correct IRQ number for the OHCI controller on AR7240
  MIPS: ath79: Fix number of GPIO lines for AR724[12]
  MIPS: Octeon: Fix broken interrupt controller code.
2012-08-25 11:45:04 -07:00
Florian Fainelli 5a6704454a MIPS: BCM63xx: Fix SPI message control register handling for BCM6338/6348.
BCM6338 and BCM6348 have a message control register width of 8 bits, instead
of 16-bits like what the SPI driver assumes right now. Also the SPI message
type shift value of 14 is actually 6 for these SoCs.
This resulted in transmit FIFO corruption because we were writing 16-bits
to an 8-bits wide register, thus spanning on the first byte of the transmit
FIFO, which had already been filed in bcm63xx_spi_fill_txrx_fifo().

Fix this by passing the message control register width and message type
shift through platform data back to the SPI driver so that it can use
it properly.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
Cc: linux-mips@linux-mips.org
Cc: grant.likely@secretlab.ca
Cc: spi-devel-general@lists.sourceforge.net
Cc: jonas.gorski@gmail.com
Patchwork: https://patchwork.linux-mips.org/patch/3983/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2012-08-17 10:57:28 +02:00
Guenter Roeck 1f68237865 spi/bcm63xx: Ensure that memory is freed only after it is no longer used
The call to spi_unregister_master() in the device remove function frees device
memory, and with it any device local data. However, device local data is still
accessed after the call to spi_unregister_master().

Acquire a reference to the SPI device and release it after cleanup is complete
to solve the problem.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-08-13 13:29:20 +01:00
Florian Fainelli d76ea24ac4 spi/bcm63xx: fix clock configuration selection
We are currently using an inferior or equal operator for comparing
the transfer frequency with the clock frequency table. Because of
this, we always end up selecting 20Mhz as a frequency, due to the
inequality transfer hz <= 20 Mhz being always true. Fix this by
reversing the inequality, which is how the comparison should be done.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-07-23 14:14:11 +01:00
Florian Fainelli 88a3a255a5 spi/bcm63xx: set master driver mode_bits.
We were not properly advertising the MODE bits supported by this driver, fix
that.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2012-04-27 11:19:15 -06:00
Florian Fainelli 1e41dc0ee2 spi/bcm63xx: don't use the stopping state
We do not need to use a flag to indicate if the master driver is stopping
it is sufficient to perform spi master unregistering in the platform
driver's remove function.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2012-04-27 11:16:46 -06:00
Florian Fainelli cde4384e10 spi/bcm63xx: convert to the pump message infrastructure
This patch converts the bcm63xx SPI driver to use the SPI infrastructure
pump message queue. Since we were previously sleeping in the SPI
driver's transfer() function (which is not allowed) this is now fixed as well.

To complete that conversion a certain number of changes have been made:
- the transfer len is split into multiple hardware transfers in case its
  size is bigger than the hardware FIFO size
- the FIFO refill is no longer done in the interrupt context, which was a
  bad idea leading to quick interrupt handler re-entrancy

Tested-by: Tanguy Bouzeloc <tanguy.bouzeloc@efixo.com>
Signed-off-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2012-04-27 11:15:41 -06:00
Florian Fainelli b42dfed83d spi: add Broadcom BCM63xx SPI controller driver
This patch adds support for the SPI controller found on the Broadcom BCM63xx
SoCs.

Signed-off-by: Tanguy Bouzeloc <tanguy.bouzeloc@efixo.com>
Signed-off-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2012-03-09 15:03:03 -07:00