Lines Matching refs:ss
168 int (*read_bufs)(struct sprd_spi *ss, u32 len);
169 int (*write_bufs)(struct sprd_spi *ss, u32 len);
172 static u32 sprd_spi_transfer_max_timeout(struct sprd_spi *ss, in sprd_spi_transfer_max_timeout() argument
180 u32 bit_time_us = DIV_ROUND_UP(USEC_PER_SEC, ss->hw_speed_hz); in sprd_spi_transfer_max_timeout()
186 u32 interval_cycle = SPRD_SPI_FIFO_SIZE * ss->word_delay; in sprd_spi_transfer_max_timeout()
188 ss->src_clk); in sprd_spi_transfer_max_timeout()
193 static int sprd_spi_wait_for_tx_end(struct sprd_spi *ss, struct spi_transfer *t) in sprd_spi_wait_for_tx_end() argument
198 us = sprd_spi_transfer_max_timeout(ss, t); in sprd_spi_wait_for_tx_end()
199 ret = readl_relaxed_poll_timeout(ss->base + SPRD_SPI_INT_RAW_STS, val, in sprd_spi_wait_for_tx_end()
202 dev_err(ss->dev, "SPI error, spi send timeout!\n"); in sprd_spi_wait_for_tx_end()
206 ret = readl_relaxed_poll_timeout(ss->base + SPRD_SPI_STS2, val, in sprd_spi_wait_for_tx_end()
209 dev_err(ss->dev, "SPI error, spi busy timeout!\n"); in sprd_spi_wait_for_tx_end()
213 writel_relaxed(SPRD_SPI_TX_END_INT_CLR, ss->base + SPRD_SPI_INT_CLR); in sprd_spi_wait_for_tx_end()
218 static int sprd_spi_wait_for_rx_end(struct sprd_spi *ss, struct spi_transfer *t) in sprd_spi_wait_for_rx_end() argument
223 us = sprd_spi_transfer_max_timeout(ss, t); in sprd_spi_wait_for_rx_end()
224 ret = readl_relaxed_poll_timeout(ss->base + SPRD_SPI_INT_RAW_STS, val, in sprd_spi_wait_for_rx_end()
227 dev_err(ss->dev, "SPI error, spi rx timeout!\n"); in sprd_spi_wait_for_rx_end()
231 writel_relaxed(SPRD_SPI_RX_END_INT_CLR, ss->base + SPRD_SPI_INT_CLR); in sprd_spi_wait_for_rx_end()
236 static void sprd_spi_tx_req(struct sprd_spi *ss) in sprd_spi_tx_req() argument
238 writel_relaxed(SPRD_SPI_SW_TX_REQ, ss->base + SPRD_SPI_CTL12); in sprd_spi_tx_req()
241 static void sprd_spi_rx_req(struct sprd_spi *ss) in sprd_spi_rx_req() argument
243 writel_relaxed(SPRD_SPI_SW_RX_REQ, ss->base + SPRD_SPI_CTL12); in sprd_spi_rx_req()
246 static void sprd_spi_enter_idle(struct sprd_spi *ss) in sprd_spi_enter_idle() argument
248 u32 val = readl_relaxed(ss->base + SPRD_SPI_CTL1); in sprd_spi_enter_idle()
251 writel_relaxed(val, ss->base + SPRD_SPI_CTL1); in sprd_spi_enter_idle()
254 static void sprd_spi_set_transfer_bits(struct sprd_spi *ss, u32 bits) in sprd_spi_set_transfer_bits() argument
256 u32 val = readl_relaxed(ss->base + SPRD_SPI_CTL0); in sprd_spi_set_transfer_bits()
261 writel_relaxed(val, ss->base + SPRD_SPI_CTL0); in sprd_spi_set_transfer_bits()
264 static void sprd_spi_set_tx_length(struct sprd_spi *ss, u32 length) in sprd_spi_set_tx_length() argument
266 u32 val = readl_relaxed(ss->base + SPRD_SPI_CTL8); in sprd_spi_set_tx_length()
271 writel_relaxed(val, ss->base + SPRD_SPI_CTL8); in sprd_spi_set_tx_length()
274 writel_relaxed(val, ss->base + SPRD_SPI_CTL9); in sprd_spi_set_tx_length()
277 static void sprd_spi_set_rx_length(struct sprd_spi *ss, u32 length) in sprd_spi_set_rx_length() argument
279 u32 val = readl_relaxed(ss->base + SPRD_SPI_CTL10); in sprd_spi_set_rx_length()
284 writel_relaxed(val, ss->base + SPRD_SPI_CTL10); in sprd_spi_set_rx_length()
287 writel_relaxed(val, ss->base + SPRD_SPI_CTL11); in sprd_spi_set_rx_length()
293 struct sprd_spi *ss = spi_controller_get_devdata(sctlr); in sprd_spi_chipselect() local
296 val = readl_relaxed(ss->base + SPRD_SPI_CTL0); in sprd_spi_chipselect()
300 writel_relaxed(val, ss->base + SPRD_SPI_CTL0); in sprd_spi_chipselect()
303 writel_relaxed(val, ss->base + SPRD_SPI_CTL0); in sprd_spi_chipselect()
307 static int sprd_spi_write_only_receive(struct sprd_spi *ss, u32 len) in sprd_spi_write_only_receive() argument
312 val = readl_relaxed(ss->base + SPRD_SPI_CTL4); in sprd_spi_write_only_receive()
314 writel_relaxed(val, ss->base + SPRD_SPI_CTL4); in sprd_spi_write_only_receive()
317 val = readl_relaxed(ss->base + SPRD_SPI_CTL4); in sprd_spi_write_only_receive()
319 writel_relaxed(val, ss->base + SPRD_SPI_CTL4); in sprd_spi_write_only_receive()
322 val = readl_relaxed(ss->base + SPRD_SPI_CTL4); in sprd_spi_write_only_receive()
324 writel_relaxed(val, ss->base + SPRD_SPI_CTL4); in sprd_spi_write_only_receive()
329 static int sprd_spi_write_bufs_u8(struct sprd_spi *ss, u32 len) in sprd_spi_write_bufs_u8() argument
331 u8 *tx_p = (u8 *)ss->tx_buf; in sprd_spi_write_bufs_u8()
335 writeb_relaxed(tx_p[i], ss->base + SPRD_SPI_TXD); in sprd_spi_write_bufs_u8()
337 ss->tx_buf += i; in sprd_spi_write_bufs_u8()
341 static int sprd_spi_write_bufs_u16(struct sprd_spi *ss, u32 len) in sprd_spi_write_bufs_u16() argument
343 u16 *tx_p = (u16 *)ss->tx_buf; in sprd_spi_write_bufs_u16()
347 writew_relaxed(tx_p[i], ss->base + SPRD_SPI_TXD); in sprd_spi_write_bufs_u16()
349 ss->tx_buf += i << 1; in sprd_spi_write_bufs_u16()
353 static int sprd_spi_write_bufs_u32(struct sprd_spi *ss, u32 len) in sprd_spi_write_bufs_u32() argument
355 u32 *tx_p = (u32 *)ss->tx_buf; in sprd_spi_write_bufs_u32()
359 writel_relaxed(tx_p[i], ss->base + SPRD_SPI_TXD); in sprd_spi_write_bufs_u32()
361 ss->tx_buf += i << 2; in sprd_spi_write_bufs_u32()
365 static int sprd_spi_read_bufs_u8(struct sprd_spi *ss, u32 len) in sprd_spi_read_bufs_u8() argument
367 u8 *rx_p = (u8 *)ss->rx_buf; in sprd_spi_read_bufs_u8()
371 rx_p[i] = readb_relaxed(ss->base + SPRD_SPI_TXD); in sprd_spi_read_bufs_u8()
373 ss->rx_buf += i; in sprd_spi_read_bufs_u8()
377 static int sprd_spi_read_bufs_u16(struct sprd_spi *ss, u32 len) in sprd_spi_read_bufs_u16() argument
379 u16 *rx_p = (u16 *)ss->rx_buf; in sprd_spi_read_bufs_u16()
383 rx_p[i] = readw_relaxed(ss->base + SPRD_SPI_TXD); in sprd_spi_read_bufs_u16()
385 ss->rx_buf += i << 1; in sprd_spi_read_bufs_u16()
389 static int sprd_spi_read_bufs_u32(struct sprd_spi *ss, u32 len) in sprd_spi_read_bufs_u32() argument
391 u32 *rx_p = (u32 *)ss->rx_buf; in sprd_spi_read_bufs_u32()
395 rx_p[i] = readl_relaxed(ss->base + SPRD_SPI_TXD); in sprd_spi_read_bufs_u32()
397 ss->rx_buf += i << 2; in sprd_spi_read_bufs_u32()
403 struct sprd_spi *ss = spi_controller_get_devdata(sdev->controller); in sprd_spi_txrx_bufs() local
404 u32 trans_len = ss->trans_len, len; in sprd_spi_txrx_bufs()
410 if (ss->trans_mode & SPRD_SPI_TX_MODE) { in sprd_spi_txrx_bufs()
411 sprd_spi_set_tx_length(ss, len); in sprd_spi_txrx_bufs()
412 write_size += ss->write_bufs(ss, len); in sprd_spi_txrx_bufs()
418 if (ss->hw_mode & SPI_3WIRE || ss->hw_mode & SPI_TX_DUAL) in sprd_spi_txrx_bufs()
419 sprd_spi_tx_req(ss); in sprd_spi_txrx_bufs()
421 ret = sprd_spi_wait_for_tx_end(ss, t); in sprd_spi_txrx_bufs()
423 sprd_spi_set_rx_length(ss, len); in sprd_spi_txrx_bufs()
429 if (ss->hw_mode & SPI_3WIRE || ss->hw_mode & SPI_TX_DUAL) in sprd_spi_txrx_bufs()
430 sprd_spi_rx_req(ss); in sprd_spi_txrx_bufs()
432 write_size += ss->write_bufs(ss, len); in sprd_spi_txrx_bufs()
434 ret = sprd_spi_wait_for_rx_end(ss, t); in sprd_spi_txrx_bufs()
440 if (ss->trans_mode & SPRD_SPI_RX_MODE) in sprd_spi_txrx_bufs()
441 read_size += ss->read_bufs(ss, len); in sprd_spi_txrx_bufs()
446 if (ss->trans_mode & SPRD_SPI_TX_MODE) in sprd_spi_txrx_bufs()
451 sprd_spi_enter_idle(ss); in sprd_spi_txrx_bufs()
456 static void sprd_spi_irq_enable(struct sprd_spi *ss) in sprd_spi_irq_enable() argument
462 ss->base + SPRD_SPI_INT_CLR); in sprd_spi_irq_enable()
464 val = readl_relaxed(ss->base + SPRD_SPI_INT_EN); in sprd_spi_irq_enable()
467 ss->base + SPRD_SPI_INT_EN); in sprd_spi_irq_enable()
470 static void sprd_spi_irq_disable(struct sprd_spi *ss) in sprd_spi_irq_disable() argument
472 writel_relaxed(0, ss->base + SPRD_SPI_INT_EN); in sprd_spi_irq_disable()
475 static void sprd_spi_dma_enable(struct sprd_spi *ss, bool enable) in sprd_spi_dma_enable() argument
477 u32 val = readl_relaxed(ss->base + SPRD_SPI_CTL2); in sprd_spi_dma_enable()
484 writel_relaxed(val, ss->base + SPRD_SPI_CTL2); in sprd_spi_dma_enable()
516 static int sprd_spi_dma_rx_config(struct sprd_spi *ss, struct spi_transfer *t) in sprd_spi_dma_rx_config() argument
518 struct dma_chan *dma_chan = ss->dma.dma_chan[SPRD_SPI_RX]; in sprd_spi_dma_rx_config()
520 .src_addr = ss->phy_base, in sprd_spi_dma_rx_config()
521 .src_addr_width = ss->dma.width, in sprd_spi_dma_rx_config()
522 .dst_addr_width = ss->dma.width, in sprd_spi_dma_rx_config()
523 .dst_maxburst = ss->dma.fragmens_len, in sprd_spi_dma_rx_config()
531 return ss->dma.rx_len; in sprd_spi_dma_rx_config()
534 static int sprd_spi_dma_tx_config(struct sprd_spi *ss, struct spi_transfer *t) in sprd_spi_dma_tx_config() argument
536 struct dma_chan *dma_chan = ss->dma.dma_chan[SPRD_SPI_TX]; in sprd_spi_dma_tx_config()
538 .dst_addr = ss->phy_base, in sprd_spi_dma_tx_config()
539 .src_addr_width = ss->dma.width, in sprd_spi_dma_tx_config()
540 .dst_addr_width = ss->dma.width, in sprd_spi_dma_tx_config()
541 .src_maxburst = ss->dma.fragmens_len, in sprd_spi_dma_tx_config()
552 static int sprd_spi_dma_request(struct sprd_spi *ss) in sprd_spi_dma_request() argument
554 ss->dma.dma_chan[SPRD_SPI_RX] = dma_request_chan(ss->dev, "rx_chn"); in sprd_spi_dma_request()
555 if (IS_ERR_OR_NULL(ss->dma.dma_chan[SPRD_SPI_RX])) in sprd_spi_dma_request()
556 return dev_err_probe(ss->dev, PTR_ERR(ss->dma.dma_chan[SPRD_SPI_RX]), in sprd_spi_dma_request()
559 ss->dma.dma_chan[SPRD_SPI_TX] = dma_request_chan(ss->dev, "tx_chn"); in sprd_spi_dma_request()
560 if (IS_ERR_OR_NULL(ss->dma.dma_chan[SPRD_SPI_TX])) { in sprd_spi_dma_request()
561 dma_release_channel(ss->dma.dma_chan[SPRD_SPI_RX]); in sprd_spi_dma_request()
562 return dev_err_probe(ss->dev, PTR_ERR(ss->dma.dma_chan[SPRD_SPI_TX]), in sprd_spi_dma_request()
569 static void sprd_spi_dma_release(struct sprd_spi *ss) in sprd_spi_dma_release() argument
571 if (ss->dma.dma_chan[SPRD_SPI_RX]) in sprd_spi_dma_release()
572 dma_release_channel(ss->dma.dma_chan[SPRD_SPI_RX]); in sprd_spi_dma_release()
574 if (ss->dma.dma_chan[SPRD_SPI_TX]) in sprd_spi_dma_release()
575 dma_release_channel(ss->dma.dma_chan[SPRD_SPI_TX]); in sprd_spi_dma_release()
581 struct sprd_spi *ss = spi_master_get_devdata(sdev->master); in sprd_spi_dma_txrx_bufs() local
582 u32 trans_len = ss->trans_len; in sprd_spi_dma_txrx_bufs()
585 reinit_completion(&ss->xfer_completion); in sprd_spi_dma_txrx_bufs()
586 sprd_spi_irq_enable(ss); in sprd_spi_dma_txrx_bufs()
587 if (ss->trans_mode & SPRD_SPI_TX_MODE) { in sprd_spi_dma_txrx_bufs()
588 write_size = sprd_spi_dma_tx_config(ss, t); in sprd_spi_dma_txrx_bufs()
589 sprd_spi_set_tx_length(ss, trans_len); in sprd_spi_dma_txrx_bufs()
595 if (ss->hw_mode & SPI_3WIRE || ss->hw_mode & SPI_TX_DUAL) in sprd_spi_dma_txrx_bufs()
596 sprd_spi_tx_req(ss); in sprd_spi_dma_txrx_bufs()
598 sprd_spi_set_rx_length(ss, trans_len); in sprd_spi_dma_txrx_bufs()
604 if (ss->hw_mode & SPI_3WIRE || ss->hw_mode & SPI_TX_DUAL) in sprd_spi_dma_txrx_bufs()
605 sprd_spi_rx_req(ss); in sprd_spi_dma_txrx_bufs()
607 write_size = ss->write_bufs(ss, trans_len); in sprd_spi_dma_txrx_bufs()
612 dev_err(ss->dev, "failed to write, ret = %d\n", ret); in sprd_spi_dma_txrx_bufs()
616 if (ss->trans_mode & SPRD_SPI_RX_MODE) { in sprd_spi_dma_txrx_bufs()
624 ss->dma.rx_len = t->len > ss->dma.fragmens_len ? in sprd_spi_dma_txrx_bufs()
625 (t->len - t->len % ss->dma.fragmens_len) : in sprd_spi_dma_txrx_bufs()
627 ret = sprd_spi_dma_rx_config(ss, t); in sprd_spi_dma_txrx_bufs()
635 sprd_spi_dma_enable(ss, true); in sprd_spi_dma_txrx_bufs()
636 wait_for_completion(&(ss->xfer_completion)); in sprd_spi_dma_txrx_bufs()
638 if (ss->trans_mode & SPRD_SPI_TX_MODE) in sprd_spi_dma_txrx_bufs()
641 ret = ss->dma.rx_len; in sprd_spi_dma_txrx_bufs()
644 sprd_spi_dma_enable(ss, false); in sprd_spi_dma_txrx_bufs()
645 sprd_spi_enter_idle(ss); in sprd_spi_dma_txrx_bufs()
646 sprd_spi_irq_disable(ss); in sprd_spi_dma_txrx_bufs()
651 static void sprd_spi_set_speed(struct sprd_spi *ss, u32 speed_hz) in sprd_spi_set_speed() argument
657 u32 clk_div = DIV_ROUND_UP(ss->src_clk, speed_hz << 1) - 1; in sprd_spi_set_speed()
660 ss->hw_speed_hz = (ss->src_clk >> 1) / (clk_div + 1); in sprd_spi_set_speed()
661 writel_relaxed(clk_div, ss->base + SPRD_SPI_CLKD); in sprd_spi_set_speed()
664 static int sprd_spi_init_hw(struct sprd_spi *ss, struct spi_transfer *t) in sprd_spi_init_hw() argument
673 val = readl_relaxed(ss->base + SPRD_SPI_CTL0); in sprd_spi_init_hw()
676 val |= ss->hw_mode & SPI_CPHA ? SPRD_SPI_NG_RX : SPRD_SPI_NG_TX; in sprd_spi_init_hw()
677 val |= ss->hw_mode & SPI_CPOL ? SPRD_SPI_SCK_REV : 0; in sprd_spi_init_hw()
678 writel_relaxed(val, ss->base + SPRD_SPI_CTL0); in sprd_spi_init_hw()
688 ss->word_delay = interval * 4 + 10; in sprd_spi_init_hw()
689 writel_relaxed(interval, ss->base + SPRD_SPI_CTL5); in sprd_spi_init_hw()
692 writel_relaxed(1, ss->base + SPRD_SPI_FIFO_RST); in sprd_spi_init_hw()
693 writel_relaxed(0, ss->base + SPRD_SPI_FIFO_RST); in sprd_spi_init_hw()
696 val = readl_relaxed(ss->base + SPRD_SPI_CTL7); in sprd_spi_init_hw()
699 if (ss->hw_mode & SPI_3WIRE) in sprd_spi_init_hw()
704 if (ss->hw_mode & SPI_TX_DUAL) in sprd_spi_init_hw()
709 writel_relaxed(val, ss->base + SPRD_SPI_CTL7); in sprd_spi_init_hw()
717 struct sprd_spi *ss = spi_controller_get_devdata(sdev->controller); in sprd_spi_setup_transfer() local
722 ss->len = t->len; in sprd_spi_setup_transfer()
723 ss->tx_buf = t->tx_buf; in sprd_spi_setup_transfer()
724 ss->rx_buf = t->rx_buf; in sprd_spi_setup_transfer()
726 ss->hw_mode = sdev->mode; in sprd_spi_setup_transfer()
727 ret = sprd_spi_init_hw(ss, t); in sprd_spi_setup_transfer()
732 sprd_spi_set_speed(ss, t->speed_hz); in sprd_spi_setup_transfer()
733 sprd_spi_set_transfer_bits(ss, bits_per_word); in sprd_spi_setup_transfer()
742 ss->trans_len = t->len; in sprd_spi_setup_transfer()
743 ss->read_bufs = sprd_spi_read_bufs_u8; in sprd_spi_setup_transfer()
744 ss->write_bufs = sprd_spi_write_bufs_u8; in sprd_spi_setup_transfer()
745 ss->dma.width = DMA_SLAVE_BUSWIDTH_1_BYTE; in sprd_spi_setup_transfer()
746 ss->dma.fragmens_len = SPRD_SPI_DMA_STEP; in sprd_spi_setup_transfer()
749 ss->trans_len = t->len >> 1; in sprd_spi_setup_transfer()
750 ss->read_bufs = sprd_spi_read_bufs_u16; in sprd_spi_setup_transfer()
751 ss->write_bufs = sprd_spi_write_bufs_u16; in sprd_spi_setup_transfer()
752 ss->dma.width = DMA_SLAVE_BUSWIDTH_2_BYTES; in sprd_spi_setup_transfer()
753 ss->dma.fragmens_len = SPRD_SPI_DMA_STEP << 1; in sprd_spi_setup_transfer()
756 ss->trans_len = t->len >> 2; in sprd_spi_setup_transfer()
757 ss->read_bufs = sprd_spi_read_bufs_u32; in sprd_spi_setup_transfer()
758 ss->write_bufs = sprd_spi_write_bufs_u32; in sprd_spi_setup_transfer()
759 ss->dma.width = DMA_SLAVE_BUSWIDTH_4_BYTES; in sprd_spi_setup_transfer()
760 ss->dma.fragmens_len = SPRD_SPI_DMA_STEP << 2; in sprd_spi_setup_transfer()
767 val = readl_relaxed(ss->base + SPRD_SPI_CTL1); in sprd_spi_setup_transfer()
774 writel_relaxed(val | mode, ss->base + SPRD_SPI_CTL1); in sprd_spi_setup_transfer()
776 ss->trans_mode = mode; in sprd_spi_setup_transfer()
782 if (ss->trans_mode == SPRD_SPI_RX_MODE) in sprd_spi_setup_transfer()
783 ss->write_bufs = sprd_spi_write_only_receive; in sprd_spi_setup_transfer()
816 struct sprd_spi *ss = (struct sprd_spi *)data; in sprd_spi_handle_irq() local
817 u32 val = readl_relaxed(ss->base + SPRD_SPI_INT_MASK_STS); in sprd_spi_handle_irq()
820 writel_relaxed(SPRD_SPI_TX_END_CLR, ss->base + SPRD_SPI_INT_CLR); in sprd_spi_handle_irq()
821 if (!(ss->trans_mode & SPRD_SPI_RX_MODE)) in sprd_spi_handle_irq()
822 complete(&ss->xfer_completion); in sprd_spi_handle_irq()
828 writel_relaxed(SPRD_SPI_RX_END_CLR, ss->base + SPRD_SPI_INT_CLR); in sprd_spi_handle_irq()
829 if (ss->dma.rx_len < ss->len) { in sprd_spi_handle_irq()
830 ss->rx_buf += ss->dma.rx_len; in sprd_spi_handle_irq()
831 ss->dma.rx_len += in sprd_spi_handle_irq()
832 ss->read_bufs(ss, ss->len - ss->dma.rx_len); in sprd_spi_handle_irq()
834 complete(&ss->xfer_completion); in sprd_spi_handle_irq()
842 static int sprd_spi_irq_init(struct platform_device *pdev, struct sprd_spi *ss) in sprd_spi_irq_init() argument
846 ss->irq = platform_get_irq(pdev, 0); in sprd_spi_irq_init()
847 if (ss->irq < 0) in sprd_spi_irq_init()
848 return ss->irq; in sprd_spi_irq_init()
850 ret = devm_request_irq(&pdev->dev, ss->irq, sprd_spi_handle_irq, in sprd_spi_irq_init()
851 0, pdev->name, ss); in sprd_spi_irq_init()
854 ss->irq, ret); in sprd_spi_irq_init()
859 static int sprd_spi_clk_init(struct platform_device *pdev, struct sprd_spi *ss) in sprd_spi_clk_init() argument
875 ss->clk = devm_clk_get(&pdev->dev, "enable"); in sprd_spi_clk_init()
876 if (IS_ERR(ss->clk)) { in sprd_spi_clk_init()
878 return PTR_ERR(ss->clk); in sprd_spi_clk_init()
882 ss->src_clk = clk_get_rate(clk_spi); in sprd_spi_clk_init()
884 ss->src_clk = SPRD_SPI_DEFAULT_SOURCE; in sprd_spi_clk_init()
892 struct sprd_spi *ss = spi_controller_get_devdata(sctlr); in sprd_spi_can_dma() local
894 return ss->dma.enable && (t->len > SPRD_SPI_FIFO_SIZE); in sprd_spi_can_dma()
897 static int sprd_spi_dma_init(struct platform_device *pdev, struct sprd_spi *ss) in sprd_spi_dma_init() argument
901 ret = sprd_spi_dma_request(ss); in sprd_spi_dma_init()
913 ss->dma.enable = true; in sprd_spi_dma_init()
922 struct sprd_spi *ss; in sprd_spi_probe() local
926 sctlr = spi_alloc_master(&pdev->dev, sizeof(*ss)); in sprd_spi_probe()
930 ss = spi_controller_get_devdata(sctlr); in sprd_spi_probe()
931 ss->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); in sprd_spi_probe()
932 if (IS_ERR(ss->base)) { in sprd_spi_probe()
933 ret = PTR_ERR(ss->base); in sprd_spi_probe()
937 ss->phy_base = res->start; in sprd_spi_probe()
938 ss->dev = &pdev->dev; in sprd_spi_probe()
946 sctlr->max_speed_hz = min_t(u32, ss->src_clk >> 1, in sprd_spi_probe()
949 init_completion(&ss->xfer_completion); in sprd_spi_probe()
951 ret = sprd_spi_clk_init(pdev, ss); in sprd_spi_probe()
955 ret = sprd_spi_irq_init(pdev, ss); in sprd_spi_probe()
959 ret = sprd_spi_dma_init(pdev, ss); in sprd_spi_probe()
963 ret = clk_prepare_enable(ss->clk); in sprd_spi_probe()
994 clk_disable_unprepare(ss->clk); in sprd_spi_probe()
996 sprd_spi_dma_release(ss); in sprd_spi_probe()
1006 struct sprd_spi *ss = spi_controller_get_devdata(sctlr); in sprd_spi_remove() local
1009 ret = pm_runtime_get_sync(ss->dev); in sprd_spi_remove()
1011 dev_err(ss->dev, "failed to resume SPI controller\n"); in sprd_spi_remove()
1016 if (ss->dma.enable) in sprd_spi_remove()
1017 sprd_spi_dma_release(ss); in sprd_spi_remove()
1018 clk_disable_unprepare(ss->clk); in sprd_spi_remove()
1027 struct sprd_spi *ss = spi_controller_get_devdata(sctlr); in sprd_spi_runtime_suspend() local
1029 if (ss->dma.enable) in sprd_spi_runtime_suspend()
1030 sprd_spi_dma_release(ss); in sprd_spi_runtime_suspend()
1032 clk_disable_unprepare(ss->clk); in sprd_spi_runtime_suspend()
1040 struct sprd_spi *ss = spi_controller_get_devdata(sctlr); in sprd_spi_runtime_resume() local
1043 ret = clk_prepare_enable(ss->clk); in sprd_spi_runtime_resume()
1047 if (!ss->dma.enable) in sprd_spi_runtime_resume()
1050 ret = sprd_spi_dma_request(ss); in sprd_spi_runtime_resume()
1052 clk_disable_unprepare(ss->clk); in sprd_spi_runtime_resume()