[PATCH 1/4] maple: match "pcie" name for CPC945

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE7215d

12 messages, 6 authors, 2006-12-12 · open the first message on its own page

[PATCH 1/4] maple: match "pcie" name for CPC945

From: Nathan Lynch <hidden>
Date: 2006-12-07 02:28:46

Some firmwares have "pcie" for the "name" property of the CPC945 PCI
Express host bridge.  Check for "pcie" in addition to "pci" so we
don't miss it.

Signed-off-by: Nathan Lynch <redacted>
---
 arch/powerpc/platforms/maple/pci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/arch/powerpc/platforms/maple/pci.c b/arch/powerpc/platforms/maple/pci.c
index 3a32ded..3f6a69f 100644
--- a/arch/powerpc/platforms/maple/pci.c
+++ b/arch/powerpc/platforms/maple/pci.c
@@ -562,7 +562,7 @@ void __init maple_pci_init(void)
 	for (np = NULL; (np = of_get_next_child(root, np)) != NULL;) {
 		if (np->name == NULL)
 			continue;
-		if (strcmp(np->name, "pci") == 0) {
+		if (!strcmp(np->name, "pci") || !strcmp(np->name, "pcie")) {
 			if (add_bridge(np) == 0)
 				of_node_get(np);
 		}
-- 
1.4.4.1

[PATCH 4/4] maple: use RTAS for reboot and halt

From: Nathan Lynch <hidden>
Date: 2006-12-07 01:51:16

On maple, use the RTAS "system-reboot" and "power-off" methods if they
are available.

Signed-off-by: Nathan Lynch <redacted>
---
 arch/powerpc/platforms/maple/setup.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/platforms/maple/setup.c b/arch/powerpc/platforms/maple/setup.c
index 094989d..f12d5c6 100644
--- a/arch/powerpc/platforms/maple/setup.c
+++ b/arch/powerpc/platforms/maple/setup.c
@@ -60,6 +60,7 @@
 #include <asm/of_device.h>
 #include <asm/lmb.h>
 #include <asm/mpic.h>
+#include <asm/rtas.h>
 #include <asm/udbg.h>
 
 #include "maple.h"
@@ -166,6 +167,16 @@ struct smp_ops_t maple_smp_ops = {
 };
 #endif /* CONFIG_SMP */
 
+static void __init maple_use_rtas_reboot_and_halt_if_present(void)
+{
+	if (rtas_service_present("system-reboot") &&
+	    rtas_service_present("power-off")) {
+		ppc_md.restart = rtas_restart;
+		ppc_md.power_off = rtas_power_off;
+		ppc_md.halt = rtas_halt;
+	}
+}
+
 void __init maple_setup_arch(void)
 {
 	/* init to some ~sane value until calibrate_delay() runs */
@@ -181,6 +192,7 @@ void __init maple_setup_arch(void)
 #ifdef CONFIG_DUMMY_CONSOLE
 	conswitchp = &dummy_con;
 #endif
+	maple_use_rtas_reboot_and_halt_if_present();
 
 	printk(KERN_DEBUG "Using native/NAP idle loop\n");
 }
-- 
1.4.4.1

[PATCH 3/4] add rtas_service_present() helper

From: Nathan Lynch <hidden>
Date: 2006-12-07 02:23:13

To test for the existence of an RTAS function, we typically do:

   foo_token = rtas_token("foo");
   if (foo_token == RTAS_UNKNOWN_SERVICE)
      return;

Add a rtas_service_present method, which provides a more conventional
boolean interface for testing the existence of an RTAS method.

Signed-off-by: Nathan Lynch <redacted>
---
 arch/powerpc/kernel/rtas.c |    6 ++++++
 include/asm-powerpc/rtas.h |    1 +
 2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 387ed0d..7970bed 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -303,6 +303,12 @@ int rtas_token(const char *service)
 }
 EXPORT_SYMBOL(rtas_token);
 
+int rtas_service_present(const char *service)
+{
+	return rtas_token(service) != RTAS_UNKNOWN_SERVICE;
+}
+EXPORT_SYMBOL(rtas_service_present);
+
 #ifdef CONFIG_RTAS_ERROR_LOGGING
 /*
  * Return the firmware-specified size of the error log buffer
diff --git a/include/asm-powerpc/rtas.h b/include/asm-powerpc/rtas.h
index 5a0c136..f08f356 100644
--- a/include/asm-powerpc/rtas.h
+++ b/include/asm-powerpc/rtas.h
@@ -159,6 +159,7 @@ extern struct rtas_t rtas;
 
 extern void enter_rtas(unsigned long);
 extern int rtas_token(const char *service);
+extern int rtas_service_present(const char *service);
 extern int rtas_call(int token, int, int, int *, ...);
 extern void rtas_restart(char *cmd);
 extern void rtas_power_off(void);
-- 
1.4.4.1

Re: [PATCH 3/4] add rtas_service_present() helper

From: Michael Ellerman <hidden>
Date: 2006-12-07 02:51:33

On Wed, 2006-12-06 at 18:50 -0600, Nathan Lynch wrote:
To test for the existence of an RTAS function, we typically do:

   foo_token = rtas_token("foo");
   if (foo_token == RTAS_UNKNOWN_SERVICE)
      return;

Add a rtas_service_present method, which provides a more conventional
boolean interface for testing the existence of an RTAS method.

I like it a lot ..

But should it be called rtas_token_present() ? :D

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person

[PATCH 2/4] maple: select PPC_RTAS

From: Nathan Lynch <hidden>
Date: 2006-12-07 02:53:59

Some systems supported by the maple platform have RTAS; make PPC_MAPLE
select PPC_RTAS.

Signed-off-by: Nathan Lynch <redacted>
---
 arch/powerpc/Kconfig |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 291c95a..f524b3b 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -470,6 +470,7 @@ config PPC_MAPLE
 	select PPC_UDBG_16550
 	select PPC_970_NAP
 	select PPC_NATIVE
+	select PPC_RTAS
 	default n
 	help
           This option enables support for the Maple 970FX Evaluation Board.
-- 
1.4.4.1

Re: [PATCH 1/4] maple: match "pcie" name for CPC945

From: Olof Johansson <hidden>
Date: 2006-12-07 03:23:48

On Wed,  6 Dec 2006 18:50:43 -0600 Nathan Lynch [off-list ref] wrote:
Some firmwares have "pcie" for the "name" property of the CPC945 PCI
Express host bridge.  Check for "pcie" in addition to "pci" so we
don't miss it.
1275 (draft) supplement for PCI Express use 'pciex'. 'Some firmware'
should be changed instead, if possible.

See http://playground.sun.com/1275/bindings/pci/pci-express.txt

That's also what pseries and rtas_pci uses.


-Olof

Re: [PATCH 3/4] add rtas_service_present() helper

From: Nathan Lynch <hidden>
Date: 2006-12-07 03:25:40

Michael Ellerman wrote:
On Wed, 2006-12-06 at 18:50 -0600, Nathan Lynch wrote:
quoted
To test for the existence of an RTAS function, we typically do:

   foo_token = rtas_token("foo");
   if (foo_token == RTAS_UNKNOWN_SERVICE)
      return;

Add a rtas_service_present method, which provides a more conventional
boolean interface for testing the existence of an RTAS method.

I like it a lot ..

But should it be called rtas_token_present() ? :D
I considered that, but thought my name was a little more descriptive
-- a token is merely an integer value, but we're really interested in
whether the service named is available.

I don't really care that much either way, though :)

Re: [PATCH 1/4] maple: match "pcie" name for CPC945

From: Segher Boessenkool <hidden>
Date: 2006-12-07 08:30:37

Some firmwares have "pcie" for the "name" property of the CPC945 PCI
Express host bridge.  Check for "pcie" in addition to "pci" so we
don't miss it.
You shouldn't use "name" but "device_type" and "compatible".


Segher

Re: [PATCH 1/4] maple: match "pcie" name for CPC945

From: Segher Boessenkool <hidden>
Date: 2006-12-07 08:41:30

quoted
Some firmwares have "pcie" for the "name" property of the CPC945 PCI
Express host bridge.  Check for "pcie" in addition to "pci" so we
don't miss it.
1275 (draft) supplement for PCI Express use 'pciex'. 'Some firmware'
should be changed instead, if possible.
Nah, the draft should be changed, "pciex" is an absolutely
horrible name :-)  The draft contains a few serious bugs
btw, I hope no one implements this as-is :-)
See http://playground.sun.com/1275/bindings/pci/pci-express.txt

That's also what pseries and rtas_pci uses.
Apple uses plain "pci".  Using the "device_type" and the
"compatible" property works fine everywhere -- *except*
for implementations following this broken draft spec (the
draft doesn't even define a value for "device_type"; also
it prohibits declaring in the "compatible" property that
a device is backward compatible to some plain old PCI
device).


Segher

Re: [PATCH 3/4] add rtas_service_present() helper

From: Linas Vepstas <hidden>
Date: 2006-12-07 21:05:38

On Thu, Dec 07, 2006 at 01:51:33PM +1100, Michael Ellerman wrote:
On Wed, 2006-12-06 at 18:50 -0600, Nathan Lynch wrote:
quoted
To test for the existence of an RTAS function, we typically do:

   foo_token = rtas_token("foo");
   if (foo_token == RTAS_UNKNOWN_SERVICE)
      return;

Add a rtas_service_present method, which provides a more conventional
boolean interface for testing the existence of an RTAS method.

I like it a lot ..
Me too ... How about making it inline?

--linas

Re: [PATCH 1/4] maple: match "pcie" name for CPC945

From: Nathan Lynch <hidden>
Date: 2006-12-11 22:38:22

Segher Boessenkool wrote:
quoted
Some firmwares have "pcie" for the "name" property of the CPC945 PCI
Express host bridge.  Check for "pcie" in addition to "pci" so we
don't miss it.
You shouldn't use "name" but "device_type" and "compatible".
Like this?

(Hmm, does the u3-agp on maple have "pci" for device_type?)
diff --git a/arch/powerpc/platforms/maple/pci.c b/arch/powerpc/platforms/maple/pci.c
index 3a32ded..011f0f1 100644
--- a/arch/powerpc/platforms/maple/pci.c
+++ b/arch/powerpc/platforms/maple/pci.c
@@ -560,13 +560,16 @@ void __init maple_pci_init(void)
 		return;
 	}
 	for (np = NULL; (np = of_get_next_child(root, np)) != NULL;) {
-		if (np->name == NULL)
+		if (!np->type)
 			continue;
-		if (strcmp(np->name, "pci") == 0) {
-			if (add_bridge(np) == 0)
-				of_node_get(np);
-		}
-		if (strcmp(np->name, "ht") == 0) {
+		if (strcmp(np->type, "pci") && strcmp(np->type, "ht"))
+			continue;
+		if ((device_is_compatible(np, "u4-pcie") ||
+		     device_is_compatible(np, "u3-agp")) &&
+		    add_bridge(np) == 0)
+			of_node_get(np);
+
+		if (device_is_compatible(np, "u3-ht")) {
 			of_node_get(np);
 			ht = np;
 		}

Re: [PATCH 1/4] maple: match "pcie" name for CPC945

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2006-12-12 22:26:53

On Mon, 2006-12-11 at 16:38 -0600, Nathan Lynch wrote:
Segher Boessenkool wrote:
quoted
quoted
Some firmwares have "pcie" for the "name" property of the CPC945 PCI
Express host bridge.  Check for "pcie" in addition to "pci" so we
don't miss it.
You shouldn't use "name" but "device_type" and "compatible".
Like this?

(Hmm, does the u3-agp on maple have "pci" for device_type?)
I hope so...

There are plenty bits of code in the kernel that _assume_ that
device_type is PCI for PHB's and P2P bridges, wether they are PCI, PCI-X
or PCIe. prom_parse.c is one, but there is more.

Ben.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help