Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

EDAC/altera: Use the Altera System Manager driver

Simplify by using the Altera System Manager driver that abstracts the
differences between ARM32 and ARM64. Also allows the removal of the
Arria10 test function since this is handled by the System Manager
driver.

Signed-off-by: Thor Thayer <thor.thayer@linux.intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: James Morse <james.morse@arm.com>
Cc: linux-edac <linux-edac@vger.kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Meng.Li@windriver.com
Cc: Robert Richter <rrichter@marvell.com>
Cc: Tony Luck <tony.luck@intel.com>
Link: https://lkml.kernel.org/r/1574361048-17572-4-git-send-email-thor.thayer@linux.intel.com

authored by

Thor Thayer and committed by
Borislav Petkov
5781823f 08a260d9

+8 -124
+8 -124
drivers/edac/altera_edac.c
··· 14 14 #include <linux/interrupt.h> 15 15 #include <linux/irqchip/chained_irq.h> 16 16 #include <linux/kernel.h> 17 + #include <linux/mfd/altera-sysmgr.h> 17 18 #include <linux/mfd/syscon.h> 18 19 #include <linux/notifier.h> 19 20 #include <linux/of_address.h> ··· 276 275 return ret; 277 276 } 278 277 279 - static int socfpga_is_a10(void); 280 278 static int altr_sdram_probe(struct platform_device *pdev) 281 279 { 282 280 const struct of_device_id *id; ··· 399 399 goto err; 400 400 401 401 /* Only the Arria10 has separate IRQs */ 402 - if (socfpga_is_a10()) { 402 + if (of_machine_is_compatible("altr,socfpga-arria10")) { 403 403 /* Arria10 specific initialization */ 404 404 res = a10_init(mc_vbase); 405 405 if (res < 0) ··· 501 501 module_platform_driver(altr_sdram_edac_driver); 502 502 503 503 #endif /* CONFIG_EDAC_ALTERA_SDRAM */ 504 - 505 - /**************** Stratix 10 EDAC Memory Controller Functions ************/ 506 - 507 - /** 508 - * s10_protected_reg_write 509 - * Write to a protected SMC register. 510 - * @context: Not used. 511 - * @reg: Address of register 512 - * @value: Value to write 513 - * Return: INTEL_SIP_SMC_STATUS_OK (0) on success 514 - * INTEL_SIP_SMC_REG_ERROR on error 515 - * INTEL_SIP_SMC_RETURN_UNKNOWN_FUNCTION if not supported 516 - */ 517 - static int s10_protected_reg_write(void *context, unsigned int reg, 518 - unsigned int val) 519 - { 520 - struct arm_smccc_res result; 521 - unsigned long offset = (unsigned long)context; 522 - 523 - arm_smccc_smc(INTEL_SIP_SMC_REG_WRITE, offset + reg, val, 0, 0, 524 - 0, 0, 0, &result); 525 - 526 - return (int)result.a0; 527 - } 528 - 529 - /** 530 - * s10_protected_reg_read 531 - * Read the status of a protected SMC register 532 - * @context: Not used. 533 - * @reg: Address of register 534 - * @value: Value read. 535 - * Return: INTEL_SIP_SMC_STATUS_OK (0) on success 536 - * INTEL_SIP_SMC_REG_ERROR on error 537 - * INTEL_SIP_SMC_RETURN_UNKNOWN_FUNCTION if not supported 538 - */ 539 - static int s10_protected_reg_read(void *context, unsigned int reg, 540 - unsigned int *val) 541 - { 542 - struct arm_smccc_res result; 543 - unsigned long offset = (unsigned long)context; 544 - 545 - arm_smccc_smc(INTEL_SIP_SMC_REG_READ, offset + reg, 0, 0, 0, 546 - 0, 0, 0, &result); 547 - 548 - *val = (unsigned int)result.a1; 549 - 550 - return (int)result.a0; 551 - } 552 - 553 - static const struct regmap_config s10_sdram_regmap_cfg = { 554 - .name = "s10_ddr", 555 - .reg_bits = 32, 556 - .reg_stride = 4, 557 - .val_bits = 32, 558 - .max_register = 0xffd12228, 559 - .reg_read = s10_protected_reg_read, 560 - .reg_write = s10_protected_reg_write, 561 - .use_single_read = true, 562 - .use_single_write = true, 563 - .fast_io = true, 564 - }; 565 - 566 - /************** </Stratix10 EDAC Memory Controller Functions> ***********/ 567 504 568 505 /************************* EDAC Parent Probe *************************/ 569 506 ··· 946 1009 return ret; 947 1010 } 948 1011 949 - static int socfpga_is_a10(void) 950 - { 951 - return of_machine_is_compatible("altr,socfpga-arria10"); 952 - } 953 - 954 1012 static __init int __maybe_unused 955 1013 altr_init_a10_ecc_block(struct device_node *np, u32 irq_mask, 956 1014 u32 ecc_ctrl_en_mask, bool dual_port) ··· 961 1029 /* Get the ECC Manager - parent of the device EDACs */ 962 1030 np_eccmgr = of_get_parent(np); 963 1031 964 - if (socfpga_is_a10()) { 965 - ecc_mgr_map = syscon_regmap_lookup_by_phandle(np_eccmgr, 966 - "altr,sysmgr-syscon"); 967 - } else { 968 - struct device_node *sysmgr_np; 969 - struct resource res; 970 - uintptr_t base; 1032 + ecc_mgr_map = 1033 + altr_sysmgr_regmap_lookup_by_phandle(np_eccmgr, 1034 + "altr,sysmgr-syscon"); 971 1035 972 - sysmgr_np = of_parse_phandle(np_eccmgr, 973 - "altr,sysmgr-syscon", 0); 974 - if (!sysmgr_np) { 975 - edac_printk(KERN_ERR, EDAC_DEVICE, 976 - "Unable to find altr,sysmgr-syscon\n"); 977 - return -ENODEV; 978 - } 979 - 980 - if (of_address_to_resource(sysmgr_np, 0, &res)) { 981 - of_node_put(sysmgr_np); 982 - return -ENOMEM; 983 - } 984 - 985 - /* Need physical address for SMCC call */ 986 - base = res.start; 987 - 988 - ecc_mgr_map = regmap_init(NULL, NULL, (void *)base, 989 - &s10_sdram_regmap_cfg); 990 - of_node_put(sysmgr_np); 991 - } 992 1036 of_node_put(np_eccmgr); 993 1037 if (IS_ERR(ecc_mgr_map)) { 994 1038 edac_printk(KERN_ERR, EDAC_DEVICE, ··· 2079 2171 platform_set_drvdata(pdev, edac); 2080 2172 INIT_LIST_HEAD(&edac->a10_ecc_devices); 2081 2173 2082 - if (socfpga_is_a10()) { 2083 - edac->ecc_mgr_map = 2084 - syscon_regmap_lookup_by_phandle(pdev->dev.of_node, 2085 - "altr,sysmgr-syscon"); 2086 - } else { 2087 - struct device_node *sysmgr_np; 2088 - struct resource res; 2089 - uintptr_t base; 2090 - 2091 - sysmgr_np = of_parse_phandle(pdev->dev.of_node, 2092 - "altr,sysmgr-syscon", 0); 2093 - if (!sysmgr_np) { 2094 - edac_printk(KERN_ERR, EDAC_DEVICE, 2095 - "Unable to find altr,sysmgr-syscon\n"); 2096 - return -ENODEV; 2097 - } 2098 - 2099 - if (of_address_to_resource(sysmgr_np, 0, &res)) 2100 - return -ENOMEM; 2101 - 2102 - /* Need physical address for SMCC call */ 2103 - base = res.start; 2104 - 2105 - edac->ecc_mgr_map = devm_regmap_init(&pdev->dev, NULL, 2106 - (void *)base, 2107 - &s10_sdram_regmap_cfg); 2108 - } 2174 + edac->ecc_mgr_map = 2175 + altr_sysmgr_regmap_lookup_by_phandle(pdev->dev.of_node, 2176 + "altr,sysmgr-syscon"); 2109 2177 2110 2178 if (IS_ERR(edac->ecc_mgr_map)) { 2111 2179 edac_printk(KERN_ERR, EDAC_DEVICE,