未验证 提交 32159969 编写于 作者: L Linus Walleij 提交者: Mark Brown

spi: st-ssc4: Covert to use GPIO descriptors

This switches the ST SSC SPI controller to use GPIO
descriptors from the core instead of GPIO numbers.
It is already using the core parsing of GPIO numbers
so the switch is pretty straight-forward.

Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220201012654.562578-1-linus.walleij@linaro.orgSigned-off-by: NMark Brown <broonie@kernel.org>
上级 6938e02f
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <linux/pinctrl/consumer.h> #include <linux/pinctrl/consumer.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
...@@ -171,11 +170,6 @@ static int spi_st_transfer_one(struct spi_master *master, ...@@ -171,11 +170,6 @@ static int spi_st_transfer_one(struct spi_master *master,
return t->len; return t->len;
} }
static void spi_st_cleanup(struct spi_device *spi)
{
gpio_free(spi->cs_gpio);
}
/* the spi->mode bits understood by this driver: */ /* the spi->mode bits understood by this driver: */
#define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST | SPI_LOOP | SPI_CS_HIGH) #define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST | SPI_LOOP | SPI_CS_HIGH)
static int spi_st_setup(struct spi_device *spi) static int spi_st_setup(struct spi_device *spi)
...@@ -183,29 +177,17 @@ static int spi_st_setup(struct spi_device *spi) ...@@ -183,29 +177,17 @@ static int spi_st_setup(struct spi_device *spi)
struct spi_st *spi_st = spi_master_get_devdata(spi->master); struct spi_st *spi_st = spi_master_get_devdata(spi->master);
u32 spi_st_clk, sscbrg, var; u32 spi_st_clk, sscbrg, var;
u32 hz = spi->max_speed_hz; u32 hz = spi->max_speed_hz;
int cs = spi->cs_gpio;
int ret;
if (!hz) { if (!hz) {
dev_err(&spi->dev, "max_speed_hz unspecified\n"); dev_err(&spi->dev, "max_speed_hz unspecified\n");
return -EINVAL; return -EINVAL;
} }
if (!gpio_is_valid(cs)) { if (!spi->cs_gpiod) {
dev_err(&spi->dev, "%d is not a valid gpio\n", cs); dev_err(&spi->dev, "no valid gpio assigned\n");
return -EINVAL; return -EINVAL;
} }
ret = gpio_request(cs, dev_name(&spi->dev));
if (ret) {
dev_err(&spi->dev, "could not request gpio:%d\n", cs);
return ret;
}
ret = gpio_direction_output(cs, spi->mode & SPI_CS_HIGH);
if (ret)
goto out_free_gpio;
spi_st_clk = clk_get_rate(spi_st->clk); spi_st_clk = clk_get_rate(spi_st->clk);
/* Set SSC_BRF */ /* Set SSC_BRF */
...@@ -213,8 +195,7 @@ static int spi_st_setup(struct spi_device *spi) ...@@ -213,8 +195,7 @@ static int spi_st_setup(struct spi_device *spi)
if (sscbrg < 0x07 || sscbrg > BIT(16)) { if (sscbrg < 0x07 || sscbrg > BIT(16)) {
dev_err(&spi->dev, dev_err(&spi->dev,
"baudrate %d outside valid range %d\n", sscbrg, hz); "baudrate %d outside valid range %d\n", sscbrg, hz);
ret = -EINVAL; return -EINVAL;
goto out_free_gpio;
} }
spi_st->baud = spi_st_clk / (2 * sscbrg); spi_st->baud = spi_st_clk / (2 * sscbrg);
...@@ -263,10 +244,6 @@ static int spi_st_setup(struct spi_device *spi) ...@@ -263,10 +244,6 @@ static int spi_st_setup(struct spi_device *spi)
readl_relaxed(spi_st->base + SSC_RBUF); readl_relaxed(spi_st->base + SSC_RBUF);
return 0; return 0;
out_free_gpio:
gpio_free(cs);
return ret;
} }
/* Interrupt fired when TX shift register becomes empty */ /* Interrupt fired when TX shift register becomes empty */
...@@ -309,11 +286,11 @@ static int spi_st_probe(struct platform_device *pdev) ...@@ -309,11 +286,11 @@ static int spi_st_probe(struct platform_device *pdev)
master->dev.of_node = np; master->dev.of_node = np;
master->mode_bits = MODEBITS; master->mode_bits = MODEBITS;
master->setup = spi_st_setup; master->setup = spi_st_setup;
master->cleanup = spi_st_cleanup;
master->transfer_one = spi_st_transfer_one; master->transfer_one = spi_st_transfer_one;
master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16); master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
master->auto_runtime_pm = true; master->auto_runtime_pm = true;
master->bus_num = pdev->id; master->bus_num = pdev->id;
master->use_gpio_descriptors = true;
spi_st = spi_master_get_devdata(master); spi_st = spi_master_get_devdata(master);
spi_st->clk = devm_clk_get(&pdev->dev, "ssc"); spi_st->clk = devm_clk_get(&pdev->dev, "ssc");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册