diff options
| -rw-r--r-- | arch/x86/Kconfig | 3 | ||||
| -rw-r--r-- | arch/x86/include/asm/olpc_ofw.h | 4 | ||||
| -rw-r--r-- | arch/x86/kernel/olpc.c | 58 | ||||
| -rw-r--r-- | arch/x86/kernel/olpc_ofw.c | 6 |
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 | |||
| 2061 | config OLPC | 2061 | config 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 | |||
| 2068 | config OLPC_OPENFIRMWARE | 2069 | config 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 */ |
| 22 | extern void setup_olpc_ofw_pgd(void); | 22 | extern void setup_olpc_ofw_pgd(void); |
| 23 | 23 | ||
| 24 | /* check if OFW was detected during boot */ | ||
| 25 | extern bool olpc_ofw_present(void); | ||
| 26 | |||
| 24 | #else /* !CONFIG_OLPC_OPENFIRMWARE */ | 27 | #else /* !CONFIG_OLPC_OPENFIRMWARE */ |
| 25 | 28 | ||
| 26 | static inline void olpc_ofw_detect(void) { } | 29 | static inline void olpc_ofw_detect(void) { } |
| 27 | static inline void setup_olpc_ofw_pgd(void) { } | 30 | static inline void setup_olpc_ofw_pgd(void) { } |
| 31 | static 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 | } |
| 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 | ||
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 | } |
| 75 | EXPORT_SYMBOL_GPL(__olpc_ofw); | 75 | EXPORT_SYMBOL_GPL(__olpc_ofw); |
| 76 | 76 | ||
| 77 | bool olpc_ofw_present(void) | ||
| 78 | { | ||
| 79 | return olpc_ofw_cif != NULL; | ||
| 80 | } | ||
| 81 | EXPORT_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 | ||
