* [PATCH v2 0/2] ARM: OMAP2+: Export SoC information to userspace using SoC infrastructure @ 2013-02-06 18:59 ` Ruslan Bilovol 0 siblings, 0 replies; 11+ messages in thread From: Ruslan Bilovol @ 2013-02-06 18:59 UTC (permalink / raw) To: tony, linux, linux-arm-kernel, linux-omap, linux-kernel Hi, This patch series is an attempt to export some OMAP SoC information (like name, revision etc.) to userspace. The first patch does some unification of OMAP SoC information representation in current sources. Second patch adds exactly needed changes using exists in Linux kernel SoC infrastructure. ----------------------------------------- v2: - changed cpu_* -> soc_* variable names - rebased on top of 'omap-for-v3.9/soc' branch of tmlind/linux-omap tree Ruslan Bilovol (2): ARM: OMAP2+: SoC name and revision unification ARM: OMAP2+: Export SoC information to userspace arch/arm/mach-omap2/common.h | 8 +++ arch/arm/mach-omap2/id.c | 154 +++++++++++++++++++++++++++++++----------- arch/arm/mach-omap2/io.c | 1 + arch/arm/plat-omap/Kconfig | 1 + 4 files changed, 126 insertions(+), 38 deletions(-) -- 1.7.9.5 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 0/2] ARM: OMAP2+: Export SoC information to userspace using SoC infrastructure @ 2013-02-06 18:59 ` Ruslan Bilovol 0 siblings, 0 replies; 11+ messages in thread From: Ruslan Bilovol @ 2013-02-06 18:59 UTC (permalink / raw) To: linux-arm-kernel Hi, This patch series is an attempt to export some OMAP SoC information (like name, revision etc.) to userspace. The first patch does some unification of OMAP SoC information representation in current sources. Second patch adds exactly needed changes using exists in Linux kernel SoC infrastructure. ----------------------------------------- v2: - changed cpu_* -> soc_* variable names - rebased on top of 'omap-for-v3.9/soc' branch of tmlind/linux-omap tree Ruslan Bilovol (2): ARM: OMAP2+: SoC name and revision unification ARM: OMAP2+: Export SoC information to userspace arch/arm/mach-omap2/common.h | 8 +++ arch/arm/mach-omap2/id.c | 154 +++++++++++++++++++++++++++++++----------- arch/arm/mach-omap2/io.c | 1 + arch/arm/plat-omap/Kconfig | 1 + 4 files changed, 126 insertions(+), 38 deletions(-) -- 1.7.9.5 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 1/2] ARM: OMAP2+: SoC name and revision unification 2013-02-06 18:59 ` Ruslan Bilovol @ 2013-02-06 18:59 ` Ruslan Bilovol -1 siblings, 0 replies; 11+ messages in thread From: Ruslan Bilovol @ 2013-02-06 18:59 UTC (permalink / raw) To: tony, linux, linux-arm-kernel, linux-omap, linux-kernel This is a long story where for each new generation of OMAP we used different approaches for creating strings for SoCs names and revisions that this patch fixes. It makes future exporting of this information to SoC infrastructure easier. Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com> --- arch/arm/mach-omap2/id.c | 89 ++++++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 38 deletions(-) diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c index 8a68f1e..b16a432 100644 --- a/arch/arm/mach-omap2/id.c +++ b/arch/arm/mach-omap2/id.c @@ -31,8 +31,11 @@ #define OMAP4_SILICON_TYPE_STANDARD 0x01 #define OMAP4_SILICON_TYPE_PERFORMANCE 0x02 +#define OMAP_SOC_MAX_NAME_LENGTH 16 + static unsigned int omap_revision; -static const char *cpu_rev; +static char soc_name[OMAP_SOC_MAX_NAME_LENGTH]; +static char soc_rev[OMAP_SOC_MAX_NAME_LENGTH]; u32 omap_features; unsigned int omap_rev(void) @@ -169,9 +172,12 @@ void __init omap2xxx_check_revision(void) j = i; } - pr_info("OMAP%04x", omap_rev() >> 16); + sprintf(soc_name, "OMAP%04x", omap_rev() >> 16); + sprintf(soc_rev, "ES%x", (omap_rev() >> 12) & 0xf); + + pr_info("%s", soc_name); if ((omap_rev() >> 8) & 0x0f) - pr_info("ES%x", (omap_rev() >> 12) & 0xf); + pr_info("%s", soc_rev); pr_info("\n"); } @@ -181,8 +187,7 @@ void __init omap2xxx_check_revision(void) static void __init omap3_cpuinfo(void) { - const char *cpu_name; - + const char *omap3_soc_name; /* * OMAP3430 and OMAP3530 are assumed to be same. * @@ -191,28 +196,30 @@ static void __init omap3_cpuinfo(void) * and CPU class bits. */ if (cpu_is_omap3630()) { - cpu_name = "OMAP3630"; + omap3_soc_name = "OMAP3630"; } else if (soc_is_am35xx()) { - cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505"; + omap3_soc_name = (omap3_has_sgx()) ? "AM3517" : "AM3505"; } else if (cpu_is_ti816x()) { - cpu_name = "TI816X"; + omap3_soc_name = "TI816X"; } else if (soc_is_am335x()) { - cpu_name = "AM335X"; + omap3_soc_name = "AM335X"; } else if (cpu_is_ti814x()) { - cpu_name = "TI814X"; + omap3_soc_name = "TI814X"; } else if (omap3_has_iva() && omap3_has_sgx()) { /* OMAP3430, OMAP3525, OMAP3515, OMAP3503 devices */ - cpu_name = "OMAP3430/3530"; + omap3_soc_name = "OMAP3430/3530"; } else if (omap3_has_iva()) { - cpu_name = "OMAP3525"; + omap3_soc_name = "OMAP3525"; } else if (omap3_has_sgx()) { - cpu_name = "OMAP3515"; + omap3_soc_name = "OMAP3515"; } else { - cpu_name = "OMAP3503"; + omap3_soc_name = "OMAP3503"; } + sprintf(soc_name, "%s", omap3_soc_name); + /* Print verbose information */ - pr_info("%s ES%s (", cpu_name, cpu_rev); + pr_info("%s %s (", soc_name, soc_rev); OMAP3_SHOW_FEATURE(l2cache); OMAP3_SHOW_FEATURE(iva); @@ -291,6 +298,7 @@ void __init ti81xx_check_features(void) void __init omap3xxx_check_revision(void) { + const char *omap3_soc_rev; u32 cpuid, idcode; u16 hawkeye; u8 rev; @@ -303,7 +311,7 @@ void __init omap3xxx_check_revision(void) cpuid = read_cpuid(CPUID_ID); if ((((cpuid >> 4) & 0xfff) == 0xc08) && ((cpuid & 0xf) == 0x0)) { omap_revision = OMAP3430_REV_ES1_0; - cpu_rev = "1.0"; + omap3_soc_rev = "ES1.0"; return; } @@ -324,26 +332,26 @@ void __init omap3xxx_check_revision(void) case 0: /* Take care of early samples */ case 1: omap_revision = OMAP3430_REV_ES2_0; - cpu_rev = "2.0"; + omap3_soc_rev = "ES2.0"; break; case 2: omap_revision = OMAP3430_REV_ES2_1; - cpu_rev = "2.1"; + omap3_soc_rev = "ES2.1"; break; case 3: omap_revision = OMAP3430_REV_ES3_0; - cpu_rev = "3.0"; + omap3_soc_rev = "ES3.0"; break; case 4: omap_revision = OMAP3430_REV_ES3_1; - cpu_rev = "3.1"; + omap3_soc_rev = "ES3.1"; break; case 7: /* FALLTHROUGH */ default: /* Use the latest known revision as default */ omap_revision = OMAP3430_REV_ES3_1_2; - cpu_rev = "3.1.2"; + omap3_soc_rev = "ES3.1.2"; } break; case 0xb868: @@ -356,13 +364,13 @@ void __init omap3xxx_check_revision(void) switch (rev) { case 0: omap_revision = AM35XX_REV_ES1_0; - cpu_rev = "1.0"; + omap3_soc_rev = "ES1.0"; break; case 1: /* FALLTHROUGH */ default: omap_revision = AM35XX_REV_ES1_1; - cpu_rev = "1.1"; + omap3_soc_rev = "ES1.1"; } break; case 0xb891: @@ -371,30 +379,30 @@ void __init omap3xxx_check_revision(void) switch(rev) { case 0: /* Take care of early samples */ omap_revision = OMAP3630_REV_ES1_0; - cpu_rev = "1.0"; + omap3_soc_rev = "1.0"; break; case 1: omap_revision = OMAP3630_REV_ES1_1; - cpu_rev = "1.1"; + omap3_soc_rev = "ES1.1"; break; case 2: /* FALLTHROUGH */ default: omap_revision = OMAP3630_REV_ES1_2; - cpu_rev = "1.2"; + omap3_soc_rev = "ES1.2"; } break; case 0xb81e: switch (rev) { case 0: omap_revision = TI8168_REV_ES1_0; - cpu_rev = "1.0"; + omap3_soc_rev = "ES1.0"; break; case 1: /* FALLTHROUGH */ default: omap_revision = TI8168_REV_ES1_1; - cpu_rev = "1.1"; + omap3_soc_rev = "ES1.1"; break; } break; @@ -402,13 +410,13 @@ void __init omap3xxx_check_revision(void) switch (rev) { case 0: omap_revision = AM335X_REV_ES1_0; - cpu_rev = "1.0"; + omap3_soc_rev = "1.0"; break; case 1: /* FALLTHROUGH */ default: omap_revision = AM335X_REV_ES2_0; - cpu_rev = "2.0"; + omap3_soc_rev = "2.0"; break; } break; @@ -418,26 +426,27 @@ void __init omap3xxx_check_revision(void) /* FALLTHROUGH */ case 1: omap_revision = TI8148_REV_ES1_0; - cpu_rev = "1.0"; + omap3_soc_rev = "ES1.0"; break; case 2: omap_revision = TI8148_REV_ES2_0; - cpu_rev = "2.0"; + omap3_soc_rev = "ES2.0"; break; case 3: /* FALLTHROUGH */ default: omap_revision = TI8148_REV_ES2_1; - cpu_rev = "2.1"; + omap3_soc_rev = "ES2.1"; break; } break; default: /* Unknown default to latest silicon rev as default */ omap_revision = OMAP3630_REV_ES1_2; - cpu_rev = "1.2"; + omap3_soc_rev = "ES1.2"; pr_warn("Warning: unknown chip type; assuming OMAP3630ES1.2\n"); } + sprintf(soc_rev, "%s", omap3_soc_rev); } void __init omap4xxx_check_revision(void) @@ -512,8 +521,10 @@ void __init omap4xxx_check_revision(void) omap_revision = OMAP4430_REV_ES2_3; } - pr_info("OMAP%04x ES%d.%d\n", omap_rev() >> 16, - ((omap_rev() >> 12) & 0xf), ((omap_rev() >> 8) & 0xf)); + sprintf(soc_name, "OMAP%04x", omap_rev() >> 16); + sprintf(soc_rev, "ES%d.%d", (omap_rev() >> 12) & 0xf, + (omap_rev() >> 8) & 0xf); + pr_info("%s %s\n", soc_name, soc_rev); } void __init omap5xxx_check_revision(void) @@ -547,8 +558,10 @@ void __init omap5xxx_check_revision(void) omap_revision = OMAP5430_REV_ES1_0; } - pr_info("OMAP%04x ES%d.0\n", - omap_rev() >> 16, ((omap_rev() >> 12) & 0xf)); + sprintf(soc_name, "OMAP%04x", omap_rev() >> 16); + sprintf(soc_rev, "ES%d.0", (omap_rev() >> 12) & 0xf); + + pr_info("%s %s\n", soc_name, soc_rev); } /* -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 1/2] ARM: OMAP2+: SoC name and revision unification @ 2013-02-06 18:59 ` Ruslan Bilovol 0 siblings, 0 replies; 11+ messages in thread From: Ruslan Bilovol @ 2013-02-06 18:59 UTC (permalink / raw) To: linux-arm-kernel This is a long story where for each new generation of OMAP we used different approaches for creating strings for SoCs names and revisions that this patch fixes. It makes future exporting of this information to SoC infrastructure easier. Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com> --- arch/arm/mach-omap2/id.c | 89 ++++++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 38 deletions(-) diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c index 8a68f1e..b16a432 100644 --- a/arch/arm/mach-omap2/id.c +++ b/arch/arm/mach-omap2/id.c @@ -31,8 +31,11 @@ #define OMAP4_SILICON_TYPE_STANDARD 0x01 #define OMAP4_SILICON_TYPE_PERFORMANCE 0x02 +#define OMAP_SOC_MAX_NAME_LENGTH 16 + static unsigned int omap_revision; -static const char *cpu_rev; +static char soc_name[OMAP_SOC_MAX_NAME_LENGTH]; +static char soc_rev[OMAP_SOC_MAX_NAME_LENGTH]; u32 omap_features; unsigned int omap_rev(void) @@ -169,9 +172,12 @@ void __init omap2xxx_check_revision(void) j = i; } - pr_info("OMAP%04x", omap_rev() >> 16); + sprintf(soc_name, "OMAP%04x", omap_rev() >> 16); + sprintf(soc_rev, "ES%x", (omap_rev() >> 12) & 0xf); + + pr_info("%s", soc_name); if ((omap_rev() >> 8) & 0x0f) - pr_info("ES%x", (omap_rev() >> 12) & 0xf); + pr_info("%s", soc_rev); pr_info("\n"); } @@ -181,8 +187,7 @@ void __init omap2xxx_check_revision(void) static void __init omap3_cpuinfo(void) { - const char *cpu_name; - + const char *omap3_soc_name; /* * OMAP3430 and OMAP3530 are assumed to be same. * @@ -191,28 +196,30 @@ static void __init omap3_cpuinfo(void) * and CPU class bits. */ if (cpu_is_omap3630()) { - cpu_name = "OMAP3630"; + omap3_soc_name = "OMAP3630"; } else if (soc_is_am35xx()) { - cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505"; + omap3_soc_name = (omap3_has_sgx()) ? "AM3517" : "AM3505"; } else if (cpu_is_ti816x()) { - cpu_name = "TI816X"; + omap3_soc_name = "TI816X"; } else if (soc_is_am335x()) { - cpu_name = "AM335X"; + omap3_soc_name = "AM335X"; } else if (cpu_is_ti814x()) { - cpu_name = "TI814X"; + omap3_soc_name = "TI814X"; } else if (omap3_has_iva() && omap3_has_sgx()) { /* OMAP3430, OMAP3525, OMAP3515, OMAP3503 devices */ - cpu_name = "OMAP3430/3530"; + omap3_soc_name = "OMAP3430/3530"; } else if (omap3_has_iva()) { - cpu_name = "OMAP3525"; + omap3_soc_name = "OMAP3525"; } else if (omap3_has_sgx()) { - cpu_name = "OMAP3515"; + omap3_soc_name = "OMAP3515"; } else { - cpu_name = "OMAP3503"; + omap3_soc_name = "OMAP3503"; } + sprintf(soc_name, "%s", omap3_soc_name); + /* Print verbose information */ - pr_info("%s ES%s (", cpu_name, cpu_rev); + pr_info("%s %s (", soc_name, soc_rev); OMAP3_SHOW_FEATURE(l2cache); OMAP3_SHOW_FEATURE(iva); @@ -291,6 +298,7 @@ void __init ti81xx_check_features(void) void __init omap3xxx_check_revision(void) { + const char *omap3_soc_rev; u32 cpuid, idcode; u16 hawkeye; u8 rev; @@ -303,7 +311,7 @@ void __init omap3xxx_check_revision(void) cpuid = read_cpuid(CPUID_ID); if ((((cpuid >> 4) & 0xfff) == 0xc08) && ((cpuid & 0xf) == 0x0)) { omap_revision = OMAP3430_REV_ES1_0; - cpu_rev = "1.0"; + omap3_soc_rev = "ES1.0"; return; } @@ -324,26 +332,26 @@ void __init omap3xxx_check_revision(void) case 0: /* Take care of early samples */ case 1: omap_revision = OMAP3430_REV_ES2_0; - cpu_rev = "2.0"; + omap3_soc_rev = "ES2.0"; break; case 2: omap_revision = OMAP3430_REV_ES2_1; - cpu_rev = "2.1"; + omap3_soc_rev = "ES2.1"; break; case 3: omap_revision = OMAP3430_REV_ES3_0; - cpu_rev = "3.0"; + omap3_soc_rev = "ES3.0"; break; case 4: omap_revision = OMAP3430_REV_ES3_1; - cpu_rev = "3.1"; + omap3_soc_rev = "ES3.1"; break; case 7: /* FALLTHROUGH */ default: /* Use the latest known revision as default */ omap_revision = OMAP3430_REV_ES3_1_2; - cpu_rev = "3.1.2"; + omap3_soc_rev = "ES3.1.2"; } break; case 0xb868: @@ -356,13 +364,13 @@ void __init omap3xxx_check_revision(void) switch (rev) { case 0: omap_revision = AM35XX_REV_ES1_0; - cpu_rev = "1.0"; + omap3_soc_rev = "ES1.0"; break; case 1: /* FALLTHROUGH */ default: omap_revision = AM35XX_REV_ES1_1; - cpu_rev = "1.1"; + omap3_soc_rev = "ES1.1"; } break; case 0xb891: @@ -371,30 +379,30 @@ void __init omap3xxx_check_revision(void) switch(rev) { case 0: /* Take care of early samples */ omap_revision = OMAP3630_REV_ES1_0; - cpu_rev = "1.0"; + omap3_soc_rev = "1.0"; break; case 1: omap_revision = OMAP3630_REV_ES1_1; - cpu_rev = "1.1"; + omap3_soc_rev = "ES1.1"; break; case 2: /* FALLTHROUGH */ default: omap_revision = OMAP3630_REV_ES1_2; - cpu_rev = "1.2"; + omap3_soc_rev = "ES1.2"; } break; case 0xb81e: switch (rev) { case 0: omap_revision = TI8168_REV_ES1_0; - cpu_rev = "1.0"; + omap3_soc_rev = "ES1.0"; break; case 1: /* FALLTHROUGH */ default: omap_revision = TI8168_REV_ES1_1; - cpu_rev = "1.1"; + omap3_soc_rev = "ES1.1"; break; } break; @@ -402,13 +410,13 @@ void __init omap3xxx_check_revision(void) switch (rev) { case 0: omap_revision = AM335X_REV_ES1_0; - cpu_rev = "1.0"; + omap3_soc_rev = "1.0"; break; case 1: /* FALLTHROUGH */ default: omap_revision = AM335X_REV_ES2_0; - cpu_rev = "2.0"; + omap3_soc_rev = "2.0"; break; } break; @@ -418,26 +426,27 @@ void __init omap3xxx_check_revision(void) /* FALLTHROUGH */ case 1: omap_revision = TI8148_REV_ES1_0; - cpu_rev = "1.0"; + omap3_soc_rev = "ES1.0"; break; case 2: omap_revision = TI8148_REV_ES2_0; - cpu_rev = "2.0"; + omap3_soc_rev = "ES2.0"; break; case 3: /* FALLTHROUGH */ default: omap_revision = TI8148_REV_ES2_1; - cpu_rev = "2.1"; + omap3_soc_rev = "ES2.1"; break; } break; default: /* Unknown default to latest silicon rev as default */ omap_revision = OMAP3630_REV_ES1_2; - cpu_rev = "1.2"; + omap3_soc_rev = "ES1.2"; pr_warn("Warning: unknown chip type; assuming OMAP3630ES1.2\n"); } + sprintf(soc_rev, "%s", omap3_soc_rev); } void __init omap4xxx_check_revision(void) @@ -512,8 +521,10 @@ void __init omap4xxx_check_revision(void) omap_revision = OMAP4430_REV_ES2_3; } - pr_info("OMAP%04x ES%d.%d\n", omap_rev() >> 16, - ((omap_rev() >> 12) & 0xf), ((omap_rev() >> 8) & 0xf)); + sprintf(soc_name, "OMAP%04x", omap_rev() >> 16); + sprintf(soc_rev, "ES%d.%d", (omap_rev() >> 12) & 0xf, + (omap_rev() >> 8) & 0xf); + pr_info("%s %s\n", soc_name, soc_rev); } void __init omap5xxx_check_revision(void) @@ -547,8 +558,10 @@ void __init omap5xxx_check_revision(void) omap_revision = OMAP5430_REV_ES1_0; } - pr_info("OMAP%04x ES%d.0\n", - omap_rev() >> 16, ((omap_rev() >> 12) & 0xf)); + sprintf(soc_name, "OMAP%04x", omap_rev() >> 16); + sprintf(soc_rev, "ES%d.0", (omap_rev() >> 12) & 0xf); + + pr_info("%s %s\n", soc_name, soc_rev); } /* -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/2] ARM: OMAP2+: SoC name and revision unification 2013-02-06 18:59 ` Ruslan Bilovol @ 2013-02-06 19:19 ` Tony Lindgren -1 siblings, 0 replies; 11+ messages in thread From: Tony Lindgren @ 2013-02-06 19:19 UTC (permalink / raw) To: Ruslan Bilovol; +Cc: linux, linux-arm-kernel, linux-omap, linux-kernel Hi, * Ruslan Bilovol <ruslan.bilovol@ti.com> [130206 11:03]: > This is a long story where for each new generation of > OMAP we used different approaches for creating > strings for SoCs names and revisions that this patch > fixes. It makes future exporting of this information > to SoC infrastructure easier. > > Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com> > --- > arch/arm/mach-omap2/id.c | 89 ++++++++++++++++++++++++++-------------------- > 1 file changed, 51 insertions(+), 38 deletions(-) > > diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c > index 8a68f1e..b16a432 100644 > --- a/arch/arm/mach-omap2/id.c > +++ b/arch/arm/mach-omap2/id.c > @@ -31,8 +31,11 @@ > #define OMAP4_SILICON_TYPE_STANDARD 0x01 > #define OMAP4_SILICON_TYPE_PERFORMANCE 0x02 > > +#define OMAP_SOC_MAX_NAME_LENGTH 16 > + > static unsigned int omap_revision; > -static const char *cpu_rev; > +static char soc_name[OMAP_SOC_MAX_NAME_LENGTH]; > +static char soc_rev[OMAP_SOC_MAX_NAME_LENGTH]; > u32 omap_features; > > unsigned int omap_rev(void) Sorry I was not clear earlier with what I meant, but if you remove static const char *cpu_rev here and use soc_name and soc_rev here.. > @@ -181,8 +187,7 @@ void __init omap2xxx_check_revision(void) > > static void __init omap3_cpuinfo(void) > { > - const char *cpu_name; > - > + const char *omap3_soc_name; > /* > * OMAP3430 and OMAP3530 are assumed to be same. > * ..then no need to replace cpu_name with omap3_soc_name here? > @@ -191,28 +196,30 @@ static void __init omap3_cpuinfo(void) > * and CPU class bits. > */ > if (cpu_is_omap3630()) { > - cpu_name = "OMAP3630"; > + omap3_soc_name = "OMAP3630"; > } else if (soc_is_am35xx()) { > - cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505"; > + omap3_soc_name = (omap3_has_sgx()) ? "AM3517" : "AM3505"; > } else if (cpu_is_ti816x()) { > - cpu_name = "TI816X"; > + omap3_soc_name = "TI816X"; > } else if (soc_is_am335x()) { > - cpu_name = "AM335X"; > + omap3_soc_name = "AM335X"; ... Or here? > void __init omap3xxx_check_revision(void) > { > + const char *omap3_soc_rev; > u32 cpuid, idcode; > u16 hawkeye; > u8 rev; Then here if you just make it a local cpu_rev.. > @@ -303,7 +311,7 @@ void __init omap3xxx_check_revision(void) > cpuid = read_cpuid(CPUID_ID); > if ((((cpuid >> 4) & 0xfff) == 0xc08) && ((cpuid & 0xf) == 0x0)) { > omap_revision = OMAP3430_REV_ES1_0; > - cpu_rev = "1.0"; > + omap3_soc_rev = "ES1.0"; > return; > } > > @@ -324,26 +332,26 @@ void __init omap3xxx_check_revision(void) > case 0: /* Take care of early samples */ > case 1: > omap_revision = OMAP3430_REV_ES2_0; > - cpu_rev = "2.0"; > + omap3_soc_rev = "ES2.0"; > break; > case 2: > omap_revision = OMAP3430_REV_ES2_1; > - cpu_rev = "2.1"; > + omap3_soc_rev = "ES2.1"; > break; > case 3: > omap_revision = OMAP3430_REV_ES3_0; > - cpu_rev = "3.0"; > + omap3_soc_rev = "ES3.0"; > break; > case 4: > omap_revision = OMAP3430_REV_ES3_1; > - cpu_rev = "3.1"; > + omap3_soc_rev = "ES3.1"; > break; ..no need to replace cpu_rev with omap3_soc_rev all over the place? Regards, Tony ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 1/2] ARM: OMAP2+: SoC name and revision unification @ 2013-02-06 19:19 ` Tony Lindgren 0 siblings, 0 replies; 11+ messages in thread From: Tony Lindgren @ 2013-02-06 19:19 UTC (permalink / raw) To: linux-arm-kernel Hi, * Ruslan Bilovol <ruslan.bilovol@ti.com> [130206 11:03]: > This is a long story where for each new generation of > OMAP we used different approaches for creating > strings for SoCs names and revisions that this patch > fixes. It makes future exporting of this information > to SoC infrastructure easier. > > Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com> > --- > arch/arm/mach-omap2/id.c | 89 ++++++++++++++++++++++++++-------------------- > 1 file changed, 51 insertions(+), 38 deletions(-) > > diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c > index 8a68f1e..b16a432 100644 > --- a/arch/arm/mach-omap2/id.c > +++ b/arch/arm/mach-omap2/id.c > @@ -31,8 +31,11 @@ > #define OMAP4_SILICON_TYPE_STANDARD 0x01 > #define OMAP4_SILICON_TYPE_PERFORMANCE 0x02 > > +#define OMAP_SOC_MAX_NAME_LENGTH 16 > + > static unsigned int omap_revision; > -static const char *cpu_rev; > +static char soc_name[OMAP_SOC_MAX_NAME_LENGTH]; > +static char soc_rev[OMAP_SOC_MAX_NAME_LENGTH]; > u32 omap_features; > > unsigned int omap_rev(void) Sorry I was not clear earlier with what I meant, but if you remove static const char *cpu_rev here and use soc_name and soc_rev here.. > @@ -181,8 +187,7 @@ void __init omap2xxx_check_revision(void) > > static void __init omap3_cpuinfo(void) > { > - const char *cpu_name; > - > + const char *omap3_soc_name; > /* > * OMAP3430 and OMAP3530 are assumed to be same. > * ..then no need to replace cpu_name with omap3_soc_name here? > @@ -191,28 +196,30 @@ static void __init omap3_cpuinfo(void) > * and CPU class bits. > */ > if (cpu_is_omap3630()) { > - cpu_name = "OMAP3630"; > + omap3_soc_name = "OMAP3630"; > } else if (soc_is_am35xx()) { > - cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505"; > + omap3_soc_name = (omap3_has_sgx()) ? "AM3517" : "AM3505"; > } else if (cpu_is_ti816x()) { > - cpu_name = "TI816X"; > + omap3_soc_name = "TI816X"; > } else if (soc_is_am335x()) { > - cpu_name = "AM335X"; > + omap3_soc_name = "AM335X"; ... Or here? > void __init omap3xxx_check_revision(void) > { > + const char *omap3_soc_rev; > u32 cpuid, idcode; > u16 hawkeye; > u8 rev; Then here if you just make it a local cpu_rev.. > @@ -303,7 +311,7 @@ void __init omap3xxx_check_revision(void) > cpuid = read_cpuid(CPUID_ID); > if ((((cpuid >> 4) & 0xfff) == 0xc08) && ((cpuid & 0xf) == 0x0)) { > omap_revision = OMAP3430_REV_ES1_0; > - cpu_rev = "1.0"; > + omap3_soc_rev = "ES1.0"; > return; > } > > @@ -324,26 +332,26 @@ void __init omap3xxx_check_revision(void) > case 0: /* Take care of early samples */ > case 1: > omap_revision = OMAP3430_REV_ES2_0; > - cpu_rev = "2.0"; > + omap3_soc_rev = "ES2.0"; > break; > case 2: > omap_revision = OMAP3430_REV_ES2_1; > - cpu_rev = "2.1"; > + omap3_soc_rev = "ES2.1"; > break; > case 3: > omap_revision = OMAP3430_REV_ES3_0; > - cpu_rev = "3.0"; > + omap3_soc_rev = "ES3.0"; > break; > case 4: > omap_revision = OMAP3430_REV_ES3_1; > - cpu_rev = "3.1"; > + omap3_soc_rev = "ES3.1"; > break; ..no need to replace cpu_rev with omap3_soc_rev all over the place? Regards, Tony ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/2] ARM: OMAP2+: SoC name and revision unification 2013-02-06 19:19 ` Tony Lindgren (?) @ 2013-02-06 22:12 ` Ruslan Bilovol -1 siblings, 0 replies; 11+ messages in thread From: Ruslan Bilovol @ 2013-02-06 22:12 UTC (permalink / raw) To: Tony Lindgren; +Cc: linux, linux-arm-kernel, linux-omap, linux-kernel On Wed, Feb 6, 2013 at 9:19 PM, Tony Lindgren <tony@atomide.com> wrote: > Hi, > > * Ruslan Bilovol <ruslan.bilovol@ti.com> [130206 11:03]: >> This is a long story where for each new generation of >> OMAP we used different approaches for creating >> strings for SoCs names and revisions that this patch >> fixes. It makes future exporting of this information >> to SoC infrastructure easier. >> >> Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com> >> --- >> arch/arm/mach-omap2/id.c | 89 ++++++++++++++++++++++++++-------------------- >> 1 file changed, 51 insertions(+), 38 deletions(-) >> >> diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c >> index 8a68f1e..b16a432 100644 >> --- a/arch/arm/mach-omap2/id.c >> +++ b/arch/arm/mach-omap2/id.c >> @@ -31,8 +31,11 @@ >> #define OMAP4_SILICON_TYPE_STANDARD 0x01 >> #define OMAP4_SILICON_TYPE_PERFORMANCE 0x02 >> >> +#define OMAP_SOC_MAX_NAME_LENGTH 16 >> + >> static unsigned int omap_revision; >> -static const char *cpu_rev; >> +static char soc_name[OMAP_SOC_MAX_NAME_LENGTH]; >> +static char soc_rev[OMAP_SOC_MAX_NAME_LENGTH]; >> u32 omap_features; >> >> unsigned int omap_rev(void) > > Sorry I was not clear earlier with what I meant, but if > you remove static const char *cpu_rev here and use > soc_name and soc_rev here.. > >> @@ -181,8 +187,7 @@ void __init omap2xxx_check_revision(void) >> >> static void __init omap3_cpuinfo(void) >> { >> - const char *cpu_name; >> - >> + const char *omap3_soc_name; >> /* >> * OMAP3430 and OMAP3530 are assumed to be same. >> * > > ..then no need to replace cpu_name with omap3_soc_name here? > >> @@ -191,28 +196,30 @@ static void __init omap3_cpuinfo(void) >> * and CPU class bits. >> */ >> if (cpu_is_omap3630()) { >> - cpu_name = "OMAP3630"; >> + omap3_soc_name = "OMAP3630"; >> } else if (soc_is_am35xx()) { >> - cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505"; >> + omap3_soc_name = (omap3_has_sgx()) ? "AM3517" : "AM3505"; >> } else if (cpu_is_ti816x()) { >> - cpu_name = "TI816X"; >> + omap3_soc_name = "TI816X"; >> } else if (soc_is_am335x()) { >> - cpu_name = "AM335X"; >> + omap3_soc_name = "AM335X"; > ... > > Or here? > >> void __init omap3xxx_check_revision(void) >> { >> + const char *omap3_soc_rev; >> u32 cpuid, idcode; >> u16 hawkeye; >> u8 rev; > > Then here if you just make it a local cpu_rev.. > >> @@ -303,7 +311,7 @@ void __init omap3xxx_check_revision(void) >> cpuid = read_cpuid(CPUID_ID); >> if ((((cpuid >> 4) & 0xfff) == 0xc08) && ((cpuid & 0xf) == 0x0)) { >> omap_revision = OMAP3430_REV_ES1_0; >> - cpu_rev = "1.0"; >> + omap3_soc_rev = "ES1.0"; >> return; >> } >> >> @@ -324,26 +332,26 @@ void __init omap3xxx_check_revision(void) >> case 0: /* Take care of early samples */ >> case 1: >> omap_revision = OMAP3430_REV_ES2_0; >> - cpu_rev = "2.0"; >> + omap3_soc_rev = "ES2.0"; >> break; >> case 2: >> omap_revision = OMAP3430_REV_ES2_1; >> - cpu_rev = "2.1"; >> + omap3_soc_rev = "ES2.1"; >> break; >> case 3: >> omap_revision = OMAP3430_REV_ES3_0; >> - cpu_rev = "3.0"; >> + omap3_soc_rev = "ES3.0"; >> break; >> case 4: >> omap_revision = OMAP3430_REV_ES3_1; >> - cpu_rev = "3.1"; >> + omap3_soc_rev = "ES3.1"; >> break; > > ..no need to replace cpu_rev with omap3_soc_rev all over the > place? Okay, I understood what do you mean here. Will fix it in next patchset.. > > Regards, > > Tony ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 1/2] ARM: OMAP2+: SoC name and revision unification @ 2013-02-06 22:12 ` Ruslan Bilovol 0 siblings, 0 replies; 11+ messages in thread From: Ruslan Bilovol @ 2013-02-06 22:12 UTC (permalink / raw) To: linux-arm-kernel On Wed, Feb 6, 2013 at 9:19 PM, Tony Lindgren <tony@atomide.com> wrote: > Hi, > > * Ruslan Bilovol <ruslan.bilovol@ti.com> [130206 11:03]: >> This is a long story where for each new generation of >> OMAP we used different approaches for creating >> strings for SoCs names and revisions that this patch >> fixes. It makes future exporting of this information >> to SoC infrastructure easier. >> >> Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com> >> --- >> arch/arm/mach-omap2/id.c | 89 ++++++++++++++++++++++++++-------------------- >> 1 file changed, 51 insertions(+), 38 deletions(-) >> >> diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c >> index 8a68f1e..b16a432 100644 >> --- a/arch/arm/mach-omap2/id.c >> +++ b/arch/arm/mach-omap2/id.c >> @@ -31,8 +31,11 @@ >> #define OMAP4_SILICON_TYPE_STANDARD 0x01 >> #define OMAP4_SILICON_TYPE_PERFORMANCE 0x02 >> >> +#define OMAP_SOC_MAX_NAME_LENGTH 16 >> + >> static unsigned int omap_revision; >> -static const char *cpu_rev; >> +static char soc_name[OMAP_SOC_MAX_NAME_LENGTH]; >> +static char soc_rev[OMAP_SOC_MAX_NAME_LENGTH]; >> u32 omap_features; >> >> unsigned int omap_rev(void) > > Sorry I was not clear earlier with what I meant, but if > you remove static const char *cpu_rev here and use > soc_name and soc_rev here.. > >> @@ -181,8 +187,7 @@ void __init omap2xxx_check_revision(void) >> >> static void __init omap3_cpuinfo(void) >> { >> - const char *cpu_name; >> - >> + const char *omap3_soc_name; >> /* >> * OMAP3430 and OMAP3530 are assumed to be same. >> * > > ..then no need to replace cpu_name with omap3_soc_name here? > >> @@ -191,28 +196,30 @@ static void __init omap3_cpuinfo(void) >> * and CPU class bits. >> */ >> if (cpu_is_omap3630()) { >> - cpu_name = "OMAP3630"; >> + omap3_soc_name = "OMAP3630"; >> } else if (soc_is_am35xx()) { >> - cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505"; >> + omap3_soc_name = (omap3_has_sgx()) ? "AM3517" : "AM3505"; >> } else if (cpu_is_ti816x()) { >> - cpu_name = "TI816X"; >> + omap3_soc_name = "TI816X"; >> } else if (soc_is_am335x()) { >> - cpu_name = "AM335X"; >> + omap3_soc_name = "AM335X"; > ... > > Or here? > >> void __init omap3xxx_check_revision(void) >> { >> + const char *omap3_soc_rev; >> u32 cpuid, idcode; >> u16 hawkeye; >> u8 rev; > > Then here if you just make it a local cpu_rev.. > >> @@ -303,7 +311,7 @@ void __init omap3xxx_check_revision(void) >> cpuid = read_cpuid(CPUID_ID); >> if ((((cpuid >> 4) & 0xfff) == 0xc08) && ((cpuid & 0xf) == 0x0)) { >> omap_revision = OMAP3430_REV_ES1_0; >> - cpu_rev = "1.0"; >> + omap3_soc_rev = "ES1.0"; >> return; >> } >> >> @@ -324,26 +332,26 @@ void __init omap3xxx_check_revision(void) >> case 0: /* Take care of early samples */ >> case 1: >> omap_revision = OMAP3430_REV_ES2_0; >> - cpu_rev = "2.0"; >> + omap3_soc_rev = "ES2.0"; >> break; >> case 2: >> omap_revision = OMAP3430_REV_ES2_1; >> - cpu_rev = "2.1"; >> + omap3_soc_rev = "ES2.1"; >> break; >> case 3: >> omap_revision = OMAP3430_REV_ES3_0; >> - cpu_rev = "3.0"; >> + omap3_soc_rev = "ES3.0"; >> break; >> case 4: >> omap_revision = OMAP3430_REV_ES3_1; >> - cpu_rev = "3.1"; >> + omap3_soc_rev = "ES3.1"; >> break; > > ..no need to replace cpu_rev with omap3_soc_rev all over the > place? Okay, I understood what do you mean here. Will fix it in next patchset.. > > Regards, > > Tony ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/2] ARM: OMAP2+: SoC name and revision unification @ 2013-02-06 22:12 ` Ruslan Bilovol 0 siblings, 0 replies; 11+ messages in thread From: Ruslan Bilovol @ 2013-02-06 22:12 UTC (permalink / raw) To: Tony Lindgren; +Cc: linux-omap, linux, linux-kernel, linux-arm-kernel On Wed, Feb 6, 2013 at 9:19 PM, Tony Lindgren <tony@atomide.com> wrote: > Hi, > > * Ruslan Bilovol <ruslan.bilovol@ti.com> [130206 11:03]: >> This is a long story where for each new generation of >> OMAP we used different approaches for creating >> strings for SoCs names and revisions that this patch >> fixes. It makes future exporting of this information >> to SoC infrastructure easier. >> >> Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com> >> --- >> arch/arm/mach-omap2/id.c | 89 ++++++++++++++++++++++++++-------------------- >> 1 file changed, 51 insertions(+), 38 deletions(-) >> >> diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c >> index 8a68f1e..b16a432 100644 >> --- a/arch/arm/mach-omap2/id.c >> +++ b/arch/arm/mach-omap2/id.c >> @@ -31,8 +31,11 @@ >> #define OMAP4_SILICON_TYPE_STANDARD 0x01 >> #define OMAP4_SILICON_TYPE_PERFORMANCE 0x02 >> >> +#define OMAP_SOC_MAX_NAME_LENGTH 16 >> + >> static unsigned int omap_revision; >> -static const char *cpu_rev; >> +static char soc_name[OMAP_SOC_MAX_NAME_LENGTH]; >> +static char soc_rev[OMAP_SOC_MAX_NAME_LENGTH]; >> u32 omap_features; >> >> unsigned int omap_rev(void) > > Sorry I was not clear earlier with what I meant, but if > you remove static const char *cpu_rev here and use > soc_name and soc_rev here.. > >> @@ -181,8 +187,7 @@ void __init omap2xxx_check_revision(void) >> >> static void __init omap3_cpuinfo(void) >> { >> - const char *cpu_name; >> - >> + const char *omap3_soc_name; >> /* >> * OMAP3430 and OMAP3530 are assumed to be same. >> * > > ..then no need to replace cpu_name with omap3_soc_name here? > >> @@ -191,28 +196,30 @@ static void __init omap3_cpuinfo(void) >> * and CPU class bits. >> */ >> if (cpu_is_omap3630()) { >> - cpu_name = "OMAP3630"; >> + omap3_soc_name = "OMAP3630"; >> } else if (soc_is_am35xx()) { >> - cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505"; >> + omap3_soc_name = (omap3_has_sgx()) ? "AM3517" : "AM3505"; >> } else if (cpu_is_ti816x()) { >> - cpu_name = "TI816X"; >> + omap3_soc_name = "TI816X"; >> } else if (soc_is_am335x()) { >> - cpu_name = "AM335X"; >> + omap3_soc_name = "AM335X"; > ... > > Or here? > >> void __init omap3xxx_check_revision(void) >> { >> + const char *omap3_soc_rev; >> u32 cpuid, idcode; >> u16 hawkeye; >> u8 rev; > > Then here if you just make it a local cpu_rev.. > >> @@ -303,7 +311,7 @@ void __init omap3xxx_check_revision(void) >> cpuid = read_cpuid(CPUID_ID); >> if ((((cpuid >> 4) & 0xfff) == 0xc08) && ((cpuid & 0xf) == 0x0)) { >> omap_revision = OMAP3430_REV_ES1_0; >> - cpu_rev = "1.0"; >> + omap3_soc_rev = "ES1.0"; >> return; >> } >> >> @@ -324,26 +332,26 @@ void __init omap3xxx_check_revision(void) >> case 0: /* Take care of early samples */ >> case 1: >> omap_revision = OMAP3430_REV_ES2_0; >> - cpu_rev = "2.0"; >> + omap3_soc_rev = "ES2.0"; >> break; >> case 2: >> omap_revision = OMAP3430_REV_ES2_1; >> - cpu_rev = "2.1"; >> + omap3_soc_rev = "ES2.1"; >> break; >> case 3: >> omap_revision = OMAP3430_REV_ES3_0; >> - cpu_rev = "3.0"; >> + omap3_soc_rev = "ES3.0"; >> break; >> case 4: >> omap_revision = OMAP3430_REV_ES3_1; >> - cpu_rev = "3.1"; >> + omap3_soc_rev = "ES3.1"; >> break; > > ..no need to replace cpu_rev with omap3_soc_rev all over the > place? Okay, I understood what do you mean here. Will fix it in next patchset.. > > Regards, > > Tony ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 2/2] ARM: OMAP2+: Export SoC information to userspace 2013-02-06 18:59 ` Ruslan Bilovol @ 2013-02-06 18:59 ` Ruslan Bilovol -1 siblings, 0 replies; 11+ messages in thread From: Ruslan Bilovol @ 2013-02-06 18:59 UTC (permalink / raw) To: tony, linux, linux-arm-kernel, linux-omap, linux-kernel In some situations it is useful for userspace to know some SoC-specific information. For example, this may be used for deciding what kernel module to use or how to better configure some settings etc. This patch exports OMAP SoC information to userspace using existing in Linux kernel SoC infrastructure. This information can be read under /sys/devices/socX directory Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com> --- arch/arm/mach-omap2/common.h | 8 ++++++ arch/arm/mach-omap2/id.c | 65 ++++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-omap2/io.c | 1 + arch/arm/plat-omap/Kconfig | 1 + 4 files changed, 75 insertions(+) diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h index 0c3a991..a024084 100644 --- a/arch/arm/mach-omap2/common.h +++ b/arch/arm/mach-omap2/common.h @@ -111,6 +111,14 @@ void ti81xx_init_late(void); void omap4430_init_late(void); int omap2_common_pm_late_init(void); +#ifdef CONFIG_SOC_BUS +void omap_soc_device_init(void); +#else +static inline void omap_soc_device_init(void) +{ +} +#endif + #if defined(CONFIG_SOC_OMAP2420) || defined(CONFIG_SOC_OMAP2430) void omap2xxx_restart(char mode, const char *cmd); #else diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c index b16a432..6134073 100644 --- a/arch/arm/mach-omap2/id.c +++ b/arch/arm/mach-omap2/id.c @@ -18,6 +18,11 @@ #include <linux/kernel.h> #include <linux/init.h> #include <linux/io.h> +#include <linux/slab.h> + +#ifdef CONFIG_SOC_BUS +#include <linux/sys_soc.h> +#endif #include <asm/cputype.h> @@ -582,3 +587,63 @@ void __init omap2_set_globals_tap(u32 class, void __iomem *tap) else tap_prod_id = 0x0208; } + +#ifdef CONFIG_SOC_BUS + +static const char const *omap_types[] = { + [OMAP2_DEVICE_TYPE_TEST] = "TST", + [OMAP2_DEVICE_TYPE_EMU] = "EMU", + [OMAP2_DEVICE_TYPE_SEC] = "HS", + [OMAP2_DEVICE_TYPE_GP] = "GP", + [OMAP2_DEVICE_TYPE_BAD] = "BAD", +}; + +static const char * __init omap_get_family(void) +{ + if (cpu_is_omap24xx()) + return kasprintf(GFP_KERNEL, "OMAP2"); + else if (cpu_is_omap34xx()) + return kasprintf(GFP_KERNEL, "OMAP3"); + else if (cpu_is_omap44xx()) + return kasprintf(GFP_KERNEL, "OMAP4"); + else if (soc_is_omap54xx()) + return kasprintf(GFP_KERNEL, "OMAP5"); + else + return kasprintf(GFP_KERNEL, "Unknown"); +} + +static ssize_t omap_get_type(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + return sprintf(buf, "%s\n", omap_types[omap_type()]); +} + +static struct device_attribute omap_soc_attr = + __ATTR(type, S_IRUGO, omap_get_type, NULL); + +void __init omap_soc_device_init(void) +{ + struct device *parent; + struct soc_device *soc_dev; + struct soc_device_attribute *soc_dev_attr; + + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); + if (!soc_dev_attr) + return; + + soc_dev_attr->machine = soc_name; + soc_dev_attr->family = omap_get_family(); + soc_dev_attr->revision = soc_rev; + + soc_dev = soc_device_register(soc_dev_attr); + if (IS_ERR_OR_NULL(soc_dev)) { + kfree(soc_dev_attr); + return; + } + + parent = soc_device_to_device(soc_dev); + if (!IS_ERR_OR_NULL(parent)) + device_create_file(parent, &omap_soc_attr); +} +#endif /* CONFIG_SOC_BUS */ diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c index 2c3fdd6..08003c1 100644 --- a/arch/arm/mach-omap2/io.c +++ b/arch/arm/mach-omap2/io.c @@ -602,6 +602,7 @@ void __init omap4430_init_late(void) omap2_common_pm_late_init(); omap4_pm_init(); omap2_clk_enable_autoidle_all(); + omap_soc_device_init(); } #endif diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig index 1fbac36..24b5687 100644 --- a/arch/arm/plat-omap/Kconfig +++ b/arch/arm/plat-omap/Kconfig @@ -30,6 +30,7 @@ config ARCH_OMAP2PLUS select PROC_DEVICETREE if PROC_FS select SPARSE_IRQ select USE_OF + select SOC_BUS help "Systems based on OMAP2, OMAP3, OMAP4 or OMAP5" -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 2/2] ARM: OMAP2+: Export SoC information to userspace @ 2013-02-06 18:59 ` Ruslan Bilovol 0 siblings, 0 replies; 11+ messages in thread From: Ruslan Bilovol @ 2013-02-06 18:59 UTC (permalink / raw) To: linux-arm-kernel In some situations it is useful for userspace to know some SoC-specific information. For example, this may be used for deciding what kernel module to use or how to better configure some settings etc. This patch exports OMAP SoC information to userspace using existing in Linux kernel SoC infrastructure. This information can be read under /sys/devices/socX directory Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com> --- arch/arm/mach-omap2/common.h | 8 ++++++ arch/arm/mach-omap2/id.c | 65 ++++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-omap2/io.c | 1 + arch/arm/plat-omap/Kconfig | 1 + 4 files changed, 75 insertions(+) diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h index 0c3a991..a024084 100644 --- a/arch/arm/mach-omap2/common.h +++ b/arch/arm/mach-omap2/common.h @@ -111,6 +111,14 @@ void ti81xx_init_late(void); void omap4430_init_late(void); int omap2_common_pm_late_init(void); +#ifdef CONFIG_SOC_BUS +void omap_soc_device_init(void); +#else +static inline void omap_soc_device_init(void) +{ +} +#endif + #if defined(CONFIG_SOC_OMAP2420) || defined(CONFIG_SOC_OMAP2430) void omap2xxx_restart(char mode, const char *cmd); #else diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c index b16a432..6134073 100644 --- a/arch/arm/mach-omap2/id.c +++ b/arch/arm/mach-omap2/id.c @@ -18,6 +18,11 @@ #include <linux/kernel.h> #include <linux/init.h> #include <linux/io.h> +#include <linux/slab.h> + +#ifdef CONFIG_SOC_BUS +#include <linux/sys_soc.h> +#endif #include <asm/cputype.h> @@ -582,3 +587,63 @@ void __init omap2_set_globals_tap(u32 class, void __iomem *tap) else tap_prod_id = 0x0208; } + +#ifdef CONFIG_SOC_BUS + +static const char const *omap_types[] = { + [OMAP2_DEVICE_TYPE_TEST] = "TST", + [OMAP2_DEVICE_TYPE_EMU] = "EMU", + [OMAP2_DEVICE_TYPE_SEC] = "HS", + [OMAP2_DEVICE_TYPE_GP] = "GP", + [OMAP2_DEVICE_TYPE_BAD] = "BAD", +}; + +static const char * __init omap_get_family(void) +{ + if (cpu_is_omap24xx()) + return kasprintf(GFP_KERNEL, "OMAP2"); + else if (cpu_is_omap34xx()) + return kasprintf(GFP_KERNEL, "OMAP3"); + else if (cpu_is_omap44xx()) + return kasprintf(GFP_KERNEL, "OMAP4"); + else if (soc_is_omap54xx()) + return kasprintf(GFP_KERNEL, "OMAP5"); + else + return kasprintf(GFP_KERNEL, "Unknown"); +} + +static ssize_t omap_get_type(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + return sprintf(buf, "%s\n", omap_types[omap_type()]); +} + +static struct device_attribute omap_soc_attr = + __ATTR(type, S_IRUGO, omap_get_type, NULL); + +void __init omap_soc_device_init(void) +{ + struct device *parent; + struct soc_device *soc_dev; + struct soc_device_attribute *soc_dev_attr; + + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); + if (!soc_dev_attr) + return; + + soc_dev_attr->machine = soc_name; + soc_dev_attr->family = omap_get_family(); + soc_dev_attr->revision = soc_rev; + + soc_dev = soc_device_register(soc_dev_attr); + if (IS_ERR_OR_NULL(soc_dev)) { + kfree(soc_dev_attr); + return; + } + + parent = soc_device_to_device(soc_dev); + if (!IS_ERR_OR_NULL(parent)) + device_create_file(parent, &omap_soc_attr); +} +#endif /* CONFIG_SOC_BUS */ diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c index 2c3fdd6..08003c1 100644 --- a/arch/arm/mach-omap2/io.c +++ b/arch/arm/mach-omap2/io.c @@ -602,6 +602,7 @@ void __init omap4430_init_late(void) omap2_common_pm_late_init(); omap4_pm_init(); omap2_clk_enable_autoidle_all(); + omap_soc_device_init(); } #endif diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig index 1fbac36..24b5687 100644 --- a/arch/arm/plat-omap/Kconfig +++ b/arch/arm/plat-omap/Kconfig @@ -30,6 +30,7 @@ config ARCH_OMAP2PLUS select PROC_DEVICETREE if PROC_FS select SPARSE_IRQ select USE_OF + select SOC_BUS help "Systems based on OMAP2, OMAP3, OMAP4 or OMAP5" -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2013-02-06 22:12 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-02-06 18:59 [PATCH v2 0/2] ARM: OMAP2+: Export SoC information to userspace using SoC infrastructure Ruslan Bilovol 2013-02-06 18:59 ` Ruslan Bilovol 2013-02-06 18:59 ` [PATCH v2 1/2] ARM: OMAP2+: SoC name and revision unification Ruslan Bilovol 2013-02-06 18:59 ` Ruslan Bilovol 2013-02-06 19:19 ` Tony Lindgren 2013-02-06 19:19 ` Tony Lindgren 2013-02-06 22:12 ` Ruslan Bilovol 2013-02-06 22:12 ` Ruslan Bilovol 2013-02-06 22:12 ` Ruslan Bilovol 2013-02-06 18:59 ` [PATCH v2 2/2] ARM: OMAP2+: Export SoC information to userspace Ruslan Bilovol 2013-02-06 18:59 ` Ruslan Bilovol
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.