Hi Andy,

This patch is a a band-aid solution to fix the following issue:

https://docs.openmoko.org/trac/ticket/1884

Actually, I think your comment on this is interesting.
I will try your idea to see whether we could detect the interrupt form
PMU or not in the last moment.
But before that, we might need this solution. I think you can keep this
patch in andy-tracking branch.

Matt
From: Matt Hsu <[EMAIL PROTECTED]>
Date: Thu, 9 Oct 2008 00:34:03 +0800

To export sysfs of debounce time of ONKEY in pcf50633 driver. 

Signed-off-by: Matt Hsu <[EMAIL PROTECTED]>
---
 drivers/i2c/chips/pcf50633.c |   44 ++++++++++++++++++++++++++++++++++++++++++
 drivers/i2c/chips/pcf50633.h |   10 +++++++++
 2 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/chips/pcf50633.c b/drivers/i2c/chips/pcf50633.c
index c186fdb..631bb1c 100644
--- a/drivers/i2c/chips/pcf50633.c
+++ b/drivers/i2c/chips/pcf50633.c
@@ -2033,6 +2033,49 @@ static ssize_t show_dump_regs(struct device *dev, struct device_attribute *attr,
 
 static DEVICE_ATTR(dump_regs, 0400, show_dump_regs, NULL);
 
+/*
+ * Onkey debounce time
+ */
+static const char *deb_time_names[] = {
+	[PCF50633_ONKEY_DEB_NONE] = "0",
+	[PCF50633_ONKEY_DEB_5MS] = "5",
+	[PCF50633_ONKEY_DEB_14MS] = "14",
+	[PCF50633_ONKEY_DEB_62MS] = "62",
+	[PCF50633_ONKEY_DEB_200MS] = "200",
+	[PCF50633_ONKEY_DEB_500MS] = "500",
+	[PCF50633_ONKEY_DEB_1000MS] = "1000",
+	[PCF50633_ONKEY_DEB_2000MS] = "2000",
+};
+
+static ssize_t set_onkey_deb(struct device *dev, struct device_attribute *attr,
+			   const char *buf, size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct pcf50633_data *pcf = i2c_get_clientdata(client);
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(deb_time_names); i++) {
+		if (!strncmp(buf, deb_time_names[i], strlen(deb_time_names[i]))) {
+			reg_set_bit_mask(pcf, PCF50633_REG_OOCTIM2,
+				0x7, i);
+		}
+	}
+
+	return count;
+}
+
+static ssize_t show_onkey_deb(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);
+	u_int8_t deb = 0x7;
+
+	deb &= reg_read(pcf, PCF50633_REG_OOCTIM2);
+	return sprintf(buf, "%s\n", deb_time_names[deb]);
+}
+
+static DEVICE_ATTR(onkey_deb, S_IRUGO | S_IWUSR, show_onkey_deb, set_onkey_deb);
 
 /***********************************************************************
  * Driver initialization
@@ -2057,6 +2100,7 @@ static struct attribute *pcf_sysfs_entries[] = {
 	&dev_attr_force_usb_limit_dangerous.attr,
 	&dev_attr_charger_adc.attr,
 	&dev_attr_dump_regs.attr,
+	&dev_attr_onkey_deb.attr,
 	NULL, /* going to add things at this point! */
 	NULL,
 	NULL,
diff --git a/drivers/i2c/chips/pcf50633.h b/drivers/i2c/chips/pcf50633.h
index 5d54131..83ad1ba 100644
--- a/drivers/i2c/chips/pcf50633.h
+++ b/drivers/i2c/chips/pcf50633.h
@@ -333,6 +333,16 @@ enum pcf50633_reg_mbcs3 {
 	PCF50633_MBCS3_VRES		= 0x80, /* 1: Vbat > Vth(RES) */
 };
 
+enum pcf50633_reg_ooctim2 {
+	PCF50633_ONKEY_DEB_NONE,
+	PCF50633_ONKEY_DEB_5MS,
+	PCF50633_ONKEY_DEB_14MS,
+	PCF50633_ONKEY_DEB_62MS,
+	PCF50633_ONKEY_DEB_200MS,
+	PCF50633_ONKEY_DEB_500MS,
+	PCF50633_ONKEY_DEB_1000MS,
+	PCF50633_ONKEY_DEB_2000MS,
+};
 /* this is to be provided by the board implementation */
 extern const u_int8_t pcf50633_initial_regs[__NUM_PCF50633_REGS];
 
-- 
1.5.3.6

Reply via email to