spi_engine        130 drivers/spi/spi-axi-spi-engine.c static unsigned int spi_engine_get_clk_div(struct spi_engine *spi_engine,
spi_engine        135 drivers/spi/spi-axi-spi-engine.c 	clk_div = DIV_ROUND_UP(clk_get_rate(spi_engine->ref_clk),
spi_engine        166 drivers/spi/spi-axi-spi-engine.c 	struct spi_engine *spi_engine, unsigned int clk_div, unsigned int delay)
spi_engine        168 drivers/spi/spi-axi-spi-engine.c 	unsigned int spi_clk = clk_get_rate(spi_engine->ref_clk);
spi_engine        194 drivers/spi/spi-axi-spi-engine.c static int spi_engine_compile_message(struct spi_engine *spi_engine,
spi_engine        209 drivers/spi/spi-axi-spi-engine.c 		new_clk_div = spi_engine_get_clk_div(spi_engine, spi, xfer);
spi_engine        221 drivers/spi/spi-axi-spi-engine.c 		spi_engine_gen_sleep(p, dry, spi_engine, clk_div,
spi_engine        235 drivers/spi/spi-axi-spi-engine.c static void spi_engine_xfer_next(struct spi_engine *spi_engine,
spi_engine        238 drivers/spi/spi-axi-spi-engine.c 	struct spi_message *msg = spi_engine->msg;
spi_engine        253 drivers/spi/spi-axi-spi-engine.c static void spi_engine_tx_next(struct spi_engine *spi_engine)
spi_engine        255 drivers/spi/spi-axi-spi-engine.c 	struct spi_transfer *xfer = spi_engine->tx_xfer;
spi_engine        258 drivers/spi/spi-axi-spi-engine.c 		spi_engine_xfer_next(spi_engine, &xfer);
spi_engine        261 drivers/spi/spi-axi-spi-engine.c 	spi_engine->tx_xfer = xfer;
spi_engine        263 drivers/spi/spi-axi-spi-engine.c 		spi_engine->tx_length = xfer->len;
spi_engine        264 drivers/spi/spi-axi-spi-engine.c 		spi_engine->tx_buf = xfer->tx_buf;
spi_engine        266 drivers/spi/spi-axi-spi-engine.c 		spi_engine->tx_buf = NULL;
spi_engine        270 drivers/spi/spi-axi-spi-engine.c static void spi_engine_rx_next(struct spi_engine *spi_engine)
spi_engine        272 drivers/spi/spi-axi-spi-engine.c 	struct spi_transfer *xfer = spi_engine->rx_xfer;
spi_engine        275 drivers/spi/spi-axi-spi-engine.c 		spi_engine_xfer_next(spi_engine, &xfer);
spi_engine        278 drivers/spi/spi-axi-spi-engine.c 	spi_engine->rx_xfer = xfer;
spi_engine        280 drivers/spi/spi-axi-spi-engine.c 		spi_engine->rx_length = xfer->len;
spi_engine        281 drivers/spi/spi-axi-spi-engine.c 		spi_engine->rx_buf = xfer->rx_buf;
spi_engine        283 drivers/spi/spi-axi-spi-engine.c 		spi_engine->rx_buf = NULL;
spi_engine        287 drivers/spi/spi-axi-spi-engine.c static bool spi_engine_write_cmd_fifo(struct spi_engine *spi_engine)
spi_engine        289 drivers/spi/spi-axi-spi-engine.c 	void __iomem *addr = spi_engine->base + SPI_ENGINE_REG_CMD_FIFO;
spi_engine        293 drivers/spi/spi-axi-spi-engine.c 	n = readl_relaxed(spi_engine->base + SPI_ENGINE_REG_CMD_FIFO_ROOM);
spi_engine        294 drivers/spi/spi-axi-spi-engine.c 	while (n && spi_engine->cmd_length) {
spi_engine        295 drivers/spi/spi-axi-spi-engine.c 		m = min(n, spi_engine->cmd_length);
spi_engine        296 drivers/spi/spi-axi-spi-engine.c 		buf = spi_engine->cmd_buf;
spi_engine        299 drivers/spi/spi-axi-spi-engine.c 		spi_engine->cmd_buf += m;
spi_engine        300 drivers/spi/spi-axi-spi-engine.c 		spi_engine->cmd_length -= m;
spi_engine        304 drivers/spi/spi-axi-spi-engine.c 	return spi_engine->cmd_length != 0;
spi_engine        307 drivers/spi/spi-axi-spi-engine.c static bool spi_engine_write_tx_fifo(struct spi_engine *spi_engine)
spi_engine        309 drivers/spi/spi-axi-spi-engine.c 	void __iomem *addr = spi_engine->base + SPI_ENGINE_REG_SDO_DATA_FIFO;
spi_engine        313 drivers/spi/spi-axi-spi-engine.c 	n = readl_relaxed(spi_engine->base + SPI_ENGINE_REG_SDO_FIFO_ROOM);
spi_engine        314 drivers/spi/spi-axi-spi-engine.c 	while (n && spi_engine->tx_length) {
spi_engine        315 drivers/spi/spi-axi-spi-engine.c 		m = min(n, spi_engine->tx_length);
spi_engine        316 drivers/spi/spi-axi-spi-engine.c 		buf = spi_engine->tx_buf;
spi_engine        319 drivers/spi/spi-axi-spi-engine.c 		spi_engine->tx_buf += m;
spi_engine        320 drivers/spi/spi-axi-spi-engine.c 		spi_engine->tx_length -= m;
spi_engine        322 drivers/spi/spi-axi-spi-engine.c 		if (spi_engine->tx_length == 0)
spi_engine        323 drivers/spi/spi-axi-spi-engine.c 			spi_engine_tx_next(spi_engine);
spi_engine        326 drivers/spi/spi-axi-spi-engine.c 	return spi_engine->tx_length != 0;
spi_engine        329 drivers/spi/spi-axi-spi-engine.c static bool spi_engine_read_rx_fifo(struct spi_engine *spi_engine)
spi_engine        331 drivers/spi/spi-axi-spi-engine.c 	void __iomem *addr = spi_engine->base + SPI_ENGINE_REG_SDI_DATA_FIFO;
spi_engine        335 drivers/spi/spi-axi-spi-engine.c 	n = readl_relaxed(spi_engine->base + SPI_ENGINE_REG_SDI_FIFO_LEVEL);
spi_engine        336 drivers/spi/spi-axi-spi-engine.c 	while (n && spi_engine->rx_length) {
spi_engine        337 drivers/spi/spi-axi-spi-engine.c 		m = min(n, spi_engine->rx_length);
spi_engine        338 drivers/spi/spi-axi-spi-engine.c 		buf = spi_engine->rx_buf;
spi_engine        341 drivers/spi/spi-axi-spi-engine.c 		spi_engine->rx_buf += m;
spi_engine        342 drivers/spi/spi-axi-spi-engine.c 		spi_engine->rx_length -= m;
spi_engine        344 drivers/spi/spi-axi-spi-engine.c 		if (spi_engine->rx_length == 0)
spi_engine        345 drivers/spi/spi-axi-spi-engine.c 			spi_engine_rx_next(spi_engine);
spi_engine        348 drivers/spi/spi-axi-spi-engine.c 	return spi_engine->rx_length != 0;
spi_engine        354 drivers/spi/spi-axi-spi-engine.c 	struct spi_engine *spi_engine = spi_master_get_devdata(master);
spi_engine        358 drivers/spi/spi-axi-spi-engine.c 	pending = readl_relaxed(spi_engine->base + SPI_ENGINE_REG_INT_PENDING);
spi_engine        362 drivers/spi/spi-axi-spi-engine.c 			spi_engine->base + SPI_ENGINE_REG_INT_PENDING);
spi_engine        363 drivers/spi/spi-axi-spi-engine.c 		spi_engine->completed_id = readl_relaxed(
spi_engine        364 drivers/spi/spi-axi-spi-engine.c 			spi_engine->base + SPI_ENGINE_REG_SYNC_ID);
spi_engine        367 drivers/spi/spi-axi-spi-engine.c 	spin_lock(&spi_engine->lock);
spi_engine        370 drivers/spi/spi-axi-spi-engine.c 		if (!spi_engine_write_cmd_fifo(spi_engine))
spi_engine        375 drivers/spi/spi-axi-spi-engine.c 		if (!spi_engine_write_tx_fifo(spi_engine))
spi_engine        380 drivers/spi/spi-axi-spi-engine.c 		if (!spi_engine_read_rx_fifo(spi_engine))
spi_engine        385 drivers/spi/spi-axi-spi-engine.c 		if (spi_engine->msg &&
spi_engine        386 drivers/spi/spi-axi-spi-engine.c 		    spi_engine->completed_id == spi_engine->sync_id) {
spi_engine        387 drivers/spi/spi-axi-spi-engine.c 			struct spi_message *msg = spi_engine->msg;
spi_engine        389 drivers/spi/spi-axi-spi-engine.c 			kfree(spi_engine->p);
spi_engine        392 drivers/spi/spi-axi-spi-engine.c 			spi_engine->msg = NULL;
spi_engine        399 drivers/spi/spi-axi-spi-engine.c 		spi_engine->int_enable &= ~disable_int;
spi_engine        400 drivers/spi/spi-axi-spi-engine.c 		writel_relaxed(spi_engine->int_enable,
spi_engine        401 drivers/spi/spi-axi-spi-engine.c 			spi_engine->base + SPI_ENGINE_REG_INT_ENABLE);
spi_engine        404 drivers/spi/spi-axi-spi-engine.c 	spin_unlock(&spi_engine->lock);
spi_engine        413 drivers/spi/spi-axi-spi-engine.c 	struct spi_engine *spi_engine = spi_master_get_devdata(master);
spi_engine        419 drivers/spi/spi-axi-spi-engine.c 	spi_engine_compile_message(spi_engine, msg, true, &p_dry);
spi_engine        425 drivers/spi/spi-axi-spi-engine.c 	spi_engine_compile_message(spi_engine, msg, false, p);
spi_engine        427 drivers/spi/spi-axi-spi-engine.c 	spin_lock_irqsave(&spi_engine->lock, flags);
spi_engine        428 drivers/spi/spi-axi-spi-engine.c 	spi_engine->sync_id = (spi_engine->sync_id + 1) & 0xff;
spi_engine        430 drivers/spi/spi-axi-spi-engine.c 		SPI_ENGINE_CMD_SYNC(spi_engine->sync_id));
spi_engine        432 drivers/spi/spi-axi-spi-engine.c 	spi_engine->msg = msg;
spi_engine        433 drivers/spi/spi-axi-spi-engine.c 	spi_engine->p = p;
spi_engine        435 drivers/spi/spi-axi-spi-engine.c 	spi_engine->cmd_buf = p->instructions;
spi_engine        436 drivers/spi/spi-axi-spi-engine.c 	spi_engine->cmd_length = p->length;
spi_engine        437 drivers/spi/spi-axi-spi-engine.c 	if (spi_engine_write_cmd_fifo(spi_engine))
spi_engine        440 drivers/spi/spi-axi-spi-engine.c 	spi_engine_tx_next(spi_engine);
spi_engine        441 drivers/spi/spi-axi-spi-engine.c 	if (spi_engine_write_tx_fifo(spi_engine))
spi_engine        444 drivers/spi/spi-axi-spi-engine.c 	spi_engine_rx_next(spi_engine);
spi_engine        445 drivers/spi/spi-axi-spi-engine.c 	if (spi_engine->rx_length != 0)
spi_engine        451 drivers/spi/spi-axi-spi-engine.c 		spi_engine->base + SPI_ENGINE_REG_INT_ENABLE);
spi_engine        452 drivers/spi/spi-axi-spi-engine.c 	spi_engine->int_enable = int_enable;
spi_engine        453 drivers/spi/spi-axi-spi-engine.c 	spin_unlock_irqrestore(&spi_engine->lock, flags);
spi_engine        460 drivers/spi/spi-axi-spi-engine.c 	struct spi_engine *spi_engine;
spi_engine        470 drivers/spi/spi-axi-spi-engine.c 	spi_engine = devm_kzalloc(&pdev->dev, sizeof(*spi_engine), GFP_KERNEL);
spi_engine        471 drivers/spi/spi-axi-spi-engine.c 	if (!spi_engine)
spi_engine        478 drivers/spi/spi-axi-spi-engine.c 	spi_master_set_devdata(master, spi_engine);
spi_engine        480 drivers/spi/spi-axi-spi-engine.c 	spin_lock_init(&spi_engine->lock);
spi_engine        482 drivers/spi/spi-axi-spi-engine.c 	spi_engine->base = devm_platform_ioremap_resource(pdev, 0);
spi_engine        483 drivers/spi/spi-axi-spi-engine.c 	if (IS_ERR(spi_engine->base)) {
spi_engine        484 drivers/spi/spi-axi-spi-engine.c 		ret = PTR_ERR(spi_engine->base);
spi_engine        488 drivers/spi/spi-axi-spi-engine.c 	version = readl(spi_engine->base + SPI_ENGINE_REG_VERSION);
spi_engine        498 drivers/spi/spi-axi-spi-engine.c 	spi_engine->clk = devm_clk_get(&pdev->dev, "s_axi_aclk");
spi_engine        499 drivers/spi/spi-axi-spi-engine.c 	if (IS_ERR(spi_engine->clk)) {
spi_engine        500 drivers/spi/spi-axi-spi-engine.c 		ret = PTR_ERR(spi_engine->clk);
spi_engine        504 drivers/spi/spi-axi-spi-engine.c 	spi_engine->ref_clk = devm_clk_get(&pdev->dev, "spi_clk");
spi_engine        505 drivers/spi/spi-axi-spi-engine.c 	if (IS_ERR(spi_engine->ref_clk)) {
spi_engine        506 drivers/spi/spi-axi-spi-engine.c 		ret = PTR_ERR(spi_engine->ref_clk);
spi_engine        510 drivers/spi/spi-axi-spi-engine.c 	ret = clk_prepare_enable(spi_engine->clk);
spi_engine        514 drivers/spi/spi-axi-spi-engine.c 	ret = clk_prepare_enable(spi_engine->ref_clk);
spi_engine        518 drivers/spi/spi-axi-spi-engine.c 	writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_RESET);
spi_engine        519 drivers/spi/spi-axi-spi-engine.c 	writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING);
spi_engine        520 drivers/spi/spi-axi-spi-engine.c 	writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE);
spi_engine        529 drivers/spi/spi-axi-spi-engine.c 	master->max_speed_hz = clk_get_rate(spi_engine->ref_clk) / 2;
spi_engine        543 drivers/spi/spi-axi-spi-engine.c 	clk_disable_unprepare(spi_engine->ref_clk);
spi_engine        545 drivers/spi/spi-axi-spi-engine.c 	clk_disable_unprepare(spi_engine->clk);
spi_engine        554 drivers/spi/spi-axi-spi-engine.c 	struct spi_engine *spi_engine = spi_master_get_devdata(master);
spi_engine        563 drivers/spi/spi-axi-spi-engine.c 	writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING);
spi_engine        564 drivers/spi/spi-axi-spi-engine.c 	writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE);
spi_engine        565 drivers/spi/spi-axi-spi-engine.c 	writel_relaxed(0x01, spi_engine->base + SPI_ENGINE_REG_RESET);
spi_engine        567 drivers/spi/spi-axi-spi-engine.c 	clk_disable_unprepare(spi_engine->ref_clk);
spi_engine        568 drivers/spi/spi-axi-spi-engine.c 	clk_disable_unprepare(spi_engine->clk);