Skip to contentSkip to conversation

maple: match "pcie" name for CPC945

PATCH In review Nathan Lynch 6 participants 12 messages Dec 7, 2006 – Dec 12, 2006 PowerPC

lore
Share & tools
lore
#0 lore raw

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

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.

---
 arch/powerpc/platforms/maple/pci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/powerpc/platforms/maple/pci.c +1 -1
index 3a32ded..3f6a69f 100644
@@ -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);
 		}
Signature · 1 line
1.4.4.1
#1 lore raw

PATCH 2/4 maple: select PPC_RTAS

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

---
 arch/powerpc/Kconfig |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/powerpc/Kconfig +1 -0
index 291c95a..f524b3b 100644
@@ -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.
Signature · 1 line
1.4.4.1
#2 lore raw

PATCH 3/4 add rtas_service_present() helper

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.

---
 arch/powerpc/kernel/rtas.c |    6 ++++++
 include/asm-powerpc/rtas.h |    1 +
 2 files changed, 7 insertions(+), 0 deletions(-)
arch/powerpc/kernel/rtas.c +6 -0
index 387ed0d..7970bed 100644
@@ -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
include/asm-powerpc/rtas.h +1 -0
index 5a0c136..f08f356 100644
@@ -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);
Signature · 1 line
1.4.4.1
#3 lore raw

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

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

---
 arch/powerpc/platforms/maple/setup.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
arch/powerpc/platforms/maple/setup.c +12 -0
index 094989d..f12d5c6 100644
@@ -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");
 }
Signature · 1 line
1.4.4.1
#4 lore raw

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

In reply to Nathan Lynch
Quoted 8 lines · Nathan Lynch

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

Signature · 8 lines
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
#5 lore raw

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

Quoted 7 lines · Michael Ellerman
Quoted 6 lines · Nathan Lynch

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

   foo_token = rtas_token("foo");
   if (foo_token == RTAS_UNKNOWN_SERVICE)
      return;
Quoted 7 lines
Quoted 2 lines

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 :)

#6 lore raw

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

In reply to Michael Ellerman
Quoted 7 lines · Michael Ellerman
Quoted 6 lines · Nathan Lynch

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

   foo_token = rtas_token("foo");
   if (foo_token == RTAS_UNKNOWN_SERVICE)
      return;
Quoted 5 lines
Quoted 2 lines

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

#7 lore raw
In reply to Nathan Lynch
Quoted 3 lines · On Wed, 6 Dec 2006 18:50:43 -0600 Nathan Lynch <[email protected]> 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

#8 lore raw
Quoted 6 lines
Quoted 3 lines

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 :-)

Quoted 3 lines

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

#9 lore raw
In reply to Nathan Lynch
Quoted 3 lines

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

#10 lore raw
Quoted 5 lines · Segher Boessenkool
Quoted 3 lines

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?)

arch/powerpc/platforms/maple/pci.c +9 -6
index 3a32ded..011f0f1 100644
@@ -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;
 		}
#11 lore raw
Quoted 10 lines · Nathan Lynch
Quoted 5 lines · Segher Boessenkool
Quoted 3 lines

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.