diff options
| -rw-r--r-- | Documentation/devicetree/bindings/spi/spi-rspi.txt | 5 | ||||
| -rw-r--r-- | drivers/spi/spi-rspi.c | 37 |
2 files changed, 28 insertions, 14 deletions
diff --git a/Documentation/devicetree/bindings/spi/spi-rspi.txt b/Documentation/devicetree/bindings/spi/spi-rspi.txt index d57d82a74054..f9929aceeacc 100644 --- a/Documentation/devicetree/bindings/spi/spi-rspi.txt +++ b/Documentation/devicetree/bindings/spi/spi-rspi.txt | |||
| @@ -30,6 +30,9 @@ Required properties: | |||
| 30 | 30 | ||
| 31 | Optional properties: | 31 | Optional properties: |
| 32 | - clocks : Must contain a reference to the functional clock. | 32 | - clocks : Must contain a reference to the functional clock. |
| 33 | - dmas : Must contain a list of two references to DMA specifiers, | ||
| 34 | one for transmission, and one for reception. | ||
| 35 | - dma-names : Must contain a list of two DMA names, "tx" and "rx". | ||
| 33 | 36 | ||
| 34 | Pinctrl properties might be needed, too. See | 37 | Pinctrl properties might be needed, too. See |
| 35 | Documentation/devicetree/bindings/pinctrl/renesas,*. | 38 | Documentation/devicetree/bindings/pinctrl/renesas,*. |
| @@ -58,4 +61,6 @@ Examples: | |||
| 58 | num-cs = <1>; | 61 | num-cs = <1>; |
| 59 | #address-cells = <1>; | 62 | #address-cells = <1>; |
| 60 | #size-cells = <0>; | 63 | #size-cells = <0>; |
| 64 | dmas = <&dmac0 0x17>, <&dmac0 0x18>; | ||
| 65 | dma-names = "tx", "rx"; | ||
| 61 | }; | 66 | }; |
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c index 6a4eb2d7f644..1da609e4491d 100644 --- a/drivers/spi/spi-rspi.c +++ b/drivers/spi/spi-rspi.c | |||
| @@ -909,10 +909,11 @@ static struct dma_chan *rspi_request_dma_chan(struct device *dev, | |||
| 909 | dma_cap_zero(mask); | 909 | dma_cap_zero(mask); |
| 910 | dma_cap_set(DMA_SLAVE, mask); | 910 | dma_cap_set(DMA_SLAVE, mask); |
| 911 | 911 | ||
| 912 | chan = dma_request_channel(mask, shdma_chan_filter, | 912 | chan = dma_request_slave_channel_compat(mask, shdma_chan_filter, |
| 913 | (void *)(unsigned long)id); | 913 | (void *)(unsigned long)id, dev, |
| 914 | dir == DMA_MEM_TO_DEV ? "tx" : "rx"); | ||
| 914 | if (!chan) { | 915 | if (!chan) { |
| 915 | dev_warn(dev, "dma_request_channel failed\n"); | 916 | dev_warn(dev, "dma_request_slave_channel_compat failed\n"); |
| 916 | return NULL; | 917 | return NULL; |
| 917 | } | 918 | } |
| 918 | 919 | ||
| @@ -941,22 +942,30 @@ static int rspi_request_dma(struct device *dev, struct spi_master *master, | |||
| 941 | const struct resource *res) | 942 | const struct resource *res) |
| 942 | { | 943 | { |
| 943 | const struct rspi_plat_data *rspi_pd = dev_get_platdata(dev); | 944 | const struct rspi_plat_data *rspi_pd = dev_get_platdata(dev); |
| 945 | unsigned int dma_tx_id, dma_rx_id; | ||
| 946 | |||
| 947 | if (dev->of_node) { | ||
| 948 | /* In the OF case we will get the slave IDs from the DT */ | ||
| 949 | dma_tx_id = 0; | ||
| 950 | dma_rx_id = 0; | ||
| 951 | } else if (rspi_pd && rspi_pd->dma_tx_id && rspi_pd->dma_rx_id) { | ||
| 952 | dma_tx_id = rspi_pd->dma_tx_id; | ||
| 953 | dma_rx_id = rspi_pd->dma_rx_id; | ||
| 954 | } else { | ||
| 955 | /* The driver assumes no error. */ | ||
| 956 | return 0; | ||
| 957 | } | ||
| 944 | 958 | ||
| 945 | if (!rspi_pd || !rspi_pd->dma_rx_id || !rspi_pd->dma_tx_id) | 959 | master->dma_tx = rspi_request_dma_chan(dev, DMA_MEM_TO_DEV, dma_tx_id, |
| 946 | return 0; /* The driver assumes no error. */ | ||
| 947 | |||
| 948 | master->dma_rx = rspi_request_dma_chan(dev, DMA_DEV_TO_MEM, | ||
| 949 | rspi_pd->dma_rx_id, | ||
| 950 | res->start + RSPI_SPDR); | 960 | res->start + RSPI_SPDR); |
| 951 | if (!master->dma_rx) | 961 | if (!master->dma_tx) |
| 952 | return -ENODEV; | 962 | return -ENODEV; |
| 953 | 963 | ||
| 954 | master->dma_tx = rspi_request_dma_chan(dev, DMA_MEM_TO_DEV, | 964 | master->dma_rx = rspi_request_dma_chan(dev, DMA_DEV_TO_MEM, dma_rx_id, |
| 955 | rspi_pd->dma_tx_id, | ||
| 956 | res->start + RSPI_SPDR); | 965 | res->start + RSPI_SPDR); |
| 957 | if (!master->dma_tx) { | 966 | if (!master->dma_rx) { |
| 958 | dma_release_channel(master->dma_rx); | 967 | dma_release_channel(master->dma_tx); |
| 959 | master->dma_rx = NULL; | 968 | master->dma_tx = NULL; |
| 960 | return -ENODEV; | 969 | return -ENODEV; |
| 961 | } | 970 | } |
| 962 | 971 | ||
