diff options
Diffstat (limited to 'arch/x86/kernel/olpc.c')
| -rw-r--r-- | arch/x86/kernel/olpc.c | 58 |
1 files changed, 25 insertions, 33 deletions
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 | } |
| 184 | EXPORT_SYMBOL_GPL(olpc_ec_cmd); | 184 | EXPORT_SYMBOL_GPL(olpc_ec_cmd); |
| 185 | 185 | ||
| 186 | #ifdef CONFIG_OLPC_OPENFIRMWARE | 186 | static bool __init check_ofw_architecture(void) |
| 187 | static 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 | |||
| 200 | static 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 | |
| 201 | static void __init platform_detect(void) | 214 | static 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 | ||
| 208 | static int __init olpc_init(void) | 223 | static 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 | ||
| 257 | unmap: | ||
| 258 | iounmap(romsig); | ||
| 259 | return 0; | 251 | return 0; |
| 260 | } | 252 | } |
| 261 | 253 | ||
