From patchwork Sat Sep 5 01:41:42 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dasgupta, Romit" X-Patchwork-Id: 45914 X-Patchwork-Delegate: me@felipebalbi.com Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n851fObt005606 for ; Sat, 5 Sep 2009 01:41:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934532AbZIEBly (ORCPT ); Fri, 4 Sep 2009 21:41:54 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S934489AbZIEBly (ORCPT ); Fri, 4 Sep 2009 21:41:54 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:60819 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934360AbZIEBlx convert rfc822-to-8bit (ORCPT ); Fri, 4 Sep 2009 21:41:53 -0400 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id n851fi3G026522; Fri, 4 Sep 2009 20:41:50 -0500 Received: from dbde71.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id n851fhVW019476; Sat, 5 Sep 2009 07:11:43 +0530 (IST) Received: from dbde02.ent.ti.com ([172.24.170.145]) by dbde71.ent.ti.com ([172.24.170.149]) with mapi; Sat, 5 Sep 2009 07:11:43 +0530 From: "Dasgupta, Romit" To: "Pandita, Vikram" , "linux-usb@vger.kernel.org" CC: "linux-omap@vger.kernel.org" , "david-b@pacbell.net" , "Gupta, Ajay Kumar" , "Gadiyar, Anand" , "felipe.balbi@nokia.com" Date: Sat, 5 Sep 2009 07:11:42 +0530 Subject: RE: [PATCH 1/3] USB: musb: All each platform to have power hooks Thread-Topic: [PATCH 1/3] USB: musb: All each platform to have power hooks Thread-Index: AcottQeNcSOK3/kdSd694CCngjJUHgAFAyKZ Message-ID: References: <1252105484-18966-1-git-send-email-vikram.pandita@ti.com> In-Reply-To: <1252105484-18966-1-git-send-email-vikram.pandita@ti.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org All the platform suspend/resume routines that have been separated out looks same. What about introducing .psuspend, .presume fields in struct musb and then from within musb_suspend() do the following? This way code duplication is reduced. if (musb->psuspend) musb->suspend(); if (musb->set_clock) musb->set_clock(musb->clock, 0); else clk_disable(musb->clock); spin_unlock_irqrestore(&musb->lock, flags); return 0; diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index f2f66eb..9a716b2 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c @@ -305,11 +305,26 @@ int __init musb_platform_init(struct musb *musb) int musb_platform_suspend(struct musb *musb) { + if (!musb->clock) + return 0; + + if (musb->set_clock) + musb->set_clock(musb->clock, 0); + else + clk_disable(musb->clock); + return 0; } int musb_platform_resume(struct musb *musb) { + if (!musb->clock) + return 0; + + if (musb->set_clock) + musb->set_clock(musb->clock, 1); + else + clk_enable(musb->clock); return 0; } diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index e16ff60..684e769 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c @@ -499,3 +499,27 @@ int musb_platform_exit(struct musb *musb) return 0; } + +int musb_platform_suspend(struct musb *musb) +{ + if (!musb->clock) + return 0; + + if (musb->set_clock) + musb->set_clock(musb->clock, 0); + else + clk_disable(musb->clock); + return 0; +} + +int musb_platform_resume(struct musb *musb) +{ + if (!musb->clock) + return 0; + + if (musb->set_clock) + musb->set_clock(musb->clock, 1); + else + clk_enable(musb->clock); + return 0; +} diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index c7c1ca0..ef97a0c 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -2186,13 +2186,9 @@ static int musb_suspend(struct platform_device *pdev, pm_message_t message) * they will even be wakeup-enabled. */ } - - if (musb->set_clock) - musb->set_clock(musb->clock, 0); - else - clk_disable(musb->clock); spin_unlock_irqrestore(&musb->lock, flags); - return 0; + + return musb_platform_suspend(musb); } static int musb_resume_early(struct platform_device *pdev) @@ -2202,16 +2198,11 @@ static int musb_resume_early(struct platform_device *pdev) if (!musb->clock) return 0; - if (musb->set_clock) - musb->set_clock(musb->clock, 1); - else - clk_enable(musb->clock); - /* for static cmos like DaVinci, register values were preserved * unless for some reason the whole soc powered down or the USB * module got reset through the PSC (vs just being disabled). */ - return 0; + return musb_platform_resume(musb); } #else diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 3487520..b957575 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -188,8 +188,6 @@ static void omap_set_vbus(struct musb *musb, int is_on) musb_readb(musb->mregs, MUSB_DEVCTL)); } -static int musb_platform_resume(struct musb *musb); - int musb_platform_set_mode(struct musb *musb, u8 musb_mode) { u8 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); @@ -281,7 +279,7 @@ int musb_platform_suspend(struct musb *musb) return 0; } -static int musb_platform_resume(struct musb *musb) +int musb_platform_resume(struct musb *musb) { u32 l; diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index 88b587c..7da5272 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c @@ -1169,3 +1169,27 @@ int musb_platform_exit(struct musb *musb) usb_nop_xceiv_unregister(); return 0; } + +int musb_platform_suspend(struct musb *musb) +{ + if (!musb->clock) + return 0; + + if (musb->set_clock) + musb->set_clock(musb->clock, 0); + else + clk_disable(musb->clock); + return 0; +} + +int musb_platform_resume(struct musb *musb) +{ + if (!musb->clock) + return 0; + + if (musb->set_clock) + musb->set_clock(musb->clock, 1); + else + clk_enable(musb->clock); + return 0; +} diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h index d437556..ede653f 100644 --- a/include/linux/usb/musb.h +++ b/include/linux/usb/musb.h @@ -105,4 +105,9 @@ extern int tusb6010_platform_retime(unsigned is_refclk); #endif /* OMAP2 */ +/* All MUSB platforms should export their suspend/resume functions */ +struct musb; +extern int musb_platform_suspend(struct musb *musb); +extern int musb_platform_resume(struct musb *musb); + #endif /* __LINUX_USB_MUSB_H */