36
36
#include <linux/kernel.h>
37
37
#include <linux/module.h>
38
38
#include <linux/of_device.h>
39
+ #include <linux/usb/of.h>
39
40
40
41
#include "core.h"
41
42
@@ -53,7 +54,8 @@ static void dwc2_set_his_params(struct dwc2_hsotg *hsotg)
53
54
{
54
55
struct dwc2_core_params * p = & hsotg -> params ;
55
56
56
- p -> otg_cap = DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE ;
57
+ p -> otg_caps .hnp_support = false;
58
+ p -> otg_caps .srp_support = false;
57
59
p -> speed = DWC2_SPEED_PARAM_HIGH ;
58
60
p -> host_rx_fifo_size = 512 ;
59
61
p -> host_nperio_tx_fifo_size = 512 ;
@@ -84,7 +86,8 @@ static void dwc2_set_rk_params(struct dwc2_hsotg *hsotg)
84
86
{
85
87
struct dwc2_core_params * p = & hsotg -> params ;
86
88
87
- p -> otg_cap = DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE ;
89
+ p -> otg_caps .hnp_support = false;
90
+ p -> otg_caps .srp_support = false;
88
91
p -> host_rx_fifo_size = 525 ;
89
92
p -> host_nperio_tx_fifo_size = 128 ;
90
93
p -> host_perio_tx_fifo_size = 256 ;
@@ -97,7 +100,8 @@ static void dwc2_set_ltq_params(struct dwc2_hsotg *hsotg)
97
100
{
98
101
struct dwc2_core_params * p = & hsotg -> params ;
99
102
100
- p -> otg_cap = 2 ;
103
+ p -> otg_caps .hnp_support = false;
104
+ p -> otg_caps .srp_support = false;
101
105
p -> host_rx_fifo_size = 288 ;
102
106
p -> host_nperio_tx_fifo_size = 128 ;
103
107
p -> host_perio_tx_fifo_size = 96 ;
@@ -111,7 +115,8 @@ static void dwc2_set_amlogic_params(struct dwc2_hsotg *hsotg)
111
115
{
112
116
struct dwc2_core_params * p = & hsotg -> params ;
113
117
114
- p -> otg_cap = DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE ;
118
+ p -> otg_caps .hnp_support = false;
119
+ p -> otg_caps .srp_support = false;
115
120
p -> speed = DWC2_SPEED_PARAM_HIGH ;
116
121
p -> host_rx_fifo_size = 512 ;
117
122
p -> host_nperio_tx_fifo_size = 500 ;
@@ -144,7 +149,8 @@ static void dwc2_set_stm32f4x9_fsotg_params(struct dwc2_hsotg *hsotg)
144
149
{
145
150
struct dwc2_core_params * p = & hsotg -> params ;
146
151
147
- p -> otg_cap = DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE ;
152
+ p -> otg_caps .hnp_support = false;
153
+ p -> otg_caps .srp_support = false;
148
154
p -> speed = DWC2_SPEED_PARAM_FULL ;
149
155
p -> host_rx_fifo_size = 128 ;
150
156
p -> host_nperio_tx_fifo_size = 96 ;
@@ -168,7 +174,8 @@ static void dwc2_set_stm32mp15_fsotg_params(struct dwc2_hsotg *hsotg)
168
174
{
169
175
struct dwc2_core_params * p = & hsotg -> params ;
170
176
171
- p -> otg_cap = DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE ;
177
+ p -> otg_caps .hnp_support = false;
178
+ p -> otg_caps .srp_support = false;
172
179
p -> speed = DWC2_SPEED_PARAM_FULL ;
173
180
p -> host_rx_fifo_size = 128 ;
174
181
p -> host_nperio_tx_fifo_size = 96 ;
@@ -188,7 +195,8 @@ static void dwc2_set_stm32mp15_hsotg_params(struct dwc2_hsotg *hsotg)
188
195
{
189
196
struct dwc2_core_params * p = & hsotg -> params ;
190
197
191
- p -> otg_cap = DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE ;
198
+ p -> otg_caps .hnp_support = false;
199
+ p -> otg_caps .srp_support = false;
192
200
p -> activate_stm_id_vb_detection = !device_property_read_bool (hsotg -> dev , "usb-role-switch" );
193
201
p -> host_rx_fifo_size = 440 ;
194
202
p -> host_nperio_tx_fifo_size = 256 ;
@@ -241,23 +249,22 @@ MODULE_DEVICE_TABLE(acpi, dwc2_acpi_match);
241
249
242
250
static void dwc2_set_param_otg_cap (struct dwc2_hsotg * hsotg )
243
251
{
244
- u8 val ;
245
-
246
252
switch (hsotg -> hw_params .op_mode ) {
247
253
case GHWCFG2_OP_MODE_HNP_SRP_CAPABLE :
248
- val = DWC2_CAP_PARAM_HNP_SRP_CAPABLE ;
254
+ hsotg -> params .otg_caps .hnp_support = true;
255
+ hsotg -> params .otg_caps .srp_support = true;
249
256
break ;
250
257
case GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE :
251
258
case GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE :
252
259
case GHWCFG2_OP_MODE_SRP_CAPABLE_HOST :
253
- val = DWC2_CAP_PARAM_SRP_ONLY_CAPABLE ;
260
+ hsotg -> params .otg_caps .hnp_support = false;
261
+ hsotg -> params .otg_caps .srp_support = true;
254
262
break ;
255
263
default :
256
- val = DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE ;
264
+ hsotg -> params .otg_caps .hnp_support = false;
265
+ hsotg -> params .otg_caps .srp_support = false;
257
266
break ;
258
267
}
259
-
260
- hsotg -> params .otg_cap = val ;
261
268
}
262
269
263
270
static void dwc2_set_param_phy_type (struct dwc2_hsotg * hsotg )
@@ -463,6 +470,8 @@ static void dwc2_get_device_properties(struct dwc2_hsotg *hsotg)
463
470
& p -> g_tx_fifo_size [1 ],
464
471
num );
465
472
}
473
+
474
+ of_usb_update_otg_caps (hsotg -> dev -> of_node , & p -> otg_caps );
466
475
}
467
476
468
477
if (of_find_property (hsotg -> dev -> of_node , "disable-over-current" , NULL ))
@@ -473,29 +482,27 @@ static void dwc2_check_param_otg_cap(struct dwc2_hsotg *hsotg)
473
482
{
474
483
int valid = 1 ;
475
484
476
- switch (hsotg -> params .otg_cap ) {
477
- case DWC2_CAP_PARAM_HNP_SRP_CAPABLE :
485
+ if (hsotg -> params .otg_caps . hnp_support && hsotg -> params . otg_caps . srp_support ) {
486
+ /* check HNP && SRP capable */
478
487
if (hsotg -> hw_params .op_mode != GHWCFG2_OP_MODE_HNP_SRP_CAPABLE )
479
488
valid = 0 ;
480
- break ;
481
- case DWC2_CAP_PARAM_SRP_ONLY_CAPABLE :
482
- switch (hsotg -> hw_params .op_mode ) {
483
- case GHWCFG2_OP_MODE_HNP_SRP_CAPABLE :
484
- case GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE :
485
- case GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE :
486
- case GHWCFG2_OP_MODE_SRP_CAPABLE_HOST :
487
- break ;
488
- default :
489
- valid = 0 ;
490
- break ;
489
+ } else if (!hsotg -> params .otg_caps .hnp_support ) {
490
+ /* check SRP only capable */
491
+ if (hsotg -> params .otg_caps .srp_support ) {
492
+ switch (hsotg -> hw_params .op_mode ) {
493
+ case GHWCFG2_OP_MODE_HNP_SRP_CAPABLE :
494
+ case GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE :
495
+ case GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE :
496
+ case GHWCFG2_OP_MODE_SRP_CAPABLE_HOST :
497
+ break ;
498
+ default :
499
+ valid = 0 ;
500
+ break ;
501
+ }
491
502
}
492
- break ;
493
- case DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE :
494
- /* always valid */
495
- break ;
496
- default :
503
+ /* else: NO HNP && NO SRP capable: always valid */
504
+ } else {
497
505
valid = 0 ;
498
- break ;
499
506
}
500
507
501
508
if (!valid )
0 commit comments