* [PATCH v4] davinci: Support various speedgrades for MityDSP-L138 and MityARM-1808 SoMs
@ 2011-01-03 13:21 Michael Williamson
2011-01-04 9:35 ` Nori, Sekhar
0 siblings, 1 reply; 3+ messages in thread
From: Michael Williamson @ 2011-01-03 13:21 UTC (permalink / raw)
To: linux-arm-kernel
For the MityDSP-L138/MityARM-1808 SoMs, the speed grade can be determined
from the part number string read from the factory configuration block on
the on-board I2C PROM. Configure the maximum CPU speed based on this
information.
This patch was tested using a MityDSP-L138 and MityARM-1808 at various
speedgrades. Also, for code coverage, a bogus configuration was tested
as well as a configuration having an unknown part number.
Signed-off-by: Michael Williamson <michael.williamson@criticallink.com>
Tested-by: Michael Williamson <michael.williamson@criticallink.com>
---
Built against linux-davinci.
Changes since v2 (v3 was sent in error, wrong file, sorry for the churn):
- reworked logic to use fall-through logic for mityomapl138_cpugreq_init call
per comments.
arch/arm/mach-davinci/board-mityomapl138.c | 83 +++++++++++++++++++++++++---
1 files changed, 75 insertions(+), 8 deletions(-)
diff --git a/arch/arm/mach-davinci/board-mityomapl138.c b/arch/arm/mach-davinci/board-mityomapl138.c
index 0bb5f0c..86d6229 100644
--- a/arch/arm/mach-davinci/board-mityomapl138.c
+++ b/arch/arm/mach-davinci/board-mityomapl138.c
@@ -44,38 +44,109 @@ struct factory_config {
static struct factory_config factory_config;
+struct part_no_info {
+ const char *part_no; /* part number string of interest */
+ int max_freq; /* khz */
+};
+
+static struct part_no_info mityomapl138_pn_info[] = {
+ {
+ .part_no = "L138-C",
+ .max_freq = 300000,
+ },
+ {
+ .part_no = "L138-D",
+ .max_freq = 375000,
+ },
+ {
+ .part_no = "L138-F",
+ .max_freq = 456000,
+ },
+ {
+ .part_no = "1808-C",
+ .max_freq = 300000,
+ },
+ {
+ .part_no = "1808-D",
+ .max_freq = 375000,
+ },
+ {
+ .part_no = "1808-F",
+ .max_freq = 456000,
+ },
+ {
+ .part_no = "1810-D",
+ .max_freq = 375000,
+ },
+};
+
+#ifdef CONFIG_CPU_FREQ
+static void mityomapl138_cpufreq_init(const char *partnum)
+{
+ int i, ret;
+
+ for (i = 0; partnum && i < ARRAY_SIZE(mityomapl138_pn_info); i++) {
+ /*
+ * the part number has additional characters beyond what is
+ * stored in the table. This information is not needed for
+ * determining the speed grade, and would require several
+ * more table entries. Only check the first N characters
+ * for a match.
+ */
+ if (!strncmp(partnum, mityomapl138_pn_info[i].part_no,
+ strlen(mityomapl138_pn_info[i].part_no))) {
+ da850_max_speed = mityomapl138_pn_info[i].max_freq;
+ break;
+ }
+ }
+
+ ret = da850_register_cpufreq("pll0_sysclk3");
+ if (ret)
+ pr_warning("cpufreq registration failed: %d\n", ret);
+}
+#else
+static void mityomapl138_cpufreq_init(const char *partnum) { }
+#endif
+
static void read_factory_config(struct memory_accessor *a, void *context)
{
int ret;
+ const char *partnum = NULL;
struct davinci_soc_info *soc_info = &davinci_soc_info;
ret = a->read(a, (char *)&factory_config, 0, sizeof(factory_config));
if (ret != sizeof(struct factory_config)) {
pr_warning("MityOMAPL138: Read Factory Config Failed: %d\n",
ret);
- return;
+ goto bad_config;
}
if (factory_config.magic != FACTORY_CONFIG_MAGIC) {
pr_warning("MityOMAPL138: Factory Config Magic Wrong (%X)\n",
factory_config.magic);
- return;
+ goto bad_config;
}
if (factory_config.version != FACTORY_CONFIG_VERSION) {
pr_warning("MityOMAPL138: Factory Config Version Wrong (%X)\n",
factory_config.version);
- return;
+ goto bad_config;
}
pr_info("MityOMAPL138: Found MAC = %pM\n", factory_config.mac);
- pr_info("MityOMAPL138: Part Number = %s\n", factory_config.partnum);
if (is_valid_ether_addr(factory_config.mac))
memcpy(soc_info->emac_pdata->mac_addr,
factory_config.mac, ETH_ALEN);
else
pr_warning("MityOMAPL138: Invalid MAC found "
"in factory config block\n");
+
+ partnum = factory_config.partnum;
+ pr_info("MityOMAPL138: Part Number = %s\n", partnum);
+
+bad_config:
+ /* default maximum speed is valid for all platforms */
+ mityomapl138_cpufreq_init(partnum);
}
static struct at24_platform_data mityomapl138_fd_chip = {
@@ -383,10 +454,6 @@ static void __init mityomapl138_init(void)
if (ret)
pr_warning("rtc setup failed: %d\n", ret);
- ret = da850_register_cpufreq("pll0_sysclk3");
- if (ret)
- pr_warning("cpufreq registration failed: %d\n", ret);
-
ret = da8xx_register_cpuidle();
if (ret)
pr_warning("cpuidle registration failed: %d\n", ret);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v4] davinci: Support various speedgrades for MityDSP-L138 and MityARM-1808 SoMs
2011-01-03 13:21 [PATCH v4] davinci: Support various speedgrades for MityDSP-L138 and MityARM-1808 SoMs Michael Williamson
@ 2011-01-04 9:35 ` Nori, Sekhar
2011-01-04 12:23 ` Michael Williamson
0 siblings, 1 reply; 3+ messages in thread
From: Nori, Sekhar @ 2011-01-04 9:35 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Jan 03, 2011 at 18:51:45, Michael Williamson wrote:
> For the MityDSP-L138/MityARM-1808 SoMs, the speed grade can be determined
> from the part number string read from the factory configuration block on
> the on-board I2C PROM. Configure the maximum CPU speed based on this
> information.
>
> This patch was tested using a MityDSP-L138 and MityARM-1808 at various
> speedgrades. Also, for code coverage, a bogus configuration was tested
> as well as a configuration having an unknown part number.
Thanks for the extensive testing. This looks good to me, except,
a whitespace nit below. But otherwise:
Reviewed-by: Sekhar Nori <nsekhar@ti.com>
> +#ifdef CONFIG_CPU_FREQ
> +static void mityomapl138_cpufreq_init(const char *partnum)
> +{
> + int i, ret;
> +
> + for (i = 0; partnum && i < ARRAY_SIZE(mityomapl138_pn_info); i++) {
> + /*
> + * the part number has additional characters beyond what is
> + * stored in the table. This information is not needed for
> + * determining the speed grade, and would require several
> + * more table entries. Only check the first N characters
> + * for a match.
> + */
> + if (!strncmp(partnum, mityomapl138_pn_info[i].part_no,
> + strlen(mityomapl138_pn_info[i].part_no))) {
> + da850_max_speed = mityomapl138_pn_info[i].max_freq;
> + break;
The indentation here makes it look like strlen is part of if()
body. May be you can indent it substantially to the right. I will
leave it to your judgment.
Thanks,
Sekhar
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v4] davinci: Support various speedgrades for MityDSP-L138 and MityARM-1808 SoMs
2011-01-04 9:35 ` Nori, Sekhar
@ 2011-01-04 12:23 ` Michael Williamson
0 siblings, 0 replies; 3+ messages in thread
From: Michael Williamson @ 2011-01-04 12:23 UTC (permalink / raw)
To: linux-arm-kernel
On 1/4/2011 4:35 AM, Nori, Sekhar wrote:
> On Mon, Jan 03, 2011 at 18:51:45, Michael Williamson wrote:
>> For the MityDSP-L138/MityARM-1808 SoMs, the speed grade can be determined
>> from the part number string read from the factory configuration block on
>> the on-board I2C PROM. Configure the maximum CPU speed based on this
>> information.
>>
>> This patch was tested using a MityDSP-L138 and MityARM-1808 at various
>> speedgrades. Also, for code coverage, a bogus configuration was tested
>> as well as a configuration having an unknown part number.
>
> Thanks for the extensive testing. This looks good to me, except,
> a whitespace nit below. But otherwise:
>
> Reviewed-by: Sekhar Nori <nsekhar@ti.com>
>
>> +#ifdef CONFIG_CPU_FREQ
>> +static void mityomapl138_cpufreq_init(const char *partnum)
>> +{
>> + int i, ret;
>> +
>> + for (i = 0; partnum && i < ARRAY_SIZE(mityomapl138_pn_info); i++) {
>> + /*
>> + * the part number has additional characters beyond what is
>> + * stored in the table. This information is not needed for
>> + * determining the speed grade, and would require several
>> + * more table entries. Only check the first N characters
>> + * for a match.
>> + */
>> + if (!strncmp(partnum, mityomapl138_pn_info[i].part_no,
>> + strlen(mityomapl138_pn_info[i].part_no))) {
>> + da850_max_speed = mityomapl138_pn_info[i].max_freq;
>> + break;
>
> The indentation here makes it look like strlen is part of if()
> body. May be you can indent it substantially to the right. I will
> leave it to your judgment.
>
> Thanks,
> Sekhar
I will align the strlen up to the partnum argument above and resubmit.
Thanks for the review.
-Mike
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-01-04 12:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-03 13:21 [PATCH v4] davinci: Support various speedgrades for MityDSP-L138 and MityARM-1808 SoMs Michael Williamson
2011-01-04 9:35 ` Nori, Sekhar
2011-01-04 12:23 ` Michael Williamson
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.