public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andres Salomon <dilinger@queued.net>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Joseph Fannin <jfannin@gmail.com>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
	jordan.crouse@amd.com, Mitch Bradley <wmb@firmworks.com>
Subject: [PATCH 2/2] OLPC: drop pre-OpenFirmware workarounds
Date: Sat, 19 Apr 2008 13:39:15 -0400	[thread overview]
Message-ID: <20080419133915.07bc0f69@ephemeral> (raw)
In-Reply-To: <20080419092544.378664a8@ephemeral>


Prior to including OFW kernel support, we had to work around the lack of
OFW.  Once OFW support is added, we can switch to using it.  This cleans
up some pre-OFW model detection and OFW signature detection.

Note: this should be a bit nicer to non-OLPC hardware.

Signed-off-by: Andres Salomon <dilinger@debian.org>
---
 arch/x86/kernel/olpc.c |   43 +++++++++++++++++++++++++++++--------------
 1 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kernel/olpc.c b/arch/x86/kernel/olpc.c
index 11670be..3a05683 100644
--- a/arch/x86/kernel/olpc.c
+++ b/arch/x86/kernel/olpc.c
@@ -190,11 +190,11 @@ EXPORT_SYMBOL_GPL(olpc_ec_cmd);
 static void __init platform_detect(void)
 {
 	size_t propsize;
-	u32 rev;
+	uint32_t rev;
 
 	if (ofw("getprop", 4, 1, NULL, "board-revision-int", &rev, 4,
 			&propsize) || propsize != 4) {
-		printk(KERN_ERR "ofw: getprop call failed!\n");
+		printk(KERN_ERR "olpc:  ofw getprop call failed!\n");
 		rev = 0;
 	}
 	olpc_platform_info.boardrev = be32_to_cpu(rev);
@@ -207,26 +207,43 @@ static void __init platform_detect(void)
 }
 #endif
 
-static int __init olpc_init(void)
+static int __init ofw_detect(void)
 {
-	unsigned char *romsig;
+	size_t propsize;
+	char romsig[20];
+	ofw_phandle phandle;
 
-	spin_lock_init(&ec_lock);
+	/* Fetch /openprom/model */
+	if (ofw("finddevice", 1, 1, "/openprom", &phandle) || phandle == ~0)
+		return -ENODEV;
 
-	romsig = ioremap(0xffffffc0, 16);
-	if (!romsig)
-		return 0;
+	if (ofw("getprop", 4, 1, phandle, "model", &romsig, sizeof(romsig),
+			&propsize) || propsize < 7)
+		return -ENODEV;
 
+	/* String should look something like "CL1   Q2D08  Q2D" */
 	if (strncmp(romsig, "CL1   Q", 7))
-		goto unmap;
+		return -ENODEV;
 	if (strncmp(romsig+6, romsig+13, 3)) {
-		printk(KERN_INFO "OLPC BIOS signature looks invalid.  "
+		printk(KERN_INFO "olpc:  BIOS signature looks invalid.  "
 				"Assuming not OLPC\n");
-		goto unmap;
+		return -ENODEV;
 	}
 
-	printk(KERN_INFO "OLPC board with OpenFirmware %.16s\n", romsig);
+	/* Looks like we have OLPC's OFW */
 	olpc_platform_info.flags |= OLPC_F_PRESENT;
+	printk(KERN_INFO "olpc:  board with OpenFirmware %.16s\n", romsig);
+
+	return 0;
+}
+
+static int __init olpc_init(void)
+{
+	spin_lock_init(&ec_lock);
+
+	/* ensure OFW is available */
+	if (ofw_detect())
+		return 0;
 
 	/* get the platform revision */
 	platform_detect();
@@ -248,8 +265,6 @@ static int __init olpc_init(void)
 			olpc_platform_info.boardrev >> 4,
 			olpc_platform_info.ecver);
 
-unmap:
-	iounmap(romsig);
 	return 0;
 }
 
-- 
1.5.4.4



