Enable USB gadget for RPI4 13/225613/1 accepted/tizen_5.5_unified accepted/tizen_5.5_unified_wearable_hotfix tizen_5.5_wearable_hotfix accepted/tizen/5.5/unified/20200224.123530 accepted/tizen/5.5/unified/wearable/hotfix/20201027.123706 submit/tizen_5.5/20200221.073551 submit/tizen_5.5_wearable_hotfix/20201026.184301
authorINSUN PYO <insun.pyo@samsung.com>
Thu, 6 Feb 2020 07:38:03 +0000 (16:38 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Fri, 21 Feb 2020 07:16:44 +0000 (07:16 +0000)
You can use this usb hal with both RPI3 and RPI4.
////////////////////////////////////////////////////////////////////////////////////////////////////
RPI3 does not have /sys/kernel/config and usb initialization faiied.
So, usb is not enabled in RPI3.
Therefore, a single usb hal can be used in both RPI3 and RPI4.

Deviced internal design for extcon providing incomplete functionality
////////////////////////////////////////////////////////////////////////////////////////////////////
Excon does not work perfectly in RPI4
So I asked the kernel team to fix the extcon value to 1.
If extcon is always 1, deviecd will not recognize when usb is disconnected, but it will work normally.

Conclusion: For targets where extcon does not work perfectly, deviced do not support usb connect/disconnect.

Change-Id: Iea3ae481b3120432197a849956fc5332748957ad
Signed-off-by: INSUN PYO <insun.pyo@samsung.com>
(cherry picked from commit 2b4d1ac644f634687defc56636ca06ab57ee7259)

CMakeLists.txt
hw/usb_cfs_client/CMakeLists.txt [new file with mode: 0644]
hw/usb_cfs_client/usb_cfs_client.c [new file with mode: 0644]
hw/usb_gadget/CMakeLists.txt [new file with mode: 0644]
hw/usb_gadget/usb_gadget.c [new file with mode: 0644]

index c10c059..2633052 100644 (file)
@@ -9,3 +9,5 @@ ADD_SUBDIRECTORY(hw/display)
 ADD_SUBDIRECTORY(hw/led)
 ADD_SUBDIRECTORY(hw/touchscreen)
 ADD_SUBDIRECTORY(hw/thermal)
+ADD_SUBDIRECTORY(hw/usb_cfs_client)
+ADD_SUBDIRECTORY(hw/usb_gadget)
diff --git a/hw/usb_cfs_client/CMakeLists.txt b/hw/usb_cfs_client/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e3447fb
--- /dev/null
@@ -0,0 +1,19 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(usb_cfs_client C)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(usb_cfs_client_pkgs REQUIRED hwcommon)
+
+FOREACH(flag ${usb_cfs_client_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_LIBRARY(${PROJECT_NAME} MODULE usb_cfs_client.c)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${usb_cfs_client_pkgs_LDFLAGS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "")
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}/hw COMPONENT RuntimeLibraries)
diff --git a/hw/usb_cfs_client/usb_cfs_client.c b/hw/usb_cfs_client/usb_cfs_client.c
new file mode 100644 (file)
index 0000000..36da551
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * device-node
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <hw/usb_client.h>
+
+HARDWARE_MODULE_STRUCTURE = {
+       .magic = HARDWARE_INFO_TAG,
+       .hal_version = HARDWARE_INFO_VERSION,
+       .device_version = USB_CLIENT_HARDWARE_DEVICE_VERSION,
+       .id = USB_CFS_CLIENT_HARDWARE_DEVICE_ID,
+       .name = "cfs-gadget",
+       .open = hw_cfs_gadget_open,
+       .close = hw_cfs_gadget_close,
+};
diff --git a/hw/usb_gadget/CMakeLists.txt b/hw/usb_gadget/CMakeLists.txt
new file mode 100644 (file)
index 0000000..039baa4
--- /dev/null
@@ -0,0 +1,19 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(usb_gadget C)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(usb_gadget_pkgs REQUIRED hwcommon)
+
+FOREACH(flag ${usb_gadget_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_LIBRARY(${PROJECT_NAME} MODULE usb_gadget.c)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${usb_gadget_pkgs_LDFLAGS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "")
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}/hw COMPONENT RuntimeLibraries)
diff --git a/hw/usb_gadget/usb_gadget.c b/hw/usb_gadget/usb_gadget.c
new file mode 100644 (file)
index 0000000..2bf9d96
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * libdevice-node
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <hw/usb_gadget.h>
+
+HARDWARE_MODULE_STRUCTURE = {
+       .magic = HARDWARE_INFO_TAG,
+       .hal_version = HARDWARE_INFO_VERSION,
+       .device_version = USB_GADGET_DEVICE_VERSION,
+       .id = USB_GADGET_DEVICE_ID,
+       .name = "simple_translator",
+       .open = simple_translator_open,
+       .close = simple_translator_close,
+};