Lines Matching refs:spi
135 static int orion_spi_baudrate_set(struct spi_device *spi, unsigned int speed) in orion_spi_baudrate_set() argument
144 orion_spi = spi_controller_get_devdata(spi->controller); in orion_spi_baudrate_set()
233 orion_spi_mode_set(struct spi_device *spi) in orion_spi_mode_set() argument
238 orion_spi = spi_controller_get_devdata(spi->controller); in orion_spi_mode_set()
242 if (spi->mode & SPI_CPOL) in orion_spi_mode_set()
244 if (spi->mode & SPI_CPHA) in orion_spi_mode_set()
246 if (spi->mode & SPI_LSB_FIRST) in orion_spi_mode_set()
255 orion_spi_50mhz_ac_timing_erratum(struct spi_device *spi, unsigned int speed) in orion_spi_50mhz_ac_timing_erratum() argument
260 orion_spi = spi_controller_get_devdata(spi->controller); in orion_spi_50mhz_ac_timing_erratum()
280 speed == 50000000 && spi->mode & SPI_CPOL && in orion_spi_50mhz_ac_timing_erratum()
281 spi->mode & SPI_CPHA) in orion_spi_50mhz_ac_timing_erratum()
293 orion_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) in orion_spi_setup_transfer() argument
296 unsigned int speed = spi->max_speed_hz; in orion_spi_setup_transfer()
297 unsigned int bits_per_word = spi->bits_per_word; in orion_spi_setup_transfer()
300 orion_spi = spi_controller_get_devdata(spi->controller); in orion_spi_setup_transfer()
308 orion_spi_mode_set(spi); in orion_spi_setup_transfer()
311 orion_spi_50mhz_ac_timing_erratum(spi, speed); in orion_spi_setup_transfer()
313 rc = orion_spi_baudrate_set(spi, speed); in orion_spi_setup_transfer()
327 static void orion_spi_set_cs(struct spi_device *spi, bool enable) in orion_spi_set_cs() argument
333 orion_spi = spi_controller_get_devdata(spi->controller); in orion_spi_set_cs()
348 val |= ORION_SPI_CS(spi_get_chipselect(spi, 0)); in orion_spi_set_cs()
382 orion_spi_write_read_8bit(struct spi_device *spi, in orion_spi_write_read_8bit() argument
389 cs_single_byte = spi->mode & SPI_CS_WORD; in orion_spi_write_read_8bit()
391 orion_spi = spi_controller_get_devdata(spi->controller); in orion_spi_write_read_8bit()
394 orion_spi_set_cs(spi, 0); in orion_spi_write_read_8bit()
410 orion_spi_set_cs(spi, 1); in orion_spi_write_read_8bit()
414 dev_err(&spi->dev, "TXS timed out\n"); in orion_spi_write_read_8bit()
422 orion_spi_set_cs(spi, 1); in orion_spi_write_read_8bit()
431 orion_spi_write_read_16bit(struct spi_device *spi, in orion_spi_write_read_16bit() argument
437 if (spi->mode & SPI_CS_WORD) { in orion_spi_write_read_16bit()
438 dev_err(&spi->dev, "SPI_CS_WORD is only supported for 8 bit words\n"); in orion_spi_write_read_16bit()
442 orion_spi = spi_controller_get_devdata(spi->controller); in orion_spi_write_read_16bit()
456 dev_err(&spi->dev, "TXS timed out\n"); in orion_spi_write_read_16bit()
467 orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer) in orion_spi_write_read() argument
472 int cs = spi_get_chipselect(spi, 0); in orion_spi_write_read()
475 word_len = spi->bits_per_word; in orion_spi_write_read()
478 orion_spi = spi_controller_get_devdata(spi->controller); in orion_spi_write_read()
487 if (vaddr && xfer->tx_buf && word_len == 8 && (spi->mode & SPI_CS_WORD) == 0) { in orion_spi_write_read()
510 if (orion_spi_write_read_8bit(spi, &tx, &rx) < 0) in orion_spi_write_read()
520 if (orion_spi_write_read_16bit(spi, &tx, &rx) < 0) in orion_spi_write_read()
532 struct spi_device *spi, in orion_spi_transfer_one() argument
537 status = orion_spi_setup_transfer(spi, t); in orion_spi_transfer_one()
542 orion_spi_write_read(spi, t); in orion_spi_transfer_one()
547 static int orion_spi_setup(struct spi_device *spi) in orion_spi_setup() argument
551 struct orion_spi *orion_spi = spi_controller_get_devdata(spi->controller); in orion_spi_setup()
557 ret = orion_spi_setup_transfer(spi, NULL); in orion_spi_setup()
648 struct orion_spi *spi; in orion_spi_probe() local
654 host = spi_alloc_host(&pdev->dev, sizeof(*spi)); in orion_spi_probe()
683 spi = spi_controller_get_devdata(host); in orion_spi_probe()
684 spi->host = host; in orion_spi_probe()
685 spi->dev = &pdev->dev; in orion_spi_probe()
689 spi->devdata = devdata; in orion_spi_probe()
691 spi->clk = devm_clk_get(&pdev->dev, NULL); in orion_spi_probe()
692 if (IS_ERR(spi->clk)) { in orion_spi_probe()
693 status = PTR_ERR(spi->clk); in orion_spi_probe()
697 status = clk_prepare_enable(spi->clk); in orion_spi_probe()
702 spi->axi_clk = devm_clk_get(&pdev->dev, "axi"); in orion_spi_probe()
703 if (PTR_ERR(spi->axi_clk) == -EPROBE_DEFER) { in orion_spi_probe()
707 if (!IS_ERR(spi->axi_clk)) in orion_spi_probe()
708 clk_prepare_enable(spi->axi_clk); in orion_spi_probe()
710 tclk_hz = clk_get_rate(spi->clk); in orion_spi_probe()
730 spi->base = devm_platform_get_and_ioremap_resource(pdev, 0, &r); in orion_spi_probe()
731 if (IS_ERR(spi->base)) { in orion_spi_probe()
732 status = PTR_ERR(spi->base); in orion_spi_probe()
766 dir_acc = &spi->child[cs].direct_access; in orion_spi_probe()
783 status = orion_spi_reset(spi); in orion_spi_probe()
797 clk_disable_unprepare(spi->axi_clk); in orion_spi_probe()
799 clk_disable_unprepare(spi->clk); in orion_spi_probe()
809 struct orion_spi *spi = spi_controller_get_devdata(host); in orion_spi_remove() local
812 clk_disable_unprepare(spi->axi_clk); in orion_spi_remove()
813 clk_disable_unprepare(spi->clk); in orion_spi_remove()
825 struct orion_spi *spi = spi_controller_get_devdata(host); in orion_spi_runtime_suspend() local
827 clk_disable_unprepare(spi->axi_clk); in orion_spi_runtime_suspend()
828 clk_disable_unprepare(spi->clk); in orion_spi_runtime_suspend()
835 struct orion_spi *spi = spi_controller_get_devdata(host); in orion_spi_runtime_resume() local
837 if (!IS_ERR(spi->axi_clk)) in orion_spi_runtime_resume()
838 clk_prepare_enable(spi->axi_clk); in orion_spi_runtime_resume()
839 return clk_prepare_enable(spi->clk); in orion_spi_runtime_resume()