summaryrefslogtreecommitdiffstats
path: root/usb_hal/inc
diff options
context:
space:
mode:
Diffstat (limited to 'usb_hal/inc')
-rw-r--r--usb_hal/inc/usb_hal_debug.h31
-rw-r--r--usb_hal/inc/usb_hal_internal.h165
-rw-r--r--usb_hal/inc/usb_hal_usbhallog.h77
3 files changed, 273 insertions, 0 deletions
diff --git a/usb_hal/inc/usb_hal_debug.h b/usb_hal/inc/usb_hal_debug.h
new file mode 100644
index 00000000..15b307a3
--- /dev/null
+++ b/usb_hal/inc/usb_hal_debug.h
@@ -0,0 +1,31 @@
+/*
+ * @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * 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.
+ */
+
+#ifndef INC_USB_HAL_DEBUG_H_
+#define INC_USB_HAL_DEBUG_H_
+
+#include "usb_hal_usbhallog.h"
+
+/* Log output control flag */
+#define USB_LOG_ENABLE_ERROR /* Error log */
+
+#ifdef USB_LOG_ENABLE_ERROR
+#define USB_ERROR_LOG(fmt, ...) FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, fmt, ##__VA_ARGS__)
+#else
+#define USB_ERROR_LOG(fmt, ...)
+#endif
+
+#endif // INC_USB_HAL_DEBUG_H_
diff --git a/usb_hal/inc/usb_hal_internal.h b/usb_hal/inc/usb_hal_internal.h
new file mode 100644
index 00000000..86c39056
--- /dev/null
+++ b/usb_hal/inc/usb_hal_internal.h
@@ -0,0 +1,165 @@
+/*
+ * @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * 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.
+ */
+
+#ifndef INC_USB_HAL_INTERNAL_H_
+#define INC_USB_HAL_INTERNAL_H_
+
+#define FILE_CONTENT_LENGTH (32)
+#define FILE_PATH_LENGTH (128)
+
+/**
+ * USB role file
+ */
+#define USB_ROLE_FILE "/sys/devices/platform/soc/ee080200.usb-phy/role"
+
+/**
+ * USB host value
+ */
+#define USB_HOST_STRING "host\n"
+
+/**
+ * USB function value
+ */
+#define USB_FUNCTION_STRING "peripheral\n"
+
+/**
+ * gpio high value
+ */
+const char kUsbGpioHighValue = '1';
+
+/**
+ * gpio low value
+ */
+const char kUsbGpioLowValue = '0';
+
+/**
+ * gpio export file
+ */
+const char kUsbGpioExportFile[] = "/sys/class/gpio/export";
+
+/**
+ * gpio file prefix
+ */
+const char kUsbGpioFilePrefix[] = "/sys/class/gpio/gpio";
+
+/**
+ * gpio direction file
+ */
+const char kUsbGpioDirectionFile[] = "/direction";
+
+/**
+ * gpio direction in
+ */
+const char kUsbGpioDirectionIn[] = "in";
+
+/**
+ * gpio direction out high
+ */
+const char kUsbGpioDirectionHigh[] = "high";
+
+/**
+ * gpio direction out low
+ */
+const char kUsbGpioDirectionLow[] = "low";
+
+/**
+ * gpio value file
+ */
+const char kUsbGpioValueFile[] = "/value";
+
+/**
+ * structure of USB role switch information
+ */
+struct UsbRoleSwitchInfo {
+ const char* file_path; //!< USB role switch file path
+ const char* usb_host_value; //!< USB host value
+ const char* usb_function_value; //!< USB function value
+};
+
+/**
+ * USB gpio port definition
+ */
+enum UsbGpioPort {
+ USB_GPIO_PORT_USB0_PWEN = 0, //!< USB0 power enable
+ USB_GPIO_PORT_USB1_PWEN, //!< USB1 power enable
+ USB_GPIO_PORT_USB2_PWEN, //!< USB2 power enable
+ USB_GPIO_PORT_USB0_OVC, //!< USB0 overcurrent
+ USB_GPIO_PORT_USB1_OVC, //!< USB1 overcurrent
+ USB_GPIO_PORT_USB2_OVC, //!< USB2 overcurrent
+ USB_GPIO_PORT_MAX
+};
+
+/**
+ * USB gpio port value definition
+ */
+enum GpioPortValue {
+ GPIO_PORT_OFF = 0, //!< gpio port on
+ GPIO_PORT_ON //!< gpio port off
+};
+
+/**
+ * Length for USB gpio port name
+ */
+#define USB_PORT_NAME_LENGTH (8)
+
+/**
+ * USB gpio port information
+ */
+struct UsbGpioPortInfo {
+ bool active_low; //!< active low or high
+ bool is_output; //!< direction output or input
+ const char* port_name; //!< gpio port name
+ char default_value; //!< output port default value (high or low)
+};
+
+/**
+ * USB gpio port config table
+ */
+const char kUsbGpioPortNameUsb0Pwen[] = "375";
+const char kUsbGpioPortNameUsb1Pwen[] = "387";
+const char kUsbGpioPortNameUsb2Pwen[] = "389";
+const char kUsbGpioPortNameUsb0Ovc[] = "376";
+const char kUsbGpioPortNameUsb1Ovc[] = "388";
+const char kUsbGpioPortNameUsb2Ovc[] = "390";
+
+const UsbGpioPortInfo kUsbGpioInfo[] = {
+ { false, true, kUsbGpioPortNameUsb0Pwen, kUsbGpioHighValue },
+ { false, true, kUsbGpioPortNameUsb1Pwen, kUsbGpioHighValue },
+ { false, true, kUsbGpioPortNameUsb2Pwen, kUsbGpioHighValue },
+ { false, false, kUsbGpioPortNameUsb0Ovc, kUsbGpioLowValue },
+ { false, false, kUsbGpioPortNameUsb1Ovc, kUsbGpioLowValue },
+ { false, false, kUsbGpioPortNameUsb2Ovc, kUsbGpioLowValue }
+};
+
+/**
+ * gpio port list of USB power enable
+ */
+const UsbGpioPort kUsbPowerEnableGpio[] = {
+ USB_GPIO_PORT_USB0_PWEN,
+ USB_GPIO_PORT_USB1_PWEN,
+ USB_GPIO_PORT_USB2_PWEN
+};
+
+/**
+ * gpio port list of USB overcurrent
+ */
+const UsbGpioPort kUsbOvercurrentGpio[] = {
+ USB_GPIO_PORT_USB0_OVC,
+ USB_GPIO_PORT_USB1_OVC,
+ USB_GPIO_PORT_USB2_OVC
+};
+
+#endif // INC_USB_HAL_INTERNAL_H_
diff --git a/usb_hal/inc/usb_hal_usbhallog.h b/usb_hal/inc/usb_hal_usbhallog.h
new file mode 100644
index 00000000..53c0a6b3
--- /dev/null
+++ b/usb_hal/inc/usb_hal_usbhallog.h
@@ -0,0 +1,77 @@
+/*
+ * @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * 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.
+ */
+
+#ifndef INC_USB_HAL_USBHALLOG_H_
+#define INC_USB_HAL_USBHALLOG_H_
+
+#include <native_service/ns_logger_if.h>
+
+#define ZONE_INIT ZONEMASK(10)
+#define ZONE_FUNC ZONEMASK(11)
+#define ZONE_MEM ZONEMASK(12)
+#define ZONE_13 ZONEMASK(13)
+#define ZONE_14 ZONEMASK(14)
+#define ZONE_15 ZONEMASK(15)
+#define ZONE_16 ZONEMASK(16)
+#define ZONE_17 ZONEMASK(17)
+#define ZONE_18 ZONEMASK(18)
+#define ZONE_19 ZONEMASK(19)
+#define ZONE_20 ZONEMASK(20)
+#define ZONE_21 ZONEMASK(21)
+#define ZONE_22 ZONEMASK(22)
+#define ZONE_23 ZONEMASK(23)
+#define ZONE_24 ZONEMASK(24)
+#define ZONE_25 ZONEMASK(25)
+#define ZONE_26 ZONEMASK(26)
+#define ZONE_27 ZONEMASK(27)
+#define ZONE_28 ZONEMASK(28)
+#define ZONE_INFO ZONEMASK(29)
+#define ZONE_WARN ZONEMASK(30)
+#define ZONE_ERR ZONEMASK(31)
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 ""
+#define ZONE_TEXT_14 ""
+#define ZONE_TEXT_15 ""
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 ""
+#define ZONE_TEXT_27 ""
+#define ZONE_TEXT_28 ""
+#define ZONE_TEXT_29 "Info"
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS (LSHAREDMEM) // LPRINT , LMSGQ, LSLOGGER
+#endif
+
+#ifndef FRAMEWORKUNIFIEDLOGAPPZONES
+#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_ERR, ZONE_WARN, ZONE_INFO
+#endif
+
+extern const CHAR AppName[]; // NOLINT (defind outside)
+#endif // INC_USB_HAL_USBHALLOG_H_