Commit graph

251 commits

Author SHA1 Message Date
Andy Shevchenko
0e1f0b1ca7
spi: pxa2xx: Move OF and ACPI ID tables closer to their user
There is no code that uses ID tables directly, except the
struct device_driver at the end of the file. Hence, move
tables closer to its user. It's always possible to access
them via pointer to a platform device.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20221021190018.63646-5-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-10-24 13:30:18 +01:00
Andy Shevchenko
07c337927e
spi: pxa2xx: Remove no more needed PCI ID table
Since the PCI enumerated devices provide a property with SSP type,
there is no more necessity to bear the copy of the ID table here.
Remove it for good.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20221021190018.63646-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-10-24 13:30:17 +01:00
Andy Shevchenko
1a1864cd87
spi: pxa2xx: Respect Intel SSP type given by a property
Allow to set the Intel SSP type by reading the property.
Only apply this to the known MFD enumerated LPSS devices.

The check is done by the looking for the specifically
named IO memory resource provided by upper layer. This
won't be an issue in the future because we strictly
prioritize the order in which we are looking for the SSP
type in the code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20221021190018.63646-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-10-24 13:30:16 +01:00
Andy Shevchenko
88a947215c
spi: pxa2xx: Validate the correctness of the SSP type
Currently we blindly apply the SSP type value from any source of the
information. Increase robustness by validating the value before use.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20221021190018.63646-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-10-24 13:30:15 +01:00
Andy Shevchenko
6c3c438c08
spi: pxa2xx: Switch from PM ifdeffery to pm_ptr()
Cleaning up the driver to use pm_ptr() macro instead of ifdeffery
that makes it simpler and allows the compiler to remove those functions
if built without CONFIG_PM and CONFIG_PM_SLEEP support.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20221020194500.10225-6-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-10-21 13:17:04 +01:00
Andy Shevchenko
8fc8250a15
spi: pxa2xx: Consistently use dev variable in pxa2xx_spi_init_pdata()
We have a temporary variable to keep a pointer to a struct device in
the pxa2xx_spi_init_pdata(). Use it consistently there.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20221020194500.10225-5-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-10-21 13:17:03 +01:00
Andy Shevchenko
e3b7fca311
spi: pxa2xx: Simplify with devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

No functional changes.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20221017171243.57078-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-10-18 19:16:51 +01:00
Linus Torvalds
2bca25eaeb spi: Updates for v6.1
With the exception of some refactoring to fix long standing issues
 where we weren't handling cache syncs properly for messages which had
 PIO and DMA transfers going to the same page correctly there has been o
 work on the core this time around, and it's also been quite a quiet
 release for the drivers too:
 
  - Fix cache syncs for cases where we have DMA and PIO transfers in the
    same message going to the same page.
  - Update the fsl_spi driver to use transfer_one() rather than a custom
    transfer function.
  - Support for configuring transfer speeds with the AMD SPI controller.
  - Support for a second chip select and 64K erase on Intel SPI.
  - Support for Microchip coreQSPI, Nuvoton NPCM845, NXP i.MX93, and
    Rockchip RK3128 and RK3588.
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmM62YIACgkQJNaLcl1U
 h9CvPAf+MF1AzJJWH9DkR846KQh7Zt1rrujRuj5SGwvHewqjJcDtDmipAbM7mRFa
 VPk6fCzfRE4btVywCDMEQX2ToB9VKBNUeP8ihVLddWrTddbkQ7hOKlTrz31dJ+6W
 F9kwXkWcqWEpMYD/wr/25eT/kkNfv27oCyPU4dRQKoGGeF+zb9jYoj0+gPDl9Om8
 ok7D1XAwY1wOqYqdPfl2thcUrBfoKtFvkTj+NNhqwuzWwIqfQHM2skwAjmD3fliQ
 lLdRc54erCOqukDddIoWr348TyJIT4v1IXnkqY3cd7da6+kpixWae73o/7WIcQUR
 4MrtPply0WWcapgU/46sCbHpjJNjjg==
 =PDCv
 -----END PGP SIGNATURE-----

