xqspi             150 drivers/spi/spi-zynq-qspi.c static inline u32 zynq_qspi_read(struct zynq_qspi *xqspi, u32 offset)
xqspi             152 drivers/spi/spi-zynq-qspi.c 	return readl_relaxed(xqspi->regs + offset);
xqspi             155 drivers/spi/spi-zynq-qspi.c static inline void zynq_qspi_write(struct zynq_qspi *xqspi, u32 offset,
xqspi             158 drivers/spi/spi-zynq-qspi.c 	writel_relaxed(val, xqspi->regs + offset);
xqspi             181 drivers/spi/spi-zynq-qspi.c static void zynq_qspi_init_hw(struct zynq_qspi *xqspi)
xqspi             185 drivers/spi/spi-zynq-qspi.c 	zynq_qspi_write(xqspi, ZYNQ_QSPI_ENABLE_OFFSET, 0);
xqspi             186 drivers/spi/spi-zynq-qspi.c 	zynq_qspi_write(xqspi, ZYNQ_QSPI_IDIS_OFFSET, ZYNQ_QSPI_IXR_ALL_MASK);
xqspi             189 drivers/spi/spi-zynq-qspi.c 	zynq_qspi_write(xqspi, ZYNQ_QSPI_LINEAR_CFG_OFFSET, 0);
xqspi             192 drivers/spi/spi-zynq-qspi.c 	while (zynq_qspi_read(xqspi, ZYNQ_QSPI_STATUS_OFFSET) &
xqspi             194 drivers/spi/spi-zynq-qspi.c 		zynq_qspi_read(xqspi, ZYNQ_QSPI_RXD_OFFSET);
xqspi             196 drivers/spi/spi-zynq-qspi.c 	zynq_qspi_write(xqspi, ZYNQ_QSPI_STATUS_OFFSET, ZYNQ_QSPI_IXR_ALL_MASK);
xqspi             197 drivers/spi/spi-zynq-qspi.c 	config_reg = zynq_qspi_read(xqspi, ZYNQ_QSPI_CONFIG_OFFSET);
xqspi             209 drivers/spi/spi-zynq-qspi.c 	zynq_qspi_write(xqspi, ZYNQ_QSPI_CONFIG_OFFSET, config_reg);
xqspi             211 drivers/spi/spi-zynq-qspi.c 	zynq_qspi_write(xqspi, ZYNQ_QSPI_RX_THRESH_OFFSET,
xqspi             213 drivers/spi/spi-zynq-qspi.c 	zynq_qspi_write(xqspi, ZYNQ_QSPI_TX_THRESH_OFFSET,
xqspi             216 drivers/spi/spi-zynq-qspi.c 	zynq_qspi_write(xqspi, ZYNQ_QSPI_ENABLE_OFFSET,
xqspi             240 drivers/spi/spi-zynq-qspi.c static void zynq_qspi_rxfifo_op(struct zynq_qspi *xqspi, unsigned int size)
xqspi             244 drivers/spi/spi-zynq-qspi.c 	data = zynq_qspi_read(xqspi, ZYNQ_QSPI_RXD_OFFSET);
xqspi             246 drivers/spi/spi-zynq-qspi.c 	if (xqspi->rxbuf) {
xqspi             247 drivers/spi/spi-zynq-qspi.c 		memcpy(xqspi->rxbuf, ((u8 *)&data) + 4 - size, size);
xqspi             248 drivers/spi/spi-zynq-qspi.c 		xqspi->rxbuf += size;
xqspi             251 drivers/spi/spi-zynq-qspi.c 	xqspi->rx_bytes -= size;
xqspi             252 drivers/spi/spi-zynq-qspi.c 	if (xqspi->rx_bytes < 0)
xqspi             253 drivers/spi/spi-zynq-qspi.c 		xqspi->rx_bytes = 0;
xqspi             261 drivers/spi/spi-zynq-qspi.c static void zynq_qspi_txfifo_op(struct zynq_qspi *xqspi, unsigned int size)
xqspi             268 drivers/spi/spi-zynq-qspi.c 	if (xqspi->txbuf) {
xqspi             270 drivers/spi/spi-zynq-qspi.c 		memcpy(&data, xqspi->txbuf, size);
xqspi             271 drivers/spi/spi-zynq-qspi.c 		xqspi->txbuf += size;
xqspi             276 drivers/spi/spi-zynq-qspi.c 	xqspi->tx_bytes -= size;
xqspi             277 drivers/spi/spi-zynq-qspi.c 	zynq_qspi_write(xqspi, offset[size - 1], data);
xqspi             288 drivers/spi/spi-zynq-qspi.c 	struct zynq_qspi *xqspi = spi_controller_get_devdata(ctrl);
xqspi             291 drivers/spi/spi-zynq-qspi.c 	config_reg = zynq_qspi_read(xqspi, ZYNQ_QSPI_CONFIG_OFFSET);
xqspi             302 drivers/spi/spi-zynq-qspi.c 	zynq_qspi_write(xqspi, ZYNQ_QSPI_CONFIG_OFFSET, config_reg);
xqspi             322 drivers/spi/spi-zynq-qspi.c static int zynq_qspi_config_op(struct zynq_qspi *xqspi, struct spi_device *spi)
xqspi             336 drivers/spi/spi-zynq-qspi.c 	       (clk_get_rate(xqspi->refclk) / (2 << baud_rate_val)) >
xqspi             340 drivers/spi/spi-zynq-qspi.c 	config_reg = zynq_qspi_read(xqspi, ZYNQ_QSPI_CONFIG_OFFSET);
xqspi             352 drivers/spi/spi-zynq-qspi.c 	zynq_qspi_write(xqspi, ZYNQ_QSPI_CONFIG_OFFSET, config_reg);
xqspi             388 drivers/spi/spi-zynq-qspi.c static void zynq_qspi_write_op(struct zynq_qspi *xqspi, int txcount,
xqspi             393 drivers/spi/spi-zynq-qspi.c 	len = xqspi->tx_bytes;
xqspi             400 drivers/spi/spi-zynq-qspi.c 			zynq_qspi_txfifo_op(xqspi, len);
xqspi             409 drivers/spi/spi-zynq-qspi.c 	if (xqspi->txbuf) {
xqspi             410 drivers/spi/spi-zynq-qspi.c 		iowrite32_rep(xqspi->regs + ZYNQ_QSPI_TXD_00_00_OFFSET,
xqspi             411 drivers/spi/spi-zynq-qspi.c 			      xqspi->txbuf, count);
xqspi             412 drivers/spi/spi-zynq-qspi.c 		xqspi->txbuf += count * 4;
xqspi             415 drivers/spi/spi-zynq-qspi.c 			writel_relaxed(0, xqspi->regs +
xqspi             419 drivers/spi/spi-zynq-qspi.c 	xqspi->tx_bytes -= count * 4;
xqspi             427 drivers/spi/spi-zynq-qspi.c static void zynq_qspi_read_op(struct zynq_qspi *xqspi, int rxcount)
xqspi             431 drivers/spi/spi-zynq-qspi.c 	len = xqspi->rx_bytes - xqspi->tx_bytes;
xqspi             435 drivers/spi/spi-zynq-qspi.c 	if (xqspi->rxbuf) {
xqspi             436 drivers/spi/spi-zynq-qspi.c 		ioread32_rep(xqspi->regs + ZYNQ_QSPI_RXD_OFFSET,
xqspi             437 drivers/spi/spi-zynq-qspi.c 			     xqspi->rxbuf, count);
xqspi             438 drivers/spi/spi-zynq-qspi.c 		xqspi->rxbuf += count * 4;
xqspi             441 drivers/spi/spi-zynq-qspi.c 			readl_relaxed(xqspi->regs + ZYNQ_QSPI_RXD_OFFSET);
xqspi             443 drivers/spi/spi-zynq-qspi.c 	xqspi->rx_bytes -= count * 4;
xqspi             447 drivers/spi/spi-zynq-qspi.c 		zynq_qspi_rxfifo_op(xqspi, len);
xqspi             465 drivers/spi/spi-zynq-qspi.c 	struct zynq_qspi *xqspi = (struct zynq_qspi *)dev_id;
xqspi             467 drivers/spi/spi-zynq-qspi.c 	intr_status = zynq_qspi_read(xqspi, ZYNQ_QSPI_STATUS_OFFSET);
xqspi             468 drivers/spi/spi-zynq-qspi.c 	zynq_qspi_write(xqspi, ZYNQ_QSPI_STATUS_OFFSET, intr_status);
xqspi             479 drivers/spi/spi-zynq-qspi.c 		zynq_qspi_read_op(xqspi, ZYNQ_QSPI_RX_THRESHOLD);
xqspi             480 drivers/spi/spi-zynq-qspi.c 		if (xqspi->tx_bytes) {
xqspi             482 drivers/spi/spi-zynq-qspi.c 			zynq_qspi_write_op(xqspi, ZYNQ_QSPI_RX_THRESHOLD,
xqspi             489 drivers/spi/spi-zynq-qspi.c 			if (!xqspi->rx_bytes) {
xqspi             490 drivers/spi/spi-zynq-qspi.c 				zynq_qspi_write(xqspi,
xqspi             493 drivers/spi/spi-zynq-qspi.c 				complete(&xqspi->data_completion);
xqspi             516 drivers/spi/spi-zynq-qspi.c 	struct zynq_qspi *xqspi = spi_controller_get_devdata(mem->spi->master);
xqspi             520 drivers/spi/spi-zynq-qspi.c 	dev_dbg(xqspi->dev, "cmd:%#x mode:%d.%d.%d.%d\n",
xqspi             525 drivers/spi/spi-zynq-qspi.c 	zynq_qspi_config_op(xqspi, mem->spi);
xqspi             528 drivers/spi/spi-zynq-qspi.c 		reinit_completion(&xqspi->data_completion);
xqspi             529 drivers/spi/spi-zynq-qspi.c 		xqspi->txbuf = (u8 *)&op->cmd.opcode;
xqspi             530 drivers/spi/spi-zynq-qspi.c 		xqspi->rxbuf = NULL;
xqspi             531 drivers/spi/spi-zynq-qspi.c 		xqspi->tx_bytes = sizeof(op->cmd.opcode);
xqspi             532 drivers/spi/spi-zynq-qspi.c 		xqspi->rx_bytes = sizeof(op->cmd.opcode);
xqspi             533 drivers/spi/spi-zynq-qspi.c 		zynq_qspi_write_op(xqspi, ZYNQ_QSPI_FIFO_DEPTH, true);
xqspi             534 drivers/spi/spi-zynq-qspi.c 		zynq_qspi_write(xqspi, ZYNQ_QSPI_IEN_OFFSET,
xqspi             536 drivers/spi/spi-zynq-qspi.c 		if (!wait_for_completion_interruptible_timeout(&xqspi->data_completion,
xqspi             543 drivers/spi/spi-zynq-qspi.c 			xqspi->txbuf[i] = op->addr.val >>
xqspi             547 drivers/spi/spi-zynq-qspi.c 		reinit_completion(&xqspi->data_completion);
xqspi             548 drivers/spi/spi-zynq-qspi.c 		xqspi->rxbuf = NULL;
xqspi             549 drivers/spi/spi-zynq-qspi.c 		xqspi->tx_bytes = op->addr.nbytes;
xqspi             550 drivers/spi/spi-zynq-qspi.c 		xqspi->rx_bytes = op->addr.nbytes;
xqspi             551 drivers/spi/spi-zynq-qspi.c 		zynq_qspi_write_op(xqspi, ZYNQ_QSPI_FIFO_DEPTH, true);
xqspi             552 drivers/spi/spi-zynq-qspi.c 		zynq_qspi_write(xqspi, ZYNQ_QSPI_IEN_OFFSET,
xqspi             554 drivers/spi/spi-zynq-qspi.c 		if (!wait_for_completion_interruptible_timeout(&xqspi->data_completion,
xqspi             562 drivers/spi/spi-zynq-qspi.c 		reinit_completion(&xqspi->data_completion);
xqspi             563 drivers/spi/spi-zynq-qspi.c 		xqspi->txbuf = tmpbuf;
xqspi             564 drivers/spi/spi-zynq-qspi.c 		xqspi->rxbuf = NULL;
xqspi             565 drivers/spi/spi-zynq-qspi.c 		xqspi->tx_bytes = op->dummy.nbytes;
xqspi             566 drivers/spi/spi-zynq-qspi.c 		xqspi->rx_bytes = op->dummy.nbytes;
xqspi             567 drivers/spi/spi-zynq-qspi.c 		zynq_qspi_write_op(xqspi, ZYNQ_QSPI_FIFO_DEPTH, true);
xqspi             568 drivers/spi/spi-zynq-qspi.c 		zynq_qspi_write(xqspi, ZYNQ_QSPI_IEN_OFFSET,
xqspi             570 drivers/spi/spi-zynq-qspi.c 		if (!wait_for_completion_interruptible_timeout(&xqspi->data_completion,
xqspi             578 drivers/spi/spi-zynq-qspi.c 		reinit_completion(&xqspi->data_completion);
xqspi             580 drivers/spi/spi-zynq-qspi.c 			xqspi->txbuf = (u8 *)op->data.buf.out;
xqspi             581 drivers/spi/spi-zynq-qspi.c 			xqspi->tx_bytes = op->data.nbytes;
xqspi             582 drivers/spi/spi-zynq-qspi.c 			xqspi->rxbuf = NULL;
xqspi             583 drivers/spi/spi-zynq-qspi.c 			xqspi->rx_bytes = op->data.nbytes;
xqspi             585 drivers/spi/spi-zynq-qspi.c 			xqspi->txbuf = NULL;
xqspi             586 drivers/spi/spi-zynq-qspi.c 			xqspi->rxbuf = (u8 *)op->data.buf.in;
xqspi             587 drivers/spi/spi-zynq-qspi.c 			xqspi->rx_bytes = op->data.nbytes;
xqspi             588 drivers/spi/spi-zynq-qspi.c 			xqspi->tx_bytes = op->data.nbytes;
xqspi             591 drivers/spi/spi-zynq-qspi.c 		zynq_qspi_write_op(xqspi, ZYNQ_QSPI_FIFO_DEPTH, true);
xqspi             592 drivers/spi/spi-zynq-qspi.c 		zynq_qspi_write(xqspi, ZYNQ_QSPI_IEN_OFFSET,
xqspi             594 drivers/spi/spi-zynq-qspi.c 		if (!wait_for_completion_interruptible_timeout(&xqspi->data_completion,
xqspi             622 drivers/spi/spi-zynq-qspi.c 	struct zynq_qspi *xqspi;
xqspi             625 drivers/spi/spi-zynq-qspi.c 	ctlr = spi_alloc_master(&pdev->dev, sizeof(*xqspi));
xqspi             629 drivers/spi/spi-zynq-qspi.c 	xqspi = spi_controller_get_devdata(ctlr);
xqspi             630 drivers/spi/spi-zynq-qspi.c 	xqspi->dev = dev;
xqspi             631 drivers/spi/spi-zynq-qspi.c 	platform_set_drvdata(pdev, xqspi);
xqspi             632 drivers/spi/spi-zynq-qspi.c 	xqspi->regs = devm_platform_ioremap_resource(pdev, 0);
xqspi             633 drivers/spi/spi-zynq-qspi.c 	if (IS_ERR(xqspi->regs)) {
xqspi             634 drivers/spi/spi-zynq-qspi.c 		ret = PTR_ERR(xqspi->regs);
xqspi             638 drivers/spi/spi-zynq-qspi.c 	xqspi->pclk = devm_clk_get(&pdev->dev, "pclk");
xqspi             639 drivers/spi/spi-zynq-qspi.c 	if (IS_ERR(xqspi->pclk)) {
xqspi             641 drivers/spi/spi-zynq-qspi.c 		ret = PTR_ERR(xqspi->pclk);
xqspi             645 drivers/spi/spi-zynq-qspi.c 	init_completion(&xqspi->data_completion);
xqspi             647 drivers/spi/spi-zynq-qspi.c 	xqspi->refclk = devm_clk_get(&pdev->dev, "ref_clk");
xqspi             648 drivers/spi/spi-zynq-qspi.c 	if (IS_ERR(xqspi->refclk)) {
xqspi             650 drivers/spi/spi-zynq-qspi.c 		ret = PTR_ERR(xqspi->refclk);
xqspi             654 drivers/spi/spi-zynq-qspi.c 	ret = clk_prepare_enable(xqspi->pclk);
xqspi             660 drivers/spi/spi-zynq-qspi.c 	ret = clk_prepare_enable(xqspi->refclk);
xqspi             667 drivers/spi/spi-zynq-qspi.c 	zynq_qspi_init_hw(xqspi);
xqspi             669 drivers/spi/spi-zynq-qspi.c 	xqspi->irq = platform_get_irq(pdev, 0);
xqspi             670 drivers/spi/spi-zynq-qspi.c 	if (xqspi->irq <= 0) {
xqspi             674 drivers/spi/spi-zynq-qspi.c 	ret = devm_request_irq(&pdev->dev, xqspi->irq, zynq_qspi_irq,
xqspi             675 drivers/spi/spi-zynq-qspi.c 			       0, pdev->name, xqspi);
xqspi             693 drivers/spi/spi-zynq-qspi.c 	ctlr->max_speed_hz = clk_get_rate(xqspi->refclk) / 2;
xqspi             704 drivers/spi/spi-zynq-qspi.c 	clk_disable_unprepare(xqspi->refclk);
xqspi             706 drivers/spi/spi-zynq-qspi.c 	clk_disable_unprepare(xqspi->pclk);
xqspi             725 drivers/spi/spi-zynq-qspi.c 	struct zynq_qspi *xqspi = platform_get_drvdata(pdev);
xqspi             727 drivers/spi/spi-zynq-qspi.c 	zynq_qspi_write(xqspi, ZYNQ_QSPI_ENABLE_OFFSET, 0);
xqspi             729 drivers/spi/spi-zynq-qspi.c 	clk_disable_unprepare(xqspi->refclk);
xqspi             730 drivers/spi/spi-zynq-qspi.c 	clk_disable_unprepare(xqspi->pclk);
xqspi             181 drivers/spi/spi-zynqmp-gqspi.c static u32 zynqmp_gqspi_read(struct zynqmp_qspi *xqspi, u32 offset)
xqspi             183 drivers/spi/spi-zynqmp-gqspi.c 	return readl_relaxed(xqspi->regs + offset);
xqspi             192 drivers/spi/spi-zynqmp-gqspi.c static inline void zynqmp_gqspi_write(struct zynqmp_qspi *xqspi, u32 offset,
xqspi             195 drivers/spi/spi-zynqmp-gqspi.c 	writel_relaxed(val, (xqspi->regs + offset));
xqspi             263 drivers/spi/spi-zynqmp-gqspi.c static void zynqmp_qspi_init_hw(struct zynqmp_qspi *xqspi)
xqspi             268 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_SEL_OFST, GQSPI_SEL_MASK);
xqspi             270 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_ISR_OFST,
xqspi             271 drivers/spi/spi-zynqmp-gqspi.c 			   zynqmp_gqspi_read(xqspi, GQSPI_ISR_OFST) |
xqspi             274 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_QSPIDMA_DST_I_STS_OFST,
xqspi             275 drivers/spi/spi-zynqmp-gqspi.c 			   zynqmp_gqspi_read(xqspi,
xqspi             277 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_QSPIDMA_DST_STS_OFST,
xqspi             278 drivers/spi/spi-zynqmp-gqspi.c 			   zynqmp_gqspi_read(xqspi,
xqspi             281 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_IDR_OFST, GQSPI_IDR_ALL_MASK);
xqspi             282 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi,
xqspi             286 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_EN_OFST, 0x0);
xqspi             287 drivers/spi/spi-zynqmp-gqspi.c 	config_reg = zynqmp_gqspi_read(xqspi, GQSPI_CONFIG_OFST);
xqspi             303 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_CONFIG_OFST, config_reg);
xqspi             306 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_FIFO_CTRL_OFST,
xqspi             311 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_LPBK_DLY_ADJ_OFST,
xqspi             312 drivers/spi/spi-zynqmp-gqspi.c 			   zynqmp_gqspi_read(xqspi, GQSPI_LPBK_DLY_ADJ_OFST) |
xqspi             315 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_TX_THRESHOLD_OFST,
xqspi             317 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_RX_THRESHOLD_OFST,
xqspi             319 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_GF_THRESHOLD_OFST,
xqspi             321 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_selectslave(xqspi,
xqspi             325 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi,
xqspi             330 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_EN_OFST, GQSPI_EN_MASK);
xqspi             339 drivers/spi/spi-zynqmp-gqspi.c static void zynqmp_qspi_copy_read_data(struct zynqmp_qspi *xqspi,
xqspi             342 drivers/spi/spi-zynqmp-gqspi.c 	memcpy(xqspi->rxbuf, &data, size);
xqspi             343 drivers/spi/spi-zynqmp-gqspi.c 	xqspi->rxbuf += size;
xqspi             344 drivers/spi/spi-zynqmp-gqspi.c 	xqspi->bytes_to_receive -= size;
xqspi             358 drivers/spi/spi-zynqmp-gqspi.c 	struct zynqmp_qspi *xqspi = spi_master_get_devdata(master);
xqspi             360 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_EN_OFST, GQSPI_EN_MASK);
xqspi             375 drivers/spi/spi-zynqmp-gqspi.c 	struct zynqmp_qspi *xqspi = spi_master_get_devdata(master);
xqspi             377 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_EN_OFST, 0x0);
xqspi             388 drivers/spi/spi-zynqmp-gqspi.c 	struct zynqmp_qspi *xqspi = spi_master_get_devdata(qspi->master);
xqspi             393 drivers/spi/spi-zynqmp-gqspi.c 	genfifoentry |= xqspi->genfifobus;
xqspi             396 drivers/spi/spi-zynqmp-gqspi.c 		genfifoentry |= xqspi->genfifocs;
xqspi             402 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_GEN_FIFO_OFST, genfifoentry);
xqspi             405 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_CONFIG_OFST,
xqspi             406 drivers/spi/spi-zynqmp-gqspi.c 			zynqmp_gqspi_read(xqspi, GQSPI_CONFIG_OFST) |
xqspi             413 drivers/spi/spi-zynqmp-gqspi.c 		statusreg = zynqmp_gqspi_read(xqspi, GQSPI_ISR_OFST);
xqspi             423 drivers/spi/spi-zynqmp-gqspi.c 		dev_err(xqspi->dev, "Chip select timed out\n");
xqspi             451 drivers/spi/spi-zynqmp-gqspi.c 	struct zynqmp_qspi *xqspi = spi_master_get_devdata(qspi->master);
xqspi             462 drivers/spi/spi-zynqmp-gqspi.c 	clk_rate = clk_get_rate(xqspi->refclk);
xqspi             469 drivers/spi/spi-zynqmp-gqspi.c 	config_reg = zynqmp_gqspi_read(xqspi, GQSPI_CONFIG_OFST);
xqspi             481 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_CONFIG_OFST, config_reg);
xqspi             508 drivers/spi/spi-zynqmp-gqspi.c static void zynqmp_qspi_filltxfifo(struct zynqmp_qspi *xqspi, int size)
xqspi             512 drivers/spi/spi-zynqmp-gqspi.c 	while ((xqspi->bytes_to_transfer > 0) && (count < size)) {
xqspi             513 drivers/spi/spi-zynqmp-gqspi.c 		memcpy(&intermediate, xqspi->txbuf, 4);
xqspi             514 drivers/spi/spi-zynqmp-gqspi.c 		zynqmp_gqspi_write(xqspi, GQSPI_TXD_OFST, intermediate);
xqspi             516 drivers/spi/spi-zynqmp-gqspi.c 		if (xqspi->bytes_to_transfer >= 4) {
xqspi             517 drivers/spi/spi-zynqmp-gqspi.c 			xqspi->txbuf += 4;
xqspi             518 drivers/spi/spi-zynqmp-gqspi.c 			xqspi->bytes_to_transfer -= 4;
xqspi             520 drivers/spi/spi-zynqmp-gqspi.c 			xqspi->txbuf += xqspi->bytes_to_transfer;
xqspi             521 drivers/spi/spi-zynqmp-gqspi.c 			xqspi->bytes_to_transfer = 0;
xqspi             533 drivers/spi/spi-zynqmp-gqspi.c static void zynqmp_qspi_readrxfifo(struct zynqmp_qspi *xqspi, u32 size)
xqspi             538 drivers/spi/spi-zynqmp-gqspi.c 	while ((count < size) && (xqspi->bytes_to_receive > 0)) {
xqspi             539 drivers/spi/spi-zynqmp-gqspi.c 		if (xqspi->bytes_to_receive >= 4) {
xqspi             540 drivers/spi/spi-zynqmp-gqspi.c 			(*(u32 *) xqspi->rxbuf) =
xqspi             541 drivers/spi/spi-zynqmp-gqspi.c 			zynqmp_gqspi_read(xqspi, GQSPI_RXD_OFST);
xqspi             542 drivers/spi/spi-zynqmp-gqspi.c 			xqspi->rxbuf += 4;
xqspi             543 drivers/spi/spi-zynqmp-gqspi.c 			xqspi->bytes_to_receive -= 4;
xqspi             546 drivers/spi/spi-zynqmp-gqspi.c 			data = zynqmp_gqspi_read(xqspi, GQSPI_RXD_OFST);
xqspi             547 drivers/spi/spi-zynqmp-gqspi.c 			count += xqspi->bytes_to_receive;
xqspi             548 drivers/spi/spi-zynqmp-gqspi.c 			zynqmp_qspi_copy_read_data(xqspi, data,
xqspi             549 drivers/spi/spi-zynqmp-gqspi.c 						   xqspi->bytes_to_receive);
xqspi             550 drivers/spi/spi-zynqmp-gqspi.c 			xqspi->bytes_to_receive = 0;
xqspi             562 drivers/spi/spi-zynqmp-gqspi.c static void zynqmp_process_dma_irq(struct zynqmp_qspi *xqspi)
xqspi             566 drivers/spi/spi-zynqmp-gqspi.c 	dma_unmap_single(xqspi->dev, xqspi->dma_addr,
xqspi             567 drivers/spi/spi-zynqmp-gqspi.c 				xqspi->dma_rx_bytes, DMA_FROM_DEVICE);
xqspi             568 drivers/spi/spi-zynqmp-gqspi.c 	xqspi->rxbuf += xqspi->dma_rx_bytes;
xqspi             569 drivers/spi/spi-zynqmp-gqspi.c 	xqspi->bytes_to_receive -= xqspi->dma_rx_bytes;
xqspi             570 drivers/spi/spi-zynqmp-gqspi.c 	xqspi->dma_rx_bytes = 0;
xqspi             573 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_QSPIDMA_DST_I_DIS_OFST,
xqspi             576 drivers/spi/spi-zynqmp-gqspi.c 	if (xqspi->bytes_to_receive > 0) {
xqspi             578 drivers/spi/spi-zynqmp-gqspi.c 		config_reg = zynqmp_gqspi_read(xqspi, GQSPI_CONFIG_OFST);
xqspi             580 drivers/spi/spi-zynqmp-gqspi.c 		zynqmp_gqspi_write(xqspi, GQSPI_CONFIG_OFST, config_reg);
xqspi             583 drivers/spi/spi-zynqmp-gqspi.c 		genfifoentry = xqspi->genfifoentry;
xqspi             584 drivers/spi/spi-zynqmp-gqspi.c 		genfifoentry |= xqspi->bytes_to_receive;
xqspi             585 drivers/spi/spi-zynqmp-gqspi.c 		zynqmp_gqspi_write(xqspi, GQSPI_GEN_FIFO_OFST, genfifoentry);
xqspi             588 drivers/spi/spi-zynqmp-gqspi.c 		zynqmp_gqspi_write(xqspi, GQSPI_GEN_FIFO_OFST, 0x0);
xqspi             591 drivers/spi/spi-zynqmp-gqspi.c 		zynqmp_gqspi_write(xqspi, GQSPI_CONFIG_OFST,
xqspi             592 drivers/spi/spi-zynqmp-gqspi.c 			(zynqmp_gqspi_read(xqspi, GQSPI_CONFIG_OFST) |
xqspi             596 drivers/spi/spi-zynqmp-gqspi.c 		zynqmp_gqspi_write(xqspi, GQSPI_IER_OFST,
xqspi             618 drivers/spi/spi-zynqmp-gqspi.c 	struct zynqmp_qspi *xqspi = spi_master_get_devdata(master);
xqspi             622 drivers/spi/spi-zynqmp-gqspi.c 	status = zynqmp_gqspi_read(xqspi, GQSPI_ISR_OFST);
xqspi             623 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_ISR_OFST, status);
xqspi             624 drivers/spi/spi-zynqmp-gqspi.c 	mask = (status & ~(zynqmp_gqspi_read(xqspi, GQSPI_IMASK_OFST)));
xqspi             627 drivers/spi/spi-zynqmp-gqspi.c 	if (xqspi->mode == GQSPI_MODE_DMA) {
xqspi             629 drivers/spi/spi-zynqmp-gqspi.c 			zynqmp_gqspi_read(xqspi, GQSPI_QSPIDMA_DST_I_STS_OFST);
xqspi             630 drivers/spi/spi-zynqmp-gqspi.c 		zynqmp_gqspi_write(xqspi, GQSPI_QSPIDMA_DST_I_STS_OFST,
xqspi             635 drivers/spi/spi-zynqmp-gqspi.c 		zynqmp_qspi_filltxfifo(xqspi, GQSPI_TX_FIFO_FILL);
xqspi             640 drivers/spi/spi-zynqmp-gqspi.c 		zynqmp_process_dma_irq(xqspi);
xqspi             644 drivers/spi/spi-zynqmp-gqspi.c 		zynqmp_qspi_readrxfifo(xqspi, GQSPI_RX_FIFO_FILL);
xqspi             648 drivers/spi/spi-zynqmp-gqspi.c 	if ((xqspi->bytes_to_receive == 0) && (xqspi->bytes_to_transfer == 0)
xqspi             650 drivers/spi/spi-zynqmp-gqspi.c 		zynqmp_gqspi_write(xqspi, GQSPI_IDR_OFST, GQSPI_ISR_IDR_MASK);
xqspi             663 drivers/spi/spi-zynqmp-gqspi.c static inline u32 zynqmp_qspi_selectspimode(struct zynqmp_qspi *xqspi,
xqspi             679 drivers/spi/spi-zynqmp-gqspi.c 		dev_warn(xqspi->dev, "Invalid SPI mode\n");
xqspi             689 drivers/spi/spi-zynqmp-gqspi.c static void zynq_qspi_setuprxdma(struct zynqmp_qspi *xqspi)
xqspi             693 drivers/spi/spi-zynqmp-gqspi.c 	u64 dma_align =  (u64)(uintptr_t)xqspi->rxbuf;
xqspi             695 drivers/spi/spi-zynqmp-gqspi.c 	if ((xqspi->bytes_to_receive < 8) ||
xqspi             698 drivers/spi/spi-zynqmp-gqspi.c 		config_reg = zynqmp_gqspi_read(xqspi, GQSPI_CONFIG_OFST);
xqspi             700 drivers/spi/spi-zynqmp-gqspi.c 		zynqmp_gqspi_write(xqspi, GQSPI_CONFIG_OFST, config_reg);
xqspi             701 drivers/spi/spi-zynqmp-gqspi.c 		xqspi->mode = GQSPI_MODE_IO;
xqspi             702 drivers/spi/spi-zynqmp-gqspi.c 		xqspi->dma_rx_bytes = 0;
xqspi             706 drivers/spi/spi-zynqmp-gqspi.c 	rx_rem = xqspi->bytes_to_receive % 4;
xqspi             707 drivers/spi/spi-zynqmp-gqspi.c 	rx_bytes = (xqspi->bytes_to_receive - rx_rem);
xqspi             709 drivers/spi/spi-zynqmp-gqspi.c 	addr = dma_map_single(xqspi->dev, (void *)xqspi->rxbuf,
xqspi             711 drivers/spi/spi-zynqmp-gqspi.c 	if (dma_mapping_error(xqspi->dev, addr))
xqspi             712 drivers/spi/spi-zynqmp-gqspi.c 		dev_err(xqspi->dev, "ERR:rxdma:memory not mapped\n");
xqspi             714 drivers/spi/spi-zynqmp-gqspi.c 	xqspi->dma_rx_bytes = rx_bytes;
xqspi             715 drivers/spi/spi-zynqmp-gqspi.c 	xqspi->dma_addr = addr;
xqspi             716 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_QSPIDMA_DST_ADDR_OFST,
xqspi             719 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_QSPIDMA_DST_ADDR_MSB_OFST,
xqspi             723 drivers/spi/spi-zynqmp-gqspi.c 	config_reg = zynqmp_gqspi_read(xqspi, GQSPI_CONFIG_OFST);
xqspi             726 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_CONFIG_OFST, config_reg);
xqspi             729 drivers/spi/spi-zynqmp-gqspi.c 	xqspi->mode = GQSPI_MODE_DMA;
xqspi             732 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_QSPIDMA_DST_SIZE_OFST, rx_bytes);
xqspi             744 drivers/spi/spi-zynqmp-gqspi.c static void zynqmp_qspi_txrxsetup(struct zynqmp_qspi *xqspi,
xqspi             751 drivers/spi/spi-zynqmp-gqspi.c 	if ((xqspi->txbuf != NULL) && (xqspi->rxbuf == NULL)) {
xqspi             757 drivers/spi/spi-zynqmp-gqspi.c 			zynqmp_qspi_selectspimode(xqspi, transfer->tx_nbits);
xqspi             758 drivers/spi/spi-zynqmp-gqspi.c 		xqspi->bytes_to_transfer = transfer->len;
xqspi             759 drivers/spi/spi-zynqmp-gqspi.c 		if (xqspi->mode == GQSPI_MODE_DMA) {
xqspi             760 drivers/spi/spi-zynqmp-gqspi.c 			config_reg = zynqmp_gqspi_read(xqspi,
xqspi             763 drivers/spi/spi-zynqmp-gqspi.c 			zynqmp_gqspi_write(xqspi, GQSPI_CONFIG_OFST,
xqspi             765 drivers/spi/spi-zynqmp-gqspi.c 			xqspi->mode = GQSPI_MODE_IO;
xqspi             767 drivers/spi/spi-zynqmp-gqspi.c 		zynqmp_qspi_filltxfifo(xqspi, GQSPI_TXD_DEPTH);
xqspi             769 drivers/spi/spi-zynqmp-gqspi.c 		xqspi->bytes_to_receive = 0;
xqspi             770 drivers/spi/spi-zynqmp-gqspi.c 	} else if ((xqspi->txbuf == NULL) && (xqspi->rxbuf != NULL)) {
xqspi             779 drivers/spi/spi-zynqmp-gqspi.c 			zynqmp_qspi_selectspimode(xqspi, transfer->rx_nbits);
xqspi             780 drivers/spi/spi-zynqmp-gqspi.c 		xqspi->bytes_to_transfer = 0;
xqspi             781 drivers/spi/spi-zynqmp-gqspi.c 		xqspi->bytes_to_receive = transfer->len;
xqspi             782 drivers/spi/spi-zynqmp-gqspi.c 		zynq_qspi_setuprxdma(xqspi);
xqspi             803 drivers/spi/spi-zynqmp-gqspi.c 	struct zynqmp_qspi *xqspi = spi_master_get_devdata(master);
xqspi             806 drivers/spi/spi-zynqmp-gqspi.c 	xqspi->txbuf = transfer->tx_buf;
xqspi             807 drivers/spi/spi-zynqmp-gqspi.c 	xqspi->rxbuf = transfer->rx_buf;
xqspi             811 drivers/spi/spi-zynqmp-gqspi.c 	genfifoentry |= xqspi->genfifocs;
xqspi             812 drivers/spi/spi-zynqmp-gqspi.c 	genfifoentry |= xqspi->genfifobus;
xqspi             814 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_qspi_txrxsetup(xqspi, transfer, &genfifoentry);
xqspi             816 drivers/spi/spi-zynqmp-gqspi.c 	if (xqspi->mode == GQSPI_MODE_DMA)
xqspi             817 drivers/spi/spi-zynqmp-gqspi.c 		transfer_len = xqspi->dma_rx_bytes;
xqspi             821 drivers/spi/spi-zynqmp-gqspi.c 	xqspi->genfifoentry = genfifoentry;
xqspi             825 drivers/spi/spi-zynqmp-gqspi.c 		zynqmp_gqspi_write(xqspi, GQSPI_GEN_FIFO_OFST, genfifoentry);
xqspi             841 drivers/spi/spi-zynqmp-gqspi.c 					zynqmp_gqspi_write(xqspi,
xqspi             853 drivers/spi/spi-zynqmp-gqspi.c 			zynqmp_gqspi_write(xqspi,
xqspi             858 drivers/spi/spi-zynqmp-gqspi.c 	if ((xqspi->mode == GQSPI_MODE_IO) &&
xqspi             859 drivers/spi/spi-zynqmp-gqspi.c 			(xqspi->rxbuf != NULL)) {
xqspi             861 drivers/spi/spi-zynqmp-gqspi.c 		zynqmp_gqspi_write(xqspi, GQSPI_GEN_FIFO_OFST, 0x0);
xqspi             865 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_CONFIG_OFST,
xqspi             866 drivers/spi/spi-zynqmp-gqspi.c 			   zynqmp_gqspi_read(xqspi, GQSPI_CONFIG_OFST) |
xqspi             869 drivers/spi/spi-zynqmp-gqspi.c 	if (xqspi->txbuf != NULL)
xqspi             871 drivers/spi/spi-zynqmp-gqspi.c 		zynqmp_gqspi_write(xqspi, GQSPI_IER_OFST,
xqspi             876 drivers/spi/spi-zynqmp-gqspi.c 	if (xqspi->rxbuf != NULL) {
xqspi             878 drivers/spi/spi-zynqmp-gqspi.c 		if (xqspi->mode == GQSPI_MODE_DMA) {
xqspi             880 drivers/spi/spi-zynqmp-gqspi.c 			zynqmp_gqspi_write(xqspi,
xqspi             884 drivers/spi/spi-zynqmp-gqspi.c 			zynqmp_gqspi_write(xqspi, GQSPI_IER_OFST,
xqspi             925 drivers/spi/spi-zynqmp-gqspi.c 	struct zynqmp_qspi *xqspi = spi_master_get_devdata(master);
xqspi             928 drivers/spi/spi-zynqmp-gqspi.c 	ret = clk_enable(xqspi->pclk);
xqspi             934 drivers/spi/spi-zynqmp-gqspi.c 	ret = clk_enable(xqspi->refclk);
xqspi             937 drivers/spi/spi-zynqmp-gqspi.c 		clk_disable(xqspi->pclk);
xqspi             943 drivers/spi/spi-zynqmp-gqspi.c 	clk_disable(xqspi->refclk);
xqspi             944 drivers/spi/spi-zynqmp-gqspi.c 	clk_disable(xqspi->pclk);
xqspi             959 drivers/spi/spi-zynqmp-gqspi.c 	struct zynqmp_qspi *xqspi = spi_master_get_devdata(master);
xqspi             961 drivers/spi/spi-zynqmp-gqspi.c 	clk_disable(xqspi->refclk);
xqspi             962 drivers/spi/spi-zynqmp-gqspi.c 	clk_disable(xqspi->pclk);
xqspi             978 drivers/spi/spi-zynqmp-gqspi.c 	struct zynqmp_qspi *xqspi = spi_master_get_devdata(master);
xqspi             981 drivers/spi/spi-zynqmp-gqspi.c 	ret = clk_enable(xqspi->pclk);
xqspi             987 drivers/spi/spi-zynqmp-gqspi.c 	ret = clk_enable(xqspi->refclk);
xqspi             990 drivers/spi/spi-zynqmp-gqspi.c 		clk_disable(xqspi->pclk);
xqspi            1015 drivers/spi/spi-zynqmp-gqspi.c 	struct zynqmp_qspi *xqspi;
xqspi            1022 drivers/spi/spi-zynqmp-gqspi.c 	master = spi_alloc_master(&pdev->dev, sizeof(*xqspi));
xqspi            1026 drivers/spi/spi-zynqmp-gqspi.c 	xqspi = spi_master_get_devdata(master);
xqspi            1030 drivers/spi/spi-zynqmp-gqspi.c 	xqspi->regs = devm_platform_ioremap_resource(pdev, 0);
xqspi            1031 drivers/spi/spi-zynqmp-gqspi.c 	if (IS_ERR(xqspi->regs)) {
xqspi            1032 drivers/spi/spi-zynqmp-gqspi.c 		ret = PTR_ERR(xqspi->regs);
xqspi            1036 drivers/spi/spi-zynqmp-gqspi.c 	xqspi->dev = dev;
xqspi            1037 drivers/spi/spi-zynqmp-gqspi.c 	xqspi->pclk = devm_clk_get(&pdev->dev, "pclk");
xqspi            1038 drivers/spi/spi-zynqmp-gqspi.c 	if (IS_ERR(xqspi->pclk)) {
xqspi            1040 drivers/spi/spi-zynqmp-gqspi.c 		ret = PTR_ERR(xqspi->pclk);
xqspi            1044 drivers/spi/spi-zynqmp-gqspi.c 	ret = clk_prepare_enable(xqspi->pclk);
xqspi            1050 drivers/spi/spi-zynqmp-gqspi.c 	xqspi->refclk = devm_clk_get(&pdev->dev, "ref_clk");
xqspi            1051 drivers/spi/spi-zynqmp-gqspi.c 	if (IS_ERR(xqspi->refclk)) {
xqspi            1053 drivers/spi/spi-zynqmp-gqspi.c 		ret = PTR_ERR(xqspi->refclk);
xqspi            1057 drivers/spi/spi-zynqmp-gqspi.c 	ret = clk_prepare_enable(xqspi->refclk);
xqspi            1068 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_qspi_init_hw(xqspi);
xqspi            1072 drivers/spi/spi-zynqmp-gqspi.c 	xqspi->irq = platform_get_irq(pdev, 0);
xqspi            1073 drivers/spi/spi-zynqmp-gqspi.c 	if (xqspi->irq <= 0) {
xqspi            1077 drivers/spi/spi-zynqmp-gqspi.c 	ret = devm_request_irq(&pdev->dev, xqspi->irq, zynqmp_qspi_irq,
xqspi            1093 drivers/spi/spi-zynqmp-gqspi.c 	master->max_speed_hz = clk_get_rate(xqspi->refclk) / 2;
xqspi            1110 drivers/spi/spi-zynqmp-gqspi.c 	clk_disable_unprepare(xqspi->refclk);
xqspi            1112 drivers/spi/spi-zynqmp-gqspi.c 	clk_disable_unprepare(xqspi->pclk);
xqspi            1132 drivers/spi/spi-zynqmp-gqspi.c 	struct zynqmp_qspi *xqspi = spi_master_get_devdata(master);
xqspi            1134 drivers/spi/spi-zynqmp-gqspi.c 	zynqmp_gqspi_write(xqspi, GQSPI_EN_OFST, 0x0);
xqspi            1135 drivers/spi/spi-zynqmp-gqspi.c 	clk_disable_unprepare(xqspi->refclk);
xqspi            1136 drivers/spi/spi-zynqmp-gqspi.c 	clk_disable_unprepare(xqspi->pclk);