Lines Matching full:master
107 * @master: SPI master
112 static int ep93xx_spi_calc_divisors(struct spi_master *master, in ep93xx_spi_calc_divisors() argument
115 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_calc_divisors()
123 rate = clamp(rate, master->min_speed_hz, master->max_speed_hz); in ep93xx_spi_calc_divisors()
146 static int ep93xx_spi_chip_setup(struct spi_master *master, in ep93xx_spi_chip_setup() argument
150 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_chip_setup()
157 err = ep93xx_spi_calc_divisors(master, xfer->speed_hz, in ep93xx_spi_chip_setup()
169 dev_dbg(&master->dev, "setup: mode %d, cpsr %d, scr %d, dss %d\n", in ep93xx_spi_chip_setup()
171 dev_dbg(&master->dev, "setup: cr0 %#x\n", cr0); in ep93xx_spi_chip_setup()
179 static void ep93xx_do_write(struct spi_master *master) in ep93xx_do_write() argument
181 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_do_write()
182 struct spi_transfer *xfer = master->cur_msg->state; in ep93xx_do_write()
197 static void ep93xx_do_read(struct spi_master *master) in ep93xx_do_read() argument
199 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_do_read()
200 struct spi_transfer *xfer = master->cur_msg->state; in ep93xx_do_read()
217 * @master: SPI master
226 static int ep93xx_spi_read_write(struct spi_master *master) in ep93xx_spi_read_write() argument
228 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_read_write()
229 struct spi_transfer *xfer = master->cur_msg->state; in ep93xx_spi_read_write()
233 ep93xx_do_read(master); in ep93xx_spi_read_write()
239 ep93xx_do_write(master); in ep93xx_spi_read_write()
264 * @master: SPI master
272 ep93xx_spi_dma_prepare(struct spi_master *master, in ep93xx_spi_dma_prepare() argument
275 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_dma_prepare()
276 struct spi_transfer *xfer = master->cur_msg->state; in ep93xx_spi_dma_prepare()
351 dev_warn(&master->dev, "len = %zu expected 0!\n", len); in ep93xx_spi_dma_prepare()
370 * @master: SPI master
376 static void ep93xx_spi_dma_finish(struct spi_master *master, in ep93xx_spi_dma_finish() argument
379 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_dma_finish()
396 struct spi_master *master = callback_param; in ep93xx_spi_dma_callback() local
398 ep93xx_spi_dma_finish(master, DMA_TO_DEVICE); in ep93xx_spi_dma_callback()
399 ep93xx_spi_dma_finish(master, DMA_FROM_DEVICE); in ep93xx_spi_dma_callback()
401 spi_finalize_current_transfer(master); in ep93xx_spi_dma_callback()
404 static int ep93xx_spi_dma_transfer(struct spi_master *master) in ep93xx_spi_dma_transfer() argument
406 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_dma_transfer()
409 rxd = ep93xx_spi_dma_prepare(master, DMA_FROM_DEVICE); in ep93xx_spi_dma_transfer()
411 dev_err(&master->dev, "DMA RX failed: %ld\n", PTR_ERR(rxd)); in ep93xx_spi_dma_transfer()
415 txd = ep93xx_spi_dma_prepare(master, DMA_TO_DEVICE); in ep93xx_spi_dma_transfer()
417 ep93xx_spi_dma_finish(master, DMA_FROM_DEVICE); in ep93xx_spi_dma_transfer()
418 dev_err(&master->dev, "DMA TX failed: %ld\n", PTR_ERR(txd)); in ep93xx_spi_dma_transfer()
424 rxd->callback_param = master; in ep93xx_spi_dma_transfer()
439 struct spi_master *master = dev_id; in ep93xx_spi_interrupt() local
440 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_interrupt()
450 dev_warn(&master->dev, in ep93xx_spi_interrupt()
452 master->cur_msg->status = -EIO; in ep93xx_spi_interrupt()
458 if (ep93xx_spi_read_write(master)) { in ep93xx_spi_interrupt()
477 spi_finalize_current_transfer(master); in ep93xx_spi_interrupt()
482 static int ep93xx_spi_transfer_one(struct spi_master *master, in ep93xx_spi_transfer_one() argument
486 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_transfer_one()
490 ret = ep93xx_spi_chip_setup(master, spi, xfer); in ep93xx_spi_transfer_one()
492 dev_err(&master->dev, "failed to setup chip for transfer\n"); in ep93xx_spi_transfer_one()
496 master->cur_msg->state = xfer; in ep93xx_spi_transfer_one()
506 return ep93xx_spi_dma_transfer(master); in ep93xx_spi_transfer_one()
509 ep93xx_spi_read_write(master); in ep93xx_spi_transfer_one()
519 static int ep93xx_spi_prepare_message(struct spi_master *master, in ep93xx_spi_prepare_message() argument
522 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_prepare_message()
531 dev_warn(&master->dev, in ep93xx_spi_prepare_message()
547 static int ep93xx_spi_prepare_hardware(struct spi_master *master) in ep93xx_spi_prepare_hardware() argument
549 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_prepare_hardware()
564 static int ep93xx_spi_unprepare_hardware(struct spi_master *master) in ep93xx_spi_unprepare_hardware() argument
566 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_unprepare_hardware()
649 struct spi_master *master; in ep93xx_spi_probe() local
672 master = spi_alloc_master(&pdev->dev, sizeof(*espi)); in ep93xx_spi_probe()
673 if (!master) in ep93xx_spi_probe()
676 master->use_gpio_descriptors = true; in ep93xx_spi_probe()
677 master->prepare_transfer_hardware = ep93xx_spi_prepare_hardware; in ep93xx_spi_probe()
678 master->unprepare_transfer_hardware = ep93xx_spi_unprepare_hardware; in ep93xx_spi_probe()
679 master->prepare_message = ep93xx_spi_prepare_message; in ep93xx_spi_probe()
680 master->transfer_one = ep93xx_spi_transfer_one; in ep93xx_spi_probe()
681 master->bus_num = pdev->id; in ep93xx_spi_probe()
682 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; in ep93xx_spi_probe()
683 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16); in ep93xx_spi_probe()
688 master->num_chipselect = 0; in ep93xx_spi_probe()
690 platform_set_drvdata(pdev, master); in ep93xx_spi_probe()
692 espi = spi_master_get_devdata(master); in ep93xx_spi_probe()
705 master->max_speed_hz = clk_get_rate(espi->clk) / 2; in ep93xx_spi_probe()
706 master->min_speed_hz = clk_get_rate(espi->clk) / (254 * 256); in ep93xx_spi_probe()
717 0, "ep93xx-spi", master); in ep93xx_spi_probe()
729 error = devm_spi_register_master(&pdev->dev, master); in ep93xx_spi_probe()
731 dev_err(&pdev->dev, "failed to register SPI master\n"); in ep93xx_spi_probe()
743 spi_master_put(master); in ep93xx_spi_probe()
750 struct spi_master *master = platform_get_drvdata(pdev); in ep93xx_spi_remove() local
751 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_remove()