Commit 17c49e53 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'spi/topic/pxa', 'spi/topic/pxa2xx',...

Merge remote-tracking branches 'spi/topic/pxa', 'spi/topic/pxa2xx', 'spi/topic/qup', 'spi/topic/rockchip' and 'spi/topic/sh' into spi-next
...@@ -6,6 +6,7 @@ and display controllers using the SPI communication interface. ...@@ -6,6 +6,7 @@ and display controllers using the SPI communication interface.
Required Properties: Required Properties:
- compatible: should be one of the following. - compatible: should be one of the following.
"rockchip,rv1108-spi" for rv1108 SoCs.
"rockchip,rk3036-spi" for rk3036 SoCS. "rockchip,rk3036-spi" for rk3036 SoCS.
"rockchip,rk3066-spi" for rk3066 SoCs. "rockchip,rk3066-spi" for rk3066 SoCs.
"rockchip,rk3188-spi" for rk3188 SoCs. "rockchip,rk3188-spi" for rk3188 SoCs.
......
...@@ -517,8 +517,8 @@ config SPI_PPC4xx ...@@ -517,8 +517,8 @@ config SPI_PPC4xx
config SPI_PXA2XX config SPI_PXA2XX
tristate "PXA2xx SSP SPI master" tristate "PXA2xx SSP SPI master"
depends on (ARCH_PXA || PCI || ACPI) depends on (ARCH_PXA || ARCH_MMP || PCI || ACPI)
select PXA_SSP if ARCH_PXA select PXA_SSP if ARCH_PXA || ARCH_MMP
help help
This enables using a PXA2xx or Sodaville SSP port as a SPI master This enables using a PXA2xx or Sodaville SSP port as a SPI master
controller. The driver can be configured to use any SSP port and controller. The driver can be configured to use any SSP port and
......
...@@ -402,8 +402,8 @@ static void cs_assert(struct driver_data *drv_data) ...@@ -402,8 +402,8 @@ static void cs_assert(struct driver_data *drv_data)
return; return;
} }
if (gpio_is_valid(chip->gpio_cs)) { if (chip->gpiod_cs) {
gpio_set_value(chip->gpio_cs, chip->gpio_cs_inverted); gpiod_set_value(chip->gpiod_cs, chip->gpio_cs_inverted);
return; return;
} }
...@@ -424,8 +424,8 @@ static void cs_deassert(struct driver_data *drv_data) ...@@ -424,8 +424,8 @@ static void cs_deassert(struct driver_data *drv_data)
return; return;
} }
if (gpio_is_valid(chip->gpio_cs)) { if (chip->gpiod_cs) {
gpio_set_value(chip->gpio_cs, !chip->gpio_cs_inverted); gpiod_set_value(chip->gpiod_cs, !chip->gpio_cs_inverted);
return; return;
} }
...@@ -1213,17 +1213,16 @@ static int setup_cs(struct spi_device *spi, struct chip_data *chip, ...@@ -1213,17 +1213,16 @@ static int setup_cs(struct spi_device *spi, struct chip_data *chip,
struct pxa2xx_spi_chip *chip_info) struct pxa2xx_spi_chip *chip_info)
{ {
struct driver_data *drv_data = spi_master_get_devdata(spi->master); struct driver_data *drv_data = spi_master_get_devdata(spi->master);
struct gpio_desc *gpiod;
int err = 0; int err = 0;
if (chip == NULL) if (chip == NULL)
return 0; return 0;
if (drv_data->cs_gpiods) { if (drv_data->cs_gpiods) {
struct gpio_desc *gpiod;
gpiod = drv_data->cs_gpiods[spi->chip_select]; gpiod = drv_data->cs_gpiods[spi->chip_select];
if (gpiod) { if (gpiod) {
chip->gpio_cs = desc_to_gpio(gpiod); chip->gpiod_cs = gpiod;
chip->gpio_cs_inverted = spi->mode & SPI_CS_HIGH; chip->gpio_cs_inverted = spi->mode & SPI_CS_HIGH;
gpiod_set_value(gpiod, chip->gpio_cs_inverted); gpiod_set_value(gpiod, chip->gpio_cs_inverted);
} }
...@@ -1237,8 +1236,10 @@ static int setup_cs(struct spi_device *spi, struct chip_data *chip, ...@@ -1237,8 +1236,10 @@ static int setup_cs(struct spi_device *spi, struct chip_data *chip,
/* NOTE: setup() can be called multiple times, possibly with /* NOTE: setup() can be called multiple times, possibly with
* different chip_info, release previously requested GPIO * different chip_info, release previously requested GPIO
*/ */
if (gpio_is_valid(chip->gpio_cs)) if (chip->gpiod_cs) {
gpio_free(chip->gpio_cs); gpio_free(desc_to_gpio(chip->gpiod_cs));
chip->gpiod_cs = NULL;
}
/* If (*cs_control) is provided, ignore GPIO chip select */ /* If (*cs_control) is provided, ignore GPIO chip select */
if (chip_info->cs_control) { if (chip_info->cs_control) {
...@@ -1254,11 +1255,11 @@ static int setup_cs(struct spi_device *spi, struct chip_data *chip, ...@@ -1254,11 +1255,11 @@ static int setup_cs(struct spi_device *spi, struct chip_data *chip,
return err; return err;
} }
chip->gpio_cs = chip_info->gpio_cs; gpiod = gpio_to_desc(chip_info->gpio_cs);
chip->gpiod_cs = gpiod;
chip->gpio_cs_inverted = spi->mode & SPI_CS_HIGH; chip->gpio_cs_inverted = spi->mode & SPI_CS_HIGH;
err = gpio_direction_output(chip->gpio_cs, err = gpiod_direction_output(gpiod, !chip->gpio_cs_inverted);
!chip->gpio_cs_inverted);
} }
return err; return err;
...@@ -1317,8 +1318,7 @@ static int setup(struct spi_device *spi) ...@@ -1317,8 +1318,7 @@ static int setup(struct spi_device *spi)
} }
chip->frm = spi->chip_select; chip->frm = spi->chip_select;
} else }
chip->gpio_cs = -1;
chip->enable_dma = drv_data->master_info->enable_dma; chip->enable_dma = drv_data->master_info->enable_dma;
chip->timeout = TIMOUT_DFLT; chip->timeout = TIMOUT_DFLT;
} }
...@@ -1416,8 +1416,8 @@ static void cleanup(struct spi_device *spi) ...@@ -1416,8 +1416,8 @@ static void cleanup(struct spi_device *spi)
return; return;
if (drv_data->ssp_type != CE4100_SSP && !drv_data->cs_gpiods && if (drv_data->ssp_type != CE4100_SSP && !drv_data->cs_gpiods &&
gpio_is_valid(chip->gpio_cs)) chip->gpiod_cs)
gpio_free(chip->gpio_cs); gpio_free(desc_to_gpio(chip->gpiod_cs));
kfree(chip); kfree(chip);
} }
...@@ -1769,8 +1769,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) ...@@ -1769,8 +1769,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
for (i = 0; i < master->num_chipselect; i++) { for (i = 0; i < master->num_chipselect; i++) {
struct gpio_desc *gpiod; struct gpio_desc *gpiod;
gpiod = devm_gpiod_get_index(dev, "cs", i, gpiod = devm_gpiod_get_index(dev, "cs", i, GPIOD_ASIS);
GPIOD_OUT_HIGH);
if (IS_ERR(gpiod)) { if (IS_ERR(gpiod)) {
/* Means use native chip select */ /* Means use native chip select */
if (PTR_ERR(gpiod) == -ENOENT) if (PTR_ERR(gpiod) == -ENOENT)
......
...@@ -83,7 +83,7 @@ struct chip_data { ...@@ -83,7 +83,7 @@ struct chip_data {
u16 lpss_tx_threshold; u16 lpss_tx_threshold;
u8 enable_dma; u8 enable_dma;
union { union {
int gpio_cs; struct gpio_desc *gpiod_cs;
unsigned int frm; unsigned int frm;
}; };
int gpio_cs_inverted; int gpio_cs_inverted;
......
This diff is collapsed.
...@@ -568,7 +568,13 @@ static void rockchip_spi_config(struct rockchip_spi *rs) ...@@ -568,7 +568,13 @@ static void rockchip_spi_config(struct rockchip_spi *rs)
writel_relaxed(cr0, rs->regs + ROCKCHIP_SPI_CTRLR0); writel_relaxed(cr0, rs->regs + ROCKCHIP_SPI_CTRLR0);
if (rs->n_bytes == 1)
writel_relaxed(rs->len - 1, rs->regs + ROCKCHIP_SPI_CTRLR1); writel_relaxed(rs->len - 1, rs->regs + ROCKCHIP_SPI_CTRLR1);
else if (rs->n_bytes == 2)
writel_relaxed((rs->len / 2) - 1, rs->regs + ROCKCHIP_SPI_CTRLR1);
else
writel_relaxed((rs->len * 2) - 1, rs->regs + ROCKCHIP_SPI_CTRLR1);
writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_TXFTLR); writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_TXFTLR);
writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_RXFTLR); writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_RXFTLR);
...@@ -666,7 +672,7 @@ static bool rockchip_spi_can_dma(struct spi_master *master, ...@@ -666,7 +672,7 @@ static bool rockchip_spi_can_dma(struct spi_master *master,
static int rockchip_spi_probe(struct platform_device *pdev) static int rockchip_spi_probe(struct platform_device *pdev)
{ {
int ret = 0; int ret;
struct rockchip_spi *rs; struct rockchip_spi *rs;
struct spi_master *master; struct spi_master *master;
struct resource *mem; struct resource *mem;
...@@ -703,13 +709,13 @@ static int rockchip_spi_probe(struct platform_device *pdev) ...@@ -703,13 +709,13 @@ static int rockchip_spi_probe(struct platform_device *pdev)
} }
ret = clk_prepare_enable(rs->apb_pclk); ret = clk_prepare_enable(rs->apb_pclk);
if (ret) { if (ret < 0) {
dev_err(&pdev->dev, "Failed to enable apb_pclk\n"); dev_err(&pdev->dev, "Failed to enable apb_pclk\n");
goto err_put_master; goto err_put_master;
} }
ret = clk_prepare_enable(rs->spiclk); ret = clk_prepare_enable(rs->spiclk);
if (ret) { if (ret < 0) {
dev_err(&pdev->dev, "Failed to enable spi_clk\n"); dev_err(&pdev->dev, "Failed to enable spi_clk\n");
goto err_disable_apbclk; goto err_disable_apbclk;
} }
...@@ -786,7 +792,7 @@ static int rockchip_spi_probe(struct platform_device *pdev) ...@@ -786,7 +792,7 @@ static int rockchip_spi_probe(struct platform_device *pdev)
} }
ret = devm_spi_register_master(&pdev->dev, master); ret = devm_spi_register_master(&pdev->dev, master);
if (ret) { if (ret < 0) {
dev_err(&pdev->dev, "Failed to register master\n"); dev_err(&pdev->dev, "Failed to register master\n");
goto err_free_dma_rx; goto err_free_dma_rx;
} }
...@@ -816,11 +822,15 @@ static int rockchip_spi_remove(struct platform_device *pdev) ...@@ -816,11 +822,15 @@ static int rockchip_spi_remove(struct platform_device *pdev)
struct spi_master *master = spi_master_get(platform_get_drvdata(pdev)); struct spi_master *master = spi_master_get(platform_get_drvdata(pdev));
struct rockchip_spi *rs = spi_master_get_devdata(master); struct rockchip_spi *rs = spi_master_get_devdata(master);
pm_runtime_disable(&pdev->dev); pm_runtime_get_sync(&pdev->dev);
clk_disable_unprepare(rs->spiclk); clk_disable_unprepare(rs->spiclk);
clk_disable_unprepare(rs->apb_pclk); clk_disable_unprepare(rs->apb_pclk);
pm_runtime_put_noidle(&pdev->dev);
pm_runtime_disable(&pdev->dev);
pm_runtime_set_suspended(&pdev->dev);
if (rs->dma_tx.ch) if (rs->dma_tx.ch)
dma_release_channel(rs->dma_tx.ch); dma_release_channel(rs->dma_tx.ch);
if (rs->dma_rx.ch) if (rs->dma_rx.ch)
...@@ -834,51 +844,42 @@ static int rockchip_spi_remove(struct platform_device *pdev) ...@@ -834,51 +844,42 @@ static int rockchip_spi_remove(struct platform_device *pdev)
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int rockchip_spi_suspend(struct device *dev) static int rockchip_spi_suspend(struct device *dev)
{ {
int ret = 0; int ret;
struct spi_master *master = dev_get_drvdata(dev); struct spi_master *master = dev_get_drvdata(dev);
struct rockchip_spi *rs = spi_master_get_devdata(master); struct rockchip_spi *rs = spi_master_get_devdata(master);
ret = spi_master_suspend(rs->master); ret = spi_master_suspend(rs->master);
if (ret) if (ret < 0)
return ret; return ret;
if (!pm_runtime_suspended(dev)) { ret = pm_runtime_force_suspend(dev);
clk_disable_unprepare(rs->spiclk); if (ret < 0)
clk_disable_unprepare(rs->apb_pclk); return ret;
}
pinctrl_pm_select_sleep_state(dev); pinctrl_pm_select_sleep_state(dev);
return ret; return 0;
} }
static int rockchip_spi_resume(struct device *dev) static int rockchip_spi_resume(struct device *dev)
{ {
int ret = 0; int ret;
struct spi_master *master = dev_get_drvdata(dev); struct spi_master *master = dev_get_drvdata(dev);
struct rockchip_spi *rs = spi_master_get_devdata(master); struct rockchip_spi *rs = spi_master_get_devdata(master);
pinctrl_pm_select_default_state(dev); pinctrl_pm_select_default_state(dev);
if (!pm_runtime_suspended(dev)) { ret = pm_runtime_force_resume(dev);
ret = clk_prepare_enable(rs->apb_pclk);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = clk_prepare_enable(rs->spiclk);
if (ret < 0) {
clk_disable_unprepare(rs->apb_pclk);
return ret;
}
}
ret = spi_master_resume(rs->master); ret = spi_master_resume(rs->master);
if (ret < 0) { if (ret < 0) {
clk_disable_unprepare(rs->spiclk); clk_disable_unprepare(rs->spiclk);
clk_disable_unprepare(rs->apb_pclk); clk_disable_unprepare(rs->apb_pclk);
} }
return ret; return 0;
} }
#endif /* CONFIG_PM_SLEEP */ #endif /* CONFIG_PM_SLEEP */
...@@ -901,14 +902,14 @@ static int rockchip_spi_runtime_resume(struct device *dev) ...@@ -901,14 +902,14 @@ static int rockchip_spi_runtime_resume(struct device *dev)
struct rockchip_spi *rs = spi_master_get_devdata(master); struct rockchip_spi *rs = spi_master_get_devdata(master);
ret = clk_prepare_enable(rs->apb_pclk); ret = clk_prepare_enable(rs->apb_pclk);
if (ret) if (ret < 0)
return ret; return ret;
ret = clk_prepare_enable(rs->spiclk); ret = clk_prepare_enable(rs->spiclk);
if (ret) if (ret < 0)
clk_disable_unprepare(rs->apb_pclk); clk_disable_unprepare(rs->apb_pclk);
return ret; return 0;
} }
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
...@@ -919,6 +920,7 @@ static const struct dev_pm_ops rockchip_spi_pm = { ...@@ -919,6 +920,7 @@ static const struct dev_pm_ops rockchip_spi_pm = {
}; };
static const struct of_device_id rockchip_spi_dt_match[] = { static const struct of_device_id rockchip_spi_dt_match[] = {
{ .compatible = "rockchip,rv1108-spi", },
{ .compatible = "rockchip,rk3036-spi", }, { .compatible = "rockchip,rk3036-spi", },
{ .compatible = "rockchip,rk3066-spi", }, { .compatible = "rockchip,rk3066-spi", },
{ .compatible = "rockchip,rk3188-spi", }, { .compatible = "rockchip,rk3188-spi", },
......
...@@ -446,8 +446,8 @@ static int spi_sh_probe(struct platform_device *pdev) ...@@ -446,8 +446,8 @@ static int spi_sh_probe(struct platform_device *pdev)
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
dev_err(&pdev->dev, "platform_get_irq error\n"); dev_err(&pdev->dev, "platform_get_irq error: %d\n", irq);
return -ENODEV; return irq;
} }
master = spi_alloc_master(&pdev->dev, sizeof(struct spi_sh_data)); master = spi_alloc_master(&pdev->dev, sizeof(struct spi_sh_data));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment