summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Bouyack <mbouyack@google.com>2020-12-08 08:52:01 -0800
committerAndrew Evans <andrewevans@google.com>2022-03-09 15:04:44 -0800
commitc410af68015d5c069c23df50bdfccc9adf373431 (patch)
tree44d14200f7f468adb5ef28cc451756cc2fc69b7f
parent41462a9eb29903dad92c718ba82ee56e19a2174d (diff)
downloadrotary-encoders-c410af68015d5c069c23df50bdfccc9adf373431.tar.gz
Add diag to power down r11 crown
'echo 1 > pd' to power down crown 'echo 0 > pd' to restore crown 'cat pd' to check current power down status Bug: 173175887 Change-Id: I9f57eb0412ac39a5b32fcd9d1f6c5351a23bed1d
-rw-r--r--ots_pat9126/pat9126.c48
-rw-r--r--ots_pat9126/pat9126.h3
2 files changed, 51 insertions, 0 deletions
diff --git a/ots_pat9126/pat9126.c b/ots_pat9126/pat9126.c
index a0e7c35..996e098 100644
--- a/ots_pat9126/pat9126.c
+++ b/ots_pat9126/pat9126.c
@@ -535,6 +535,50 @@ static ssize_t pat9126_sleep_level_store(struct device *dev,
return count;
}
+static ssize_t pat9126_pd_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf,
+ size_t count) {
+ u8 config, tmp;
+
+ struct pixart_pat9126_data *data =
+ (struct pixart_pat9126_data *) dev_get_drvdata(dev);
+ struct i2c_client *client = data->client;
+
+ pat9126_read(client, PIXART_PAT9126_CONFIG_REG, &config);
+ config &= ~POWER_DOWN_ENABLE_BIT;
+
+ if (!kstrtou8(buf, 0, &tmp)) {
+ if (tmp) {
+ config |= POWER_DOWN_ENABLE_BIT;
+ }
+
+ dev_dbg(dev, "power down: %d\n", (tmp ? 1 : 0));
+ pat9126_write(client, PIXART_PAT9126_CONFIG_REG, config);
+ } else {
+ dev_warn(dev, "failed to parse sysfs arg: '%s'\n", buf);
+ }
+
+ return count;
+}
+
+static ssize_t pat9126_pd_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf) {
+ int count = 0;
+ uint8_t tmp;
+
+ struct pixart_pat9126_data *data =
+ (struct pixart_pat9126_data *) dev_get_drvdata(dev);
+ struct i2c_client *client = data->client;
+
+ pat9126_read(client, PIXART_PAT9126_CONFIG_REG, &tmp);
+ tmp = ((POWER_DOWN_ENABLE_BIT & tmp) ? 1 : 0);
+ count += sprintf(buf, "0x%x\n", tmp);
+
+ return count;
+}
+
static DEVICE_ATTR
(crown_sensitivity, S_IRUGO | S_IWUSR | S_IWGRP, pat9126_sensitivity_show, pat9126_sensitivity_store);
@@ -547,11 +591,15 @@ static DEVICE_ATTR
static DEVICE_ATTR
(sleep_level, S_IWUSR | S_IWGRP, NULL, pat9126_sleep_level_store);
+static DEVICE_ATTR
+ (pd, S_IRUGO | S_IWUSR | S_IWGRP, pat9126_pd_show, pat9126_pd_store);
+
static struct attribute *pat9126_attr_list[] = {
&dev_attr_crown_sensitivity.attr,
&dev_attr_id.attr,
&dev_attr_max_sleep_level.attr,
&dev_attr_sleep_level.attr,
+ &dev_attr_pd.attr,
NULL,
};
diff --git a/ots_pat9126/pat9126.h b/ots_pat9126/pat9126.h
index d94a955..72d8a7e 100644
--- a/ots_pat9126/pat9126.h
+++ b/ots_pat9126/pat9126.h
@@ -114,6 +114,9 @@
#define SLEEP_MODE_ONE 0x2
#define SLEEP_MODE_TWO 0x4
+/* Power down bit */
+#define POWER_DOWN_ENABLE_BIT 0x08
+
/*define pixel grab flag*/
#define OTS_FRAME_VALID 0x80
#define OTS_PIXEL_VALID 0x40