aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Drake <dsd@laptop.org>2010-09-23 12:28:46 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2010-09-23 14:15:00 -0400
commit3e3c486012a3dbb113c0ca15ee265d309d77aea9 (patch)
tree9b1a1e22ab7f7a9e7cd47778cc70e007375fcb11
parent76fb657017588a0912f0d1d140cb807446e4ef05 (diff)
x86, olpc: Rework BIOS signature check
The XO-1.5 laptop is not currently detected as an OLPC machine because it fails this XO-1-centric check. Now that we have OLPC OFW support in the kernel, a more sensible check is to see if we found OFW during boot and check the architecture property. Also remove a now-meaningless codepath, as we're always going to have OFW support with OLPC. Signed-off-by: Daniel Drake <dsd@laptop.org> LKML-Reference: <20100923162846.D8D409D401B@zog.reactivated.net> Cc: Andres Salomon <dilinger@queued.net> Cc: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--arch/x86/Kconfig3
-rw-r--r--arch/x86/include/asm/olpc_ofw.h4
-rw-r--r--arch/x86/kernel/olpc.c58
-rw-r--r--arch/x86/kernel/olpc_ofw.c6
4 files changed, 37 insertions, 34 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 0ed4c9bfcd13..c25525571347 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2061,6 +2061,7 @@ config SCx200HR_TIMER
2061config OLPC 2061config OLPC
2062 bool "One Laptop Per Child support" 2062 bool "One Laptop Per Child support"
2063 select GPIOLIB 2063 select GPIOLIB
2064 select OLPC_OPENFIRMWARE
2064 ---help--- 2065 ---help---
2065 Add support for detecting the unique features of the OLPC 2066 Add support for detecting the unique features of the OLPC
2066 XO hardware. 2067 XO hardware.
@@ -2068,7 +2069,7 @@ config OLPC
2068config OLPC_OPENFIRMWARE 2069config OLPC_OPENFIRMWARE
2069 bool "Support for OLPC's Open Firmware" 2070 bool "Support for OLPC's Open Firmware"
2070 depends on !X86_64 && !X86_PAE 2071 depends on !X86_64 && !X86_PAE
2071 default y if OLPC 2072 default n
2072 help 2073 help
2073 This option adds support for the implementation of Open Firmware 2074 This option adds support for the implementation of Open Firmware
2074 that is used on the OLPC XO-1 Children's Machine. 2075 that is used on the OLPC XO-1 Children's Machine.
diff --git a/arch/x86/include/asm/olpc_ofw.h b/arch/x86/include/asm/olpc_ofw.h
index 08fde475cb3b..2a8478140bb3 100644
--- a/arch/x86/include/asm/olpc_ofw.h
+++ b/arch/x86/include/asm/olpc_ofw.h
@@ -21,10 +21,14 @@ extern void olpc_ofw_detect(void);
21/* install OFW's pde permanently into the kernel's pgtable */ 21/* install OFW's pde permanently into the kernel's pgtable */
22extern void setup_olpc_ofw_pgd(void); 22extern void setup_olpc_ofw_pgd(void);
23 23
24/* check if OFW was detected during boot */
25extern bool olpc_ofw_present(void);
26
24#else /* !CONFIG_OLPC_OPENFIRMWARE */ 27#else /* !CONFIG_OLPC_OPENFIRMWARE */
25 28
26static inline void olpc_ofw_detect(void) { } 29static inline void olpc_ofw_detect(void) { }
27static inline void setup_olpc_ofw_pgd(void) { } 30static inline void setup_olpc_ofw_pgd(void) { }
31static inline bool olpc_ofw_present(void) { return false; }
28 32
29#endif /* !CONFIG_OLPC_OPENFIRMWARE */ 33#endif /* !CONFIG_OLPC_OPENFIRMWARE */
30 34
diff --git a/arch/x86/kernel/olpc.c b/arch/x86/kernel/olpc.c
index 635888cf050d..37c49934c785 100644
--- a/arch/x86/kernel/olpc.c
+++ b/arch/x86/kernel/olpc.c
@@ -183,8 +183,21 @@ err:
183} 183}
184EXPORT_SYMBOL_GPL(olpc_ec_cmd); 184EXPORT_SYMBOL_GPL(olpc_ec_cmd);
185 185
186#ifdef CONFIG_OLPC_OPENFIRMWARE 186static bool __init check_ofw_architecture(void)
187static void __init platform_detect(void) 187{
188 size_t propsize;
189 char olpc_arch[5];
190 const void *args[] = { NULL, "architecture", olpc_arch, (void *)5 };
191 void *res[] = { &propsize };
192
193 if (olpc_ofw("getprop", args, res)) {
194 printk(KERN_ERR "ofw: getprop call failed!\n");
195 return false;
196 }
197 return propsize == 5 && strncmp("OLPC", olpc_arch, 5) == 0;
198}
199
200static u32 __init get_board_revision(void)
188{ 201{
189 size_t propsize; 202 size_t propsize;
190 __be32 rev; 203 __be32 rev;
@@ -193,46 +206,27 @@ static void __init platform_detect(void)
193 206
194 if (olpc_ofw("getprop", args, res) || propsize != 4) { 207 if (olpc_ofw("getprop", args, res) || propsize != 4) {
195 printk(KERN_ERR "ofw: getprop call failed!\n"); 208 printk(KERN_ERR "ofw: getprop call failed!\n");
196 rev = cpu_to_be32(0); 209 return cpu_to_be32(0);
197 } 210 }
198 olpc_platform_info.boardrev = be32_to_cpu(rev); 211 return be32_to_cpu(rev);
199} 212}
200#else 213
201static void __init platform_detect(void) 214static bool __init platform_detect(void)
202{ 215{
203 /* stopgap until OFW support is added to the kernel */ 216 if (!check_ofw_architecture())
204 olpc_platform_info.boardrev = olpc_board(0xc2); 217 return false;
218 olpc_platform_info.flags |= OLPC_F_PRESENT;
219 olpc_platform_info.boardrev = get_board_revision();
220 return true;
205} 221}
206#endif
207 222
208static int __init olpc_init(void) 223static int __init olpc_init(void)
209{ 224{
210 unsigned char *romsig; 225 if (!olpc_ofw_present() || !platform_detect())
211
212 /* The ioremap check is dangerous; limit what we run it on */
213 if (!is_geode() || cs5535_has_vsa2())
214 return 0; 226 return 0;
215 227
216 spin_lock_init(&ec_lock); 228 spin_lock_init(&ec_lock);
217 229
218 romsig = ioremap(0xffffffc0, 16);
219 if (!romsig)
220 return 0;
221
222 if (strncmp(romsig, "CL1 Q", 7))
223 goto unmap;
224 if (strncmp(romsig+6, romsig+13, 3)) {
225 printk(KERN_INFO "OLPC BIOS signature looks invalid. "
226 "Assuming not OLPC\n");
227 goto unmap;
228 }
229
230 printk(KERN_INFO "OLPC board with OpenFirmware %.16s\n", romsig);
231 olpc_platform_info.flags |= OLPC_F_PRESENT;
232
233 /* get the platform revision */
234 platform_detect();
235
236 /* assume B1 and above models always have a DCON */ 230 /* assume B1 and above models always have a DCON */
237 if (olpc_board_at_least(olpc_board(0xb1))) 231 if (olpc_board_at_least(olpc_board(0xb1)))
238 olpc_platform_info.flags |= OLPC_F_DCON; 232 olpc_platform_info.flags |= OLPC_F_DCON;
@@ -254,8 +248,6 @@ static int __init olpc_init(void)
254 olpc_platform_info.boardrev >> 4, 248 olpc_platform_info.boardrev >> 4,
255 olpc_platform_info.ecver); 249 olpc_platform_info.ecver);
256 250
257unmap:
258 iounmap(romsig);
259 return 0; 251 return 0;
260} 252}
261 253
diff --git a/arch/x86/kernel/olpc_ofw.c b/arch/x86/kernel/olpc_ofw.c
index 3218aa71ab5e..787320464379 100644
--- a/arch/x86/kernel/olpc_ofw.c
+++ b/arch/x86/kernel/olpc_ofw.c
@@ -74,6 +74,12 @@ int __olpc_ofw(const char *name, int nr_args, const void **args, int nr_res,
74} 74}
75EXPORT_SYMBOL_GPL(__olpc_ofw); 75EXPORT_SYMBOL_GPL(__olpc_ofw);
76 76
77bool olpc_ofw_present(void)
78{
79 return olpc_ofw_cif != NULL;
80}
81EXPORT_SYMBOL_GPL(olpc_ofw_present);
82
77/* OFW cif _should_ be above this address */ 83/* OFW cif _should_ be above this address */
78#define OFW_MIN 0xff000000 84#define OFW_MIN 0xff000000
79 85