summaryrefslogtreecommitdiff
path: root/target/linux/s3c24xx/patches-2.6.26/1094-debug-glamo-dump-regs.patch.patch
blob: f7ab57ac702fc65260ddcf7c14ff5bbe3624541a (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
From 1dd60fdf9fe229443304a5f53c265d9f2b35a7ec Mon Sep 17 00:00:00 2001
From: warmcat <andy@warmcat.com>
Date: Fri, 25 Jul 2008 23:06:02 +0100
Subject: [PATCH] debug-glamo-dump-regs.patch
 From: Andy Green <andy@openmoko.com>

Sigend-off-by: Andy Green <andy@openmoko.com>
---
 drivers/mfd/glamo/glamo-core.c |   91 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 90 insertions(+), 1 deletions(-)

diff --git a/drivers/mfd/glamo/glamo-core.c b/drivers/mfd/glamo/glamo-core.c
index 4d8e47f..accd933 100644
--- a/drivers/mfd/glamo/glamo-core.c
+++ b/drivers/mfd/glamo/glamo-core.c
@@ -977,10 +977,92 @@ static int glamo_supported(struct glamo_core *glamo)
 	return 1;
 }
 
+static ssize_t regs_write(struct device *dev, struct device_attribute *attr,
+			   const char *buf, size_t count)
+{
+	unsigned long reg = simple_strtoul(buf, NULL, 10);
+	struct glamo_core *glamo = dev_get_drvdata(dev);
+
+	while (*buf && (*buf != ' '))
+		buf++;
+	if (*buf != ' ')
+		return -EINVAL;
+	while (*buf && (*buf == ' '))
+		buf++;
+	if (!*buf)
+		return -EINVAL;
+
+	printk(KERN_INFO"reg 0x%02lX <-- 0x%04lX\n",
+	       reg, simple_strtoul(buf, NULL, 10));
+
+	__reg_write(glamo, reg, simple_strtoul(buf, NULL, 10));
+
+	return count;
+}
+
+static ssize_t regs_read(struct device *dev, struct device_attribute *attr,
+			char *buf)
+{
+	struct glamo_core *glamo = dev_get_drvdata(dev);
+	int n, n1 = 0, r;
+	char * end = buf;
+	struct reg_range {
+		int start;
+		int count;
+		char * name;
+	};
+	struct reg_range reg_range[] = {
+		{ 0x0000, 0x200, "General" },
+		{ 0x0200, 0x100, "Host Bus" },
+		{ 0x0300, 0x100, "Memory" },
+/*		{ 0x0400, 0x100, "Sensor" },
+		{ 0x0500, 0x300, "ISP" },
+		{ 0x0800, 0x400, "JPEG" },
+		{ 0x0c00, 0x500, "MPEG" },
+		{ 0x1100, 0x400, "LCD" },
+		{ 0x1500, 0x080, "MPU 0" },
+		{ 0x1580, 0x080, "MPU 1" },
+		{ 0x1600, 0x080, "Command Queue" },
+		{ 0x1680, 0x080, "RISC CPU" },
+		{ 0x1700, 0x400, "2D Unit" },
+		{ 0x1b00, 0x900, "3D Unit" },
+*/
+	};
+
+	spin_lock(&glamo->lock);
+
+	for (r = 0; r < ARRAY_SIZE(reg_range); r++) {
+		n1 = 0;
+		end += sprintf(end, "\n%s\n\n", reg_range[r].name);
+		for (n = reg_range[r].start;
+		     n < reg_range[r].start + reg_range[r].count; n += 2) {
+			if (((n1++) & 7) == 0)
+				end += sprintf(end, "\n%04X:  ",
+					       n + reg_range[r].start);
+			end += sprintf(end, "%04x ", __reg_read(glamo, n));
+		}
+		end += sprintf(end, "\n");
+	}
+	spin_unlock(&glamo->lock);
+
+	return end - buf;
+}
+
+static DEVICE_ATTR(regs, 0644, regs_read, regs_write);
+static struct attribute *glamo_sysfs_entries[] = {
+	&dev_attr_regs.attr,
+	NULL
+};
+static struct attribute_group glamo_attr_group = {
+	.name	= NULL,
+	.attrs	= glamo_sysfs_entries,
+};
+
+
 
 static int __init glamo_probe(struct platform_device *pdev)
 {
-	int rc, irq;
+	int rc = 0, irq;
 	struct glamo_core *glamo;
 
 	if (glamo_handle) {
@@ -1080,6 +1162,12 @@ static int __init glamo_probe(struct platform_device *pdev)
 		goto out_free;
 	}
 
+	rc = sysfs_create_group(&pdev->dev.kobj, &glamo_attr_group);
+	if (rc < 0) {
+		dev_err(&pdev->dev, "cannot create sysfs group\n");
+		goto out_free;
+	}
+
 	platform_set_drvdata(pdev, glamo);
 
 	dev_dbg(&glamo->pdev->dev, "running init script\n");
@@ -1103,6 +1191,7 @@ static int __init glamo_probe(struct platform_device *pdev)
 		glamo->irq_works = 1;
 	} else
 		glamo->irq_works = 0;
+
 	return 0;
 
 out_free:
-- 
1.5.6.3