mtu3: fix setup packet response for HNP and SRP request
Subsystems (3)
PATCH 1/1 mtu3: fix setup packet response for HNP and SRP request
1. Add OTG_HNP_REQD and OTG_SRP_REQD definitions in ch9.h.
2. When OTG_HNP_REQD and OTG_SRP_REQD has been received,
usb hardware must not enter TEST mode but need to response setup packet.
3. Add otg_srp_reqd and otg_hnp_reqd in struct ssusb_mtk for futher implementation.
--- drivers/usb/mtu3/mtu3.h | 4 ++++ drivers/usb/mtu3/mtu3_gadget_ep0.c | 13 +++++++++++++ include/uapi/linux/usb/ch9.h | 5 +++++ 3 files changed, 22 insertions(+)
drivers/usb/mtu3/mtu3.h +4 -0
@@ -226,6 +226,8 @@ struct otg_switch_mtk {* @dma_clk: dma_bus_ck clock for AXI bus etc * @dr_mode: works in which mode: * host only, device only or dual-role mode +* @otg_srp_reqd: used for SRP request handling. +* @otg_hnp_reqd: used for HNP request handling. * @u2_ports: number of usb2.0 host ports * @u3_ports: number of usb3.0 host ports * @u3p_dis_msk: mask of disabling usb3 ports, for example, bit0==1 to
@@ -252,6 +254,8 @@ struct ssusb_mtk {/* otg */ struct otg_switch_mtk otg_switch;enum usb_dr_mode dr_mode; +bool otg_srp_reqd; +bool otg_hnp_reqd;bool is_host;int u2_ports;int u3_ports;
drivers/usb/mtu3/mtu3_gadget_ep0.c +13 -0
@@ -285,11 +285,24 @@ static int handle_test_mode(struct mtu3 *mtu, struct usb_ctrlrequest *setup)dev_dbg (mtu->dev,"TEST_PACKET\n" ); mtu->test_mode_nr =TEST_PACKET_MODE ;break ; +case OTG_SRP_REQD : +dev_dbg (mtu->dev,"OTG_SRP_REQD\n" ); + mtu->ssusb->otg_srp_reqd =1 ; +break ; +case OTG_HNP_REQD : +dev_dbg (mtu->dev,"OTG_HNP_REQD\n" ); + mtu->ssusb->otg_hnp_reqd =1 ; +break ;default : handled = -EINVAL ; goto out; } +if (mtu->ssusb->otg_srp_reqd || mtu->ssusb->otg_hnp_reqd) { + mtu->ep0_state =MU3D_EP0_STATE_SETUP ; + goto out; + } + mtu->test_mode = true;/* no TX completion interrupt, and need restart platform after test */
include/uapi/linux/usb/ch9.h +5 -0
@@ -143,6 +143,11 @@#define TEST_SE0_NAK 3#define TEST_PACKET 4#define TEST_FORCE_EN 5 +/* +* OTG HNP and SRP REQD +*/ +#define OTG_SRP_REQD 6 +#define OTG_HNP_REQD 7/* Status Type */ #define USB_STATUS_TYPE_STANDARD 0
Signature · 1 line
2.18.0
Chunfeng Yun
maintainerHi Macpaul,
Quoted 6 lines · Macpaul Lin
1. Add
OTG_HNP_REQDandOTG_SRP_REQDdefinitions inch9.h.
2. WhenOTG_HNP_REQDandOTG_SRP_REQDhas been received,
usb hardware must not enter TEST mode but need to response setup packet.
3. Addotg_srp_reqdandotg_hnp_reqdin structssusb_mtkfor futher implementation.
Quoted 6 lines
Signed-off-by Macpaul Lin <[email protected]>--- drivers/usb/mtu3/mtu3.h | 4 ++++ drivers/usb/mtu3/mtu3_gadget_ep0.c | 13 +++++++++++++ include/uapi/linux/usb/ch9.h | 5 +++++ 3 files changed, 22 insertions(+)
The driver currently doesn't support HNP/SRP, so there will be something wrong when connected with PET to run compliance test, and I prefer not to support it, because it's rarely used in normal case, thanks
Quoted 68 lines
drivers/usb/mtu3/mtu3.h +4
-0@@ -226,6 +226,8 @@ struct otg_switch_mtk {* @dma_clk: dma_bus_ck clock for AXI bus etc * @dr_mode: works in which mode: * host only, device only or dual-role mode +* @otg_srp_reqd: used for SRP request handling. +* @otg_hnp_reqd: used for HNP request handling. * @u2_ports: number of usb2.0 host ports * @u3_ports: number of usb3.0 host ports * @u3p_dis_msk: mask of disabling usb3 ports, for example, bit0==1 to @@ -252,6 +254,8 @@ struct ssusb_mtk {/* otg */ struct otg_switch_mtk otg_switch;enum usb_dr_mode dr_mode; +bool otg_srp_reqd; +bool otg_hnp_reqd;bool is_host;int u2_ports;int u3_ports;drivers/usb/mtu3/mtu3_gadget_ep0.c +13
-0@@ -285,11 +285,24 @@ static int handle_test_mode(struct mtu3 *mtu, struct usb_ctrlrequest *setup)dev_dbg (mtu->dev,"TEST_PACKET\n" ); mtu->test_mode_nr =TEST_PACKET_MODE ;break ; +case OTG_SRP_REQD : +dev_dbg (mtu->dev,"OTG_SRP_REQD\n" ); + mtu->ssusb->otg_srp_reqd =1 ; +break ; +case OTG_HNP_REQD : +dev_dbg (mtu->dev,"OTG_HNP_REQD\n" ); + mtu->ssusb->otg_hnp_reqd =1 ; +break ;default : handled = -EINVAL ; goto out; } +if (mtu->ssusb->otg_srp_reqd || mtu->ssusb->otg_hnp_reqd) { + mtu->ep0_state =MU3D_EP0_STATE_SETUP ; + goto out; + } + mtu->test_mode = true;/* no TX completion interrupt, and need restart platform after test */ include/uapi/linux/usb/ch9.h +5
-0@@ -143,6 +143,11 @@#define TEST_SE0_NAK 3#define TEST_PACKET 4#define TEST_FORCE_EN 5 +/* +* OTG HNP and SRP REQD +*/ +#define OTG_SRP_REQD 6 +#define OTG_HNP_REQD 7/* Status Type */ #define USB_STATUS_TYPE_STANDARD 0