aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Caruso <ejcaruso@chromium.org>2017-05-16 11:46:48 -0400
committerBenson Leung <bleung@chromium.org>2017-06-23 19:12:19 -0400
commitabbb054d53266bfbd45ca9f2ba6522e3fd5b7f86 (patch)
tree000639f160202c08c3b585807c085811f0b12312
parent405c84308c4335ee7cb58b9304b77b85e61f7129 (diff)
platform/chrome: cros_ec_lightbar - Add userspace lightbar control bit to EC
Some devices might want to turn off the lightbar if e.g. the system turns the screen off due to idleness. This prevents the kernel from going through its normal suspend/resume pathways. Signed-off-by: Eric Caruso <ejcaruso@chromium.org> Signed-off-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> Signed-off-by: Benson Leung <bleung@chromium.org>
-rw-r--r--drivers/platform/chrome/cros_ec_lightbar.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/platform/chrome/cros_ec_lightbar.c b/drivers/platform/chrome/cros_ec_lightbar.c
index 4df379dc4bb9..e570c1ef7728 100644
--- a/drivers/platform/chrome/cros_ec_lightbar.c
+++ b/drivers/platform/chrome/cros_ec_lightbar.c
@@ -38,6 +38,12 @@
38/* Rate-limit the lightbar interface to prevent DoS. */ 38/* Rate-limit the lightbar interface to prevent DoS. */
39static unsigned long lb_interval_jiffies = 50 * HZ / 1000; 39static unsigned long lb_interval_jiffies = 50 * HZ / 1000;
40 40
41/*
42 * Whether or not we have given userspace control of the lightbar.
43 * If this is true, we won't do anything during suspend/resume.
44 */
45static bool userspace_control;
46
41static ssize_t interval_msec_show(struct device *dev, 47static ssize_t interval_msec_show(struct device *dev,
42 struct device_attribute *attr, char *buf) 48 struct device_attribute *attr, char *buf)
43{ 49{
@@ -407,11 +413,17 @@ error:
407 413
408int lb_suspend(struct cros_ec_dev *ec) 414int lb_suspend(struct cros_ec_dev *ec)
409{ 415{
416 if (userspace_control)
417 return 0;
418
410 return lb_send_empty_cmd(ec, LIGHTBAR_CMD_SUSPEND); 419 return lb_send_empty_cmd(ec, LIGHTBAR_CMD_SUSPEND);
411} 420}
412 421
413int lb_resume(struct cros_ec_dev *ec) 422int lb_resume(struct cros_ec_dev *ec)
414{ 423{
424 if (userspace_control)
425 return 0;
426
415 return lb_send_empty_cmd(ec, LIGHTBAR_CMD_RESUME); 427 return lb_send_empty_cmd(ec, LIGHTBAR_CMD_RESUME);
416} 428}
417 429
@@ -528,6 +540,30 @@ exit:
528 return ret; 540 return ret;
529} 541}
530 542
543static ssize_t userspace_control_show(struct device *dev,
544 struct device_attribute *attr,
545 char *buf)
546{
547 return scnprintf(buf, PAGE_SIZE, "%d\n", userspace_control);
548}
549
550static ssize_t userspace_control_store(struct device *dev,
551 struct device_attribute *attr,
552 const char *buf,
553 size_t count)
554{
555 bool enable;
556 int ret;
557
558 ret = strtobool(buf, &enable);
559 if (ret < 0)
560 return ret;
561
562 userspace_control = enable;
563
564 return count;
565}
566
531/* Module initialization */ 567/* Module initialization */
532 568
533static DEVICE_ATTR_RW(interval_msec); 569static DEVICE_ATTR_RW(interval_msec);
@@ -536,6 +572,7 @@ static DEVICE_ATTR_WO(brightness);
536static DEVICE_ATTR_WO(led_rgb); 572static DEVICE_ATTR_WO(led_rgb);
537static DEVICE_ATTR_RW(sequence); 573static DEVICE_ATTR_RW(sequence);
538static DEVICE_ATTR_WO(program); 574static DEVICE_ATTR_WO(program);
575static DEVICE_ATTR_RW(userspace_control);
539 576
540static struct attribute *__lb_cmds_attrs[] = { 577static struct attribute *__lb_cmds_attrs[] = {
541 &dev_attr_interval_msec.attr, 578 &dev_attr_interval_msec.attr,
@@ -544,6 +581,7 @@ static struct attribute *__lb_cmds_attrs[] = {
544 &dev_attr_led_rgb.attr, 581 &dev_attr_led_rgb.attr,
545 &dev_attr_sequence.attr, 582 &dev_attr_sequence.attr,
546 &dev_attr_program.attr, 583 &dev_attr_program.attr,
584 &dev_attr_userspace_control.attr,
547 NULL, 585 NULL,
548}; 586};
549 587