Lines Matching refs:master

29 	struct spi_master *master;  member
130 struct uniphier_spi_priv *priv = spi_master_get_devdata(spi->master); in uniphier_spi_set_mode()
183 struct uniphier_spi_priv *priv = spi_master_get_devdata(spi->master); in uniphier_spi_set_transfer_size()
201 struct uniphier_spi_priv *priv = spi_master_get_devdata(spi->master); in uniphier_spi_set_baudrate()
220 struct uniphier_spi_priv *priv = spi_master_get_devdata(spi->master); in uniphier_spi_setup_transfer()
336 struct uniphier_spi_priv *priv = spi_master_get_devdata(spi->master); in uniphier_spi_set_cs()
349 static bool uniphier_spi_can_dma(struct spi_master *master, in uniphier_spi_can_dma() argument
353 struct uniphier_spi_priv *priv = spi_master_get_devdata(master); in uniphier_spi_can_dma()
356 if ((!master->dma_tx && !master->dma_rx) in uniphier_spi_can_dma()
357 || (!master->dma_tx && t->tx_buf) in uniphier_spi_can_dma()
358 || (!master->dma_rx && t->rx_buf)) in uniphier_spi_can_dma()
366 struct spi_master *master = data; in uniphier_spi_dma_rxcb() local
367 struct uniphier_spi_priv *priv = spi_master_get_devdata(master); in uniphier_spi_dma_rxcb()
373 spi_finalize_current_transfer(master); in uniphier_spi_dma_rxcb()
378 struct spi_master *master = data; in uniphier_spi_dma_txcb() local
379 struct uniphier_spi_priv *priv = spi_master_get_devdata(master); in uniphier_spi_dma_txcb()
385 spi_finalize_current_transfer(master); in uniphier_spi_dma_txcb()
388 static int uniphier_spi_transfer_one_dma(struct spi_master *master, in uniphier_spi_transfer_one_dma() argument
392 struct uniphier_spi_priv *priv = spi_master_get_devdata(master); in uniphier_spi_transfer_one_dma()
415 dmaengine_slave_config(master->dma_rx, &rxconf); in uniphier_spi_transfer_one_dma()
418 master->dma_rx, in uniphier_spi_transfer_one_dma()
425 rxdesc->callback_param = master; in uniphier_spi_transfer_one_dma()
431 dma_async_issue_pending(master->dma_rx); in uniphier_spi_transfer_one_dma()
442 dmaengine_slave_config(master->dma_tx, &txconf); in uniphier_spi_transfer_one_dma()
445 master->dma_tx, in uniphier_spi_transfer_one_dma()
452 txdesc->callback_param = master; in uniphier_spi_transfer_one_dma()
458 dma_async_issue_pending(master->dma_tx); in uniphier_spi_transfer_one_dma()
466 dmaengine_terminate_sync(master->dma_rx); in uniphier_spi_transfer_one_dma()
471 static int uniphier_spi_transfer_one_irq(struct spi_master *master, in uniphier_spi_transfer_one_irq() argument
475 struct uniphier_spi_priv *priv = spi_master_get_devdata(master); in uniphier_spi_transfer_one_irq()
476 struct device *dev = master->dev.parent; in uniphier_spi_transfer_one_irq()
498 static int uniphier_spi_transfer_one_poll(struct spi_master *master, in uniphier_spi_transfer_one_poll() argument
502 struct uniphier_spi_priv *priv = spi_master_get_devdata(master); in uniphier_spi_transfer_one_poll()
523 return uniphier_spi_transfer_one_irq(master, spi, t); in uniphier_spi_transfer_one_poll()
526 static int uniphier_spi_transfer_one(struct spi_master *master, in uniphier_spi_transfer_one() argument
530 struct uniphier_spi_priv *priv = spi_master_get_devdata(master); in uniphier_spi_transfer_one()
540 use_dma = master->can_dma ? master->can_dma(master, spi, t) : false; in uniphier_spi_transfer_one()
542 return uniphier_spi_transfer_one_dma(master, spi, t); in uniphier_spi_transfer_one()
551 return uniphier_spi_transfer_one_irq(master, spi, t); in uniphier_spi_transfer_one()
553 return uniphier_spi_transfer_one_poll(master, spi, t); in uniphier_spi_transfer_one()
556 static int uniphier_spi_prepare_transfer_hardware(struct spi_master *master) in uniphier_spi_prepare_transfer_hardware() argument
558 struct uniphier_spi_priv *priv = spi_master_get_devdata(master); in uniphier_spi_prepare_transfer_hardware()
565 static int uniphier_spi_unprepare_transfer_hardware(struct spi_master *master) in uniphier_spi_unprepare_transfer_hardware() argument
567 struct uniphier_spi_priv *priv = spi_master_get_devdata(master); in uniphier_spi_unprepare_transfer_hardware()
574 static void uniphier_spi_handle_err(struct spi_master *master, in uniphier_spi_handle_err() argument
577 struct uniphier_spi_priv *priv = spi_master_get_devdata(master); in uniphier_spi_handle_err()
590 dmaengine_terminate_async(master->dma_tx); in uniphier_spi_handle_err()
595 dmaengine_terminate_async(master->dma_rx); in uniphier_spi_handle_err()
644 struct spi_master *master; in uniphier_spi_probe() local
652 master = spi_alloc_master(&pdev->dev, sizeof(*priv)); in uniphier_spi_probe()
653 if (!master) in uniphier_spi_probe()
656 platform_set_drvdata(pdev, master); in uniphier_spi_probe()
658 priv = spi_master_get_devdata(master); in uniphier_spi_probe()
659 priv->master = master; in uniphier_spi_probe()
697 master->max_speed_hz = DIV_ROUND_UP(clk_rate, SSI_MIN_CLK_DIVIDER); in uniphier_spi_probe()
698 master->min_speed_hz = DIV_ROUND_UP(clk_rate, SSI_MAX_CLK_DIVIDER); in uniphier_spi_probe()
699 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST; in uniphier_spi_probe()
700 master->dev.of_node = pdev->dev.of_node; in uniphier_spi_probe()
701 master->bus_num = pdev->id; in uniphier_spi_probe()
702 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32); in uniphier_spi_probe()
704 master->set_cs = uniphier_spi_set_cs; in uniphier_spi_probe()
705 master->transfer_one = uniphier_spi_transfer_one; in uniphier_spi_probe()
706 master->prepare_transfer_hardware in uniphier_spi_probe()
708 master->unprepare_transfer_hardware in uniphier_spi_probe()
710 master->handle_err = uniphier_spi_handle_err; in uniphier_spi_probe()
711 master->can_dma = uniphier_spi_can_dma; in uniphier_spi_probe()
713 master->num_chipselect = 1; in uniphier_spi_probe()
714 master->flags = SPI_CONTROLLER_MUST_RX | SPI_CONTROLLER_MUST_TX; in uniphier_spi_probe()
716 master->dma_tx = dma_request_chan(&pdev->dev, "tx"); in uniphier_spi_probe()
717 if (IS_ERR_OR_NULL(master->dma_tx)) { in uniphier_spi_probe()
718 if (PTR_ERR(master->dma_tx) == -EPROBE_DEFER) { in uniphier_spi_probe()
722 master->dma_tx = NULL; in uniphier_spi_probe()
725 ret = dma_get_slave_caps(master->dma_tx, &caps); in uniphier_spi_probe()
734 master->dma_rx = dma_request_chan(&pdev->dev, "rx"); in uniphier_spi_probe()
735 if (IS_ERR_OR_NULL(master->dma_rx)) { in uniphier_spi_probe()
736 if (PTR_ERR(master->dma_rx) == -EPROBE_DEFER) { in uniphier_spi_probe()
740 master->dma_rx = NULL; in uniphier_spi_probe()
743 ret = dma_get_slave_caps(master->dma_rx, &caps); in uniphier_spi_probe()
752 master->max_dma_len = min(dma_tx_burst, dma_rx_burst); in uniphier_spi_probe()
754 ret = devm_spi_register_master(&pdev->dev, master); in uniphier_spi_probe()
761 if (!IS_ERR_OR_NULL(master->dma_rx)) { in uniphier_spi_probe()
762 dma_release_channel(master->dma_rx); in uniphier_spi_probe()
763 master->dma_rx = NULL; in uniphier_spi_probe()
765 if (!IS_ERR_OR_NULL(master->dma_tx)) { in uniphier_spi_probe()
766 dma_release_channel(master->dma_tx); in uniphier_spi_probe()
767 master->dma_tx = NULL; in uniphier_spi_probe()
774 spi_master_put(master); in uniphier_spi_probe()
780 struct spi_master *master = platform_get_drvdata(pdev); in uniphier_spi_remove() local
781 struct uniphier_spi_priv *priv = spi_master_get_devdata(master); in uniphier_spi_remove()
783 if (master->dma_tx) in uniphier_spi_remove()
784 dma_release_channel(master->dma_tx); in uniphier_spi_remove()
785 if (master->dma_rx) in uniphier_spi_remove()
786 dma_release_channel(master->dma_rx); in uniphier_spi_remove()