Unverified Commit c3c71262 authored by Mark Brown's avatar Mark Brown
Browse files

Merge branch 'spi-4.18' into spi-linus

parents 1ffaddd0 563a53f3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -319,7 +319,7 @@ static void cdns_spi_fill_tx_fifo(struct cdns_spi *xspi)
		 */
		if (cdns_spi_read(xspi, CDNS_SPI_ISR) &
		    CDNS_SPI_IXR_TXFULL)
			usleep_range(10, 20);
			udelay(10);

		if (xspi->txbuf)
			cdns_spi_write(xspi, CDNS_SPI_TXD, *xspi->txbuf++);
@@ -739,7 +739,7 @@ static int __maybe_unused cnds_runtime_resume(struct device *dev)
	ret = clk_prepare_enable(xspi->ref_clk);
	if (ret) {
		dev_err(dev, "Cannot enable device clock.\n");
		clk_disable(xspi->pclk);
		clk_disable_unprepare(xspi->pclk);
		return ret;
	}
	return 0;
+1 −1
Original line number Diff line number Diff line
@@ -217,7 +217,7 @@ static void davinci_spi_chipselect(struct spi_device *spi, int value)
	pdata = &dspi->pdata;

	/* program delay transfers if tx_delay is non zero */
	if (spicfg->wdelay)
	if (spicfg && spicfg->wdelay)
		spidat1 |= SPIDAT1_WDEL;

	/*
+2 −1
Original line number Diff line number Diff line
@@ -485,6 +485,8 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
	dws->dma_inited = 0;
	dws->dma_addr = (dma_addr_t)(dws->paddr + DW_SPI_DR);

	spi_controller_set_devdata(master, dws);

	ret = request_irq(dws->irq, dw_spi_irq, IRQF_SHARED, dev_name(dev),
			  master);
	if (ret < 0) {
@@ -518,7 +520,6 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
		}
	}

	spi_controller_set_devdata(master, dws);
	ret = devm_spi_register_controller(dev, master);
	if (ret) {
		dev_err(&master->dev, "problem registering spi master\n");
+12 −0
Original line number Diff line number Diff line
@@ -943,11 +943,23 @@ static int dspi_resume(struct device *dev)

static SIMPLE_DEV_PM_OPS(dspi_pm, dspi_suspend, dspi_resume);

static const struct regmap_range dspi_volatile_ranges[] = {
	regmap_reg_range(SPI_MCR, SPI_TCR),
	regmap_reg_range(SPI_SR, SPI_SR),
	regmap_reg_range(SPI_PUSHR, SPI_RXFR3),
};

static const struct regmap_access_table dspi_volatile_table = {
	.yes_ranges     = dspi_volatile_ranges,
	.n_yes_ranges   = ARRAY_SIZE(dspi_volatile_ranges),
};

static const struct regmap_config dspi_regmap_config = {
	.reg_bits = 32,
	.val_bits = 32,
	.reg_stride = 4,
	.max_register = 0x88,
	.volatile_table = &dspi_volatile_table,
};

static void dspi_init(struct fsl_dspi *dspi)
+40 −37
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/of_gpio.h>
#include <linux/clk.h>
#include <linux/sizes.h>
#include <linux/gpio.h>
@@ -681,9 +682,9 @@ static int orion_spi_probe(struct platform_device *pdev)
		goto out_rel_axi_clk;
	}

	/* Scan all SPI devices of this controller for direct mapped devices */
	for_each_available_child_of_node(pdev->dev.of_node, np) {
		u32 cs;
		int cs_gpio;

		/* Get chip-select number from the "reg" property */
		status = of_property_read_u32(np, "reg", &cs);
@@ -694,6 +695,44 @@ static int orion_spi_probe(struct platform_device *pdev)
			continue;
		}

		/*
		 * Initialize the CS GPIO:
		 * - properly request the actual GPIO signal
		 * - de-assert the logical signal so that all GPIO CS lines
		 *   are inactive when probing for slaves
		 * - find an unused physical CS which will be driven for any
		 *   slave which uses a CS GPIO
		 */
		cs_gpio = of_get_named_gpio(pdev->dev.of_node, "cs-gpios", cs);
		if (cs_gpio > 0) {
			char *gpio_name;
			int cs_flags;

			if (spi->unused_hw_gpio == -1) {
				dev_info(&pdev->dev,
					"Selected unused HW CS#%d for any GPIO CSes\n",
					cs);
				spi->unused_hw_gpio = cs;
			}

			gpio_name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
					"%s-CS%d", dev_name(&pdev->dev), cs);
			if (!gpio_name) {
				status = -ENOMEM;
				goto out_rel_axi_clk;
			}

			cs_flags = of_property_read_bool(np, "spi-cs-high") ?
				GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH;
			status = devm_gpio_request_one(&pdev->dev, cs_gpio,
					cs_flags, gpio_name);
			if (status) {
				dev_err(&pdev->dev,
					"Can't request GPIO for CS %d\n", cs);
				goto out_rel_axi_clk;
			}
		}

		/*
		 * Check if an address is configured for this SPI device. If
		 * not, the MBus mapping via the 'ranges' property in the 'soc'
@@ -740,44 +779,8 @@ static int orion_spi_probe(struct platform_device *pdev)
	if (status < 0)
		goto out_rel_pm;

	if (master->cs_gpios) {
		int i;
		for (i = 0; i < master->num_chipselect; ++i) {
			char *gpio_name;

			if (!gpio_is_valid(master->cs_gpios[i])) {
				continue;
			}

			gpio_name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
					"%s-CS%d", dev_name(&pdev->dev), i);
			if (!gpio_name) {
				status = -ENOMEM;
				goto out_rel_master;
			}

			status = devm_gpio_request(&pdev->dev,
					master->cs_gpios[i], gpio_name);
			if (status) {
				dev_err(&pdev->dev,
					"Can't request GPIO for CS %d\n",
					master->cs_gpios[i]);
				goto out_rel_master;
			}
			if (spi->unused_hw_gpio == -1) {
				dev_info(&pdev->dev,
					"Selected unused HW CS#%d for any GPIO CSes\n",
					i);
				spi->unused_hw_gpio = i;
			}
		}
	}


	return status;

out_rel_master:
	spi_unregister_master(master);
out_rel_pm:
	pm_runtime_disable(&pdev->dev);
out_rel_axi_clk:
Loading