Lines Matching refs:controller
193 static bool fsl_lpspi_can_dma(struct spi_controller *controller,
199 if (!controller->dma_rx)
216 static int lpspi_prepare_xfer_hardware(struct spi_controller *controller)
219 spi_controller_get_devdata(controller);
231 static int lpspi_unprepare_xfer_hardware(struct spi_controller *controller)
234 spi_controller_get_devdata(controller);
364 static int fsl_lpspi_dma_configure(struct spi_controller *controller)
370 spi_controller_get_devdata(controller);
390 ret = dmaengine_slave_config(controller->dma_tx, &tx);
401 ret = dmaengine_slave_config(controller->dma_rx, &rx);
444 static int fsl_lpspi_setup_transfer(struct spi_controller *controller,
449 spi_controller_get_devdata(spi->controller);
484 if (fsl_lpspi_can_dma(controller, spi, t))
492 static int fsl_lpspi_target_abort(struct spi_controller *controller)
495 spi_controller_get_devdata(controller);
508 static int fsl_lpspi_wait_for_completion(struct spi_controller *controller)
511 spi_controller_get_devdata(controller);
578 static int fsl_lpspi_dma_transfer(struct spi_controller *controller,
588 ret = fsl_lpspi_dma_configure(controller);
592 desc_rx = dmaengine_prep_slave_sg(controller->dma_rx,
602 dma_async_issue_pending(controller->dma_rx);
604 desc_tx = dmaengine_prep_slave_sg(controller->dma_tx,
608 dmaengine_terminate_all(controller->dma_tx);
616 dma_async_issue_pending(controller->dma_tx);
629 dmaengine_terminate_all(controller->dma_tx);
630 dmaengine_terminate_all(controller->dma_rx);
639 dmaengine_terminate_all(controller->dma_tx);
640 dmaengine_terminate_all(controller->dma_rx);
649 dmaengine_terminate_all(controller->dma_tx);
650 dmaengine_terminate_all(controller->dma_rx);
659 dmaengine_terminate_all(controller->dma_tx);
660 dmaengine_terminate_all(controller->dma_rx);
671 static void fsl_lpspi_dma_exit(struct spi_controller *controller)
673 if (controller->dma_rx) {
674 dma_release_channel(controller->dma_rx);
675 controller->dma_rx = NULL;
678 if (controller->dma_tx) {
679 dma_release_channel(controller->dma_tx);
680 controller->dma_tx = NULL;
686 struct spi_controller *controller)
691 controller->dma_tx = dma_request_chan(dev, "tx");
692 if (IS_ERR(controller->dma_tx)) {
693 ret = PTR_ERR(controller->dma_tx);
695 controller->dma_tx = NULL;
700 controller->dma_rx = dma_request_chan(dev, "rx");
701 if (IS_ERR(controller->dma_rx)) {
702 ret = PTR_ERR(controller->dma_rx);
704 controller->dma_rx = NULL;
710 controller->can_dma = fsl_lpspi_can_dma;
711 controller->max_dma_len = FSL_LPSPI_MAX_EDMA_BYTES;
715 fsl_lpspi_dma_exit(controller);
719 static int fsl_lpspi_pio_transfer(struct spi_controller *controller,
723 spi_controller_get_devdata(controller);
735 ret = fsl_lpspi_wait_for_completion(controller);
744 static int fsl_lpspi_transfer_one(struct spi_controller *controller,
749 spi_controller_get_devdata(controller);
753 ret = fsl_lpspi_setup_transfer(controller, spi, t);
763 ret = fsl_lpspi_dma_transfer(controller, fsl_lpspi, t);
765 ret = fsl_lpspi_pio_transfer(controller, t);
807 struct spi_controller *controller = dev_get_drvdata(dev);
811 fsl_lpspi = spi_controller_get_devdata(controller);
828 struct spi_controller *controller = dev_get_drvdata(dev);
831 fsl_lpspi = spi_controller_get_devdata(controller);
855 struct spi_controller *controller;
868 controller = devm_spi_alloc_target(&pdev->dev,
871 controller = devm_spi_alloc_host(&pdev->dev,
874 if (!controller)
877 platform_set_drvdata(pdev, controller);
879 fsl_lpspi = spi_controller_get_devdata(controller);
942 controller->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32);
943 controller->transfer_one = fsl_lpspi_transfer_one;
944 controller->prepare_transfer_hardware = lpspi_prepare_xfer_hardware;
945 controller->unprepare_transfer_hardware = lpspi_unprepare_xfer_hardware;
946 controller->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
947 controller->flags = SPI_CONTROLLER_MUST_RX | SPI_CONTROLLER_MUST_TX;
948 controller->dev.of_node = pdev->dev.of_node;
949 controller->bus_num = pdev->id;
950 controller->num_chipselect = num_cs;
951 controller->target_abort = fsl_lpspi_target_abort;
953 controller->use_gpio_descriptors = true;
955 ret = fsl_lpspi_dma_init(&pdev->dev, fsl_lpspi, controller);
963 ret = devm_spi_register_controller(&pdev->dev, controller);
975 fsl_lpspi_dma_exit(controller);
986 struct spi_controller *controller = platform_get_drvdata(pdev);
988 spi_controller_get_devdata(controller);
990 fsl_lpspi_dma_exit(controller);