|
9 | 9 | #include <linux/clk.h> |
10 | 10 | #include <linux/delay.h> |
11 | 11 | #include <linux/dmaengine.h> |
12 | | -#include <linux/gpio.h> |
13 | 12 | #include <linux/interrupt.h> |
14 | 13 | #include <linux/iopoll.h> |
15 | 14 | #include <linux/module.h> |
@@ -973,29 +972,6 @@ static irqreturn_t stm32h7_spi_irq_thread(int irq, void *dev_id) |
973 | 972 | return IRQ_HANDLED; |
974 | 973 | } |
975 | 974 |
|
976 | | -/** |
977 | | - * stm32_spi_setup - setup device chip select |
978 | | - */ |
979 | | -static int stm32_spi_setup(struct spi_device *spi_dev) |
980 | | -{ |
981 | | - int ret = 0; |
982 | | - |
983 | | - if (!gpio_is_valid(spi_dev->cs_gpio)) { |
984 | | - dev_err(&spi_dev->dev, "%d is not a valid gpio\n", |
985 | | - spi_dev->cs_gpio); |
986 | | - return -EINVAL; |
987 | | - } |
988 | | - |
989 | | - dev_dbg(&spi_dev->dev, "%s: set gpio%d output %s\n", __func__, |
990 | | - spi_dev->cs_gpio, |
991 | | - (spi_dev->mode & SPI_CS_HIGH) ? "low" : "high"); |
992 | | - |
993 | | - ret = gpio_direction_output(spi_dev->cs_gpio, |
994 | | - !(spi_dev->mode & SPI_CS_HIGH)); |
995 | | - |
996 | | - return ret; |
997 | | -} |
998 | | - |
999 | 975 | /** |
1000 | 976 | * stm32_spi_prepare_msg - set up the controller to transfer a single message |
1001 | 977 | */ |
@@ -1810,7 +1786,7 @@ static int stm32_spi_probe(struct platform_device *pdev) |
1810 | 1786 | struct spi_master *master; |
1811 | 1787 | struct stm32_spi *spi; |
1812 | 1788 | struct resource *res; |
1813 | | - int i, ret; |
| 1789 | + int ret; |
1814 | 1790 |
|
1815 | 1791 | master = spi_alloc_master(&pdev->dev, sizeof(struct stm32_spi)); |
1816 | 1792 | if (!master) { |
@@ -1898,7 +1874,7 @@ static int stm32_spi_probe(struct platform_device *pdev) |
1898 | 1874 | master->bits_per_word_mask = spi->cfg->get_bpw_mask(spi); |
1899 | 1875 | master->max_speed_hz = spi->clk_rate / spi->cfg->baud_rate_div_min; |
1900 | 1876 | master->min_speed_hz = spi->clk_rate / spi->cfg->baud_rate_div_max; |
1901 | | - master->setup = stm32_spi_setup; |
| 1877 | + master->use_gpio_descriptors = true; |
1902 | 1878 | master->prepare_message = stm32_spi_prepare_msg; |
1903 | 1879 | master->transfer_one = stm32_spi_transfer_one; |
1904 | 1880 | master->unprepare_message = stm32_spi_unprepare_msg; |
@@ -1928,29 +1904,12 @@ static int stm32_spi_probe(struct platform_device *pdev) |
1928 | 1904 | goto err_dma_release; |
1929 | 1905 | } |
1930 | 1906 |
|
1931 | | - if (!master->cs_gpios) { |
| 1907 | + if (!master->cs_gpiods) { |
1932 | 1908 | dev_err(&pdev->dev, "no CS gpios available\n"); |
1933 | 1909 | ret = -EINVAL; |
1934 | 1910 | goto err_dma_release; |
1935 | 1911 | } |
1936 | 1912 |
|
1937 | | - for (i = 0; i < master->num_chipselect; i++) { |
1938 | | - if (!gpio_is_valid(master->cs_gpios[i])) { |
1939 | | - dev_err(&pdev->dev, "%i is not a valid gpio\n", |
1940 | | - master->cs_gpios[i]); |
1941 | | - ret = -EINVAL; |
1942 | | - goto err_dma_release; |
1943 | | - } |
1944 | | - |
1945 | | - ret = devm_gpio_request(&pdev->dev, master->cs_gpios[i], |
1946 | | - DRIVER_NAME); |
1947 | | - if (ret) { |
1948 | | - dev_err(&pdev->dev, "can't get CS gpio %i\n", |
1949 | | - master->cs_gpios[i]); |
1950 | | - goto err_dma_release; |
1951 | | - } |
1952 | | - } |
1953 | | - |
1954 | 1913 | dev_info(&pdev->dev, "driver initialized\n"); |
1955 | 1914 |
|
1956 | 1915 | return 0; |
|
0 commit comments