Skip to content

Commit 5781823

Browse files
tthayer-intelsuryasaimadhu
authored andcommitted
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
1 parent 08a260d commit 5781823

1 file changed

Lines changed: 8 additions & 124 deletions

File tree

drivers/edac/altera_edac.c

Lines changed: 8 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/interrupt.h>
1515
#include <linux/irqchip/chained_irq.h>
1616
#include <linux/kernel.h>
17+
#include <linux/mfd/altera-sysmgr.h>
1718
#include <linux/mfd/syscon.h>
1819
#include <linux/notifier.h>
1920
#include <linux/of_address.h>
@@ -275,7 +276,6 @@ static int a10_unmask_irq(struct platform_device *pdev, u32 mask)
275276
return ret;
276277
}
277278

278-
static int socfpga_is_a10(void);
279279
static int altr_sdram_probe(struct platform_device *pdev)
280280
{
281281
const struct of_device_id *id;
@@ -399,7 +399,7 @@ static int altr_sdram_probe(struct platform_device *pdev)
399399
goto err;
400400

401401
/* Only the Arria10 has separate IRQs */
402-
if (socfpga_is_a10()) {
402+
if (of_machine_is_compatible("altr,socfpga-arria10")) {
403403
/* Arria10 specific initialization */
404404
res = a10_init(mc_vbase);
405405
if (res < 0)
@@ -502,69 +502,6 @@ module_platform_driver(altr_sdram_edac_driver);
502502

503503
#endif /* CONFIG_EDAC_ALTERA_SDRAM */
504504

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-
568505
/************************* EDAC Parent Probe *************************/
569506

570507
static const struct of_device_id altr_edac_device_of_match[];
@@ -1009,11 +946,6 @@ static int __maybe_unused altr_init_memory_port(void __iomem *ioaddr, int port)
1009946
return ret;
1010947
}
1011948

1012-
static int socfpga_is_a10(void)
1013-
{
1014-
return of_machine_is_compatible("altr,socfpga-arria10");
1015-
}
1016-
1017949
static __init int __maybe_unused
1018950
altr_init_a10_ecc_block(struct device_node *np, u32 irq_mask,
1019951
u32 ecc_ctrl_en_mask, bool dual_port)
@@ -1029,34 +961,10 @@ altr_init_a10_ecc_block(struct device_node *np, u32 irq_mask,
1029961
/* Get the ECC Manager - parent of the device EDACs */
1030962
np_eccmgr = of_get_parent(np);
1031963

1032-
if (socfpga_is_a10()) {
1033-
ecc_mgr_map = syscon_regmap_lookup_by_phandle(np_eccmgr,
1034-
"altr,sysmgr-syscon");
1035-
} else {
1036-
struct device_node *sysmgr_np;
1037-
struct resource res;
1038-
uintptr_t base;
1039-
1040-
sysmgr_np = of_parse_phandle(np_eccmgr,
1041-
"altr,sysmgr-syscon", 0);
1042-
if (!sysmgr_np) {
1043-
edac_printk(KERN_ERR, EDAC_DEVICE,
1044-
"Unable to find altr,sysmgr-syscon\n");
1045-
return -ENODEV;
1046-
}
964+
ecc_mgr_map =
965+
altr_sysmgr_regmap_lookup_by_phandle(np_eccmgr,
966+
"altr,sysmgr-syscon");
1047967

1048-
if (of_address_to_resource(sysmgr_np, 0, &res)) {
1049-
of_node_put(sysmgr_np);
1050-
return -ENOMEM;
1051-
}
1052-
1053-
/* Need physical address for SMCC call */
1054-
base = res.start;
1055-
1056-
ecc_mgr_map = regmap_init(NULL, NULL, (void *)base,
1057-
&s10_sdram_regmap_cfg);
1058-
of_node_put(sysmgr_np);
1059-
}
1060968
of_node_put(np_eccmgr);
1061969
if (IS_ERR(ecc_mgr_map)) {
1062970
edac_printk(KERN_ERR, EDAC_DEVICE,
@@ -2171,33 +2079,9 @@ static int altr_edac_a10_probe(struct platform_device *pdev)
21712079
platform_set_drvdata(pdev, edac);
21722080
INIT_LIST_HEAD(&edac->a10_ecc_devices);
21732081

2174-
if (socfpga_is_a10()) {
2175-
edac->ecc_mgr_map =
2176-
syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
2177-
"altr,sysmgr-syscon");
2178-
} else {
2179-
struct device_node *sysmgr_np;
2180-
struct resource res;
2181-
uintptr_t base;
2182-
2183-
sysmgr_np = of_parse_phandle(pdev->dev.of_node,
2184-
"altr,sysmgr-syscon", 0);
2185-
if (!sysmgr_np) {
2186-
edac_printk(KERN_ERR, EDAC_DEVICE,
2187-
"Unable to find altr,sysmgr-syscon\n");
2188-
return -ENODEV;
2189-
}
2190-
2191-
if (of_address_to_resource(sysmgr_np, 0, &res))
2192-
return -ENOMEM;
2193-
2194-
/* Need physical address for SMCC call */
2195-
base = res.start;
2196-
2197-
edac->ecc_mgr_map = devm_regmap_init(&pdev->dev, NULL,
2198-
(void *)base,
2199-
&s10_sdram_regmap_cfg);
2200-
}
2082+
edac->ecc_mgr_map =
2083+
altr_sysmgr_regmap_lookup_by_phandle(pdev->dev.of_node,
2084+
"altr,sysmgr-syscon");
22012085

22022086
if (IS_ERR(edac->ecc_mgr_map)) {
22032087
edac_printk(KERN_ERR, EDAC_DEVICE,

0 commit comments

Comments
 (0)