[ep93xx] package more board specific modules:
[openwrt.git] / target / linux / s3c24xx / files-2.6.30 / drivers / misc / gta02_pm_resume_reason.c
1 /*
2 * Resume reason sysfs for the Openmoko Freerunner GSM Phone
3 *
4 * (C) 2008 by Openmoko Inc.
5 * Author: Andy Green <andy@openmoko.com>
6 * All rights reserved.
7 *
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
11 *
12 */
13
14 #include <linux/module.h>
15 #include <linux/init.h>
16 #include <linux/kernel.h>
17 #include <linux/platform_device.h>
18 #include <linux/io.h>
19
20 #include <mach/regs-gpio.h>
21
22 static unsigned int *gstatus4_mapped;
23 static char *resume_reasons[17] = {
24 "EINT00_ACCEL1",
25 "EINT01_GSM",
26 "EINT02_BLUETOOTH",
27 "EINT03_DEBUGBRD",
28 "EINT04_JACK",
29 "EINT05_WLAN",
30 "EINT06_AUXKEY",
31 "EINT07_HOLDKEY",
32 "EINT08_ACCEL2",
33 "EINT09_PMU",
34 "EINT10_NULL",
35 "EINT11_NULL",
36 "EINT12_GLAMO",
37 "EINT13_NULL",
38 "EINT14_NULL",
39 "EINT15_NULL",
40 NULL
41 };
42
43 static ssize_t resume_reason_read(struct device *dev,
44 struct device_attribute *attr,
45 char *buf)
46 {
47 int bit = 0;
48 char *end = buf;
49
50 for (bit = 0; resume_reasons[bit]; bit++) {
51 if ((*gstatus4_mapped) & (1 << bit))
52 end += sprintf(end, "* %s\n", resume_reasons[bit]);
53 else
54 end += sprintf(end, " %s\n", resume_reasons[bit]);
55
56 }
57
58 return end - buf;
59 }
60
61
62 static DEVICE_ATTR(resume_reason, 0644, resume_reason_read, NULL);
63
64 static struct attribute *gta02_resume_reason_sysfs_entries[] = {
65 &dev_attr_resume_reason.attr,
66 NULL
67 };
68
69 static struct attribute_group gta02_resume_reason_attr_group = {
70 .name = NULL,
71 .attrs = gta02_resume_reason_sysfs_entries,
72 };
73
74 static int __init gta02_resume_reason_probe(struct platform_device *pdev)
75 {
76 dev_info(&pdev->dev, "starting\n");
77
78 gstatus4_mapped = ioremap(S3C24XX_GSTATUS4, 0x4);
79 if (!gstatus4_mapped) {
80 dev_err(&pdev->dev, "failed to ioremap() memory region\n");
81 return -EINVAL;
82 }
83
84 return sysfs_create_group(&pdev->dev.kobj,
85 &gta02_resume_reason_attr_group);
86 }
87
88 static int gta02_resume_reason_remove(struct platform_device *pdev)
89 {
90 sysfs_remove_group(&pdev->dev.kobj, &gta02_resume_reason_attr_group);
91 iounmap(gstatus4_mapped);
92 return 0;
93 }
94
95 static struct platform_driver gta02_resume_reason_driver = {
96 .probe = gta02_resume_reason_probe,
97 .remove = gta02_resume_reason_remove,
98 .driver = {
99 .name = "gta02-resume-reason",
100 },
101 };
102
103 static int __devinit gta02_resume_reason_init(void)
104 {
105 return platform_driver_register(&gta02_resume_reason_driver);
106 }
107
108 static void gta02_resume_reason_exit(void)
109 {
110 platform_driver_unregister(&gta02_resume_reason_driver);
111 }
112
113 module_init(gta02_resume_reason_init);
114 module_exit(gta02_resume_reason_exit);
115
116 MODULE_LICENSE("GPL");
117 MODULE_AUTHOR("Andy Green <andy@openmoko.com>");
118 MODULE_DESCRIPTION("GTA02 resume_reason");
This page took 0.054589 seconds and 5 git commands to generate.