diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-06 19:24:34 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-06 19:24:34 -0400 |
commit | 3cf8ad3394b8675e92a35c438f22341197535531 (patch) | |
tree | 39c9c5b9465e4f63f6cdf9b767d8046eaf0f3ac7 | |
parent | 66cd55d2b903643cbd019ef97a5305d9428d3865 (diff) | |
parent | 54e5bc020ce1c959eaa7be18cedb734b6b13745e (diff) |
Merge branch 'x86-olpc-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'x86-olpc-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
x86, olpc: Constify an olpc_ofw() arg
x86, olpc: Use pr_debug() for EC commands
x86, olpc: Add comment about implicit optimization barrier
x86, olpc: Add support for calling into OpenFirmware
-rw-r--r-- | Documentation/x86/zero-page.txt | 1 | ||||
-rw-r--r-- | arch/x86/Kconfig | 9 | ||||
-rw-r--r-- | arch/x86/include/asm/bootparam.h | 11 | ||||
-rw-r--r-- | arch/x86/include/asm/olpc_ofw.h | 31 | ||||
-rw-r--r-- | arch/x86/kernel/Makefile | 1 | ||||
-rw-r--r-- | arch/x86/kernel/head_32.S | 6 | ||||
-rw-r--r-- | arch/x86/kernel/olpc.c | 20 | ||||
-rw-r--r-- | arch/x86/kernel/olpc_ofw.c | 106 | ||||
-rw-r--r-- | arch/x86/kernel/setup.c | 6 |
9 files changed, 178 insertions, 13 deletions
diff --git a/Documentation/x86/zero-page.txt b/Documentation/x86/zero-page.txt index feb37e177010..cf5437deda81 100644 --- a/Documentation/x86/zero-page.txt +++ b/Documentation/x86/zero-page.txt | |||
@@ -18,6 +18,7 @@ Offset Proto Name Meaning | |||
18 | 080/010 ALL hd0_info hd0 disk parameter, OBSOLETE!! | 18 | 080/010 ALL hd0_info hd0 disk parameter, OBSOLETE!! |
19 | 090/010 ALL hd1_info hd1 disk parameter, OBSOLETE!! | 19 | 090/010 ALL hd1_info hd1 disk parameter, OBSOLETE!! |
20 | 0A0/010 ALL sys_desc_table System description table (struct sys_desc_table) | 20 | 0A0/010 ALL sys_desc_table System description table (struct sys_desc_table) |
21 | 0B0/010 ALL olpc_ofw_header OLPC's OpenFirmware CIF and friends | ||
21 | 140/080 ALL edid_info Video mode setup (struct edid_info) | 22 | 140/080 ALL edid_info Video mode setup (struct edid_info) |
22 | 1C0/020 ALL efi_info EFI 32 information (struct efi_info) | 23 | 1C0/020 ALL efi_info EFI 32 information (struct efi_info) |
23 | 1E0/004 ALL alk_mem_k Alternative mem check, in KB | 24 | 1E0/004 ALL alk_mem_k Alternative mem check, in KB |
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index baa34e510222..a84fc34c8f77 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -2060,6 +2060,15 @@ config OLPC | |||
2060 | Add support for detecting the unique features of the OLPC | 2060 | Add support for detecting the unique features of the OLPC |
2061 | XO hardware. | 2061 | XO hardware. |
2062 | 2062 | ||
2063 | config OLPC_OPENFIRMWARE | ||
2064 | bool "Support for OLPC's Open Firmware" | ||
2065 | depends on !X86_64 && !X86_PAE | ||
2066 | default y if OLPC | ||
2067 | help | ||
2068 | This option adds support for the implementation of Open Firmware | ||
2069 | that is used on the OLPC XO-1 Children's Machine. | ||
2070 | If unsure, say N here. | ||
2071 | |||
2063 | endif # X86_32 | 2072 | endif # X86_32 |
2064 | 2073 | ||
2065 | config K8_NB | 2074 | config K8_NB |
diff --git a/arch/x86/include/asm/bootparam.h b/arch/x86/include/asm/bootparam.h index 6be33d83c716..8e6218550e77 100644 --- a/arch/x86/include/asm/bootparam.h +++ b/arch/x86/include/asm/bootparam.h | |||
@@ -70,6 +70,14 @@ struct sys_desc_table { | |||
70 | __u8 table[14]; | 70 | __u8 table[14]; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | /* Gleaned from OFW's set-parameters in cpu/x86/pc/linux.fth */ | ||
74 | struct olpc_ofw_header { | ||
75 | __u32 ofw_magic; /* OFW signature */ | ||
76 | __u32 ofw_version; | ||
77 | __u32 cif_handler; /* callback into OFW */ | ||
78 | __u32 irq_desc_table; | ||
79 | } __attribute__((packed)); | ||
80 | |||
73 | struct efi_info { | 81 | struct efi_info { |
74 | __u32 efi_loader_signature; | 82 | __u32 efi_loader_signature; |
75 | __u32 efi_systab; | 83 | __u32 efi_systab; |
@@ -92,7 +100,8 @@ struct boot_params { | |||
92 | __u8 hd0_info[16]; /* obsolete! */ /* 0x080 */ | 100 | __u8 hd0_info[16]; /* obsolete! */ /* 0x080 */ |
93 | __u8 hd1_info[16]; /* obsolete! */ /* 0x090 */ | 101 | __u8 hd1_info[16]; /* obsolete! */ /* 0x090 */ |
94 | struct sys_desc_table sys_desc_table; /* 0x0a0 */ | 102 | struct sys_desc_table sys_desc_table; /* 0x0a0 */ |
95 | __u8 _pad4[144]; /* 0x0b0 */ | 103 | struct olpc_ofw_header olpc_ofw_header; /* 0x0b0 */ |
104 | __u8 _pad4[128]; /* 0x0c0 */ | ||
96 | struct edid_info edid_info; /* 0x140 */ | 105 | struct edid_info edid_info; /* 0x140 */ |
97 | struct efi_info efi_info; /* 0x1c0 */ | 106 | struct efi_info efi_info; /* 0x1c0 */ |
98 | __u32 alt_mem_k; /* 0x1e0 */ | 107 | __u32 alt_mem_k; /* 0x1e0 */ |
diff --git a/arch/x86/include/asm/olpc_ofw.h b/arch/x86/include/asm/olpc_ofw.h new file mode 100644 index 000000000000..08fde475cb3b --- /dev/null +++ b/arch/x86/include/asm/olpc_ofw.h | |||
@@ -0,0 +1,31 @@ | |||
1 | #ifndef _ASM_X86_OLPC_OFW_H | ||
2 | #define _ASM_X86_OLPC_OFW_H | ||
3 | |||
4 | /* index into the page table containing the entry OFW occupies */ | ||
5 | #define OLPC_OFW_PDE_NR 1022 | ||
6 | |||
7 | #define OLPC_OFW_SIG 0x2057464F /* aka "OFW " */ | ||
8 | |||
9 | #ifdef CONFIG_OLPC_OPENFIRMWARE | ||
10 | |||
11 | /* run an OFW command by calling into the firmware */ | ||
12 | #define olpc_ofw(name, args, res) \ | ||
13 | __olpc_ofw((name), ARRAY_SIZE(args), args, ARRAY_SIZE(res), res) | ||
14 | |||
15 | extern int __olpc_ofw(const char *name, int nr_args, const void **args, int nr_res, | ||
16 | void **res); | ||
17 | |||
18 | /* determine whether OFW is available and lives in the proper memory */ | ||
19 | extern void olpc_ofw_detect(void); | ||
20 | |||
21 | /* install OFW's pde permanently into the kernel's pgtable */ | ||
22 | extern void setup_olpc_ofw_pgd(void); | ||
23 | |||
24 | #else /* !CONFIG_OLPC_OPENFIRMWARE */ | ||
25 | |||
26 | static inline void olpc_ofw_detect(void) { } | ||
27 | static inline void setup_olpc_ofw_pgd(void) { } | ||
28 | |||
29 | #endif /* !CONFIG_OLPC_OPENFIRMWARE */ | ||
30 | |||
31 | #endif /* _ASM_X86_OLPC_OFW_H */ | ||
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index e77b22083721..0925676266bd 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile | |||
@@ -104,6 +104,7 @@ obj-$(CONFIG_SCx200) += scx200.o | |||
104 | scx200-y += scx200_32.o | 104 | scx200-y += scx200_32.o |
105 | 105 | ||
106 | obj-$(CONFIG_OLPC) += olpc.o | 106 | obj-$(CONFIG_OLPC) += olpc.o |
107 | obj-$(CONFIG_OLPC_OPENFIRMWARE) += olpc_ofw.o | ||
107 | obj-$(CONFIG_X86_MRST) += mrst.o | 108 | obj-$(CONFIG_X86_MRST) += mrst.o |
108 | 109 | ||
109 | microcode-y := microcode_core.o | 110 | microcode-y := microcode_core.o |
diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S index 37c3d4b17d85..ff4c453e13f3 100644 --- a/arch/x86/kernel/head_32.S +++ b/arch/x86/kernel/head_32.S | |||
@@ -131,6 +131,12 @@ ENTRY(startup_32) | |||
131 | movsl | 131 | movsl |
132 | 1: | 132 | 1: |
133 | 133 | ||
134 | #ifdef CONFIG_OLPC_OPENFIRMWARE | ||
135 | /* save OFW's pgdir table for later use when calling into OFW */ | ||
136 | movl %cr3, %eax | ||
137 | movl %eax, pa(olpc_ofw_pgd) | ||
138 | #endif | ||
139 | |||
134 | #ifdef CONFIG_PARAVIRT | 140 | #ifdef CONFIG_PARAVIRT |
135 | /* This is can only trip for a broken bootloader... */ | 141 | /* This is can only trip for a broken bootloader... */ |
136 | cmpw $0x207, pa(boot_params + BP_version) | 142 | cmpw $0x207, pa(boot_params + BP_version) |
diff --git a/arch/x86/kernel/olpc.c b/arch/x86/kernel/olpc.c index 8297160c41b3..0e0cdde519be 100644 --- a/arch/x86/kernel/olpc.c +++ b/arch/x86/kernel/olpc.c | |||
@@ -21,10 +21,7 @@ | |||
21 | #include <asm/geode.h> | 21 | #include <asm/geode.h> |
22 | #include <asm/setup.h> | 22 | #include <asm/setup.h> |
23 | #include <asm/olpc.h> | 23 | #include <asm/olpc.h> |
24 | 24 | #include <asm/olpc_ofw.h> | |
25 | #ifdef CONFIG_OPEN_FIRMWARE | ||
26 | #include <asm/ofw.h> | ||
27 | #endif | ||
28 | 25 | ||
29 | struct olpc_platform_t olpc_platform_info; | 26 | struct olpc_platform_t olpc_platform_info; |
30 | EXPORT_SYMBOL_GPL(olpc_platform_info); | 27 | EXPORT_SYMBOL_GPL(olpc_platform_info); |
@@ -145,7 +142,7 @@ restart: | |||
145 | * The OBF flag will sometimes misbehave due to what we believe | 142 | * The OBF flag will sometimes misbehave due to what we believe |
146 | * is a hardware quirk.. | 143 | * is a hardware quirk.. |
147 | */ | 144 | */ |
148 | printk(KERN_DEBUG "olpc-ec: running cmd 0x%x\n", cmd); | 145 | pr_devel("olpc-ec: running cmd 0x%x\n", cmd); |
149 | outb(cmd, 0x6c); | 146 | outb(cmd, 0x6c); |
150 | 147 | ||
151 | if (wait_on_ibf(0x6c, 0)) { | 148 | if (wait_on_ibf(0x6c, 0)) { |
@@ -162,8 +159,7 @@ restart: | |||
162 | " EC accept data!\n"); | 159 | " EC accept data!\n"); |
163 | goto err; | 160 | goto err; |
164 | } | 161 | } |
165 | printk(KERN_DEBUG "olpc-ec: sending cmd arg 0x%x\n", | 162 | pr_devel("olpc-ec: sending cmd arg 0x%x\n", inbuf[i]); |
166 | inbuf[i]); | ||
167 | outb(inbuf[i], 0x68); | 163 | outb(inbuf[i], 0x68); |
168 | } | 164 | } |
169 | } | 165 | } |
@@ -176,8 +172,7 @@ restart: | |||
176 | goto restart; | 172 | goto restart; |
177 | } | 173 | } |
178 | outbuf[i] = inb(0x68); | 174 | outbuf[i] = inb(0x68); |
179 | printk(KERN_DEBUG "olpc-ec: received 0x%x\n", | 175 | pr_devel("olpc-ec: received 0x%x\n", outbuf[i]); |
180 | outbuf[i]); | ||
181 | } | 176 | } |
182 | } | 177 | } |
183 | 178 | ||
@@ -188,14 +183,15 @@ err: | |||
188 | } | 183 | } |
189 | EXPORT_SYMBOL_GPL(olpc_ec_cmd); | 184 | EXPORT_SYMBOL_GPL(olpc_ec_cmd); |
190 | 185 | ||
191 | #ifdef CONFIG_OPEN_FIRMWARE | 186 | #ifdef CONFIG_OLPC_OPENFIRMWARE |
192 | static void __init platform_detect(void) | 187 | static void __init platform_detect(void) |
193 | { | 188 | { |
194 | size_t propsize; | 189 | size_t propsize; |
195 | __be32 rev; | 190 | __be32 rev; |
191 | const void *args[] = { NULL, "board-revision-int", &rev, (void *)4 }; | ||
192 | void *res[] = { &propsize }; | ||
196 | 193 | ||
197 | if (ofw("getprop", 4, 1, NULL, "board-revision-int", &rev, 4, | 194 | if (olpc_ofw("getprop", args, res) || propsize != 4) { |
198 | &propsize) || propsize != 4) { | ||
199 | printk(KERN_ERR "ofw: getprop call failed!\n"); | 195 | printk(KERN_ERR "ofw: getprop call failed!\n"); |
200 | rev = cpu_to_be32(0); | 196 | rev = cpu_to_be32(0); |
201 | } | 197 | } |
diff --git a/arch/x86/kernel/olpc_ofw.c b/arch/x86/kernel/olpc_ofw.c new file mode 100644 index 000000000000..3218aa71ab5e --- /dev/null +++ b/arch/x86/kernel/olpc_ofw.c | |||
@@ -0,0 +1,106 @@ | |||
1 | #include <linux/kernel.h> | ||
2 | #include <linux/module.h> | ||
3 | #include <linux/init.h> | ||
4 | #include <asm/page.h> | ||
5 | #include <asm/setup.h> | ||
6 | #include <asm/io.h> | ||
7 | #include <asm/pgtable.h> | ||
8 | #include <asm/olpc_ofw.h> | ||
9 | |||
10 | /* address of OFW callback interface; will be NULL if OFW isn't found */ | ||
11 | static int (*olpc_ofw_cif)(int *); | ||
12 | |||
13 | /* page dir entry containing OFW's pgdir table; filled in by head_32.S */ | ||
14 | u32 olpc_ofw_pgd __initdata; | ||
15 | |||
16 | static DEFINE_SPINLOCK(ofw_lock); | ||
17 | |||
18 | #define MAXARGS 10 | ||
19 | |||
20 | void __init setup_olpc_ofw_pgd(void) | ||
21 | { | ||
22 | pgd_t *base, *ofw_pde; | ||
23 | |||
24 | if (!olpc_ofw_cif) | ||
25 | return; | ||
26 | |||
27 | /* fetch OFW's PDE */ | ||
28 | base = early_ioremap(olpc_ofw_pgd, sizeof(olpc_ofw_pgd) * PTRS_PER_PGD); | ||
29 | if (!base) { | ||
30 | printk(KERN_ERR "failed to remap OFW's pgd - disabling OFW!\n"); | ||
31 | olpc_ofw_cif = NULL; | ||
32 | return; | ||
33 | } | ||
34 | ofw_pde = &base[OLPC_OFW_PDE_NR]; | ||
35 | |||
36 | /* install OFW's PDE permanently into the kernel's pgtable */ | ||
37 | set_pgd(&swapper_pg_dir[OLPC_OFW_PDE_NR], *ofw_pde); | ||
38 | /* implicit optimization barrier here due to uninline function return */ | ||
39 | |||
40 | early_iounmap(base, sizeof(olpc_ofw_pgd) * PTRS_PER_PGD); | ||
41 | } | ||
42 | |||
43 | int __olpc_ofw(const char *name, int nr_args, const void **args, int nr_res, | ||
44 | void **res) | ||
45 | { | ||
46 | int ofw_args[MAXARGS + 3]; | ||
47 | unsigned long flags; | ||
48 | int ret, i, *p; | ||
49 | |||
50 | BUG_ON(nr_args + nr_res > MAXARGS); | ||
51 | |||
52 | if (!olpc_ofw_cif) | ||
53 | return -EIO; | ||
54 | |||
55 | ofw_args[0] = (int)name; | ||
56 | ofw_args[1] = nr_args; | ||
57 | ofw_args[2] = nr_res; | ||
58 | |||
59 | p = &ofw_args[3]; | ||
60 | for (i = 0; i < nr_args; i++, p++) | ||
61 | *p = (int)args[i]; | ||
62 | |||
63 | /* call into ofw */ | ||
64 | spin_lock_irqsave(&ofw_lock, flags); | ||
65 | ret = olpc_ofw_cif(ofw_args); | ||
66 | spin_unlock_irqrestore(&ofw_lock, flags); | ||
67 | |||
68 | if (!ret) { | ||
69 | for (i = 0; i < nr_res; i++, p++) | ||
70 | *((int *)res[i]) = *p; | ||
71 | } | ||
72 | |||
73 | return ret; | ||
74 | } | ||
75 | EXPORT_SYMBOL_GPL(__olpc_ofw); | ||
76 | |||
77 | /* OFW cif _should_ be above this address */ | ||
78 | #define OFW_MIN 0xff000000 | ||
79 | |||
80 | /* OFW starts on a 1MB boundary */ | ||
81 | #define OFW_BOUND (1<<20) | ||
82 | |||
83 | void __init olpc_ofw_detect(void) | ||
84 | { | ||
85 | struct olpc_ofw_header *hdr = &boot_params.olpc_ofw_header; | ||
86 | unsigned long start; | ||
87 | |||
88 | /* ensure OFW booted us by checking for "OFW " string */ | ||
89 | if (hdr->ofw_magic != OLPC_OFW_SIG) | ||
90 | return; | ||
91 | |||
92 | olpc_ofw_cif = (int (*)(int *))hdr->cif_handler; | ||
93 | |||
94 | if ((unsigned long)olpc_ofw_cif < OFW_MIN) { | ||
95 | printk(KERN_ERR "OFW detected, but cif has invalid address 0x%lx - disabling.\n", | ||
96 | (unsigned long)olpc_ofw_cif); | ||
97 | olpc_ofw_cif = NULL; | ||
98 | return; | ||
99 | } | ||
100 | |||
101 | /* determine where OFW starts in memory */ | ||
102 | start = round_down((unsigned long)olpc_ofw_cif, OFW_BOUND); | ||
103 | printk(KERN_INFO "OFW detected in memory, cif @ 0x%lx (reserving top %ldMB)\n", | ||
104 | (unsigned long)olpc_ofw_cif, (-start) >> 20); | ||
105 | reserve_top_address(-start); | ||
106 | } | ||
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index b4ae4acbd031..b008e7883207 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c | |||
@@ -102,6 +102,7 @@ | |||
102 | 102 | ||
103 | #include <asm/paravirt.h> | 103 | #include <asm/paravirt.h> |
104 | #include <asm/hypervisor.h> | 104 | #include <asm/hypervisor.h> |
105 | #include <asm/olpc_ofw.h> | ||
105 | 106 | ||
106 | #include <asm/percpu.h> | 107 | #include <asm/percpu.h> |
107 | #include <asm/topology.h> | 108 | #include <asm/topology.h> |
@@ -736,10 +737,15 @@ void __init setup_arch(char **cmdline_p) | |||
736 | /* VMI may relocate the fixmap; do this before touching ioremap area */ | 737 | /* VMI may relocate the fixmap; do this before touching ioremap area */ |
737 | vmi_init(); | 738 | vmi_init(); |
738 | 739 | ||
740 | /* OFW also may relocate the fixmap */ | ||
741 | olpc_ofw_detect(); | ||
742 | |||
739 | early_trap_init(); | 743 | early_trap_init(); |
740 | early_cpu_init(); | 744 | early_cpu_init(); |
741 | early_ioremap_init(); | 745 | early_ioremap_init(); |
742 | 746 | ||
747 | setup_olpc_ofw_pgd(); | ||
748 | |||
743 | ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev); | 749 | ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev); |
744 | screen_info = boot_params.screen_info; | 750 | screen_info = boot_params.screen_info; |
745 | edid_info = boot_params.edid_info; | 751 | edid_info = boot_params.edid_info; |