Lines Matching +full:child +full:- +full:interrupt +full:- +full:base
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2017-2018, Intel Corporation. All rights reserved
4 * Copyright Altera Corporation (C) 2014-2016. All rights reserved.
5 * Copyright 2011-2012 Calxeda, Inc.
12 #include <linux/firmware/intel/stratix10-smc.h>
14 #include <linux/interrupt.h>
17 #include <linux/mfd/altera-sysmgr.h>
84 struct altr_sdram_mc_data *drvdata = mci->pvt_info; in altr_sdram_mc_err_handler()
85 const struct altr_sdram_prv_data *priv = drvdata->data; in altr_sdram_mc_err_handler()
88 regmap_read(drvdata->mc_vbase, priv->ecc_stat_offset, &status); in altr_sdram_mc_err_handler()
90 if (status & priv->ecc_stat_ue_mask) { in altr_sdram_mc_err_handler()
91 regmap_read(drvdata->mc_vbase, priv->ecc_daddr_offset, in altr_sdram_mc_err_handler()
93 if (priv->ecc_uecnt_offset) in altr_sdram_mc_err_handler()
94 regmap_read(drvdata->mc_vbase, priv->ecc_uecnt_offset, in altr_sdram_mc_err_handler()
99 if (status & priv->ecc_stat_ce_mask) { in altr_sdram_mc_err_handler()
100 regmap_read(drvdata->mc_vbase, priv->ecc_saddr_offset, in altr_sdram_mc_err_handler()
102 if (priv->ecc_uecnt_offset) in altr_sdram_mc_err_handler()
103 regmap_read(drvdata->mc_vbase, priv->ecc_cecnt_offset, in altr_sdram_mc_err_handler()
108 0, 0, -1, mci->ctl_name, ""); in altr_sdram_mc_err_handler()
110 regmap_write(drvdata->mc_vbase, priv->ecc_irq_clr_offset, in altr_sdram_mc_err_handler()
111 priv->ecc_irq_clr_mask); in altr_sdram_mc_err_handler()
122 struct mem_ctl_info *mci = file->private_data; in altr_sdr_mc_err_inject_write()
123 struct altr_sdram_mc_data *drvdata = mci->pvt_info; in altr_sdr_mc_err_inject_write()
124 const struct altr_sdram_prv_data *priv = drvdata->data; in altr_sdr_mc_err_inject_write()
129 ptemp = dma_alloc_coherent(mci->pdev, 16, &dma_handle, GFP_KERNEL); in altr_sdr_mc_err_inject_write()
131 dma_free_coherent(mci->pdev, 16, ptemp, dma_handle); in altr_sdr_mc_err_inject_write()
134 return -ENOMEM; in altr_sdr_mc_err_inject_write()
137 regmap_read(drvdata->mc_vbase, priv->ce_ue_trgr_offset, in altr_sdr_mc_err_inject_write()
139 read_reg &= ~(priv->ce_set_mask | priv->ue_set_mask); in altr_sdr_mc_err_inject_write()
149 regmap_write(drvdata->mc_vbase, priv->ce_ue_trgr_offset, in altr_sdr_mc_err_inject_write()
150 (read_reg | priv->ue_set_mask)); in altr_sdr_mc_err_inject_write()
156 regmap_write(drvdata->mc_vbase, priv->ce_ue_trgr_offset, in altr_sdr_mc_err_inject_write()
157 (read_reg | priv->ce_set_mask)); in altr_sdr_mc_err_inject_write()
165 regmap_write(drvdata->mc_vbase, priv->ce_ue_trgr_offset, read_reg); in altr_sdr_mc_err_inject_write()
183 dma_free_coherent(mci->pdev, 16, ptemp, dma_handle); in altr_sdr_mc_err_inject_write()
199 if (!mci->debugfs) in altr_sdr_mc_create_debugfs_nodes()
202 edac_debugfs_create_file("altr_trigger", S_IWUSR, mci->debugfs, mci, in altr_sdr_mc_create_debugfs_nodes()
226 { .compatible = "altr,sdram-edac", .data = &c5_data},
227 { .compatible = "altr,sdram-edac-a10", .data = &a10_data},
238 return -ENODEV; in a10_init()
244 return -ENODEV; in a10_init()
256 dev_name(&pdev->dev))) { in a10_unmask_irq()
259 return -EBUSY; in a10_unmask_irq()
267 ret = -ENOMEM; in a10_unmask_irq()
294 mc_vbase = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, in altr_sdram_probe()
295 "altr,sdr-syscon"); in altr_sdram_probe()
298 "regmap for altr,sdr-syscon lookup failed.\n"); in altr_sdram_probe()
299 return -ENODEV; in altr_sdram_probe()
303 priv = device_get_match_data(&pdev->dev); in altr_sdram_probe()
306 if (regmap_read(mc_vbase, priv->ecc_ctrl_offset, &read_reg) || in altr_sdram_probe()
307 ((read_reg & priv->ecc_ctl_en_mask) != priv->ecc_ctl_en_mask)) { in altr_sdram_probe()
310 return -ENODEV; in altr_sdram_probe()
317 return -ENODEV; in altr_sdram_probe()
320 /* Ensure the SDRAM Interrupt is disabled */ in altr_sdram_probe()
321 if (regmap_update_bits(mc_vbase, priv->ecc_irq_en_offset, in altr_sdram_probe()
322 priv->ecc_irq_en_mask, 0)) { in altr_sdram_probe()
325 return -ENODEV; in altr_sdram_probe()
329 if (regmap_update_bits(mc_vbase, priv->ecc_cnt_rst_offset, in altr_sdram_probe()
330 priv->ecc_cnt_rst_mask, in altr_sdram_probe()
331 priv->ecc_cnt_rst_mask)) { in altr_sdram_probe()
334 return -ENODEV; in altr_sdram_probe()
337 if (regmap_update_bits(mc_vbase, priv->ecc_cnt_rst_offset, in altr_sdram_probe()
338 priv->ecc_cnt_rst_mask, 0)) { in altr_sdram_probe()
341 return -ENODEV; in altr_sdram_probe()
363 return -ENOMEM; in altr_sdram_probe()
365 mci->pdev = &pdev->dev; in altr_sdram_probe()
366 drvdata = mci->pvt_info; in altr_sdram_probe()
367 drvdata->mc_vbase = mc_vbase; in altr_sdram_probe()
368 drvdata->data = priv; in altr_sdram_probe()
371 if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL)) { in altr_sdram_probe()
374 res = -ENOMEM; in altr_sdram_probe()
378 mci->mtype_cap = MEM_FLAG_DDR3; in altr_sdram_probe()
379 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED; in altr_sdram_probe()
380 mci->edac_cap = EDAC_FLAG_SECDED; in altr_sdram_probe()
381 mci->mod_name = EDAC_MOD_STR; in altr_sdram_probe()
382 mci->ctl_name = dev_name(&pdev->dev); in altr_sdram_probe()
383 mci->scrub_mode = SCRUB_SW_SRC; in altr_sdram_probe()
384 mci->dev_name = dev_name(&pdev->dev); in altr_sdram_probe()
386 dimm = *mci->dimms; in altr_sdram_probe()
387 dimm->nr_pages = ((mem_size - 1) >> PAGE_SHIFT) + 1; in altr_sdram_probe()
388 dimm->grain = 8; in altr_sdram_probe()
389 dimm->dtype = DEV_X8; in altr_sdram_probe()
390 dimm->mtype = MEM_DDR3; in altr_sdram_probe()
391 dimm->edac_mode = EDAC_SECDED; in altr_sdram_probe()
398 if (of_machine_is_compatible("altr,socfpga-arria10")) { in altr_sdram_probe()
404 res = devm_request_irq(&pdev->dev, irq2, in altr_sdram_probe()
406 IRQF_SHARED, dev_name(&pdev->dev), mci); in altr_sdram_probe()
410 res = -ENODEV; in altr_sdram_probe()
421 res = devm_request_irq(&pdev->dev, irq, altr_sdram_mc_err_handler, in altr_sdram_probe()
422 irqflags, dev_name(&pdev->dev), mci); in altr_sdram_probe()
426 res = -ENODEV; in altr_sdram_probe()
430 /* Infrastructure ready - enable the IRQ */ in altr_sdram_probe()
431 if (regmap_update_bits(drvdata->mc_vbase, priv->ecc_irq_en_offset, in altr_sdram_probe()
432 priv->ecc_irq_en_mask, priv->ecc_irq_en_mask)) { in altr_sdram_probe()
435 res = -ENODEV; in altr_sdram_probe()
441 devres_close_group(&pdev->dev, NULL); in altr_sdram_probe()
446 edac_mc_del_mc(&pdev->dev); in altr_sdram_probe()
448 devres_release_group(&pdev->dev, NULL); in altr_sdram_probe()
461 edac_mc_del_mc(&pdev->dev); in altr_sdram_remove()
475 return -EPERM; in altr_sdram_prepare()
504 { .compatible = "altr,socfpga-ecc-manager" },
511 of_platform_populate(pdev->dev.of_node, altr_edac_device_of_match, in altr_edac_probe()
512 NULL, &pdev->dev); in altr_edac_probe()
552 struct altr_edac_device_dev *drvdata = dci->pvt_info; in altr_edac_device_handler()
553 const struct edac_device_prv_data *priv = drvdata->data; in altr_edac_device_handler()
555 if (irq == drvdata->sb_irq) { in altr_edac_device_handler()
556 if (priv->ce_clear_mask) in altr_edac_device_handler()
557 writel(priv->ce_clear_mask, drvdata->base); in altr_edac_device_handler()
558 edac_device_handle_ce(dci, 0, 0, drvdata->edac_dev_name); in altr_edac_device_handler()
560 } else if (irq == drvdata->db_irq) { in altr_edac_device_handler()
561 if (priv->ue_clear_mask) in altr_edac_device_handler()
562 writel(priv->ue_clear_mask, drvdata->base); in altr_edac_device_handler()
563 edac_device_handle_ue(dci, 0, 0, drvdata->edac_dev_name); in altr_edac_device_handler()
582 struct edac_device_ctl_info *edac_dci = file->private_data; in altr_edac_device_trig()
583 struct altr_edac_device_dev *drvdata = edac_dci->pvt_info; in altr_edac_device_trig()
584 const struct edac_device_prv_data *priv = drvdata->data; in altr_edac_device_trig()
585 void *generic_ptr = edac_dci->dev; in altr_edac_device_trig()
588 return -EFAULT; in altr_edac_device_trig()
590 if (!priv->alloc_mem) in altr_edac_device_trig()
591 return -ENOMEM; in altr_edac_device_trig()
597 ptemp = priv->alloc_mem(priv->trig_alloc_sz, &generic_ptr); in altr_edac_device_trig()
601 return -ENOMEM; in altr_edac_device_trig()
605 error_mask = priv->ue_set_mask; in altr_edac_device_trig()
607 error_mask = priv->ce_set_mask; in altr_edac_device_trig()
614 for (i = 0; i < (priv->trig_alloc_sz / sizeof(*ptemp)); i++) { in altr_edac_device_trig()
618 result = -1; in altr_edac_device_trig()
620 writel(error_mask, (drvdata->base + priv->set_err_ofst)); in altr_edac_device_trig()
621 writel(priv->ecc_enable_mask, (drvdata->base + in altr_edac_device_trig()
622 priv->set_err_ofst)); in altr_edac_device_trig()
638 if (priv->free_mem) in altr_edac_device_trig()
639 priv->free_mem(ptemp, priv->trig_alloc_sz, generic_ptr); in altr_edac_device_trig()
673 struct altr_edac_device_dev *drvdata = edac_dci->pvt_info; in altr_create_edacdev_dbgfs()
678 drvdata->debugfs_dir = edac_debugfs_create_dir(drvdata->edac_dev_name); in altr_create_edacdev_dbgfs()
679 if (!drvdata->debugfs_dir) in altr_create_edacdev_dbgfs()
683 drvdata->debugfs_dir, edac_dci, in altr_create_edacdev_dbgfs()
684 priv->inject_fops)) in altr_create_edacdev_dbgfs()
685 debugfs_remove_recursive(drvdata->debugfs_dir); in altr_create_edacdev_dbgfs()
690 { .compatible = "altr,socfpga-l2-ecc", .data = &l2ecc_data },
693 { .compatible = "altr,socfpga-ocram-ecc", .data = &ocramecc_data },
713 struct device_node *np = pdev->dev.of_node; in altr_edac_device_probe()
714 char *ecc_name = (char *)np->name; in altr_edac_device_probe()
717 if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL)) { in altr_edac_device_probe()
720 return -ENOMEM; in altr_edac_device_probe()
727 res = -ENODEV; in altr_edac_device_probe()
731 if (!devm_request_mem_region(&pdev->dev, r->start, resource_size(r), in altr_edac_device_probe()
732 dev_name(&pdev->dev))) { in altr_edac_device_probe()
735 res = -EBUSY; in altr_edac_device_probe()
745 res = -ENOMEM; in altr_edac_device_probe()
749 drvdata = dci->pvt_info; in altr_edac_device_probe()
750 dci->dev = &pdev->dev; in altr_edac_device_probe()
752 drvdata->edac_dev_name = ecc_name; in altr_edac_device_probe()
754 drvdata->base = devm_ioremap(&pdev->dev, r->start, resource_size(r)); in altr_edac_device_probe()
755 if (!drvdata->base) { in altr_edac_device_probe()
756 res = -ENOMEM; in altr_edac_device_probe()
761 drvdata->data = of_match_node(altr_edac_device_of_match, np)->data; in altr_edac_device_probe()
764 if (drvdata->data->setup) { in altr_edac_device_probe()
765 res = drvdata->data->setup(drvdata); in altr_edac_device_probe()
770 drvdata->sb_irq = platform_get_irq(pdev, 0); in altr_edac_device_probe()
771 res = devm_request_irq(&pdev->dev, drvdata->sb_irq, in altr_edac_device_probe()
773 0, dev_name(&pdev->dev), dci); in altr_edac_device_probe()
777 drvdata->db_irq = platform_get_irq(pdev, 1); in altr_edac_device_probe()
778 res = devm_request_irq(&pdev->dev, drvdata->db_irq, in altr_edac_device_probe()
780 0, dev_name(&pdev->dev), dci); in altr_edac_device_probe()
784 dci->mod_name = "Altera ECC Manager"; in altr_edac_device_probe()
785 dci->dev_name = drvdata->edac_dev_name; in altr_edac_device_probe()
791 altr_create_edacdev_dbgfs(dci, drvdata->data); in altr_edac_device_probe()
793 devres_close_group(&pdev->dev, NULL); in altr_edac_device_probe()
800 devres_release_group(&pdev->dev, NULL); in altr_edac_device_probe()
810 struct altr_edac_device_dev *drvdata = dci->pvt_info; in altr_edac_device_remove()
812 debugfs_remove_recursive(drvdata->debugfs_dir); in altr_edac_device_remove()
813 edac_device_del_device(&pdev->dev); in altr_edac_device_remove()
832 * Can't turn on ECC here because accessing un-initialized memory will
838 void __iomem *base = device->base; in altr_check_ecc_deps() local
839 const struct edac_device_prv_data *prv = device->data; in altr_check_ecc_deps()
841 if (readl(base + prv->ecc_en_ofst) & prv->ecc_enable_mask) in altr_check_ecc_deps()
846 device->edac_dev_name); in altr_check_ecc_deps()
847 return -ENODEV; in altr_check_ecc_deps()
853 void __iomem *base = dci->base; in altr_edac_a10_ecc_irq() local
855 if (irq == dci->sb_irq) { in altr_edac_a10_ecc_irq()
857 base + ALTR_A10_ECC_INTSTAT_OFST); in altr_edac_a10_ecc_irq()
858 edac_device_handle_ce(dci->edac_dev, 0, 0, dci->edac_dev_name); in altr_edac_a10_ecc_irq()
861 } else if (irq == dci->db_irq) { in altr_edac_a10_ecc_irq()
863 base + ALTR_A10_ECC_INTSTAT_OFST); in altr_edac_a10_ecc_irq()
864 edac_device_handle_ue(dci->edac_dev, 0, 0, dci->edac_dev_name); in altr_edac_a10_ecc_irq()
865 if (dci->data->panic) in altr_edac_a10_ecc_irq()
884 return -ENODEV; in a10_get_irq_mask()
933 while (limit--) { in altr_init_memory_port()
940 ret = -EBUSY; in altr_init_memory_port()
958 ecc_name = (char *)np->name; in altr_init_a10_ecc_block()
960 /* Get the ECC Manager - parent of the device EDACs */ in altr_init_a10_ecc_block()
965 "altr,sysmgr-syscon"); in altr_init_a10_ecc_block()
970 "Unable to get syscon altr,sysmgr-syscon\n"); in altr_init_a10_ecc_block()
971 return -ENODEV; in altr_init_a10_ecc_block()
979 return -ENODEV; in altr_init_a10_ecc_block()
1008 /* Interrupt mode set to every SBERR */ in altr_init_a10_ecc_block()
1029 struct device_node *child, *np; in altr_init_a10_ecc_device_type() local
1032 "altr,socfpga-a10-ecc-manager"); in altr_init_a10_ecc_device_type()
1035 return -ENODEV; in altr_init_a10_ecc_device_type()
1038 for_each_child_of_node(np, child) { in altr_init_a10_ecc_device_type()
1042 if (!of_device_is_available(child)) in altr_init_a10_ecc_device_type()
1044 if (!of_device_is_compatible(child, compat)) in altr_init_a10_ecc_device_type()
1047 if (validate_parent_available(child)) in altr_init_a10_ecc_device_type()
1050 irq = a10_get_irq_mask(child); in altr_init_a10_ecc_device_type()
1055 pdev_id = of_match_node(altr_edac_a10_device_of_match, child); in altr_init_a10_ecc_device_type()
1060 prv = pdev_id->data; in altr_init_a10_ecc_device_type()
1064 altr_init_a10_ecc_block(child, BIT(irq), in altr_init_a10_ecc_device_type()
1065 prv->ecc_enable_mask, 0); in altr_init_a10_ecc_device_type()
1077 * A legacy U-Boot bug only enabled memory mapped access to the ECC Enable
1084 const struct edac_device_prv_data *prv = device->data; in altr_s10_sdram_check_ecc_deps()
1092 np = of_find_compatible_node(NULL, NULL, "altr,sdr-ctl"); in altr_s10_sdram_check_ecc_deps()
1099 sdram_ecc_addr = (unsigned long)sdram_addr + prv->ecc_en_ofst; in altr_s10_sdram_check_ecc_deps()
1104 if (!ret && (read_reg & prv->ecc_enable_mask)) in altr_s10_sdram_check_ecc_deps()
1110 device->edac_dev_name); in altr_s10_sdram_check_ecc_deps()
1111 return -ENODEV; in altr_s10_sdram_check_ecc_deps()
1138 np = of_find_compatible_node(NULL, NULL, "altr,socfpga-ocram-ecc"); in ocram_alloc_mem()
1184 void __iomem *base = device->base; in altr_check_ocram_deps_init() local
1193 (base + ALTR_A10_ECC_INITSTAT_OFST))) in altr_check_ocram_deps_init()
1194 return -ENODEV; in altr_check_ocram_deps_init()
1197 writel(ALTR_A10_ECC_SERRINTEN, (base + ALTR_A10_ECC_ERRINTENS_OFST)); in altr_check_ocram_deps_init()
1269 void __iomem *base = device->base; in altr_l2_check_deps() local
1270 const struct edac_device_prv_data *prv = device->data; in altr_l2_check_deps()
1272 if ((readl(base) & prv->ecc_enable_mask) == in altr_l2_check_deps()
1273 prv->ecc_enable_mask) in altr_l2_check_deps()
1278 return -ENODEV; in altr_l2_check_deps()
1285 if (irq == dci->sb_irq) { in altr_edac_a10_l2_irq()
1286 regmap_write(dci->edac->ecc_mgr_map, in altr_edac_a10_l2_irq()
1289 edac_device_handle_ce(dci->edac_dev, 0, 0, dci->edac_dev_name); in altr_edac_a10_l2_irq()
1292 } else if (irq == dci->db_irq) { in altr_edac_a10_l2_irq()
1293 regmap_write(dci->edac->ecc_mgr_map, in altr_edac_a10_l2_irq()
1296 edac_device_handle_ue(dci->edac_dev, 0, 0, dci->edac_dev_name); in altr_edac_a10_l2_irq()
1347 ret = altr_init_a10_ecc_device_type("altr,socfpga-eth-mac-ecc"); in socfpga_init_ethernet_ecc()
1377 ret = altr_init_a10_ecc_device_type("altr,socfpga-nand-ecc"); in socfpga_init_nand_ecc()
1407 ret = altr_init_a10_ecc_device_type("altr,socfpga-dma-ecc"); in socfpga_init_dma_ecc()
1437 ret = altr_init_a10_ecc_device_type("altr,socfpga-usb-ecc"); in socfpga_init_usb_ecc()
1467 ret = altr_init_a10_ecc_device_type("altr,socfpga-qspi-ecc"); in socfpga_init_qspi_ecc()
1498 char *ecc_name = "sdmmcb-ecc"; in altr_portb_setup()
1507 np = of_find_compatible_node(NULL, NULL, "altr,socfpga-sdmmc-ecc"); in altr_portb_setup()
1510 return -ENODEV; in altr_portb_setup()
1521 return -ENOMEM; in altr_portb_setup()
1525 altdev = dci->pvt_info; in altr_portb_setup()
1528 if (!devres_open_group(&altdev->ddev, altr_portb_setup, GFP_KERNEL)) in altr_portb_setup()
1529 return -ENOMEM; in altr_portb_setup()
1532 altdev->edac_dev_name = ecc_name; in altr_portb_setup()
1533 altdev->edac_idx = edac_idx; in altr_portb_setup()
1534 altdev->edac_dev = dci; in altr_portb_setup()
1535 altdev->data = prv; in altr_portb_setup()
1536 dci->dev = &altdev->ddev; in altr_portb_setup()
1537 dci->ctl_name = "Altera ECC Manager"; in altr_portb_setup()
1538 dci->mod_name = ecc_name; in altr_portb_setup()
1539 dci->dev_name = ecc_name; in altr_portb_setup()
1542 * Update the PortB IRQs - A10 has 4, S10 has 2, Index accordingly in altr_portb_setup()
1548 altdev->sb_irq = irq_of_parse_and_map(np, 1); in altr_portb_setup()
1550 altdev->sb_irq = irq_of_parse_and_map(np, 2); in altr_portb_setup()
1552 if (!altdev->sb_irq) { in altr_portb_setup()
1554 rc = -ENODEV; in altr_portb_setup()
1557 rc = devm_request_irq(&altdev->ddev, altdev->sb_irq, in altr_portb_setup()
1558 prv->ecc_irq_handler, in altr_portb_setup()
1568 rc = of_property_read_u32_index(np, "interrupts", 1, &altdev->db_irq); in altr_portb_setup()
1575 altdev->db_irq = irq_of_parse_and_map(np, 3); in altr_portb_setup()
1576 if (!altdev->db_irq) { in altr_portb_setup()
1578 rc = -ENODEV; in altr_portb_setup()
1581 rc = devm_request_irq(&altdev->ddev, altdev->db_irq, in altr_portb_setup()
1582 prv->ecc_irq_handler, in altr_portb_setup()
1595 rc = -ENOMEM; in altr_portb_setup()
1600 list_add(&altdev->next, &altdev->edac->a10_ecc_devices); in altr_portb_setup()
1602 devres_remove_group(&altdev->ddev, altr_portb_setup); in altr_portb_setup()
1608 devres_release_group(&altdev->ddev, altr_portb_setup); in altr_portb_setup()
1616 int rc = -ENODEV; in socfpga_init_sdmmc_ecc()
1617 struct device_node *child; in socfpga_init_sdmmc_ecc() local
1619 child = of_find_compatible_node(NULL, NULL, "altr,socfpga-sdmmc-ecc"); in socfpga_init_sdmmc_ecc()
1620 if (!child) in socfpga_init_sdmmc_ecc()
1621 return -ENODEV; in socfpga_init_sdmmc_ecc()
1623 if (!of_device_is_available(child)) in socfpga_init_sdmmc_ecc()
1626 if (validate_parent_available(child)) in socfpga_init_sdmmc_ecc()
1630 rc = altr_init_a10_ecc_block(child, ALTR_A10_SDMMC_IRQ_MASK, in socfpga_init_sdmmc_ecc()
1639 of_node_put(child); in socfpga_init_sdmmc_ecc()
1646 void __iomem *base = ad->base; in altr_edac_a10_ecc_irq_portb() local
1647 const struct edac_device_prv_data *priv = ad->data; in altr_edac_a10_ecc_irq_portb()
1649 if (irq == ad->sb_irq) { in altr_edac_a10_ecc_irq_portb()
1650 writel(priv->ce_clear_mask, in altr_edac_a10_ecc_irq_portb()
1651 base + ALTR_A10_ECC_INTSTAT_OFST); in altr_edac_a10_ecc_irq_portb()
1652 edac_device_handle_ce(ad->edac_dev, 0, 0, ad->edac_dev_name); in altr_edac_a10_ecc_irq_portb()
1654 } else if (irq == ad->db_irq) { in altr_edac_a10_ecc_irq_portb()
1655 writel(priv->ue_clear_mask, in altr_edac_a10_ecc_irq_portb()
1656 base + ALTR_A10_ECC_INTSTAT_OFST); in altr_edac_a10_ecc_irq_portb()
1657 edac_device_handle_ue(ad->edac_dev, 0, 0, ad->edac_dev_name); in altr_edac_a10_ecc_irq_portb()
1697 { .compatible = "altr,socfpga-a10-l2-ecc", .data = &a10_l2ecc_data },
1700 { .compatible = "altr,socfpga-a10-ocram-ecc",
1704 { .compatible = "altr,socfpga-eth-mac-ecc",
1708 { .compatible = "altr,socfpga-nand-ecc", .data = &a10_nandecc_data },
1711 { .compatible = "altr,socfpga-dma-ecc", .data = &a10_dmaecc_data },
1714 { .compatible = "altr,socfpga-usb-ecc", .data = &a10_usbecc_data },
1717 { .compatible = "altr,socfpga-qspi-ecc", .data = &a10_qspiecc_data },
1720 { .compatible = "altr,socfpga-sdmmc-ecc", .data = &a10_sdmmcecca_data },
1723 { .compatible = "altr,sdram-edac-s10", .data = &s10_sdramecc_data },
1740 struct edac_device_ctl_info *edac_dci = file->private_data; in altr_edac_a10_device_trig()
1741 struct altr_edac_device_dev *drvdata = edac_dci->pvt_info; in altr_edac_a10_device_trig()
1742 const struct edac_device_prv_data *priv = drvdata->data; in altr_edac_a10_device_trig()
1743 void __iomem *set_addr = (drvdata->base + priv->set_err_ofst); in altr_edac_a10_device_trig()
1748 return -EFAULT; in altr_edac_a10_device_trig()
1752 writel(priv->ue_set_mask, set_addr); in altr_edac_a10_device_trig()
1754 writel(priv->ce_set_mask, set_addr); in altr_edac_a10_device_trig()
1756 /* Ensure the interrupt test bits are set */ in altr_edac_a10_device_trig()
1772 struct edac_device_ctl_info *edac_dci = file->private_data; in altr_edac_a10_device_trig2()
1773 struct altr_edac_device_dev *drvdata = edac_dci->pvt_info; in altr_edac_a10_device_trig2()
1774 const struct edac_device_prv_data *priv = drvdata->data; in altr_edac_a10_device_trig2()
1775 void __iomem *set_addr = (drvdata->base + priv->set_err_ofst); in altr_edac_a10_device_trig2()
1780 return -EFAULT; in altr_edac_a10_device_trig2()
1784 writel(priv->ue_set_mask, set_addr); in altr_edac_a10_device_trig2()
1787 writel(ECC_WORD_WRITE, drvdata->base + ECC_BLK_DBYTECTRL_OFST); in altr_edac_a10_device_trig2()
1789 writel(0, drvdata->base + ECC_BLK_ADDRESS_OFST); in altr_edac_a10_device_trig2()
1791 writel(ECC_READ_EDOVR, drvdata->base + ECC_BLK_ACCCTRL_OFST); in altr_edac_a10_device_trig2()
1793 writel(ECC_XACT_KICK, drvdata->base + ECC_BLK_STARTACC_OFST); in altr_edac_a10_device_trig2()
1795 writel(readl(drvdata->base + ECC_BLK_RDATA0_OFST) ^ 0x1, in altr_edac_a10_device_trig2()
1796 drvdata->base + ECC_BLK_WDATA0_OFST); in altr_edac_a10_device_trig2()
1797 writel(readl(drvdata->base + ECC_BLK_RDATA1_OFST), in altr_edac_a10_device_trig2()
1798 drvdata->base + ECC_BLK_WDATA1_OFST); in altr_edac_a10_device_trig2()
1799 writel(readl(drvdata->base + ECC_BLK_RDATA2_OFST), in altr_edac_a10_device_trig2()
1800 drvdata->base + ECC_BLK_WDATA2_OFST); in altr_edac_a10_device_trig2()
1801 writel(readl(drvdata->base + ECC_BLK_RDATA3_OFST), in altr_edac_a10_device_trig2()
1802 drvdata->base + ECC_BLK_WDATA3_OFST); in altr_edac_a10_device_trig2()
1805 writel(readl(drvdata->base + ECC_BLK_RECC0_OFST), in altr_edac_a10_device_trig2()
1806 drvdata->base + ECC_BLK_WECC0_OFST); in altr_edac_a10_device_trig2()
1807 writel(readl(drvdata->base + ECC_BLK_RECC1_OFST), in altr_edac_a10_device_trig2()
1808 drvdata->base + ECC_BLK_WECC1_OFST); in altr_edac_a10_device_trig2()
1810 writel(ECC_WRITE_EDOVR, drvdata->base + ECC_BLK_ACCCTRL_OFST); in altr_edac_a10_device_trig2()
1812 writel(ECC_XACT_KICK, drvdata->base + ECC_BLK_STARTACC_OFST); in altr_edac_a10_device_trig2()
1814 writel(ECC_READ_EDOVR, drvdata->base + ECC_BLK_ACCCTRL_OFST); in altr_edac_a10_device_trig2()
1816 writel(ECC_XACT_KICK, drvdata->base + ECC_BLK_STARTACC_OFST); in altr_edac_a10_device_trig2()
1819 /* Ensure the interrupt test bits are set */ in altr_edac_a10_device_trig2()
1834 dberr = (irq == edac->db_irq) ? 1 : 0; in altr_edac_a10_irq_handler()
1840 regmap_read(edac->ecc_mgr_map, sm_offset, &irq_status); in altr_edac_a10_irq_handler()
1844 generic_handle_domain_irq(edac->domain, dberr * 32 + bit); in altr_edac_a10_irq_handler()
1855 if (of_device_is_compatible(np, "altr,sdram-edac-s10")) in validate_parent_available()
1859 parent = of_parse_phandle(np, "altr,ecc-parent", 0); in validate_parent_available()
1861 ret = -ENODEV; in validate_parent_available()
1873 parent = of_parse_phandle(np, "altr,sdr-syscon", 0); in get_s10_sdram_edac_resource()
1875 return -ENODEV; in get_s10_sdram_edac_resource()
1888 char *ecc_name = (char *)np->name; in altr_edac_a10_device_add()
1897 return -ENODEV; in altr_edac_a10_device_add()
1900 prv = pdev_id->data; in altr_edac_a10_device_add()
1902 return -ENODEV; in altr_edac_a10_device_add()
1905 return -ENODEV; in altr_edac_a10_device_add()
1907 if (!devres_open_group(edac->dev, altr_edac_a10_device_add, GFP_KERNEL)) in altr_edac_a10_device_add()
1908 return -ENOMEM; in altr_edac_a10_device_add()
1910 if (of_device_is_compatible(np, "altr,sdram-edac-s10")) in altr_edac_a10_device_add()
1928 rc = -ENOMEM; in altr_edac_a10_device_add()
1932 altdev = dci->pvt_info; in altr_edac_a10_device_add()
1933 dci->dev = edac->dev; in altr_edac_a10_device_add()
1934 altdev->edac_dev_name = ecc_name; in altr_edac_a10_device_add()
1935 altdev->edac_idx = edac_idx; in altr_edac_a10_device_add()
1936 altdev->edac = edac; in altr_edac_a10_device_add()
1937 altdev->edac_dev = dci; in altr_edac_a10_device_add()
1938 altdev->data = prv; in altr_edac_a10_device_add()
1939 altdev->ddev = *edac->dev; in altr_edac_a10_device_add()
1940 dci->dev = &altdev->ddev; in altr_edac_a10_device_add()
1941 dci->ctl_name = "Altera ECC Manager"; in altr_edac_a10_device_add()
1942 dci->mod_name = ecc_name; in altr_edac_a10_device_add()
1943 dci->dev_name = ecc_name; in altr_edac_a10_device_add()
1945 altdev->base = devm_ioremap_resource(edac->dev, &res); in altr_edac_a10_device_add()
1946 if (IS_ERR(altdev->base)) { in altr_edac_a10_device_add()
1947 rc = PTR_ERR(altdev->base); in altr_edac_a10_device_add()
1952 if (altdev->data->setup) { in altr_edac_a10_device_add()
1953 rc = altdev->data->setup(altdev); in altr_edac_a10_device_add()
1958 altdev->sb_irq = irq_of_parse_and_map(np, 0); in altr_edac_a10_device_add()
1959 if (!altdev->sb_irq) { in altr_edac_a10_device_add()
1961 rc = -ENODEV; in altr_edac_a10_device_add()
1964 rc = devm_request_irq(edac->dev, altdev->sb_irq, prv->ecc_irq_handler, in altr_edac_a10_device_add()
1974 rc = of_property_read_u32_index(np, "interrupts", 0, &altdev->db_irq); in altr_edac_a10_device_add()
1981 altdev->db_irq = irq_of_parse_and_map(np, 1); in altr_edac_a10_device_add()
1982 if (!altdev->db_irq) { in altr_edac_a10_device_add()
1984 rc = -ENODEV; in altr_edac_a10_device_add()
1987 rc = devm_request_irq(edac->dev, altdev->db_irq, prv->ecc_irq_handler, in altr_edac_a10_device_add()
1998 dev_err(edac->dev, "edac_device_add_device failed\n"); in altr_edac_a10_device_add()
1999 rc = -ENOMEM; in altr_edac_a10_device_add()
2005 list_add(&altdev->next, &edac->a10_ecc_devices); in altr_edac_a10_device_add()
2007 devres_remove_group(edac->dev, altr_edac_a10_device_add); in altr_edac_a10_device_add()
2014 devres_release_group(edac->dev, NULL); in altr_edac_a10_device_add()
2025 regmap_write(edac->ecc_mgr_map, A10_SYSMGR_ECC_INTMASK_SET_OFST, in a10_eccmgr_irq_mask()
2026 BIT(d->hwirq)); in a10_eccmgr_irq_mask()
2033 regmap_write(edac->ecc_mgr_map, A10_SYSMGR_ECC_INTMASK_CLR_OFST, in a10_eccmgr_irq_unmask()
2034 BIT(d->hwirq)); in a10_eccmgr_irq_unmask()
2040 struct altr_arria10_edac *edac = d->host_data; in a10_eccmgr_irqdomain_map()
2042 irq_set_chip_and_handler(irq, &edac->irq_chip, handle_simple_irq); in a10_eccmgr_irqdomain_map()
2058 /* panic routine issues reboot on non-zero panic_timeout */
2071 regmap_read(edac->ecc_mgr_map, S10_SYSMGR_ECC_INTSTAT_DERR_OFST, in s10_edac_dberr_handler()
2073 regmap_write(edac->ecc_mgr_map, S10_SYSMGR_UE_VAL_OFST, dberror); in s10_edac_dberr_handler()
2080 list_for_each(position, &edac->a10_ecc_devices) { in s10_edac_dberr_handler()
2083 if (!(BIT(ed->db_irq) & dberror)) in s10_edac_dberr_handler()
2087 ed->base + ALTR_A10_ECC_INTSTAT_OFST); in s10_edac_dberr_handler()
2088 err_addr = readl(ed->base + ALTR_S10_DERR_ADDRA_OFST); in s10_edac_dberr_handler()
2089 regmap_write(edac->ecc_mgr_map, in s10_edac_dberr_handler()
2093 ed->edac_dev_name, err_addr); in s10_edac_dberr_handler()
2110 struct device_node *child; in altr_edac_a10_probe() local
2112 edac = devm_kzalloc(&pdev->dev, sizeof(*edac), GFP_KERNEL); in altr_edac_a10_probe()
2114 return -ENOMEM; in altr_edac_a10_probe()
2116 edac->dev = &pdev->dev; in altr_edac_a10_probe()
2118 INIT_LIST_HEAD(&edac->a10_ecc_devices); in altr_edac_a10_probe()
2120 edac->ecc_mgr_map = in altr_edac_a10_probe()
2121 altr_sysmgr_regmap_lookup_by_phandle(pdev->dev.of_node, in altr_edac_a10_probe()
2122 "altr,sysmgr-syscon"); in altr_edac_a10_probe()
2124 if (IS_ERR(edac->ecc_mgr_map)) { in altr_edac_a10_probe()
2126 "Unable to get syscon altr,sysmgr-syscon\n"); in altr_edac_a10_probe()
2127 return PTR_ERR(edac->ecc_mgr_map); in altr_edac_a10_probe()
2130 edac->irq_chip.name = pdev->dev.of_node->name; in altr_edac_a10_probe()
2131 edac->irq_chip.irq_mask = a10_eccmgr_irq_mask; in altr_edac_a10_probe()
2132 edac->irq_chip.irq_unmask = a10_eccmgr_irq_unmask; in altr_edac_a10_probe()
2133 edac->domain = irq_domain_add_linear(pdev->dev.of_node, 64, in altr_edac_a10_probe()
2135 if (!edac->domain) { in altr_edac_a10_probe()
2136 dev_err(&pdev->dev, "Error adding IRQ domain\n"); in altr_edac_a10_probe()
2137 return -ENOMEM; in altr_edac_a10_probe()
2140 edac->sb_irq = platform_get_irq(pdev, 0); in altr_edac_a10_probe()
2141 if (edac->sb_irq < 0) in altr_edac_a10_probe()
2142 return edac->sb_irq; in altr_edac_a10_probe()
2144 irq_set_chained_handler_and_data(edac->sb_irq, in altr_edac_a10_probe()
2152 edac->panic_notifier.notifier_call = s10_edac_dberr_handler; in altr_edac_a10_probe()
2154 &edac->panic_notifier); in altr_edac_a10_probe()
2157 regmap_read(edac->ecc_mgr_map, S10_SYSMGR_UE_VAL_OFST, in altr_edac_a10_probe()
2160 regmap_read(edac->ecc_mgr_map, S10_SYSMGR_UE_ADDR_OFST, in altr_edac_a10_probe()
2166 regmap_write(edac->ecc_mgr_map, in altr_edac_a10_probe()
2168 regmap_write(edac->ecc_mgr_map, in altr_edac_a10_probe()
2173 edac->db_irq = platform_get_irq(pdev, 1); in altr_edac_a10_probe()
2174 if (edac->db_irq < 0) in altr_edac_a10_probe()
2175 return edac->db_irq; in altr_edac_a10_probe()
2177 irq_set_chained_handler_and_data(edac->db_irq, in altr_edac_a10_probe()
2181 for_each_child_of_node(pdev->dev.of_node, child) { in altr_edac_a10_probe()
2182 if (!of_device_is_available(child)) in altr_edac_a10_probe()
2185 if (of_match_node(altr_edac_a10_device_of_match, child)) in altr_edac_a10_probe()
2186 altr_edac_a10_device_add(edac, child); in altr_edac_a10_probe()
2189 else if (of_device_is_compatible(child, "altr,sdram-edac-a10")) in altr_edac_a10_probe()
2190 of_platform_populate(pdev->dev.of_node, in altr_edac_a10_probe()
2192 NULL, &pdev->dev); in altr_edac_a10_probe()
2200 { .compatible = "altr,socfpga-a10-ecc-manager" },
2201 { .compatible = "altr,socfpga-s10-ecc-manager" },