Skip to content

Commit e294092

Browse files
pawellcdnsgregkh
authored andcommitted
usb: cdns2: Fix controller reset issue
Patch fixes the procedure of resetting controller. The CPUCTRL register is write only and reading returns 0. Waiting for reset to complite is incorrect. Fixes: 3eb1f1e ("usb: cdns2: Add main part of Cadence USBHS driver") cc: [email protected] Signed-off-by: Pawel Laszczak <[email protected]> Link: https://lore.kernel.org/r/PH7PR07MB9538D56D75F1F399D0BB96F0DD922@PH7PR07MB9538.namprd07.prod.outlook.com Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9149c9b commit e294092

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

drivers/usb/gadget/udc/cdns2/cdns2-gadget.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,7 +2251,6 @@ static int cdns2_gadget_start(struct cdns2_device *pdev)
22512251
{
22522252
u32 max_speed;
22532253
void *buf;
2254-
int val;
22552254
int ret;
22562255

22572256
pdev->usb_regs = pdev->regs;
@@ -2261,14 +2260,9 @@ static int cdns2_gadget_start(struct cdns2_device *pdev)
22612260
pdev->adma_regs = pdev->regs + CDNS2_ADMA_REGS_OFFSET;
22622261

22632262
/* Reset controller. */
2264-
set_reg_bit_8(&pdev->usb_regs->cpuctrl, CPUCTRL_SW_RST);
2265-
2266-
ret = readl_poll_timeout_atomic(&pdev->usb_regs->cpuctrl, val,
2267-
!(val & CPUCTRL_SW_RST), 1, 10000);
2268-
if (ret) {
2269-
dev_err(pdev->dev, "Error: reset controller timeout\n");
2270-
return -EINVAL;
2271-
}
2263+
writeb(CPUCTRL_SW_RST | CPUCTRL_UPCLK | CPUCTRL_WUEN,
2264+
&pdev->usb_regs->cpuctrl);
2265+
usleep_range(5, 10);
22722266

22732267
usb_initialize_gadget(pdev->dev, &pdev->gadget, NULL);
22742268

drivers/usb/gadget/udc/cdns2/cdns2-gadget.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,17 @@ struct cdns2_usb_regs {
292292
#define SPEEDCTRL_HSDISABLE BIT(7)
293293

294294
/* CPUCTRL- bitmasks. */
295+
/* UP clock enable */
296+
#define CPUCTRL_UPCLK BIT(0)
295297
/* Controller reset bit. */
296298
#define CPUCTRL_SW_RST BIT(1)
299+
/**
300+
* If the wuen bit is ‘1’, the upclken is automatically set to ‘1’ after
301+
* detecting rising edge of wuintereq interrupt. If the wuen bit is ‘0’,
302+
* the wuintereq interrupt is ignored.
303+
*/
304+
#define CPUCTRL_WUEN BIT(7)
305+
297306

298307
/**
299308
* struct cdns2_adma_regs - ADMA controller registers.

0 commit comments

Comments
 (0)