Commit 5517525e authored by Ricardo Ribalda Delgado's avatar Ricardo Ribalda Delgado Committed by Felipe Balbi

usb: gadget: udc: net2280: Improve patching of defect 7374

Once the defect 7374 is patched, there is no reason the keep reading the
idx scratch register.

Cache the content of the scratch idx register on device flag.
Signed-off-by: default avatarRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 485f44d0
...@@ -1765,16 +1765,17 @@ static void defect7374_disable_data_eps(struct net2280 *dev) ...@@ -1765,16 +1765,17 @@ static void defect7374_disable_data_eps(struct net2280 *dev)
static void defect7374_enable_data_eps_zero(struct net2280 *dev) static void defect7374_enable_data_eps_zero(struct net2280 *dev)
{ {
u32 tmp = 0, tmp_reg; u32 tmp = 0, tmp_reg;
u32 fsmvalue, scratch; u32 scratch;
int i; int i;
unsigned char ep_sel; unsigned char ep_sel;
scratch = get_idx_reg(dev->regs, SCRATCH); scratch = get_idx_reg(dev->regs, SCRATCH);
fsmvalue = scratch & (0xf << DEFECT7374_FSM_FIELD);
WARN_ON((scratch & (0xf << DEFECT7374_FSM_FIELD))
== DEFECT7374_FSM_SS_CONTROL_READ);
scratch &= ~(0xf << DEFECT7374_FSM_FIELD); scratch &= ~(0xf << DEFECT7374_FSM_FIELD);
/*See if firmware needs to set up for workaround*/
if (fsmvalue != DEFECT7374_FSM_SS_CONTROL_READ) {
ep_warn(dev, "Operate Defect 7374 workaround soft this time"); ep_warn(dev, "Operate Defect 7374 workaround soft this time");
ep_warn(dev, "It will operate on cold-reboot and SS connect"); ep_warn(dev, "It will operate on cold-reboot and SS connect");
...@@ -1831,10 +1832,6 @@ static void defect7374_enable_data_eps_zero(struct net2280 *dev) ...@@ -1831,10 +1832,6 @@ static void defect7374_enable_data_eps_zero(struct net2280 *dev)
scratch |= DEFECT7374_FSM_WAITING_FOR_CONTROL_READ; scratch |= DEFECT7374_FSM_WAITING_FOR_CONTROL_READ;
set_idx_reg(dev->regs, SCRATCH, scratch); set_idx_reg(dev->regs, SCRATCH, scratch);
} else{
ep_warn(dev, "Defect 7374 workaround soft will NOT operate");
ep_warn(dev, "It will operate on cold-reboot and SS connect");
}
} }
/* keeping it simple: /* keeping it simple:
...@@ -1885,21 +1882,13 @@ static void usb_reset_228x(struct net2280 *dev) ...@@ -1885,21 +1882,13 @@ static void usb_reset_228x(struct net2280 *dev)
static void usb_reset_338x(struct net2280 *dev) static void usb_reset_338x(struct net2280 *dev)
{ {
u32 tmp; u32 tmp;
u32 fsmvalue;
dev->gadget.speed = USB_SPEED_UNKNOWN; dev->gadget.speed = USB_SPEED_UNKNOWN;
(void)readl(&dev->usb->usbctl); (void)readl(&dev->usb->usbctl);
net2280_led_init(dev); net2280_led_init(dev);
fsmvalue = get_idx_reg(dev->regs, SCRATCH) & if (dev->bug7734_patched) {
(0xf << DEFECT7374_FSM_FIELD);
/* See if firmware needs to set up for workaround: */
if (fsmvalue != DEFECT7374_FSM_SS_CONTROL_READ) {
ep_info(dev, "%s: Defect 7374 FsmValue 0x%08x\n", __func__,
fsmvalue);
} else {
/* disable automatic responses, and irqs */ /* disable automatic responses, and irqs */
writel(0, &dev->usb->stdrsp); writel(0, &dev->usb->stdrsp);
writel(0, &dev->regs->pciirqenb0); writel(0, &dev->regs->pciirqenb0);
...@@ -1916,7 +1905,7 @@ static void usb_reset_338x(struct net2280 *dev) ...@@ -1916,7 +1905,7 @@ static void usb_reset_338x(struct net2280 *dev)
writel(~0, &dev->regs->irqstat0), writel(~0, &dev->regs->irqstat1); writel(~0, &dev->regs->irqstat0), writel(~0, &dev->regs->irqstat1);
if (fsmvalue == DEFECT7374_FSM_SS_CONTROL_READ) { if (dev->bug7734_patched) {
/* reset, and enable pci */ /* reset, and enable pci */
tmp = readl(&dev->regs->devinit) | tmp = readl(&dev->regs->devinit) |
BIT(PCI_ENABLE) | BIT(PCI_ENABLE) |
...@@ -1982,7 +1971,6 @@ static void usb_reinit_338x(struct net2280 *dev) ...@@ -1982,7 +1971,6 @@ static void usb_reinit_338x(struct net2280 *dev)
{ {
int i; int i;
u32 tmp, val; u32 tmp, val;
u32 fsmvalue;
static const u32 ne[9] = { 0, 1, 2, 3, 4, 1, 2, 3, 4 }; static const u32 ne[9] = { 0, 1, 2, 3, 4, 1, 2, 3, 4 };
static const u32 ep_reg_addr[9] = { 0x00, 0xC0, 0x00, 0xC0, 0x00, static const u32 ep_reg_addr[9] = { 0x00, 0xC0, 0x00, 0xC0, 0x00,
0x00, 0xC0, 0x00, 0xC0 }; 0x00, 0xC0, 0x00, 0xC0 };
...@@ -2020,14 +2008,7 @@ static void usb_reinit_338x(struct net2280 *dev) ...@@ -2020,14 +2008,7 @@ static void usb_reinit_338x(struct net2280 *dev)
dev->ep[0].stopped = 0; dev->ep[0].stopped = 0;
/* Link layer set up */ /* Link layer set up */
fsmvalue = get_idx_reg(dev->regs, SCRATCH) & if (dev->bug7734_patched) {
(0xf << DEFECT7374_FSM_FIELD);
/* See if driver needs to set up for workaround: */
if (fsmvalue != DEFECT7374_FSM_SS_CONTROL_READ)
ep_info(dev, "%s: Defect 7374 FsmValue %08x\n",
__func__, fsmvalue);
else {
tmp = readl(&dev->usb_ext->usbctl2) & tmp = readl(&dev->usb_ext->usbctl2) &
~(BIT(U1_ENABLE) | BIT(U2_ENABLE) | BIT(LTM_ENABLE)); ~(BIT(U1_ENABLE) | BIT(U2_ENABLE) | BIT(LTM_ENABLE));
writel(tmp, &dev->usb_ext->usbctl2); writel(tmp, &dev->usb_ext->usbctl2);
...@@ -2134,15 +2115,8 @@ static void ep0_start_228x(struct net2280 *dev) ...@@ -2134,15 +2115,8 @@ static void ep0_start_228x(struct net2280 *dev)
static void ep0_start_338x(struct net2280 *dev) static void ep0_start_338x(struct net2280 *dev)
{ {
u32 fsmvalue;
fsmvalue = get_idx_reg(dev->regs, SCRATCH) &
(0xf << DEFECT7374_FSM_FIELD);
if (fsmvalue != DEFECT7374_FSM_SS_CONTROL_READ) if (dev->bug7734_patched)
ep_info(dev, "%s: Defect 7374 FsmValue %08x\n", __func__,
fsmvalue);
else
writel(BIT(CLEAR_NAK_OUT_PACKETS_MODE) | writel(BIT(CLEAR_NAK_OUT_PACKETS_MODE) |
BIT(SET_EP_HIDE_STATUS_PHASE), BIT(SET_EP_HIDE_STATUS_PHASE),
&dev->epregs[0].ep_rsp); &dev->epregs[0].ep_rsp);
...@@ -2230,7 +2204,7 @@ static int net2280_start(struct usb_gadget *_gadget, ...@@ -2230,7 +2204,7 @@ static int net2280_start(struct usb_gadget *_gadget,
*/ */
net2280_led_active(dev, 1); net2280_led_active(dev, 1);
if (dev->quirks & PLX_SUPERSPEED) if ((dev->quirks & PLX_SUPERSPEED) && !dev->bug7734_patched)
defect7374_enable_data_eps_zero(dev); defect7374_enable_data_eps_zero(dev);
ep0_start(dev); ep0_start(dev);
...@@ -2552,6 +2526,7 @@ static void defect7374_workaround(struct net2280 *dev, struct usb_ctrlrequest r) ...@@ -2552,6 +2526,7 @@ static void defect7374_workaround(struct net2280 *dev, struct usb_ctrlrequest r)
* run after the next USB connection. * run after the next USB connection.
*/ */
scratch |= DEFECT7374_FSM_NON_SS_CONTROL_READ; scratch |= DEFECT7374_FSM_NON_SS_CONTROL_READ;
dev->bug7734_patched = 1;
goto restore_data_eps; goto restore_data_eps;
} }
...@@ -2565,6 +2540,7 @@ static void defect7374_workaround(struct net2280 *dev, struct usb_ctrlrequest r) ...@@ -2565,6 +2540,7 @@ static void defect7374_workaround(struct net2280 *dev, struct usb_ctrlrequest r)
if ((state >= (ACK_GOOD_NORMAL << STATE)) && if ((state >= (ACK_GOOD_NORMAL << STATE)) &&
(state <= (ACK_GOOD_MORE_ACKS_TO_COME << STATE))) { (state <= (ACK_GOOD_MORE_ACKS_TO_COME << STATE))) {
scratch |= DEFECT7374_FSM_SS_CONTROL_READ; scratch |= DEFECT7374_FSM_SS_CONTROL_READ;
dev->bug7734_patched = 1;
break; break;
} }
...@@ -2904,7 +2880,7 @@ static void handle_stat0_irqs(struct net2280 *dev, u32 stat) ...@@ -2904,7 +2880,7 @@ static void handle_stat0_irqs(struct net2280 *dev, u32 stat)
cpu_to_le32s(&u.raw[0]); cpu_to_le32s(&u.raw[0]);
cpu_to_le32s(&u.raw[1]); cpu_to_le32s(&u.raw[1]);
if (dev->quirks & PLX_SUPERSPEED) if ((dev->quirks & PLX_SUPERSPEED) && !dev->bug7734_patched)
defect7374_workaround(dev, u.r); defect7374_workaround(dev, u.r);
tmp = 0; tmp = 0;
...@@ -3418,9 +3394,12 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -3418,9 +3394,12 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
fsmvalue = get_idx_reg(dev->regs, SCRATCH) & fsmvalue = get_idx_reg(dev->regs, SCRATCH) &
(0xf << DEFECT7374_FSM_FIELD); (0xf << DEFECT7374_FSM_FIELD);
/* See if firmware needs to set up for workaround: */ /* See if firmware needs to set up for workaround: */
if (fsmvalue == DEFECT7374_FSM_SS_CONTROL_READ) if (fsmvalue == DEFECT7374_FSM_SS_CONTROL_READ) {
dev->bug7734_patched = 1;
writel(0, &dev->usb->usbctl); writel(0, &dev->usb->usbctl);
} else{ } else
dev->bug7734_patched = 0;
} else {
dev->enhanced_mode = 0; dev->enhanced_mode = 0;
dev->n_ep = 7; dev->n_ep = 7;
/* put into initial config, link up all endpoints */ /* put into initial config, link up all endpoints */
......
...@@ -165,7 +165,8 @@ struct net2280 { ...@@ -165,7 +165,8 @@ struct net2280 {
ltm_enable:1, ltm_enable:1,
wakeup_enable:1, wakeup_enable:1,
selfpowered:1, selfpowered:1,
addressed_state:1; addressed_state:1,
bug7734_patched:1;
u16 chiprev; u16 chiprev;
int enhanced_mode; int enhanced_mode;
int n_ep; int n_ep;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment