Skip to content

Commit a7a9bac

Browse files
lkundraksre
authored andcommitted
x86/platform/olpc: Use a correct version when making up a battery node
The XO-1 and XO-1.5 batteries apparently differ in an ability to report ambient temperature. We need to use a different compatible string for the XO-1.5 battery. Previously olpc_dt_fixup() used the presence of the battery node's compatible property to decide whether the DT is up to date. Now we need to look for a particular value in the compatible string, to decide Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Acked-by: Pavel Machek <pavel@ucw.cz> Acked-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
1 parent 47e120d commit a7a9bac

File tree

1 file changed

+50
-14
lines changed

1 file changed

+50
-14
lines changed

arch/x86/platform/olpc/olpc_dt.c

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -220,41 +220,77 @@ static u32 __init olpc_dt_get_board_revision(void)
220220
return be32_to_cpu(rev);
221221
}
222222

223+
int olpc_dt_compatible_match(phandle node, const char *compat)
224+
{
225+
char buf[64], *p;
226+
int plen, len;
227+
228+
plen = olpc_dt_getproperty(node, "compatible", buf, sizeof(buf));
229+
if (plen <= 0)
230+
return 0;
231+
232+
len = strlen(compat);
233+
for (p = buf; p < buf + plen; p += strlen(p) + 1) {
234+
if (strcmp(p, compat) == 0)
235+
return 1;
236+
}
237+
238+
return 0;
239+
}
240+
223241
void __init olpc_dt_fixup(void)
224242
{
225-
int r;
226-
char buf[64];
227243
phandle node;
228244
u32 board_rev;
229245

230246
node = olpc_dt_finddevice("/battery@0");
231247
if (!node)
232248
return;
233249

234-
/*
235-
* If the battery node has a compatible property, we are running a new
236-
* enough firmware and don't have fixups to make.
237-
*/
238-
r = olpc_dt_getproperty(node, "compatible", buf, sizeof(buf));
239-
if (r > 0)
240-
return;
241-
242-
pr_info("PROM DT: Old firmware detected, applying fixes\n");
243-
244250
board_rev = olpc_dt_get_board_revision();
245251
if (!board_rev)
246252
return;
247253

248254
if (board_rev >= olpc_board_pre(0xd0)) {
249-
/* XO-1.5: add dcon device */
255+
/* XO-1.5 */
256+
257+
if (olpc_dt_compatible_match(node, "olpc,xo1.5-battery"))
258+
return;
259+
260+
/* Add olpc,xo1.5-battery compatible marker to battery node */
261+
olpc_dt_interpret("\" /battery@0\" find-device");
262+
olpc_dt_interpret(" \" olpc,xo1.5-battery\" +compatible");
263+
olpc_dt_interpret("device-end");
264+
265+
if (olpc_dt_compatible_match(node, "olpc,xo1-battery")) {
266+
/*
267+
* If we have a olpc,xo1-battery compatible, then we're
268+
* running a new enough firmware that already has
269+
* the dcon node.
270+
*/
271+
return;
272+
}
273+
274+
/* Add dcon device */
250275
olpc_dt_interpret("\" /pci/display@1\" find-device");
251276
olpc_dt_interpret(" new-device");
252277
olpc_dt_interpret(" \" dcon\" device-name");
253278
olpc_dt_interpret(" \" olpc,xo1-dcon\" +compatible");
254279
olpc_dt_interpret(" finish-device");
255280
olpc_dt_interpret("device-end");
256281
} else {
257-
/* XO-1: add dcon device, mark RTC as olpc,xo1-rtc */
282+
/* XO-1 */
283+
284+
if (olpc_dt_compatible_match(node, "olpc,xo1-battery")) {
285+
/*
286+
* If we have a olpc,xo1-battery compatible, then we're
287+
* running a new enough firmware that already has
288+
* the dcon and RTC nodes.
289+
*/
290+
return;
291+
}
292+
293+
/* Add dcon device, mark RTC as olpc,xo1-rtc */
258294
olpc_dt_interpret("\" /pci/display@1,1\" find-device");
259295
olpc_dt_interpret(" new-device");
260296
olpc_dt_interpret(" \" dcon\" device-name");

0 commit comments

Comments
 (0)