forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/usb/chipidea/otg.c
....@@ -23,6 +23,7 @@
2323
2424 /**
2525 * hw_read_otgsc returns otgsc register bits value.
26
+ * @ci: the controller
2627 * @mask: bitfield mask
2728 */
2829 u32 hw_read_otgsc(struct ci_hdrc *ci, u32 mask)
....@@ -35,7 +36,7 @@
3536 * detection overwrite OTGSC register value
3637 */
3738 cable = &ci->platdata->vbus_extcon;
38
- if (!IS_ERR(cable->edev)) {
39
+ if (!IS_ERR(cable->edev) || ci->role_switch) {
3940 if (cable->changed)
4041 val |= OTGSC_BSVIS;
4142 else
....@@ -53,7 +54,7 @@
5354 }
5455
5556 cable = &ci->platdata->id_extcon;
56
- if (!IS_ERR(cable->edev)) {
57
+ if (!IS_ERR(cable->edev) || ci->role_switch) {
5758 if (cable->changed)
5859 val |= OTGSC_IDIS;
5960 else
....@@ -75,6 +76,7 @@
7576
7677 /**
7778 * hw_write_otgsc updates target bits of OTGSC register.
79
+ * @ci: the controller
7880 * @mask: bitfield mask
7981 * @data: to be written
8082 */
....@@ -83,7 +85,7 @@
8385 struct ci_hdrc_cable *cable;
8486
8587 cable = &ci->platdata->vbus_extcon;
86
- if (!IS_ERR(cable->edev)) {
88
+ if (!IS_ERR(cable->edev) || ci->role_switch) {
8789 if (data & mask & OTGSC_BSVIS)
8890 cable->changed = false;
8991
....@@ -97,7 +99,7 @@
9799 }
98100
99101 cable = &ci->platdata->id_extcon;
100
- if (!IS_ERR(cable->edev)) {
102
+ if (!IS_ERR(cable->edev) || ci->role_switch) {
101103 if (data & mask & OTGSC_IDIS)
102104 cable->changed = false;
103105
....@@ -170,6 +172,13 @@
170172 dev_dbg(ci->dev, "switching from %s to %s\n",
171173 ci_role(ci)->name, ci->roles[role]->name);
172174
175
+ if (ci->vbus_active && ci->role == CI_ROLE_GADGET)
176
+ /*
177
+ * vbus disconnect event is lost due to role
178
+ * switch occurs during system suspend.
179
+ */
180
+ usb_gadget_vbus_disconnect(&ci->gadget);
181
+
173182 ci_role_stop(ci);
174183
175184 if (role == CI_ROLE_GADGET &&
....@@ -222,7 +231,7 @@
222231
223232 /**
224233 * ci_hdrc_otg_init - initialize otg struct
225
- * ci: the controller
234
+ * @ci: the controller
226235 */
227236 int ci_hdrc_otg_init(struct ci_hdrc *ci)
228237 {
....@@ -241,7 +250,7 @@
241250
242251 /**
243252 * ci_hdrc_otg_destroy - destroy otg struct
244
- * ci: the controller
253
+ * @ci: the controller
245254 */
246255 void ci_hdrc_otg_destroy(struct ci_hdrc *ci)
247256 {