Lines Matching refs:ss

169 	int (*read_bufs)(struct sprd_spi *ss, u32 len);
170 int (*write_bufs)(struct sprd_spi *ss, u32 len);
173 static u32 sprd_spi_transfer_max_timeout(struct sprd_spi *ss, in sprd_spi_transfer_max_timeout() argument
181 u32 bit_time_us = DIV_ROUND_UP(USEC_PER_SEC, ss->hw_speed_hz); in sprd_spi_transfer_max_timeout()
187 u32 interval_cycle = SPRD_SPI_FIFO_SIZE * ss->word_delay; in sprd_spi_transfer_max_timeout()
189 ss->src_clk); in sprd_spi_transfer_max_timeout()
194 static int sprd_spi_wait_for_tx_end(struct sprd_spi *ss, struct spi_transfer *t) in sprd_spi_wait_for_tx_end() argument
199 us = sprd_spi_transfer_max_timeout(ss, t); in sprd_spi_wait_for_tx_end()
200 ret = readl_relaxed_poll_timeout(ss->base + SPRD_SPI_INT_RAW_STS, val, in sprd_spi_wait_for_tx_end()
203 dev_err(ss->dev, "SPI error, spi send timeout!\n"); in sprd_spi_wait_for_tx_end()
207 ret = readl_relaxed_poll_timeout(ss->base + SPRD_SPI_STS2, val, in sprd_spi_wait_for_tx_end()
210 dev_err(ss->dev, "SPI error, spi busy timeout!\n"); in sprd_spi_wait_for_tx_end()
214 writel_relaxed(SPRD_SPI_TX_END_INT_CLR, ss->base + SPRD_SPI_INT_CLR); in sprd_spi_wait_for_tx_end()
219 static int sprd_spi_wait_for_rx_end(struct sprd_spi *ss, struct spi_transfer *t) in sprd_spi_wait_for_rx_end() argument
224 us = sprd_spi_transfer_max_timeout(ss, t); in sprd_spi_wait_for_rx_end()
225 ret = readl_relaxed_poll_timeout(ss->base + SPRD_SPI_INT_RAW_STS, val, in sprd_spi_wait_for_rx_end()
228 dev_err(ss->dev, "SPI error, spi rx timeout!\n"); in sprd_spi_wait_for_rx_end()
232 writel_relaxed(SPRD_SPI_RX_END_INT_CLR, ss->base + SPRD_SPI_INT_CLR); in sprd_spi_wait_for_rx_end()
237 static void sprd_spi_tx_req(struct sprd_spi *ss) in sprd_spi_tx_req() argument
239 writel_relaxed(SPRD_SPI_SW_TX_REQ, ss->base + SPRD_SPI_CTL12); in sprd_spi_tx_req()
242 static void sprd_spi_rx_req(struct sprd_spi *ss) in sprd_spi_rx_req() argument
244 writel_relaxed(SPRD_SPI_SW_RX_REQ, ss->base + SPRD_SPI_CTL12); in sprd_spi_rx_req()
247 static void sprd_spi_enter_idle(struct sprd_spi *ss) in sprd_spi_enter_idle() argument
249 u32 val = readl_relaxed(ss->base + SPRD_SPI_CTL1); in sprd_spi_enter_idle()
252 writel_relaxed(val, ss->base + SPRD_SPI_CTL1); in sprd_spi_enter_idle()
255 static void sprd_spi_set_transfer_bits(struct sprd_spi *ss, u32 bits) in sprd_spi_set_transfer_bits() argument
257 u32 val = readl_relaxed(ss->base + SPRD_SPI_CTL0); in sprd_spi_set_transfer_bits()
262 writel_relaxed(val, ss->base + SPRD_SPI_CTL0); in sprd_spi_set_transfer_bits()
265 static void sprd_spi_set_tx_length(struct sprd_spi *ss, u32 length) in sprd_spi_set_tx_length() argument
267 u32 val = readl_relaxed(ss->base + SPRD_SPI_CTL8); in sprd_spi_set_tx_length()
272 writel_relaxed(val, ss->base + SPRD_SPI_CTL8); in sprd_spi_set_tx_length()
275 writel_relaxed(val, ss->base + SPRD_SPI_CTL9); in sprd_spi_set_tx_length()
278 static void sprd_spi_set_rx_length(struct sprd_spi *ss, u32 length) in sprd_spi_set_rx_length() argument
280 u32 val = readl_relaxed(ss->base + SPRD_SPI_CTL10); in sprd_spi_set_rx_length()
285 writel_relaxed(val, ss->base + SPRD_SPI_CTL10); in sprd_spi_set_rx_length()
288 writel_relaxed(val, ss->base + SPRD_SPI_CTL11); in sprd_spi_set_rx_length()
294 struct sprd_spi *ss = spi_controller_get_devdata(sctlr); in sprd_spi_chipselect() local
297 val = readl_relaxed(ss->base + SPRD_SPI_CTL0); in sprd_spi_chipselect()
301 writel_relaxed(val, ss->base + SPRD_SPI_CTL0); in sprd_spi_chipselect()
304 writel_relaxed(val, ss->base + SPRD_SPI_CTL0); in sprd_spi_chipselect()
308 static int sprd_spi_write_only_receive(struct sprd_spi *ss, u32 len) in sprd_spi_write_only_receive() argument
313 val = readl_relaxed(ss->base + SPRD_SPI_CTL4); in sprd_spi_write_only_receive()
315 writel_relaxed(val, ss->base + SPRD_SPI_CTL4); in sprd_spi_write_only_receive()
318 val = readl_relaxed(ss->base + SPRD_SPI_CTL4); in sprd_spi_write_only_receive()
320 writel_relaxed(val, ss->base + SPRD_SPI_CTL4); in sprd_spi_write_only_receive()
323 val = readl_relaxed(ss->base + SPRD_SPI_CTL4); in sprd_spi_write_only_receive()
325 writel_relaxed(val, ss->base + SPRD_SPI_CTL4); in sprd_spi_write_only_receive()
330 static int sprd_spi_write_bufs_u8(struct sprd_spi *ss, u32 len) in sprd_spi_write_bufs_u8() argument
332 u8 *tx_p = (u8 *)ss->tx_buf; in sprd_spi_write_bufs_u8()
336 writeb_relaxed(tx_p[i], ss->base + SPRD_SPI_TXD); in sprd_spi_write_bufs_u8()
338 ss->tx_buf += i; in sprd_spi_write_bufs_u8()
342 static int sprd_spi_write_bufs_u16(struct sprd_spi *ss, u32 len) in sprd_spi_write_bufs_u16() argument
344 u16 *tx_p = (u16 *)ss->tx_buf; in sprd_spi_write_bufs_u16()
348 writew_relaxed(tx_p[i], ss->base + SPRD_SPI_TXD); in sprd_spi_write_bufs_u16()
350 ss->tx_buf += i << 1; in sprd_spi_write_bufs_u16()
354 static int sprd_spi_write_bufs_u32(struct sprd_spi *ss, u32 len) in sprd_spi_write_bufs_u32() argument
356 u32 *tx_p = (u32 *)ss->tx_buf; in sprd_spi_write_bufs_u32()
360 writel_relaxed(tx_p[i], ss->base + SPRD_SPI_TXD); in sprd_spi_write_bufs_u32()
362 ss->tx_buf += i << 2; in sprd_spi_write_bufs_u32()
366 static int sprd_spi_read_bufs_u8(struct sprd_spi *ss, u32 len) in sprd_spi_read_bufs_u8() argument
368 u8 *rx_p = (u8 *)ss->rx_buf; in sprd_spi_read_bufs_u8()
372 rx_p[i] = readb_relaxed(ss->base + SPRD_SPI_TXD); in sprd_spi_read_bufs_u8()
374 ss->rx_buf += i; in sprd_spi_read_bufs_u8()
378 static int sprd_spi_read_bufs_u16(struct sprd_spi *ss, u32 len) in sprd_spi_read_bufs_u16() argument
380 u16 *rx_p = (u16 *)ss->rx_buf; in sprd_spi_read_bufs_u16()
384 rx_p[i] = readw_relaxed(ss->base + SPRD_SPI_TXD); in sprd_spi_read_bufs_u16()
386 ss->rx_buf += i << 1; in sprd_spi_read_bufs_u16()
390 static int sprd_spi_read_bufs_u32(struct sprd_spi *ss, u32 len) in sprd_spi_read_bufs_u32() argument
392 u32 *rx_p = (u32 *)ss->rx_buf; in sprd_spi_read_bufs_u32()
396 rx_p[i] = readl_relaxed(ss->base + SPRD_SPI_TXD); in sprd_spi_read_bufs_u32()
398 ss->rx_buf += i << 2; in sprd_spi_read_bufs_u32()
404 struct sprd_spi *ss = spi_controller_get_devdata(sdev->controller); in sprd_spi_txrx_bufs() local
405 u32 trans_len = ss->trans_len, len; in sprd_spi_txrx_bufs()
411 if (ss->trans_mode & SPRD_SPI_TX_MODE) { in sprd_spi_txrx_bufs()
412 sprd_spi_set_tx_length(ss, len); in sprd_spi_txrx_bufs()
413 write_size += ss->write_bufs(ss, len); in sprd_spi_txrx_bufs()
419 if (ss->hw_mode & SPI_3WIRE || ss->hw_mode & SPI_TX_DUAL) in sprd_spi_txrx_bufs()
420 sprd_spi_tx_req(ss); in sprd_spi_txrx_bufs()
422 ret = sprd_spi_wait_for_tx_end(ss, t); in sprd_spi_txrx_bufs()
424 sprd_spi_set_rx_length(ss, len); in sprd_spi_txrx_bufs()
430 if (ss->hw_mode & SPI_3WIRE || ss->hw_mode & SPI_TX_DUAL) in sprd_spi_txrx_bufs()
431 sprd_spi_rx_req(ss); in sprd_spi_txrx_bufs()
433 write_size += ss->write_bufs(ss, len); in sprd_spi_txrx_bufs()
435 ret = sprd_spi_wait_for_rx_end(ss, t); in sprd_spi_txrx_bufs()
441 if (ss->trans_mode & SPRD_SPI_RX_MODE) in sprd_spi_txrx_bufs()
442 read_size += ss->read_bufs(ss, len); in sprd_spi_txrx_bufs()
447 if (ss->trans_mode & SPRD_SPI_TX_MODE) in sprd_spi_txrx_bufs()
452 sprd_spi_enter_idle(ss); in sprd_spi_txrx_bufs()
457 static void sprd_spi_irq_enable(struct sprd_spi *ss) in sprd_spi_irq_enable() argument
463 ss->base + SPRD_SPI_INT_CLR); in sprd_spi_irq_enable()
465 val = readl_relaxed(ss->base + SPRD_SPI_INT_EN); in sprd_spi_irq_enable()
468 ss->base + SPRD_SPI_INT_EN); in sprd_spi_irq_enable()
471 static void sprd_spi_irq_disable(struct sprd_spi *ss) in sprd_spi_irq_disable() argument
473 writel_relaxed(0, ss->base + SPRD_SPI_INT_EN); in sprd_spi_irq_disable()
476 static void sprd_spi_dma_enable(struct sprd_spi *ss, bool enable) in sprd_spi_dma_enable() argument
478 u32 val = readl_relaxed(ss->base + SPRD_SPI_CTL2); in sprd_spi_dma_enable()
485 writel_relaxed(val, ss->base + SPRD_SPI_CTL2); in sprd_spi_dma_enable()
517 static int sprd_spi_dma_rx_config(struct sprd_spi *ss, struct spi_transfer *t) in sprd_spi_dma_rx_config() argument
519 struct dma_chan *dma_chan = ss->dma.dma_chan[SPRD_SPI_RX]; in sprd_spi_dma_rx_config()
521 .src_addr = ss->phy_base, in sprd_spi_dma_rx_config()
522 .src_addr_width = ss->dma.width, in sprd_spi_dma_rx_config()
523 .dst_addr_width = ss->dma.width, in sprd_spi_dma_rx_config()
524 .dst_maxburst = ss->dma.fragmens_len, in sprd_spi_dma_rx_config()
532 return ss->dma.rx_len; in sprd_spi_dma_rx_config()
535 static int sprd_spi_dma_tx_config(struct sprd_spi *ss, struct spi_transfer *t) in sprd_spi_dma_tx_config() argument
537 struct dma_chan *dma_chan = ss->dma.dma_chan[SPRD_SPI_TX]; in sprd_spi_dma_tx_config()
539 .dst_addr = ss->phy_base, in sprd_spi_dma_tx_config()
540 .src_addr_width = ss->dma.width, in sprd_spi_dma_tx_config()
541 .dst_addr_width = ss->dma.width, in sprd_spi_dma_tx_config()
542 .src_maxburst = ss->dma.fragmens_len, in sprd_spi_dma_tx_config()
553 static int sprd_spi_dma_request(struct sprd_spi *ss) in sprd_spi_dma_request() argument
555 ss->dma.dma_chan[SPRD_SPI_RX] = dma_request_chan(ss->dev, "rx_chn"); in sprd_spi_dma_request()
556 if (IS_ERR_OR_NULL(ss->dma.dma_chan[SPRD_SPI_RX])) in sprd_spi_dma_request()
557 return dev_err_probe(ss->dev, PTR_ERR(ss->dma.dma_chan[SPRD_SPI_RX]), in sprd_spi_dma_request()
560 ss->dma.dma_chan[SPRD_SPI_TX] = dma_request_chan(ss->dev, "tx_chn"); in sprd_spi_dma_request()
561 if (IS_ERR_OR_NULL(ss->dma.dma_chan[SPRD_SPI_TX])) { in sprd_spi_dma_request()
562 dma_release_channel(ss->dma.dma_chan[SPRD_SPI_RX]); in sprd_spi_dma_request()
563 return dev_err_probe(ss->dev, PTR_ERR(ss->dma.dma_chan[SPRD_SPI_TX]), in sprd_spi_dma_request()
570 static void sprd_spi_dma_release(struct sprd_spi *ss) in sprd_spi_dma_release() argument
572 if (ss->dma.dma_chan[SPRD_SPI_RX]) in sprd_spi_dma_release()
573 dma_release_channel(ss->dma.dma_chan[SPRD_SPI_RX]); in sprd_spi_dma_release()
575 if (ss->dma.dma_chan[SPRD_SPI_TX]) in sprd_spi_dma_release()
576 dma_release_channel(ss->dma.dma_chan[SPRD_SPI_TX]); in sprd_spi_dma_release()
582 struct sprd_spi *ss = spi_master_get_devdata(sdev->master); in sprd_spi_dma_txrx_bufs() local
583 u32 trans_len = ss->trans_len; in sprd_spi_dma_txrx_bufs()
586 reinit_completion(&ss->xfer_completion); in sprd_spi_dma_txrx_bufs()
587 sprd_spi_irq_enable(ss); in sprd_spi_dma_txrx_bufs()
588 if (ss->trans_mode & SPRD_SPI_TX_MODE) { in sprd_spi_dma_txrx_bufs()
589 write_size = sprd_spi_dma_tx_config(ss, t); in sprd_spi_dma_txrx_bufs()
590 sprd_spi_set_tx_length(ss, trans_len); in sprd_spi_dma_txrx_bufs()
596 if (ss->hw_mode & SPI_3WIRE || ss->hw_mode & SPI_TX_DUAL) in sprd_spi_dma_txrx_bufs()
597 sprd_spi_tx_req(ss); in sprd_spi_dma_txrx_bufs()
599 sprd_spi_set_rx_length(ss, trans_len); in sprd_spi_dma_txrx_bufs()
605 if (ss->hw_mode & SPI_3WIRE || ss->hw_mode & SPI_TX_DUAL) in sprd_spi_dma_txrx_bufs()
606 sprd_spi_rx_req(ss); in sprd_spi_dma_txrx_bufs()
608 write_size = ss->write_bufs(ss, trans_len); in sprd_spi_dma_txrx_bufs()
613 dev_err(ss->dev, "failed to write, ret = %d\n", ret); in sprd_spi_dma_txrx_bufs()
617 if (ss->trans_mode & SPRD_SPI_RX_MODE) { in sprd_spi_dma_txrx_bufs()
625 ss->dma.rx_len = t->len > ss->dma.fragmens_len ? in sprd_spi_dma_txrx_bufs()
626 (t->len - t->len % ss->dma.fragmens_len) : in sprd_spi_dma_txrx_bufs()
628 ret = sprd_spi_dma_rx_config(ss, t); in sprd_spi_dma_txrx_bufs()
636 sprd_spi_dma_enable(ss, true); in sprd_spi_dma_txrx_bufs()
637 wait_for_completion(&(ss->xfer_completion)); in sprd_spi_dma_txrx_bufs()
639 if (ss->trans_mode & SPRD_SPI_TX_MODE) in sprd_spi_dma_txrx_bufs()
642 ret = ss->dma.rx_len; in sprd_spi_dma_txrx_bufs()
645 sprd_spi_dma_enable(ss, false); in sprd_spi_dma_txrx_bufs()
646 sprd_spi_enter_idle(ss); in sprd_spi_dma_txrx_bufs()
647 sprd_spi_irq_disable(ss); in sprd_spi_dma_txrx_bufs()
652 static void sprd_spi_set_speed(struct sprd_spi *ss, u32 speed_hz) in sprd_spi_set_speed() argument
658 u32 clk_div = DIV_ROUND_UP(ss->src_clk, speed_hz << 1) - 1; in sprd_spi_set_speed()
661 ss->hw_speed_hz = (ss->src_clk >> 1) / (clk_div + 1); in sprd_spi_set_speed()
662 writel_relaxed(clk_div, ss->base + SPRD_SPI_CLKD); in sprd_spi_set_speed()
665 static int sprd_spi_init_hw(struct sprd_spi *ss, struct spi_transfer *t) in sprd_spi_init_hw() argument
674 val = readl_relaxed(ss->base + SPRD_SPI_CTL0); in sprd_spi_init_hw()
677 val |= ss->hw_mode & SPI_CPHA ? SPRD_SPI_NG_RX : SPRD_SPI_NG_TX; in sprd_spi_init_hw()
678 val |= ss->hw_mode & SPI_CPOL ? SPRD_SPI_SCK_REV : 0; in sprd_spi_init_hw()
679 writel_relaxed(val, ss->base + SPRD_SPI_CTL0); in sprd_spi_init_hw()
689 ss->word_delay = interval * 4 + 10; in sprd_spi_init_hw()
690 writel_relaxed(interval, ss->base + SPRD_SPI_CTL5); in sprd_spi_init_hw()
693 writel_relaxed(1, ss->base + SPRD_SPI_FIFO_RST); in sprd_spi_init_hw()
694 writel_relaxed(0, ss->base + SPRD_SPI_FIFO_RST); in sprd_spi_init_hw()
697 val = readl_relaxed(ss->base + SPRD_SPI_CTL7); in sprd_spi_init_hw()
700 if (ss->hw_mode & SPI_3WIRE) in sprd_spi_init_hw()
705 if (ss->hw_mode & SPI_TX_DUAL) in sprd_spi_init_hw()
710 writel_relaxed(val, ss->base + SPRD_SPI_CTL7); in sprd_spi_init_hw()
718 struct sprd_spi *ss = spi_controller_get_devdata(sdev->controller); in sprd_spi_setup_transfer() local
723 ss->len = t->len; in sprd_spi_setup_transfer()
724 ss->tx_buf = t->tx_buf; in sprd_spi_setup_transfer()
725 ss->rx_buf = t->rx_buf; in sprd_spi_setup_transfer()
727 ss->hw_mode = sdev->mode; in sprd_spi_setup_transfer()
728 ret = sprd_spi_init_hw(ss, t); in sprd_spi_setup_transfer()
733 sprd_spi_set_speed(ss, t->speed_hz); in sprd_spi_setup_transfer()
734 sprd_spi_set_transfer_bits(ss, bits_per_word); in sprd_spi_setup_transfer()
743 ss->trans_len = t->len; in sprd_spi_setup_transfer()
744 ss->read_bufs = sprd_spi_read_bufs_u8; in sprd_spi_setup_transfer()
745 ss->write_bufs = sprd_spi_write_bufs_u8; in sprd_spi_setup_transfer()
746 ss->dma.width = DMA_SLAVE_BUSWIDTH_1_BYTE; in sprd_spi_setup_transfer()
747 ss->dma.fragmens_len = SPRD_SPI_DMA_STEP; in sprd_spi_setup_transfer()
750 ss->trans_len = t->len >> 1; in sprd_spi_setup_transfer()
751 ss->read_bufs = sprd_spi_read_bufs_u16; in sprd_spi_setup_transfer()
752 ss->write_bufs = sprd_spi_write_bufs_u16; in sprd_spi_setup_transfer()
753 ss->dma.width = DMA_SLAVE_BUSWIDTH_2_BYTES; in sprd_spi_setup_transfer()
754 ss->dma.fragmens_len = SPRD_SPI_DMA_STEP << 1; in sprd_spi_setup_transfer()
757 ss->trans_len = t->len >> 2; in sprd_spi_setup_transfer()
758 ss->read_bufs = sprd_spi_read_bufs_u32; in sprd_spi_setup_transfer()
759 ss->write_bufs = sprd_spi_write_bufs_u32; in sprd_spi_setup_transfer()
760 ss->dma.width = DMA_SLAVE_BUSWIDTH_4_BYTES; in sprd_spi_setup_transfer()
761 ss->dma.fragmens_len = SPRD_SPI_DMA_STEP << 2; in sprd_spi_setup_transfer()
768 val = readl_relaxed(ss->base + SPRD_SPI_CTL1); in sprd_spi_setup_transfer()
775 writel_relaxed(val | mode, ss->base + SPRD_SPI_CTL1); in sprd_spi_setup_transfer()
777 ss->trans_mode = mode; in sprd_spi_setup_transfer()
783 if (ss->trans_mode == SPRD_SPI_RX_MODE) in sprd_spi_setup_transfer()
784 ss->write_bufs = sprd_spi_write_only_receive; in sprd_spi_setup_transfer()
817 struct sprd_spi *ss = (struct sprd_spi *)data; in sprd_spi_handle_irq() local
818 u32 val = readl_relaxed(ss->base + SPRD_SPI_INT_MASK_STS); in sprd_spi_handle_irq()
821 writel_relaxed(SPRD_SPI_TX_END_CLR, ss->base + SPRD_SPI_INT_CLR); in sprd_spi_handle_irq()
822 if (!(ss->trans_mode & SPRD_SPI_RX_MODE)) in sprd_spi_handle_irq()
823 complete(&ss->xfer_completion); in sprd_spi_handle_irq()
829 writel_relaxed(SPRD_SPI_RX_END_CLR, ss->base + SPRD_SPI_INT_CLR); in sprd_spi_handle_irq()
830 if (ss->dma.rx_len < ss->len) { in sprd_spi_handle_irq()
831 ss->rx_buf += ss->dma.rx_len; in sprd_spi_handle_irq()
832 ss->dma.rx_len += in sprd_spi_handle_irq()
833 ss->read_bufs(ss, ss->len - ss->dma.rx_len); in sprd_spi_handle_irq()
835 complete(&ss->xfer_completion); in sprd_spi_handle_irq()
843 static int sprd_spi_irq_init(struct platform_device *pdev, struct sprd_spi *ss) in sprd_spi_irq_init() argument
847 ss->irq = platform_get_irq(pdev, 0); in sprd_spi_irq_init()
848 if (ss->irq < 0) in sprd_spi_irq_init()
849 return ss->irq; in sprd_spi_irq_init()
851 ret = devm_request_irq(&pdev->dev, ss->irq, sprd_spi_handle_irq, in sprd_spi_irq_init()
852 0, pdev->name, ss); in sprd_spi_irq_init()
855 ss->irq, ret); in sprd_spi_irq_init()
860 static int sprd_spi_clk_init(struct platform_device *pdev, struct sprd_spi *ss) in sprd_spi_clk_init() argument
876 ss->clk = devm_clk_get(&pdev->dev, "enable"); in sprd_spi_clk_init()
877 if (IS_ERR(ss->clk)) { in sprd_spi_clk_init()
879 return PTR_ERR(ss->clk); in sprd_spi_clk_init()
883 ss->src_clk = clk_get_rate(clk_spi); in sprd_spi_clk_init()
885 ss->src_clk = SPRD_SPI_DEFAULT_SOURCE; in sprd_spi_clk_init()
893 struct sprd_spi *ss = spi_controller_get_devdata(sctlr); in sprd_spi_can_dma() local
895 return ss->dma.enable && (t->len > SPRD_SPI_FIFO_SIZE); in sprd_spi_can_dma()
898 static int sprd_spi_dma_init(struct platform_device *pdev, struct sprd_spi *ss) in sprd_spi_dma_init() argument
902 ret = sprd_spi_dma_request(ss); in sprd_spi_dma_init()
914 ss->dma.enable = true; in sprd_spi_dma_init()
923 struct sprd_spi *ss; in sprd_spi_probe() local
927 sctlr = spi_alloc_master(&pdev->dev, sizeof(*ss)); in sprd_spi_probe()
931 ss = spi_controller_get_devdata(sctlr); in sprd_spi_probe()
933 ss->base = devm_ioremap_resource(&pdev->dev, res); in sprd_spi_probe()
934 if (IS_ERR(ss->base)) { in sprd_spi_probe()
935 ret = PTR_ERR(ss->base); in sprd_spi_probe()
939 ss->phy_base = res->start; in sprd_spi_probe()
940 ss->dev = &pdev->dev; in sprd_spi_probe()
948 sctlr->max_speed_hz = min_t(u32, ss->src_clk >> 1, in sprd_spi_probe()
951 init_completion(&ss->xfer_completion); in sprd_spi_probe()
953 ret = sprd_spi_clk_init(pdev, ss); in sprd_spi_probe()
957 ret = sprd_spi_irq_init(pdev, ss); in sprd_spi_probe()
961 ret = sprd_spi_dma_init(pdev, ss); in sprd_spi_probe()
965 ret = clk_prepare_enable(ss->clk); in sprd_spi_probe()
996 clk_disable_unprepare(ss->clk); in sprd_spi_probe()
998 sprd_spi_dma_release(ss); in sprd_spi_probe()
1008 struct sprd_spi *ss = spi_controller_get_devdata(sctlr); in sprd_spi_remove() local
1011 ret = pm_runtime_get_sync(ss->dev); in sprd_spi_remove()
1013 pm_runtime_put_noidle(ss->dev); in sprd_spi_remove()
1014 dev_err(ss->dev, "failed to resume SPI controller\n"); in sprd_spi_remove()
1020 if (ss->dma.enable) in sprd_spi_remove()
1021 sprd_spi_dma_release(ss); in sprd_spi_remove()
1022 clk_disable_unprepare(ss->clk); in sprd_spi_remove()
1032 struct sprd_spi *ss = spi_controller_get_devdata(sctlr); in sprd_spi_runtime_suspend() local
1034 if (ss->dma.enable) in sprd_spi_runtime_suspend()
1035 sprd_spi_dma_release(ss); in sprd_spi_runtime_suspend()
1037 clk_disable_unprepare(ss->clk); in sprd_spi_runtime_suspend()
1045 struct sprd_spi *ss = spi_controller_get_devdata(sctlr); in sprd_spi_runtime_resume() local
1048 ret = clk_prepare_enable(ss->clk); in sprd_spi_runtime_resume()
1052 if (!ss->dma.enable) in sprd_spi_runtime_resume()
1055 ret = sprd_spi_dma_request(ss); in sprd_spi_runtime_resume()
1057 clk_disable_unprepare(ss->clk); in sprd_spi_runtime_resume()