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.

usb: mtu3: support function remote wakeup

Add function wake notification to support function remote wakeup,
currently assume the composite device only enable function wake
for the first interface.

Forward request to function driver when the recipient is an interface,
including:
GetStatus() request to the first interface in a function returns the
information about 'function remote wakeup' and 'function remote wakeup
capalbe';
SetFeature request of FUNCTION_SUSPEND to an interface recipient, the
controller driver saves the suspend option;

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/20220708071903.25752-5-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Chunfeng Yun and committed by
Greg Kroah-Hartman
1742b765 683ff6e4

+38 -4
+18
drivers/usb/mtu3/mtu3_gadget.c
··· 433 433 return (int)mtu3_readl(mtu->mac_base, U3D_USB20_FRAME_NUM); 434 434 } 435 435 436 + static void function_wake_notif(struct mtu3 *mtu, u8 intf) 437 + { 438 + mtu3_writel(mtu->mac_base, U3D_DEV_NOTIF_0, 439 + TYPE_FUNCTION_WAKE | DEV_NOTIF_VAL_FW(intf)); 440 + mtu3_setbits(mtu->mac_base, U3D_DEV_NOTIF_0, SEND_DEV_NOTIF); 441 + } 442 + 436 443 static int mtu3_gadget_wakeup(struct usb_gadget *gadget) 437 444 { 438 445 struct mtu3 *mtu = gadget_to_mtu3(gadget); ··· 453 446 454 447 spin_lock_irqsave(&mtu->lock, flags); 455 448 if (mtu->g.speed >= USB_SPEED_SUPER) { 449 + /* 450 + * class driver may do function wakeup even UFP is in U0, 451 + * and UX_EXIT only takes effect in U1/U2/U3; 452 + */ 456 453 mtu3_setbits(mtu->mac_base, U3D_LINK_POWER_CONTROL, UX_EXIT); 454 + /* 455 + * Assume there's only one function on the composite device 456 + * and enable remote wake for the first interface. 457 + * FIXME if the IAD (interface association descriptor) shows 458 + * there is more than one function. 459 + */ 460 + function_wake_notif(mtu, 0); 457 461 } else { 458 462 mtu3_setbits(mtu->mac_base, U3D_POWER_MANAGEMENT, RESUME); 459 463 spin_unlock_irqrestore(&mtu->lock, flags);
+4 -4
drivers/usb/mtu3/mtu3_gadget_ep0.c
··· 226 226 227 227 break; 228 228 case USB_RECIP_INTERFACE: 229 + /* status of function remote wakeup, forward request */ 230 + handled = 0; 229 231 break; 230 232 case USB_RECIP_ENDPOINT: 231 233 epnum = (u8) le16_to_cpu(setup->wIndex); ··· 399 397 /* superspeed only */ 400 398 if (value == USB_INTRF_FUNC_SUSPEND && 401 399 mtu->g.speed >= USB_SPEED_SUPER) { 402 - /* 403 - * forward the request because function drivers 404 - * should handle it 405 - */ 400 + /* forward the request for function suspend */ 401 + mtu->may_wakeup = !!(index & USB_INTRF_FUNC_SUSPEND_RW); 406 402 handled = 0; 407 403 } 408 404 break;
+16
drivers/usb/mtu3/mtu3_hw_regs.h
··· 341 341 #define U3D_LINK_UX_INACT_TIMER (SSUSB_USB3_SYS_CSR_BASE + 0x020C) 342 342 #define U3D_LINK_POWER_CONTROL (SSUSB_USB3_SYS_CSR_BASE + 0x0210) 343 343 #define U3D_LINK_ERR_COUNT (SSUSB_USB3_SYS_CSR_BASE + 0x0214) 344 + #define U3D_DEV_NOTIF_0 (SSUSB_USB3_SYS_CSR_BASE + 0x0290) 345 + #define U3D_DEV_NOTIF_1 (SSUSB_USB3_SYS_CSR_BASE + 0x0294) 344 346 345 347 /*---------------- SSUSB_USB3_SYS_CSR FIELD DEFINITION ----------------*/ 346 348 ··· 366 364 /* U3D_LINK_ERR_COUNT */ 367 365 #define CLR_LINK_ERR_CNT BIT(16) 368 366 #define LINK_ERROR_COUNT GENMASK(15, 0) 367 + 368 + /* U3D_DEV_NOTIF_0 */ 369 + #define DEV_NOTIF_TYPE_SPECIFIC_LOW_MSK GENMASK(31, 8) 370 + #define DEV_NOTIF_VAL_FW(x) (((x) & 0xff) << 8) 371 + #define DEV_NOTIF_VAL_LTM(x) (((x) & 0xfff) << 8) 372 + #define DEV_NOTIF_VAL_IAM(x) (((x) & 0xffff) << 8) 373 + #define DEV_NOTIF_TYPE_MSK GENMASK(7, 4) 374 + /* Notification Type */ 375 + #define TYPE_FUNCTION_WAKE (0x1 << 4) 376 + #define TYPE_LATENCY_TOLERANCE_MESSAGE (0x2 << 4) 377 + #define TYPE_BUS_INTERVAL_ADJUST_MESSAGE (0x3 << 4) 378 + #define TYPE_HOST_ROLE_REQUEST (0x4 << 4) 379 + #define TYPE_SUBLINK_SPEED (0x5 << 4) 380 + #define SEND_DEV_NOTIF BIT(0) 369 381 370 382 /*---------------- SSUSB_USB2_CSR REGISTER DEFINITION ----------------*/ 371 383