Lines Matching refs:bs
94 static inline u32 bcm2835_rd(struct bcm2835_spi *bs, unsigned reg) in bcm2835_rd() argument
96 return readl(bs->regs + reg); in bcm2835_rd()
99 static inline void bcm2835_wr(struct bcm2835_spi *bs, unsigned reg, u32 val) in bcm2835_wr() argument
101 writel(val, bs->regs + reg); in bcm2835_wr()
104 static inline void bcm2835_rd_fifo(struct bcm2835_spi *bs) in bcm2835_rd_fifo() argument
108 while ((bs->rx_len) && in bcm2835_rd_fifo()
109 (bcm2835_rd(bs, BCM2835_SPI_CS) & BCM2835_SPI_CS_RXD)) { in bcm2835_rd_fifo()
110 byte = bcm2835_rd(bs, BCM2835_SPI_FIFO); in bcm2835_rd_fifo()
111 if (bs->rx_buf) in bcm2835_rd_fifo()
112 *bs->rx_buf++ = byte; in bcm2835_rd_fifo()
113 bs->rx_len--; in bcm2835_rd_fifo()
117 static inline void bcm2835_wr_fifo(struct bcm2835_spi *bs) in bcm2835_wr_fifo() argument
121 while ((bs->tx_len) && in bcm2835_wr_fifo()
122 (bcm2835_rd(bs, BCM2835_SPI_CS) & BCM2835_SPI_CS_TXD)) { in bcm2835_wr_fifo()
123 byte = bs->tx_buf ? *bs->tx_buf++ : 0; in bcm2835_wr_fifo()
124 bcm2835_wr(bs, BCM2835_SPI_FIFO, byte); in bcm2835_wr_fifo()
125 bs->tx_len--; in bcm2835_wr_fifo()
131 struct bcm2835_spi *bs = spi_master_get_devdata(master); in bcm2835_spi_reset_hw() local
132 u32 cs = bcm2835_rd(bs, BCM2835_SPI_CS); in bcm2835_spi_reset_hw()
143 bcm2835_wr(bs, BCM2835_SPI_CS, cs); in bcm2835_spi_reset_hw()
145 bcm2835_wr(bs, BCM2835_SPI_DLEN, 0); in bcm2835_spi_reset_hw()
151 struct bcm2835_spi *bs = spi_master_get_devdata(master); in bcm2835_spi_interrupt() local
154 bcm2835_rd_fifo(bs); in bcm2835_spi_interrupt()
156 bcm2835_wr_fifo(bs); in bcm2835_spi_interrupt()
159 if (bcm2835_rd(bs, BCM2835_SPI_CS) & BCM2835_SPI_CS_DONE) { in bcm2835_spi_interrupt()
174 struct bcm2835_spi *bs = spi_master_get_devdata(master); in bcm2835_spi_transfer_one_irq() local
186 bcm2835_wr(bs, BCM2835_SPI_CS, in bcm2835_spi_transfer_one_irq()
189 bcm2835_wr_fifo(bs); in bcm2835_spi_transfer_one_irq()
199 bcm2835_wr(bs, BCM2835_SPI_CS, cs); in bcm2835_spi_transfer_one_irq()
226 struct bcm2835_spi *bs = spi_master_get_devdata(master); in bcm2835_spi_dma_done() local
239 bs->dma_pending = 0; in bcm2835_spi_dma_done()
308 struct bcm2835_spi *bs = spi_master_get_devdata(master); in bcm2835_spi_transfer_one_dma() local
328 bs->dma_pending = 1; in bcm2835_spi_transfer_one_dma()
331 bcm2835_wr(bs, BCM2835_SPI_DLEN, tfr->len); in bcm2835_spi_transfer_one_dma()
334 bcm2835_wr(bs, BCM2835_SPI_CS, in bcm2835_spi_transfer_one_dma()
485 struct bcm2835_spi *bs = spi_master_get_devdata(master); in bcm2835_spi_transfer_one_poll() local
489 bcm2835_wr(bs, BCM2835_SPI_CS, cs | BCM2835_SPI_CS_TA); in bcm2835_spi_transfer_one_poll()
495 bcm2835_wr_fifo(bs); in bcm2835_spi_transfer_one_poll()
501 while (bs->rx_len) { in bcm2835_spi_transfer_one_poll()
503 bcm2835_wr_fifo(bs); in bcm2835_spi_transfer_one_poll()
506 bcm2835_rd_fifo(bs); in bcm2835_spi_transfer_one_poll()
511 if (bs->rx_len && time_after(jiffies, timeout)) { in bcm2835_spi_transfer_one_poll()
515 bs->tx_len, bs->rx_len); in bcm2835_spi_transfer_one_poll()
532 struct bcm2835_spi *bs = spi_master_get_devdata(master); in bcm2835_spi_transfer_one() local
536 u32 cs = bcm2835_rd(bs, BCM2835_SPI_CS); in bcm2835_spi_transfer_one()
540 clk_hz = clk_get_rate(bs->clk); in bcm2835_spi_transfer_one()
555 bcm2835_wr(bs, BCM2835_SPI_CLK, cdiv); in bcm2835_spi_transfer_one()
571 bs->tx_buf = tfr->tx_buf; in bcm2835_spi_transfer_one()
572 bs->rx_buf = tfr->rx_buf; in bcm2835_spi_transfer_one()
573 bs->tx_len = tfr->len; in bcm2835_spi_transfer_one()
574 bs->rx_len = tfr->len; in bcm2835_spi_transfer_one()
599 struct bcm2835_spi *bs = spi_master_get_devdata(master); in bcm2835_spi_prepare_message() local
600 u32 cs = bcm2835_rd(bs, BCM2835_SPI_CS); in bcm2835_spi_prepare_message()
609 bcm2835_wr(bs, BCM2835_SPI_CS, cs); in bcm2835_spi_prepare_message()
617 struct bcm2835_spi *bs = spi_master_get_devdata(master); in bcm2835_spi_handle_err() local
620 if (bs->dma_pending) { in bcm2835_spi_handle_err()
623 bs->dma_pending = 0; in bcm2835_spi_handle_err()
642 struct bcm2835_spi *bs = spi_master_get_devdata(master); in bcm2835_spi_set_cs() local
643 u32 cs = bcm2835_rd(bs, BCM2835_SPI_CS); in bcm2835_spi_set_cs()
679 bcm2835_wr(bs, BCM2835_SPI_CS, cs); in bcm2835_spi_set_cs()
737 struct bcm2835_spi *bs; in bcm2835_spi_probe() local
741 master = spi_alloc_master(&pdev->dev, sizeof(*bs)); in bcm2835_spi_probe()
759 bs = spi_master_get_devdata(master); in bcm2835_spi_probe()
762 bs->regs = devm_ioremap_resource(&pdev->dev, res); in bcm2835_spi_probe()
763 if (IS_ERR(bs->regs)) { in bcm2835_spi_probe()
764 err = PTR_ERR(bs->regs); in bcm2835_spi_probe()
768 bs->clk = devm_clk_get(&pdev->dev, NULL); in bcm2835_spi_probe()
769 if (IS_ERR(bs->clk)) { in bcm2835_spi_probe()
770 err = PTR_ERR(bs->clk); in bcm2835_spi_probe()
775 bs->irq = platform_get_irq(pdev, 0); in bcm2835_spi_probe()
776 if (bs->irq <= 0) { in bcm2835_spi_probe()
777 dev_err(&pdev->dev, "could not get IRQ: %d\n", bs->irq); in bcm2835_spi_probe()
778 err = bs->irq ? bs->irq : -ENODEV; in bcm2835_spi_probe()
782 clk_prepare_enable(bs->clk); in bcm2835_spi_probe()
787 bcm2835_wr(bs, BCM2835_SPI_CS, in bcm2835_spi_probe()
790 err = devm_request_irq(&pdev->dev, bs->irq, bcm2835_spi_interrupt, 0, in bcm2835_spi_probe()
806 clk_disable_unprepare(bs->clk); in bcm2835_spi_probe()
815 struct bcm2835_spi *bs = spi_master_get_devdata(master); in bcm2835_spi_remove() local
818 bcm2835_wr(bs, BCM2835_SPI_CS, in bcm2835_spi_remove()
821 clk_disable_unprepare(bs->clk); in bcm2835_spi_remove()