Skip to contentSkip to conversation

platform/chrome: wilco_ec: Add Boot on AC support

PATCH Superseded Nick Crews 1 participant 2 messages Apr 10, 2019 Chrome hardware platform support

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Nick Crews

author
#0 lore raw

PATCH v2 1/2 platform/chrome: wilco_ec: Add Boot on AC support

Boot on AC is a policy which makes the device boot from S5 when AC power is connected. This is useful for users who want to run their device headless or with a dock.

v2 changes:
- Move documentation to Documentation/ABI/testing/sysfs-platform-wilco-ec

---
 .../ABI/testing/sysfs-platform-wilco-ec       | 11 +++
 drivers/platform/chrome/wilco_ec/Makefile     |  2 +-
 drivers/platform/chrome/wilco_ec/core.c       |  9 +++
 drivers/platform/chrome/wilco_ec/sysfs.c      | 77 +++++++++++++++++++
 include/linux/platform_data/wilco-ec.h        |  3 +
 5 files changed, 101 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-wilco-ec
 create mode 100644 drivers/platform/chrome/wilco_ec/sysfs.c
Documentation/ABI/testing/sysfs-platform-wilco-ec new file +11 -0
new file mode 100644
index 000000000000..e074c203cd32
@@ -0,0 +1,11 @@
+What:		/sys/bus/platform/devices/GOOG000C\:00/boot_on_ac
+Date:		April 2019
+KernelVersion:	5.2
+Description:
+		Boot on AC is a policy which makes the device boot from S5
+		when AC power is connected. This is useful for users who
+		want to run their device headless or with a dock.
+
+		Input should be parseable by kstrtou8() to 0 or 1.
+		Output will be either "0\n" or "1\n".
+
drivers/platform/chrome/wilco_ec/Makefile +1 -1
index 063e7fb4ea17..1281dd7737c4 100644
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
-wilco_ec-objs				:= core.o mailbox.o
+wilco_ec-objs				:= core.o mailbox.o sysfs.o
 obj-$(CONFIG_WILCO_EC)			+= wilco_ec.o
 wilco_ec_debugfs-objs			:= debugfs.o
 obj-$(CONFIG_WILCO_EC_DEBUGFS)		+= wilco_ec_debugfs.o
drivers/platform/chrome/wilco_ec/core.c +9 -0
index 05e1e2be1c91..abd15d04e57b 100644
@@ -89,8 +89,16 @@ static int wilco_ec_probe(struct platform_device *pdev)
 		goto unregister_debugfs;
 	}
 
+	ret = wilco_ec_add_sysfs(ec);
+	if (ret < 0) {
+		dev_err(dev, "Failed to create sysfs entries: %d", ret);
+		goto unregister_rtc;
+	}
+
 	return 0;
 
+unregister_rtc:
+	platform_device_unregister(ec->rtc_pdev);
 unregister_debugfs:
 	if (ec->debugfs_pdev)
 		platform_device_unregister(ec->debugfs_pdev);
@@ -102,6 +110,7 @@ static int wilco_ec_remove(struct platform_device *pdev)
 {
 	struct wilco_ec_device *ec = platform_get_drvdata(pdev);
 
+	wilco_ec_remove_sysfs(ec);
 	platform_device_unregister(ec->rtc_pdev);
 	if (ec->debugfs_pdev)
 		platform_device_unregister(ec->debugfs_pdev);
drivers/platform/chrome/wilco_ec/sysfs.c new file +77 -0

77 lines not on this page · raw message

include/linux/platform_data/wilco-ec.h +3 -0
index 1ff224793c99..05d011605b85 100644
@@ -123,4 +123,7 @@ struct wilco_ec_message {
  */
 int wilco_ec_mailbox(struct wilco_ec_device *ec, struct wilco_ec_message *msg);
 
+int wilco_ec_add_sysfs(struct wilco_ec_device *ec);
+void wilco_ec_remove_sysfs(struct wilco_ec_device *ec);
+
 #endif /* WILCO_EC_H */
Signature · 1 line
2.20.1
author
#1 lore raw

PATCH v2 2/2 platform/chrome: wilco_ec: Add USB PowerShare Policy control

USB PowerShare is a policy which affects charging via the special USB PowerShare port (marked with a small lightning bolt or battery icon) when in low power states:
- In S0, the port will always provide power.
- In S0ix, if power_share is enabled, then power will be supplied to the port when on AC or if battery is > 50%. Else no power is supplied.
- In S5, if power_share is enabled, then power will be supplied to the port when on AC. Else no power is supplied.

v2 changes:
- Move documentation to Documentation/ABI/testing/sysfs-platform-wilco-ec
- Zero out reserved bytes in requests.

---
 .../ABI/testing/sysfs-platform-wilco-ec       | 16 ++++
 drivers/platform/chrome/wilco_ec/sysfs.c      | 93 +++++++++++++++++++
 2 files changed, 109 insertions(+)
Documentation/ABI/testing/sysfs-platform-wilco-ec +16 -0
index e074c203cd32..0c07d5e0b737 100644
@@ -9,3 +9,19 @@ Description:
 		Input should be parseable by kstrtou8() to 0 or 1.
 		Output will be either "0\n" or "1\n".
 
+What:		/sys/bus/platform/devices/GOOG000C\:00/usb_power_share
+Date:		April 2019
+KernelVersion:	5.2
+Description:
+		Control the USB PowerShare Policy. USB PowerShare is a policy
+		which affects charging via the special USB PowerShare port
+		(marked with a small lightning bolt or battery icon) when in
+		low power states:
+		- In S0, the port will always provide power.
+		- In S0ix, if power_share is enabled, then power will be
+		  supplied to the port when on AC or if battery is > 50%.
+		  Else no power is supplied.
+		- In S5, if power_share is enabled, then power will be supplied
+		  to the port when on AC. Else no power is supplied.
+
+		Input should be either "0" or "1".
drivers/platform/chrome/wilco_ec/sysfs.c +93 -0

107 lines not on this page · raw message

Signature · 1 line
2.20.1