Merge "hikey: Refactor configfs support to use init.hikey.usb.rc" into m-betta-dev
diff --git a/device.mk b/device.mk
index e1337ce..1ecdd36 100644
--- a/device.mk
+++ b/device.mk
@@ -29,6 +29,7 @@
$(LOCAL_DTB):hi6220-hikey.dtb \
$(LOCAL_PATH)/fstab.hikey:root/fstab.hikey \
$(LOCAL_PATH)/init.hikey.rc:root/init.hikey.rc \
+ $(LOCAL_PATH)/init.hikey.usb.rc:root/init.hikey.usb.rc \
$(LOCAL_PATH)/ueventd.hikey.rc:root/ueventd.hikey.rc \
$(LOCAL_PATH)/hikey.kl:system/usr/keylayout/hikey.kl
diff --git a/init.hikey.rc b/init.hikey.rc
index 4a1914e..a43adf1 100644
--- a/init.hikey.rc
+++ b/init.hikey.rc
@@ -1,3 +1,5 @@
+import init.hikey.usb.rc
+
on init
# mount debugfs
mount debugfs /sys/kernel/debug /sys/kernel/debug
@@ -29,28 +31,6 @@
mount_all /fstab.hikey
setprop ro.crypto.fuse_sdcard false
- mount configfs none /sys/kernel/config
- mkdir /sys/kernel/config/usb_gadget/g1
- mkdir /sys/kernel/config/usb_gadget/g1/functions/ffs.adb
-
- mkdir /dev/usb-ffs 0770 shell shell
- mkdir /dev/usb-ffs/adb 0770 shell shell
- mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
-
- write /sys/kernel/config/usb_gadget/g1/idVendor 0x12d1
- write /sys/kernel/config/usb_gadget/g1/idProduct 0x103a
- mkdir /sys/kernel/config/usb_gadget/g1/strings/0x409
- write /sys/kernel/config/usb_gadget/g1/strings/0x409/serialnumber "0123456789"
- write /sys/kernel/config/usb_gadget/g1/strings/0x409/manufacturer "HISILICON"
- write /sys/kernel/config/usb_gadget/g1/strings/0x409/product "ADB Gadget"
-
- mkdir /sys/kernel/config/usb_gadget/g1/configs/c.1
- mkdir /sys/kernel/config/usb_gadget/g1/configs/c.1/strings/0x409
- write /sys/kernel/config/usb_gadget/g1/configs/c.1/strings/0x409/configuration "Conf 1"
- symlink /sys/kernel/config/usb_gadget/g1/functions/ffs.adb /sys/kernel/config/usb_gadget/g1/configs/c.1/ffs.adb
- start adbd
-
-
on post-fs-data
mkdir /data/media 0770 media_rw media_rw
mkdir /data/misc/gatord 0700 root root
@@ -108,21 +88,6 @@
mkdir /data/misc/dhcp 0770 dhcp dhcp
chown dhcp dhcp /data/misc/dhcp
-on property:sys.usb.config=adb
- write /sys/kernel/config/usb_gadget/g1/UDC "f72c0000.usb"
- write /sys/class/udc/f72c0000.usb/soft_connect "disconnect"
- write /sys/class/udc/f72c0000.usb/soft_connect "connect"
- setprop sys.usb.state ${sys.usb.config}
-
-# FIXME: we need to bind the driver while adbd is restarted. We need delay else bind fails. Need to investigate
-on property:init.svc.adbd=running
- wait /dev/socket/hack 1
- write /sys/kernel/config/usb_gadget/g1/UDC "f72c0000.usb"
- write /sys/class/udc/f72c0000.usb/soft_connect "disconnect"
- write /sys/class/udc/f72c0000.usb/soft_connect "connect"
- setprop sys.usb.state ${sys.usb.config}
-
-
on property:usb_speed.switch=high
write /sys/kernel/debug/f72c0000.usb/config "0"
diff --git a/init.hikey.usb.rc b/init.hikey.usb.rc
new file mode 100644
index 0000000..25e0e1d
--- /dev/null
+++ b/init.hikey.usb.rc
@@ -0,0 +1,89 @@
+on boot
+ mkdir /dev/usb-ffs 0770 shell shell
+ mkdir /dev/usb-ffs/adb 0770 shell shell
+ mount configfs none /config
+ mkdir /config/usb_gadget/g1 0770 shell shell
+ write /config/usb_gadget/g1/idVendor 0x18d1
+ write /config/usb_gadget/g1/bcdDevice 0x0223
+ write /config/usb_gadget/g1/bcdUSB 0x0200
+ mkdir /config/usb_gadget/g1/strings/0x409 0770
+ write /config/usb_gadget/g1/strings/0x409/serialnumber "0123456789"
+ write /config/usb_gadget/g1/strings/0x409/manufacturer "HISILICON"
+ write /config/usb_gadget/g1/strings/0x409/product "ADB Gadget"
+ mkdir /config/usb_gadget/g1/functions/accessory.gs2
+ mkdir /config/usb_gadget/g1/functions/audio_source.gs3
+ mkdir /config/usb_gadget/g1/functions/ffs.adb
+ mkdir /config/usb_gadget/g1/functions/mtp.gs0
+ mkdir /config/usb_gadget/g1/functions/ptp.gs1
+ mkdir /config/usb_gadget/g1/functions/rndis.gs4
+ write /config/usb_gadget/g1/functions/rndis.gs4/wceis 1
+ mkdir /config/usb_gadget/g1/functions/midi.gs5
+ mkdir /config/usb_gadget/g1/configs/b.1 0770 shell shell
+ mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell
+ write /config/usb_gadget/g1/os_desc/b_vendor_code 0x1
+ write /config/usb_gadget/g1/os_desc/qw_sign "MSFT100"
+ write /config/usb_gadget/g1/configs/b.1/MaxPower 500
+ symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1
+ mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
+ setprop sys.usb.configfs 1
+ setprop sys.usb.controller "f72c0000.usb"
+
+on property:sys.usb.config=none && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/os_desc/use 0
+ setprop sys.usb.ffs.ready 0
+
+on property:init.svc.adbd=stopped
+ setprop sys.usb.ffs.ready 0
+
+on property:sys.usb.config=mtp && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/functions/mtp.gs0/os_desc/interface.MTP/compatible_id "MTP"
+ write /config/usb_gadget/g1/os_desc/use 1
+ write /config/usb_gadget/g1/idProduct 0x5202
+
+on property:sys.usb.config=mtp,adb && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/functions/mtp.gs0/os_desc/interface.MTP/compatible_id "MTP"
+ write /config/usb_gadget/g1/os_desc/use 1
+ write /config/usb_gadget/g1/idProduct 0x5203
+
+on property:sys.usb.config=rndis && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x5204
+
+on property:sys.usb.config=rndis,adb && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x5205
+
+on property:sys.usb.config=ptp && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/functions/ptp.gs1/os_desc/interface.MTP/compatible_id "PTP"
+ write /config/usb_gadget/g1/os_desc/use 1
+ write /config/usb_gadget/g1/idProduct 0x5206
+
+on property:sys.usb.config=ptp,adb && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/functions/ptp.gs1/os_desc/interface.MTP/compatible_id "PTP"
+ write /config/usb_gadget/g1/os_desc/use 1
+ write /config/usb_gadget/g1/idProduct 0x5207
+
+on property:sys.usb.config=adb && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x5208
+
+on property:sys.usb.config=midi && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x5209
+
+on property:sys.usb.config=midi,adb && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x520a
+
+on property:sys.usb.config=accessory && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x2d00
+
+on property:sys.usb.config=accessory,adb && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x2d01
+
+on property:sys.usb.config=audio_source && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x2d02
+
+on property:sys.usb.config=audio_source,adb && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x2d03
+
+on property:sys.usb.config=accessory,audio_source && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x2d04
+
+on property:sys.usb.config=accessory,audio_source,adb && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x2d05