Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: cdns3: imx: add power lost support for system resume

imx need special handle when controller lost power

Signed-off-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Frank Li <frank.li@nxp.com>
Signed-off-by: Peter Chen <peter.chen@kernel.org>

authored by

Frank Li and committed by
Peter Chen
2fd69eca 2cf2581c

+34
+34
drivers/usb/cdns3/cdns3-imx.c
··· 361 361 362 362 return 0; 363 363 } 364 + 365 + 366 + /* Indicate if the controller was power lost before */ 367 + static inline bool cdns_imx_is_power_lost(struct cdns_imx *data) 368 + { 369 + u32 value; 370 + 371 + value = cdns_imx_readl(data, USB3_CORE_CTRL1); 372 + if ((value & SW_RESET_MASK) == ALL_SW_RESET) 373 + return true; 374 + else 375 + return false; 376 + } 377 + 378 + static int cdns_imx_system_resume(struct device *dev) 379 + { 380 + struct cdns_imx *data = dev_get_drvdata(dev); 381 + int ret; 382 + 383 + ret = cdns_imx_resume(dev); 384 + if (ret) 385 + return ret; 386 + 387 + if (cdns_imx_is_power_lost(data)) { 388 + dev_dbg(dev, "resume from power lost\n"); 389 + ret = cdns_imx_noncore_init(data); 390 + if (ret) 391 + cdns_imx_suspend(dev); 392 + } 393 + 394 + return ret; 395 + } 396 + 364 397 #else 365 398 static int cdns_imx_platform_suspend(struct device *dev, 366 399 bool suspend, bool wakeup) ··· 405 372 406 373 static const struct dev_pm_ops cdns_imx_pm_ops = { 407 374 SET_RUNTIME_PM_OPS(cdns_imx_suspend, cdns_imx_resume, NULL) 375 + SET_SYSTEM_SLEEP_PM_OPS(cdns_imx_suspend, cdns_imx_system_resume) 408 376 }; 409 377 410 378 static const struct of_device_id cdns_imx_of_match[] = {