forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/drivers/usb/chipidea/ci.h
....@@ -1,4 +1,4 @@
1
-// SPDX-License-Identifier: GPL-2.0
1
+/* SPDX-License-Identifier: GPL-2.0 */
22 /*
33 * ci.h - common structures, functions, and macros of the ChipIdea driver
44 *
....@@ -16,6 +16,7 @@
1616 #include <linux/usb/gadget.h>
1717 #include <linux/usb/otg-fsm.h>
1818 #include <linux/usb/otg.h>
19
+#include <linux/usb/role.h>
1920 #include <linux/ulpi/interface.h>
2021
2122 /******************************************************************************
....@@ -24,6 +25,7 @@
2425 #define TD_PAGE_COUNT 5
2526 #define CI_HDRC_PAGE_SIZE 4096ul /* page size for TD's */
2627 #define ENDPT_MAX 32
28
+#define CI_MAX_BUF_SIZE (TD_PAGE_COUNT * CI_HDRC_PAGE_SIZE)
2729
2830 /******************************************************************************
2931 * REGISTERS
....@@ -217,6 +219,7 @@
217219 ktime_t hr_timeouts[NUM_OTG_FSM_TIMERS];
218220 unsigned enabled_otg_timer_bits;
219221 enum otg_fsm_timer next_otg_timer;
222
+ struct usb_role_switch *role_switch;
220223 struct work_struct work;
221224 struct workqueue_struct *wq;
222225
....@@ -290,6 +293,26 @@
290293 ci->roles[role]->stop(ci);
291294 }
292295
296
+static inline enum usb_role ci_role_to_usb_role(struct ci_hdrc *ci)
297
+{
298
+ if (ci->role == CI_ROLE_HOST)
299
+ return USB_ROLE_HOST;
300
+ else if (ci->role == CI_ROLE_GADGET && ci->vbus_active)
301
+ return USB_ROLE_DEVICE;
302
+ else
303
+ return USB_ROLE_NONE;
304
+}
305
+
306
+static inline enum ci_role usb_role_to_ci_role(enum usb_role role)
307
+{
308
+ if (role == USB_ROLE_HOST)
309
+ return CI_ROLE_HOST;
310
+ else if (role == USB_ROLE_DEVICE)
311
+ return CI_ROLE_GADGET;
312
+ else
313
+ return CI_ROLE_END;
314
+}
315
+
293316 /**
294317 * hw_read_id_reg: reads from a identification register
295318 * @ci: the controller