Lines Matching full:xspi

125 static void xlp_spi_sysctl_setup(struct xlp_spi_priv *xspi)  in xlp_spi_sysctl_setup()  argument
130 xlp_spi_sysctl_write(xspi, XLP_SPI_SYSCTRL, in xlp_spi_sysctl_setup()
132 xlp_spi_sysctl_write(xspi, XLP_SPI_SYSCTRL, XLP_SPI_SYS_PMEN); in xlp_spi_sysctl_setup()
137 struct xlp_spi_priv *xspi; in xlp_spi_setup() local
141 xspi = spi_controller_get_devdata(spi->controller); in xlp_spi_setup()
146 fdiv = DIV_ROUND_UP(xspi->spi_clk, spi->max_speed_hz); in xlp_spi_setup()
152 xlp_spi_reg_write(xspi, cs, XLP_SPI_FDIV, fdiv); in xlp_spi_setup()
153 xlp_spi_reg_write(xspi, cs, XLP_SPI_FIFO_THRESH, XLP_SPI_TXRXTH); in xlp_spi_setup()
154 cfg = xlp_spi_reg_read(xspi, cs, XLP_SPI_CONFIG); in xlp_spi_setup()
175 xlp_spi_reg_write(xspi, cs, XLP_SPI_CONFIG, cfg); in xlp_spi_setup()
180 static void xlp_spi_read_rxfifo(struct xlp_spi_priv *xspi) in xlp_spi_read_rxfifo() argument
185 rxfifo_cnt = xlp_spi_reg_read(xspi, xspi->cs, XLP_SPI_FIFO_WCNT); in xlp_spi_read_rxfifo()
188 rx_data = xlp_spi_reg_read(xspi, xspi->cs, XLP_SPI_RXDATA_FIFO); in xlp_spi_read_rxfifo()
190 nbytes = min(xspi->rx_len, 4); in xlp_spi_read_rxfifo()
192 xspi->rx_buf[i] = (rx_data >> (j * 8)) & 0xff; in xlp_spi_read_rxfifo()
194 xspi->rx_len -= nbytes; in xlp_spi_read_rxfifo()
195 xspi->rx_buf += nbytes; in xlp_spi_read_rxfifo()
200 static void xlp_spi_fill_txfifo(struct xlp_spi_priv *xspi) in xlp_spi_fill_txfifo() argument
205 txfifo_cnt = xlp_spi_reg_read(xspi, xspi->cs, XLP_SPI_FIFO_WCNT); in xlp_spi_fill_txfifo()
208 while (xspi->tx_len && (txfifo_cnt < XLP_SPI_FIFO_SIZE)) { in xlp_spi_fill_txfifo()
211 nbytes = min(xspi->tx_len, 4); in xlp_spi_fill_txfifo()
213 tx_data |= xspi->tx_buf[i] << (j * 8); in xlp_spi_fill_txfifo()
215 xlp_spi_reg_write(xspi, xspi->cs, XLP_SPI_TXDATA_FIFO, tx_data); in xlp_spi_fill_txfifo()
216 xspi->tx_len -= nbytes; in xlp_spi_fill_txfifo()
217 xspi->tx_buf += nbytes; in xlp_spi_fill_txfifo()
224 struct xlp_spi_priv *xspi = dev_id; in xlp_spi_interrupt() local
227 stat = xlp_spi_reg_read(xspi, xspi->cs, XLP_SPI_STATUS) & in xlp_spi_interrupt()
233 if (xspi->tx_len) in xlp_spi_interrupt()
234 xlp_spi_fill_txfifo(xspi); in xlp_spi_interrupt()
236 xspi->txerrors++; in xlp_spi_interrupt()
240 if (xspi->rx_len) in xlp_spi_interrupt()
241 xlp_spi_read_rxfifo(xspi); in xlp_spi_interrupt()
243 xspi->rxerrors++; in xlp_spi_interrupt()
247 xlp_spi_reg_write(xspi, xspi->cs, XLP_SPI_STATUS, stat); in xlp_spi_interrupt()
249 complete(&xspi->done); in xlp_spi_interrupt()
254 static void xlp_spi_send_cmd(struct xlp_spi_priv *xspi, int xfer_len, in xlp_spi_send_cmd() argument
259 if (xspi->tx_buf) in xlp_spi_send_cmd()
261 if (xspi->rx_buf) in xlp_spi_send_cmd()
266 xlp_spi_reg_write(xspi, xspi->cs, XLP_SPI_CMD, cmd); in xlp_spi_send_cmd()
350 struct xlp_spi_priv *xspi = spi_controller_get_devdata(host); in xlp_spi_transfer_one() local
353 xspi->cs = spi_get_chipselect(spi, 0); in xlp_spi_transfer_one()
354 xspi->dev = spi->dev; in xlp_spi_transfer_one()
357 xspi->cmd_cont = 0; in xlp_spi_transfer_one()
359 xspi->cmd_cont = 1; in xlp_spi_transfer_one()
361 if (xlp_spi_txrx_bufs(xspi, t)) in xlp_spi_transfer_one()
371 struct xlp_spi_priv *xspi; in xlp_spi_probe() local
375 xspi = devm_kzalloc(&pdev->dev, sizeof(*xspi), GFP_KERNEL); in xlp_spi_probe()
376 if (!xspi) in xlp_spi_probe()
379 xspi->base = devm_platform_ioremap_resource(pdev, 0); in xlp_spi_probe()
380 if (IS_ERR(xspi->base)) in xlp_spi_probe()
381 return PTR_ERR(xspi->base); in xlp_spi_probe()
387 pdev->name, xspi); in xlp_spi_probe()
399 xspi->spi_clk = clk_get_rate(clk); in xlp_spi_probe()
414 init_completion(&xspi->done); in xlp_spi_probe()
415 spi_controller_set_devdata(host, xspi); in xlp_spi_probe()
416 xlp_spi_sysctl_setup(xspi); in xlp_spi_probe()