Lines Matching +full:ifc +full:- +full:nand

1 // SPDX-License-Identifier: GPL-2.0-or-later
29 * convert_ifc_address - convert the base address
39 * fsl_ifc_find - find IFC bank
42 * This function walks IFC banks comparing "Base address" field of the CSPR
51 if (!fsl_ifc_ctrl_dev || !fsl_ifc_ctrl_dev->gregs) in fsl_ifc_find()
52 return -ENODEV; in fsl_ifc_find()
54 for (i = 0; i < fsl_ifc_ctrl_dev->banks; i++) { in fsl_ifc_find()
55 u32 cspr = ifc_in32(&fsl_ifc_ctrl_dev->gregs->cspr_cs[i].cspr); in fsl_ifc_find()
62 return -ENOENT; in fsl_ifc_find()
68 struct fsl_ifc_global __iomem *ifc = ctrl->gregs; in fsl_ifc_ctrl_init() local
73 if (ifc_in32(&ifc->cm_evter_stat) & IFC_CM_EVTER_STAT_CSER) in fsl_ifc_ctrl_init()
74 ifc_out32(IFC_CM_EVTER_STAT_CSER, &ifc->cm_evter_stat); in fsl_ifc_ctrl_init()
77 ifc_out32(IFC_CM_EVTER_EN_CSEREN, &ifc->cm_evter_en); in fsl_ifc_ctrl_init()
80 ifc_out32(IFC_CM_EVTER_INTR_EN_CSERIREN, &ifc->cm_evter_intr_en); in fsl_ifc_ctrl_init()
81 ifc_out32(0x0, &ifc->cm_erattr0); in fsl_ifc_ctrl_init()
82 ifc_out32(0x0, &ifc->cm_erattr1); in fsl_ifc_ctrl_init()
89 struct fsl_ifc_ctrl *ctrl = dev_get_drvdata(&dev->dev); in fsl_ifc_ctrl_remove()
91 of_platform_depopulate(&dev->dev); in fsl_ifc_ctrl_remove()
92 free_irq(ctrl->nand_irq, ctrl); in fsl_ifc_ctrl_remove()
93 free_irq(ctrl->irq, ctrl); in fsl_ifc_ctrl_remove()
95 irq_dispose_mapping(ctrl->nand_irq); in fsl_ifc_ctrl_remove()
96 irq_dispose_mapping(ctrl->irq); in fsl_ifc_ctrl_remove()
98 iounmap(ctrl->gregs); in fsl_ifc_ctrl_remove()
100 dev_set_drvdata(&dev->dev, NULL); in fsl_ifc_ctrl_remove()
104 * NAND events are split between an operational interrupt which only
106 * including non-NAND errors. Whichever interrupt gets to it first
113 struct fsl_ifc_runtime __iomem *ifc = ctrl->rregs; in check_nand_stat() local
119 stat = ifc_in32(&ifc->ifc_nand.nand_evter_stat); in check_nand_stat()
121 ifc_out32(stat, &ifc->ifc_nand.nand_evter_stat); in check_nand_stat()
122 ctrl->nand_stat = stat; in check_nand_stat()
123 wake_up(&ctrl->nand_wait); in check_nand_stat()
142 * NOTE: This interrupt is used to report ifc events of various kinds,
148 struct fsl_ifc_global __iomem *ifc = ctrl->gregs; in fsl_ifc_ctrl_irq() local
153 cs_err = ifc_in32(&ifc->cm_evter_stat); in fsl_ifc_ctrl_irq()
155 dev_err(ctrl->dev, "transaction sent to IFC is not mapped to any memory bank 0x%08X\n", in fsl_ifc_ctrl_irq()
158 ifc_out32(IFC_CM_EVTER_STAT_CSER, &ifc->cm_evter_stat); in fsl_ifc_ctrl_irq()
161 status = ifc_in32(&ifc->cm_erattr0); in fsl_ifc_ctrl_irq()
162 err_addr = ifc_in32(&ifc->cm_erattr1); in fsl_ifc_ctrl_irq()
165 dev_err(ctrl->dev, "Read transaction error CM_ERATTR0 0x%08X\n", in fsl_ifc_ctrl_irq()
168 dev_err(ctrl->dev, "Write transaction error CM_ERATTR0 0x%08X\n", in fsl_ifc_ctrl_irq()
173 dev_err(ctrl->dev, "AXI ID of the error transaction 0x%08X\n", in fsl_ifc_ctrl_irq()
178 dev_err(ctrl->dev, "SRC ID of the error transaction 0x%08X\n", in fsl_ifc_ctrl_irq()
181 dev_err(ctrl->dev, "Transaction Address corresponding to error ERADDR 0x%08X\n", in fsl_ifc_ctrl_irq()
199 * resources for the NAND banks themselves are allocated
208 dev_info(&dev->dev, "Freescale Integrated Flash Controller\n"); in fsl_ifc_ctrl_probe()
210 fsl_ifc_ctrl_dev = devm_kzalloc(&dev->dev, sizeof(*fsl_ifc_ctrl_dev), in fsl_ifc_ctrl_probe()
213 return -ENOMEM; in fsl_ifc_ctrl_probe()
215 dev_set_drvdata(&dev->dev, fsl_ifc_ctrl_dev); in fsl_ifc_ctrl_probe()
217 /* IOMAP the entire IFC region */ in fsl_ifc_ctrl_probe()
218 fsl_ifc_ctrl_dev->gregs = of_iomap(dev->dev.of_node, 0); in fsl_ifc_ctrl_probe()
219 if (!fsl_ifc_ctrl_dev->gregs) { in fsl_ifc_ctrl_probe()
220 dev_err(&dev->dev, "failed to get memory region\n"); in fsl_ifc_ctrl_probe()
221 return -ENODEV; in fsl_ifc_ctrl_probe()
224 if (of_property_read_bool(dev->dev.of_node, "little-endian")) { in fsl_ifc_ctrl_probe()
225 fsl_ifc_ctrl_dev->little_endian = true; in fsl_ifc_ctrl_probe()
226 dev_dbg(&dev->dev, "IFC REGISTERS are LITTLE endian\n"); in fsl_ifc_ctrl_probe()
228 fsl_ifc_ctrl_dev->little_endian = false; in fsl_ifc_ctrl_probe()
229 dev_dbg(&dev->dev, "IFC REGISTERS are BIG endian\n"); in fsl_ifc_ctrl_probe()
232 version = ifc_in32(&fsl_ifc_ctrl_dev->gregs->ifc_rev) & in fsl_ifc_ctrl_probe()
236 dev_info(&dev->dev, "IFC version %d.%d, %d banks\n", in fsl_ifc_ctrl_probe()
239 fsl_ifc_ctrl_dev->version = version; in fsl_ifc_ctrl_probe()
240 fsl_ifc_ctrl_dev->banks = banks; in fsl_ifc_ctrl_probe()
242 addr = fsl_ifc_ctrl_dev->gregs; in fsl_ifc_ctrl_probe()
247 fsl_ifc_ctrl_dev->rregs = addr; in fsl_ifc_ctrl_probe()
250 fsl_ifc_ctrl_dev->irq = irq_of_parse_and_map(dev->dev.of_node, 0); in fsl_ifc_ctrl_probe()
251 if (fsl_ifc_ctrl_dev->irq == 0) { in fsl_ifc_ctrl_probe()
252 dev_err(&dev->dev, "failed to get irq resource for IFC\n"); in fsl_ifc_ctrl_probe()
253 ret = -ENODEV; in fsl_ifc_ctrl_probe()
257 /* get the nand machine irq */ in fsl_ifc_ctrl_probe()
258 fsl_ifc_ctrl_dev->nand_irq = in fsl_ifc_ctrl_probe()
259 irq_of_parse_and_map(dev->dev.of_node, 1); in fsl_ifc_ctrl_probe()
261 fsl_ifc_ctrl_dev->dev = &dev->dev; in fsl_ifc_ctrl_probe()
267 init_waitqueue_head(&fsl_ifc_ctrl_dev->nand_wait); in fsl_ifc_ctrl_probe()
269 ret = request_irq(fsl_ifc_ctrl_dev->irq, fsl_ifc_ctrl_irq, IRQF_SHARED, in fsl_ifc_ctrl_probe()
270 "fsl-ifc", fsl_ifc_ctrl_dev); in fsl_ifc_ctrl_probe()
272 dev_err(&dev->dev, "failed to install irq (%d)\n", in fsl_ifc_ctrl_probe()
273 fsl_ifc_ctrl_dev->irq); in fsl_ifc_ctrl_probe()
277 if (fsl_ifc_ctrl_dev->nand_irq) { in fsl_ifc_ctrl_probe()
278 ret = request_irq(fsl_ifc_ctrl_dev->nand_irq, fsl_ifc_nand_irq, in fsl_ifc_ctrl_probe()
279 0, "fsl-ifc-nand", fsl_ifc_ctrl_dev); in fsl_ifc_ctrl_probe()
281 dev_err(&dev->dev, "failed to install irq (%d)\n", in fsl_ifc_ctrl_probe()
282 fsl_ifc_ctrl_dev->nand_irq); in fsl_ifc_ctrl_probe()
287 /* legacy dts may still use "simple-bus" compatible */ in fsl_ifc_ctrl_probe()
288 ret = of_platform_default_populate(dev->dev.of_node, NULL, &dev->dev); in fsl_ifc_ctrl_probe()
295 free_irq(fsl_ifc_ctrl_dev->nand_irq, fsl_ifc_ctrl_dev); in fsl_ifc_ctrl_probe()
297 free_irq(fsl_ifc_ctrl_dev->irq, fsl_ifc_ctrl_dev); in fsl_ifc_ctrl_probe()
299 irq_dispose_mapping(fsl_ifc_ctrl_dev->nand_irq); in fsl_ifc_ctrl_probe()
300 irq_dispose_mapping(fsl_ifc_ctrl_dev->irq); in fsl_ifc_ctrl_probe()
302 iounmap(fsl_ifc_ctrl_dev->gregs); in fsl_ifc_ctrl_probe()
308 .compatible = "fsl,ifc",
315 .name = "fsl-ifc",