Lines Matching refs:spi_st
53 struct spi_st { struct
69 static void ssc_write_tx_fifo(struct spi_st *spi_st) in ssc_write_tx_fifo() argument
74 if (spi_st->words_remaining > FIFO_SIZE) in ssc_write_tx_fifo()
77 count = spi_st->words_remaining; in ssc_write_tx_fifo()
80 if (spi_st->tx_ptr) { in ssc_write_tx_fifo()
81 if (spi_st->bytes_per_word == 1) { in ssc_write_tx_fifo()
82 word = *spi_st->tx_ptr++; in ssc_write_tx_fifo()
84 word = *spi_st->tx_ptr++; in ssc_write_tx_fifo()
85 word = *spi_st->tx_ptr++ | (word << 8); in ssc_write_tx_fifo()
88 writel_relaxed(word, spi_st->base + SSC_TBUF); in ssc_write_tx_fifo()
93 static void ssc_read_rx_fifo(struct spi_st *spi_st) in ssc_read_rx_fifo() argument
98 if (spi_st->words_remaining > FIFO_SIZE) in ssc_read_rx_fifo()
101 count = spi_st->words_remaining; in ssc_read_rx_fifo()
104 word = readl_relaxed(spi_st->base + SSC_RBUF); in ssc_read_rx_fifo()
106 if (spi_st->rx_ptr) { in ssc_read_rx_fifo()
107 if (spi_st->bytes_per_word == 1) { in ssc_read_rx_fifo()
108 *spi_st->rx_ptr++ = (uint8_t)word; in ssc_read_rx_fifo()
110 *spi_st->rx_ptr++ = (word >> 8); in ssc_read_rx_fifo()
111 *spi_st->rx_ptr++ = word & 0xff; in ssc_read_rx_fifo()
115 spi_st->words_remaining -= count; in ssc_read_rx_fifo()
121 struct spi_st *spi_st = spi_master_get_devdata(master); in spi_st_transfer_one() local
125 spi_st->tx_ptr = t->tx_buf; in spi_st_transfer_one()
126 spi_st->rx_ptr = t->rx_buf; in spi_st_transfer_one()
133 spi_st->bytes_per_word = 2; in spi_st_transfer_one()
134 spi_st->words_remaining = t->len / 2; in spi_st_transfer_one()
141 spi_st->bytes_per_word = 2; in spi_st_transfer_one()
142 spi_st->words_remaining = t->len / 2; in spi_st_transfer_one()
145 ctl = readl_relaxed(spi_st->base + SSC_CTL); in spi_st_transfer_one()
146 writel_relaxed((ctl | 0xf), spi_st->base + SSC_CTL); in spi_st_transfer_one()
148 readl_relaxed(spi_st->base + SSC_RBUF); in spi_st_transfer_one()
151 spi_st->bytes_per_word = 1; in spi_st_transfer_one()
152 spi_st->words_remaining = t->len; in spi_st_transfer_one()
155 reinit_completion(&spi_st->done); in spi_st_transfer_one()
158 ssc_write_tx_fifo(spi_st); in spi_st_transfer_one()
159 writel_relaxed(SSC_IEN_TEEN, spi_st->base + SSC_IEN); in spi_st_transfer_one()
162 wait_for_completion(&spi_st->done); in spi_st_transfer_one()
166 writel_relaxed(ctl, spi_st->base + SSC_CTL); in spi_st_transfer_one()
177 struct spi_st *spi_st = spi_master_get_devdata(spi->master); in spi_st_setup() local
191 spi_st_clk = clk_get_rate(spi_st->clk); in spi_st_setup()
201 spi_st->baud = spi_st_clk / (2 * sscbrg); in spi_st_setup()
205 writel_relaxed(sscbrg, spi_st->base + SSC_BRG); in spi_st_setup()
209 hz, spi_st->baud, sscbrg); in spi_st_setup()
212 var = readl_relaxed(spi_st->base + SSC_CTL); in spi_st_setup()
241 writel_relaxed(var, spi_st->base + SSC_CTL); in spi_st_setup()
244 readl_relaxed(spi_st->base + SSC_RBUF); in spi_st_setup()
252 struct spi_st *spi_st = (struct spi_st *)dev_id; in spi_st_irq() local
255 ssc_read_rx_fifo(spi_st); in spi_st_irq()
258 if (spi_st->words_remaining) { in spi_st_irq()
259 ssc_write_tx_fifo(spi_st); in spi_st_irq()
262 writel_relaxed(0x0, spi_st->base + SSC_IEN); in spi_st_irq()
267 readl(spi_st->base + SSC_IEN); in spi_st_irq()
268 complete(&spi_st->done); in spi_st_irq()
278 struct spi_st *spi_st; in spi_st_probe() local
282 master = spi_alloc_master(&pdev->dev, sizeof(*spi_st)); in spi_st_probe()
294 spi_st = spi_master_get_devdata(master); in spi_st_probe()
296 spi_st->clk = devm_clk_get(&pdev->dev, "ssc"); in spi_st_probe()
297 if (IS_ERR(spi_st->clk)) { in spi_st_probe()
299 ret = PTR_ERR(spi_st->clk); in spi_st_probe()
303 ret = clk_prepare_enable(spi_st->clk); in spi_st_probe()
307 init_completion(&spi_st->done); in spi_st_probe()
310 spi_st->base = devm_platform_ioremap_resource(pdev, 0); in spi_st_probe()
311 if (IS_ERR(spi_st->base)) { in spi_st_probe()
312 ret = PTR_ERR(spi_st->base); in spi_st_probe()
317 writel_relaxed(0x0, spi_st->base + SSC_I2C); in spi_st_probe()
318 var = readw_relaxed(spi_st->base + SSC_CTL); in spi_st_probe()
320 writel_relaxed(var, spi_st->base + SSC_CTL); in spi_st_probe()
323 var = readl_relaxed(spi_st->base + SSC_CTL); in spi_st_probe()
325 writel_relaxed(var, spi_st->base + SSC_CTL); in spi_st_probe()
328 var = readl_relaxed(spi_st->base + SSC_CTL); in spi_st_probe()
330 writel_relaxed(var, spi_st->base + SSC_CTL); in spi_st_probe()
340 pdev->name, spi_st); in spi_st_probe()
363 clk_disable_unprepare(spi_st->clk); in spi_st_probe()
372 struct spi_st *spi_st = spi_master_get_devdata(master); in spi_st_remove() local
376 clk_disable_unprepare(spi_st->clk); in spi_st_remove()
385 struct spi_st *spi_st = spi_master_get_devdata(master); in spi_st_runtime_suspend() local
387 writel_relaxed(0, spi_st->base + SSC_IEN); in spi_st_runtime_suspend()
390 clk_disable_unprepare(spi_st->clk); in spi_st_runtime_suspend()
398 struct spi_st *spi_st = spi_master_get_devdata(master); in spi_st_runtime_resume() local
401 ret = clk_prepare_enable(spi_st->clk); in spi_st_runtime_resume()