···11-Synopsys DesignWare AMBA 2.0 Synchronous Serial Interface.22-33-Required properties:44-- compatible : "snps,dw-apb-ssi" or "mscc,<soc>-spi", where soc is "ocelot" or55- "jaguar2", or "amazon,alpine-dw-apb-ssi"66-- reg : The register base for the controller. For "mscc,<soc>-spi", a second77- register set is required (named ICPU_CFG:SPI_MST)88-- interrupts : One interrupt, used by the controller.99-- #address-cells : <1>, as required by generic SPI binding.1010-- #size-cells : <0>, also as required by generic SPI binding.1111-- clocks : phandles for the clocks, see the description of clock-names below.1212- The phandle for the "ssi_clk" is required. The phandle for the "pclk" clock1313- is optional. If a single clock is specified but no clock-name, it is the1414- "ssi_clk" clock. If both clocks are listed, the "ssi_clk" must be first.1515-1616-Optional properties:1717-- clock-names : Contains the names of the clocks:1818- "ssi_clk", for the core clock used to generate the external SPI clock.1919- "pclk", the interface clock, required for register access. If a clock domain2020- used to enable this clock then it should be named "pclk_clkdomain".2121-- cs-gpios : Specifies the gpio pins to be used for chipselects.2222-- num-cs : The number of chipselects. If omitted, this will default to 4.2323-- reg-io-width : The I/O register width (in bytes) implemented by this2424- device. Supported values are 2 or 4 (the default).2525-2626-Child nodes as per the generic SPI binding.2727-2828-Example:2929-3030- spi@fff00000 {3131- compatible = "snps,dw-apb-ssi";3232- reg = <0xfff00000 0x1000>;3333- interrupts = <0 154 4>;3434- #address-cells = <1>;3535- #size-cells = <0>;3636- clocks = <&spi_m_clk>;3737- num-cs = <2>;3838- cs-gpios = <&gpio0 13 0>,3939- <&gpio0 14 0>;4040- };4141-
···11-Device tree configuration for Renesas RSPI/QSPI driver22-33-Required properties:44-- compatible : For Renesas Serial Peripheral Interface on legacy SH:55- "renesas,rspi-<soctype>", "renesas,rspi" as fallback.66- For Renesas Serial Peripheral Interface on RZ/A:77- "renesas,rspi-<soctype>", "renesas,rspi-rz" as fallback.88- For Quad Serial Peripheral Interface on R-Car Gen2 and99- RZ/G1 devices:1010- "renesas,qspi-<soctype>", "renesas,qspi" as fallback.1111- Examples with soctypes are:1212- - "renesas,rspi-sh7757" (SH)1313- - "renesas,rspi-r7s72100" (RZ/A1H)1414- - "renesas,rspi-r7s9210" (RZ/A2)1515- - "renesas,qspi-r8a7743" (RZ/G1M)1616- - "renesas,qspi-r8a7744" (RZ/G1N)1717- - "renesas,qspi-r8a7745" (RZ/G1E)1818- - "renesas,qspi-r8a77470" (RZ/G1C)1919- - "renesas,qspi-r8a7790" (R-Car H2)2020- - "renesas,qspi-r8a7791" (R-Car M2-W)2121- - "renesas,qspi-r8a7792" (R-Car V2H)2222- - "renesas,qspi-r8a7793" (R-Car M2-N)2323- - "renesas,qspi-r8a7794" (R-Car E2)2424-- reg : Address start and address range size of the device2525-- interrupts : A list of interrupt-specifiers, one for each entry in2626- interrupt-names.2727- If interrupt-names is not present, an interrupt specifier2828- for a single muxed interrupt.2929-- interrupt-names : A list of interrupt names. Should contain (if present):3030- - "error" for SPEI,3131- - "rx" for SPRI,3232- - "tx" to SPTI,3333- - "mux" for a single muxed interrupt.3434-- num-cs : Number of chip selects. Some RSPI cores have more than 1.3535-- #address-cells : Must be <1>3636-- #size-cells : Must be <0>3737-3838-Optional properties:3939-- clocks : Must contain a reference to the functional clock.4040-- dmas : Must contain a list of two references to DMA specifiers,4141- one for transmission, and one for reception.4242-- dma-names : Must contain a list of two DMA names, "tx" and "rx".4343-4444-Pinctrl properties might be needed, too. See4545-Documentation/devicetree/bindings/pinctrl/renesas,*.4646-4747-Examples:4848-4949- spi0: spi@e800c800 {5050- compatible = "renesas,rspi-r7s72100", "renesas,rspi-rz";5151- reg = <0xe800c800 0x24>;5252- interrupts = <0 238 IRQ_TYPE_LEVEL_HIGH>,5353- <0 239 IRQ_TYPE_LEVEL_HIGH>,5454- <0 240 IRQ_TYPE_LEVEL_HIGH>;5555- interrupt-names = "error", "rx", "tx";5656- interrupt-parent = <&gic>;5757- num-cs = <1>;5858- #address-cells = <1>;5959- #size-cells = <0>;6060- };6161-6262- spi: spi@e6b10000 {6363- compatible = "renesas,qspi-r8a7791", "renesas,qspi";6464- reg = <0 0xe6b10000 0 0x2c>;6565- interrupt-parent = <&gic>;6666- interrupts = <0 184 IRQ_TYPE_LEVEL_HIGH>;6767- clocks = <&mstp9_clks R8A7791_CLK_QSPI_MOD>;6868- num-cs = <1>;6969- #address-cells = <1>;7070- #size-cells = <0>;7171- dmas = <&dmac0 0x17>, <&dmac0 0x18>;7272- dma-names = "tx", "rx";7373- };
···11-Socionext UniPhier SPI controller driver22-33-UniPhier SoCs have SCSSI which supports SPI single channel.44-55-Required properties:66- - compatible: should be "socionext,uniphier-scssi"77- - reg: address and length of the spi master registers88- - #address-cells: must be <1>, see spi-bus.txt99- - #size-cells: must be <0>, see spi-bus.txt1010- - interrupts: a single interrupt specifier1111- - pinctrl-names: should be "default"1212- - pinctrl-0: pin control state for the default mode1313- - clocks: a phandle to the clock for the device1414- - resets: a phandle to the reset control for the device1515-1616-Example:1717-1818-spi0: spi@54006000 {1919- compatible = "socionext,uniphier-scssi";2020- reg = <0x54006000 0x100>;2121- #address-cells = <1>;2222- #size-cells = <0>;2323- interrupts = <0 39 4>;2424- pinctrl-names = "default";2525- pinctrl-0 = <&pinctrl_spi0>;2626- clocks = <&peri_clk 11>;2727- resets = <&peri_rst 11>;2828-};
···892892F: drivers/gpu/drm/amd/include/vi_structs.h893893F: include/uapi/linux/kfd_ioctl.h894894895895+AMD SPI DRIVER896896+M: Sanjay R Mehta <sanju.mehta@amd.com>897897+S: Maintained898898+F: drivers/spi/spi-amd.c899899+895900AMD MP2 I2C DRIVER896901M: Elie Morisse <syniurge@gmail.com>897902M: Nehal Shah <nehal-bakulchandra.shah@amd.com>
+16-6
drivers/spi/Kconfig
···226226 help227227 general driver for SPI controller core from DesignWare228228229229+if SPI_DESIGNWARE230230+231231+config SPI_DW_DMA232232+ bool "DMA support for DW SPI controller"233233+229234config SPI_DW_PCI230235 tristate "PCI interface driver for DW SPI core"231231- depends on SPI_DESIGNWARE && PCI232232-233233-config SPI_DW_MID_DMA234234- bool "DMA support for DW SPI controller on Intel MID platform"235235- depends on SPI_DW_PCI && DW_DMAC_PCI236236+ depends on PCI236237237238config SPI_DW_MMIO238239 tristate "Memory-mapped io interface driver for DW SPI core"239239- depends on SPI_DESIGNWARE240240+ depends on HAS_IOMEM241241+242242+endif240243241244config SPI_DLN2242245 tristate "Diolan DLN-2 USB SPI adapter"···847844config SPI_UNIPHIER848845 tristate "Socionext UniPhier SPI Controller"849846 depends on (ARCH_UNIPHIER || COMPILE_TEST) && OF847847+ depends on HAS_IOMEM850848 help851849 This enables a driver for the Socionext UniPhier SoC SCSSI SPI controller.852850···913909 depends on (SPI_MASTER && HAS_DMA) || COMPILE_TEST914910 help915911 Enables Xilinx GQSPI controller driver for Zynq UltraScale+ MPSoC.912912+913913+config SPI_AMD914914+ tristate "AMD SPI controller"915915+ depends on SPI_MASTER || COMPILE_TEST916916+ help917917+ Enables SPI controller driver for AMD SoC.916918917919#918920# Add new SPI master controllers in alphabetical order above this line
···1717#include <linux/of.h>1818#include <linux/of_address.h>1919#include <linux/of_device.h>2020-#include <linux/of_gpio.h>2120#include <linux/clk.h>2221#include <linux/sizes.h>2323-#include <linux/gpio.h>2422#include <asm/unaligned.h>25232624#define DRIVER_NAME "orion_spi"···9698 struct clk *clk;9799 struct clk *axi_clk;98100 const struct orion_spi_dev *devdata;9999- int unused_hw_gpio;100101101102 struct orion_child_options child[ORION_NUM_CHIPSELECTS];102103};···322325static void orion_spi_set_cs(struct spi_device *spi, bool enable)323326{324327 struct orion_spi *orion_spi;325325- int cs;326328327329 orion_spi = spi_master_get_devdata(spi->master);328330329329- if (gpio_is_valid(spi->cs_gpio))330330- cs = orion_spi->unused_hw_gpio;331331- else332332- cs = spi->chip_select;333333-331331+ /*332332+ * If this line is using a GPIO to control chip select, this internal333333+ * .set_cs() function will still be called, so we clear any previous334334+ * chip select. The CS we activate will not have any elecrical effect,335335+ * as it is handled by a GPIO, but that doesn't matter. What we need336336+ * is to deassert the old chip select and assert some other chip select.337337+ */334338 orion_spi_clrbits(orion_spi, ORION_SPI_IF_CTRL_REG, ORION_SPI_CS_MASK);335339 orion_spi_setbits(orion_spi, ORION_SPI_IF_CTRL_REG,336336- ORION_SPI_CS(cs));340340+ ORION_SPI_CS(spi->chip_select));337341338338- /* Chip select logic is inverted from spi_set_cs */342342+ /*343343+ * Chip select logic is inverted from spi_set_cs(). For lines using a344344+ * GPIO to do chip select SPI_CS_HIGH is enforced and inversion happens345345+ * in the GPIO library, but we don't care about that, because in those346346+ * cases we are dealing with an unused native CS anyways so the polarity347347+ * doesn't matter.348348+ */339349 if (!enable)340350 orion_spi_setbits(orion_spi, ORION_SPI_IF_CTRL_REG, 0x1);341351 else···507503508504static int orion_spi_setup(struct spi_device *spi)509505{510510- if (gpio_is_valid(spi->cs_gpio)) {511511- gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));512512- }513506 return orion_spi_setup_transfer(spi, NULL);514507}515508···623622 master->setup = orion_spi_setup;624623 master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);625624 master->auto_runtime_pm = true;625625+ master->use_gpio_descriptors = true;626626 master->flags = SPI_MASTER_GPIO_SS;627627628628 platform_set_drvdata(pdev, master);629629630630 spi = spi_master_get_devdata(master);631631 spi->master = master;632632- spi->unused_hw_gpio = -1;633632634633 of_id = of_match_device(orion_spi_of_match_table, &pdev->dev);635634 devdata = (of_id) ? of_id->data : &orion_spi_dev_data;···684683 for_each_available_child_of_node(pdev->dev.of_node, np) {685684 struct orion_direct_acc *dir_acc;686685 u32 cs;687687- int cs_gpio;688686689687 /* Get chip-select number from the "reg" property */690688 status = of_property_read_u32(np, "reg", &cs);···692692 "%pOF has no valid 'reg' property (%d)\n",693693 np, status);694694 continue;695695- }696696-697697- /*698698- * Initialize the CS GPIO:699699- * - properly request the actual GPIO signal700700- * - de-assert the logical signal so that all GPIO CS lines701701- * are inactive when probing for slaves702702- * - find an unused physical CS which will be driven for any703703- * slave which uses a CS GPIO704704- */705705- cs_gpio = of_get_named_gpio(pdev->dev.of_node, "cs-gpios", cs);706706- if (cs_gpio > 0) {707707- char *gpio_name;708708- int cs_flags;709709-710710- if (spi->unused_hw_gpio == -1) {711711- dev_info(&pdev->dev,712712- "Selected unused HW CS#%d for any GPIO CSes\n",713713- cs);714714- spi->unused_hw_gpio = cs;715715- }716716-717717- gpio_name = devm_kasprintf(&pdev->dev, GFP_KERNEL,718718- "%s-CS%d", dev_name(&pdev->dev), cs);719719- if (!gpio_name) {720720- status = -ENOMEM;721721- goto out_rel_axi_clk;722722- }723723-724724- cs_flags = of_property_read_bool(np, "spi-cs-high") ?725725- GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH;726726- status = devm_gpio_request_one(&pdev->dev, cs_gpio,727727- cs_flags, gpio_name);728728- if (status) {729729- dev_err(&pdev->dev,730730- "Can't request GPIO for CS %d\n", cs);731731- goto out_rel_axi_clk;732732- }733695 }734696735697 /*
···811811 mask |= STM32F4_SPI_SR_TXE;812812 }813813814814- if (!spi->cur_usedma && spi->cur_comm == SPI_FULL_DUPLEX) {814814+ if (!spi->cur_usedma && (spi->cur_comm == SPI_FULL_DUPLEX ||815815+ spi->cur_comm == SPI_SIMPLEX_RX ||816816+ spi->cur_comm == SPI_3WIRE_RX)) {815817 /* TXE flag is set and is handled when RXNE flag occurs */816818 sr &= ~STM32F4_SPI_SR_TXE;817819 mask |= STM32F4_SPI_SR_RXNE | STM32F4_SPI_SR_OVR;···852850 stm32f4_spi_read_rx(spi);853851 if (spi->rx_len == 0)854852 end = true;855855- else /* Load data for discontinuous mode */853853+ else if (spi->tx_buf)/* Load data for discontinuous mode */856854 stm32f4_spi_write_tx(spi);857855 }858856···11531151 /* Enable the interrupts relative to the current communication mode */11541152 if (spi->cur_comm == SPI_SIMPLEX_TX || spi->cur_comm == SPI_3WIRE_TX) {11551153 cr2 |= STM32F4_SPI_CR2_TXEIE;11561156- } else if (spi->cur_comm == SPI_FULL_DUPLEX) {11541154+ } else if (spi->cur_comm == SPI_FULL_DUPLEX ||11551155+ spi->cur_comm == SPI_SIMPLEX_RX ||11561156+ spi->cur_comm == SPI_3WIRE_RX) {11571157 /* In transmit-only mode, the OVR flag is set in the SR register11581158 * since the received data are never read. Therefore set OVR11591159 * interrupt only when rx buffer is available.···14661462 stm32_spi_set_bits(spi, STM32F4_SPI_CR1,14671463 STM32F4_SPI_CR1_BIDIMODE |14681464 STM32F4_SPI_CR1_BIDIOE);14691469- } else if (comm_type == SPI_FULL_DUPLEX) {14651465+ } else if (comm_type == SPI_FULL_DUPLEX ||14661466+ comm_type == SPI_SIMPLEX_RX) {14701467 stm32_spi_clr_bits(spi, STM32F4_SPI_CR1,14711468 STM32F4_SPI_CR1_BIDIMODE |14691469+ STM32F4_SPI_CR1_BIDIOE);14701470+ } else if (comm_type == SPI_3WIRE_RX) {14711471+ stm32_spi_set_bits(spi, STM32F4_SPI_CR1,14721472+ STM32F4_SPI_CR1_BIDIMODE);14731473+ stm32_spi_clr_bits(spi, STM32F4_SPI_CR1,14721474 STM32F4_SPI_CR1_BIDIOE);14731475 } else {14741476 return -EINVAL;···19161906 master->prepare_message = stm32_spi_prepare_msg;19171907 master->transfer_one = stm32_spi_transfer_one;19181908 master->unprepare_message = stm32_spi_unprepare_msg;19091909+ master->flags = SPI_MASTER_MUST_TX;1919191019201911 spi->dma_tx = dma_request_chan(spi->dev, "tx");19211912 if (IS_ERR(spi->dma_tx)) {
···13981398 ret = pm_runtime_get_sync(&pdev->dev);13991399 if (ret < 0) {14001400 dev_err(&pdev->dev, "pm runtime get failed, e = %d\n", ret);14011401+ pm_runtime_put_noidle(&pdev->dev);14011402 goto exit_pm_disable;14021403 }14031404
+1
drivers/spi/spi-tegra20-sflash.c
···491491 ret = pm_runtime_get_sync(&pdev->dev);492492 if (ret < 0) {493493 dev_err(&pdev->dev, "pm runtime get failed, e = %d\n", ret);494494+ pm_runtime_put_noidle(&pdev->dev);494495 goto exit_pm_disable;495496 }496497
+1
drivers/spi/spi-tegra20-slink.c
···11181118 ret = pm_runtime_get_sync(&pdev->dev);11191119 if (ret < 0) {11201120 dev_err(&pdev->dev, "pm runtime get failed, e = %d\n", ret);11211121+ pm_runtime_put_noidle(&pdev->dev);11211122 goto exit_pm_disable;11221123 }11231124 tspi->def_command_reg = SLINK_M_S;
+7-4
drivers/spi/spi-uniphier.c
···659659 priv->master = master;660660 priv->is_save_param = false;661661662662- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);663663- priv->base = devm_ioremap_resource(&pdev->dev, res);662662+ priv->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);664663 if (IS_ERR(priv->base)) {665664 ret = PTR_ERR(priv->base);666665 goto out_master_put;···715716716717 master->dma_tx = dma_request_chan(&pdev->dev, "tx");717718 if (IS_ERR_OR_NULL(master->dma_tx)) {718718- if (PTR_ERR(master->dma_tx) == -EPROBE_DEFER)719719+ if (PTR_ERR(master->dma_tx) == -EPROBE_DEFER) {720720+ ret = -EPROBE_DEFER;719721 goto out_disable_clk;722722+ }720723 master->dma_tx = NULL;721724 dma_tx_burst = INT_MAX;722725 } else {···733732734733 master->dma_rx = dma_request_chan(&pdev->dev, "rx");735734 if (IS_ERR_OR_NULL(master->dma_rx)) {736736- if (PTR_ERR(master->dma_rx) == -EPROBE_DEFER)735735+ if (PTR_ERR(master->dma_rx) == -EPROBE_DEFER) {736736+ ret = -EPROBE_DEFER;737737 goto out_disable_clk;738738+ }738739 master->dma_rx = NULL;739740 dma_rx_burst = INT_MAX;740741 } else {
+6-4
drivers/spi/spi.c
···10231023 void *tmp;10241024 unsigned int max_tx, max_rx;1025102510261026- if (ctlr->flags & (SPI_CONTROLLER_MUST_RX | SPI_CONTROLLER_MUST_TX)) {10261026+ if ((ctlr->flags & (SPI_CONTROLLER_MUST_RX | SPI_CONTROLLER_MUST_TX))10271027+ && !(msg->spi->mode & SPI_3WIRE)) {10271028 max_tx = 0;10281029 max_rx = 0;10291030···10761075{10771076 struct spi_statistics *statm = &ctlr->statistics;10781077 struct spi_statistics *stats = &msg->spi->statistics;10791079- unsigned long long ms = 1;10781078+ unsigned long long ms;1080107910811080 if (spi_controller_is_slave(ctlr)) {10821081 if (wait_for_completion_interruptible(&ctlr->xfer_completion)) {···11601159int spi_delay_exec(struct spi_delay *_delay, struct spi_transfer *xfer)11611160{11621161 int delay;11621162+11631163+ might_sleep();1163116411641165 if (!_delay)11651166 return -EINVAL;···38583855 * is zero for success, else a negative errno status code.38593856 * This call may only be used from a context that may sleep.38603857 *38613861- * Parameters to this routine are always copied using a small buffer;38623862- * portable code should never use this for more than 32 bytes.38583858+ * Parameters to this routine are always copied using a small buffer.38633859 * Performance-sensitive or bulk transfer code should instead use38643860 * spi_{async,sync}() calls with dma-safe buffers.38653861 *