Lines Matching +full:data +full:- +full:role
1 /* SPDX-License-Identifier: GPL-2.0 */
3 * ci.h - common structures, functions, and macros of the ChipIdea driver
5 * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved.
17 #include <linux/usb/otg-fsm.h>
19 #include <linux/usb/role.h>
76 * struct ci_hw_ep - endpoint representation
127 * struct ci_role_driver - host/gadget role driver
128 * @start: start this role
129 * @stop: stop this role
130 * @suspend: system suspend handler for this role
131 * @resume: system resume handler for this role
132 * @irq: irq handler for this role
133 * @name: role name string (host/gadget)
145 * struct hw_bank - hardware register mapping representation
165 * struct ci_hdrc - chipidea device representation
171 * @role: current role
172 * @is_otg: if the device is otg-capable
178 * @work: work for role changing
193 * @remote_wakeup: host-enabled remote wakeup
211 * @mutex: protect code from concorrent running when doing role switch
219 enum ci_role role; member
270 BUG_ON(ci->role >= CI_ROLE_END || !ci->roles[ci->role]); in ci_role()
271 return ci->roles[ci->role]; in ci_role()
274 static inline int ci_role_start(struct ci_hdrc *ci, enum ci_role role) in ci_role_start() argument
278 if (role >= CI_ROLE_END) in ci_role_start()
279 return -EINVAL; in ci_role_start()
281 if (!ci->roles[role]) in ci_role_start()
282 return -ENXIO; in ci_role_start()
284 ret = ci->roles[role]->start(ci); in ci_role_start()
288 ci->role = role; in ci_role_start()
290 if (ci->usb_phy) { in ci_role_start()
291 if (role == CI_ROLE_HOST) in ci_role_start()
292 usb_phy_set_event(ci->usb_phy, USB_EVENT_ID); in ci_role_start()
295 usb_phy_set_event(ci->usb_phy, USB_EVENT_NONE); in ci_role_start()
303 enum ci_role role = ci->role; in ci_role_stop() local
305 if (role == CI_ROLE_END) in ci_role_stop()
308 ci->role = CI_ROLE_END; in ci_role_stop()
310 ci->roles[role]->stop(ci); in ci_role_stop()
312 if (ci->usb_phy) in ci_role_stop()
313 usb_phy_set_event(ci->usb_phy, USB_EVENT_NONE); in ci_role_stop()
318 if (ci->role == CI_ROLE_HOST) in ci_role_to_usb_role()
320 else if (ci->role == CI_ROLE_GADGET && ci->vbus_active) in ci_role_to_usb_role()
326 static inline enum ci_role usb_role_to_ci_role(enum usb_role role) in usb_role_to_ci_role() argument
328 if (role == USB_ROLE_HOST) in usb_role_to_ci_role()
330 else if (role == USB_ROLE_DEVICE) in usb_role_to_ci_role()
346 return ioread32(ci->hw_bank.abs + offset) & mask; in hw_read_id_reg()
354 * @data: new value
357 u32 mask, u32 data) in hw_write_id_reg() argument
360 data = (ioread32(ci->hw_bank.abs + offset) & ~mask) in hw_write_id_reg()
361 | (data & mask); in hw_write_id_reg()
363 iowrite32(data, ci->hw_bank.abs + offset); in hw_write_id_reg()
376 return ioread32(ci->hw_bank.regmap[reg]) & mask; in hw_read()
393 if (ci->imx28_write_fix) in __hw_write()
404 * @data: new value
407 u32 mask, u32 data) in hw_write() argument
410 data = (ioread32(ci->hw_bank.regmap[reg]) & ~mask) in hw_write()
411 | (data & mask); in hw_write()
413 __hw_write(ci, data, ci->hw_bank.regmap[reg]); in hw_write()
427 u32 val = ioread32(ci->hw_bank.regmap[reg]) & mask; in hw_test_and_clear()
429 __hw_write(ci, val, ci->hw_bank.regmap[reg]); in hw_test_and_clear()
438 * @data: new value
443 u32 mask, u32 data) in hw_test_and_write() argument
447 hw_write(ci, reg, mask, data); in hw_test_and_write()
460 struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps; in ci_otg_is_fsm_mode()
462 return ci->is_otg && ci->roles[CI_ROLE_HOST] && in ci_otg_is_fsm_mode()
463 ci->roles[CI_ROLE_GADGET] && (otg_caps->srp_support || in ci_otg_is_fsm_mode()
464 otg_caps->hnp_support || otg_caps->adp_support); in ci_otg_is_fsm_mode()