LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/3] powerpc: setup_64 comment cleanup.
From: Linas Vepstas @ 2007-09-06 17:47 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: ppc-dev
In-Reply-To: <20070906174615.GB21800@austin.ibm.com>


Gramatical corrections to comments.

Signed-off-by: Linas Vepstas <linas@austin.ibm.com>

----

 arch/powerpc/kernel/prom.c     |    8 +++++---
 arch/powerpc/kernel/setup_64.c |    6 +++---
 2 files changed, 8 insertions(+), 6 deletions(-)

Index: linux-2.6.22-git2/arch/powerpc/kernel/setup_64.c
===================================================================
--- linux-2.6.22-git2.orig/arch/powerpc/kernel/setup_64.c	2007-09-04 17:29:36.000000000 -0500
+++ linux-2.6.22-git2/arch/powerpc/kernel/setup_64.c	2007-09-05 14:12:23.000000000 -0500
@@ -181,9 +181,9 @@ void __init early_setup(unsigned long dt
  	DBG(" -> early_setup(), dt_ptr: 0x%lx\n", dt_ptr);
 
 	/*
-	 * Do early initializations using the flattened device
-	 * tree, like retreiving the physical memory map or
-	 * calculating/retreiving the hash table size
+	 * Do early initialization using the flattened device
+	 * tree, such as retrieving the physical memory map or
+	 * calculating/retrieving the hash table size.
 	 */
 	early_init_devtree(__va(dt_ptr));
 
Index: linux-2.6.22-git2/arch/powerpc/kernel/prom.c
===================================================================
--- linux-2.6.22-git2.orig/arch/powerpc/kernel/prom.c	2007-09-05 14:23:06.000000000 -0500
+++ linux-2.6.22-git2/arch/powerpc/kernel/prom.c	2007-09-05 14:24:49.000000000 -0500
@@ -433,9 +433,11 @@ static int __init early_parse_mem(char *
 }
 early_param("mem", early_parse_mem);
 
-/*
- * The device tree may be allocated below our memory limit, or inside the
- * crash kernel region for kdump. If so, move it out now.
+/**
+ * move_device_tree - move tree to an unused area, if needed.
+ *
+ * The device tree may be allocated beyond our memory limit, or inside the
+ * crash kernel region for kdump. If so, move it out of the way.
  */
 static void move_device_tree(void)
 {

^ permalink raw reply

* Re: [PATCH 8/9] 8xx: Adder 875 support
From: Segher Boessenkool @ 2007-09-06 17:50 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev
In-Reply-To: <20070906141620.GB16353@ld0162-tx32.am.freescale.net>

>>> +	model = "Analogue & Micro Adder MPC875";
>>
>> This should probably be just "MPC875".
>
> There's more than one board with an MPC875 on it.

"model" is the model name the vendor uses.  It isn't supposed to
be unique globally, nor does it say what CPU is on the board.


Segher

^ permalink raw reply

* [PATCH 1/3] powerpc: prom_init whitespace cleanup, typo fix.
From: Linas Vepstas @ 2007-09-06 17:45 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: ppc-dev
In-Reply-To: <20070906174416.GW4584@austin.ibm.com>


Whitespace cleanup: badly indented lines.
Typo in comment.

Signed-off-by: Linas Vepstas <linas@austin.ibm.com>

----

 arch/powerpc/kernel/prom_init.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Index: linux-2.6.22-git2/arch/powerpc/kernel/prom_init.c
===================================================================
--- linux-2.6.22-git2.orig/arch/powerpc/kernel/prom_init.c	2007-07-08 18:32:17.000000000 -0500
+++ linux-2.6.22-git2/arch/powerpc/kernel/prom_init.c	2007-08-28 16:40:26.000000000 -0500
@@ -1197,7 +1197,7 @@ static void __init prom_initialize_tce_t
 		if ((type[0] == 0) || (strstr(type, RELOC("pci")) == NULL))
 			continue;
 
-		/* Keep the old logic in tack to avoid regression. */
+		/* Keep the old logic intact to avoid regression. */
 		if (compatible[0] != 0) {
 			if ((strstr(compatible, RELOC("python")) == NULL) &&
 			    (strstr(compatible, RELOC("Speedwagon")) == NULL) &&
@@ -2224,7 +2224,7 @@ static void __init fixup_device_tree(voi
 
 static void __init prom_find_boot_cpu(void)
 {
-       	struct prom_t *_prom = &RELOC(prom);
+	struct prom_t *_prom = &RELOC(prom);
 	u32 getprop_rval;
 	ihandle prom_cpu;
 	phandle cpu_pkg;
@@ -2244,7 +2244,7 @@ static void __init prom_find_boot_cpu(vo
 static void __init prom_check_initrd(unsigned long r3, unsigned long r4)
 {
 #ifdef CONFIG_BLK_DEV_INITRD
-       	struct prom_t *_prom = &RELOC(prom);
+	struct prom_t *_prom = &RELOC(prom);
 
 	if (r3 && r4 && r4 != 0xdeadbeef) {
 		unsigned long val;
@@ -2277,7 +2277,7 @@ unsigned long __init prom_init(unsigned 
 			       unsigned long pp,
 			       unsigned long r6, unsigned long r7)
 {	
-       	struct prom_t *_prom;
+	struct prom_t *_prom;
 	unsigned long hdr;
 	unsigned long offset = reloc_offset();
 
@@ -2336,8 +2336,8 @@ unsigned long __init prom_init(unsigned 
 	/*
 	 * Copy the CPU hold code
 	 */
-       	if (RELOC(of_platform) != PLATFORM_POWERMAC)
-       		copy_and_flush(0, KERNELBASE + offset, 0x100, 0);
+	if (RELOC(of_platform) != PLATFORM_POWERMAC)
+		copy_and_flush(0, KERNELBASE + offset, 0x100, 0);
 
 	/*
 	 * Do early parsing of command line

^ permalink raw reply

* [PATCH 2/3] powerpc: prom whitespace cleanup
From: Linas Vepstas @ 2007-09-06 17:46 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: ppc-dev
In-Reply-To: <20070906174521.GA21800@austin.ibm.com>


Whitespace cleanup: badly indented lines.

Signed-off-by: Linas Vepstas <linas@austin.ibm.com>

----

 arch/powerpc/kernel/prom.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Index: linux-2.6.22-git2/arch/powerpc/kernel/prom.c
===================================================================
--- linux-2.6.22-git2.orig/arch/powerpc/kernel/prom.c	2007-08-29 14:14:12.000000000 -0500
+++ linux-2.6.22-git2/arch/powerpc/kernel/prom.c	2007-08-29 14:15:10.000000000 -0500
@@ -782,13 +782,13 @@ static int __init early_init_dt_scan_cho
 #endif
 
 #ifdef CONFIG_KEXEC
-       lprop = (u64*)of_get_flat_dt_prop(node, "linux,crashkernel-base", NULL);
-       if (lprop)
-               crashk_res.start = *lprop;
-
-       lprop = (u64*)of_get_flat_dt_prop(node, "linux,crashkernel-size", NULL);
-       if (lprop)
-               crashk_res.end = crashk_res.start + *lprop - 1;
+	lprop = (u64*)of_get_flat_dt_prop(node, "linux,crashkernel-base", NULL);
+	if (lprop)
+		crashk_res.start = *lprop;
+
+	lprop = (u64*)of_get_flat_dt_prop(node, "linux,crashkernel-size", NULL);
+	if (lprop)
+		crashk_res.end = crashk_res.start + *lprop - 1;
 #endif
 
 	early_init_dt_check_for_initrd(node);

^ permalink raw reply

* [PATCH 0/3] powerpc: whitespace cleanup, grammar corrections
From: Linas Vepstas @ 2007-09-06 17:44 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: ppc-dev


These popped out at me while I was reading code.
Its all janitorial.

--linas

^ permalink raw reply

* Re: Support a new platform in arch/ppc or in arch/powerpc ?
From: Josh Boyer @ 2007-09-06 17:42 UTC (permalink / raw)
  To: CHAVENT Paul; +Cc: linuxppc-embedded
In-Reply-To: <631F24C6E5322142A5BDEFA2E8518080297862@tls01.criltechnology.net>

On Thu, 6 Sep 2007 18:53:54 +0200
"CHAVENT Paul" <Paul.CHAVENT@alyotech.fr> wrote:

> Good morning.
> 
> I would like to port a bsp (for the motorola MVME5500 sbc) to the current (2.6.22.6) kernel.
> 
> Should i implement it in arch/powerpc ?

Yes.  arch/ppc is bug fix only at this point.

> If i should do it in arch/powerpc, can i copy some code i need in arch/ppc ? For example, with kernel 2.6.18.1 i used arch/ppc/syslib/todc_time and arch/ppc/syslib/pci_auto, but perhaps i don't need it anymore ?

I'm not sure those will work well in arch/powerpc.  But obviously some
code porting is expected.

josh

^ permalink raw reply

* Re: [RFC/PATCH 1/2] Basic generic time/clocksource code for PowerPC
From: Scott Wood @ 2007-09-06 17:24 UTC (permalink / raw)
  To: Gabriel Paubert; +Cc: linuxppc-dev, Paul Mackerras
In-Reply-To: <20070906170547.GA12432@iram.es>

On Thu, Sep 06, 2007 at 07:05:47PM +0200, Gabriel Paubert wrote:
> On Thu, Sep 06, 2007 at 12:01:23PM -0500, Scott Wood wrote:
> > On Thu, Sep 06, 2007 at 06:55:35PM +0200, Gabriel Paubert wrote:
> > > So who will be in charge of updating the RTC now? The update 
> > > every 11 min is there to stay on x86(-64) it seems.
> > 
> > Put something in crontab to run hwclock periodically.
> 
> I have many machines on which cron is not even installed.

OK, so use something else that waits in a loop and periodically updates
the clock.  It shouldn't be the kernel's responsibility.

-Scott

^ permalink raw reply

* Re: [RFC/PATCH 1/2] Basic generic time/clocksource code for PowerPC
From: Gabriel Paubert @ 2007-09-06 17:05 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev, Paul Mackerras
In-Reply-To: <20070906170123.GA17990@ld0162-tx32.am.freescale.net>

On Thu, Sep 06, 2007 at 12:01:23PM -0500, Scott Wood wrote:
> On Thu, Sep 06, 2007 at 06:55:35PM +0200, Gabriel Paubert wrote:
> > On Fri, Sep 07, 2007 at 12:41:38AM +1000, Paul Mackerras wrote:
> > > This changes PowerPC to use the generic time infrastructure for
> > > gettimeofday et al.  We register a clocksource which uses the timebase
> > > register, or the RTC on the 601.
> > > 
> > > It also gets rid of the RTC update stuff.  IIRC we discussed removing
> > > this some time ago but never actually did it.
> > 
> > So who will be in charge of updating the RTC now? The update 
> > every 11 min is there to stay on x86(-64) it seems.
> 
> Put something in crontab to run hwclock periodically.
> 

I have many machines on which cron is not even installed.

	Gabriel

^ permalink raw reply

* How to use MMC-over-SPI on MPC8313E
From: Vinu @ 2007-09-06 16:48 UTC (permalink / raw)
  To: linuxppc-dev

Hi all,

I am working on MPC8313ERDB  Eval board, and want to  use SD Memory card 
to store Linux OS and file system.
The SD card controller is connected directly with the SPI bus.

I simply don't know how to use MMC-over-SPI  technology to make SD card 
usable.

It would be a great help if anybody have any documentation or driver etc.

Thanks.

v2g

^ permalink raw reply

* Support a new platform in arch/ppc or in arch/powerpc ?
From: CHAVENT Paul @ 2007-09-06 16:53 UTC (permalink / raw)
  To: linuxppc-embedded

Good morning.

I would like to port a bsp (for the motorola MVME5500 sbc) to the =
current (2.6.22.6) kernel.

Should i implement it in arch/powerpc ?

If i should do it in arch/powerpc, can i copy some code i need in =
arch/ppc ? For example, with kernel 2.6.18.1 i used =
arch/ppc/syslib/todc_time and arch/ppc/syslib/pci_auto, but perhaps i =
don't need it anymore ?

Is there any recommandation for arch/powerpc implementation ?

Thank you.

Paul.

^ permalink raw reply

* Re: [RFC/PATCH 1/2] Basic generic time/clocksource code for PowerPC
From: Scott Wood @ 2007-09-06 17:01 UTC (permalink / raw)
  To: Gabriel Paubert; +Cc: linuxppc-dev, Paul Mackerras
In-Reply-To: <20070906165535.GA11420@iram.es>

On Thu, Sep 06, 2007 at 06:55:35PM +0200, Gabriel Paubert wrote:
> On Fri, Sep 07, 2007 at 12:41:38AM +1000, Paul Mackerras wrote:
> > This changes PowerPC to use the generic time infrastructure for
> > gettimeofday et al.  We register a clocksource which uses the timebase
> > register, or the RTC on the 601.
> > 
> > It also gets rid of the RTC update stuff.  IIRC we discussed removing
> > this some time ago but never actually did it.
> 
> So who will be in charge of updating the RTC now? The update 
> every 11 min is there to stay on x86(-64) it seems.

Put something in crontab to run hwclock periodically.

-Scott

^ permalink raw reply

* Re: Keep On Debugging You
From: Scott Wood @ 2007-09-06 16:56 UTC (permalink / raw)
  To: Linas Vepstas; +Cc: linuxppc-dev, Zhang Wei-r63237, Timur Tabi, Timur Tabi
In-Reply-To: <20070906165133.GV4584@austin.ibm.com>

On Thu, Sep 06, 2007 at 11:51:33AM -0500, Linas Vepstas wrote:
> On Thu, Sep 06, 2007 at 10:21:43AM -0500, Timur Tabi wrote:
> > Zhang Wei-r63237 wrote:
> > > Oops!
> > > 
> > > Could you give us a live show version? :D  
> > 
> > Sorry, I'm booked up for the rest of the year.
> 
> Hmm. Maybe someone could sneak a videocam into one of the
> venues, and, you know, post a pirated, illegal copy on
> youtube or something.

I think that's allowed, as long as you also post the sheet music, don't
restrict further distribution in any way that it isn't already, and
precede the video with a copyright statement and disclaimer of warranty
when the play button is pressed in the most ordinary way. :-)

-Scott

^ permalink raw reply

* Re: [RFC/PATCH 1/2] Basic generic time/clocksource code for PowerPC
From: Gabriel Paubert @ 2007-09-06 16:55 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev
In-Reply-To: <18144.4514.601900.881855@cargo.ozlabs.ibm.com>

On Fri, Sep 07, 2007 at 12:41:38AM +1000, Paul Mackerras wrote:
> This changes PowerPC to use the generic time infrastructure for
> gettimeofday et al.  We register a clocksource which uses the timebase
> register, or the RTC on the 601.
> 
> It also gets rid of the RTC update stuff.  IIRC we discussed removing
> this some time ago but never actually did it.

So who will be in charge of updating the RTC now? The update 
every 11 min is there to stay on x86(-64) it seems.

Removing this will have strange side effects: as an example,
your laptop clock will be good if it synchronized on NTP, 
then you put it to sleep, disconnect the network and RTC read 
on wake up returns a wrong value, giving wrong timestamps.

As someone who has a network of tens of machines using
NTP for synchornisation I think it is a very bad idea
unless we have a replacement.

	Gabriel

^ permalink raw reply

* Re: Keep On Debugging You
From: Linas Vepstas @ 2007-09-06 16:51 UTC (permalink / raw)
  To: Timur Tabi; +Cc: linuxppc-dev, Timur Tabi, Zhang Wei-r63237
In-Reply-To: <46E01B07.3040804@freescale.com>

On Thu, Sep 06, 2007 at 10:21:43AM -0500, Timur Tabi wrote:
> Zhang Wei-r63237 wrote:
> > Oops!
> > 
> > Could you give us a live show version? :D  
> 
> Sorry, I'm booked up for the rest of the year.

Hmm. Maybe someone could sneak a videocam into one of the
venues, and, you know, post a pirated, illegal copy on
youtube or something.

--linas

^ permalink raw reply

* [PATCH 2.6.23] PS3: Ignore storage devices that are still being probed
From: Geert Uytterhoeven @ 2007-09-06 16:14 UTC (permalink / raw)
  To: Paul Mackerras
  Cc: Linux/PPC Development, Andrew Morton,
	Cell Broadband Engine OSS Development

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2632 bytes --]

PS3: A storage device may show up in the repository before the hypervisor has
finished probing:
  - If its type is not yet known, it shows up as PS3_DEV_TYPE_STOR_DUMMY,
  - If its regions are being probed, it shows up as having zero regions.
If any of these happen, consider the device not yet present.  The storage
probe thread will retry later.

This fixes the timing-dependent problem where a kernel booted from FLASH ROM
sometimes cannot find the hard disk.

Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
---
 arch/powerpc/platforms/ps3/platform.h   |    1 +
 arch/powerpc/platforms/ps3/repository.c |   29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

--- a/arch/powerpc/platforms/ps3/platform.h
+++ b/arch/powerpc/platforms/ps3/platform.h
@@ -83,6 +83,7 @@ enum ps3_dev_type {
 	PS3_DEV_TYPE_STOR_ROM = TYPE_ROM,	/* 5 */
 	PS3_DEV_TYPE_SB_GPIO = 6,
 	PS3_DEV_TYPE_STOR_FLASH = TYPE_RBC,	/* 14 */
+	PS3_DEV_TYPE_STOR_DUMMY = 32,
 	PS3_DEV_TYPE_NOACCESS = 255,
 };
 
--- a/arch/powerpc/platforms/ps3/repository.c
+++ b/arch/powerpc/platforms/ps3/repository.c
@@ -349,6 +349,35 @@ int ps3_repository_find_device(struct ps
 		return result;
 	}
 
+	if (tmp.bus_type == PS3_BUS_TYPE_STORAGE) {
+		/*
+		 * A storage device may show up in the repository before the
+		 * hypervisor has finished probing its type and regions
+		 */
+		unsigned int num_regions;
+
+		if (tmp.dev_type == PS3_DEV_TYPE_STOR_DUMMY) {
+			pr_debug("%s:%u storage device not ready\n", __func__,
+				 __LINE__);
+			return -ENODEV;
+		}
+
+		result = ps3_repository_read_stor_dev_num_regions(tmp.bus_index,
+								  tmp.dev_index,
+								  &num_regions);
+		if (result) {
+			pr_debug("%s:%d read_stor_dev_num_regions failed\n",
+				 __func__, __LINE__);
+			return result;
+		}
+
+		if (!num_regions) {
+			pr_debug("%s:%u storage device has no regions yet\n",
+				 __func__, __LINE__);
+			return -ENODEV;
+		}
+	}
+
 	result = ps3_repository_read_dev_id(tmp.bus_index, tmp.dev_index,
 		&tmp.dev_id);
 

With kind regards,
 
Geert Uytterhoeven
Software Architect

Sony Network and Software Technology Center Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium
 
Phone:    +32 (0)2 700 8453	
Fax:      +32 (0)2 700 8622	
E-mail:   Geert.Uytterhoeven@sonycom.com	
Internet: http://www.sony-europe.com/
 	
Sony Network and Software Technology Center Europe	
A division of Sony Service Centre (Europe) N.V.	
Registered office: Technologielaan 7 · B-1840 Londerzeel · Belgium	
VAT BE 0413.825.160 · RPR Brussels	
Fortis Bank Zaventem · Swift GEBABEBB08A · IBAN BE39001382358619

^ permalink raw reply

* Re: Configuring for UPM on MPC82xx using new device binding from Scott
From: Scott Wood @ 2007-09-06 15:53 UTC (permalink / raw)
  To: Esben Haabendal; +Cc: linuxppc-dev
In-Reply-To: <b0c1bc04d7f1f36bd546cd46ea1e035a@127.0.0.1>

On Thu, Sep 06, 2007 at 04:23:49PM +0200, Esben Haabendal wrote:
> Is it possible to configure chipselect to use UPM A and UPM B in an
> MPC8270 chip using the new CPM device bindings patches from Scott?
> 
> I need to pass in the 3 bits for MS (machine select to the relevant MRx
> register).

The BRx setup should be done by the firmware if at all possible.
As long as the entry is valid, cuboot-pq2.c shouldn't change the
attributes.

-Scott

^ permalink raw reply

* Re: Keep On Debugging You
From: Timur Tabi @ 2007-09-06 15:21 UTC (permalink / raw)
  To: Zhang Wei-r63237; +Cc: linuxppc-dev, Timur Tabi
In-Reply-To: <46B96294322F7D458F9648B60E15112C81293B@zch01exm26.fsl.freescale.net>

Zhang Wei-r63237 wrote:
> Oops!
> 
> Could you give us a live show version? :D  

Sorry, I'm booked up for the rest of the year.

-- 
Timur Tabi
Linux Kernel Developer @ Freescale

^ permalink raw reply

* Re: [PATCH] powerpc: Add workaround for MPICs with broken register reads
From: Milton Miller @ 2007-09-06 14:55 UTC (permalink / raw)
  To: Olof Johansson; +Cc: ppcdev
In-Reply-To: <20070905024417.GE27139@lixom.net>

On Wed Sep 5 12:44:17 EST 2007, Olof Johansson wrote:
> diff --git a/arch/powerpc/platforms/Kconfig 
> b/arch/powerpc/platforms/Kconfig
> index 041df77..b9f1efa 100644
> --- a/arch/powerpc/platforms/Kconfig
> +++ b/arch/powerpc/platforms/Kconfig
> @@ -137,6 +137,10 @@ config MPIC_U3_HT_IRQS
>         depends on PPC_MAPLE
>         default y
>
> +config MPIC_BROKEN_REGREAD
> +       bool
> +       depends on PPC_PASEMI
> +
>  config IBMVIO
>         depends on PPC_PSERIES || PPC_ISERIES
>         bool
> diff --git a/arch/powerpc/platforms/pasemi/Kconfig 
> b/arch/powerpc/platforms/pasemi/Kconfig
> index 95cd90f..117d90a 100644
> --- a/arch/powerpc/platforms/pasemi/Kconfig
> +++ b/arch/powerpc/platforms/pasemi/Kconfig
> @@ -5,6 +5,7 @@ config PPC_PASEMI
>         select MPIC
>         select PPC_UDBG_16550
>         select PPC_NATIVE
> +       select MPIC_BROKEN_REGREAD
>         help
>           This option enables support for PA Semi's PWRficient line
>           of SoC processors, including PA6T-1682M


Since you are using select (and not default y), instead of the depends 
on PPC_PASEMI how about adding a short description of what the config 
does as help text, in case some future mpic has a similar bug?

milton

^ permalink raw reply

* [RFC/PATCH 2/2] Generic clockevents and no-idle-HZ for PowerPC
From: Paul Mackerras @ 2007-09-06 14:44 UTC (permalink / raw)
  To: linuxppc-dev

This creates a clockevent for the PowerPC decrementer and registers it
with the generic clock/timer system, and implements the dynamic ticks
(no idle HZ) option for PowerPC.

This is based largely on an earlier patch by Tony Breeds.  It could
still use more cleanup.  This and the previous patch seem to be
working fine on my G4 powerbook (ppc32).

Signed-off-by: Paul Mackerras <paulus@samba.org>
---
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index ebecc85..9a4fac2 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -27,6 +27,9 @@ config GENERIC_TIME
 config GENERIC_TIME_VSYSCALL
 	def_bool y
 
+config GENERIC_CLOCKEVENTS
+	def_bool y
+
 config GENERIC_HARDIRQS
 	bool
 	default y
@@ -162,6 +165,7 @@ config HIGHMEM
 	bool "High memory support"
 	depends on PPC32
 
+source kernel/time/Kconfig
 source kernel/Kconfig.hz
 source kernel/Kconfig.preempt
 source "fs/Kconfig.binfmt"
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index a408053..b2bb50b 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -307,7 +307,6 @@ int main(void)
 	DEFINE(CLOCK_REALTIME, CLOCK_REALTIME);
 	DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC);
 	DEFINE(NSEC_PER_SEC, NSEC_PER_SEC);
-	DEFINE(CLOCK_REALTIME_RES, TICK_NSEC);
 
 #ifdef CONFIG_BUG
 	DEFINE(BUG_ENTRY_SIZE, sizeof(struct bug_entry));
diff --git a/arch/powerpc/kernel/idle.c b/arch/powerpc/kernel/idle.c
index a9e9cbd..abd2957 100644
--- a/arch/powerpc/kernel/idle.c
+++ b/arch/powerpc/kernel/idle.c
@@ -24,6 +24,7 @@
 #include <linux/smp.h>
 #include <linux/cpu.h>
 #include <linux/sysctl.h>
+#include <linux/tick.h>
 
 #include <asm/system.h>
 #include <asm/processor.h>
@@ -59,6 +60,7 @@ void cpu_idle(void)
 
 	set_thread_flag(TIF_POLLING_NRFLAG);
 	while (1) {
+		tick_nohz_stop_sched_tick();
 		while (!need_resched() && !cpu_should_die()) {
 			ppc64_runlatch_off();
 
@@ -90,6 +92,7 @@ void cpu_idle(void)
 
 		HMT_medium();
 		ppc64_runlatch_on();
+		tick_nohz_restart_sched_tick();
 		if (cpu_should_die())
 			cpu_die();
 		preempt_enable_no_resched();
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 1ea4316..1118c2d 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -560,6 +560,9 @@ int __devinit start_secondary(void *unused)
 	if (system_state > SYSTEM_BOOTING)
 		snapshot_timebase();
 
+	/* FIXME: should be in if() above */
+	secondary_cpu_time_init();
+
 	spin_lock(&call_lock);
 	cpu_set(cpu, cpu_online_map);
 	spin_unlock(&call_lock);
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 7e960a2..1353d73 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -78,12 +78,31 @@
 /* TODO:
  *  o Code style
  *    * Variable names ... be consistent.
+ *      - decrementers => events
+ *      - evt == an event source
+ *      - clc == a tb_tick to fire at
+ *      - jiffies  is related to HZ
+ *      - tb_jiffies/tick are releted to the timebase
+ *  o test on PPC32 and other platforms
+ *  o determine compatability with VIRT_CPU_ACCOUNTING
+ *  o Seperate out into other files.
+ *  o Startup, it's ugly, make sure a return value is appropriate
+ *  o HOTPLUG_CPU safe!
+ *    * revmoval / addition.
  *
  * TODO: Clocksource
  *  o iSeries registation and matching it with the titan-recalibrate
- *  o xtime:  Either time.c manages it, or clocksource does, not both
+ *  o Create clocksources for each of the platforms, and store in
+ *    appropriate place
+ *
+ * TODO: Clockevents
+ *  o Create clockevents for each of the platforms, and store in
+ *    appropriate place
+ *  o CPU Hotplug
+ *  o "fair" machanisim for distributing do_timer() updates.
  */
 
+#include <linux/clockchips.h>
 #include <linux/clocksource.h>
 
 static struct clocksource clocksource_timebase = {
@@ -96,6 +115,25 @@ static struct clocksource clocksource_timebase = {
 	.read         = NULL,   /* To be filled in */
 };
 
+#define DECREMENTER_MAX	0x7fffffff
+
+static int decrementer_set_next_event(unsigned long evt,
+				      struct clock_event_device *dev);
+static void decrementer_set_mode(enum clock_event_mode mode,
+				 struct clock_event_device *dev);
+
+static struct clock_event_device decrementer_clockevent = {
+       .name           = "decrementer",
+       .rating         = 200,
+       .shift          = 32,
+       .mult           = 0,	/* To be filled in */
+       .irq            = -1,
+       .set_next_event = decrementer_set_next_event,
+       .set_mode       = decrementer_set_mode,
+       .features       = CLOCK_EVT_FEAT_ONESHOT,
+};
+static DEFINE_PER_CPU(struct clock_event_device, decrementers);
+
 #ifdef CONFIG_PPC_ISERIES
 static unsigned long __initdata iSeries_recal_titan;
 static signed long __initdata iSeries_recal_tb;
@@ -436,7 +474,6 @@ static int __init iSeries_tb_recal(void)
 {
 	struct div_result divres;
 	unsigned long titan, tb;
-	u64 tb_to_xs;
 
 	/* Make sure we only run on iSeries */
 	if (!firmware_has_feature(FW_FEATURE_ISERIES))
@@ -512,10 +549,10 @@ void __init iSeries_time_init_early(void)
 void timer_interrupt(struct pt_regs * regs)
 {
 	struct pt_regs *old_regs;
-	int next_dec;
 	int cpu = smp_processor_id();
 	unsigned long ticks;
 	u64 tb_next_jiffy;
+	struct clock_event_device *evt = &per_cpu(decrementers, cpu);
 
 #ifdef CONFIG_PPC32
 	if (atomic_read(&ppc_n_lost_interrupts) != 0)
@@ -525,7 +562,6 @@ void timer_interrupt(struct pt_regs * regs)
 	old_regs = set_irq_regs(regs);
 	irq_enter();
 
-	profile_tick(CPU_PROFILING);
 	calculate_steal_time();
 
 #ifdef CONFIG_PPC_ISERIES
@@ -533,42 +569,10 @@ void timer_interrupt(struct pt_regs * regs)
 		get_lppaca()->int_dword.fields.decr_int = 0;
 #endif
 
-	while ((ticks = tb_ticks_since(per_cpu(last_jiffy, cpu)))
-	       >= tb_ticks_per_jiffy) {
-		/* Update last_jiffy */
-		per_cpu(last_jiffy, cpu) += tb_ticks_per_jiffy;
-		/* Handle RTCL overflow on 601 */
-		if (__USE_RTC() && per_cpu(last_jiffy, cpu) >= 1000000000)
-			per_cpu(last_jiffy, cpu) -= 1000000000;
-
-		/*
-		 * We cannot disable the decrementer, so in the period
-		 * between this cpu's being marked offline in cpu_online_map
-		 * and calling stop-self, it is taking timer interrupts.
-		 * Avoid calling into the scheduler rebalancing code if this
-		 * is the case.
-		 */
-		if (!cpu_is_offline(cpu))
-			account_process_time(regs);
-
-		/*
-		 * No need to check whether cpu is offline here; boot_cpuid
-		 * should have been fixed up by now.
-		 */
-		if (cpu != boot_cpuid)
-			continue;
-
-		write_seqlock(&xtime_lock);
-		tb_next_jiffy = tb_last_jiffy + tb_ticks_per_jiffy;
-		if (per_cpu(last_jiffy, cpu) >= tb_next_jiffy) {
-			tb_last_jiffy = tb_next_jiffy;
-			do_timer(1);
-		}
-		write_sequnlock(&xtime_lock);
-	}
-	
-	next_dec = tb_ticks_per_jiffy - ticks;
-	set_dec(next_dec);
+	if (evt->event_handler)
+		evt->event_handler(evt);
+	else
+		evt->set_next_event(DECREMENTER_MAX, evt);
 
 #ifdef CONFIG_PPC_ISERIES
 	if (firmware_has_feature(FW_FEATURE_ISERIES) && hvlpevent_is_pending())
@@ -702,6 +706,11 @@ unsigned long get_boot_time(void)
 		      tm.tm_hour, tm.tm_min, tm.tm_sec);
 }
 
+unsigned long read_persistent_clock(void)
+{
+	return get_boot_time();
+}
+
 /* clocksource code */
 static cycle_t timebase_read(void)
 {
@@ -710,6 +719,53 @@ static cycle_t timebase_read(void)
 	return (cycle_t)get_tb();
 }
 
+static int decrementer_set_next_event(unsigned long evt,
+				      struct clock_event_device *dev)
+{
+	set_dec(evt);
+	return 0;
+}
+
+static void decrementer_set_mode(enum clock_event_mode mode,
+				 struct clock_event_device *dev)
+{
+	if (mode != CLOCK_EVT_MODE_ONESHOT)
+		decrementer_set_next_event(DECREMENTER_MAX, dev);
+}
+
+static void register_decrementer_clockevent(int cpu)
+{
+	struct clock_event_device *dec = &per_cpu(decrementers, cpu);
+
+	*dec = decrementer_clockevent;
+	dec->cpumask = cpumask_of_cpu(cpu);
+
+	printk(KERN_ERR "clockevent: %s mult[%lx] shift[%d] cpu[%d]\n",
+	       dec->name, dec->mult, dec->shift, cpu);
+
+	clockevents_register_device(dec);
+}
+
+void init_decrementer_clockevent(void)
+{
+	int cpu = smp_processor_id();
+
+	decrementer_clockevent.mult = div_sc(ppc_tb_freq, NSEC_PER_SEC,
+					     decrementer_clockevent.shift);
+	decrementer_clockevent.max_delta_ns =
+		clockevent_delta2ns(DECREMENTER_MAX, &decrementer_clockevent);
+	decrementer_clockevent.min_delta_ns = 1000;
+
+	register_decrementer_clockevent(cpu);
+}
+
+void secondary_cpu_time_init(void)
+{
+	/* FIME: Should make unrelatred change to move snapshot_timebase
+	 * call here ! */
+	register_decrementer_clockevent(smp_processor_id());
+}
+
 void update_vsyscall(struct timespec *wall_time, struct clocksource *clock)
 {
 	u64 t2x, stamp_xsec;
@@ -749,6 +805,8 @@ void __init clocksource_init(void)
 	printk(KERN_INFO "clocksource: %s mult[%x] shift[%d] registered\n",
 	       clocksource_timebase.name,
 	       clocksource_timebase.mult, clocksource_timebase.shift);
+
+	init_decrementer_clockevent();
 }
 
 /* This function is only called on the boot processor */
@@ -874,8 +932,7 @@ void __init time_init(void)
 	/* Register the clocksource */
 	clocksource_init();
 
-	/* Not exact, but the timer interrupt takes care of this */
-	set_dec(tb_ticks_per_jiffy);
+	set_dec(DECREMENTER_MAX);
 }
 
 
diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S b/arch/powerpc/kernel/vdso32/gettimeofday.S
index 72ca26d..c007658 100644
--- a/arch/powerpc/kernel/vdso32/gettimeofday.S
+++ b/arch/powerpc/kernel/vdso32/gettimeofday.S
@@ -225,8 +225,7 @@ V_FUNCTION_BEGIN(__kernel_clock_getres)
 	cmpli	cr0,r4,0
 	crclr	cr0*4+so
 	beqlr
-	lis	r5,CLOCK_REALTIME_RES@h
-	ori	r5,r5,CLOCK_REALTIME_RES@l
+	li	r5,1
 	stw	r3,TSPC32_TV_SEC(r4)
 	stw	r5,TSPC32_TV_NSEC(r4)
 	blr
diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S
index c6401f9..7d16ddb 100644
--- a/arch/powerpc/kernel/vdso64/gettimeofday.S
+++ b/arch/powerpc/kernel/vdso64/gettimeofday.S
@@ -198,8 +198,7 @@ V_FUNCTION_BEGIN(__kernel_clock_getres)
 	cmpli	cr0,r4,0
 	crclr	cr0*4+so
 	beqlr
-	lis	r5,CLOCK_REALTIME_RES@h
-	ori	r5,r5,CLOCK_REALTIME_RES@l
+	li	r5,1
 	std	r3,TSPC64_TV_SEC(r4)
 	std	r5,TSPC64_TV_NSEC(r4)
 	blr
diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c
index fad493e..6f27db4 100644
--- a/arch/powerpc/platforms/iseries/setup.c
+++ b/arch/powerpc/platforms/iseries/setup.c
@@ -26,6 +26,7 @@
 #include <linux/major.h>
 #include <linux/root_dev.h>
 #include <linux/kernel.h>
+#include <linux/tick.h>
 
 #include <asm/processor.h>
 #include <asm/machdep.h>
@@ -561,6 +562,7 @@ static void yield_shared_processor(void)
 static void iseries_shared_idle(void)
 {
 	while (1) {
+		tick_nohz_stop_sched_tick();
 		while (!need_resched() && !hvlpevent_is_pending()) {
 			local_irq_disable();
 			ppc64_runlatch_off();
@@ -574,6 +576,7 @@ static void iseries_shared_idle(void)
 		}
 
 		ppc64_runlatch_on();
+		tick_nohz_restart_sched_tick();
 
 		if (hvlpevent_is_pending())
 			process_iSeries_events();
@@ -589,6 +592,7 @@ static void iseries_dedicated_idle(void)
 	set_thread_flag(TIF_POLLING_NRFLAG);
 
 	while (1) {
+		tick_nohz_stop_sched_tick();
 		if (!need_resched()) {
 			while (!need_resched()) {
 				ppc64_runlatch_off();
@@ -605,6 +609,7 @@ static void iseries_dedicated_idle(void)
 		}
 
 		ppc64_runlatch_on();
+		tick_nohz_restart_sched_tick();
 		preempt_enable_no_resched();
 		schedule();
 		preempt_disable();
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile
index 08ce31e..3b289cf 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -20,11 +20,6 @@ obj-$(CONFIG_MV64X60)		+= $(mv64x60-y) mv64x60_pic.o mv64x60_dev.o
 obj-$(CONFIG_RTC_DRV_CMOS)	+= rtc_cmos_setup.o
 obj-$(CONFIG_AXON_RAM)		+= axonram.o
 
-# contains only the suspend handler for time
-ifeq ($(CONFIG_RTC_CLASS),)
-obj-$(CONFIG_PM)		+= timer.o
-endif
-
 ifeq ($(CONFIG_PPC_MERGE),y)
 obj-$(CONFIG_PPC_INDIRECT_PCI)	+= indirect_pci.o
 obj-$(CONFIG_PPC_I8259)		+= i8259.o
diff --git a/include/asm-powerpc/time.h b/include/asm-powerpc/time.h
index fdc271e..f9d9abb 100644
--- a/include/asm-powerpc/time.h
+++ b/include/asm-powerpc/time.h
@@ -240,6 +240,7 @@ extern void snapshot_timebases(void);
 #define snapshot_timebases()			do { } while (0)
 #endif
 
+extern void secondary_cpu_time_init(void);
 extern void iSeries_time_init_early(void);
 
 #endif /* __KERNEL__ */

^ permalink raw reply related

* Re: [RFC] AmigaOne device tree source v2
From: Segher Boessenkool @ 2007-09-06 14:42 UTC (permalink / raw)
  To: Sven Luther; +Cc: David Gibson, linuxppc-dev
In-Reply-To: <20070906140940.GA3947@powerlinux.fr>

>>>> The node should have a compatible
>>>> property which is sufficient to select the right bridge driver.
>>> Yeah, I defined a compatible = "mai,articias"; property in the pci
>>> node.
>>> Are there any naming conventions (maybe lower case only)?
>>
>> It's conventional for the part behind the comma to be lower-case
>> only, yes.  There are more stringent rules for the part before
>> the comma (the manufacturer part).  What is "mai"?
>
> mai logic (some mentor arc derivative i think, ma stands for mentor 
> arc)
> was the firm who produced the articia northbridge.

It should either be "00009D2,articia-s" (using the OUI) or
"mai-logic,articia-s", then.

> The Articia S
> northbridge was known to be defective, and i am unsure if mai survived
> it or something.

It seems they didn't.


Segher

^ permalink raw reply

* [RFC/PATCH 1/2] Basic generic time/clocksource code for PowerPC
From: Paul Mackerras @ 2007-09-06 14:41 UTC (permalink / raw)
  To: linuxppc-dev

This changes PowerPC to use the generic time infrastructure for
gettimeofday et al.  We register a clocksource which uses the timebase
register, or the RTC on the 601.

It also gets rid of the RTC update stuff.  IIRC we discussed removing
this some time ago but never actually did it.

This is based largely on an earlier patch by Tony Breeds.  It could
still use a little more cleanup.

Signed-off-by: Paul Mackerras <paulus@samba.org>
---

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 00099ef..ebecc85 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -21,6 +21,12 @@ config MMU
 	bool
 	default y
 
+config GENERIC_TIME
+	def_bool y
+
+config GENERIC_TIME_VSYSCALL
+	def_bool y
+
 config GENERIC_HARDIRQS
 	bool
 	default y
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index b5944d8..7e960a2 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -73,16 +73,34 @@
 #include <asm/iseries/hv_call_xm.h>
 #endif
 
-/* keep track of when we need to update the rtc */
-time_t last_rtc_update;
+/* powerpc clocksource/clockevent code */
+
+/* TODO:
+ *  o Code style
+ *    * Variable names ... be consistent.
+ *
+ * TODO: Clocksource
+ *  o iSeries registation and matching it with the titan-recalibrate
+ *  o xtime:  Either time.c manages it, or clocksource does, not both
+ */
+
+#include <linux/clocksource.h>
+
+static struct clocksource clocksource_timebase = {
+	.name         = "timebase",
+	.rating       = 400,
+	.flags        = CLOCK_SOURCE_IS_CONTINUOUS,
+	.mask         = CLOCKSOURCE_MASK(64),
+	.shift        = 22,
+	.mult         = 0,	/* To be filled in */
+	.read         = NULL,   /* To be filled in */
+};
+
 #ifdef CONFIG_PPC_ISERIES
 static unsigned long __initdata iSeries_recal_titan;
 static signed long __initdata iSeries_recal_tb;
 #endif
 
-/* The decrementer counts down by 128 every 128ns on a 601. */
-#define DECREMENTER_COUNT_601	(1000000000 / HZ)
-
 #define XSEC_PER_SEC (1024*1024)
 
 #ifdef CONFIG_PPC64
@@ -348,98 +366,6 @@ void udelay(unsigned long usecs)
 }
 EXPORT_SYMBOL(udelay);
 
-static __inline__ void timer_check_rtc(void)
-{
-        /*
-         * update the rtc when needed, this should be performed on the
-         * right fraction of a second. Half or full second ?
-         * Full second works on mk48t59 clocks, others need testing.
-         * Note that this update is basically only used through 
-         * the adjtimex system calls. Setting the HW clock in
-         * any other way is a /dev/rtc and userland business.
-         * This is still wrong by -0.5/+1.5 jiffies because of the
-         * timer interrupt resolution and possible delay, but here we 
-         * hit a quantization limit which can only be solved by higher
-         * resolution timers and decoupling time management from timer
-         * interrupts. This is also wrong on the clocks
-         * which require being written at the half second boundary.
-         * We should have an rtc call that only sets the minutes and
-         * seconds like on Intel to avoid problems with non UTC clocks.
-         */
-        if (ppc_md.set_rtc_time && ntp_synced() &&
-	    xtime.tv_sec - last_rtc_update >= 659 &&
-	    abs((xtime.tv_nsec/1000) - (1000000-1000000/HZ)) < 500000/HZ) {
-		struct rtc_time tm;
-		to_tm(xtime.tv_sec + 1 + timezone_offset, &tm);
-		tm.tm_year -= 1900;
-		tm.tm_mon -= 1;
-		if (ppc_md.set_rtc_time(&tm) == 0)
-			last_rtc_update = xtime.tv_sec + 1;
-		else
-			/* Try again one minute later */
-			last_rtc_update += 60;
-        }
-}
-
-/*
- * This version of gettimeofday has microsecond resolution.
- */
-static inline void __do_gettimeofday(struct timeval *tv)
-{
-	unsigned long sec, usec;
-	u64 tb_ticks, xsec;
-	struct gettimeofday_vars *temp_varp;
-	u64 temp_tb_to_xs, temp_stamp_xsec;
-
-	/*
-	 * These calculations are faster (gets rid of divides)
-	 * if done in units of 1/2^20 rather than microseconds.
-	 * The conversion to microseconds at the end is done
-	 * without a divide (and in fact, without a multiply)
-	 */
-	temp_varp = do_gtod.varp;
-
-	/* Sampling the time base must be done after loading
-	 * do_gtod.varp in order to avoid racing with update_gtod.
-	 */
-	data_barrier(temp_varp);
-	tb_ticks = get_tb() - temp_varp->tb_orig_stamp;
-	temp_tb_to_xs = temp_varp->tb_to_xs;
-	temp_stamp_xsec = temp_varp->stamp_xsec;
-	xsec = temp_stamp_xsec + mulhdu(tb_ticks, temp_tb_to_xs);
-	sec = xsec / XSEC_PER_SEC;
-	usec = (unsigned long)xsec & (XSEC_PER_SEC - 1);
-	usec = SCALE_XSEC(usec, 1000000);
-
-	tv->tv_sec = sec;
-	tv->tv_usec = usec;
-}
-
-void do_gettimeofday(struct timeval *tv)
-{
-	if (__USE_RTC()) {
-		/* do this the old way */
-		unsigned long flags, seq;
-		unsigned int sec, nsec, usec;
-
-		do {
-			seq = read_seqbegin_irqsave(&xtime_lock, flags);
-			sec = xtime.tv_sec;
-			nsec = xtime.tv_nsec + tb_ticks_since(tb_last_jiffy);
-		} while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
-		usec = nsec / 1000;
-		while (usec >= 1000000) {
-			usec -= 1000000;
-			++sec;
-		}
-		tv->tv_sec = sec;
-		tv->tv_usec = usec;
-		return;
-	}
-	__do_gettimeofday(tv);
-}
-
-EXPORT_SYMBOL(do_gettimeofday);
 
 /*
  * There are two copies of tb_to_xs and stamp_xsec so that no
@@ -485,56 +411,6 @@ static inline void update_gtod(u64 new_tb_stamp, u64 new_stamp_xsec,
 	++(vdso_data->tb_update_count);
 }
 
-/*
- * When the timebase - tb_orig_stamp gets too big, we do a manipulation
- * between tb_orig_stamp and stamp_xsec. The goal here is to keep the
- * difference tb - tb_orig_stamp small enough to always fit inside a
- * 32 bits number. This is a requirement of our fast 32 bits userland
- * implementation in the vdso. If we "miss" a call to this function
- * (interrupt latency, CPU locked in a spinlock, ...) and we end up
- * with a too big difference, then the vdso will fallback to calling
- * the syscall
- */
-static __inline__ void timer_recalc_offset(u64 cur_tb)
-{
-	unsigned long offset;
-	u64 new_stamp_xsec;
-	u64 tlen, t2x;
-	u64 tb, xsec_old, xsec_new;
-	struct gettimeofday_vars *varp;
-
-	if (__USE_RTC())
-		return;
-	tlen = current_tick_length();
-	offset = cur_tb - do_gtod.varp->tb_orig_stamp;
-	if (tlen == last_tick_len && offset < 0x80000000u)
-		return;
-	if (tlen != last_tick_len) {
-		t2x = mulhdu(tlen << TICKLEN_SHIFT, ticklen_to_xs);
-		last_tick_len = tlen;
-	} else
-		t2x = do_gtod.varp->tb_to_xs;
-	new_stamp_xsec = (u64) xtime.tv_nsec * XSEC_PER_SEC;
-	do_div(new_stamp_xsec, 1000000000);
-	new_stamp_xsec += (u64) xtime.tv_sec * XSEC_PER_SEC;
-
-	++vdso_data->tb_update_count;
-	smp_mb();
-
-	/*
-	 * Make sure time doesn't go backwards for userspace gettimeofday.
-	 */
-	tb = get_tb();
-	varp = do_gtod.varp;
-	xsec_old = mulhdu(tb - varp->tb_orig_stamp, varp->tb_to_xs)
-		+ varp->stamp_xsec;
-	xsec_new = mulhdu(tb - cur_tb, t2x) + new_stamp_xsec;
-	if (xsec_new < xsec_old)
-		new_stamp_xsec += xsec_old - xsec_new;
-
-	update_gtod(cur_tb, new_stamp_xsec, t2x);
-}
-
 #ifdef CONFIG_SMP
 unsigned long profile_pc(struct pt_regs *regs)
 {
@@ -560,6 +436,7 @@ static int __init iSeries_tb_recal(void)
 {
 	struct div_result divres;
 	unsigned long titan, tb;
+	u64 tb_to_xs;
 
 	/* Make sure we only run on iSeries */
 	if (!firmware_has_feature(FW_FEATURE_ISERIES))
@@ -686,8 +563,6 @@ void timer_interrupt(struct pt_regs * regs)
 		if (per_cpu(last_jiffy, cpu) >= tb_next_jiffy) {
 			tb_last_jiffy = tb_next_jiffy;
 			do_timer(1);
-			timer_recalc_offset(tb_last_jiffy);
-			timer_check_rtc();
 		}
 		write_sequnlock(&xtime_lock);
 	}
@@ -759,71 +634,6 @@ unsigned long long sched_clock(void)
 	return mulhdu(get_tb() - boot_tb, tb_to_ns_scale) << tb_to_ns_shift;
 }
 
-int do_settimeofday(struct timespec *tv)
-{
-	time_t wtm_sec, new_sec = tv->tv_sec;
-	long wtm_nsec, new_nsec = tv->tv_nsec;
-	unsigned long flags;
-	u64 new_xsec;
-	unsigned long tb_delta;
-
-	if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
-		return -EINVAL;
-
-	write_seqlock_irqsave(&xtime_lock, flags);
-
-	/*
-	 * Updating the RTC is not the job of this code. If the time is
-	 * stepped under NTP, the RTC will be updated after STA_UNSYNC
-	 * is cleared.  Tools like clock/hwclock either copy the RTC
-	 * to the system time, in which case there is no point in writing
-	 * to the RTC again, or write to the RTC but then they don't call
-	 * settimeofday to perform this operation.
-	 */
-
-	/* Make userspace gettimeofday spin until we're done. */
-	++vdso_data->tb_update_count;
-	smp_mb();
-
-	/*
-	 * Subtract off the number of nanoseconds since the
-	 * beginning of the last tick.
-	 */
-	tb_delta = tb_ticks_since(tb_last_jiffy);
-	tb_delta = mulhdu(tb_delta, do_gtod.varp->tb_to_xs); /* in xsec */
-	new_nsec -= SCALE_XSEC(tb_delta, 1000000000);
-
-	wtm_sec  = wall_to_monotonic.tv_sec + (xtime.tv_sec - new_sec);
-	wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - new_nsec);
-
- 	set_normalized_timespec(&xtime, new_sec, new_nsec);
-	set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec);
-
-	/* In case of a large backwards jump in time with NTP, we want the 
-	 * clock to be updated as soon as the PLL is again in lock.
-	 */
-	last_rtc_update = new_sec - 658;
-
-	ntp_clear();
-
-	new_xsec = xtime.tv_nsec;
-	if (new_xsec != 0) {
-		new_xsec *= XSEC_PER_SEC;
-		do_div(new_xsec, NSEC_PER_SEC);
-	}
-	new_xsec += (u64)xtime.tv_sec * XSEC_PER_SEC;
-	update_gtod(tb_last_jiffy, new_xsec, do_gtod.varp->tb_to_xs);
-
-	vdso_data->tz_minuteswest = sys_tz.tz_minuteswest;
-	vdso_data->tz_dsttime = sys_tz.tz_dsttime;
-
-	write_sequnlock_irqrestore(&xtime_lock, flags);
-	clock_was_set();
-	return 0;
-}
-
-EXPORT_SYMBOL(do_settimeofday);
-
 static int __init get_freq(char *name, int cells, unsigned long *val)
 {
 	struct device_node *cpu;
@@ -892,6 +702,55 @@ unsigned long get_boot_time(void)
 		      tm.tm_hour, tm.tm_min, tm.tm_sec);
 }
 
+/* clocksource code */
+static cycle_t timebase_read(void)
+{
+	if (__USE_RTC())
+		return (cycle_t)get_rtc();
+	return (cycle_t)get_tb();
+}
+
+void update_vsyscall(struct timespec *wall_time, struct clocksource *clock)
+{
+	u64 t2x, stamp_xsec;
+
+	if (__USE_RTC() || clock != &clocksource_timebase)
+		return;
+
+	/* Make userspace gettimeofday spin until we're done. */
+	++vdso_data->tb_update_count;
+	smp_mb();
+
+	/* XXX this assumes clock->shift == 22 */
+	/* 4611686018 ~= 2^(20+64-22) / 1e9 */
+	t2x = (u64) clock->mult * 4611686018ULL;
+	stamp_xsec = (u64) xtime.tv_nsec * XSEC_PER_SEC;
+	do_div(stamp_xsec, 1000000000);
+	stamp_xsec += (u64) xtime.tv_sec * XSEC_PER_SEC;
+	update_gtod(clock->cycle_last, stamp_xsec, t2x);
+}
+
+void __init clocksource_init(void)
+{
+	int mult;
+
+	mult = clocksource_hz2mult(tb_ticks_per_sec,
+	                           clocksource_timebase.shift);
+	clocksource_timebase.mult = mult;
+
+	clocksource_timebase.read = timebase_read;
+
+	if (clocksource_register(&clocksource_timebase)) {
+		printk(KERN_ERR "clocksource: %s is already registered\n",
+		       clocksource_timebase.name);
+		return;
+	}
+
+	printk(KERN_INFO "clocksource: %s mult[%x] shift[%d] registered\n",
+	       clocksource_timebase.name,
+	       clocksource_timebase.mult, clocksource_timebase.shift);
+}
+
 /* This function is only called on the boot processor */
 void __init time_init(void)
 {
@@ -1008,11 +867,13 @@ void __init time_init(void)
 
 	time_freq = 0;
 
-	last_rtc_update = xtime.tv_sec;
 	set_normalized_timespec(&wall_to_monotonic,
 	                        -xtime.tv_sec, -xtime.tv_nsec);
 	write_sequnlock_irqrestore(&xtime_lock, flags);
 
+	/* Register the clocksource */
+	clocksource_init();
+
 	/* Not exact, but the timer interrupt takes care of this */
 	set_dec(tb_ticks_per_jiffy);
 }

^ permalink raw reply related

* Re: [RFC] AmigaOne device tree source v2
From: Sven Luther @ 2007-09-06 14:09 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: David Gibson, linuxppc-dev
In-Reply-To: <007113bd4008c022872fae697d5dd20f@kernel.crashing.org>

On Thu, Sep 06, 2007 at 04:00:45PM +0200, Segher Boessenkool wrote:
> >> The node should have a compatible
> >> property which is sufficient to select the right bridge driver.
> > Yeah, I defined a compatible = "mai,articias"; property in the pci 
> > node.
> > Are there any naming conventions (maybe lower case only)?
> 
> It's conventional for the part behind the comma to be lower-case
> only, yes.  There are more stringent rules for the part before
> the comma (the manufacturer part).  What is "mai"?

mai logic (some mentor arc derivative i think, ma stands for mentor arc)
was the firm who produced the articia northbridge. The Articia S
northbridge was known to be defective, and i am unsure if mai survived
it or something. 

Friendly,

Sven Luther

^ permalink raw reply

* Re: [PATCH v7 3/3] [POWERPC] MPC832x_RDB: update dts to use SPI1in QE, register mmc_spi stub
From: Timur Tabi @ 2007-09-06 14:35 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: linuxppc-dev
In-Reply-To: <6242650d3fca3afaff242518972bc494@kernel.crashing.org>

Segher Boessenkool wrote:
>>> _and system GPIOs_ :-)
>>
>> Yup, firmware should set up gpios, to make initial kernel boot.
>> After that, kernel can and should manage GPIOs.
> 
> Sure.  But only the GPIOs it _does_ need to toggle, not the ones
> that have to be fixed to a certain value (like everything that is
> described in the par_io nodes now).

Some history:

The par_io nodes are statically defined because the we don't support the 
concept of moving devices from one UCC to another.  When the boards are 
designed, typically the external PHYs (UART, Ethernet, whatever) are 
hard-wired to a particular UCC, and so its par_io configuration is static.

This works only because there are usually more than enough UCCs for every 
device.  The 8360, for instance, has 8 UCCs, but the MPC8360EMDS only uses two 
of them, for Ethernet.

So having the par_io nodes in the device tree is very convenient, because it

A) Is simple and compact
B) Doesn't require full-blown GPIO support
C) The device drivers can ignore par_io programming - they can just assume 
that the pins are configured correctly.
D) It makes it easy for U-Boot and/or Linux to configure the pins.

There are some drawbacks.  For instance on UART, in loopback mode, the par_io 
pins should be reconfigured.  Since loopback mode is a configurable option for 
serial drivers, that means that a UCC UART driver (which I'm working on) needs 
to be aware of the par_io pins.  It would be nice if there were a way I could 
tag a par_io node as being for loopback.

-- 
Timur Tabi
Linux Kernel Developer @ Freescale

^ permalink raw reply

* Configuring for UPM on MPC82xx using new device binding from Scott
From: Esben Haabendal @ 2007-09-06 14:23 UTC (permalink / raw)
  To: linuxppc-dev


Hi

Is it possible to configure chipselect to use UPM A and UPM B in an MPC8270 chip using the new CPM device bindings patches from Scott?

I need to pass in the 3 bits for MS (machine select to the relevant MRx register).

Best regards,
Esben Haabendal

^ permalink raw reply

* Re: [PATCH v7 3/3] [POWERPC] MPC832x_RDB: update dts to use SPI1in QE, register mmc_spi stub
From: Segher Boessenkool @ 2007-09-06 14:29 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev, Timur Tabi
In-Reply-To: <20070906141901.GC16353@ld0162-tx32.am.freescale.net>

>>> AFAIK, there is no other standard data structure that could take 
>>> place
>>> of the par_io nodes in the DTS.
>>
>> The device tree is not a dumping ground for all your "I need some
>> standard data structure" stuff.  Use an XML file if you have to ;-)
>
> Bah.  How about we just remove the nodes you don't want to see before
> passing it on to the kernel? :-)

That is fine.  In fact, LinuxBIOS will probably do similar things.

Since this node will have one user only, feel free to create a
format for it that is as simple as possible for what you need
it for, there's no need to follow any conventions (as long as
you can create a _real_ tree from it later ;-) )


Segher

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox