[patch 2.6.19-rc6 4/6] ACPI exports RTC extensions through platform_data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Define platform_data for the MC146818 based RTCs, currently just holding
extensions standardized by ACPI (but available on some ACPI-neutral clones).

Update ACPI to export that RTC extension information through platform_data
to the PNP or platform bus device node.

Signed-off-by: David Brownell <[email protected]>

Index: g26/include/linux/mc146818rtc.h
===================================================================
--- g26.orig/include/linux/mc146818rtc.h	2006-11-20 10:03:06.000000000 -0800
+++ g26/include/linux/mc146818rtc.h	2006-11-20 10:10:45.000000000 -0800
@@ -18,6 +18,18 @@
 #ifdef __KERNEL__
 #include <linux/spinlock.h>		/* spinlock_t */
 extern spinlock_t rtc_lock;		/* serialize CMOS RAM access */
+
+/* Some RTCs extend the mc146818 register set to support alarms of more
+ * than 24 hours in the future; or dates that include a century code.
+ * And sometimes the RTC alarm can wake the system from suspend-to-disk.
+ * This platform_data structure can pass this information to the driver.
+ */
+struct cmos_rtc_board_info {
+	u8	rtc_day_alarm;		/* zero, or register index */
+	u8	rtc_mon_alarm;		/* zero, or register index */
+	u8	rtc_century;		/* zero, or register index */
+	u8	wake_from_std;		/* true iff alarm wakes from STD */
+};
 #endif
 
 /**********************************************************************
Index: g26/drivers/acpi/glue.c
===================================================================
--- g26.orig/drivers/acpi/glue.c	2006-11-20 10:03:06.000000000 -0800
+++ g26/drivers/acpi/glue.c	2006-11-20 10:10:45.000000000 -0800
@@ -358,3 +358,107 @@ static int __init init_acpi_device_notif
 }
 
 arch_initcall(init_acpi_device_notify);
+
+
+#if defined(CONFIG_RTC_DRV_CMOS) || defined(CONFIG_RTC_DRV_CMOS_MODULE)
+
+/* Every ACPI platform has a mc146818 compatible "cmos rtc".  We want
+ * to find its device node, so we can pass ACPI-specific config data
+ * to its driver.  So we'll just probe for that device -- with a dummy
+ * driver, using the relevant bus -- before the RTC driver initializes.
+ */
+#include <linux/mc146818rtc.h>
+
+static struct cmos_rtc_board_info rtc_info;
+
+static struct device *rtc_dev __initdata;
+static char drvname[] __initdata = "rtc_cmos";
+
+
+#ifdef CONFIG_PNPACPI
+
+/* PNP devices are registered in a subsys_initcall();
+ * ACPI specifies the PNP IDs to use.
+ */
+#include <linux/pnp.h>
+
+static struct pnp_device_id rtc_ids[] __initdata = {
+	{ .id = "PNP0b00", },
+	{ .id = "PNP0b01", },
+	{ .id = "PNP0b02", },
+	{ },
+};
+
+static int __init
+rtc_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
+{
+	rtc_dev = &pnp->dev;
+	return -ENXIO;
+}
+
+static struct pnp_driver cmos_pnp_driver __initdata = {
+	.name		= drvname,
+	.id_table	= rtc_ids,
+	.probe		= rtc_pnp_probe,
+};
+
+static struct device *__init get_rtc_dev(void)
+{
+	if (pnp_register_driver(&cmos_pnp_driver) == 0)
+		pnp_unregister_driver(&cmos_pnp_driver);
+	return rtc_dev;
+}
+
+#else
+
+/* We expect platforms to register an RTC device, conventionally at or
+ * near arch_initcall().  That should work even without ACPI.  The driver
+ * name matters; it must match the driver.
+ */
+#include <linux/platform_device.h>
+
+static int __init rtc_platform_probe(struct platform_device *pdev)
+{
+	rtc_dev = &pdev->dev;
+	return -ENXIO;
+}
+
+static struct platform_driver rtc_platform_driver __initdata = {
+	.driver = {
+		.name		= drvname,
+	},
+	.probe		= rtc_platform_probe,
+};
+
+static struct device *__init get_rtc_dev(void)
+{
+	if (platform_driver_register(&rtc_platform_driver) == 0)
+		platform_driver_unregister(&rtc_platform_driver);
+	return rtc_dev;
+}
+
+#endif
+
+static int __init acpi_rtc_init(void)
+{
+	struct device *dev = get_rtc_dev();
+
+	if (dev) {
+		rtc_info.rtc_day_alarm = acpi_gbl_FADT->day_alrm;
+		rtc_info.rtc_mon_alarm = acpi_gbl_FADT->mon_alrm;
+		rtc_info.rtc_century = acpi_gbl_FADT->century;
+
+		/* REVISIT iff revision > FADT2_REVISION_ID ? */
+		rtc_info.wake_from_std = acpi_gbl_FADT->rtcs4;
+
+		dev->platform_data = &rtc_info;
+
+		/* RTC always wakes from S1/S2/S3, and often S4/STD */
+		device_init_wakeup(dev, 1);
+	} else
+		pr_debug("ACPI: RTC unavailable?\n");
+	return 0;
+}
+fs_initcall(acpi_rtc_init);
+
+#endif

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux