2 * @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef INC_USB_HAL_INTERNAL_H_
18 #define INC_USB_HAL_INTERNAL_H_
20 #define FILE_CONTENT_LENGTH (32)
21 #define FILE_PATH_LENGTH (128)
26 #define USB_ROLE_FILE "/sys/devices/platform/soc/ee080200.usb-phy/role"
31 #define USB_HOST_STRING "host\n"
36 #define USB_FUNCTION_STRING "peripheral\n"
41 const char kUsbGpioHighValue = '1';
46 const char kUsbGpioLowValue = '0';
51 const char kUsbGpioExportFile[] = "/sys/class/gpio/export";
56 const char kUsbGpioFilePrefix[] = "/sys/class/gpio/gpio";
61 const char kUsbGpioDirectionFile[] = "/direction";
66 const char kUsbGpioDirectionIn[] = "in";
69 * gpio direction out high
71 const char kUsbGpioDirectionHigh[] = "high";
74 * gpio direction out low
76 const char kUsbGpioDirectionLow[] = "low";
81 const char kUsbGpioValueFile[] = "/value";
84 * structure of USB role switch information
86 struct UsbRoleSwitchInfo {
87 const char* file_path; //!< USB role switch file path
88 const char* usb_host_value; //!< USB host value
89 const char* usb_function_value; //!< USB function value
93 * USB gpio port definition
96 USB_GPIO_PORT_USB0_PWEN = 0, //!< USB0 power enable
97 USB_GPIO_PORT_USB1_PWEN, //!< USB1 power enable
98 USB_GPIO_PORT_USB2_PWEN, //!< USB2 power enable
99 USB_GPIO_PORT_USB0_OVC, //!< USB0 overcurrent
100 USB_GPIO_PORT_USB1_OVC, //!< USB1 overcurrent
101 USB_GPIO_PORT_USB2_OVC, //!< USB2 overcurrent
106 * USB gpio port value definition
109 GPIO_PORT_OFF = 0, //!< gpio port on
110 GPIO_PORT_ON //!< gpio port off
114 * Length for USB gpio port name
116 #define USB_PORT_NAME_LENGTH (8)
119 * USB gpio port information
121 struct UsbGpioPortInfo {
122 bool active_low; //!< active low or high
123 bool is_output; //!< direction output or input
124 const char* port_name; //!< gpio port name
125 char default_value; //!< output port default value (high or low)
129 * USB gpio port config table
131 const char kUsbGpioPortNameUsb0Pwen[] = "375";
132 const char kUsbGpioPortNameUsb1Pwen[] = "387";
133 const char kUsbGpioPortNameUsb2Pwen[] = "389";
134 const char kUsbGpioPortNameUsb0Ovc[] = "376";
135 const char kUsbGpioPortNameUsb1Ovc[] = "388";
136 const char kUsbGpioPortNameUsb2Ovc[] = "390";
138 const UsbGpioPortInfo kUsbGpioInfo[] = {
139 { false, true, kUsbGpioPortNameUsb0Pwen, kUsbGpioHighValue },
140 { false, true, kUsbGpioPortNameUsb1Pwen, kUsbGpioHighValue },
141 { false, true, kUsbGpioPortNameUsb2Pwen, kUsbGpioHighValue },
142 { false, false, kUsbGpioPortNameUsb0Ovc, kUsbGpioLowValue },
143 { false, false, kUsbGpioPortNameUsb1Ovc, kUsbGpioLowValue },
144 { false, false, kUsbGpioPortNameUsb2Ovc, kUsbGpioLowValue }
148 * gpio port list of USB power enable
150 const UsbGpioPort kUsbPowerEnableGpio[] = {
151 USB_GPIO_PORT_USB0_PWEN,
152 USB_GPIO_PORT_USB1_PWEN,
153 USB_GPIO_PORT_USB2_PWEN
157 * gpio port list of USB overcurrent
159 const UsbGpioPort kUsbOvercurrentGpio[] = {
160 USB_GPIO_PORT_USB0_OVC,
161 USB_GPIO_PORT_USB1_OVC,
162 USB_GPIO_PORT_USB2_OVC
165 #endif // INC_USB_HAL_INTERNAL_H_