• Home
  • Raw
  • Download

Lines Matching refs:f

380 static inline int needs_ip_only(struct nxp_fspi *f)  in needs_ip_only()  argument
382 return f->devtype_data->quirks & FSPI_QUIRK_USE_IP_ONLY; in needs_ip_only()
392 static void fspi_writel(struct nxp_fspi *f, u32 val, void __iomem *addr) in fspi_writel() argument
394 if (f->devtype_data->little_endian) in fspi_writel()
400 static u32 fspi_readl(struct nxp_fspi *f, void __iomem *addr) in fspi_readl() argument
402 if (f->devtype_data->little_endian) in fspi_readl()
410 struct nxp_fspi *f = dev_id; in nxp_fspi_irq_handler() local
414 reg = fspi_readl(f, f->iobase + FSPI_INTR); in nxp_fspi_irq_handler()
415 fspi_writel(f, FSPI_INTR_IPCMDDONE, f->iobase + FSPI_INTR); in nxp_fspi_irq_handler()
418 complete(&f->c); in nxp_fspi_irq_handler()
423 static int nxp_fspi_check_buswidth(struct nxp_fspi *f, u8 width) in nxp_fspi_check_buswidth() argument
439 struct nxp_fspi *f = spi_controller_get_devdata(mem->spi->master); in nxp_fspi_supports_op() local
442 ret = nxp_fspi_check_buswidth(f, op->cmd.buswidth); in nxp_fspi_supports_op()
445 ret |= nxp_fspi_check_buswidth(f, op->addr.buswidth); in nxp_fspi_supports_op()
448 ret |= nxp_fspi_check_buswidth(f, op->dummy.buswidth); in nxp_fspi_supports_op()
451 ret |= nxp_fspi_check_buswidth(f, op->data.buswidth); in nxp_fspi_supports_op()
467 if (op->addr.val >= f->memmap_phy_size) in nxp_fspi_supports_op()
477 (op->data.nbytes > f->devtype_data->ahb_buf_size || in nxp_fspi_supports_op()
478 (op->data.nbytes > f->devtype_data->rxfifo - 4 && in nxp_fspi_supports_op()
483 op->data.nbytes > f->devtype_data->txfifo) in nxp_fspi_supports_op()
490 static int fspi_readl_poll_tout(struct nxp_fspi *f, void __iomem *base, in fspi_readl_poll_tout() argument
496 if (!f->devtype_data->little_endian) in fspi_readl_poll_tout()
512 static inline void nxp_fspi_invalid(struct nxp_fspi *f) in nxp_fspi_invalid() argument
517 reg = fspi_readl(f, f->iobase + FSPI_MCR0); in nxp_fspi_invalid()
518 fspi_writel(f, reg | FSPI_MCR0_SWRST, f->iobase + FSPI_MCR0); in nxp_fspi_invalid()
521 ret = fspi_readl_poll_tout(f, f->iobase + FSPI_MCR0, in nxp_fspi_invalid()
526 static void nxp_fspi_prepare_lut(struct nxp_fspi *f, in nxp_fspi_prepare_lut() argument
529 void __iomem *base = f->iobase; in nxp_fspi_prepare_lut()
572 fspi_writel(f, FSPI_LUTKEY_VALUE, f->iobase + FSPI_LUTKEY); in nxp_fspi_prepare_lut()
573 fspi_writel(f, FSPI_LCKER_UNLOCK, f->iobase + FSPI_LCKCR); in nxp_fspi_prepare_lut()
577 fspi_writel(f, lutval[i], base + FSPI_LUT_REG(i)); in nxp_fspi_prepare_lut()
579 dev_dbg(f->dev, "CMD[%x] lutval[0:%x \t 1:%x \t 2:%x \t 3:%x], size: 0x%08x\n", in nxp_fspi_prepare_lut()
583 fspi_writel(f, FSPI_LUTKEY_VALUE, f->iobase + FSPI_LUTKEY); in nxp_fspi_prepare_lut()
584 fspi_writel(f, FSPI_LCKER_LOCK, f->iobase + FSPI_LCKCR); in nxp_fspi_prepare_lut()
587 static int nxp_fspi_clk_prep_enable(struct nxp_fspi *f) in nxp_fspi_clk_prep_enable() argument
591 if (is_acpi_node(dev_fwnode(f->dev))) in nxp_fspi_clk_prep_enable()
594 ret = clk_prepare_enable(f->clk_en); in nxp_fspi_clk_prep_enable()
598 ret = clk_prepare_enable(f->clk); in nxp_fspi_clk_prep_enable()
600 clk_disable_unprepare(f->clk_en); in nxp_fspi_clk_prep_enable()
607 static int nxp_fspi_clk_disable_unprep(struct nxp_fspi *f) in nxp_fspi_clk_disable_unprep() argument
609 if (is_acpi_node(dev_fwnode(f->dev))) in nxp_fspi_clk_disable_unprep()
612 clk_disable_unprepare(f->clk); in nxp_fspi_clk_disable_unprep()
613 clk_disable_unprepare(f->clk_en); in nxp_fspi_clk_disable_unprep()
656 static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi) in nxp_fspi_select_mem() argument
666 if (f->selected == spi->chip_select) in nxp_fspi_select_mem()
670 fspi_writel(f, 0, f->iobase + FSPI_FLSHA1CR0); in nxp_fspi_select_mem()
671 fspi_writel(f, 0, f->iobase + FSPI_FLSHA2CR0); in nxp_fspi_select_mem()
672 fspi_writel(f, 0, f->iobase + FSPI_FLSHB1CR0); in nxp_fspi_select_mem()
673 fspi_writel(f, 0, f->iobase + FSPI_FLSHB2CR0); in nxp_fspi_select_mem()
676 size_kb = FSPI_FLSHXCR0_SZ(f->memmap_phy_size); in nxp_fspi_select_mem()
678 fspi_writel(f, size_kb, f->iobase + FSPI_FLSHA1CR0 + in nxp_fspi_select_mem()
681 dev_dbg(f->dev, "Slave device [CS:%x] selected\n", spi->chip_select); in nxp_fspi_select_mem()
683 nxp_fspi_clk_disable_unprep(f); in nxp_fspi_select_mem()
685 ret = clk_set_rate(f->clk, rate); in nxp_fspi_select_mem()
689 ret = nxp_fspi_clk_prep_enable(f); in nxp_fspi_select_mem()
693 f->selected = spi->chip_select; in nxp_fspi_select_mem()
696 static int nxp_fspi_read_ahb(struct nxp_fspi *f, const struct spi_mem_op *op) in nxp_fspi_read_ahb() argument
702 if ((!f->ahb_addr) || start < f->memmap_start || in nxp_fspi_read_ahb()
703 start + len > f->memmap_start + f->memmap_len) { in nxp_fspi_read_ahb()
704 if (f->ahb_addr) in nxp_fspi_read_ahb()
705 iounmap(f->ahb_addr); in nxp_fspi_read_ahb()
707 f->memmap_start = start; in nxp_fspi_read_ahb()
708 f->memmap_len = len > NXP_FSPI_MIN_IOMAP ? in nxp_fspi_read_ahb()
711 f->ahb_addr = ioremap(f->memmap_phy + f->memmap_start, in nxp_fspi_read_ahb()
712 f->memmap_len); in nxp_fspi_read_ahb()
714 if (!f->ahb_addr) { in nxp_fspi_read_ahb()
715 dev_err(f->dev, "failed to alloc memory\n"); in nxp_fspi_read_ahb()
722 f->ahb_addr + start - f->memmap_start, len); in nxp_fspi_read_ahb()
727 static void nxp_fspi_fill_txfifo(struct nxp_fspi *f, in nxp_fspi_fill_txfifo() argument
730 void __iomem *base = f->iobase; in nxp_fspi_fill_txfifo()
735 fspi_writel(f, FSPI_IPTXFCR_CLR, base + FSPI_IPTXFCR); in nxp_fspi_fill_txfifo()
744 ret = fspi_readl_poll_tout(f, f->iobase + FSPI_INTR, in nxp_fspi_fill_txfifo()
749 fspi_writel(f, *(u32 *) (buf + i), base + FSPI_TFDR); in nxp_fspi_fill_txfifo()
750 fspi_writel(f, *(u32 *) (buf + i + 4), base + FSPI_TFDR + 4); in nxp_fspi_fill_txfifo()
751 fspi_writel(f, FSPI_INTR_IPTXWE, base + FSPI_INTR); in nxp_fspi_fill_txfifo()
758 ret = fspi_readl_poll_tout(f, f->iobase + FSPI_INTR, in nxp_fspi_fill_txfifo()
765 fspi_writel(f, data, base + FSPI_TFDR + j); in nxp_fspi_fill_txfifo()
767 fspi_writel(f, FSPI_INTR_IPTXWE, base + FSPI_INTR); in nxp_fspi_fill_txfifo()
771 static void nxp_fspi_read_rxfifo(struct nxp_fspi *f, in nxp_fspi_read_rxfifo() argument
774 void __iomem *base = f->iobase; in nxp_fspi_read_rxfifo()
785 ret = fspi_readl_poll_tout(f, f->iobase + FSPI_INTR, in nxp_fspi_read_rxfifo()
790 *(u32 *)(buf + i) = fspi_readl(f, base + FSPI_RFDR); in nxp_fspi_read_rxfifo()
791 *(u32 *)(buf + i + 4) = fspi_readl(f, base + FSPI_RFDR + 4); in nxp_fspi_read_rxfifo()
793 fspi_writel(f, FSPI_INTR_IPRXWA, base + FSPI_INTR); in nxp_fspi_read_rxfifo()
802 ret = fspi_readl_poll_tout(f, f->iobase + FSPI_INTR, in nxp_fspi_read_rxfifo()
809 tmp = fspi_readl(f, base + FSPI_RFDR + j); in nxp_fspi_read_rxfifo()
817 fspi_writel(f, FSPI_IPRXFCR_CLR, base + FSPI_IPRXFCR); in nxp_fspi_read_rxfifo()
819 fspi_writel(f, FSPI_INTR_IPRXWA, base + FSPI_INTR); in nxp_fspi_read_rxfifo()
822 static int nxp_fspi_do_op(struct nxp_fspi *f, const struct spi_mem_op *op) in nxp_fspi_do_op() argument
824 void __iomem *base = f->iobase; in nxp_fspi_do_op()
829 reg = fspi_readl(f, base + FSPI_IPRXFCR); in nxp_fspi_do_op()
833 fspi_writel(f, reg, base + FSPI_IPRXFCR); in nxp_fspi_do_op()
835 init_completion(&f->c); in nxp_fspi_do_op()
837 fspi_writel(f, op->addr.val, base + FSPI_IPCR0); in nxp_fspi_do_op()
843 fspi_writel(f, op->data.nbytes | in nxp_fspi_do_op()
849 fspi_writel(f, FSPI_IPCMD_TRG, base + FSPI_IPCMD); in nxp_fspi_do_op()
852 if (!wait_for_completion_timeout(&f->c, msecs_to_jiffies(1000))) in nxp_fspi_do_op()
857 nxp_fspi_read_rxfifo(f, op); in nxp_fspi_do_op()
864 struct nxp_fspi *f = spi_controller_get_devdata(mem->spi->master); in nxp_fspi_exec_op() local
867 mutex_lock(&f->lock); in nxp_fspi_exec_op()
870 err = fspi_readl_poll_tout(f, f->iobase + FSPI_STS0, in nxp_fspi_exec_op()
874 nxp_fspi_select_mem(f, mem->spi); in nxp_fspi_exec_op()
876 nxp_fspi_prepare_lut(f, op); in nxp_fspi_exec_op()
883 if (op->data.nbytes > (f->devtype_data->rxfifo - 4) && in nxp_fspi_exec_op()
885 !needs_ip_only(f)) { in nxp_fspi_exec_op()
886 err = nxp_fspi_read_ahb(f, op); in nxp_fspi_exec_op()
889 nxp_fspi_fill_txfifo(f, op); in nxp_fspi_exec_op()
891 err = nxp_fspi_do_op(f, op); in nxp_fspi_exec_op()
895 nxp_fspi_invalid(f); in nxp_fspi_exec_op()
897 mutex_unlock(&f->lock); in nxp_fspi_exec_op()
904 struct nxp_fspi *f = spi_controller_get_devdata(mem->spi->master); in nxp_fspi_adjust_op_size() local
907 if (op->data.nbytes > f->devtype_data->txfifo) in nxp_fspi_adjust_op_size()
908 op->data.nbytes = f->devtype_data->txfifo; in nxp_fspi_adjust_op_size()
910 if (op->data.nbytes > f->devtype_data->ahb_buf_size) in nxp_fspi_adjust_op_size()
911 op->data.nbytes = f->devtype_data->ahb_buf_size; in nxp_fspi_adjust_op_size()
912 else if (op->data.nbytes > (f->devtype_data->rxfifo - 4)) in nxp_fspi_adjust_op_size()
918 needs_ip_only(f) && in nxp_fspi_adjust_op_size()
919 op->data.nbytes > f->devtype_data->rxfifo) in nxp_fspi_adjust_op_size()
920 op->data.nbytes = f->devtype_data->rxfifo; in nxp_fspi_adjust_op_size()
925 static void erratum_err050568(struct nxp_fspi *f) in erratum_err050568() argument
937 dev_dbg(f->dev, "Errata applicable only for LS1028A\n"); in erratum_err050568()
943 dev_err(f->dev, "No syscon regmap\n"); in erratum_err050568()
952 dev_dbg(f->dev, "val: 0x%08x, sys_pll_ratio: %d\n", val, sys_pll_ratio); in erratum_err050568()
956 f->devtype_data->quirks |= FSPI_QUIRK_USE_IP_ONLY; in erratum_err050568()
961 dev_err(f->dev, "Errata cannot be executed. Read via IP bus may not work\n"); in erratum_err050568()
964 static int nxp_fspi_default_setup(struct nxp_fspi *f) in nxp_fspi_default_setup() argument
966 void __iomem *base = f->iobase; in nxp_fspi_default_setup()
971 nxp_fspi_clk_disable_unprep(f); in nxp_fspi_default_setup()
974 ret = clk_set_rate(f->clk, 20000000); in nxp_fspi_default_setup()
978 ret = nxp_fspi_clk_prep_enable(f); in nxp_fspi_default_setup()
988 if (of_device_is_compatible(f->dev->of_node, "nxp,lx2160a-fspi")) in nxp_fspi_default_setup()
989 erratum_err050568(f); in nxp_fspi_default_setup()
993 ret = fspi_readl_poll_tout(f, f->iobase + FSPI_MCR0, in nxp_fspi_default_setup()
998 fspi_writel(f, FSPI_MCR0_MDIS, base + FSPI_MCR0); in nxp_fspi_default_setup()
1001 fspi_writel(f, FSPI_DLLACR_OVRDEN, base + FSPI_DLLACR); in nxp_fspi_default_setup()
1002 fspi_writel(f, FSPI_DLLBCR_OVRDEN, base + FSPI_DLLBCR); in nxp_fspi_default_setup()
1005 fspi_writel(f, FSPI_MCR0_AHB_TIMEOUT(0xFF) | in nxp_fspi_default_setup()
1013 reg = fspi_readl(f, f->iobase + FSPI_MCR2); in nxp_fspi_default_setup()
1015 fspi_writel(f, reg, base + FSPI_MCR2); in nxp_fspi_default_setup()
1019 fspi_writel(f, 0, base + FSPI_AHBRX_BUF0CR0 + 4 * i); in nxp_fspi_default_setup()
1025 fspi_writel(f, (f->devtype_data->ahb_buf_size / 8 | in nxp_fspi_default_setup()
1029 fspi_writel(f, FSPI_AHBCR_PREF_EN | FSPI_AHBCR_RDADDROPT, in nxp_fspi_default_setup()
1034 fspi_writel(f, reg, base + FSPI_FLSHA1CR1); in nxp_fspi_default_setup()
1035 fspi_writel(f, reg, base + FSPI_FLSHA2CR1); in nxp_fspi_default_setup()
1036 fspi_writel(f, reg, base + FSPI_FLSHB1CR1); in nxp_fspi_default_setup()
1037 fspi_writel(f, reg, base + FSPI_FLSHB2CR1); in nxp_fspi_default_setup()
1040 fspi_writel(f, SEQID_LUT, base + FSPI_FLSHA1CR2); in nxp_fspi_default_setup()
1041 fspi_writel(f, SEQID_LUT, base + FSPI_FLSHA2CR2); in nxp_fspi_default_setup()
1042 fspi_writel(f, SEQID_LUT, base + FSPI_FLSHB1CR2); in nxp_fspi_default_setup()
1043 fspi_writel(f, SEQID_LUT, base + FSPI_FLSHB2CR2); in nxp_fspi_default_setup()
1045 f->selected = -1; in nxp_fspi_default_setup()
1048 fspi_writel(f, FSPI_INTEN_IPCMDDONE, base + FSPI_INTEN); in nxp_fspi_default_setup()
1055 struct nxp_fspi *f = spi_controller_get_devdata(mem->spi->master); in nxp_fspi_get_name() local
1060 if (of_get_available_child_count(f->dev->of_node) == 1) in nxp_fspi_get_name()
1061 return dev_name(f->dev); in nxp_fspi_get_name()
1064 "%s-%d", dev_name(f->dev), in nxp_fspi_get_name()
1088 struct nxp_fspi *f; in nxp_fspi_probe() local
1092 ctlr = spi_alloc_master(&pdev->dev, sizeof(*f)); in nxp_fspi_probe()
1099 f = spi_controller_get_devdata(ctlr); in nxp_fspi_probe()
1100 f->dev = dev; in nxp_fspi_probe()
1101 f->devtype_data = (struct nxp_fspi_devtype_data *)device_get_match_data(dev); in nxp_fspi_probe()
1102 if (!f->devtype_data) { in nxp_fspi_probe()
1107 platform_set_drvdata(pdev, f); in nxp_fspi_probe()
1110 if (is_acpi_node(dev_fwnode(f->dev))) in nxp_fspi_probe()
1116 f->iobase = devm_ioremap_resource(dev, res); in nxp_fspi_probe()
1117 if (IS_ERR(f->iobase)) { in nxp_fspi_probe()
1118 ret = PTR_ERR(f->iobase); in nxp_fspi_probe()
1123 if (is_acpi_node(dev_fwnode(f->dev))) in nxp_fspi_probe()
1135 f->memmap_phy = res->start; in nxp_fspi_probe()
1136 f->memmap_phy_size = resource_size(res); in nxp_fspi_probe()
1140 f->clk_en = devm_clk_get(dev, "fspi_en"); in nxp_fspi_probe()
1141 if (IS_ERR(f->clk_en)) { in nxp_fspi_probe()
1142 ret = PTR_ERR(f->clk_en); in nxp_fspi_probe()
1146 f->clk = devm_clk_get(dev, "fspi"); in nxp_fspi_probe()
1147 if (IS_ERR(f->clk)) { in nxp_fspi_probe()
1148 ret = PTR_ERR(f->clk); in nxp_fspi_probe()
1152 ret = nxp_fspi_clk_prep_enable(f); in nxp_fspi_probe()
1160 reg = fspi_readl(f, f->iobase + FSPI_INTR); in nxp_fspi_probe()
1162 fspi_writel(f, reg, f->iobase + FSPI_INTR); in nxp_fspi_probe()
1170 nxp_fspi_irq_handler, 0, pdev->name, f); in nxp_fspi_probe()
1176 mutex_init(&f->lock); in nxp_fspi_probe()
1182 nxp_fspi_default_setup(f); in nxp_fspi_probe()
1193 mutex_destroy(&f->lock); in nxp_fspi_probe()
1196 nxp_fspi_clk_disable_unprep(f); in nxp_fspi_probe()
1207 struct nxp_fspi *f = platform_get_drvdata(pdev); in nxp_fspi_remove() local
1210 fspi_writel(f, FSPI_MCR0_MDIS, f->iobase + FSPI_MCR0); in nxp_fspi_remove()
1212 nxp_fspi_clk_disable_unprep(f); in nxp_fspi_remove()
1214 mutex_destroy(&f->lock); in nxp_fspi_remove()
1216 if (f->ahb_addr) in nxp_fspi_remove()
1217 iounmap(f->ahb_addr); in nxp_fspi_remove()
1229 struct nxp_fspi *f = dev_get_drvdata(dev); in nxp_fspi_resume() local
1231 nxp_fspi_default_setup(f); in nxp_fspi_resume()