initialize the url field for packages
[openwrt.git] / target / linux / s3c24xx / patches-2.6.24 / 1104-debug-glamo-dump-regs.patch.patch
1 From dda4110e4b365da5a520e8c2e3964d556206881d Mon Sep 17 00:00:00 2001
2 From: warmcat <andy@warmcat.com>
3 Date: Sun, 13 Apr 2008 07:25:52 +0100
4 Subject: [PATCH] debug-glamo-dump-regs.patch
5 From: Andy Green <andy@openmoko.com>
6
7 Sigend-off-by: Andy Green <andy@openmoko.com>
8 ---
9 drivers/mfd/glamo/glamo-core.c | 91 +++++++++++++++++++++++++++++++++++++++-
10 1 files changed, 90 insertions(+), 1 deletions(-)
11
12 diff --git a/drivers/mfd/glamo/glamo-core.c b/drivers/mfd/glamo/glamo-core.c
13 index 4d8e47f..accd933 100644
14 --- a/drivers/mfd/glamo/glamo-core.c
15 +++ b/drivers/mfd/glamo/glamo-core.c
16 @@ -977,10 +977,92 @@ static int glamo_supported(struct glamo_core *glamo)
17 return 1;
18 }
19
20 +static ssize_t regs_write(struct device *dev, struct device_attribute *attr,
21 + const char *buf, size_t count)
22 +{
23 + unsigned long reg = simple_strtoul(buf, NULL, 10);
24 + struct glamo_core *glamo = dev_get_drvdata(dev);
25 +
26 + while (*buf && (*buf != ' '))
27 + buf++;
28 + if (*buf != ' ')
29 + return -EINVAL;
30 + while (*buf && (*buf == ' '))
31 + buf++;
32 + if (!*buf)
33 + return -EINVAL;
34 +
35 + printk(KERN_INFO"reg 0x%02lX <-- 0x%04lX\n",
36 + reg, simple_strtoul(buf, NULL, 10));
37 +
38 + __reg_write(glamo, reg, simple_strtoul(buf, NULL, 10));
39 +
40 + return count;
41 +}
42 +
43 +static ssize_t regs_read(struct device *dev, struct device_attribute *attr,
44 + char *buf)
45 +{
46 + struct glamo_core *glamo = dev_get_drvdata(dev);
47 + int n, n1 = 0, r;
48 + char * end = buf;
49 + struct reg_range {
50 + int start;
51 + int count;
52 + char * name;
53 + };
54 + struct reg_range reg_range[] = {
55 + { 0x0000, 0x200, "General" },
56 + { 0x0200, 0x100, "Host Bus" },
57 + { 0x0300, 0x100, "Memory" },
58 +/* { 0x0400, 0x100, "Sensor" },
59 + { 0x0500, 0x300, "ISP" },
60 + { 0x0800, 0x400, "JPEG" },
61 + { 0x0c00, 0x500, "MPEG" },
62 + { 0x1100, 0x400, "LCD" },
63 + { 0x1500, 0x080, "MPU 0" },
64 + { 0x1580, 0x080, "MPU 1" },
65 + { 0x1600, 0x080, "Command Queue" },
66 + { 0x1680, 0x080, "RISC CPU" },
67 + { 0x1700, 0x400, "2D Unit" },
68 + { 0x1b00, 0x900, "3D Unit" },
69 +*/
70 + };
71 +
72 + spin_lock(&glamo->lock);
73 +
74 + for (r = 0; r < ARRAY_SIZE(reg_range); r++) {
75 + n1 = 0;
76 + end += sprintf(end, "\n%s\n\n", reg_range[r].name);
77 + for (n = reg_range[r].start;
78 + n < reg_range[r].start + reg_range[r].count; n += 2) {
79 + if (((n1++) & 7) == 0)
80 + end += sprintf(end, "\n%04X: ",
81 + n + reg_range[r].start);
82 + end += sprintf(end, "%04x ", __reg_read(glamo, n));
83 + }
84 + end += sprintf(end, "\n");
85 + }
86 + spin_unlock(&glamo->lock);
87 +
88 + return end - buf;
89 +}
90 +
91 +static DEVICE_ATTR(regs, 0644, regs_read, regs_write);
92 +static struct attribute *glamo_sysfs_entries[] = {
93 + &dev_attr_regs.attr,
94 + NULL
95 +};
96 +static struct attribute_group glamo_attr_group = {
97 + .name = NULL,
98 + .attrs = glamo_sysfs_entries,
99 +};
100 +
101 +
102
103 static int __init glamo_probe(struct platform_device *pdev)
104 {
105 - int rc, irq;
106 + int rc = 0, irq;
107 struct glamo_core *glamo;
108
109 if (glamo_handle) {
110 @@ -1080,6 +1162,12 @@ static int __init glamo_probe(struct platform_device *pdev)
111 goto out_free;
112 }
113
114 + rc = sysfs_create_group(&pdev->dev.kobj, &glamo_attr_group);
115 + if (rc < 0) {
116 + dev_err(&pdev->dev, "cannot create sysfs group\n");
117 + goto out_free;
118 + }
119 +
120 platform_set_drvdata(pdev, glamo);
121
122 dev_dbg(&glamo->pdev->dev, "running init script\n");
123 @@ -1103,6 +1191,7 @@ static int __init glamo_probe(struct platform_device *pdev)
124 glamo->irq_works = 1;
125 } else
126 glamo->irq_works = 0;
127 +
128 return 0;
129
130 out_free:
131 --
132 1.5.6.5
133
This page took 0.047636 seconds and 5 git commands to generate.