Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'usb-6.11-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB fixes from Greg KH:
"Here are a handful of small USB fixes for 6.11-rc7. Included in here
are:

- dwc3 driver fixes for two reported problems

- two typec ucsi driver fixes

- cdns2 controller reset fix

All of these have been in linux-next this week with no reported
problems"

* tag 'usb-6.11-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
usb: typec: ucsi: Fix cable registration
usb: typec: ucsi: Fix the partner PD revision
usb: cdns2: Fix controller reset issue
usb: dwc3: core: update LC timer as per USB Spec V3.2
usb: dwc3: Avoid waking up gadget during startxfer

+87 -73
+15
drivers/usb/dwc3/core.c
··· 1387 1387 } 1388 1388 1389 1389 /* 1390 + * STAR 9001285599: This issue affects DWC_usb3 version 3.20a 1391 + * only. If the PM TIMER ECM is enabled through GUCTL2[19], the 1392 + * link compliance test (TD7.21) may fail. If the ECN is not 1393 + * enabled (GUCTL2[19] = 0), the controller will use the old timer 1394 + * value (5us), which is still acceptable for the link compliance 1395 + * test. Therefore, do not enable PM TIMER ECM in 3.20a by 1396 + * setting GUCTL2[19] by default; instead, use GUCTL2[19] = 0. 1397 + */ 1398 + if (DWC3_VER_IS(DWC3, 320A)) { 1399 + reg = dwc3_readl(dwc->regs, DWC3_GUCTL2); 1400 + reg &= ~DWC3_GUCTL2_LC_TIMER; 1401 + dwc3_writel(dwc->regs, DWC3_GUCTL2, reg); 1402 + } 1403 + 1404 + /* 1390 1405 * When configured in HOST mode, after issuing U3/L2 exit controller 1391 1406 * fails to send proper CRC checksum in CRC5 feild. Because of this 1392 1407 * behaviour Transaction Error is generated, resulting in reset and
+2
drivers/usb/dwc3/core.h
··· 421 421 422 422 /* Global User Control Register 2 */ 423 423 #define DWC3_GUCTL2_RST_ACTBITLATER BIT(14) 424 + #define DWC3_GUCTL2_LC_TIMER BIT(19) 424 425 425 426 /* Global User Control Register 3 */ 426 427 #define DWC3_GUCTL3_SPLITDISABLE BIT(14) ··· 1270 1269 #define DWC3_REVISION_290A 0x5533290a 1271 1270 #define DWC3_REVISION_300A 0x5533300a 1272 1271 #define DWC3_REVISION_310A 0x5533310a 1272 + #define DWC3_REVISION_320A 0x5533320a 1273 1273 #define DWC3_REVISION_330A 0x5533330a 1274 1274 1275 1275 #define DWC31_REVISION_ANY 0x0
+17 -24
drivers/usb/dwc3/gadget.c
··· 287 287 * 288 288 * Caller should handle locking. This function will issue @cmd with given 289 289 * @params to @dep and wait for its completion. 290 + * 291 + * According to the programming guide, if the link state is in L1/L2/U3, 292 + * then sending the Start Transfer command may not complete. The 293 + * programming guide suggested to bring the link state back to ON/U0 by 294 + * performing remote wakeup prior to sending the command. However, don't 295 + * initiate remote wakeup when the user/function does not send wakeup 296 + * request via wakeup ops. Send the command when it's allowed. 297 + * 298 + * Notes: 299 + * For L1 link state, issuing a command requires the clearing of 300 + * GUSB2PHYCFG.SUSPENDUSB2, which turns on the signal required to complete 301 + * the given command (usually within 50us). This should happen within the 302 + * command timeout set by driver. No additional step is needed. 303 + * 304 + * For L2 or U3 link state, the gadget is in USB suspend. Care should be 305 + * taken when sending Start Transfer command to ensure that it's done after 306 + * USB resume. 290 307 */ 291 308 int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd, 292 309 struct dwc3_gadget_ep_cmd_params *params) ··· 342 325 343 326 if (saved_config) 344 327 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); 345 - } 346 - 347 - if (DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_STARTTRANSFER) { 348 - int link_state; 349 - 350 - /* 351 - * Initiate remote wakeup if the link state is in U3 when 352 - * operating in SS/SSP or L1/L2 when operating in HS/FS. If the 353 - * link state is in U1/U2, no remote wakeup is needed. The Start 354 - * Transfer command will initiate the link recovery. 355 - */ 356 - link_state = dwc3_gadget_get_link_state(dwc); 357 - switch (link_state) { 358 - case DWC3_LINK_STATE_U2: 359 - if (dwc->gadget->speed >= USB_SPEED_SUPER) 360 - break; 361 - 362 - fallthrough; 363 - case DWC3_LINK_STATE_U3: 364 - ret = __dwc3_gadget_wakeup(dwc, false); 365 - dev_WARN_ONCE(dwc->dev, ret, "wakeup failed --> %d\n", 366 - ret); 367 - break; 368 - } 369 328 } 370 329 371 330 /*
+3 -9
drivers/usb/gadget/udc/cdns2/cdns2-gadget.c
··· 2251 2251 { 2252 2252 u32 max_speed; 2253 2253 void *buf; 2254 - int val; 2255 2254 int ret; 2256 2255 2257 2256 pdev->usb_regs = pdev->regs; ··· 2260 2261 pdev->adma_regs = pdev->regs + CDNS2_ADMA_REGS_OFFSET; 2261 2262 2262 2263 /* Reset controller. */ 2263 - set_reg_bit_8(&pdev->usb_regs->cpuctrl, CPUCTRL_SW_RST); 2264 - 2265 - ret = readl_poll_timeout_atomic(&pdev->usb_regs->cpuctrl, val, 2266 - !(val & CPUCTRL_SW_RST), 1, 10000); 2267 - if (ret) { 2268 - dev_err(pdev->dev, "Error: reset controller timeout\n"); 2269 - return -EINVAL; 2270 - } 2264 + writeb(CPUCTRL_SW_RST | CPUCTRL_UPCLK | CPUCTRL_WUEN, 2265 + &pdev->usb_regs->cpuctrl); 2266 + usleep_range(5, 10); 2271 2267 2272 2268 usb_initialize_gadget(pdev->dev, &pdev->gadget, NULL); 2273 2269
+9
drivers/usb/gadget/udc/cdns2/cdns2-gadget.h
··· 292 292 #define SPEEDCTRL_HSDISABLE BIT(7) 293 293 294 294 /* CPUCTRL- bitmasks. */ 295 + /* UP clock enable */ 296 + #define CPUCTRL_UPCLK BIT(0) 295 297 /* Controller reset bit. */ 296 298 #define CPUCTRL_SW_RST BIT(1) 299 + /** 300 + * If the wuen bit is ‘1’, the upclken is automatically set to ‘1’ after 301 + * detecting rising edge of wuintereq interrupt. If the wuen bit is ‘0’, 302 + * the wuintereq interrupt is ignored. 303 + */ 304 + #define CPUCTRL_WUEN BIT(7) 305 + 297 306 298 307 /** 299 308 * struct cdns2_adma_regs - ADMA controller registers.
+41 -39
drivers/usb/typec/ucsi/ucsi.c
··· 965 965 966 966 static int ucsi_register_cable(struct ucsi_connector *con) 967 967 { 968 + struct ucsi_cable_property cable_prop; 968 969 struct typec_cable *cable; 969 970 struct typec_cable_desc desc = {}; 971 + u64 command; 972 + int ret; 970 973 971 - switch (UCSI_CABLE_PROP_FLAG_PLUG_TYPE(con->cable_prop.flags)) { 974 + command = UCSI_GET_CABLE_PROPERTY | UCSI_CONNECTOR_NUMBER(con->num); 975 + ret = ucsi_send_command(con->ucsi, command, &cable_prop, sizeof(cable_prop)); 976 + if (ret < 0) { 977 + dev_err(con->ucsi->dev, "GET_CABLE_PROPERTY failed (%d)\n", ret); 978 + return ret; 979 + } 980 + 981 + switch (UCSI_CABLE_PROP_FLAG_PLUG_TYPE(cable_prop.flags)) { 972 982 case UCSI_CABLE_PROPERTY_PLUG_TYPE_A: 973 983 desc.type = USB_PLUG_TYPE_A; 974 984 break; ··· 994 984 } 995 985 996 986 desc.identity = &con->cable_identity; 997 - desc.active = !!(UCSI_CABLE_PROP_FLAG_ACTIVE_CABLE & 998 - con->cable_prop.flags); 999 - desc.pd_revision = UCSI_CABLE_PROP_FLAG_PD_MAJOR_REV_AS_BCD( 1000 - con->cable_prop.flags); 987 + desc.active = !!(UCSI_CABLE_PROP_FLAG_ACTIVE_CABLE & cable_prop.flags); 988 + 989 + if (con->ucsi->version >= UCSI_VERSION_2_1) 990 + desc.pd_revision = UCSI_CABLE_PROP_FLAG_PD_MAJOR_REV_AS_BCD(cable_prop.flags); 1001 991 1002 992 cable = typec_register_cable(con->port, &desc); 1003 993 if (IS_ERR(cable)) { ··· 1022 1012 con->cable = NULL; 1023 1013 } 1024 1014 1015 + static int ucsi_check_connector_capability(struct ucsi_connector *con) 1016 + { 1017 + u64 command; 1018 + int ret; 1019 + 1020 + if (!con->partner || con->ucsi->version < UCSI_VERSION_2_1) 1021 + return 0; 1022 + 1023 + command = UCSI_GET_CONNECTOR_CAPABILITY | UCSI_CONNECTOR_NUMBER(con->num); 1024 + ret = ucsi_send_command(con->ucsi, command, &con->cap, sizeof(con->cap)); 1025 + if (ret < 0) { 1026 + dev_err(con->ucsi->dev, "GET_CONNECTOR_CAPABILITY failed (%d)\n", ret); 1027 + return ret; 1028 + } 1029 + 1030 + typec_partner_set_pd_revision(con->partner, 1031 + UCSI_CONCAP_FLAG_PARTNER_PD_MAJOR_REV_AS_BCD(con->cap.flags)); 1032 + 1033 + return ret; 1034 + } 1035 + 1025 1036 static void ucsi_pwr_opmode_change(struct ucsi_connector *con) 1026 1037 { 1027 1038 switch (UCSI_CONSTAT_PWR_OPMODE(con->status.flags)) { ··· 1052 1021 ucsi_partner_task(con, ucsi_get_src_pdos, 30, 0); 1053 1022 ucsi_partner_task(con, ucsi_check_altmodes, 30, HZ); 1054 1023 ucsi_partner_task(con, ucsi_register_partner_pdos, 1, HZ); 1024 + ucsi_partner_task(con, ucsi_check_connector_capability, 1, HZ); 1055 1025 break; 1056 1026 case UCSI_CONSTAT_PWR_OPMODE_TYPEC1_5: 1057 1027 con->rdo = 0; ··· 1096 1064 1097 1065 desc.identity = &con->partner_identity; 1098 1066 desc.usb_pd = pwr_opmode == UCSI_CONSTAT_PWR_OPMODE_PD; 1099 - desc.pd_revision = UCSI_CONCAP_FLAG_PARTNER_PD_MAJOR_REV_AS_BCD(con->cap.flags); 1100 1067 1101 1068 partner = typec_register_partner(con->port, &desc); 1102 1069 if (IS_ERR(partner)) { ··· 1172 1141 con->num, u_role); 1173 1142 } 1174 1143 1175 - static int ucsi_check_connector_capability(struct ucsi_connector *con) 1176 - { 1177 - u64 command; 1178 - int ret; 1179 - 1180 - if (!con->partner || con->ucsi->version < UCSI_VERSION_2_0) 1181 - return 0; 1182 - 1183 - command = UCSI_GET_CONNECTOR_CAPABILITY | UCSI_CONNECTOR_NUMBER(con->num); 1184 - ret = ucsi_send_command(con->ucsi, command, &con->cap, sizeof(con->cap)); 1185 - if (ret < 0) { 1186 - dev_err(con->ucsi->dev, "GET_CONNECTOR_CAPABILITY failed (%d)\n", ret); 1187 - return ret; 1188 - } 1189 - 1190 - typec_partner_set_pd_revision(con->partner, 1191 - UCSI_CONCAP_FLAG_PARTNER_PD_MAJOR_REV_AS_BCD(con->cap.flags)); 1192 - 1193 - return ret; 1194 - } 1195 - 1196 1144 static int ucsi_check_connection(struct ucsi_connector *con) 1197 1145 { 1198 1146 u8 prev_flags = con->status.flags; ··· 1203 1193 1204 1194 static int ucsi_check_cable(struct ucsi_connector *con) 1205 1195 { 1206 - u64 command; 1207 1196 int ret, num_plug_am; 1208 1197 1209 1198 if (con->cable) 1210 1199 return 0; 1211 - 1212 - command = UCSI_GET_CABLE_PROPERTY | UCSI_CONNECTOR_NUMBER(con->num); 1213 - ret = ucsi_send_command(con->ucsi, command, &con->cable_prop, 1214 - sizeof(con->cable_prop)); 1215 - if (ret < 0) { 1216 - dev_err(con->ucsi->dev, "GET_CABLE_PROPERTY failed (%d)\n", 1217 - ret); 1218 - return ret; 1219 - } 1220 1200 1221 1201 ret = ucsi_register_cable(con); 1222 1202 if (ret < 0) ··· 1283 1283 if (con->status.flags & UCSI_CONSTAT_CONNECTED) { 1284 1284 ucsi_register_partner(con); 1285 1285 ucsi_partner_task(con, ucsi_check_connection, 1, HZ); 1286 - ucsi_partner_task(con, ucsi_check_connector_capability, 1, HZ); 1287 1286 if (con->ucsi->cap.features & UCSI_CAP_GET_PD_MESSAGE) 1288 1287 ucsi_partner_task(con, ucsi_get_partner_identity, 1, HZ); 1289 1288 if (con->ucsi->cap.features & UCSI_CAP_CABLE_DETAILS) 1290 1289 ucsi_partner_task(con, ucsi_check_cable, 1, HZ); 1291 1290 1292 1291 if (UCSI_CONSTAT_PWR_OPMODE(con->status.flags) == 1293 - UCSI_CONSTAT_PWR_OPMODE_PD) 1292 + UCSI_CONSTAT_PWR_OPMODE_PD) { 1294 1293 ucsi_partner_task(con, ucsi_register_partner_pdos, 1, HZ); 1294 + ucsi_partner_task(con, ucsi_check_connector_capability, 1, HZ); 1295 + } 1295 1296 } else { 1296 1297 ucsi_unregister_partner(con); 1297 1298 } ··· 1707 1706 ucsi_register_device_pdos(con); 1708 1707 ucsi_get_src_pdos(con); 1709 1708 ucsi_check_altmodes(con); 1709 + ucsi_check_connector_capability(con); 1710 1710 } 1711 1711 1712 1712 trace_ucsi_register_port(con->num, &con->status);
-1
drivers/usb/typec/ucsi/ucsi.h
··· 465 465 466 466 struct ucsi_connector_status status; 467 467 struct ucsi_connector_capability cap; 468 - struct ucsi_cable_property cable_prop; 469 468 struct power_supply *psy; 470 469 struct power_supply_desc psy_desc; 471 470 u32 rdo;