Merge tag 'spi-v6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi

Pull spi updates from Mark Brown:
 "With the exception of some refactoring to fix long standing issues
  where we weren't handling cache syncs properly for messages which had
  PIO and DMA transfers going to the same page correctly there has been
  no work on the core this time around, and it's also been quite a quiet
  release for the drivers too:

   - Fix cache syncs for cases where we have DMA and PIO transfers in
     the same message going to the same page

   - Update the fsl_spi driver to use transfer_one() rather than a
     custom transfer function

   - Support for configuring transfer speeds with the AMD SPI controller

   - Support for a second chip select and 64K erase on Intel SPI

   - Support for Microchip coreQSPI, Nuvoton NPCM845, NXP i.MX93, and
     Rockchip RK3128 and RK3588"

* tag 'spi-v6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: (73 commits)
  spi: Ensure that sg_table won't be used after being freed
  spi: spi-gxp: Use devm_platform_ioremap_resource()
  spi: s3c64xx: Fix large transfers with DMA
  spi: Split transfers larger than max size
  spi: Fix cache corruption due to DMA/PIO overlap
  spi: Save current RX and TX DMA devices
  spi: mt65xx: Add dma max segment size declaration
  spi: migrate mt7621 text bindings to YAML
  spi: renesas,sh-msiof: Add r8a779g0 support
  spi: spi-fsl-qspi: Use devm_platform_ioremap_resource_byname()
  spi: spi-fsl-lpspi: Use devm_platform_get_and_ioremap_resource()
  spi: spi-fsl-dspi: Use devm_platform_get_and_ioremap_resource()
  spi/omap100k:Fix PM disable depth imbalance in omap1_spi100k_probe
  spi: dw: Fix PM disable depth imbalance in dw_spi_bt1_probe
  spi: cadence-quadspi: Fix PM disable depth imbalance in cqspi_probe
  spi: s3c24xx: Switch to use devm_spi_alloc_master()
  spi: xilinx: Switch to use devm_spi_alloc_master()
  spi: img-spfi: using pm_runtime_resume_and_get instead of pm_runtime_get_sync
  spi: aspeed: Remove redundant dev_err call
  spi: spi-mpc52xx: switch to using gpiod API
  ...
2022-10-04 19:36:53 -07:00
Andy Shevchenko
2990f3a87e spi: pxa2xx: Refactor _UID handling to use acpi_dev_uid_to_integer()
ACPI utils provide acpi_dev_uid_to_integer() helper to extract _UID as
an integer. Use it instead of custom approach.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-09-19 18:34:42 +02:00
ye xingchen
d294e99cdc
spi: pxa2xx: Remove the unneeded result variable
Return the value clk_prepare_enable() directly instead of storing it in
another redundant variable.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Link: https://lore.kernel.org/r/20220825072828.229294-1-ye.xingchen@zte.com.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-08-25 12:29:36 +01:00
Jarkko Nikula
3190d4be37
spi: pxa2xx: Add support for Intel Meteor Lake-P
Add support for LPSS SPI on Intel Meteor Lake-P. It has three
controllers each having two chip selects.

This squashes a fix from Ap, Kamal <kamal.ap@intel.com> fixing incorrect
PCI ID of 3rd controller.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20220630073305.632850-1-jarkko.nikula@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-30 10:56:31 +01:00
Jarkko Nikula
54d0fd06e2
spi: pxa2xx: Add support for Intel Raptor Lake PCH-S
Add support for LPSS SPI on Intel Raptor Lake PCH-S. It has four
controllers each having two chip selects.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Link: https://lore.kernel.org/r/20220216091317.1302254-1-jarkko.nikula@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-02-16 16:34:26 +00:00
Linus Walleij
31455bbda2
spi: pxa2xx_spi: Convert to use GPIO descriptors
This converts the PXA2xx SPI driver to use GPIO descriptors
exclusively to retrieve GPIO chip select lines.

