summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-mt65xx.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* spi: mediatek: add SPI_CS_HIGH supportLuhua Xu2019-11-181-2/+10
| | | | | | | | | Change to use SPI_CS_HIGH to support spi CS polarity setting for chips support enhance_timing. Signed-off-by: Luhua Xu <luhua.xu@mediatek.com> Link: https://lore.kernel.org/r/1574053037-26721-2-git-send-email-luhua.xu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: Use devm_platform_ioremap_resource() in mtk_spi_probe()Markus Elfring2019-10-011-10/+1
| | | | | | | | | | Simplify this function implementation by using a known wrapper function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Link: https://lore.kernel.org/r/478e0df1-e800-8cf1-f9b3-d72f8e26aa0b@web.de Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: support large PAluhua.xu2019-09-131-5/+39
| | | | | | | | Add spi large PA(max=64G) support for DMA transfer. Signed-off-by: luhua.xu <luhua.xu@mediatek.com> Link: https://lore.kernel.org/r/1568195731-3239-4-git-send-email-luhua.xu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: add spi support for mt6765 ICluhua.xu2019-09-131-0/+9
| | | | | | | | This patch add spi support for mt6765 IC. Signed-off-by: luhua.xu <luhua.xu@mediatek.com> Link: https://lore.kernel.org/r/1568195731-3239-3-git-send-email-luhua.xu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: Remove dev_err() usage after platform_get_irq()Stephen Boyd2019-08-021-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't need dev_err() messages when platform_get_irq() fails now that platform_get_irq() prints an error message itself when something goes wrong. Let's remove these prints with a simple semantic patch. // <smpl> @@ expression ret; struct platform_device *E; @@ ret = ( platform_get_irq(E, ...) | platform_get_irq_byname(E, ...) ); if ( \( ret < 0 \| ret <= 0 \) ) { ( -if (ret != -EPROBE_DEFER) -{ ... -dev_err(...); -... } | ... -dev_err(...); ) ... } // </smpl> While we're here, remove braces on if statements that only have one statement (manually). Cc: Mark Brown <broonie@kernel.org> Cc: linux-spi@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Stephen Boyd <swboyd@chromium.org> Link: https://lore.kernel.org/r/20190730181557.90391-42-swboyd@chromium.org Signed-off-by: Mark Brown <broonie@kernel.org>
* Merge tag 'v5.2-rc4' into spi-5.3Mark Brown2019-06-101-9/+1
|\ | | | | | | Linux 5.2-rc4
| * treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174Thomas Gleixner2019-05-301-9/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 as published by the free software foundation this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 655 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Richard Fontana <rfontana@redhat.com> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190527070034.575739538@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | spi: mediatek: add SPI_LSB_FIRST supportLeilk Liu2019-06-061-9/+6
|/ | | | | | | this patch add SPI_LSB_FIRST feature support. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: add spi support for mt7629 ICLeilk Liu2018-11-271-0/+3
| | | | | | | this patch add support for mt7629 IC. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* Merge branch 'spi-4.20' into spi-4.21 for uniphier DTMark Brown2018-11-061-2/+2
|\
| * spi: mediatek: use correct mata->xfer_len when in fifo transferLeilk Liu2018-10-311-2/+2
| | | | | | | | | | | | | | | | | | when xfer_len is greater than 64 bytes and use fifo mode to transfer, the actual length from the third time is mata->xfer_len but not len in mtk_spi_interrupt(). Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | spi: mediatek: add spi support for mt8183 ICLeilk Liu2018-11-051-0/+9
|/ | | | | | | this patch add support for mt8183 IC. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: Don't modify spi_transfer when transfer.Peter Shih2018-09-181-16/+21
| | | | | | | | | | | | | | Mediatek SPI driver modifies some fields (tx_buf, rx_buf, len, tx_dma, rx_dma) of the spi_transfer* passed in when doing transfer_one and in interrupt handler. This is somewhat unexpected, and there are some caller (e.g. Cr50 spi driver) that reuse the spi_transfer for multiple messages. Add a field to record how many bytes have been transferred, and calculate the right len / buffer based on it instead. Signed-off-by: Pi-Hsun Shih <pihsun@chromium.org> Change-Id: I23e218cd964f16c0b2b26127d4a5ca6529867673 Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: add spi support for mt2712 ICleilk.liu@mediatek.com2017-06-201-0/+7
| | | | | | | | this patch add support for mt2712 IC. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: add spi support for mt7622 ICLeilk Liu2017-06-131-0/+9
| | | | | | | this patch add support for mt7622 IC. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: adjust register to enhance time accuracyLeilk Liu2017-06-131-5/+40
| | | | | | | this patch adjust register to enhance time accuracy. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: Only do dma for 4-byte aligned buffersDaniel Kurtz2017-01-311-4/+33
| | | | | | | | | | | | | | | | | | | | | | | | | Mediatek SPI DMA only works when tx and rx buffer addresses are 4-byte aligned. Unaligned DMA transactions appeared to work previously, since we the spi core was incorrectly using the spi_master device for dma, which had a 0 dma_mask, and therefore the swiotlb dma map operations were falling back to using bounce buffers. Since each DMA transaction would use its own buffer, the mapped starting address of each transaction was always aligned. When doing real DMA, the mapped address will share the alignment of the raw tx/rx buffer provided by the SPI user, which may or may not be aligned. If a buffer is not aligned, we cannot use DMA, and must use FIFO based transaction instead. So, this patch implements a scheme that allows using the FIFO for arbitrary length transactions (larger than the 32-byte FIFO size) by reloading the FIFO in the interrupt handler. Signed-off-by: Daniel Kurtz <djkurtz@chromium.org> Cc: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: remove spi_master_put in mtk_spi_remove()Wei Yongjun2016-07-271-1/+0
| | | | | | | | | | | The call to spi_master_put() in mtk_spi_remove() is redundant since the master is registered using devm_spi_register_master() and no reference hold by using spi_master_get() in mtk_spi_remove(). This is detected by Coccinelle semantic patch. Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
*-. Merge remote-tracking branches 'spi/topic/lm70llp', 'spi/topic/loopback', ↵Mark Brown2016-01-111-15/+21
|\ \ | | | | | | | | | 'spi/topic/mtk' and 'spi/topic/omap2-mcspi' into spi-next
| | * spi: mediatek: Add spi support for mt2701 ICLeilk Liu2015-12-311-0/+3
| | | | | | | | | | | | | | | | | | | | | This patch adds spi support for mt2701 IC. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | * spi: mediatek: merge all identical compat to mtk_common_compatLeilk Liu2015-12-311-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch merge all identical compat into on mtk_common_compat and used for all compatible soc. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | * spi: mediatek: revise mtk_spi_probe() failure flowLeilk Liu2015-11-251-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | mtk_spi_probe() calls pm_runtime_enable(), after pm_runtime_enable() is called, it should call pm_runtime_disable() in the failure flow. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | * Merge branch 'fix/mediatek' of ↵Mark Brown2015-11-251-8/+18
| | |\ | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi into spi-mtk
| | * | spi: mediatek: remove needless pair of writel()/readl()leilk.liu@mediatek.com2015-11-211-3/+0
| |/ / | | | | | | | | | | | | | | | | | | | | | It's not need to re-read and re-write SPI_CMD_REG, so remove it. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | | Merge remote-tracking branch 'spi/fix/mtk' into spi-linusMark Brown2016-01-111-10/+18
|\ \ \ | |_|/ |/| |
| * | spi: mediatek: Prevent overflows in FIFO transfersNicolas Boichat2015-12-301-10/+18
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | In the case where transfer length is not a multiple of 4, KASAN reports 2 out-of-bounds memory accesses: - mtk_spi_interrupt: ioread32_rep writes past the end of trans->rx_buf. - mtk_spi_fifo_transfer: iowrite32_rep reads past the end of xfer->tx_buf. Fix this by using memcpy on the remainder of the bytes. Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Signed-off-by: Mark Brown <broonie@kernel.org>
* / spi: mediatek: single device does not require cs_gpiosNicolas Boichat2015-11-161-8/+18
|/ | | | | | | | | | | | | | | When only one device is present, it is not necessary to specify cs_gpios, as the CS line can be controlled by the hardware module. Without this patch, older device tree bindings used before 37457607 "spi: mediatek: mt8173 spi multiple devices support" would cause a panic on boot. This fixes the crash, and re-introduces backward compatibility. Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Acked-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: mt8173 spi multiple devices supportLeilk Liu2015-10-271-13/+52
| | | | | | | | | | | | | | | | | mt8173 IC spi HW has 4 gpio group, it's possible to support max <= 4 slave devices, even mtk spi HW is not congruent to spi core. 1. When a device do a spi_message transfer, spi HW should know which pad-group this device is on, and then writes pad-select register. 2. Mtk pad-select register just selects which MISO pin HW will receive data. For example, pad-select=1(select spi1 pins), HW just receives data from spi1 MISO, but it still send waveform to all 4 group cs/clk/mosi. If cs pin in other groups is still spi mode, after spi1 is selected(by active cs pin), devices on other group will also be selected. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: handle controller_data in mtk_spi_setupLeilk Liu2015-10-271-7/+12
| | | | | | | | controller_data is related with device, so move to master->setup function. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: remove mtk_spi_configLeilk Liu2015-10-271-33/+26
| | | | | | | | | mtk_spi_config() and mtk_spi_prepare_message() both initialize spi register, so remove mtk_spi_config() and init all register in mtk_spi_prepare_message(). Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
*-. Merge remote-tracking branches 'spi/fix/atmel', 'spi/fix/bcm2835', ↵Mark Brown2015-09-221-30/+23
|\ \ | | | | | | | | | 'spi/fix/doc', 'spi/fix/mediatek', 'spi/fix/meson', 'spi/fix/mtk' and 'spi/fix/pxa2xx' into spi-linus
| | * spi: mediatek: fix spi cs polarity errorLeilk Liu2015-09-071-20/+7
| |/ |/| | | | | | | | | | | | | | | | | Mediatek spi HW can't set cs inactive(keep cs high) directly. Instead, it supplies pause mode to do it indirectly. If driver unsets SPI_CMD_PAUSE_MODE in CMD_REG, it also needs to reset internal state machine to let cs inactive at once. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * spi: mediatek: fix wrong error return value on probeJavier Martinez Canillas2015-09-161-2/+2
| | | | | | | | | | | | | | | | | | | | Commit adcbcfea15d62 ("spi: mediatek: fix spi clock usage error") added a new sel_clk but introduced bugs in the error paths since the wrong struct clk pointers are passed to PTR_ERR(). Fixes: adcbcfea15d62 ("spi: mediatek: fix spi clock usage error") Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * spi: mediatek: fix spi clock usage errorLeilk Liu2015-08-311-8/+15
| | | | | | | | | | | | | | | | | | | | | | spi clock manages flow: CLK_TOP_SYSPLL3_D2 ---> CLK_TOP_SPI_SEL ---> CLK_PERI_SPI0 (source clock) (clock mux) (clock gate) spi driver should choose source clock by clock mux, then enable clock gate. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * spi: mediatek: remove clk_disable_unprepare()Leilk Liu2015-08-311-1/+0
|/ | | | | | | | | This patch removes clk_disable_unprepare() in mtk_spi_remove(). clk_disable_prepare/unprepare must be balance, spi-clk is disabled in mtk_spi_probe, so not needs to disable again. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: fix SPI_CMD_PAUSE_IE macro errorLeilk Liu2015-08-271-1/+1
| | | | | | | | enable pause interrupt should use SPI_CMD_PAUSE_IE MACRO, so fix it. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: replace *_time nameLeilk Liu2015-08-251-12/+8
| | | | | | | This patch replaces *_time name in mtk_spi_prepare_transfer(). Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: add PM clk_prepare_enable fail flowLeilk Liu2015-08-251-2/+11
| | | | | | | This patch adds PM clk_prepare_enable fail flow. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: replace int with u32, delete TAB and define ↵Leilk Liu2015-08-251-8/+10
| | | | | | | | | | MTK_SPI_PAUSE_INT_STATUS marco this patch replaces int with u32, deletes TAB, and defines MTK_SPI_PAUSE_INT_STATUS marco. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: add linux/io.h include fileLeilk Liu2015-08-251-0/+1
| | | | | | | | mediatek spi driver uses readl/writel, so add linux/io.h, even so it's implicitly imported by spi/spi.h Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: use BIT() to instead of SPI_CMD_*_OFFSETLeilk Liu2015-08-201-17/+20
| | | | | | | | This patch removes SPI_CMD_*_OFFSET defines, and uses the BIT(x) defines instead. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: medaitek: revise quirks compatibility styleLeilk Liu2015-08-201-18/+7
| | | | | | | The quirks are true/false, so define these as bool. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: fix spi incorrect endian usageLeilk Liu2015-08-201-22/+16
| | | | | | | | | TX_ENDIAN/RX_ENDIAN bits define whether to reverse the endian order of the data DMA from/to memory. The endian order should keep the same with cpu endian. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: remove redundant clock in prepare_hardware/unprepare_hardwareLeilk Liu2015-08-191-17/+0
| | | | | | | | clock in prepare_hardware/unprepare_hardware is redundant with pm_runtime, so remove them. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: Mediatek: fixup cpu_to_le32 incorrect usageLeilk Liu2015-08-131-4/+2
| | | | | | | | writel() already does a cpu_to_le32 conversion, so remove cpu_to_le32(). Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: fix endian warningsLeilk Liu2015-08-111-2/+4
| | | | | | | | | | | | | This patch fixes endian warnings detected by sparse: - sparse: incorrect type in argument 1 (different base types) expected unsigned int [unsigned] val got restricted __le32 [usertype] <noident> - sparse: incorrect type in argument 1 (different base types) expected unsigned int [unsigned] val got restricted __le32 [usertype] <noident> Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mt65xx: Fix module aliasAxel Lin2015-08-111-1/+1
| | | | | | | Remove extra space and make the alias matches driver name. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: mtk_spi_driver can be statickbuild test robot2015-08-071-1/+1
| | | | | Signed-off-by: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: mediatek: Add spi bus for Mediatek MT8173Leilk Liu2015-08-071-0/+749
This patch adds basic spi bus for MT8173. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>