MLK-17619: spi: ecspi: request gpio resources before setting the value
gpio controller ignored all values were set before request resources, move the devm_gpio_request to spi_imx_setup to fix the issue. Signed-off-by: Han Xu <han.xu@nxp.com> Suggested-and-reviewed-by: Fugang Duan <fugang.duan@nxp.com>pull/10/head
parent
da32813359
commit
296b9130f3
|
@ -1302,15 +1302,24 @@ static int spi_imx_transfer(struct spi_device *spi,
|
|||
|
||||
static int spi_imx_setup(struct spi_device *spi)
|
||||
{
|
||||
int ret;
|
||||
|
||||
dev_dbg(&spi->dev, "%s: mode %d, %u bpw, %d hz\n", __func__,
|
||||
spi->mode, spi->bits_per_word, spi->max_speed_hz);
|
||||
|
||||
if (spi->mode & SPI_NO_CS)
|
||||
return 0;
|
||||
|
||||
if (gpio_is_valid(spi->cs_gpio))
|
||||
if (gpio_is_valid(spi->cs_gpio)) {
|
||||
ret = devm_gpio_request(&spi->master->dev, spi->cs_gpio,
|
||||
dev_name(&spi->master->dev));
|
||||
if (ret) {
|
||||
dev_err(&spi->master->dev, "Can't get CS GPIO \n");
|
||||
return ret;
|
||||
}
|
||||
gpio_direction_output(spi->cs_gpio,
|
||||
spi->mode & SPI_CS_HIGH ? 0 : 1);
|
||||
}
|
||||
|
||||
spi_imx_chipselect(spi, BITBANG_CS_INACTIVE);
|
||||
|
||||
|
@ -1484,25 +1493,6 @@ static int spi_imx_probe(struct platform_device *pdev)
|
|||
goto out_clk_put;
|
||||
}
|
||||
|
||||
if (!master->cs_gpios) {
|
||||
dev_err(&pdev->dev, "No CS GPIOs available\n");
|
||||
ret = -EINVAL;
|
||||
goto out_clk_put;
|
||||
}
|
||||
|
||||
for (i = 0; i < master->num_chipselect; i++) {
|
||||
if (!gpio_is_valid(master->cs_gpios[i]))
|
||||
continue;
|
||||
|
||||
ret = devm_gpio_request(&pdev->dev, master->cs_gpios[i],
|
||||
DRIVER_NAME);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "Can't get CS GPIO %i\n",
|
||||
master->cs_gpios[i]);
|
||||
goto out_clk_put;
|
||||
}
|
||||
}
|
||||
|
||||
dev_info(&pdev->dev, "probed\n");
|
||||
|
||||
clk_disable_unprepare(spi_imx->clk_ipg);
|
||||
|
|
Loading…
Reference in New Issue