debug-pcf50633-dump-regs.patch
From: Andy Green <[EMAIL PROTECTED]>
Add a /sys node
cat /sys/devices/platform/s3c2440-i2c/i2c-adapter/i2c-0/0-0073/dump_regs
to allow us to peer into the dark and terrifying mysteries
of pcf50633.
Signed-off-by: Andy Green <[EMAIL PROTECTED]>
---
drivers/i2c/chips/pcf50633.c | 45 +++++++++++++++++++++++++++++++++++++++++-
1 files changed, 44 insertions(+), 1 deletions(-)
diff --git a/drivers/i2c/chips/pcf50633.c b/drivers/i2c/chips/pcf50633.c
index 82e69ce..78343bb 100644
--- a/drivers/i2c/chips/pcf50633.c
+++ b/drivers/i2c/chips/pcf50633.c
@@ -1299,6 +1299,48 @@ static struct backlight_ops pcf50633bl_ops = {
.update_status = pcf50633bl_set_intensity,
};
+/*
+ * Dump regs
+ */
+
+static ssize_t show_dump_regs(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct pcf50633_data *pcf = i2c_get_clientdata(client);
+ u8 dump[16];
+ int n, n1, idx = 0;
+ char *buf1 = buf;
+ static u8 address_no_read[] = { /* must be ascending */
+ PCF50633_REG_INT1,
+ PCF50633_REG_INT2,
+ PCF50633_REG_INT3,
+ PCF50633_REG_INT4,
+ PCF50633_REG_INT5,
+ 0 /* terminator */
+ };
+
+ for (n = 0; n < 256; n += sizeof(dump)) {
+
+ for (n1 = 0; n1 < sizeof(dump); n1++)
+ if (n == address_no_read[idx]) {
+ idx++;
+ dump[n1] = 0x00;
+ } else
+ dump[n1] = reg_read(pcf, n + n1);
+
+ hex_dump_to_buffer(dump, sizeof(dump), 16, 1, buf1, 128, 0);
+ buf1 += strlen(buf1);
+ *buf1++ = '\n';
+ *buf1 = '\0';
+ }
+
+ return buf1 - buf;
+}
+
+static DEVICE_ATTR(dump_regs, 0400, show_dump_regs, NULL);
+
+
/***********************************************************************
* Driver initialization
***********************************************************************/
@@ -1315,7 +1357,7 @@ static struct platform_device gta01_pm_bt_dev = {
};
#endif
-static struct attribute *pcf_sysfs_entries[18] = {
+static struct attribute *pcf_sysfs_entries[] = {
&dev_attr_voltage_auto.attr,
&dev_attr_voltage_down1.attr,
&dev_attr_voltage_down2.attr,
@@ -1327,6 +1369,7 @@ static struct attribute *pcf_sysfs_entries[18] = {
&dev_attr_voltage_ldo5.attr,
&dev_attr_voltage_ldo6.attr,
&dev_attr_voltage_hcldo.attr,
+ &dev_attr_dump_regs.attr,
NULL
};