Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0bb474a4 authored by Anton Blanchard's avatar Anton Blanchard Committed by Paul Mackerras
Browse files

[POWERPC] support ibm,extended-*-frequency properties



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: default avatarAnton Blanchard <anton@samba.org>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent ccba051c
Loading
Loading
Loading
Loading
+30 −27
Original line number Original line Diff line number Diff line
@@ -857,42 +857,50 @@ int do_settimeofday(struct timespec *tv)


EXPORT_SYMBOL(do_settimeofday);
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;
	struct device_node *cpu;
	unsigned int *fp;
	unsigned int *fp;
	int node_found;
	int found = 0;


	/*
	/* The cpu node should have timebase and clock frequency properties */
	 * The cpu node should have a timebase-frequency property
	 * to tell us the rate at which the decrementer counts.
	 */
	cpu = of_find_node_by_type(NULL, "cpu");
	cpu = of_find_node_by_type(NULL, "cpu");


	ppc_tb_freq = DEFAULT_TB_FREQ;		/* hardcoded default */
	node_found = 0;
	if (cpu) {
	if (cpu) {
		fp = (unsigned int *)get_property(cpu, "timebase-frequency",
		fp = (unsigned int *)get_property(cpu, name, NULL);
						  NULL);
		if (fp) {
		if (fp) {
			node_found = 1;
			found = 1;
			ppc_tb_freq = *fp;
			*val = 0;
			while (cells--)
				*val = (*val << 32) | *fp++;
		}

		of_node_put(cpu);
	}
	}

	return found;
}
}
	if (!node_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 "
		printk(KERN_ERR "WARNING: Estimating decrementer frequency "
				"(not found)\n");
				"(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
#ifdef CONFIG_BOOKE
	/* Set the time base to zero */
	/* Set the time base to zero */
	mtspr(SPRN_TBWL, 0);
	mtspr(SPRN_TBWL, 0);
@@ -904,11 +912,6 @@ void __init generic_calibrate_decr(void)
	/* Enable decrementer interrupt */
	/* Enable decrementer interrupt */
	mtspr(SPRN_TCR, TCR_DIE);
	mtspr(SPRN_TCR, TCR_DIE);
#endif
#endif
	if (!node_found)
		printk(KERN_ERR "WARNING: Estimating processor frequency "
				"(not found)\n");

	of_node_put(cpu);
}
}


unsigned long get_boot_time(void)
unsigned long get_boot_time(void)