* [PATCH] powerpc: support ibm,extended-*-frequency properties
@ 2006-06-20 8:47 Anton Blanchard
2006-06-20 9:50 ` Segher Boessenkool
2006-06-28 4:48 ` Kumar Gala
0 siblings, 2 replies; 6+ messages in thread
From: Anton Blanchard @ 2006-06-20 8:47 UTC (permalink / raw)
To: linuxppc-dev; +Cc: paulus
Support the ibm,extended-*-frequency properties found in recent POWER5
firmware:
cpus/PowerPC,POWER5@0/clock-frequency
59aa5880 (1504336000)
cpus/PowerPC,POWER5@0/ibm,extended-clock-frequency
00000000 59aa5880
cpus/PowerPC,POWER5@0/timebase-frequency
0b354b10 (188042000)
cpus/PowerPC,POWER5@0/ibm,extended-timebase-frequency
00000000 0b354b10
Signed-off-by: Anton Blanchard <anton@samba.org>
---
Index: build/arch/powerpc/kernel/time.c
===================================================================
--- build.orig/arch/powerpc/kernel/time.c 2006-06-20 11:55:34.000000000 +1000
+++ build/arch/powerpc/kernel/time.c 2006-06-20 18:25:35.000000000 +1000
@@ -857,42 +857,50 @@ int do_settimeofday(struct timespec *tv)
EXPORT_SYMBOL(do_settimeofday);
-void __init generic_calibrate_decr(void)
+static int __init get_freq(char *name, int cells, unsigned long *val)
{
struct device_node *cpu;
unsigned int *fp;
- int node_found;
+ int found = 0;
- /*
- * The cpu node should have a timebase-frequency property
- * to tell us the rate at which the decrementer counts.
- */
+ /* The cpu node should have timebase and clock frequency properties */
cpu = of_find_node_by_type(NULL, "cpu");
- ppc_tb_freq = DEFAULT_TB_FREQ; /* hardcoded default */
- node_found = 0;
if (cpu) {
- fp = (unsigned int *)get_property(cpu, "timebase-frequency",
- NULL);
+ fp = (unsigned int *)get_property(cpu, name, NULL);
if (fp) {
- node_found = 1;
- ppc_tb_freq = *fp;
+ found = 1;
+ *val = 0;
+ while (cells--)
+ *val = (*val << 32) | *fp++;
}
+
+ of_node_put(cpu);
}
- if (!node_found)
+
+ return found;
+}
+
+void __init generic_calibrate_decr(void)
+{
+ ppc_tb_freq = DEFAULT_TB_FREQ; /* hardcoded default */
+
+ if (!get_freq("ibm,extended-timebase-frequency", 2, &ppc_tb_freq) &&
+ !get_freq("timebase-frequency", 1, &ppc_tb_freq)) {
+
printk(KERN_ERR "WARNING: Estimating decrementer frequency "
"(not found)\n");
+ }
- ppc_proc_freq = DEFAULT_PROC_FREQ;
- node_found = 0;
- if (cpu) {
- fp = (unsigned int *)get_property(cpu, "clock-frequency",
- NULL);
- if (fp) {
- node_found = 1;
- ppc_proc_freq = *fp;
- }
+ ppc_proc_freq = DEFAULT_PROC_FREQ; /* hardcoded default */
+
+ if (!get_freq("ibm,extended-clock-frequency", 2, &ppc_proc_freq) &&
+ !get_freq("clock-frequency", 1, &ppc_proc_freq)) {
+
+ printk(KERN_ERR "WARNING: Estimating processor frequency "
+ "(not found)\n");
}
+
#ifdef CONFIG_BOOKE
/* Set the time base to zero */
mtspr(SPRN_TBWL, 0);
@@ -904,11 +912,6 @@ void __init generic_calibrate_decr(void)
/* Enable decrementer interrupt */
mtspr(SPRN_TCR, TCR_DIE);
#endif
- if (!node_found)
- printk(KERN_ERR "WARNING: Estimating processor frequency "
- "(not found)\n");
-
- of_node_put(cpu);
}
unsigned long get_boot_time(void)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] powerpc: support ibm,extended-*-frequency properties
2006-06-20 8:47 [PATCH] powerpc: support ibm,extended-*-frequency properties Anton Blanchard
@ 2006-06-20 9:50 ` Segher Boessenkool
2006-06-28 11:28 ` Anton Blanchard
2006-06-28 4:48 ` Kumar Gala
1 sibling, 1 reply; 6+ messages in thread
From: Segher Boessenkool @ 2006-06-20 9:50 UTC (permalink / raw)
To: Anton Blanchard; +Cc: linuxppc-dev, paulus
Hi Anton,
> Support the ibm,extended-*-frequency properties found in recent POWER5
> firmware:
>
> cpus/PowerPC,POWER5@0/clock-frequency
> 59aa5880 (1504336000)
> cpus/PowerPC,POWER5@0/ibm,extended-clock-frequency
> 00000000 59aa5880
> cpus/PowerPC,POWER5@0/timebase-frequency
> 0b354b10 (188042000)
> cpus/PowerPC,POWER5@0/ibm,extended-timebase-frequency
> 00000000 0b354b10
Could you also allow the regular "timebase-frequency" property
to consist of two cells, with the same semantics? That's what
some other systems do. Hey, it'd simplify this code, if anything :-)
In fact, some kernel code already does this if I'm not mistaken
(the Cell port, perhaps?)
Segher
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] powerpc: support ibm,extended-*-frequency properties
2006-06-20 8:47 [PATCH] powerpc: support ibm,extended-*-frequency properties Anton Blanchard
2006-06-20 9:50 ` Segher Boessenkool
@ 2006-06-28 4:48 ` Kumar Gala
2006-06-28 11:15 ` Segher Boessenkool
2006-06-29 21:27 ` Olof Johansson
1 sibling, 2 replies; 6+ messages in thread
From: Kumar Gala @ 2006-06-28 4:48 UTC (permalink / raw)
To: Anton Blanchard; +Cc: linuxppc-dev, paulus
On Jun 20, 2006, at 3:47 AM, Anton Blanchard wrote:
>
> Support the ibm,extended-*-frequency properties found in recent POWER5
> firmware:
>
> cpus/PowerPC,POWER5@0/clock-frequency
> 59aa5880 (1504336000)
> cpus/PowerPC,POWER5@0/ibm,extended-clock-frequency
> 00000000 59aa5880
> cpus/PowerPC,POWER5@0/timebase-frequency
> 0b354b10 (188042000)
> cpus/PowerPC,POWER5@0/ibm,extended-timebase-frequency
> 00000000 0b354b10
>
> Signed-off-by: Anton Blanchard <anton@samba.org>
> ---
>
> Index: build/arch/powerpc/kernel/time.c
> ===================================================================
> --- build.orig/arch/powerpc/kernel/time.c 2006-06-20
> 11:55:34.000000000 +1000
> +++ build/arch/powerpc/kernel/time.c 2006-06-20 18:25:35.000000000
> +1000
> @@ -857,42 +857,50 @@ int do_settimeofday(struct timespec *tv)
>
> EXPORT_SYMBOL(do_settimeofday);
>
> -void __init generic_calibrate_decr(void)
> +static int __init get_freq(char *name, int cells, unsigned long *val)
> {
> struct device_node *cpu;
> unsigned int *fp;
> - int node_found;
> + int found = 0;
>
> - /*
> - * The cpu node should have a timebase-frequency property
> - * to tell us the rate at which the decrementer counts.
> - */
> + /* The cpu node should have timebase and clock frequency
> properties */
> cpu = of_find_node_by_type(NULL, "cpu");
>
> - ppc_tb_freq = DEFAULT_TB_FREQ; /* hardcoded default */
> - node_found = 0;
> if (cpu) {
> - fp = (unsigned int *)get_property(cpu, "timebase-frequency",
> - NULL);
> + fp = (unsigned int *)get_property(cpu, name, NULL);
> if (fp) {
> - node_found = 1;
> - ppc_tb_freq = *fp;
> + found = 1;
> + *val = 0;
> + while (cells--)
> + *val = (*val << 32) | *fp++;
Is it reasonable for cells to be greater than 1 on a 32-bit system?
If not, ok to protect this with a CONFIG_PPC64
> }
> +
> + of_node_put(cpu);
> }
> - if (!node_found)
> +
> + return found;
> +}
> +
> +void __init generic_calibrate_decr(void)
> +{
> + ppc_tb_freq = DEFAULT_TB_FREQ; /* hardcoded default */
> +
> + if (!get_freq("ibm,extended-timebase-frequency", 2, &ppc_tb_freq) &&
> + !get_freq("timebase-frequency", 1, &ppc_tb_freq)) {
> +
> printk(KERN_ERR "WARNING: Estimating decrementer frequency "
> "(not found)\n");
> + }
>
> - ppc_proc_freq = DEFAULT_PROC_FREQ;
> - node_found = 0;
> - if (cpu) {
> - fp = (unsigned int *)get_property(cpu, "clock-frequency",
> - NULL);
> - if (fp) {
> - node_found = 1;
> - ppc_proc_freq = *fp;
> - }
> + ppc_proc_freq = DEFAULT_PROC_FREQ; /* hardcoded default */
> +
> + if (!get_freq("ibm,extended-clock-frequency", 2, &ppc_proc_freq) &&
> + !get_freq("clock-frequency", 1, &ppc_proc_freq)) {
> +
> + printk(KERN_ERR "WARNING: Estimating processor frequency "
> + "(not found)\n");
> }
> +
> #ifdef CONFIG_BOOKE
> /* Set the time base to zero */
> mtspr(SPRN_TBWL, 0);
> @@ -904,11 +912,6 @@ void __init generic_calibrate_decr(void)
> /* Enable decrementer interrupt */
> mtspr(SPRN_TCR, TCR_DIE);
> #endif
> - if (!node_found)
> - printk(KERN_ERR "WARNING: Estimating processor frequency "
> - "(not found)\n");
> -
> - of_node_put(cpu);
> }
>
> unsigned long get_boot_time(void)
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] powerpc: support ibm,extended-*-frequency properties
2006-06-28 4:48 ` Kumar Gala
@ 2006-06-28 11:15 ` Segher Boessenkool
2006-06-29 21:27 ` Olof Johansson
1 sibling, 0 replies; 6+ messages in thread
From: Segher Boessenkool @ 2006-06-28 11:15 UTC (permalink / raw)
To: Kumar Gala; +Cc: linuxppc-dev, paulus, Anton Blanchard
> Is it reasonable for cells to be greater than 1 on a 32-bit system?
Yes.
Segher
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] powerpc: support ibm,extended-*-frequency properties
2006-06-20 9:50 ` Segher Boessenkool
@ 2006-06-28 11:28 ` Anton Blanchard
0 siblings, 0 replies; 6+ messages in thread
From: Anton Blanchard @ 2006-06-28 11:28 UTC (permalink / raw)
To: Segher Boessenkool; +Cc: linuxppc-dev, paulus
> Could you also allow the regular "timebase-frequency" property
> to consist of two cells, with the same semantics? That's what
> some other systems do. Hey, it'd simplify this code, if anything :-)
>
> In fact, some kernel code already does this if I'm not mistaken
> (the Cell port, perhaps?)
Yeah it seems reasonable to just use the property size, I'll submit an
incremental patch for that.
Anton
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] powerpc: support ibm,extended-*-frequency properties
2006-06-28 4:48 ` Kumar Gala
2006-06-28 11:15 ` Segher Boessenkool
@ 2006-06-29 21:27 ` Olof Johansson
1 sibling, 0 replies; 6+ messages in thread
From: Olof Johansson @ 2006-06-29 21:27 UTC (permalink / raw)
To: Kumar Gala; +Cc: linuxppc-dev, paulus, Anton Blanchard
On Tue, Jun 27, 2006 at 11:48:57PM -0500, Kumar Gala wrote:
> On Jun 20, 2006, at 3:47 AM, Anton Blanchard wrote:
> > + while (cells--)
> > + *val = (*val << 32) | *fp++;
>
> Is it reasonable for cells to be greater than 1 on a 32-bit system?
> If not, ok to protect this with a CONFIG_PPC64
Well, large values will be broken on 32-bit no matter what right now:
CC arch/powerpc/kernel/time.o
arch/powerpc/kernel/time.c: In function ‘get_freq’:
arch/powerpc/kernel/time.c:875: warning: left shift count >= width of type
-Olof
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-06-29 21:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-20 8:47 [PATCH] powerpc: support ibm,extended-*-frequency properties Anton Blanchard
2006-06-20 9:50 ` Segher Boessenkool
2006-06-28 11:28 ` Anton Blanchard
2006-06-28 4:48 ` Kumar Gala
2006-06-28 11:15 ` Segher Boessenkool
2006-06-29 21:27 ` Olof Johansson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).