summaryrefslogtreecommitdiff
path: root/target/linux/s3c24xx/patches/0095-add-pcb-rev-sysfs.patch.patch
blob: 8c14b2bd7aa4fa87435e8608c0b2f0821eac33ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
From 440ff3efce2982d9808045a696d9b7c17f539a10 Mon Sep 17 00:00:00 2001
From: Andy Green <andy@openmoko.com>
Date: Fri, 25 Jul 2008 23:06:02 +0100
Subject: [PATCH] add-pcb-rev-sysfs.patch
 Signed-off-by: Andy Green <andy@openmoko.com>

---
 arch/arm/mach-s3c2440/mach-gta02.c      |    6 ++
 arch/arm/plat-s3c24xx/Makefile          |    6 ++-
 arch/arm/plat-s3c24xx/neo1973_version.c |   90 +++++++++++++++++++++++++++++++
 3 files changed, 101 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/plat-s3c24xx/neo1973_version.c

diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c
index a2a63fe..3574375 100644
--- a/arch/arm/mach-s3c2440/mach-gta02.c
+++ b/arch/arm/mach-s3c2440/mach-gta02.c
@@ -372,6 +372,11 @@ int gta02_get_pcb_revision(void)
 	return u;
 }
 
+struct platform_device gta02_version_device = {
+	.name 		= "neo1973-version",
+	.num_resources	= 0,
+};
+
 
 static struct map_desc gta02_iodesc[] __initdata = {
 	{
@@ -724,6 +729,7 @@ static struct platform_device *gta02_devices[] __initdata = {
 	&s3c_device_ts,
 	&gta02_nor_flash,
 	&sc32440_fiq_device,
+	&gta02_version_device,
 };
 
 static struct s3c2410_nand_set gta02_nand_sets[] = {
diff --git a/arch/arm/plat-s3c24xx/Makefile b/arch/arm/plat-s3c24xx/Makefile
index d58265f..6b32a8a 100644
--- a/arch/arm/plat-s3c24xx/Makefile
+++ b/arch/arm/plat-s3c24xx/Makefile
@@ -29,4 +29,8 @@ obj-$(CONFIG_PM)		+= pm.o
 obj-$(CONFIG_PM)		+= sleep.o
 obj-$(CONFIG_S3C2410_DMA)	+= dma.o
 obj-$(CONFIG_MACH_SMDK)		+= common-smdk.o
-obj-$(CONFIG_MACH_NEO1973)	+= neo1973_pm_host.o neo1973_pm_gsm.o neo1973_pm_gps.o neo1973_pm_bt.o
+obj-$(CONFIG_MACH_NEO1973)	+= neo1973_version.o \
+				   neo1973_pm_host.o \
+				   neo1973_pm_gsm.o \
+				   neo1973_pm_gps.o \
+				   neo1973_pm_bt.o
diff --git a/arch/arm/plat-s3c24xx/neo1973_version.c b/arch/arm/plat-s3c24xx/neo1973_version.c
new file mode 100644
index 0000000..ad41a0f
--- /dev/null
+++ b/arch/arm/plat-s3c24xx/neo1973_version.c
@@ -0,0 +1,90 @@
+/*
+ * PCB version sysfs for the FIC Neo1973 GSM Phone
+ *
+ * (C) 2007 by OpenMoko Inc.
+ * Author: Andy Green <andy@openmoko.com>
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+
+#include <asm/hardware.h>
+#include <asm/mach-types.h>
+
+#ifdef CONFIG_MACH_NEO1973_GTA02
+#include <asm/arch/gta02.h>
+
+static ssize_t version_read(struct device *dev, struct device_attribute *attr,
+			    char *buf)
+{
+	return sprintf(buf, "0x%03X\n", gta02_get_pcb_revision());
+}
+
+
+static DEVICE_ATTR(pcb, 0644, version_read, NULL);
+
+static struct attribute *neo1973_version_sysfs_entries[] = {
+	&dev_attr_pcb.attr,
+	NULL
+};
+
+static struct attribute_group neo1973_version_attr_group = {
+	.name	= NULL,
+	.attrs	= neo1973_version_sysfs_entries,
+};
+
+static int __init neo1973_version_probe(struct platform_device *pdev)
+{
+	dev_info(&pdev->dev, "starting\n");
+
+	switch (machine_arch_type) {
+#ifdef CONFIG_MACH_NEO1973_GTA01
+	case MACH_TYPE_NEO1973_GTA01:
+		return -EINVAL;
+#endif /* CONFIG_MACH_NEO1973_GTA01 */
+	default:
+		break;
+	}
+
+	return sysfs_create_group(&pdev->dev.kobj, &neo1973_version_attr_group);
+}
+
+static int neo1973_version_remove(struct platform_device *pdev)
+{
+	sysfs_remove_group(&pdev->dev.kobj, &neo1973_version_attr_group);
+	return 0;
+}
+
+static struct platform_driver neo1973_version_driver = {
+	.probe		= neo1973_version_probe,
+	.remove		= neo1973_version_remove,
+	.driver		= {
+		.name		= "neo1973-version",
+	},
+};
+
+static int __devinit neo1973_version_init(void)
+{
+	return platform_driver_register(&neo1973_version_driver);
+}
+
+static void neo1973_version_exit(void)
+{
+	platform_driver_unregister(&neo1973_version_driver);
+}
+
+module_init(neo1973_version_init);
+module_exit(neo1973_version_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Andy Green <andy@openmoko.com>");
+MODULE_DESCRIPTION("Neo1973 PCB version");
+#endif
-- 
1.5.6.3