USB: chipidea misc patches
Subsystems (4)
cover USB: chipidea misc patches
Hi all,
In this series, I add several new interfaces for chipidea driver, they are mainly for system configuration adjustment. The USB performance may be improved with these configuration changing, but each vendor driver owner needs to consult with your IC owner which configuration parameters are suitable for your system before changing it, and only change it if necessary.
The other changes are for imx, it shows how imx uses these interfaces. Shawn, the patch [5/10] and [9/10] are dts changes, help to review it please.
Peter Chen (10):
usb: chipidea: udc: zero-length packet is only needed for TX
usb: chipidea: define stream mode disable for both roles
usb: chipidea: imx: add stream mode enable for device mode at
imx6sl/imx6sx
Doc: usb: ci-hdrc-usb2: add ahb-burst-config for binding doc
ARM: imx6: set ahb-burst-config as 0 for USB
usb: chipidea: add ahb burst configuration interface
usb: chipidea: usbmisc_imx: add unburst setting for imx6
Doc: usb: ci-hdrc-usb2: add tx(rx)-burst-config-dword for binding doc
ARM: imx6: change default burst size for USB
usb: chipidea: add tx/rx burst size configuration interface
.../devicetree/bindings/usb/ci-hdrc-usb2.txt | 10 ++++ arch/arm/boot/dts/imx6qdl.dtsi | 12 +++++ arch/arm/boot/dts/imx6sl.dtsi | 9 ++++ arch/arm/boot/dts/imx6sx.dtsi | 9 ++++ drivers/usb/chipidea/bits.h | 7 +++ drivers/usb/chipidea/ci.h | 1 + drivers/usb/chipidea/ci_hdrc_imx.c | 16 +++--- drivers/usb/chipidea/core.c | 62 +++++++++++++++++++++- drivers/usb/chipidea/udc.c | 2 +- drivers/usb/chipidea/usbmisc_imx.c | 12 ++++- include/linux/usb/chipidea.h | 11 +++- 11 files changed, 140 insertions(+), 11 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/10 usb: chipidea: udc: zero-length packet is only needed for TX
The zero-length packet is the sendor tells the receiver that there is no more data, so it is only needed at the TX side.
--- drivers/usb/chipidea/udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/chipidea/udc.c +1 -1
@@ -445,7 +445,7 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq) rest -= count; } -if (hwreq->req.zero && hwreq->req.length +if (hwreq->req.zero && hwreq->req.length && hwep->dir ==TX && (hwreq->req.length % hwep->ep.maxpacket ==0 ))add_td_to_list (hwep, hwreq,0 );
Signature · 1 line
1.9.1
PATCH 2/10 usb: chipidea: define stream mode disable for both roles
In reply to Peter ChenThe system bus and chipidea IP have different limitations for both host and device mode.
For example, with below errata, we need to enable SDIS(Stream Disable Mode) at host mode. But we don't want it for device mode at the same system.
TAR 9000378958
Title: Non-Double Word Aligned Buffer Address Sometimes Causes Host to Hang on OUT Retry
Impacted Configuration: Host mode, all transfer types
Description:
The host core operating in streaming mode may under run while sending the data packet of an OUT transaction. This under run can occur if there are unexpected system delays in fetching the remaining packet data from memory. The host forces a bad CRC on the packet, the device detects the error and discards the packet. The host then retries a Bulk, Interrupt, or Control transfer if an under run occurs according to the USB specification. During simulations, it was found that the host does not issue the retry of the failed bulk OUT. It does not issue any other transactions except SOF packets that have incorrect frame numbers.
The second failure mode occurs if the under run occurs on an ISO OUT transaction and the next ISO transaction is a zero byte packet. The host does not issue any transactions (including SOFs). The device detects a Suspend condition, reverts to full speed, and waits for resume signaling.
A third failure mode occurs when the host under runs on an ISO OUT and the next ISO in the schedule is an ISO OUT with two max packets of 1024 bytes each.
The host should issue MDATA for the first OUT followed by DATA1 for the second. However, it drops the MDATA transaction, and issues the DATA1 transaction.
The system impact of this bug is the same regardless of the failure mode observed. The host core hangs, the ehci_ctrl state machine waits for the protocol engine to send the completion status for the corrupted transaction, which never occurs. No indication is sent to the host controller driver, no register bits change and no interrupts occur. Eventually the requesting application times out. Detailed internal behavior:
The EHCI control state machine (ehci_ctrl) in the DMA block is responsible for parsing the schedules and initiating all transactions. The ehci_ctrl state machine passes the transaction details to the protocol block by writing the transaction information in to the TxFIFO. It then asserts the pe_hst_run_pkt signal to inform the host protocol state machine (pe_hst_state) that there is a packet in the TxFIFO. A tag of 0x0 indicates a start of packet with the data providing the following information:
35:32 Tag
31:30 Reserved
29:23 Endpoint (lowest 4 bits)
22:16 Address
15:10 Reserved
9:8 Endpoint speed
7:6 Endpoint type
5:6 Data Toggle
3:0 PID
The pe_hst_state reads the packet information and constructs the packet and issues it to the PHY interface.
The ehci_ctrl state machine writes the start transaction information in to the TxFIFO as 0x03002910c for the OUT packet that had the under run error. However, it writes 0xC3002910C for the retry of the Out transaction, which is incorrect.
The pe_hst_state enters a bus timeout state after sending the bad CRC for the packet that under ran. It then purges any data that was back filled in to the TxFIFO for the packet that under ran. The pe_hst_state machine stops purging the TxFIFO when it is empty or if it reads a location that has a tag of 0x0, indicating a start of packet command.
The pe_hst_state reads 0xC3002910C and discards it as it does not decode to a start of packet command. It continues to purge the OUT data that has been pre-buffered for the OUT retry . The pe_hst_state detects the hst_packet_run signal and attempts to read the PID and address information from the TxFIFO. This location has packet data and so does not decode to a valid PID and so falls through to the PE_HST_SOF_LOAD state where the frame_num_counter is updated. The frame_num_counter is updated with the data in the TxFIFO. In this case, the data is incorrect as the ehci_ctrl state machine did not initiate the load. The hst_pe_state machine detects the SOF request signal and sends an SOF with the bad frame number. Meanwhile, the ehci_ctrl state machine waits indefinitely in the run_pkt state waiting for the completion status from pe_hst_state machine, which will never happen. The ISO failure case is similar except that there is no retry for ISO. The ehci_ctrl state machine moves to the next transfer in the periodic schedule. If the under run occurs on the last entry of the periodic list then it moves to the Async schedule.
In the case of ISO OUT simulations, the next ISO is a zero byte OUT and again the start of packet command gets corrupted. The TxFIFO is empty when the hst_pe_state attempts to read the Address and PID information as the transaction is a zero byte packet. This results in the hst_pe_state machine staying in the GET_PID state, which means that it does not issue any transactions (including SOFs). The device detects a Suspend condition and reverts to full speed mode and waits for a Resume or Reset signal.
The EHCI specification allows a Non-DoubleWord (32 bits) offset to be used as a current offset for Buffer Pointer Page 0 of the qTD. In Non-DoubleWord aligned cases, the core reads the packet data from the AHB memory, performs the alignment operation before writing it in to the TxFIFO as a 32 bit data word. An End Of Packet tag (EOP) is written to the TxFIFO after all the packet data has been written in to the TxFIFO. The alignment function is reset to Idle by the EOP tag. The corruption of the start of packet command arises because the packet buffer for the OUT transaction that under ran is not aligned to a DoubleWord, and hence no EOP tag is written to the TxFIFO. The alignment function is still active when the start packet information is written in to the TxFIFO for the retry of the bulk packet or for the next transaction in the case of an under run on an ISO. This results in the corruption of the start tag and the transaction information. Click for waveform showing the command 0x 0000300291 being written in to the TX FIFO for the Out that under ran.
Click for waveform showing the command 0xC3002910C written to the TxFIFO instead of 0x 0000300291
Versions affected: Versions 2.10a and previous versions
How discovered: Customer simulation
Workaround:
1- The EHCI specification allows a non-DoubleWord offset to be used as a current offset for Buffer Pointer Page 0 of the qTD. However, if a DoubleWord offset is used then this issue does not arise.
2- Use non streaming mode to eliminate under runs.
Resolution:
The fix involves changes to the traffic state machine in the vusb_hs_dma_traf block. The ehci_ctrl state machine updates the context information by encoding the transaction results on the hst_op_context_update signals at the end of a transaction. The signal hst_op_context_update is added to the traffic state machine, and the tx_fifo_under_ran_r signal is generated if the transaction results in an under run error. Click for waveform
The traffic state machine then traverses to the do_eop states if the tx_fifo_under_ran error is asserted. Thus an EOP tag is written in to the TxFIFO as shown in this waveform .
The EOP tag resets the align state machine to the Idle state ensuring that the next command written by the echi_ctrl state machine does not get corrupted.
File(s) modified:
RTL code fixed: ?..
Method of reproducing: This failure cannot be reproduced in the current test bench.
Date Found: March 2010
Date Fixed: June 2010
Update information:
Added the RTL code fix
--- drivers/usb/chipidea/core.c | 13 ++++++++++++- include/linux/usb/chipidea.h | 5 ++++- 2 files changed, 16 insertions(+), 2 deletions(-)
drivers/usb/chipidea/core.c +12 -1
@@ -64,6 +64,7 @@#include <linux/of.h> #include <linux/phy.h> #include <linux/regulator/consumer.h> +#include <linux/usb/ehci_def.h> #include "ci.h" #include "udc.h"
@@ -413,7 +414,17 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)*/ void ci_platform_configure (struct ci_hdrc *ci) { -if (ci->platdata->flags &CI_HDRC_DISABLE_STREAMING ) +bool is_device_mode, is_host_mode; + + is_device_mode =hw_read (ci,OP_USBMODE ,USBMODE_CM ) ==USBMODE_CM_DC ; + is_host_mode =hw_read (ci,OP_USBMODE ,USBMODE_CM ) ==USBMODE_CM_HC ; + +if (is_device_mode && + (ci->platdata->flags &CI_HDRC_DISABLE_DEVICE_STREAMING )) +hw_write (ci,OP_USBMODE ,USBMODE_CI_SDIS ,USBMODE_CI_SDIS ); + +if (is_host_mode && + (ci->platdata->flags &CI_HDRC_DISABLE_HOST_STREAMING ))hw_write (ci,OP_USBMODE ,USBMODE_CI_SDIS ,USBMODE_CI_SDIS );if (ci->platdata->flags &CI_HDRC_FORCE_FULLSPEED ) {
include/linux/usb/chipidea.h +4 -1
@@ -20,7 +20,6 @@ struct ci_hdrc_platform_data {unsigned long flags;#define CI_HDRC_REGS_SHARED BIT(0)#define CI_HDRC_SUPPORTS_RUNTIME_PM BIT(2) -#define CI_HDRC_DISABLE_STREAMING BIT(3)/* * Only set it when DCCPARAMS.DC==1 and DCCPARAMS.HC==1, * but otg is not supported (no register otgsc).
@@ -30,6 +29,10 @@ struct ci_hdrc_platform_data {#define CI_HDRC_FORCE_FULLSPEED BIT(6)#define CI_HDRC_TURN_VBUS_EARLY_ON BIT(7)#define CI_HDRC_SET_NON_ZERO_TTHA BIT(8) +#define CI_HDRC_DISABLE_DEVICE_STREAMING BIT(9) +#define CI_HDRC_DISABLE_HOST_STREAMING BIT(10) +#define CI_HDRC_DISABLE_STREAMING (CI_HDRC_DISABLE_DEVICE_STREAMING | \ + CI_HDRC_DISABLE_HOST_STREAMING)enum usb_dr_mode dr_mode;#define CI_HDRC_CONTROLLER_RESET_EVENT 0#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1
Signature · 1 line
1.9.1
Greg KH
maintainerPATCH 2/10 usb: chipidea: define stream mode disable for both roles
Quoted 10 lines · Peter Chen
The system bus and chipidea IP have different limitations for both host and device mode.
For example, with below errata, we need to enable SDIS(Stream Disable Mode) at host mode. But we don't want it for device mode at the same system.TAR 9000378958
Title: Non-Double Word Aligned Buffer Address Sometimes Causes Host to Hang on OUT Retry
Impacted Configuration: Host mode, all transfer types
Description:
The host core operating in streaming mode may under run while sending the data packet of an OUT transaction. This under run can occur if there are unexpected system delays in fetching the remaining packet data from memory. The host forces a bad CRC on the packet, the device detects the error and discards the packet. The host then retries a Bulk, Interrupt, or Control transfer if an under run occurs according to the USB specification.
<snip>
Properly format this huge wall of text please, don't commit this as-is.
thanks,
greg k-h
PATCH 2/10 usb: chipidea: define stream mode disable for both roles
Quoted 12 lines · Greg KH
Quoted 10 lines · Peter Chen
The system bus and chipidea IP have different limitations for both host and device mode.
For example, with below errata, we need to enable SDIS(Stream Disable Mode) at host mode. But we don't want it for device mode at the same system.TAR 9000378958
Title: Non-Double Word Aligned Buffer Address Sometimes Causes Host to Hang on OUT Retry
Impacted Configuration: Host mode, all transfer types
Description:
The host core operating in streaming mode may under run while sending the data packet of an OUT transaction. This under run can occur if there are unexpected system delays in fetching the remaining packet data from memory. The host forces a bad CRC on the packet, the device detects the error and discards the packet. The host then retries a Bulk, Interrupt, or Control transfer if an under run occurs according to the USB specification.
Quoted 4 lines
<snip>
Properly format this huge wall of text please, don't commit this as-is.
Thanks, I will
Signature · 2 lines
Best Regards, Peter Chen
PATCH 2/10 usb: chipidea: define stream mode disable for both roles
In reply to Peter Cheninclude/linux/usb/chipidea.h struct ci_hdrc_platform_data { · line 23
Quoted 5 lines · Peter Chen
include/linux/usb/chipidea.h +0
-1@@ -20,7 +20,6 @@ struct ci_hdrc_platform_data {unsigned long flags;#define CI_HDRC_REGS_SHARED BIT(0)#define CI_HDRC_SUPPORTS_RUNTIME_PM BIT(2) -#define CI_HDRC_DISABLE_STREAMING BIT(3)
Why not just rename this one, now you have a "hole" in your bit field that people aren't going to know if they can use or not.
thanks,
greg k-h
PATCH 2/10 usb: chipidea: define stream mode disable for both roles
Quoted 10 lines · Greg KH
include/linux/usb/chipidea.h struct ci_hdrc_platform_data { · line 23
Quoted 5 lines · Peter Chen
include/linux/usb/chipidea.h +0
-1@@ -20,7 +20,6 @@ struct ci_hdrc_platform_data {unsigned long flags;#define CI_HDRC_REGS_SHARED BIT(0)#define CI_HDRC_SUPPORTS_RUNTIME_PM BIT(2) -#define CI_HDRC_DISABLE_STREAMING BIT(3)Why not just rename this one, now you have a "hole" in your bit field that people aren't going to know if they can use or not.
I will change it, thanks.
Signature · 2 lines
Best Regards, Peter Chen
Sascha Hauer
maintainerPATCH 2/10 usb: chipidea: define stream mode disable for both roles
In reply to Peter ChenHi Peter,
Quoted 10 lines · Peter Chen
The system bus and chipidea IP have different limitations for both host and device mode.
For example, with below errata, we need to enable SDIS(Stream Disable Mode) at host mode. But we don't want it for device mode at the same system.TAR 9000378958
Title: Non-Double Word Aligned Buffer Address Sometimes Causes Host to Hang on OUT Retry
Impacted Configuration: Host mode, all transfer types
Description:
The host core operating in streaming mode may under run while sending the data packet of an OUT transaction. This under run can occur if there are unexpected system delays in fetching the remaining packet data from memory. The host forces a bad CRC on the packet, the device detects the error and discards the packet. The host then retries a Bulk, Interrupt, or Control transfer if an under run occurs according to the USB specification.
Please add linebreaks at 75 characters or so.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Sascha Hauer
maintainerPATCH 2/10 usb: chipidea: define stream mode disable for both roles
Quoted 8 lines · Sascha Hauer
Hi Peter,
Quoted 5 lines · Peter Chen
The system bus and chipidea IP have different limitations for both host and device mode.
For example, with below errata, we need to enable SDIS(Stream Disable Mode) at host mode. But we don't want it for device mode at the same system.
Quoted 7 lines
Quoted 5 lines
TAR 9000378958
Title: Non-Double Word Aligned Buffer Address Sometimes Causes Host to Hang on OUT Retry
Impacted Configuration: Host mode, all transfer types
Description:
The host core operating in streaming mode may under run while sending the data packet of an OUT transaction. This under run can occur if there are unexpected system delays in fetching the remaining packet data from memory. The host forces a bad CRC on the packet, the device detects the error and discards the packet. The host then retries a Bulk, Interrupt, or Control transfer if an under run occurs according to the USB specification.Please add linebreaks at 75 characters or so.
Oh sorry, this already had been addressed. Should have read further.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
PATCH 3/10 usb: chipidea: imx: add stream mode enable for device mode at imx6sl/imx6sx
In reply to Peter ChenStream mode enable is known for better performance, this stream mode enable patch has been passed with stress tests at device mode for imx6sl and imx6sx, and no issue is found.
--- drivers/usb/chipidea/ci_hdrc_imx.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/usb/chipidea/ci_hdrc_imx.c +10 -6
@@ -29,26 +29,31 @@ struct ci_hdrc_imx_platform_flag { };static const struct ci_hdrc_imx_platform_flag imx27_usb_data = { +CI_HDRC_DISABLE_STREAMING , };static const struct ci_hdrc_imx_platform_flag imx28_usb_data = { .flags =CI_HDRC_IMX28_WRITE_FIX | -CI_HDRC_TURN_VBUS_EARLY_ON , +CI_HDRC_TURN_VBUS_EARLY_ON | +CI_HDRC_DISABLE_STREAMING , };static const struct ci_hdrc_imx_platform_flag imx6q_usb_data = { .flags =CI_HDRC_SUPPORTS_RUNTIME_PM | -CI_HDRC_TURN_VBUS_EARLY_ON , +CI_HDRC_TURN_VBUS_EARLY_ON | +CI_HDRC_DISABLE_STREAMING , };static const struct ci_hdrc_imx_platform_flag imx6sl_usb_data = { .flags =CI_HDRC_SUPPORTS_RUNTIME_PM | -CI_HDRC_TURN_VBUS_EARLY_ON , +CI_HDRC_TURN_VBUS_EARLY_ON | +CI_HDRC_DISABLE_HOST_STREAMING , };static const struct ci_hdrc_imx_platform_flag imx6sx_usb_data = { .flags =CI_HDRC_SUPPORTS_RUNTIME_PM | -CI_HDRC_TURN_VBUS_EARLY_ON , +CI_HDRC_TURN_VBUS_EARLY_ON | +CI_HDRC_DISABLE_HOST_STREAMING , };static const struct of_device_id ci_hdrc_imx_dt_ids[] = {
@@ -126,8 +131,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)struct ci_hdrc_platform_data pdata = { .name =dev_name (&pdev->dev), .capoffset =DEF_CAPOFFSET , - .flags =CI_HDRC_DISABLE_STREAMING | -CI_HDRC_SET_NON_ZERO_TTHA , + .flags =CI_HDRC_SET_NON_ZERO_TTHA , };int ret; const struct of_device_id *of_id =
Signature · 1 line
1.9.1
PATCH 4/10 Doc: usb: ci-hdrc-usb2: add ahb-burst-config for binding doc
In reply to Peter ChenIt is used to change ahb burst configuration for platforms, it is vendor specific.
--- Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +4 -0
@@ -32,6 +32,8 @@ Optional properties: - external-vbus-divider: (FSL only) enables off-chip resistor divider for Vbus - itc-setting: interrupt threshold control register control, the setting should be aligned with ITC bits at register USBCMD. +- ahb-burst-config: it is vendor dependent, the required value should be + aligned with AHBBRST at SBUSCFG, the range is from 0x0 to 0x7. Example:
@@ -44,4 +46,6 @@ Example: phy-names = "usb-phy"; vbus-supply = <®_usb0_vbus>; gadget-itc-setting = <0x4>; /* 4 micro-frames */ + /* Incremental burst of unspecified length */ + ahb-burst-config = <0x0>; };
Signature · 1 line
1.9.1
PATCH 5/10 ARM: imx6: set ahb-burst-config as 0 for USB
In reply to Peter ChenAfter setting ahb burst configuration as 0, we can increase tx/rx burst size, it will improve the USB performance
--- arch/arm/boot/dts/imx6qdl.dtsi | 4 ++++ arch/arm/boot/dts/imx6sl.dtsi | 3 +++ arch/arm/boot/dts/imx6sx.dtsi | 3 +++ 3 files changed, 10 insertions(+)
arch/arm/boot/dts/imx6qdl.dtsi +4 -0
@@ -853,6 +853,7 @@ clocks = <&clks IMX6QDL_CLK_USBOH3>; fsl,usbphy = <&usbphy1>; fsl,usbmisc = <&usbmisc 0>; + ahb-burst-config = <0x0>; status = "disabled"; };
@@ -864,6 +865,7 @@ fsl,usbphy = <&usbphy2>; fsl,usbmisc = <&usbmisc 1>; dr_mode = "host"; + ahb-burst-config = <0x0>; status = "disabled"; };
@@ -874,6 +876,7 @@ clocks = <&clks IMX6QDL_CLK_USBOH3>; fsl,usbmisc = <&usbmisc 2>; dr_mode = "host"; + ahb-burst-config = <0x0>; status = "disabled"; };
@@ -884,6 +887,7 @@ clocks = <&clks IMX6QDL_CLK_USBOH3>; fsl,usbmisc = <&usbmisc 3>; dr_mode = "host"; + ahb-burst-config = <0x0>; status = "disabled"; };
arch/arm/boot/dts/imx6sl.dtsi +3 -0
@@ -688,6 +688,7 @@ clocks = <&clks IMX6SL_CLK_USBOH3>; fsl,usbphy = <&usbphy1>; fsl,usbmisc = <&usbmisc 0>; + ahb-burst-config = <0x0>; status = "disabled"; };
@@ -698,6 +699,7 @@ clocks = <&clks IMX6SL_CLK_USBOH3>; fsl,usbphy = <&usbphy2>; fsl,usbmisc = <&usbmisc 1>; + ahb-burst-config = <0x0>; status = "disabled"; };
@@ -708,6 +710,7 @@ clocks = <&clks IMX6SL_CLK_USBOH3>; fsl,usbmisc = <&usbmisc 2>; dr_mode = "host"; + ahb-burst-config = <0x0>; status = "disabled"; };
arch/arm/boot/dts/imx6sx.dtsi +3 -0
@@ -746,6 +746,7 @@ fsl,usbphy = <&usbphy1>; fsl,usbmisc = <&usbmisc 0>; fsl,anatop = <&anatop>; + ahb-burst-config = <0x0>; status = "disabled"; };
@@ -756,6 +757,7 @@ clocks = <&clks IMX6SX_CLK_USBOH3>; fsl,usbphy = <&usbphy2>; fsl,usbmisc = <&usbmisc 1>; + ahb-burst-config = <0x0>; status = "disabled"; };
@@ -768,6 +770,7 @@ phy_type = "hsic"; fsl,anatop = <&anatop>; dr_mode = "host"; + ahb-burst-config = <0x0>; status = "disabled"; };
Signature · 1 line
1.9.1
PATCH 6/10 usb: chipidea: add ahb burst configuration interface
In reply to Peter ChenThe users can change it through dts or platform data if they want to change the default value.
--- drivers/usb/chipidea/bits.h | 3 +++ drivers/usb/chipidea/core.c | 14 ++++++++++++++ include/linux/usb/chipidea.h | 2 ++ 3 files changed, 19 insertions(+)
drivers/usb/chipidea/bits.h +3 -0
@@ -25,6 +25,9 @@#define VERSION (0xF << 25)#define CIVERSION (0x7 << 29) +/* SBUSCFG */ +#define AHBBRST_MASK 0x7 +/* HCCPARAMS */ #define HCCPARAMS_LEN BIT(17)
drivers/usb/chipidea/core.c +14 -0
@@ -439,6 +439,9 @@ void ci_platform_configure(struct ci_hdrc *ci)hw_write (ci,OP_USBCMD ,0xff0000 , ci->platdata->itc_setting <<16 ); +if (ci->platdata->flags &CI_HDRC_OVERRIDE_AHB_BURST ) +hw_write_id_reg (ci,ID_SBUSCFG ,AHBBRST_MASK , + ci->platdata->ahb_burst_config); }/**
@@ -647,6 +650,17 @@ static int ci_get_platdata(struct device *dev, } } +if (of_find_property (dev->of_node,"ahb-burst-config" ,NULL )) { + ret =of_property_read_u32 (dev->of_node,"ahb-burst-config" , + &platdata->ahb_burst_config); +if (ret) { +dev_err (dev, +"failed to get ahb-burst-config\n" ); +return ret; + } + platdata->flags |=CI_HDRC_OVERRIDE_AHB_BURST ; + } +return 0 ; }
include/linux/usb/chipidea.h +2 -0
@@ -33,6 +33,7 @@ struct ci_hdrc_platform_data {#define CI_HDRC_DISABLE_HOST_STREAMING BIT(10)#define CI_HDRC_DISABLE_STREAMING (CI_HDRC_DISABLE_DEVICE_STREAMING | \ CI_HDRC_DISABLE_HOST_STREAMING) +#define CI_HDRC_OVERRIDE_AHB_BURST BIT(11)enum usb_dr_mode dr_mode;#define CI_HDRC_CONTROLLER_RESET_EVENT 0#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1
@@ -42,6 +43,7 @@ struct ci_hdrc_platform_data {bool tpl_support;/* interrupt threshold setting */ u32 itc_setting; +u32 ahb_burst_config; };/* Default offset of capability registers */
Signature · 1 line
1.9.1
PATCH 7/10 usb: chipidea: usbmisc_imx: add unburst setting for imx6
In reply to Peter ChenWith this setting and AHBBRST at SBUSCFG as "Incremental burst of unspecified length", each unburst size can be taken as one single transfer. It is benefit for unburst size transfer.
--- drivers/usb/chipidea/usbmisc_imx.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/usb/chipidea/usbmisc_imx.c +10 -2
@@ -54,6 +54,7 @@#define MX53_USB_PHYCTRL1_PLLDIV_MASK 0x3#define MX53_USB_PLL_DIV_24_MHZ 0x01 +#define MX6_BM_UNBURST_SETTING BIT(1)#define MX6_BM_OVER_CUR_DIS BIT(7)#define MX6_BM_WAKEUP_ENABLE BIT(10)#define MX6_BM_ID_WAKEUP BIT(16)
@@ -255,14 +256,21 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data)if (data->index >3 )return -EINVAL ; +spin_lock_irqsave (&usbmisc->lock, flags); +if (data->disable_oc) { -spin_lock_irqsave (&usbmisc->lock, flags); reg =readl (usbmisc->base + data->index *4 );writel (reg |MX6_BM_OVER_CUR_DIS , usbmisc->base + data->index *4 ); -spin_unlock_irqrestore (&usbmisc->lock, flags); } +/* SoC unburst setting */ + reg =readl (usbmisc->base + data->index *4 ); +writel (reg |MX6_BM_UNBURST_SETTING , + usbmisc->base + data->index *4 ); + +spin_unlock_irqrestore (&usbmisc->lock, flags); +usbmisc_imx6q_set_wakeup (data, false);return 0 ;
Signature · 1 line
1.9.1
PATCH 7/10 usb: chipidea: usbmisc_imx: add unburst setting for imx6
Hi,
Quoted 4 lines
With this setting and AHBBRST at SBUSCFG as "Incremental burst of unspecified length", each unburst size can be taken as one single transfer. It is benefit for unburst size transfer.
What is an 'unburst'?
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
PATCH 7/10 usb: chipidea: usbmisc_imx: add unburst setting for imx6
Quoted 8 lines · Lothar Wa?mann
Hi,
Quoted 4 lines
With this setting and AHBBRST at SBUSCFG as "Incremental burst of unspecified length", each unburst size can be taken as one single transfer. It is benefit for unburst size transfer.
What is an 'unburst'?
Assume burst size is 8 dword, unburst size 't' < 8.
With this feature, 't' length payload can be taken as one burst transfer, otherwise, the single transfer (1 dword) will be used.
Signature · 2 lines
Best Regards, Peter Chen
PATCH 7/10 usb: chipidea: usbmisc_imx: add unburst setting for imx6
Hi,
Quoted 7 lines · Lothar Wa?mann
Quoted 6 lines
Hi,
Quoted 4 lines
With this setting and AHBBRST at SBUSCFG as "Incremental burst of unspecified length", each unburst size can be taken as one single transfer. It is benefit for unburst size transfer.
Quoted 9 lines
Quoted 2 lines
What is an 'unburst'?
Assume burst size is 8 dword, unburst size 't' < 8.
With this feature, 't' length payload can be taken as one burst transfer, otherwise, the single transfer (1 dword) will be used.
IMO non-burst would be a better word.
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
PATCH 7/10 usb: chipidea: usbmisc_imx: add unburst setting for imx6
Quoted 11 lines
Quoted 11 lines · Lothar Wa?mann
Quoted 8 lines
Hi,
Quoted 4 lines
With this setting and AHBBRST at SBUSCFG as "Incremental burst of unspecified length", each unburst size can be taken as one single transfer. It is benefit for unburst size transfer.
What is an 'unburst'?
Quoted 8 lines
Quoted 6 lines
Assume burst size is 8 dword, unburst size 't' < 8.
With this feature, 't' length payload can be taken as one burst transfer, otherwise, the single transfer
(1 dword) will be used.IMO non-burst would be a better word.
Thanks, will change.
Peter
PATCH 8/10 Doc: usb: ci-hdrc-usb2: add tx(rx)-burst-config-dword for binding doc
In reply to Peter ChenIt is used to override the default setting for burst size, changing burst size takes effect only when the SBUSCFG.AHBBRST = 0.
--- Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +6 -0
@@ -34,6 +34,10 @@ Optional properties: should be aligned with ITC bits at register USBCMD. - ahb-burst-config: it is vendor dependent, the required value should be aligned with AHBBRST at SBUSCFG, the range is from 0x0 to 0x7. +- tx-burst-size-dword: it is vendor dependent, the tx burst size in dword + (4 bytes). +- rx-burst-size-dword: it is vendor dependent, the rx burst size in dword + (4 bytes). Example:
@@ -48,4 +52,6 @@ Example: gadget-itc-setting = <0x4>; /* 4 micro-frames */ /* Incremental burst of unspecified length */ ahb-burst-config = <0x0>; + tx-burst-size-dword = <0x10>; /* 64 bytes */ + rx-burst-size-dword = <0x10>; };
Signature · 1 line
1.9.1
PATCH 9/10 ARM: imx6: change default burst size for USB
In reply to Peter ChenIt can improve the USB performance when choosing larger burst size at some systems (bus size is larger), there is no side effect if this burst size is larger than bus size.
--- arch/arm/boot/dts/imx6qdl.dtsi | 8 ++++++++ arch/arm/boot/dts/imx6sl.dtsi | 6 ++++++ arch/arm/boot/dts/imx6sx.dtsi | 6 ++++++ 3 files changed, 20 insertions(+)
arch/arm/boot/dts/imx6qdl.dtsi +8 -0
@@ -854,6 +854,8 @@ fsl,usbphy = <&usbphy1>; fsl,usbmisc = <&usbmisc 0>; ahb-burst-config = <0x0>; + tx-burst-size-dword = <0x10>; + rx-burst-size-dword = <0x10>; status = "disabled"; };
@@ -866,6 +868,8 @@ fsl,usbmisc = <&usbmisc 1>; dr_mode = "host"; ahb-burst-config = <0x0>; + tx-burst-size-dword = <0x10>; + rx-burst-size-dword = <0x10>; status = "disabled"; };
@@ -877,6 +881,8 @@ fsl,usbmisc = <&usbmisc 2>; dr_mode = "host"; ahb-burst-config = <0x0>; + tx-burst-size-dword = <0x10>; + rx-burst-size-dword = <0x10>; status = "disabled"; };
@@ -888,6 +894,8 @@ fsl,usbmisc = <&usbmisc 3>; dr_mode = "host"; ahb-burst-config = <0x0>; + tx-burst-size-dword = <0x10>; + rx-burst-size-dword = <0x10>; status = "disabled"; };
arch/arm/boot/dts/imx6sl.dtsi +6 -0
@@ -689,6 +689,8 @@ fsl,usbphy = <&usbphy1>; fsl,usbmisc = <&usbmisc 0>; ahb-burst-config = <0x0>; + tx-burst-size-dword = <0x10>; + rx-burst-size-dword = <0x10>; status = "disabled"; };
@@ -700,6 +702,8 @@ fsl,usbphy = <&usbphy2>; fsl,usbmisc = <&usbmisc 1>; ahb-burst-config = <0x0>; + tx-burst-size-dword = <0x10>; + rx-burst-size-dword = <0x10>; status = "disabled"; };
@@ -711,6 +715,8 @@ fsl,usbmisc = <&usbmisc 2>; dr_mode = "host"; ahb-burst-config = <0x0>; + tx-burst-size-dword = <0x10>; + rx-burst-size-dword = <0x10>; status = "disabled"; };
arch/arm/boot/dts/imx6sx.dtsi +6 -0
@@ -747,6 +747,8 @@ fsl,usbmisc = <&usbmisc 0>; fsl,anatop = <&anatop>; ahb-burst-config = <0x0>; + tx-burst-size-dword = <0x10>; + rx-burst-size-dword = <0x10>; status = "disabled"; };
@@ -758,6 +760,8 @@ fsl,usbphy = <&usbphy2>; fsl,usbmisc = <&usbmisc 1>; ahb-burst-config = <0x0>; + tx-burst-size-dword = <0x10>; + rx-burst-size-dword = <0x10>; status = "disabled"; };
@@ -771,6 +775,8 @@ fsl,anatop = <&anatop>; dr_mode = "host"; ahb-burst-config = <0x0>; + tx-burst-size-dword = <0x10>; + rx-burst-size-dword = <0x10>; status = "disabled"; };
Signature · 1 line
1.9.1
PATCH 10/10 usb: chipidea: add tx/rx burst size configuration interface
In reply to Peter ChenThe user can adjust it through dts or platform data
--- drivers/usb/chipidea/bits.h | 4 ++++ drivers/usb/chipidea/ci.h | 1 + drivers/usb/chipidea/core.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/usb/chipidea.h | 4 ++++ 4 files changed, 44 insertions(+)
drivers/usb/chipidea/bits.h +4 -0
@@ -61,6 +61,10 @@/* Set non-zero value for internal TT Hub address representation */ #define TTCTRL_TTHA (0x7fUL << 24) +/* BURSTSIZE */ +#define RX_BURST_MASK 0xff +#define TX_BURST_MASK 0xff00 +/* PORTSC */ #define PORTSC_CCS BIT(0)#define PORTSC_CSC BIT(1)
drivers/usb/chipidea/ci.h +1 -0
@@ -51,6 +51,7 @@ enum ci_hw_regs {OP_DEVICEADDR ,OP_ENDPTLISTADDR ,OP_TTCTRL , +OP_BURSTSIZE ,OP_PORTSC ,OP_DEVLC , OP_OTGSC,
drivers/usb/chipidea/core.c +35 -0
@@ -86,6 +86,7 @@ static const u8 ci_regs_nolpm[] = { [OP_DEVICEADDR] = 0x14U, [OP_ENDPTLISTADDR] = 0x18U, [OP_TTCTRL] = 0x1CU, + [OP_BURSTSIZE] = 0x20U, [OP_PORTSC] = 0x44U, [OP_DEVLC] = 0x84U, [OP_OTGSC] = 0x64U,
@@ -109,6 +110,7 @@ static const u8 ci_regs_lpm[] = { [OP_DEVICEADDR] = 0x14U, [OP_ENDPTLISTADDR] = 0x18U, [OP_TTCTRL] = 0x1CU, + [OP_BURSTSIZE] = 0x20U, [OP_PORTSC] = 0x44U, [OP_DEVLC] = 0x84U, [OP_OTGSC] = 0xC4U,
@@ -442,6 +444,17 @@ void ci_platform_configure(struct ci_hdrc *ci)if (ci->platdata->flags &CI_HDRC_OVERRIDE_AHB_BURST )hw_write_id_reg (ci,ID_SBUSCFG ,AHBBRST_MASK , ci->platdata->ahb_burst_config); + +/* override burst size, take effect only when ahb_burst_config is 0 */ +if (!hw_read_id_reg (ci,ID_SBUSCFG ,AHBBRST_MASK )) { +if (ci->platdata->flags &CI_HDRC_OVERRIDE_TX_BURST ) +hw_write (ci,OP_BURSTSIZE ,TX_BURST_MASK , + ci->platdata->tx_burst_size <<__ffs (TX_BURST_MASK )); + +if (ci->platdata->flags &CI_HDRC_OVERRIDE_RX_BURST ) +hw_write (ci,OP_BURSTSIZE ,RX_BURST_MASK , + ci->platdata->rx_burst_size); + } }/**
@@ -661,6 +674,28 @@ static int ci_get_platdata(struct device *dev, platdata->flags |=CI_HDRC_OVERRIDE_AHB_BURST ; } +if (of_find_property (dev->of_node,"tx-burst-size-dword" ,NULL )) { + ret =of_property_read_u32 (dev->of_node,"tx-burst-size-dword" , + &platdata->tx_burst_size); +if (ret) { +dev_err (dev, +"failed to get tx-burst-size-dword\n" ); +return ret; + } + platdata->flags |=CI_HDRC_OVERRIDE_TX_BURST ; + } + +if (of_find_property (dev->of_node,"rx-burst-size-dword" ,NULL )) { + ret =of_property_read_u32 (dev->of_node,"rx-burst-size-dword" , + &platdata->rx_burst_size); +if (ret) { +dev_err (dev, +"failed to get rx-burst-size-dword\n" ); +return ret; + } + platdata->flags |=CI_HDRC_OVERRIDE_RX_BURST ; + } +return 0 ; }
include/linux/usb/chipidea.h +4 -0
@@ -34,6 +34,8 @@ struct ci_hdrc_platform_data {#define CI_HDRC_DISABLE_STREAMING (CI_HDRC_DISABLE_DEVICE_STREAMING | \ CI_HDRC_DISABLE_HOST_STREAMING)#define CI_HDRC_OVERRIDE_AHB_BURST BIT(11) +#define CI_HDRC_OVERRIDE_TX_BURST BIT(12) +#define CI_HDRC_OVERRIDE_RX_BURST BIT(13)enum usb_dr_mode dr_mode;#define CI_HDRC_CONTROLLER_RESET_EVENT 0#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1
@@ -44,6 +46,8 @@ struct ci_hdrc_platform_data {/* interrupt threshold setting */ u32 itc_setting;u32 ahb_burst_config; +u32 tx_burst_size; +u32 rx_burst_size; };/* Default offset of capability registers */
Signature · 1 line
1.9.1