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>
7 Sigend-off-by: Andy Green <andy@openmoko.com>
9 drivers/mfd/glamo/glamo-core.c | 91 +++++++++++++++++++++++++++++++++++++++-
10 1 files changed, 90 insertions(+), 1 deletions(-)
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)
20 +static ssize_t regs_write(struct device *dev, struct device_attribute *attr,
21 + const char *buf, size_t count)
23 + unsigned long reg = simple_strtoul(buf, NULL, 10);
24 + struct glamo_core *glamo = dev_get_drvdata(dev);
26 + while (*buf && (*buf != ' '))
30 + while (*buf && (*buf == ' '))
35 + printk(KERN_INFO"reg 0x%02lX <-- 0x%04lX\n",
36 + reg, simple_strtoul(buf, NULL, 10));
38 + __reg_write(glamo, reg, simple_strtoul(buf, NULL, 10));
43 +static ssize_t regs_read(struct device *dev, struct device_attribute *attr,
46 + struct glamo_core *glamo = dev_get_drvdata(dev);
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" },
72 + spin_lock(&glamo->lock);
74 + for (r = 0; r < ARRAY_SIZE(reg_range); r++) {
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));
84 + end += sprintf(end, "\n");
86 + spin_unlock(&glamo->lock);
91 +static DEVICE_ATTR(regs, 0644, regs_read, regs_write);
92 +static struct attribute *glamo_sysfs_entries[] = {
93 + &dev_attr_regs.attr,
96 +static struct attribute_group glamo_attr_group = {
98 + .attrs = glamo_sysfs_entries,
103 static int __init glamo_probe(struct platform_device *pdev)
107 struct glamo_core *glamo;
110 @@ -1080,6 +1162,12 @@ static int __init glamo_probe(struct platform_device *pdev)
114 + rc = sysfs_create_group(&pdev->dev.kobj, &glamo_attr_group);
116 + dev_err(&pdev->dev, "cannot create sysfs group\n");
120 platform_set_drvdata(pdev, glamo);
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;
126 glamo->irq_works = 0;