Lines Matching +full:pre +full:- +full:programmed

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright © 2007-2008 MontaVista Software, Inc.
10 * Author: Roy Zang <tie-fei.zang@freescale.com>
36 * fsl_lbc_addr - convert the base address
46 struct device_node *np = fsl_lbc_ctrl_dev->dev->of_node; in fsl_lbc_addr()
57 * fsl_lbc_find - find Localbus bank
70 if (!fsl_lbc_ctrl_dev || !fsl_lbc_ctrl_dev->regs) in fsl_lbc_find()
71 return -ENODEV; in fsl_lbc_find()
73 lbc = fsl_lbc_ctrl_dev->regs; in fsl_lbc_find()
74 for (i = 0; i < ARRAY_SIZE(lbc->bank); i++) { in fsl_lbc_find()
75 u32 br = in_be32(&lbc->bank[i].br); in fsl_lbc_find()
76 u32 or = in_be32(&lbc->bank[i].or); in fsl_lbc_find()
82 return -ENOENT; in fsl_lbc_find()
87 * fsl_upm_find - find pre-programmed UPM via base address
105 if (!fsl_lbc_ctrl_dev || !fsl_lbc_ctrl_dev->regs) in fsl_upm_find()
106 return -ENODEV; in fsl_upm_find()
108 lbc = fsl_lbc_ctrl_dev->regs; in fsl_upm_find()
109 br = in_be32(&lbc->bank[bank].br); in fsl_upm_find()
113 upm->mxmr = &lbc->mamr; in fsl_upm_find()
116 upm->mxmr = &lbc->mbmr; in fsl_upm_find()
119 upm->mxmr = &lbc->mcmr; in fsl_upm_find()
122 return -EINVAL; in fsl_upm_find()
127 upm->width = 8; in fsl_upm_find()
130 upm->width = 16; in fsl_upm_find()
133 upm->width = 32; in fsl_upm_find()
136 return -EINVAL; in fsl_upm_find()
144 * fsl_upm_run_pattern - actually run an UPM pattern
151 * pre-programmed AMX bits in the UPM RAM.
158 if (!fsl_lbc_ctrl_dev || !fsl_lbc_ctrl_dev->regs) in fsl_upm_run_pattern()
159 return -ENODEV; in fsl_upm_run_pattern()
163 out_be32(&fsl_lbc_ctrl_dev->regs->mar, mar); in fsl_upm_run_pattern()
165 switch (upm->width) { in fsl_upm_run_pattern()
176 ret = -EINVAL; in fsl_upm_run_pattern()
189 struct fsl_lbc_regs __iomem *lbc = ctrl->regs; in fsl_lbc_ctrl_init()
192 setbits32(&lbc->ltesr, LTESR_CLEAR); in fsl_lbc_ctrl_init()
193 out_be32(&lbc->lteatr, 0); in fsl_lbc_ctrl_init()
194 out_be32(&lbc->ltear, 0); in fsl_lbc_ctrl_init()
195 out_be32(&lbc->lteccr, LTECCR_CLEAR); in fsl_lbc_ctrl_init()
196 out_be32(&lbc->ltedr, LTEDR_ENABLE); in fsl_lbc_ctrl_init()
200 clrsetbits_be32(&lbc->lbcr, LBCR_BMT, LBCR_BMTPS); in fsl_lbc_ctrl_init()
213 struct fsl_lbc_regs __iomem *lbc = ctrl->regs; in fsl_lbc_ctrl_irq()
218 status = in_be32(&lbc->ltesr); in fsl_lbc_ctrl_irq()
224 out_be32(&lbc->ltesr, LTESR_CLEAR); in fsl_lbc_ctrl_irq()
225 out_be32(&lbc->lteatr, 0); in fsl_lbc_ctrl_irq()
226 out_be32(&lbc->ltear, 0); in fsl_lbc_ctrl_irq()
227 ctrl->irq_status = status; in fsl_lbc_ctrl_irq()
230 dev_err(ctrl->dev, "Local bus monitor time-out: " in fsl_lbc_ctrl_irq()
233 dev_err(ctrl->dev, "Write protect error: " in fsl_lbc_ctrl_irq()
236 dev_err(ctrl->dev, "Atomic write error: " in fsl_lbc_ctrl_irq()
239 dev_err(ctrl->dev, "Atomic read error: " in fsl_lbc_ctrl_irq()
242 dev_err(ctrl->dev, "Chip select error: " in fsl_lbc_ctrl_irq()
245 dev_err(ctrl->dev, "FCM command time-out: " in fsl_lbc_ctrl_irq()
248 wake_up(&ctrl->irq_wait); in fsl_lbc_ctrl_irq()
251 dev_err(ctrl->dev, "Parity or Uncorrectable ECC error: " in fsl_lbc_ctrl_irq()
254 wake_up(&ctrl->irq_wait); in fsl_lbc_ctrl_irq()
258 wake_up(&ctrl->irq_wait); in fsl_lbc_ctrl_irq()
261 dev_err(ctrl->dev, "Unknown error: " in fsl_lbc_ctrl_irq()
281 if (!dev->dev.of_node) { in fsl_lbc_ctrl_probe()
282 dev_err(&dev->dev, "Device OF-Node is NULL"); in fsl_lbc_ctrl_probe()
283 return -EFAULT; in fsl_lbc_ctrl_probe()
288 return -ENOMEM; in fsl_lbc_ctrl_probe()
290 dev_set_drvdata(&dev->dev, fsl_lbc_ctrl_dev); in fsl_lbc_ctrl_probe()
292 spin_lock_init(&fsl_lbc_ctrl_dev->lock); in fsl_lbc_ctrl_probe()
293 init_waitqueue_head(&fsl_lbc_ctrl_dev->irq_wait); in fsl_lbc_ctrl_probe()
295 fsl_lbc_ctrl_dev->regs = of_iomap(dev->dev.of_node, 0); in fsl_lbc_ctrl_probe()
296 if (!fsl_lbc_ctrl_dev->regs) { in fsl_lbc_ctrl_probe()
297 dev_err(&dev->dev, "failed to get memory region\n"); in fsl_lbc_ctrl_probe()
298 ret = -ENODEV; in fsl_lbc_ctrl_probe()
302 fsl_lbc_ctrl_dev->irq[0] = irq_of_parse_and_map(dev->dev.of_node, 0); in fsl_lbc_ctrl_probe()
303 if (!fsl_lbc_ctrl_dev->irq[0]) { in fsl_lbc_ctrl_probe()
304 dev_err(&dev->dev, "failed to get irq resource\n"); in fsl_lbc_ctrl_probe()
305 ret = -ENODEV; in fsl_lbc_ctrl_probe()
309 fsl_lbc_ctrl_dev->dev = &dev->dev; in fsl_lbc_ctrl_probe()
311 ret = fsl_lbc_ctrl_init(fsl_lbc_ctrl_dev, dev->dev.of_node); in fsl_lbc_ctrl_probe()
315 ret = request_irq(fsl_lbc_ctrl_dev->irq[0], fsl_lbc_ctrl_irq, 0, in fsl_lbc_ctrl_probe()
316 "fsl-lbc", fsl_lbc_ctrl_dev); in fsl_lbc_ctrl_probe()
318 dev_err(&dev->dev, "failed to install irq (%d)\n", in fsl_lbc_ctrl_probe()
319 fsl_lbc_ctrl_dev->irq[0]); in fsl_lbc_ctrl_probe()
320 ret = fsl_lbc_ctrl_dev->irq[0]; in fsl_lbc_ctrl_probe()
324 fsl_lbc_ctrl_dev->irq[1] = irq_of_parse_and_map(dev->dev.of_node, 1); in fsl_lbc_ctrl_probe()
325 if (fsl_lbc_ctrl_dev->irq[1]) { in fsl_lbc_ctrl_probe()
326 ret = request_irq(fsl_lbc_ctrl_dev->irq[1], fsl_lbc_ctrl_irq, in fsl_lbc_ctrl_probe()
327 IRQF_SHARED, "fsl-lbc-err", fsl_lbc_ctrl_dev); in fsl_lbc_ctrl_probe()
329 dev_err(&dev->dev, "failed to install irq (%d)\n", in fsl_lbc_ctrl_probe()
330 fsl_lbc_ctrl_dev->irq[1]); in fsl_lbc_ctrl_probe()
331 ret = fsl_lbc_ctrl_dev->irq[1]; in fsl_lbc_ctrl_probe()
337 out_be32(&fsl_lbc_ctrl_dev->regs->lteir, LTEIR_ENABLE); in fsl_lbc_ctrl_probe()
342 free_irq(fsl_lbc_ctrl_dev->irq[0], fsl_lbc_ctrl_dev); in fsl_lbc_ctrl_probe()
344 iounmap(fsl_lbc_ctrl_dev->regs); in fsl_lbc_ctrl_probe()
362 lbc = ctrl->regs; in fsl_lbc_syscore_suspend()
366 ctrl->saved_regs = kmalloc(sizeof(struct fsl_lbc_regs), GFP_KERNEL); in fsl_lbc_syscore_suspend()
367 if (!ctrl->saved_regs) in fsl_lbc_syscore_suspend()
368 return -ENOMEM; in fsl_lbc_syscore_suspend()
370 _memcpy_fromio(ctrl->saved_regs, lbc, sizeof(struct fsl_lbc_regs)); in fsl_lbc_syscore_suspend()
386 lbc = ctrl->regs; in fsl_lbc_syscore_resume()
390 if (ctrl->saved_regs) { in fsl_lbc_syscore_resume()
391 _memcpy_toio(lbc, ctrl->saved_regs, in fsl_lbc_syscore_resume()
393 kfree(ctrl->saved_regs); in fsl_lbc_syscore_resume()
394 ctrl->saved_regs = NULL; in fsl_lbc_syscore_resume()
404 { .compatible = "fsl,pq3-localbus", },
405 { .compatible = "fsl,pq2-localbus", },
406 { .compatible = "fsl,pq2pro-localbus", },
419 .name = "fsl-lbc",