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

usb: musb: Add missing PM suspend and resume functions for 2430 glue

Looks like we are missing suspend and resume functions for pm_ops that
are needed to idle the hardware for system suspend for 2430 glue layer.

We can rely on the driver internal PM runtime state, and call driver
functions to idle the hardware on suspend if needed. There is no need
to add a dependency to PM runtime for system suspend here.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Link: https://lore.kernel.org/r/20210518074449.17070-1-tony@atomide.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Tony Lindgren and committed by
Greg Kroah-Hartman
62d472d8 c5c7489d

+32
+32
drivers/usb/musb/omap2430.c
··· 33 33 enum musb_vbus_id_status status; 34 34 struct work_struct omap_musb_mailbox_work; 35 35 struct device *control_otghs; 36 + unsigned int is_runtime_suspended:1; 37 + unsigned int needs_resume:1; 36 38 }; 37 39 #define glue_to_musb(g) platform_get_drvdata(g->musb) 38 40 ··· 461 459 phy_power_off(musb->phy); 462 460 phy_exit(musb->phy); 463 461 462 + glue->is_runtime_suspended = 1; 463 + 464 464 return 0; 465 465 } 466 466 ··· 484 480 /* Wait for musb to get oriented. Otherwise we can get babble */ 485 481 usleep_range(200000, 250000); 486 482 483 + glue->is_runtime_suspended = 0; 484 + 487 485 return 0; 486 + } 487 + 488 + static int omap2430_suspend(struct device *dev) 489 + { 490 + struct omap2430_glue *glue = dev_get_drvdata(dev); 491 + 492 + if (glue->is_runtime_suspended) 493 + return 0; 494 + 495 + glue->needs_resume = 1; 496 + 497 + return omap2430_runtime_suspend(dev); 498 + } 499 + 500 + static int omap2430_resume(struct device *dev) 501 + { 502 + struct omap2430_glue *glue = dev_get_drvdata(dev); 503 + 504 + if (!glue->needs_resume) 505 + return 0; 506 + 507 + glue->needs_resume = 0; 508 + 509 + return omap2430_runtime_resume(dev); 488 510 } 489 511 490 512 static const struct dev_pm_ops omap2430_pm_ops = { 491 513 .runtime_suspend = omap2430_runtime_suspend, 492 514 .runtime_resume = omap2430_runtime_resume, 515 + .suspend = omap2430_suspend, 516 + .resume = omap2430_resume, 493 517 }; 494 518 495 519 #define DEV_PM_OPS (&omap2430_pm_ops)