2 * Resume reason sysfs for the Openmoko Freerunner GSM Phone
4 * (C) 2008 by Openmoko Inc.
5 * Author: Andy Green <andy@openmoko.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License resume_reason 2 as
10 * published by the Free Software Foundation
14 #include <linux/module.h>
15 #include <linux/init.h>
16 #include <linux/kernel.h>
17 #include <linux/platform_device.h>
20 #include <mach/regs-gpio.h>
22 static unsigned int *gstatus4_mapped
;
23 static char *resume_reasons
[17] = {
43 static ssize_t
resume_reason_read(struct device
*dev
,
44 struct device_attribute
*attr
,
50 for (bit
= 0; resume_reasons
[bit
]; bit
++) {
51 if ((*gstatus4_mapped
) & (1 << bit
))
52 end
+= sprintf(end
, "* %s\n", resume_reasons
[bit
]);
54 end
+= sprintf(end
, " %s\n", resume_reasons
[bit
]);
62 static DEVICE_ATTR(resume_reason
, 0644, resume_reason_read
, NULL
);
64 static struct attribute
*gta02_resume_reason_sysfs_entries
[] = {
65 &dev_attr_resume_reason
.attr
,
69 static struct attribute_group gta02_resume_reason_attr_group
= {
71 .attrs
= gta02_resume_reason_sysfs_entries
,
74 static int __init
gta02_resume_reason_probe(struct platform_device
*pdev
)
76 dev_info(&pdev
->dev
, "starting\n");
78 gstatus4_mapped
= ioremap(S3C24XX_GSTATUS4
, 0x4);
79 if (!gstatus4_mapped
) {
80 dev_err(&pdev
->dev
, "failed to ioremap() memory region\n");
84 return sysfs_create_group(&pdev
->dev
.kobj
,
85 >a02_resume_reason_attr_group
);
88 static int gta02_resume_reason_remove(struct platform_device
*pdev
)
90 sysfs_remove_group(&pdev
->dev
.kobj
, >a02_resume_reason_attr_group
);
91 iounmap(gstatus4_mapped
);
95 static struct platform_driver gta02_resume_reason_driver
= {
96 .probe
= gta02_resume_reason_probe
,
97 .remove
= gta02_resume_reason_remove
,
99 .name
= "gta02-resume-reason",
103 static int __devinit
gta02_resume_reason_init(void)
105 return platform_driver_register(>a02_resume_reason_driver
);
108 static void gta02_resume_reason_exit(void)
110 platform_driver_unregister(>a02_resume_reason_driver
);
113 module_init(gta02_resume_reason_init
);
114 module_exit(gta02_resume_reason_exit
);
116 MODULE_LICENSE("GPL");
117 MODULE_AUTHOR("Andy Green <andy@openmoko.com>");
118 MODULE_DESCRIPTION("GTA02 resume_reason");