Skip to content

Commit

Permalink
x86: register a platform RTC device if PNP doesn't describe it
Browse files Browse the repository at this point in the history
Most if not all x86 platforms have an RTC device, but sometimes the RTC
is not exposed as a PNP0b00/PNP0b01/PNP0b02 device in PNPBIOS or ACPI:

    http://bugzilla.kernel.org/show_bug.cgi?id=11580
    https://bugzilla.redhat.com/show_bug.cgi?id=451188

It's best if we can discover the RTC via PNP because then we know
which flavor of device it is, where it lives, and which IRQ it uses.

But if we can't, we should register a platform device using the
compiled-in RTC_PORT/RTC_IRQ resource assumptions.

Signed-off-by: Bjorn Helgaas <[email protected]>
Acked-by: Rafael J. Wysocki <[email protected]>
Acked-by: David Brownell <[email protected]>
Reported-by: Rik Theys <[email protected]>
Reported-by: [email protected]
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Bjorn Helgaas authored and torvalds committed Oct 14, 2008
1 parent a474aae commit 758a7f7
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions arch/x86/kernel/rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,25 @@ static struct platform_device rtc_device = {
static __init int add_rtc_cmos(void)
{
#ifdef CONFIG_PNP
if (!pnp_platform_devices)
platform_device_register(&rtc_device);
#else
static const char *ids[] __initconst =
{ "PNP0b00", "PNP0b01", "PNP0b02", };
struct pnp_dev *dev;
struct pnp_id *id;
int i;

pnp_for_each_dev(dev) {
for (id = dev->id; id; id = id->next) {
for (i = 0; i < ARRAY_SIZE(ids); i++) {
if (compare_pnp_id(id, ids[i]) != 0)
return 0;
}
}
}
#endif

platform_device_register(&rtc_device);
#endif /* CONFIG_PNP */
dev_info(&rtc_device.dev,
"registered platform RTC device (no PNP device found)\n");
return 0;
}
device_initcall(add_rtc_cmos);

0 comments on commit 758a7f7

Please sign in to comment.