| .. | .. |
|---|
| 1 | | -// SPDX-License-Identifier: GPL-2.0 |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ |
|---|
| 2 | 2 | /* |
|---|
| 3 | 3 | * ci.h - common structures, functions, and macros of the ChipIdea driver |
|---|
| 4 | 4 | * |
|---|
| .. | .. |
|---|
| 16 | 16 | #include <linux/usb/gadget.h> |
|---|
| 17 | 17 | #include <linux/usb/otg-fsm.h> |
|---|
| 18 | 18 | #include <linux/usb/otg.h> |
|---|
| 19 | +#include <linux/usb/role.h> |
|---|
| 19 | 20 | #include <linux/ulpi/interface.h> |
|---|
| 20 | 21 | |
|---|
| 21 | 22 | /****************************************************************************** |
|---|
| .. | .. |
|---|
| 24 | 25 | #define TD_PAGE_COUNT 5 |
|---|
| 25 | 26 | #define CI_HDRC_PAGE_SIZE 4096ul /* page size for TD's */ |
|---|
| 26 | 27 | #define ENDPT_MAX 32 |
|---|
| 28 | +#define CI_MAX_BUF_SIZE (TD_PAGE_COUNT * CI_HDRC_PAGE_SIZE) |
|---|
| 27 | 29 | |
|---|
| 28 | 30 | /****************************************************************************** |
|---|
| 29 | 31 | * REGISTERS |
|---|
| .. | .. |
|---|
| 217 | 219 | ktime_t hr_timeouts[NUM_OTG_FSM_TIMERS]; |
|---|
| 218 | 220 | unsigned enabled_otg_timer_bits; |
|---|
| 219 | 221 | enum otg_fsm_timer next_otg_timer; |
|---|
| 222 | + struct usb_role_switch *role_switch; |
|---|
| 220 | 223 | struct work_struct work; |
|---|
| 221 | 224 | struct workqueue_struct *wq; |
|---|
| 222 | 225 | |
|---|
| .. | .. |
|---|
| 290 | 293 | ci->roles[role]->stop(ci); |
|---|
| 291 | 294 | } |
|---|
| 292 | 295 | |
|---|
| 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 | + |
|---|
| 293 | 316 | /** |
|---|
| 294 | 317 | * hw_read_id_reg: reads from a identification register |
|---|
| 295 | 318 | * @ci: the controller |
|---|