-- 
Need a kernel or Debian developer?  Contact me, I'm looking for contracts.

  parent reply	other threads:[~2008-04-19 17:37 UTC|newest]

Thread overview: 109+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-18  8:47 2.6.25-mm1 Andrew Morton
2008-04-18 11:26 ` [PATCH] 2.6.25-mm1 - Build Failure with PWRficient onchip memory controller driver Kamalesh Babulal
2008-04-18 13:02 ` StackProtector Oopses - Re: 2.6.25-mm1 Reuben Farrelly
2008-04-18 13:36   ` Ingo Molnar
2008-04-18 13:51     ` Arjan van de Ven
2008-04-18 14:41       ` Reuben Farrelly
2008-04-18 14:49     ` Reuben Farrelly
2008-04-21 15:06       ` Ingo Molnar
2008-04-22  1:48         ` Arjan van de Ven
2008-04-22  2:04           ` Valdis.Kletnieks
2008-04-22  8:34           ` Ingo Molnar
2008-04-22 14:29             ` Arjan van de Ven
2008-04-18 16:40 ` 2.6.25-mm1 (build error: driver core) Randy Dunlap
2008-04-18 16:56   ` Greg KH
2008-04-18 18:38     ` Dan Williams
2008-04-18 16:45 ` 2.6.25-mm1 (build error: trace selftest) Randy Dunlap
2008-04-18 20:14 ` 2.6.25-mm1 Valdis.Kletnieks
2008-04-18 23:09 ` 2.6.25-mm1: orphaned files after build Alexey Dobriyan
2008-04-19  2:13 ` 2.6.25-mm1 Joseph Fannin
2008-04-19  3:02   ` 2.6.25-mm1 Andrew Morton
2008-04-19  4:14     ` 2.6.25-mm1 Dmitry Torokhov
2008-04-19  4:29       ` 2.6.25-mm1 Andrew Morton
2008-04-19  6:33         ` 2.6.25-mm1 Joseph Fannin
2008-04-21 11:07         ` 2.6.25-mm1 Takashi Iwai
2008-04-21 17:44           ` 2.6.25-mm1 (snd-pcsp causes driver conflict) Stas Sergeev
2008-04-22 10:09             ` Takashi Iwai
2008-04-22 17:54               ` Stas Sergeev
2008-04-23  8:55                 ` Takashi Iwai
2008-04-23 14:14                   ` Takashi Iwai
2008-04-21 19:45           ` 2.6.25-mm1 Stas Sergeev
2008-04-21 14:06         ` 2.6.25-mm1 Takashi Iwai
2008-04-21 17:55           ` 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC) Stas Sergeev
2008-04-22 10:13             ` Takashi Iwai
2008-04-22 14:01               ` Dmitry Torokhov
2008-04-22 16:42                 ` Stas Sergeev
2008-04-22 18:31               ` Stas Sergeev
2008-04-23  8:49                 ` Takashi Iwai
2008-04-23 14:18                   ` Takashi Iwai
2008-04-23 20:02                   ` Stas Sergeev
2008-04-24  9:40                     ` Takashi Iwai
2008-04-25  3:51                       ` Stas Sergeev
2008-04-25  6:28                         ` Takashi Iwai
2008-04-25 16:45                           ` Stas Sergeev
2008-04-25 16:51                             ` Takashi Iwai
2008-04-25 17:25                               ` Stas Sergeev
2008-05-02 16:44                               ` Takashi Iwai
2008-05-02 16:57                                 ` Stas Sergeev
2008-05-06 10:20                                   ` Takashi Iwai
2008-05-06 16:51                                     ` Stas Sergeev
2008-04-25 18:09                             ` Dmitry Torokhov
2008-04-25 18:31                               ` Stas Sergeev
2008-04-25 18:37                                 ` Dmitry Torokhov
2008-04-19  2:25 ` 2.6.25-mm1 Joseph Fannin
2008-04-19  3:08   ` 2.6.25-mm1 Andrew Morton
2008-04-19  3:10 ` 2.6.25-mm1 Joseph Fannin
2008-04-19  3:29   ` 2.6.25-mm1 Andrew Morton
2008-04-19 13:25     ` 2.6.25-mm1 Andres Salomon
2008-04-19 17:38       ` 2.6.25-mm1 Andrew Morton
2008-04-19 17:50         ` 2.6.25-mm1 Andres Salomon
2008-04-21 14:56           ` 2.6.25-mm1 Jordan Crouse
2008-04-21 15:05             ` 2.6.25-mm1 Andres Salomon
2008-04-21 15:12               ` 2.6.25-mm1 Jordan Crouse
2008-04-19 17:39       ` [PATCH 1/2] OLPC: Add support for calling into Open Firmware Andres Salomon
2008-04-20 10:34         ` Yinghai Lu
2008-04-20 12:07           ` H. Peter Anvin
2008-04-20 17:59             ` Andres Salomon
2008-04-20 18:42               ` Mitch Bradley
2008-04-20 19:12                 ` H. Peter Anvin
2008-04-21  3:39                   ` Mitch Bradley
2008-04-21  4:54                     ` Yinghai Lu
2008-04-21  8:22                       ` Mitch Bradley
2008-04-21 11:36                     ` H. Peter Anvin
2008-04-21 13:09                       ` H. Peter Anvin
2008-04-21 13:13                       ` H. Peter Anvin
2008-04-21 13:19                       ` H. Peter Anvin
2008-04-21 15:05                     ` Jordan Crouse
2008-04-21 14:58                       ` H. Peter Anvin
2008-04-20 19:13               ` [PATCH 1/2] " H. Peter Anvin
2008-04-21  3:09           ` Mitch Bradley
2008-04-21  3:15             ` Yinghai Lu
2008-04-21  4:05               ` Mitch Bradley
2008-04-21  4:26                 ` David Miller
2008-04-21  4:50                 ` Yinghai Lu
2008-04-21  8:03                   ` Mitch Bradley
2008-04-21 14:24                 ` Andres Salomon
2008-04-21 15:54                   ` David Woodhouse
2008-04-21 16:57                     ` H. Peter Anvin
2008-04-21 18:54                       ` David Woodhouse
2008-04-21 17:03                     ` Andres Salomon
2008-04-21 19:18                       ` David Woodhouse
2008-04-21 19:46                         ` Andres Salomon
2008-04-21 20:25                           ` David Woodhouse
2008-04-21 21:02                             ` [PATCH] OLPC: only check for OFW signature on VSA-less Geodes Andres Salomon
2008-04-21 21:17                               ` Jordan Crouse
2008-04-21 21:17                               ` [PATCH] " David Woodhouse
2008-04-29  3:06                               ` Andrew Morton
2008-04-29  5:32                                 ` [PATCH] x86: GEODE: cache results from geode_has_vsa2() and uninline Andres Salomon
2008-04-29 20:35                                   ` Andrew Morton
2008-04-29 20:57                                     ` Andres Salomon
2008-04-19 17:39       ` Andres Salomon [this message]
2008-04-19 18:21     ` 2.6.25-mm1 Arjan van de Ven
2008-04-20 11:29 ` internal compiler error: SIGSEGV [Was: 2.6.25-mm1] Jiri Slaby
2008-04-21  8:31 ` Jiri Slaby
2008-04-21  9:06   ` Al Viro
2008-04-21  9:37     ` fault in __d_lookup " Jiri Slaby
2008-04-21  9:45       ` Al Viro
2008-04-21  9:59         ` Jiri Slaby
2008-04-21 13:42           ` Rafael J. Wysocki
2008-04-21 17:23           ` Matthew Wilcox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080419133915.07bc0f69@ephemeral \
    --to=dilinger@queued.net \
    --cc=akpm@linux-foundation.org \
    --cc=jfannin@gmail.com \
    --cc=jordan.crouse@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=wmb@firmworks.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox