Lines Matching refs:ctlr

117 spi_ingenic_prepare_dma(struct spi_controller *ctlr, struct dma_chan *chan,  in spi_ingenic_prepare_dma()  argument
121 struct ingenic_spi *priv = spi_controller_get_devdata(ctlr); in spi_ingenic_prepare_dma()
156 desc->callback_param = ctlr; in spi_ingenic_prepare_dma()
170 static int spi_ingenic_dma_tx(struct spi_controller *ctlr, in spi_ingenic_dma_tx() argument
175 rx_desc = spi_ingenic_prepare_dma(ctlr, ctlr->dma_rx, in spi_ingenic_dma_tx()
180 tx_desc = spi_ingenic_prepare_dma(ctlr, ctlr->dma_tx, in spi_ingenic_dma_tx()
183 dmaengine_terminate_async(ctlr->dma_rx); in spi_ingenic_dma_tx()
188 dma_async_issue_pending(ctlr->dma_rx); in spi_ingenic_dma_tx()
189 dma_async_issue_pending(ctlr->dma_tx); in spi_ingenic_dma_tx()
235 static int spi_ingenic_transfer_one(struct spi_controller *ctlr, in spi_ingenic_transfer_one() argument
239 struct ingenic_spi *priv = spi_controller_get_devdata(ctlr); in spi_ingenic_transfer_one()
241 bool can_dma = ctlr->can_dma && ctlr->can_dma(ctlr, spi, xfer); in spi_ingenic_transfer_one()
245 if (ctlr->cur_msg_mapped && can_dma) in spi_ingenic_transfer_one()
246 return spi_ingenic_dma_tx(ctlr, xfer, bits); in spi_ingenic_transfer_one()
257 static int spi_ingenic_prepare_message(struct spi_controller *ctlr, in spi_ingenic_prepare_message() argument
260 struct ingenic_spi *priv = spi_controller_get_devdata(ctlr); in spi_ingenic_prepare_message()
297 static int spi_ingenic_prepare_hardware(struct spi_controller *ctlr) in spi_ingenic_prepare_hardware() argument
299 struct ingenic_spi *priv = spi_controller_get_devdata(ctlr); in spi_ingenic_prepare_hardware()
314 static int spi_ingenic_unprepare_hardware(struct spi_controller *ctlr) in spi_ingenic_unprepare_hardware() argument
316 struct ingenic_spi *priv = spi_controller_get_devdata(ctlr); in spi_ingenic_unprepare_hardware()
325 static bool spi_ingenic_can_dma(struct spi_controller *ctlr, in spi_ingenic_can_dma() argument
332 ret = dma_get_slave_caps(ctlr->dma_tx, &caps); in spi_ingenic_can_dma()
342 static int spi_ingenic_request_dma(struct spi_controller *ctlr, in spi_ingenic_request_dma() argument
345 ctlr->dma_tx = dma_request_slave_channel(dev, "tx"); in spi_ingenic_request_dma()
346 if (!ctlr->dma_tx) in spi_ingenic_request_dma()
349 ctlr->dma_rx = dma_request_slave_channel(dev, "rx"); in spi_ingenic_request_dma()
351 if (!ctlr->dma_rx) in spi_ingenic_request_dma()
354 ctlr->can_dma = spi_ingenic_can_dma; in spi_ingenic_request_dma()
361 struct spi_controller *ctlr = data; in spi_ingenic_release_dma() local
363 if (ctlr->dma_tx) in spi_ingenic_release_dma()
364 dma_release_channel(ctlr->dma_tx); in spi_ingenic_release_dma()
365 if (ctlr->dma_rx) in spi_ingenic_release_dma()
366 dma_release_channel(ctlr->dma_rx); in spi_ingenic_release_dma()
380 struct spi_controller *ctlr; in spi_ingenic_probe() local
391 ctlr = devm_spi_alloc_master(dev, sizeof(*priv)); in spi_ingenic_probe()
392 if (!ctlr) { in spi_ingenic_probe()
397 priv = spi_controller_get_devdata(ctlr); in spi_ingenic_probe()
419 platform_set_drvdata(pdev, ctlr); in spi_ingenic_probe()
421 ctlr->prepare_transfer_hardware = spi_ingenic_prepare_hardware; in spi_ingenic_probe()
422 ctlr->unprepare_transfer_hardware = spi_ingenic_unprepare_hardware; in spi_ingenic_probe()
423 ctlr->prepare_message = spi_ingenic_prepare_message; in spi_ingenic_probe()
424 ctlr->set_cs = spi_ingenic_set_cs; in spi_ingenic_probe()
425 ctlr->transfer_one = spi_ingenic_transfer_one; in spi_ingenic_probe()
426 ctlr->mode_bits = SPI_MODE_3 | SPI_LSB_FIRST | SPI_LOOP | SPI_CS_HIGH; in spi_ingenic_probe()
427 ctlr->flags = SPI_CONTROLLER_MUST_RX | SPI_CONTROLLER_MUST_TX; in spi_ingenic_probe()
428 ctlr->max_dma_len = SPI_INGENIC_FIFO_SIZE; in spi_ingenic_probe()
429 ctlr->bits_per_word_mask = pdata->bits_per_word_mask; in spi_ingenic_probe()
430 ctlr->min_speed_hz = 7200; in spi_ingenic_probe()
431 ctlr->max_speed_hz = 54000000; in spi_ingenic_probe()
432 ctlr->num_chipselect = 2; in spi_ingenic_probe()
433 ctlr->dev.of_node = pdev->dev.of_node; in spi_ingenic_probe()
435 if (spi_ingenic_request_dma(ctlr, dev)) in spi_ingenic_probe()
438 ret = devm_add_action_or_reset(dev, spi_ingenic_release_dma, ctlr); in spi_ingenic_probe()
444 ret = devm_spi_register_controller(dev, ctlr); in spi_ingenic_probe()