The device tree and ACPI paths of the driver already use
descriptors, hence ->use_gpio_descriptors is already set and
this codepath is well tested.

Convert all the PXA boards providing chip select GPIOs as
platform data and drop the old GPIO chipselect handling in
favor of the core managing it exclusively.

Cc: Marek Vasut <marek.vasut@gmail.com>
Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: linux-arm-kernel@lists.infradead.org
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220125005836.494807-1-linus.walleij@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-01-31 15:17:27 +00:00
Andy Shevchenko
12baee68b2
spi: pxa2xx: Propagate firmware node
Propagate firmware node by using a specific API call, i.e. device_set_node().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20211222155739.7699-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-12-23 13:38:40 +00:00
Andy Shevchenko
8393961c53
spi: pxa2xx: Get rid of unused enable_loopback member
There is no user of the enable_loopback member in the struct pxa2xx_spi_chip.
Remote this legacy member completely.

The mentioned in the documentation the testing phase can be performed with
spidev_test tool.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20211123192723.44537-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-11-29 12:20:00 +00:00
Andy Shevchenko
a9c8f68ce2
spi: pxa2xx: Get rid of unused ->cs_control()
Since the last user of the custom ->cs_control() gone, we may get rid of
this legacy API completely.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20211123192723.44537-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-11-29 12:19:59 +00:00
Andy Shevchenko
44ec41b7f7
spi: pxa2xx: Remove redundant ->read() and ->write() in struct chip_data
Since the commit 196b0e2cf2 ("spi: pxa2xx: Remove if statement
that is always true in pump_transfers()") the ->read() and ->write()
methods in the struct driver_data are reconfigured for each transfer.
Hence no need to keep the intermediate state in the struct chip_data.

The same applies to n_bytes member of the same data structure.
Get rid of unneeded storage for good.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20211122200622.43305-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-11-23 12:09:10 +00:00
Andy Shevchenko
e3aa9acc71
spi: pxa2xx: Adapt reset_sccr1() to the case when no message available
In some cases reset_sccr1() can be called when no message available.
This means that there is no associated chip to receive that message
and hence no threshold needs to be set. Adapt the function to such
cases.

Fixes: 3bbdc08326 ("spi: pxa2xx: Reuse int_stop_and_reset() in couple of places")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210721121520.62605-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-07-22 12:41:19 +01:00
Andy Shevchenko
3bbdc08326
spi: pxa2xx: Reuse int_stop_and_reset() in couple of places
Reuse int_stop_and_reset() in couple of places.

While at it, change the order of the int_stop_and_reset() and pxa2xx_spi_off()
to be in align with the similar flow in int_error_stop().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210719074842.36060-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-07-19 12:58:54 +01:00
Andy Shevchenko
cdcb26ce74
spi: pxa2xx: Reset DMA bits in CR1 in reset_sccr1()
In order to allow reset_sccr1() to be reused in DMA paths,
reset DMA bits in CR1 in this function.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210719074842.36060-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-07-19 12:58:53 +01:00
Andy Shevchenko
e0a6512d29
spi: pxa2xx: Convert reset_sccr1() to use pxa2xx_spi_update()
Convert reset_sccr1() to use pxa2xx_spi_update().
It will help for further improvements.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210719074842.36060-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-07-19 12:58:52 +01:00
Mark Brown
1a435466b0
Merge branch 'for-5.13' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi into spi-5.14 2021-06-01 18:33:33 +01:00
Lukas Wunner
2ec6f20b33
spi: Cleanup on failure of initial setup
Commit c7299fea67 ("spi: Fix spi device unregister flow") changed the
SPI core's behavior if the ->setup() hook returns an error upon adding
an spi_device:  Before, the ->cleanup() hook was invoked to free any
allocations that were made by ->setup().  With the commit, that's no
longer the case, so the ->setup() hook is expected to free the
allocations itself.

I've identified 5 drivers which depend on the old behavior and am fixing
them up hereinafter: spi-bitbang.c spi-fsl-spi.c spi-omap-uwire.c
spi-omap2-mcspi.c spi-pxa2xx.c

Importantly, ->setup() is not only invoked on spi_device *addition*:
It may subsequently be called to *change* SPI parameters.  If changing
these SPI parameters fails, freeing memory allocations would be wrong.
That should only be done if the spi_device is finally destroyed.
I am therefore using a bool "initial_setup" in 4 of the affected drivers
to differentiate between the invocation on *adding* the spi_device and
any subsequent invocations: spi-bitbang.c spi-fsl-spi.c spi-omap-uwire.c
spi-omap2-mcspi.c

In spi-pxa2xx.c, it seems the ->setup() hook can only fail on spi_device
addition, not any subsequent calls.  It therefore doesn't need the bool.

It's worth noting that 5 other drivers already perform a cleanup if the
->setup() hook fails.  Before c7299fea67, they caused a double-free
if ->setup() failed on spi_device addition.  Since the commit, they're
fine.  These drivers are: spi-mpc512x-psc.c spi-pl022.c spi-s3c64xx.c
spi-st-ssc4.c spi-tegra114.c

(spi-pxa2xx.c also already performs a cleanup, but only in one of
several error paths.)

Fixes: c7299fea67 ("spi: Fix spi device unregister flow")
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: Saravana Kannan <saravanak@google.com>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> # pxa2xx
Link: https://lore.kernel.org/r/f76a0599469f265b69c371538794101fa37b5536.1622149321.git.lukas@wunner.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-06-01 14:03:12 +01:00
Andy Shevchenko
70252440b2
spi: pxa2xx: Use predefined mask when programming FIFO thresholds
The predefined mask for threshold modification can be used
in case of Intel Merrifield SPI. Replace open-coded value
with predefined mask when programming FIFO thresholds.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210517140351.901-10-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-05-18 14:05:37 +01:00
Andy Shevchenko
8083d6b812
spi: pxa2xx: Fix style of and typos in the comments and messages
Fix style of the comments and messages along with typos in them.

While at it, update Intel Copyright year.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210517140351.901-8-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-05-18 14:05:35 +01:00
Andy Shevchenko
684a3ac720
spi: pxa2xx: Fix printf() specifiers
Instead of explicit casting use proper specifier in one case,
and fix specifier signness in another.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210517140351.901-7-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-05-18 14:05:34 +01:00
Andy Shevchenko
eb743ec600
spi: pxa2xx: Drop unneeded '!= 0' comparisons
In the few places it's redundant to compare against 0.
Drop the unneeded comparisons.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210517140351.901-6-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-05-18 14:05:33 +01:00
Andy Shevchenko
ccd60b2030
spi: pxa2xx: Drop duplicate chip_select in struct chip_data
The struct chip_data had been introduced in order to keep the parameters
that may be provided on stack during device allocation. There is no need
to duplicate parameters there, which are carried on by SPI device itself.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210517140351.901-5-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-05-18 14:05:32 +01:00
Andy Shevchenko
de6926f307
spi: pxa2xx: Switch to use SPI core GPIO (legacy) CS handling
SPI core has been already providing the GPIO CS handling. Use it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210517140351.901-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-05-18 14:05:31 +01:00
Andy Shevchenko
778c12e694
spi: pxa2xx: Switch to use SPI core GPIO (descriptor) CS handling
SPI core has been already providing the GPIO CS handling. Use it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210517140351.901-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-05-18 14:05:30 +01:00
Andy Shevchenko
94acf80755
spi: pxa2xx: Propagate firmware node to the child SPI controller device
SPI core may utilize properties and resources provided by the parent device.
Propagate firmware node to the child SPI controller device for that.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210517140351.901-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-05-18 14:05:29 +01:00
Andy Shevchenko
3fdb59cf10
spi: pxa2xx: Introduce special type for Merrifield SPIs
Intel Merrifield SPI is actually more closer to PXA3xx. It has extended FIFO
(32 bytes) and additional registers to get or set FIFO thresholds.

Introduce new type for Intel Merrifield SPI host controllers and handle bigger
FIFO size.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210510124134.24638-15-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-05-11 09:35:11 +01:00
Andy Shevchenko
6d380132ea
spi: pxa2xx: Extract read_SSSR_bits() helper
There are few places that repeat the logic of "read some bits from SSSR".
Extract read_SSSR_bits() helper to deduplicate that.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210510124134.24638-13-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-05-11 09:35:09 +01:00
Andy Shevchenko
42c80cd439
spi: pxa2xx: Extract clear_SSCR1_bits() helper
There are few places that repeat the logic of "clear some bits in SSCR1".
Extract clear_SSCR1_bits() helper to deduplicate that.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210510124134.24638-12-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-05-11 09:35:08 +01:00
Andy Shevchenko
1bed378c6b
spi: pxa2xx: Extract pxa2xx_spi_update() helper
There are few places that repeat the logic of "update if changed".
Extract pxa2xx_spi_update() helper to deduplicate that.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210510124134.24638-11-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-05-11 09:35:07 +01:00
Andy Shevchenko
0c8ccd8b26
spi: pxa2xx: Use pxa_ssp_enable()/pxa_ssp_disable() in the driver
There are few places that repeat the logic of pxa_ssp_enable() and
pxa_ssp_disable(). Use them instead of open coded variants.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210510124134.24638-10-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-05-11 09:35:06 +01:00
Andy Shevchenko
4761d2e7e5
spi: pxa2xx: Reuse int_error_stop() in pxa2xx_spi_slave_abort()
It appears that pxa2xx_spi_slave_abort()almost  repeats the functionality
of the int_error_stop(). Reuse int_error_stop() in pxa2xx_spi_slave_abort().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210510124134.24638-9-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-05-11 09:35:05 +01:00
Andy Shevchenko
ab77fe8935
spi: pxa2xx: Introduce int_stop_and_reset() helper
Currently we have three times the same few lines repeated in the code.
Deduplicate them by newly introduced int_stop_and_reset() helper.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210510124134.24638-8-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-05-11 09:35:04 +01:00
Andy Shevchenko
0e4768713e
spi: pxa2xx: Replace header inclusions by forward declarations
When the data structure is only referred by pointer, compiler may not need
to see the contents of the data type. Thus, we may replace header inclusions
by respective forward declarations. Due to above add missed headers as well.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210423182441.50272-5-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-05-10 13:17:12 +01:00
Andy Shevchenko
c3dce24c40
spi: pxa2xx: Utilize struct device from struct ssp_device
We have a duplication of struct device in the struct driver_data,
get rid of it and reuse member from struct ssp_device instead.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210423182441.50272-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-05-10 13:17:11 +01:00
Andy Shevchenko
9e43c9a8d5
spi: pxa2xx: Utilize MMIO and physical base from struct ssp_device
We have a duplication of MMIO and physical base addresses in
the struct driver_data, get rid of it and reuse members from
struct ssp_device instead.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210423182441.50272-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-05-10 13:17:10 +01:00
Andy Shevchenko
f2eed8caa3
spi: pxa2xx: Use one point of return when ->probe() fails
When we can't allocate SPI controller, jump to the error path rather than
return locally.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210423182441.50272-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-05-10 13:17:09 +01:00
Mark Brown
c7ed5fd5fb
Merge branch 'for-5.12' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi into spi-5.13 2021-04-15 19:29:40 +01:00
Jarkko Nikula
8c4ffe4d02
spi: pxa2xx: Add support for Intel Alder Lake PCH-M
Add support for LPSS SPI on Intel Alder Lake PCH-M.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Link: https://lore.kernel.org/r/20210415135917.54144-1-jarkko.nikula@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-15 16:06:55 +01:00
Jay Fang
c07caca3ce
spi: pxa2xx: Fix checkpatch spacing errors
Fix checkpatch errors:

  ERROR: space prohibited before that ',' (ctx:WxW)
  #255: FILE: spi-pxa2xx-pci.c:255:
  +	ssp->clk = clk_register_fixed_rate(&dev->dev, buf , NULL, 0,
 	                                                  ^
  ERROR: "foo* bar" should be "foo *bar"
  #621: FILE: spi-pxa2xx.c:621:
  +static void int_error_stop(struct driver_data *drv_data, const char* msg)

Signed-off-by: Jay Fang <f.fangjian@huawei.com>
Link: https://lore.kernel.org/r/1616566602-13894-4-git-send-email-f.fangjian@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-24 19:51:05 +00:00
Jarkko Nikula
a402e397b9
spi: pxa2xx: Add support for Intel Alder Lake PCH-P
Add support for LPSS SPI on Intel Alder Lake PCH-P variant.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Link: https://lore.kernel.org/r/20210114144021.1820262-1-jarkko.nikula@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-01-14 16:46:09 +00:00
Lukas Wunner
5626308bb9
spi: pxa2xx: Fix use-after-free on unbind
pxa2xx_spi_remove() accesses the driver's private data after calling
spi_unregister_controller() even though that function releases the last
reference on the spi_controller and thereby frees the private data.

Fix by switching over to the new devm_spi_alloc_master/slave() helper
which keeps the private data accessible until the driver has unbound.

Fixes: 32e5b57232 ("spi: pxa2xx: Fix controller unregister order")
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: <stable@vger.kernel.org> # v2.6.17+: 5e844cc37a: spi: Introduce device-managed SPI controller allocation
Cc: <stable@vger.kernel.org> # v2.6.17+: 32e5b57232: spi: pxa2xx: Fix controller unregister order
Cc: <stable@vger.kernel.org> # v2.6.17+
Link: https://lore.kernel.org/r/5764b04d4a6e43069ebb7808f64c2f774ac6f193.1607286887.git.lukas@wunner.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-12-07 14:18:50 +00:00
Jarkko Nikula
b8450e0142
spi: pxa2xx: Add support for Intel Alder Lake PCH-S
Add support for LPSS SPI on Intel Alder Lake. It has four LPSS SPI
controllers each having two chip selects.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Link: https://lore.kernel.org/r/20201204082409.183700-1-jarkko.nikula@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-12-04 18:03:59 +00:00
Lee Jones
9b2d611929
spi: spi-pxa2xx: Do not define 'struct acpi_device_id' when !CONFIG_ACPI
Since ACPI_PTR() is used to NULLify the value when !CONFIG_ACPI,
struct 'pxa2xx_spi_acpi_match' becomes defined but unused.

Fixes the following W=1 kernel build warning(s):

 drivers/spi/spi-pxa2xx.c:1435:36: warning: ‘pxa2xx_spi_acpi_match’ defined but not used [-Wunused-const-variable=]
 1435 | static const struct acpi_device_id pxa2xx_spi_acpi_match[] = {
 | ^~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Link: https://lore.kernel.org/r/20200717135424.2442271-14-lee.jones@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-07-17 16:38:55 +01:00
Mark Brown
411b0f305b
Merge series "spi: spi-sun6i: One fix and some improvements" from Marc Kleine-Budde <mkl@pengutronix.de>:
Hello,

this series first fixes the calculation of the clock rate. The driver will
round up to the nearest clock rate instead of rounding down. Resulting in SPI
devices accessed with a too high SPI clock.

The remaining patches improve the performance of the driver. The changes range
from micro-optimizations like reducing MMIO writes to the controller to
reducing the number of needed interrupts in some use cases.

regards,
Marc

changes since v1:
- added Maxime Ripard's to the existing patches
- 06/10: (was 05/10 in v1)
  "spi: spi-sun6i: sun6i_spi_drain_fifo(): introduce sun6i_spi_get_rx_fifo_count() and make use of it"
  use FIELD_GET instead of open coding it
  (tnx: Maxime Ripard)
- 05/10: "spi: spi-sun6i: sun6i_spi_get_tx_fifo_count: Convert manual shift+mask to FIELD_GET()"
  new patch

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
2020-07-07 14:26:33 +01:00