summaryrefslogtreecommitdiff
path: root/rootdir/init.usb.rc
diff options
context:
space:
mode:
authorTim Kilbourn <tkilbourn@google.com>2015-08-12 09:36:00 -0700
committerTim Kilbourn <tkilbourn@google.com>2015-08-17 14:56:57 -0700
commit8c12fdf4abee092df34e449fa91a66f999e34682 (patch)
tree17a23de52d142ff6e2a5e568f6f3fcf53efba2e3 /rootdir/init.usb.rc
parentfe1b462765d6db4b8b431704dda1b4b3882db61f (diff)
Use init to write usb typec props
The sysfs nodes are owned by root, so use init to write role changes. Bug: 21615151 Change-Id: I39ad03a23af0be9ac859d4fb79a46edc27e30f4e
Diffstat (limited to 'rootdir/init.usb.rc')
-rw-r--r--rootdir/init.usb.rc31
1 files changed, 31 insertions, 0 deletions
diff --git a/rootdir/init.usb.rc b/rootdir/init.usb.rc
index e290ca47f..648223093 100644
--- a/rootdir/init.usb.rc
+++ b/rootdir/init.usb.rc
@@ -89,3 +89,34 @@ on property:sys.usb.config=accessory,audio_source,adb
# when changing the default configuration
on property:persist.sys.usb.config=*
setprop sys.usb.config ${persist.sys.usb.config}
+
+#
+# USB type C
+#
+
+# USB mode changes
+on property:sys.usb.typec.mode=dfp
+ write /sys/class/dual_role_usb/otg_default/mode ${sys.usb.typec.mode}
+ setprop sys.usb.typec.state ${sys.usb.typec.mode}
+
+on property:sys.usb.typec.mode=ufp
+ write /sys/class/dual_role_usb/otg_default/mode ${sys.usb.typec.mode}
+ setprop sys.usb.typec.state ${sys.usb.typec.mode}
+
+# USB data role changes
+on property:sys.usb.typec.data_role=device
+ write /sys/class/dual_role_usb/otg_default/data_role ${sys.usb.typec.data}
+ setprop sys.usb.typec.state ${sys.usb.typec.data_role}
+
+on property:sys.usb.typec.data_role=host
+ write /sys/class/dual_role_usb/otg_default/data_role ${sys.usb.typec.data}
+ setprop sys.usb.typec.state ${sys.usb.typec.data_role}
+
+# USB power role changes
+on property:sys.usb.typec.power_role=source
+ write /sys/class/dual_role_usb/otg_default/power_role ${sys.usb.typec.power}
+ setprop sys.usb.typec.state ${sys.usb.typec.power_role}
+
+on property:sys.usb.typec.power_role=sink
+ write /sys/class/dual_role_usb/otg_default/power_role ${sys.usb.typec.power}
+ setprop sys.usb.typec.state ${sys.usb.typec.power_role}