Lines Matching full:spi
3 * Marvell Orion SPI controller driver
14 #include <linux/spi/spi.h>
74 * have both is for managing the armada-370-spi case with old
130 static int orion_spi_baudrate_set(struct spi_device *spi, unsigned int speed) in orion_spi_baudrate_set() argument
139 orion_spi = spi_master_get_devdata(spi->master); in orion_spi_baudrate_set()
216 /* Convert the rate to SPI clock divisor value. */ in orion_spi_baudrate_set()
228 orion_spi_mode_set(struct spi_device *spi) in orion_spi_mode_set() argument
233 orion_spi = spi_master_get_devdata(spi->master); in orion_spi_mode_set()
237 if (spi->mode & SPI_CPOL) in orion_spi_mode_set()
239 if (spi->mode & SPI_CPHA) in orion_spi_mode_set()
241 if (spi->mode & SPI_LSB_FIRST) in orion_spi_mode_set()
250 orion_spi_50mhz_ac_timing_erratum(struct spi_device *spi, unsigned int speed) in orion_spi_50mhz_ac_timing_erratum() argument
255 orion_spi = spi_master_get_devdata(spi->master); in orion_spi_50mhz_ac_timing_erratum()
259 * SPI interface supports frequencies of up to 50 MHz. in orion_spi_50mhz_ac_timing_erratum()
261 * 250 MHz and the SPI interfaces is configured for 50MHz SPI in orion_spi_50mhz_ac_timing_erratum()
263 * reads from the SPI device. in orion_spi_50mhz_ac_timing_erratum()
266 * 1. Set CPOL=CPHA=0 in "SPI Interface Configuration in orion_spi_50mhz_ac_timing_erratum()
268 * 2. Set TMISO_SAMPLE value to 0x2 in "SPI Timing Parameters 1 in orion_spi_50mhz_ac_timing_erratum()
275 speed == 50000000 && spi->mode & SPI_CPOL && in orion_spi_50mhz_ac_timing_erratum()
276 spi->mode & SPI_CPHA) in orion_spi_50mhz_ac_timing_erratum()
288 orion_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) in orion_spi_setup_transfer() argument
291 unsigned int speed = spi->max_speed_hz; in orion_spi_setup_transfer()
292 unsigned int bits_per_word = spi->bits_per_word; in orion_spi_setup_transfer()
295 orion_spi = spi_master_get_devdata(spi->master); in orion_spi_setup_transfer()
303 orion_spi_mode_set(spi); in orion_spi_setup_transfer()
306 orion_spi_50mhz_ac_timing_erratum(spi, speed); in orion_spi_setup_transfer()
308 rc = orion_spi_baudrate_set(spi, speed); in orion_spi_setup_transfer()
322 static void orion_spi_set_cs(struct spi_device *spi, bool enable) in orion_spi_set_cs() argument
326 orion_spi = spi_master_get_devdata(spi->master); in orion_spi_set_cs()
337 ORION_SPI_CS(spi->chip_select)); in orion_spi_set_cs()
367 orion_spi_write_read_8bit(struct spi_device *spi, in orion_spi_write_read_8bit() argument
373 orion_spi = spi_master_get_devdata(spi->master); in orion_spi_write_read_8bit()
387 dev_err(&spi->dev, "TXS timed out\n"); in orion_spi_write_read_8bit()
398 orion_spi_write_read_16bit(struct spi_device *spi, in orion_spi_write_read_16bit() argument
404 orion_spi = spi_master_get_devdata(spi->master); in orion_spi_write_read_16bit()
418 dev_err(&spi->dev, "TXS timed out\n"); in orion_spi_write_read_16bit()
429 orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer) in orion_spi_write_read() argument
434 int cs = spi->chip_select; in orion_spi_write_read()
437 word_len = spi->bits_per_word; in orion_spi_write_read()
440 orion_spi = spi_master_get_devdata(spi->master); in orion_spi_write_read()
443 * Use SPI direct write mode if base address is available. Otherwise in orion_spi_write_read()
453 * Send the TX-data to the SPI device via the direct in orion_spi_write_read()
471 if (orion_spi_write_read_8bit(spi, &tx, &rx) < 0) in orion_spi_write_read()
481 if (orion_spi_write_read_16bit(spi, &tx, &rx) < 0) in orion_spi_write_read()
493 struct spi_device *spi, in orion_spi_transfer_one() argument
498 status = orion_spi_setup_transfer(spi, t); in orion_spi_transfer_one()
503 orion_spi_write_read(spi, t); in orion_spi_transfer_one()
508 static int orion_spi_setup(struct spi_device *spi) in orion_spi_setup() argument
510 return orion_spi_setup_transfer(spi, NULL); in orion_spi_setup()
518 /* Don't deassert CS between the direct mapped SPI transfers */ in orion_spi_reset()
563 .compatible = "marvell,orion-spi",
567 .compatible = "marvell,armada-370-spi",
571 .compatible = "marvell,armada-375-spi",
575 .compatible = "marvell,armada-380-spi",
579 .compatible = "marvell,armada-390-spi",
583 .compatible = "marvell,armada-xp-spi",
596 struct orion_spi *spi; in orion_spi_probe() local
602 master = spi_alloc_master(&pdev->dev, sizeof(*spi)); in orion_spi_probe()
618 /* we support all 4 SPI modes and LSB first option */ in orion_spi_probe()
631 spi = spi_master_get_devdata(master); in orion_spi_probe()
632 spi->master = master; in orion_spi_probe()
636 spi->devdata = devdata; in orion_spi_probe()
638 spi->clk = devm_clk_get(&pdev->dev, NULL); in orion_spi_probe()
639 if (IS_ERR(spi->clk)) { in orion_spi_probe()
640 status = PTR_ERR(spi->clk); in orion_spi_probe()
644 status = clk_prepare_enable(spi->clk); in orion_spi_probe()
649 spi->axi_clk = devm_clk_get(&pdev->dev, "axi"); in orion_spi_probe()
650 if (PTR_ERR(spi->axi_clk) == -EPROBE_DEFER) { in orion_spi_probe()
654 if (!IS_ERR(spi->axi_clk)) in orion_spi_probe()
655 clk_prepare_enable(spi->axi_clk); in orion_spi_probe()
657 tclk_hz = clk_get_rate(spi->clk); in orion_spi_probe()
660 * With old device tree, armada-370-spi could be used with in orion_spi_probe()
667 "marvell,armada-370-spi")) in orion_spi_probe()
678 spi->base = devm_ioremap_resource(&pdev->dev, r); in orion_spi_probe()
679 if (IS_ERR(spi->base)) { in orion_spi_probe()
680 status = PTR_ERR(spi->base); in orion_spi_probe()
698 * Check if an address is configured for this SPI device. If in orion_spi_probe()
711 * This needs to get extended for the direct SPI NOR / SPI NAND in orion_spi_probe()
714 dir_acc = &spi->child[cs].direct_access; in orion_spi_probe()
730 status = orion_spi_reset(spi); in orion_spi_probe()
744 clk_disable_unprepare(spi->axi_clk); in orion_spi_probe()
746 clk_disable_unprepare(spi->clk); in orion_spi_probe()
756 struct orion_spi *spi = spi_master_get_devdata(master); in orion_spi_remove() local
759 clk_disable_unprepare(spi->axi_clk); in orion_spi_remove()
760 clk_disable_unprepare(spi->clk); in orion_spi_remove()
774 struct orion_spi *spi = spi_master_get_devdata(master); in orion_spi_runtime_suspend() local
776 clk_disable_unprepare(spi->axi_clk); in orion_spi_runtime_suspend()
777 clk_disable_unprepare(spi->clk); in orion_spi_runtime_suspend()
784 struct orion_spi *spi = spi_master_get_devdata(master); in orion_spi_runtime_resume() local
786 if (!IS_ERR(spi->axi_clk)) in orion_spi_runtime_resume()
787 clk_prepare_enable(spi->axi_clk); in orion_spi_runtime_resume()
788 return clk_prepare_enable(spi->clk); in orion_spi_runtime_resume()
810 MODULE_DESCRIPTION("Orion SPI driver");