Lines Matching full:edac
3 * APM X-Gene SoC EDAC (error detection and correction)
11 #include <linux/edac.h>
66 static void xgene_edac_pcp_rd(struct xgene_edac *edac, u32 reg, u32 *val) in xgene_edac_pcp_rd() argument
68 *val = readl(edac->pcp_csr + reg); in xgene_edac_pcp_rd()
71 static void xgene_edac_pcp_clrbits(struct xgene_edac *edac, u32 reg, in xgene_edac_pcp_clrbits() argument
76 spin_lock(&edac->lock); in xgene_edac_pcp_clrbits()
77 val = readl(edac->pcp_csr + reg); in xgene_edac_pcp_clrbits()
79 writel(val, edac->pcp_csr + reg); in xgene_edac_pcp_clrbits()
80 spin_unlock(&edac->lock); in xgene_edac_pcp_clrbits()
83 static void xgene_edac_pcp_setbits(struct xgene_edac *edac, u32 reg, in xgene_edac_pcp_setbits() argument
88 spin_lock(&edac->lock); in xgene_edac_pcp_setbits()
89 val = readl(edac->pcp_csr + reg); in xgene_edac_pcp_setbits()
91 writel(val, edac->pcp_csr + reg); in xgene_edac_pcp_setbits()
92 spin_unlock(&edac->lock); in xgene_edac_pcp_setbits()
135 struct xgene_edac *edac; member
185 xgene_edac_pcp_rd(ctx->edac, PCPHPERRINTSTS, &pcp_hp_stat); in xgene_edac_mc_check()
186 xgene_edac_pcp_rd(ctx->edac, PCPLPERRINTSTS, &pcp_lp_stat); in xgene_edac_mc_check()
255 mutex_lock(&ctx->edac->mc_lock); in xgene_edac_mc_irq_ctl()
267 ctx->edac->mc_registered_mask |= 1 << ctx->mcu_id; in xgene_edac_mc_irq_ctl()
270 if (ctx->edac->mc_registered_mask == in xgene_edac_mc_irq_ctl()
271 ctx->edac->mc_active_mask) { in xgene_edac_mc_irq_ctl()
273 xgene_edac_pcp_clrbits(ctx->edac, PCPHPERRINTMSK, in xgene_edac_mc_irq_ctl()
276 xgene_edac_pcp_clrbits(ctx->edac, PCPLPERRINTMSK, in xgene_edac_mc_irq_ctl()
297 xgene_edac_pcp_setbits(ctx->edac, PCPHPERRINTMSK, in xgene_edac_mc_irq_ctl()
299 xgene_edac_pcp_setbits(ctx->edac, PCPLPERRINTMSK, in xgene_edac_mc_irq_ctl()
303 ctx->edac->mc_registered_mask &= ~(1 << ctx->mcu_id); in xgene_edac_mc_irq_ctl()
306 mutex_unlock(&ctx->edac->mc_lock); in xgene_edac_mc_irq_ctl()
314 if (regmap_read(ctx->edac->csw_map, CSW_CSWCR, ®)) in xgene_edac_mc_is_active()
322 if (regmap_read(ctx->edac->mcbb_map, MCBADDRMR, ®)) in xgene_edac_mc_is_active()
330 if (regmap_read(ctx->edac->mcba_map, MCBADDRMR, ®)) in xgene_edac_mc_is_active()
336 if (!ctx->edac->mc_active_mask) in xgene_edac_mc_is_active()
337 ctx->edac->mc_active_mask = mcu_mask; in xgene_edac_mc_is_active()
342 static int xgene_edac_mc_add(struct xgene_edac *edac, struct device_node *np) in xgene_edac_mc_add() argument
352 tmp_ctx.edac = edac; in xgene_edac_mc_add()
354 if (!devres_open_group(edac->dev, xgene_edac_mc_add, GFP_KERNEL)) in xgene_edac_mc_add()
359 dev_err(edac->dev, "no MCU resource address\n"); in xgene_edac_mc_add()
362 tmp_ctx.mcu_csr = devm_ioremap_resource(edac->dev, &res); in xgene_edac_mc_add()
364 dev_err(edac->dev, "unable to map MCU resource\n"); in xgene_edac_mc_add()
371 dev_err(edac->dev, "no memory-controller property\n"); in xgene_edac_mc_add()
414 dev_err(edac->dev, "edac_mc_add_mc failed\n"); in xgene_edac_mc_add()
421 list_add(&ctx->next, &edac->mcus); in xgene_edac_mc_add()
425 devres_remove_group(edac->dev, xgene_edac_mc_add); in xgene_edac_mc_add()
427 dev_info(edac->dev, "X-Gene EDAC MC registered\n"); in xgene_edac_mc_add()
433 devres_release_group(edac->dev, xgene_edac_mc_add); in xgene_edac_mc_add()
512 struct xgene_edac *edac; member
740 xgene_edac_pcp_rd(ctx->edac, PCPHPERRINTSTS, &pcp_hp_stat); in xgene_edac_pmd_check()
790 xgene_edac_pcp_clrbits(ctx->edac, PCPHPERRINTMSK, in xgene_edac_pmd_hw_ctl()
793 xgene_edac_pcp_setbits(ctx->edac, PCPHPERRINTMSK, in xgene_edac_pmd_hw_ctl()
867 if (!IS_ENABLED(CONFIG_EDAC_DEBUG) || !ctx->edac->dfs) in xgene_edac_pmd_create_debugfs_nodes()
871 dbgfs_dir = edac_debugfs_create_dir_at(name, ctx->edac->dfs); in xgene_edac_pmd_create_debugfs_nodes()
886 static int xgene_edac_pmd_add(struct xgene_edac *edac, struct device_node *np, in xgene_edac_pmd_add() argument
897 if (!devres_open_group(edac->dev, xgene_edac_pmd_add, GFP_KERNEL)) in xgene_edac_pmd_add()
902 dev_err(edac->dev, "no pmd-controller property\n"); in xgene_edac_pmd_add()
906 rc = regmap_read(edac->efuse_map, 0, &val); in xgene_edac_pmd_add()
926 ctx->edac = edac; in xgene_edac_pmd_add()
928 ctx->ddev = *edac->dev; in xgene_edac_pmd_add()
937 dev_err(edac->dev, "no PMD resource address\n"); in xgene_edac_pmd_add()
940 ctx->pmd_csr = devm_ioremap_resource(edac->dev, &res); in xgene_edac_pmd_add()
942 dev_err(edac->dev, in xgene_edac_pmd_add()
955 dev_err(edac->dev, "edac_device_add_device failed\n"); in xgene_edac_pmd_add()
963 list_add(&ctx->next, &edac->pmds); in xgene_edac_pmd_add()
967 devres_remove_group(edac->dev, xgene_edac_pmd_add); in xgene_edac_pmd_add()
969 dev_info(edac->dev, "X-Gene EDAC PMD%d registered\n", ctx->pmd); in xgene_edac_pmd_add()
975 devres_release_group(edac->dev, xgene_edac_pmd_add); in xgene_edac_pmd_add()
1020 struct xgene_edac *edac; member
1133 xgene_edac_pcp_clrbits(ctx->edac, PCPHPERRINTMSK, in xgene_edac_l3_hw_init()
1135 xgene_edac_pcp_clrbits(ctx->edac, PCPLPERRINTMSK, in xgene_edac_l3_hw_init()
1138 xgene_edac_pcp_setbits(ctx->edac, PCPHPERRINTMSK, in xgene_edac_l3_hw_init()
1140 xgene_edac_pcp_setbits(ctx->edac, PCPLPERRINTMSK, in xgene_edac_l3_hw_init()
1171 if (!IS_ENABLED(CONFIG_EDAC_DEBUG) || !ctx->edac->dfs) in xgene_edac_l3_create_debugfs_nodes()
1175 dbgfs_dir = edac_debugfs_create_dir_at(name, ctx->edac->dfs); in xgene_edac_l3_create_debugfs_nodes()
1183 static int xgene_edac_l3_add(struct xgene_edac *edac, struct device_node *np, in xgene_edac_l3_add() argument
1193 if (!devres_open_group(edac->dev, xgene_edac_l3_add, GFP_KERNEL)) in xgene_edac_l3_add()
1198 dev_err(edac->dev, "no L3 resource address\n"); in xgene_edac_l3_add()
1201 dev_csr = devm_ioremap_resource(edac->dev, &res); in xgene_edac_l3_add()
1203 dev_err(edac->dev, in xgene_edac_l3_add()
1221 ctx->edac = edac; in xgene_edac_l3_add()
1223 ctx->ddev = *edac->dev; in xgene_edac_l3_add()
1237 dev_err(edac->dev, "failed edac_device_add_device()\n"); in xgene_edac_l3_add()
1245 list_add(&ctx->next, &edac->l3s); in xgene_edac_l3_add()
1249 devres_remove_group(edac->dev, xgene_edac_l3_add); in xgene_edac_l3_add()
1251 dev_info(edac->dev, "X-Gene EDAC L3 registered\n"); in xgene_edac_l3_add()
1257 devres_release_group(edac->dev, xgene_edac_l3_add); in xgene_edac_l3_add()
1266 edac_device_del_device(l3->edac->dev); in xgene_edac_l3_remove()
1470 if (!ctx->edac->rb_map) in xgene_edac_rb_report()
1480 if (regmap_read(ctx->edac->rb_map, RBCSR, ®)) in xgene_edac_rb_report()
1486 if (regmap_read(ctx->edac->rb_map, RBEIR, ®)) in xgene_edac_rb_report()
1505 if (regmap_write(ctx->edac->rb_map, RBEIR, 0)) in xgene_edac_rb_report()
1507 if (regmap_write(ctx->edac->rb_map, RBCSR, 0)) in xgene_edac_rb_report()
1642 xgene_edac_pcp_rd(ctx->edac, PCPHPERRINTSTS, &pcp_hp_stat); in xgene_edac_soc_check()
1643 xgene_edac_pcp_rd(ctx->edac, PCPLPERRINTSTS, &pcp_lp_stat); in xgene_edac_soc_check()
1644 xgene_edac_pcp_rd(ctx->edac, MEMERRINTSTS, ®); in xgene_edac_soc_check()
1693 xgene_edac_pcp_clrbits(ctx->edac, PCPHPERRINTMSK, in xgene_edac_soc_hw_init()
1698 xgene_edac_pcp_clrbits(ctx->edac, PCPLPERRINTMSK, in xgene_edac_soc_hw_init()
1701 xgene_edac_pcp_setbits(ctx->edac, PCPHPERRINTMSK, in xgene_edac_soc_hw_init()
1706 xgene_edac_pcp_setbits(ctx->edac, PCPLPERRINTMSK, in xgene_edac_soc_hw_init()
1717 xgene_edac_pcp_setbits(ctx->edac, MEMERRINTMSK, in xgene_edac_soc_hw_init()
1722 static int xgene_edac_soc_add(struct xgene_edac *edac, struct device_node *np, in xgene_edac_soc_add() argument
1732 if (!devres_open_group(edac->dev, xgene_edac_soc_add, GFP_KERNEL)) in xgene_edac_soc_add()
1737 dev_err(edac->dev, "no SoC resource address\n"); in xgene_edac_soc_add()
1740 dev_csr = devm_ioremap_resource(edac->dev, &res); in xgene_edac_soc_add()
1742 dev_err(edac->dev, in xgene_edac_soc_add()
1760 ctx->edac = edac; in xgene_edac_soc_add()
1762 ctx->ddev = *edac->dev; in xgene_edac_soc_add()
1774 dev_err(edac->dev, "failed edac_device_add_device()\n"); in xgene_edac_soc_add()
1782 list_add(&ctx->next, &edac->socs); in xgene_edac_soc_add()
1786 devres_remove_group(edac->dev, xgene_edac_soc_add); in xgene_edac_soc_add()
1788 dev_info(edac->dev, "X-Gene EDAC SoC registered\n"); in xgene_edac_soc_add()
1795 devres_release_group(edac->dev, xgene_edac_soc_add); in xgene_edac_soc_add()
1804 edac_device_del_device(soc->edac->dev); in xgene_edac_soc_remove()
1844 struct xgene_edac *edac; in xgene_edac_probe() local
1849 edac = devm_kzalloc(&pdev->dev, sizeof(*edac), GFP_KERNEL); in xgene_edac_probe()
1850 if (!edac) in xgene_edac_probe()
1853 edac->dev = &pdev->dev; in xgene_edac_probe()
1854 platform_set_drvdata(pdev, edac); in xgene_edac_probe()
1855 INIT_LIST_HEAD(&edac->mcus); in xgene_edac_probe()
1856 INIT_LIST_HEAD(&edac->pmds); in xgene_edac_probe()
1857 INIT_LIST_HEAD(&edac->l3s); in xgene_edac_probe()
1858 INIT_LIST_HEAD(&edac->socs); in xgene_edac_probe()
1859 spin_lock_init(&edac->lock); in xgene_edac_probe()
1860 mutex_init(&edac->mc_lock); in xgene_edac_probe()
1862 edac->csw_map = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, in xgene_edac_probe()
1864 if (IS_ERR(edac->csw_map)) { in xgene_edac_probe()
1865 dev_err(edac->dev, "unable to get syscon regmap csw\n"); in xgene_edac_probe()
1866 rc = PTR_ERR(edac->csw_map); in xgene_edac_probe()
1870 edac->mcba_map = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, in xgene_edac_probe()
1872 if (IS_ERR(edac->mcba_map)) { in xgene_edac_probe()
1873 dev_err(edac->dev, "unable to get syscon regmap mcba\n"); in xgene_edac_probe()
1874 rc = PTR_ERR(edac->mcba_map); in xgene_edac_probe()
1878 edac->mcbb_map = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, in xgene_edac_probe()
1880 if (IS_ERR(edac->mcbb_map)) { in xgene_edac_probe()
1881 dev_err(edac->dev, "unable to get syscon regmap mcbb\n"); in xgene_edac_probe()
1882 rc = PTR_ERR(edac->mcbb_map); in xgene_edac_probe()
1885 edac->efuse_map = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, in xgene_edac_probe()
1887 if (IS_ERR(edac->efuse_map)) { in xgene_edac_probe()
1888 dev_err(edac->dev, "unable to get syscon regmap efuse\n"); in xgene_edac_probe()
1889 rc = PTR_ERR(edac->efuse_map); in xgene_edac_probe()
1897 edac->rb_map = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, in xgene_edac_probe()
1899 if (IS_ERR(edac->rb_map)) { in xgene_edac_probe()
1900 dev_warn(edac->dev, "missing syscon regmap rb\n"); in xgene_edac_probe()
1901 edac->rb_map = NULL; in xgene_edac_probe()
1905 edac->pcp_csr = devm_ioremap_resource(&pdev->dev, res); in xgene_edac_probe()
1906 if (IS_ERR(edac->pcp_csr)) { in xgene_edac_probe()
1908 rc = PTR_ERR(edac->pcp_csr); in xgene_edac_probe()
1925 dev_name(&pdev->dev), edac); in xgene_edac_probe()
1934 edac->dfs = edac_debugfs_create_dir(pdev->dev.kobj.name); in xgene_edac_probe()
1939 if (of_device_is_compatible(child, "apm,xgene-edac-mc")) in xgene_edac_probe()
1940 xgene_edac_mc_add(edac, child); in xgene_edac_probe()
1941 if (of_device_is_compatible(child, "apm,xgene-edac-pmd")) in xgene_edac_probe()
1942 xgene_edac_pmd_add(edac, child, 1); in xgene_edac_probe()
1943 if (of_device_is_compatible(child, "apm,xgene-edac-pmd-v2")) in xgene_edac_probe()
1944 xgene_edac_pmd_add(edac, child, 2); in xgene_edac_probe()
1945 if (of_device_is_compatible(child, "apm,xgene-edac-l3")) in xgene_edac_probe()
1946 xgene_edac_l3_add(edac, child, 1); in xgene_edac_probe()
1947 if (of_device_is_compatible(child, "apm,xgene-edac-l3-v2")) in xgene_edac_probe()
1948 xgene_edac_l3_add(edac, child, 2); in xgene_edac_probe()
1949 if (of_device_is_compatible(child, "apm,xgene-edac-soc")) in xgene_edac_probe()
1950 xgene_edac_soc_add(edac, child, 0); in xgene_edac_probe()
1951 if (of_device_is_compatible(child, "apm,xgene-edac-soc-v1")) in xgene_edac_probe()
1952 xgene_edac_soc_add(edac, child, 1); in xgene_edac_probe()
1963 struct xgene_edac *edac = dev_get_drvdata(&pdev->dev); in xgene_edac_remove() local
1971 list_for_each_entry_safe(mcu, temp_mcu, &edac->mcus, next) in xgene_edac_remove()
1974 list_for_each_entry_safe(pmd, temp_pmd, &edac->pmds, next) in xgene_edac_remove()
1977 list_for_each_entry_safe(node, temp_node, &edac->l3s, next) in xgene_edac_remove()
1980 list_for_each_entry_safe(node, temp_node, &edac->socs, next) in xgene_edac_remove()
1985 { .compatible = "apm,xgene-edac" },
1994 .name = "xgene-edac",
2019 "EDAC fails to register\n"); in xgene_edac_init()
2038 MODULE_DESCRIPTION("APM X-Gene EDAC driver");
2041 "EDAC error reporting state: 0=Poll, 2=Interrupt");