diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c index 8e5c3cae811e..15674c6734c6 100644 --- a/drivers/soc/fsl/guts.c +++ b/drivers/soc/fsl/guts.c @@ -27,6 +27,23 @@ struct fsl_soc_data { u32 uid_offset; }; +enum qoriq_die { + DIE_T4240, + DIE_T1040, + DIE_T2080, + DIE_T1024, + DIE_LS1043A, + DIE_LS2080A, + DIE_LS1088A, + DIE_LS1012A, + DIE_LS1046A, + DIE_LS2088A, + DIE_LS1021A, + DIE_LX2160A, + DIE_LS1028A, + DIE_MAX, +}; + /* SoC die attribute definition for QorIQ platform */ static const struct fsl_soc_die_attr fsl_soc_die[] = { /* @@ -34,21 +51,25 @@ static const struct fsl_soc_die_attr fsl_soc_die[] = { */ /* Die: T4240, SoC: T4240/T4160/T4080 */ + [DIE_T4240] = { .die = "T4240", .svr = 0x82400000, .mask = 0xfff00000, }, /* Die: T1040, SoC: T1040/T1020/T1042/T1022 */ + [DIE_T1040] = { .die = "T1040", .svr = 0x85200000, .mask = 0xfff00000, }, /* Die: T2080, SoC: T2080/T2081 */ + [DIE_T2080] = { .die = "T2080", .svr = 0x85300000, .mask = 0xfff00000, }, /* Die: T1024, SoC: T1024/T1014/T1023/T1013 */ + [DIE_T1024] = { .die = "T1024", .svr = 0x85400000, .mask = 0xfff00000, @@ -59,46 +80,55 @@ static const struct fsl_soc_die_attr fsl_soc_die[] = { */ /* Die: LS1043A, SoC: LS1043A/LS1023A */ + [DIE_LS1043A] = { .die = "LS1043A", .svr = 0x87920000, .mask = 0xffff0000, }, /* Die: LS2080A, SoC: LS2080A/LS2040A/LS2085A */ + [DIE_LS2080A] = { .die = "LS2080A", .svr = 0x87010000, .mask = 0xff3f0000, }, /* Die: LS1088A, SoC: LS1088A/LS1048A/LS1084A/LS1044A */ + [DIE_LS1088A] = { .die = "LS1088A", .svr = 0x87030000, .mask = 0xff3f0000, }, /* Die: LS1012A, SoC: LS1012A */ + [DIE_LS1012A] = { .die = "LS1012A", .svr = 0x87040000, .mask = 0xffff0000, }, /* Die: LS1046A, SoC: LS1046A/LS1026A */ + [DIE_LS1046A] = { .die = "LS1046A", .svr = 0x87070000, .mask = 0xffff0000, }, /* Die: LS2088A, SoC: LS2088A/LS2048A/LS2084A/LS2044A */ + [DIE_LS2088A] = { .die = "LS2088A", .svr = 0x87090000, .mask = 0xff3f0000, }, /* Die: LS1021A, SoC: LS1021A/LS1020A/LS1022A */ + [DIE_LS1021A] = { .die = "LS1021A", .svr = 0x87000000, .mask = 0xfff70000, }, /* Die: LX2160A, SoC: LX2160A/LX2120A/LX2080A */ + [DIE_LX2160A] = { .die = "LX2160A", .svr = 0x87360000, .mask = 0xff3f0000, }, /* Die: LS1028A, SoC: LS1028A */ + [DIE_LS1028A] = { .die = "LS1028A", .svr = 0x870b0000, .mask = 0xff3f0000, @@ -109,6 +139,7 @@ static const struct fsl_soc_die_attr fsl_soc_die[] = { static struct fsl_soc_guts { struct ccsr_guts __iomem *dcfg_ccsr; bool little_endian; + u32 svr; } soc; static unsigned int fsl_guts_read(const void __iomem *reg) @@ -119,11 +150,16 @@ static unsigned int fsl_guts_read(const void __iomem *reg) return ioread32be(reg); } +static bool fsl_soc_die_match_one(u32 svr, const struct fsl_soc_die_attr *match) +{ + return match->svr == (svr & match->mask); +} + static const struct fsl_soc_die_attr *fsl_soc_die_match( u32 svr, const struct fsl_soc_die_attr *matches) { while (matches->svr) { - if (matches->svr == (svr & matches->mask)) + if (fsl_soc_die_match_one(svr, matches)) return matches; matches++; } @@ -202,7 +238,6 @@ static int __init fsl_guts_init(void) const struct of_device_id *match; struct device_node *np; u64 soc_uid = 0; - u32 svr; int ret; np = of_find_matching_node_and_match(NULL, fsl_guts_of_match, &match); @@ -217,7 +252,7 @@ static int __init fsl_guts_init(void) } soc.little_endian = of_property_read_bool(np, "little-endian"); - svr = fsl_guts_read(&soc.dcfg_ccsr->svr); + soc.svr = fsl_guts_read(&soc.dcfg_ccsr->svr); of_node_put(np); /* Register soc device */ @@ -231,7 +266,7 @@ static int __init fsl_guts_init(void) if (ret) of_machine_read_compatible(&soc_dev_attr->machine, 0); - soc_die = fsl_soc_die_match(svr, fsl_soc_die); + soc_die = fsl_soc_die_match(soc.svr, fsl_soc_die); if (soc_die) { soc_dev_attr->family = kasprintf(GFP_KERNEL, "QorIQ %s", soc_die->die); @@ -243,14 +278,14 @@ static int __init fsl_guts_init(void) goto err_free_soc_dev_attr; } - soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "svr:0x%08x", svr); + soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "svr:0x%08x", soc.svr); if (!soc_dev_attr->soc_id) { ret = -ENOMEM; goto err_free_family; } soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d.%d", - (svr >> 4) & 0xf, svr & 0xf); + (soc.svr >> 4) & 0xf, soc.svr & 0xf); if (!soc_dev_attr->revision) { ret = -ENOMEM; goto err_free_soc_id;