usb: isp1760: arm tc2 board isp1761 fixes
Subsystems (2)
Rui Miguel Silva
maintainerv2 cover usb: isp1760: arm tc2 board isp1761 fixes
Hi,
Dietmar complained that the latest changes to this driver broke booting his Arm TC2 board [0]. I did not have one of that boards but Dietmar provided out of band help trying to debug the issue, many thanks for that.
Meanwhile, yesterday I could get access (remotely) to one of TC2 board and manage to fix the issues that were breaking this to work on that system.
This is rebased on top of the latest (this evening) usb-testing/(this morning) usb-next. If, and I am sure it is too late to include in to 5.14, it should go to the first 5.14.y stable with this tag:
Thanks again Dietmar for reporting and your help.
Cheers,
Rui
v1[1]->v2:
Dietmar:
- change email from gmx.de to arm.com
- add tested-by tag
[0]: https://lore.kernel.org/linux-usb/[email protected]/
[1]: https://lore.kernel.org/linux-usb/[email protected]/T/#t
Rui Miguel Silva (5):
usb: isp1760: fix memory pool initialization
usb: isp1760: fix qtd fill length
usb: isp1760: write to status and address register
usb: isp1760: use the right irq status bit
usb: isp1760: otg control register access
drivers/usb/isp1760/isp1760-core.c | 50 ++++++++++++++++-------------- drivers/usb/isp1760/isp1760-hcd.c | 33 ++++++++++---------- drivers/usb/isp1760/isp1760-regs.h | 16 ++++++++++ drivers/usb/isp1760/isp1760-udc.c | 12 +++---- 4 files changed, 65 insertions(+), 46 deletions(-)
Signature · 1 line
2.33.0
Rui Miguel Silva
maintainerPATCH v2 1/5 usb: isp1760: fix memory pool initialization
The loops to setup the memory pool were skipping some blocks, that was not visible on the ISP1763 because it has fewer blocks than the ISP1761. But won testing on that IP from the family that would be an issue.
--- drivers/usb/isp1760/isp1760-hcd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/isp1760/isp1760-hcd.c +2 -2
@@ -588,8 +588,8 @@ static void init_memory(struct isp1760_hcd *priv) payload_addr =PAYLOAD_OFFSET ; -for (i =0 , curr =0 ; i <ARRAY_SIZE (mem->blocks); i++) { -for (j =0 ; j < mem->blocks[i]; j++, curr++) { +for (i =0 , curr =0 ; i <ARRAY_SIZE (mem->blocks); i++, curr += j) { +for (j =0 ; j < mem->blocks[i]; j++) { priv->memory_pool[curr + j].start = payload_addr; priv->memory_pool[curr + j].size = mem->blocks_size[i]; priv->memory_pool[curr + j].free =1 ;
Signature · 1 line
2.33.0
Rui Miguel Silva
maintainerPATCH v2 2/5 usb: isp1760: fix qtd fill length
In reply to Rui Miguel SilvaWhen trying to send bulks bigger than the biggest block size we need to split them over several qtd. Fix this limiting the maximum qtd size to largest block size.
--- drivers/usb/isp1760/isp1760-hcd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/usb/isp1760/isp1760-hcd.c +4 -2
@@ -1829,9 +1829,11 @@ static void packetize_urb(struct usb_hcd *hcd, goto cleanup;if (len > mem->blocks_size[ISP176x_BLOCK_NUM -1 ]) - len = mem->blocks_size[ISP176x_BLOCK_NUM -1 ]; + this_qtd_len = mem->blocks_size[ISP176x_BLOCK_NUM -1 ]; +else + this_qtd_len = len; - this_qtd_len =qtd_fill (qtd, buf, len); + this_qtd_len =qtd_fill (qtd, buf, this_qtd_len);list_add_tail (&qtd->qtd_list, head); len -= this_qtd_len;
Signature · 1 line
2.33.0
Rui Miguel Silva
maintainerPATCH v2 3/5 usb: isp1760: write to status and address register
In reply to Rui Miguel SilvaWe were already writing directly the port status register to trigger changes in isp1763. The same is needed in other IP from the family, including also to setup the read address before reading from device.
--- drivers/usb/isp1760/isp1760-hcd.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
drivers/usb/isp1760/isp1760-hcd.c +11 -12
@@ -182,7 +182,7 @@ struct urb_listitem {struct urb *urb; }; -static const u32 isp1763_hc_portsc1_fields[] = { +static const u32 isp176x_hc_portsc1_fields[] = { [PORT_OWNER ] =BIT (13 ), [PORT_POWER ] =BIT (12 ), [PORT_LSTATUS ] =BIT (10 ),
@@ -205,27 +205,28 @@ static u32 isp1760_hcd_read(struct usb_hcd *hcd, u32 field) }/* -* We need, in isp1763, to write directly the values to the portsc1 +* We need, in isp176x, to write directly the values to the portsc1 * register so it will make the other values to trigger. */ static void isp1760_hcd_portsc1_set_clear (struct isp1760_hcd *priv,u32 field,u32 val) { -u32 bit = isp1763_hc_portsc1_fields[field]; -u32 port_status =readl (priv->base +ISP1763_HC_PORTSC1 ); +u32 bit = isp176x_hc_portsc1_fields[field]; +u16 portsc1_reg = priv->is_isp1763 ?ISP1763_HC_PORTSC1 : + ISP176x_HC_PORTSC1; +u32 port_status =readl (priv->base + portsc1_reg);if (val) -writel (port_status | bit, priv->base +ISP1763_HC_PORTSC1 ); +writel (port_status | bit, priv->base + portsc1_reg);else -writel (port_status & ~bit, priv->base +ISP1763_HC_PORTSC1 ); +writel (port_status & ~bit, priv->base + portsc1_reg); }static void isp1760_hcd_write (struct usb_hcd *hcd,u32 field,u32 val) {struct isp1760_hcd *priv =hcd_to_priv (hcd); -if (unlikely (priv->is_isp1763 && - (field >=PORT_OWNER && field <=PORT_CONNECT ))) +if (unlikely ((field >=PORT_OWNER && field <=PORT_CONNECT )))return isp1760_hcd_portsc1_set_clear (priv, field, val);isp1760_field_write (priv->fields, field, val);
@@ -367,8 +368,7 @@ static void isp1760_mem_read(struct usb_hcd *hcd, u32 src_offset, void *dst, {struct isp1760_hcd *priv =hcd_to_priv (hcd); -isp1760_hcd_write (hcd,MEM_BANK_SEL ,ISP_BANK_0 ); -isp1760_hcd_write (hcd,MEM_START_ADDR , src_offset); +isp1760_reg_write (priv->regs, ISP176x_HC_MEMORY, src_offset);ndelay (100 );bank_reads8 (priv->base, src_offset,ISP_BANK_0 , dst, bytes);
@@ -496,8 +496,7 @@ static void isp1760_ptd_read(struct usb_hcd *hcd, u32 ptd_offset, u32 slot,u16 src_offset = ptd_offset + slot *sizeof (*ptd);struct isp1760_hcd *priv =hcd_to_priv (hcd); -isp1760_hcd_write (hcd,MEM_BANK_SEL ,ISP_BANK_0 ); -isp1760_hcd_write (hcd,MEM_START_ADDR , src_offset); +isp1760_reg_write (priv->regs, ISP176x_HC_MEMORY, src_offset);ndelay (90 ); bank_reads8(priv->base, src_offset, ISP_BANK_0, (void *)ptd,
Signature · 1 line
2.33.0
Rui Miguel Silva
maintainerPATCH v2 4/5 usb: isp1760: use the right irq status bit
In reply to Rui Miguel SilvaInstead of using the fields enum values to check interrupts trigged, use the correct bit values.
--- drivers/usb/isp1760/isp1760-udc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/usb/isp1760/isp1760-udc.c +6 -6
@@ -1363,7 +1363,7 @@ static irqreturn_t isp1760_udc_irq(int irq, void *dev) status =isp1760_udc_irq_get_status (udc); -if (status &DC_IEVBUS ) { +if (status & ISP176x_DC_IEVBUS) {dev_dbg (udc->isp->dev,"%s(VBUS)\n" , __func__);/* The VBUS interrupt is only triggered when VBUS appears. */ spin_lock (&udc->lock);
@@ -1371,7 +1371,7 @@ static irqreturn_t isp1760_udc_irq(int irq, void *dev)spin_unlock (&udc->lock); } -if (status &DC_IEBRST ) { +if (status & ISP176x_DC_IEBRST) {dev_dbg (udc->isp->dev,"%s(BRST)\n" , __func__);isp1760_udc_reset (udc);
@@ -1391,18 +1391,18 @@ static irqreturn_t isp1760_udc_irq(int irq, void *dev) } } -if (status &DC_IEP0SETUP ) { +if (status & ISP176x_DC_IEP0SETUP) {dev_dbg (udc->isp->dev,"%s(EP0SETUP)\n" , __func__);isp1760_ep0_setup (udc); } -if (status &DC_IERESM ) { +if (status & ISP176x_DC_IERESM) {dev_dbg (udc->isp->dev,"%s(RESM)\n" , __func__);isp1760_udc_resume (udc); } -if (status &DC_IESUSP ) { +if (status & ISP176x_DC_IESUSP) {dev_dbg (udc->isp->dev,"%s(SUSP)\n" , __func__);spin_lock (&udc->lock);
@@ -1413,7 +1413,7 @@ static irqreturn_t isp1760_udc_irq(int irq, void *dev)spin_unlock (&udc->lock); } -if (status &DC_IEHS_STA ) { +if (status & ISP176x_DC_IEHS_STA) {dev_dbg (udc->isp->dev,"%s(HS_STA)\n" , __func__); udc->gadget.speed =USB_SPEED_HIGH ; }
Signature · 1 line
2.33.0
Rui Miguel Silva
maintainerPATCH v2 5/5 usb: isp1760: otg control register access
In reply to Rui Miguel SilvaThe set/clear of the otg control values is done writing to two different 16bit registers, however we setup the regmap width for isp1760/61 to 32bit value bits.
So, just access the clear register address (0x376)as the high part of the otg control register set (0x374), and write the values in one go to make sure they get clear/set.
--- drivers/usb/isp1760/isp1760-core.c | 50 ++++++++++++++++-------------- drivers/usb/isp1760/isp1760-regs.h | 16 ++++++++++ 2 files changed, 42 insertions(+), 24 deletions(-)
drivers/usb/isp1760/isp1760-core.c +26 -24
@@ -30,6 +30,7 @@ static int isp1760_init_core(struct isp1760_device *isp) {struct isp1760_hcd *hcd = &isp->hcd;struct isp1760_udc *udc = &isp->udc; +u32 otg_ctrl;/* Low-level chip reset */ if (isp->rst_gpio) {
@@ -83,16 +84,17 @@ static int isp1760_init_core(struct isp1760_device *isp)* * TODO: Really support OTG. For now we configure port 1 in device mode */ -if (((isp->devflags &ISP1760_FLAG_ISP1761 ) || - (isp->devflags &ISP1760_FLAG_ISP1763 )) && - (isp->devflags &ISP1760_FLAG_PERIPHERAL_EN )) { -isp1760_field_set (hcd->fields,HW_DM_PULLDOWN ); -isp1760_field_set (hcd->fields,HW_DP_PULLDOWN ); -isp1760_field_set (hcd->fields,HW_OTG_DISABLE ); - }else { -isp1760_field_set (hcd->fields,HW_SW_SEL_HC_DC ); -isp1760_field_set (hcd->fields,HW_VBUS_DRV ); -isp1760_field_set (hcd->fields,HW_SEL_CP_EXT ); +if (isp->devflags &ISP1760_FLAG_ISP1761 ) { +if (isp->devflags &ISP1760_FLAG_PERIPHERAL_EN ) { + otg_ctrl = (ISP176x_HW_DM_PULLDOWN_CLEAR | + ISP176x_HW_DP_PULLDOWN_CLEAR | + ISP176x_HW_OTG_DISABLE); + }else { + otg_ctrl = (ISP176x_HW_SW_SEL_HC_DC_CLEAR | + ISP176x_HW_VBUS_DRV | + ISP176x_HW_SEL_CP_EXT); + } +isp1760_reg_write (hcd->regs, ISP176x_HC_OTG_CTRL, otg_ctrl); } dev_info(isp->dev, "%s bus width: %u, oc: %s\n",
@@ -235,20 +237,20 @@ static const struct reg_field isp1760_hc_reg_fields[] = { [HC_ISO_IRQ_MASK_AND] = REG_FIELD(ISP176x_HC_ISO_IRQ_MASK_AND, 0, 31), [HC_INT_IRQ_MASK_AND] = REG_FIELD(ISP176x_HC_INT_IRQ_MASK_AND, 0, 31), [HC_ATL_IRQ_MASK_AND] = REG_FIELD(ISP176x_HC_ATL_IRQ_MASK_AND, 0, 31), - [HW_OTG_DISABLE] = REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 10, 10), - [HW_SW_SEL_HC_DC] = REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 7, 7), - [HW_VBUS_DRV] = REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 4, 4), - [HW_SEL_CP_EXT] = REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 3, 3), - [HW_DM_PULLDOWN] = REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 2, 2), - [HW_DP_PULLDOWN] = REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 1, 1), - [HW_DP_PULLUP] = REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 0, 0), - [HW_OTG_DISABLE_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 10, 10), - [HW_SW_SEL_HC_DC_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 7, 7), - [HW_VBUS_DRV_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 4, 4), - [HW_SEL_CP_EXT_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 3, 3), - [HW_DM_PULLDOWN_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 2, 2), - [HW_DP_PULLDOWN_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 1, 1), - [HW_DP_PULLUP_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 0, 0), + [HW_OTG_DISABLE_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL, 26, 26), + [HW_SW_SEL_HC_DC_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL, 23, 23), + [HW_VBUS_DRV_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL, 20, 20), + [HW_SEL_CP_EXT_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL, 19, 19), + [HW_DM_PULLDOWN_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL, 18, 18), + [HW_DP_PULLDOWN_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL, 17, 17), + [HW_DP_PULLUP_CLEAR] = REG_FIELD(ISP176x_HC_OTG_CTRL, 16, 16), + [HW_OTG_DISABLE] = REG_FIELD(ISP176x_HC_OTG_CTRL, 10, 10), + [HW_SW_SEL_HC_DC] = REG_FIELD(ISP176x_HC_OTG_CTRL, 7, 7), + [HW_VBUS_DRV] = REG_FIELD(ISP176x_HC_OTG_CTRL, 4, 4), + [HW_SEL_CP_EXT] = REG_FIELD(ISP176x_HC_OTG_CTRL, 3, 3), + [HW_DM_PULLDOWN] = REG_FIELD(ISP176x_HC_OTG_CTRL, 2, 2), + [HW_DP_PULLDOWN] = REG_FIELD(ISP176x_HC_OTG_CTRL, 1, 1), + [HW_DP_PULLUP] = REG_FIELD(ISP176x_HC_OTG_CTRL, 0, 0), };static const struct reg_field isp1763_hc_reg_fields[] = {
drivers/usb/isp1760/isp1760-regs.h +16 -0
@@ -61,6 +61,7 @@#define ISP176x_HC_INT_IRQ_MASK_AND 0x328#define ISP176x_HC_ATL_IRQ_MASK_AND 0x32c +#define ISP176x_HC_OTG_CTRL 0x374#define ISP176x_HC_OTG_CTRL_SET 0x374#define ISP176x_HC_OTG_CTRL_CLEAR 0x376
@@ -179,6 +180,21 @@ enum isp176x_host_controller_fields {#define ISP176x_DC_IESUSP BIT(3)#define ISP176x_DC_IEBRST BIT(0) +#define ISP176x_HW_OTG_DISABLE_CLEAR BIT(26) +#define ISP176x_HW_SW_SEL_HC_DC_CLEAR BIT(23) +#define ISP176x_HW_VBUS_DRV_CLEAR BIT(20) +#define ISP176x_HW_SEL_CP_EXT_CLEAR BIT(19) +#define ISP176x_HW_DM_PULLDOWN_CLEAR BIT(18) +#define ISP176x_HW_DP_PULLDOWN_CLEAR BIT(17) +#define ISP176x_HW_DP_PULLUP_CLEAR BIT(16) +#define ISP176x_HW_OTG_DISABLE BIT(10) +#define ISP176x_HW_SW_SEL_HC_DC BIT(7) +#define ISP176x_HW_VBUS_DRV BIT(4) +#define ISP176x_HW_SEL_CP_EXT BIT(3) +#define ISP176x_HW_DM_PULLDOWN BIT(2) +#define ISP176x_HW_DP_PULLDOWN BIT(1) +#define ISP176x_HW_DP_PULLUP BIT(0) +#define ISP176x_DC_ENDPTYP_ISOC 0x01#define ISP176x_DC_ENDPTYP_BULK 0x02#define ISP176x_DC_ENDPTYP_INTERRUPT 0x03
Signature · 1 line
2.33.0