Lines Matching +full:xspi +full:- +full:nor
1 // SPDX-License-Identifier: GPL-2.0+
2 // Cadence XSPI flash controller driver
3 // Copyright (C) 2020-21 Cadence
19 #include <linux/spi/spi-mem.h>
27 #define CDNS_XSPI_NAME "cadence-xspi"
31 * configure XSPI controller pin-strap settings
157 FIELD_PREP(CDNS_XSPI_CMD_P1_R1_ADDR0, (op)->addr.val & 0xff))
160 FIELD_PREP(CDNS_XSPI_CMD_P1_R2_ADDR1, ((op)->addr.val >> 8) & 0xFF) | \
161 FIELD_PREP(CDNS_XSPI_CMD_P1_R2_ADDR2, ((op)->addr.val >> 16) & 0xFF) | \
162 FIELD_PREP(CDNS_XSPI_CMD_P1_R2_ADDR3, ((op)->addr.val >> 24) & 0xFF) | \
163 FIELD_PREP(CDNS_XSPI_CMD_P1_R2_ADDR4, ((op)->addr.val >> 32) & 0xFF))
166 FIELD_PREP(CDNS_XSPI_CMD_P1_R3_ADDR5, ((op)->addr.val >> 40) & 0xFF) | \
167 FIELD_PREP(CDNS_XSPI_CMD_P1_R3_CMD, (op)->cmd.opcode) | \
169 FIELD_PREP(CDNS_XSPI_CMD_P1_R3_NUM_ADDR_BYTES, (op)->addr.nbytes))
172 FIELD_PREP(CDNS_XSPI_CMD_P1_R4_ADDR_IOS, ilog2((op)->addr.buswidth)) | \
173 FIELD_PREP(CDNS_XSPI_CMD_P1_R4_CMD_IOS, ilog2((op)->cmd.buswidth)) | \
180 FIELD_PREP(CDNS_XSPI_CMD_DSEQ_R2_DCNT_L, (op)->data.nbytes & 0xFFFF)
184 ((op)->data.nbytes >> 16) & 0xffff) | \
186 (op)->dummy.buswidth != 0 ? \
187 (((dummybytes) * 8) / (op)->dummy.buswidth) : \
193 ilog2((op)->data.buswidth)) | \
195 ((op)->data.dir == SPI_MEM_DATA_IN) ? \
198 /* Helper macros for GENERIC and GENERIC-DSEQ instruction type */
250 /* Marvell overlay registers - clock */
259 /* Marvell overlay registers - xfer */
280 #define GENERIC_CMD_DATA_REG_3_COUNT(len) (len >= 10 ? 2 : len - 8)
281 #define GENERIC_CMD_DATA_REG_2_COUNT(len) (len >= 7 ? 3 : len - 4)
282 #define GENERIC_CMD_DATA_REG_1_COUNT(len) (len >= 3 ? 2 : len - 1)
384 u32 dll_cntrl = readl(cdns_xspi->iobase + in cdns_xspi_reset_dll()
389 writel(dll_cntrl, cdns_xspi->iobase + in cdns_xspi_reset_dll()
397 return !readl_relaxed_poll_timeout(cdns_xspi->iobase + in cdns_xspi_is_dll_locked()
405 writel(cdns_xspi->driver_data->dll_phy_ctrl, in cdns_xspi_configure_phy()
406 cdns_xspi->iobase + CDNS_XSPI_RF_MINICTRL_REGS_DLL_PHY_CTRL); in cdns_xspi_configure_phy()
407 writel(cdns_xspi->driver_data->ctb_rfile_phy_ctrl, in cdns_xspi_configure_phy()
408 cdns_xspi->auxbase + CDNS_XSPI_PHY_CTB_RFILE_PHY_CTRL); in cdns_xspi_configure_phy()
409 writel(cdns_xspi->driver_data->rfile_phy_tsel, in cdns_xspi_configure_phy()
410 cdns_xspi->auxbase + CDNS_XSPI_PHY_CTB_RFILE_PHY_TSEL); in cdns_xspi_configure_phy()
411 writel(cdns_xspi->driver_data->rfile_phy_dq_timing, in cdns_xspi_configure_phy()
412 cdns_xspi->auxbase + CDNS_XSPI_PHY_DATASLICE_RFILE_PHY_DQ_TIMING); in cdns_xspi_configure_phy()
413 writel(cdns_xspi->driver_data->rfile_phy_dqs_timing, in cdns_xspi_configure_phy()
414 cdns_xspi->auxbase + CDNS_XSPI_PHY_DATASLICE_RFILE_PHY_DQS_TIMING); in cdns_xspi_configure_phy()
415 writel(cdns_xspi->driver_data->rfile_phy_gate_lpbk_ctrl, in cdns_xspi_configure_phy()
416 cdns_xspi->auxbase + CDNS_XSPI_PHY_DATASLICE_RFILE_PHY_GATE_LPBK_CTRL); in cdns_xspi_configure_phy()
417 writel(cdns_xspi->driver_data->rfile_phy_dll_master_ctrl, in cdns_xspi_configure_phy()
418 cdns_xspi->auxbase + CDNS_XSPI_PHY_DATASLICE_RFILE_PHY_DLL_MASTER_CTRL); in cdns_xspi_configure_phy()
419 writel(cdns_xspi->driver_data->rfile_phy_dll_slave_ctrl, in cdns_xspi_configure_phy()
420 cdns_xspi->auxbase + CDNS_XSPI_PHY_DATASLICE_RFILE_PHY_DLL_SLAVE_CTRL); in cdns_xspi_configure_phy()
443 dev_dbg(cdns_xspi->dev, "Found clk div: %d, clk val: %d\n", in cdns_mrvl_xspi_setup_clock()
448 clk_reg = readl(cdns_xspi->auxbase + MRVL_XSPI_CLK_CTRL_AUX_REG); in cdns_mrvl_xspi_setup_clock()
453 cdns_xspi->auxbase + MRVL_XSPI_CLK_CTRL_AUX_REG); in cdns_mrvl_xspi_setup_clock()
464 cdns_xspi->auxbase + MRVL_XSPI_CLK_CTRL_AUX_REG); in cdns_mrvl_xspi_setup_clock()
473 return readl_relaxed_poll_timeout(cdns_xspi->iobase + in cdns_xspi_wait_for_controller_idle()
484 writel(cmd_regs[5], cdns_xspi->iobase + CDNS_XSPI_CMD_REG_5); in cdns_xspi_trigger_command()
485 writel(cmd_regs[4], cdns_xspi->iobase + CDNS_XSPI_CMD_REG_4); in cdns_xspi_trigger_command()
486 writel(cmd_regs[3], cdns_xspi->iobase + CDNS_XSPI_CMD_REG_3); in cdns_xspi_trigger_command()
487 writel(cmd_regs[2], cdns_xspi->iobase + CDNS_XSPI_CMD_REG_2); in cdns_xspi_trigger_command()
488 writel(cmd_regs[1], cdns_xspi->iobase + CDNS_XSPI_CMD_REG_1); in cdns_xspi_trigger_command()
489 writel(cmd_regs[0], cdns_xspi->iobase + CDNS_XSPI_CMD_REG_0); in cdns_xspi_trigger_command()
495 u32 cmd_status = readl(cdns_xspi->iobase + CDNS_XSPI_CMD_STATUS_REG); in cdns_xspi_check_command_status()
500 dev_err(cdns_xspi->dev, in cdns_xspi_check_command_status()
502 ret = -EPROTO; in cdns_xspi_check_command_status()
505 dev_err(cdns_xspi->dev, in cdns_xspi_check_command_status()
507 ret = -EPROTO; in cdns_xspi_check_command_status()
510 dev_err(cdns_xspi->dev, in cdns_xspi_check_command_status()
512 ret = -EPROTO; in cdns_xspi_check_command_status()
515 dev_err(cdns_xspi->dev, in cdns_xspi_check_command_status()
517 ret = -EPROTO; in cdns_xspi_check_command_status()
521 dev_err(cdns_xspi->dev, "Fatal err - command not completed\n"); in cdns_xspi_check_command_status()
522 ret = -EPROTO; in cdns_xspi_check_command_status()
533 intr_enable = readl(cdns_xspi->iobase + CDNS_XSPI_INTR_ENABLE_REG); in cdns_xspi_set_interrupts()
538 writel(intr_enable, cdns_xspi->iobase + CDNS_XSPI_INTR_ENABLE_REG); in cdns_xspi_set_interrupts()
547 irq_status = readl(cdns_xspi->iobase + CDNS_XSPI_INTR_STATUS_REG); in marvell_xspi_set_interrupts()
548 writel(irq_status, cdns_xspi->iobase + CDNS_XSPI_INTR_STATUS_REG); in marvell_xspi_set_interrupts()
550 intr_enable = readl(cdns_xspi->iobase + CDNS_XSPI_INTR_ENABLE_REG); in marvell_xspi_set_interrupts()
555 writel(intr_enable, cdns_xspi->iobase + CDNS_XSPI_INTR_ENABLE_REG); in marvell_xspi_set_interrupts()
564 ctrl_ver = readl(cdns_xspi->iobase + CDNS_XSPI_CTRL_VERSION_REG); in cdns_xspi_controller_init()
567 dev_err(cdns_xspi->dev, in cdns_xspi_controller_init()
568 "Incorrect XSPI magic number: %x, expected: %x\n", in cdns_xspi_controller_init()
570 return -EIO; in cdns_xspi_controller_init()
573 ctrl_features = readl(cdns_xspi->iobase + CDNS_XSPI_CTRL_FEATURES_REG); in cdns_xspi_controller_init()
574 cdns_xspi->hw_num_banks = FIELD_GET(CDNS_XSPI_NUM_BANKS, ctrl_features); in cdns_xspi_controller_init()
575 cdns_xspi->set_interrupts_handler(cdns_xspi, false); in cdns_xspi_controller_init()
585 sdma_size = readl(cdns_xspi->iobase + CDNS_XSPI_SDMA_SIZE_REG); in cdns_xspi_sdma_handle()
586 sdma_trd_info = readl(cdns_xspi->iobase + CDNS_XSPI_SDMA_TRD_INFO_REG); in cdns_xspi_sdma_handle()
591 ioread8_rep(cdns_xspi->sdmabase, in cdns_xspi_sdma_handle()
592 cdns_xspi->in_buffer, sdma_size); in cdns_xspi_sdma_handle()
596 iowrite8_rep(cdns_xspi->sdmabase, in cdns_xspi_sdma_handle()
597 cdns_xspi->out_buffer, sdma_size); in cdns_xspi_sdma_handle()
608 len -= full_ops * 8; in m_ioreadq()
614 } while (--full_ops); in m_ioreadq()
623 len = len > 8 ? len - 8 : 0; in m_ioreadq()
634 len -= full_ops * 8; in m_iowriteq()
639 } while (--full_ops); in m_iowriteq()
647 len = len > 8 ? len - 8 : 0; in m_iowriteq()
657 sdma_size = readl(cdns_xspi->iobase + CDNS_XSPI_SDMA_SIZE_REG); in marvell_xspi_sdma_handle()
658 sdma_trd_info = readl(cdns_xspi->iobase + CDNS_XSPI_SDMA_TRD_INFO_REG); in marvell_xspi_sdma_handle()
663 m_ioreadq(cdns_xspi->sdmabase, in marvell_xspi_sdma_handle()
664 cdns_xspi->in_buffer, sdma_size); in marvell_xspi_sdma_handle()
668 m_iowriteq(cdns_xspi->sdmabase, in marvell_xspi_sdma_handle()
669 cdns_xspi->out_buffer, sdma_size); in marvell_xspi_sdma_handle()
681 int dummybytes = op->dummy.nbytes; in cdns_xspi_send_stig_command()
685 return -EIO; in cdns_xspi_send_stig_command()
688 cdns_xspi->iobase + CDNS_XSPI_CTRL_CONFIG_REG); in cdns_xspi_send_stig_command()
690 cdns_xspi->set_interrupts_handler(cdns_xspi, true); in cdns_xspi_send_stig_command()
691 cdns_xspi->sdma_error = false; in cdns_xspi_send_stig_command()
698 dummybytes--; in cdns_xspi_send_stig_command()
703 cdns_xspi->cur_cs); in cdns_xspi_send_stig_command()
713 cdns_xspi->cur_cs); in cdns_xspi_send_stig_command()
715 cdns_xspi->in_buffer = op->data.buf.in; in cdns_xspi_send_stig_command()
716 cdns_xspi->out_buffer = op->data.buf.out; in cdns_xspi_send_stig_command()
720 wait_for_completion(&cdns_xspi->sdma_complete); in cdns_xspi_send_stig_command()
721 if (cdns_xspi->sdma_error) { in cdns_xspi_send_stig_command()
722 cdns_xspi->set_interrupts_handler(cdns_xspi, false); in cdns_xspi_send_stig_command()
723 return -EIO; in cdns_xspi_send_stig_command()
725 cdns_xspi->sdma_handler(cdns_xspi); in cdns_xspi_send_stig_command()
728 wait_for_completion(&cdns_xspi->cmd_complete); in cdns_xspi_send_stig_command()
729 cdns_xspi->set_interrupts_handler(cdns_xspi, false); in cdns_xspi_send_stig_command()
733 return -EPROTO; in cdns_xspi_send_stig_command()
742 enum spi_mem_data_dir dir = op->data.dir; in cdns_xspi_mem_op()
744 if (cdns_xspi->cur_cs != spi_get_chipselect(mem->spi, 0)) in cdns_xspi_mem_op()
745 cdns_xspi->cur_cs = spi_get_chipselect(mem->spi, 0); in cdns_xspi_mem_op()
755 spi_controller_get_devdata(mem->spi->controller); in cdns_xspi_mem_op_execute()
767 spi_controller_get_devdata(mem->spi->controller); in marvell_xspi_mem_op_execute()
770 cdns_mrvl_xspi_setup_clock(cdns_xspi, mem->spi->max_speed_hz); in marvell_xspi_mem_op_execute()
781 struct spi_device *spi = mem->spi; in cdns_xspi_supports_op()
785 adev = ACPI_COMPANION(&spi->dev); in cdns_xspi_supports_op()
787 if (!acpi_dev_get_property(adev, "spi-tx-bus-width", ACPI_TYPE_INTEGER, in cdns_xspi_supports_op()
789 switch (obj->integer.value) { in cdns_xspi_supports_op()
793 spi->mode |= SPI_TX_DUAL; in cdns_xspi_supports_op()
796 spi->mode |= SPI_TX_QUAD; in cdns_xspi_supports_op()
799 spi->mode |= SPI_TX_OCTAL; in cdns_xspi_supports_op()
802 dev_warn(&spi->dev, in cdns_xspi_supports_op()
803 "spi-tx-bus-width %lld not supported\n", in cdns_xspi_supports_op()
804 obj->integer.value); in cdns_xspi_supports_op()
809 if (!acpi_dev_get_property(adev, "spi-rx-bus-width", ACPI_TYPE_INTEGER, in cdns_xspi_supports_op()
811 switch (obj->integer.value) { in cdns_xspi_supports_op()
815 spi->mode |= SPI_RX_DUAL; in cdns_xspi_supports_op()
818 spi->mode |= SPI_RX_QUAD; in cdns_xspi_supports_op()
821 spi->mode |= SPI_RX_OCTAL; in cdns_xspi_supports_op()
824 dev_warn(&spi->dev, in cdns_xspi_supports_op()
825 "spi-rx-bus-width %lld not supported\n", in cdns_xspi_supports_op()
826 obj->integer.value); in cdns_xspi_supports_op()
841 spi_controller_get_devdata(mem->spi->controller); in cdns_xspi_adjust_mem_op_size()
843 op->data.nbytes = clamp_val(op->data.nbytes, 0, cdns_xspi->sdmasize); in cdns_xspi_adjust_mem_op_size()
870 irq_status = readl(cdns_xspi->iobase + CDNS_XSPI_INTR_STATUS_REG); in cdns_xspi_irq_handler()
871 writel(irq_status, cdns_xspi->iobase + CDNS_XSPI_INTR_STATUS_REG); in cdns_xspi_irq_handler()
877 dev_err(cdns_xspi->dev, in cdns_xspi_irq_handler()
879 cdns_xspi->sdma_error = true; in cdns_xspi_irq_handler()
880 complete(&cdns_xspi->sdma_complete); in cdns_xspi_irq_handler()
884 complete(&cdns_xspi->sdma_complete); in cdns_xspi_irq_handler()
887 complete(&cdns_xspi->cmd_complete); in cdns_xspi_irq_handler()
892 irq_status = readl(cdns_xspi->iobase + CDNS_XSPI_TRD_COMP_INTR_STATUS); in cdns_xspi_irq_handler()
895 cdns_xspi->iobase + CDNS_XSPI_TRD_COMP_INTR_STATUS); in cdns_xspi_irq_handler()
897 complete(&cdns_xspi->auto_cmd_complete); in cdns_xspi_irq_handler()
910 device_for_each_child_node(&pdev->dev, fwnode_child) { in cdns_xspi_of_get_plat_data()
915 dev_err(&pdev->dev, "Couldn't get memory chip select\n"); in cdns_xspi_of_get_plat_data()
917 return -ENXIO; in cdns_xspi_of_get_plat_data()
919 dev_err(&pdev->dev, "reg (cs) parameter value too large\n"); in cdns_xspi_of_get_plat_data()
921 return -ENXIO; in cdns_xspi_of_get_plat_data()
930 struct device *dev = cdns_xspi->dev; in cdns_xspi_print_phy_config()
934 readl(cdns_xspi->iobase + CDNS_XSPI_DLL_PHY_CTRL)); in cdns_xspi_print_phy_config()
936 readl(cdns_xspi->auxbase + CDNS_XSPI_CCP_PHY_DQ_TIMING)); in cdns_xspi_print_phy_config()
938 readl(cdns_xspi->auxbase + CDNS_XSPI_CCP_PHY_DQS_TIMING)); in cdns_xspi_print_phy_config()
940 readl(cdns_xspi->auxbase + CDNS_XSPI_CCP_PHY_GATE_LPBCK_CTRL)); in cdns_xspi_print_phy_config()
942 readl(cdns_xspi->auxbase + CDNS_XSPI_CCP_PHY_DLL_SLAVE_CTRL)); in cdns_xspi_print_phy_config()
954 for (i = GENERIC_CMD_DATA_REG_3_COUNT(len); i >= 0 ; i--) in cdns_xspi_prepare_generic()
959 for (i = GENERIC_CMD_DATA_REG_2_COUNT(len); i >= 0; i--) in cdns_xspi_prepare_generic()
963 for (i = GENERIC_CMD_DATA_REG_1_COUNT(len); i >= 0 ; i--) in cdns_xspi_prepare_generic()
976 u64 d = readq(cdns_xspi->xferbase + in marvell_xspi_read_single_qword()
977 MRVL_XFER_FUNC_CTRL_READ_DATA(cdns_xspi->current_xfer_qword)); in marvell_xspi_read_single_qword()
987 cdns_xspi->current_xfer_qword++; in marvell_xspi_read_single_qword()
988 cdns_xspi->current_xfer_qword %= MRVL_XFER_QWORD_COUNT; in marvell_xspi_read_single_qword()
993 u64 d = readq(cdns_xspi->xferbase + in cdns_xspi_finish_read()
994 MRVL_XFER_FUNC_CTRL_READ_DATA(cdns_xspi->current_xfer_qword)); in cdns_xspi_finish_read()
1004 cdns_xspi->current_xfer_qword++; in cdns_xspi_finish_read()
1005 cdns_xspi->current_xfer_qword %= MRVL_XFER_QWORD_COUNT; in cdns_xspi_finish_read()
1024 (cdns_xspi->iobase + CDNS_XSPI_CTRL_STATUS_REG, in cdns_xspi_is_stig_ready()
1036 (cdns_xspi->iobase + CDNS_XSPI_INTR_STATUS_REG, in cdns_xspi_is_sdma_ready()
1047 struct spi_device *spi = m->spi; in cdns_xspi_transfer_one_message_b0()
1056 if (!cdns_xspi->xfer_in_progress) { in cdns_xspi_transfer_one_message_b0()
1057 u32 xfer_control = readl(cdns_xspi->xferbase + MRVL_XFER_FUNC_CTRL); in cdns_xspi_transfer_one_message_b0()
1059 cdns_xspi->current_xfer_qword = 0; in cdns_xspi_transfer_one_message_b0()
1060 cdns_xspi->xfer_in_progress = true; in cdns_xspi_transfer_one_message_b0()
1067 writel(xfer_control, cdns_xspi->xferbase + MRVL_XFER_FUNC_CTRL); in cdns_xspi_transfer_one_message_b0()
1070 list_for_each_entry(t, &m->transfers, transfer_list) { in cdns_xspi_transfer_one_message_b0()
1071 u8 *txd = (u8 *) t->tx_buf; in cdns_xspi_transfer_one_message_b0()
1072 u8 *rxd = (u8 *) t->rx_buf; in cdns_xspi_transfer_one_message_b0()
1079 cdns_xspi->in_buffer = txd + 1; in cdns_xspi_transfer_one_message_b0()
1080 cdns_xspi->out_buffer = txd + 1; in cdns_xspi_transfer_one_message_b0()
1082 while (t->len) { in cdns_xspi_transfer_one_message_b0()
1084 current_transfer_len = min(max_len, t->len); in cdns_xspi_transfer_one_message_b0()
1091 return -EIO; in cdns_xspi_transfer_one_message_b0()
1095 cdns_xspi_prepare_transfer(cs, 1, current_transfer_len - 1, in cdns_xspi_transfer_one_message_b0()
1099 return -EIO; in cdns_xspi_transfer_one_message_b0()
1100 cdns_xspi->sdma_handler(cdns_xspi); in cdns_xspi_transfer_one_message_b0()
1102 return -EIO; in cdns_xspi_transfer_one_message_b0()
1104 cdns_xspi->in_buffer += current_transfer_len; in cdns_xspi_transfer_one_message_b0()
1105 cdns_xspi->out_buffer += current_transfer_len; in cdns_xspi_transfer_one_message_b0()
1115 cdns_xspi->current_xfer_qword += current_transfer_len / in cdns_xspi_transfer_one_message_b0()
1118 cdns_xspi->current_xfer_qword++; in cdns_xspi_transfer_one_message_b0()
1120 cdns_xspi->current_xfer_qword %= MRVL_XFER_QWORD_COUNT; in cdns_xspi_transfer_one_message_b0()
1122 cs_change = t->cs_change; in cdns_xspi_transfer_one_message_b0()
1123 t->len -= current_transfer_len; in cdns_xspi_transfer_one_message_b0()
1129 u32 xfer_control = readl(cdns_xspi->xferbase + MRVL_XFER_FUNC_CTRL); in cdns_xspi_transfer_one_message_b0()
1133 writel(xfer_control, cdns_xspi->xferbase + MRVL_XFER_FUNC_CTRL); in cdns_xspi_transfer_one_message_b0()
1134 cdns_xspi->xfer_in_progress = false; in cdns_xspi_transfer_one_message_b0()
1137 m->status = 0; in cdns_xspi_transfer_one_message_b0()
1145 struct device *dev = &pdev->dev; in cdns_xspi_probe()
1153 return -ENOMEM; in cdns_xspi_probe()
1155 host->mode_bits = SPI_3WIRE | SPI_TX_DUAL | SPI_TX_QUAD | in cdns_xspi_probe()
1160 cdns_xspi->driver_data = of_device_get_match_data(dev); in cdns_xspi_probe()
1161 if (!cdns_xspi->driver_data) { in cdns_xspi_probe()
1162 cdns_xspi->driver_data = acpi_device_get_match_data(dev); in cdns_xspi_probe()
1163 if (!cdns_xspi->driver_data) in cdns_xspi_probe()
1164 return -ENODEV; in cdns_xspi_probe()
1167 if (cdns_xspi->driver_data->mrvl_hw_overlay) { in cdns_xspi_probe()
1168 host->mem_ops = &marvell_xspi_mem_ops; in cdns_xspi_probe()
1169 host->transfer_one_message = cdns_xspi_transfer_one_message_b0; in cdns_xspi_probe()
1170 cdns_xspi->sdma_handler = &marvell_xspi_sdma_handle; in cdns_xspi_probe()
1171 cdns_xspi->set_interrupts_handler = &marvell_xspi_set_interrupts; in cdns_xspi_probe()
1173 host->mem_ops = &cadence_xspi_mem_ops; in cdns_xspi_probe()
1174 cdns_xspi->sdma_handler = &cdns_xspi_sdma_handle; in cdns_xspi_probe()
1175 cdns_xspi->set_interrupts_handler = &cdns_xspi_set_interrupts; in cdns_xspi_probe()
1177 host->dev.of_node = pdev->dev.of_node; in cdns_xspi_probe()
1178 host->bus_num = -1; in cdns_xspi_probe()
1182 cdns_xspi->pdev = pdev; in cdns_xspi_probe()
1183 cdns_xspi->dev = &pdev->dev; in cdns_xspi_probe()
1184 cdns_xspi->cur_cs = 0; in cdns_xspi_probe()
1186 init_completion(&cdns_xspi->cmd_complete); in cdns_xspi_probe()
1187 init_completion(&cdns_xspi->auto_cmd_complete); in cdns_xspi_probe()
1188 init_completion(&cdns_xspi->sdma_complete); in cdns_xspi_probe()
1192 return -ENODEV; in cdns_xspi_probe()
1194 cdns_xspi->iobase = devm_platform_ioremap_resource_byname(pdev, "io"); in cdns_xspi_probe()
1195 if (IS_ERR(cdns_xspi->iobase)) { in cdns_xspi_probe()
1196 cdns_xspi->iobase = devm_platform_ioremap_resource(pdev, 0); in cdns_xspi_probe()
1197 if (IS_ERR(cdns_xspi->iobase)) { in cdns_xspi_probe()
1199 return PTR_ERR(cdns_xspi->iobase); in cdns_xspi_probe()
1204 cdns_xspi->sdmabase = devm_ioremap_resource(dev, res); in cdns_xspi_probe()
1205 if (IS_ERR(cdns_xspi->sdmabase)) { in cdns_xspi_probe()
1207 cdns_xspi->sdmabase = devm_ioremap_resource(dev, res); in cdns_xspi_probe()
1208 if (IS_ERR(cdns_xspi->sdmabase)) in cdns_xspi_probe()
1209 return PTR_ERR(cdns_xspi->sdmabase); in cdns_xspi_probe()
1211 cdns_xspi->sdmasize = resource_size(res); in cdns_xspi_probe()
1213 cdns_xspi->auxbase = devm_platform_ioremap_resource_byname(pdev, "aux"); in cdns_xspi_probe()
1214 if (IS_ERR(cdns_xspi->auxbase)) { in cdns_xspi_probe()
1215 cdns_xspi->auxbase = devm_platform_ioremap_resource(pdev, 2); in cdns_xspi_probe()
1216 if (IS_ERR(cdns_xspi->auxbase)) { in cdns_xspi_probe()
1218 return PTR_ERR(cdns_xspi->auxbase); in cdns_xspi_probe()
1222 if (cdns_xspi->driver_data->mrvl_hw_overlay) { in cdns_xspi_probe()
1223 cdns_xspi->xferbase = devm_platform_ioremap_resource_byname(pdev, "xfer"); in cdns_xspi_probe()
1224 if (IS_ERR(cdns_xspi->xferbase)) { in cdns_xspi_probe()
1225 cdns_xspi->xferbase = devm_platform_ioremap_resource(pdev, 3); in cdns_xspi_probe()
1226 if (IS_ERR(cdns_xspi->xferbase)) { in cdns_xspi_probe()
1229 cdns_xspi->xferbase = cdns_xspi->iobase + 0x8000; in cdns_xspi_probe()
1234 cdns_xspi->irq = platform_get_irq(pdev, 0); in cdns_xspi_probe()
1235 if (cdns_xspi->irq < 0) in cdns_xspi_probe()
1236 return -ENXIO; in cdns_xspi_probe()
1238 ret = devm_request_irq(dev, cdns_xspi->irq, cdns_xspi_irq_handler, in cdns_xspi_probe()
1239 IRQF_SHARED, pdev->name, cdns_xspi); in cdns_xspi_probe()
1241 dev_err(dev, "Failed to request IRQ: %d\n", cdns_xspi->irq); in cdns_xspi_probe()
1245 if (cdns_xspi->driver_data->mrvl_hw_overlay) { in cdns_xspi_probe()
1258 host->num_chipselect = 1 << cdns_xspi->hw_num_banks; in cdns_xspi_probe()
1273 .compatible = "cdns,xspi-nor",
1277 .compatible = "marvell,cn10-xspi-nor",
1294 MODULE_DESCRIPTION("Cadence XSPI Controller Driver");