From patchwork Thu Dec 3 12:57:29 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonyoung Shim X-Patchwork-Id: 64510 X-Patchwork-Delegate: dougsland@redhat.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 nB3CvQJt019095 for ; Thu, 3 Dec 2009 12:57:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754267AbZLCM5X (ORCPT ); Thu, 3 Dec 2009 07:57:23 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754261AbZLCM5X (ORCPT ); Thu, 3 Dec 2009 07:57:23 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:33040 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754131AbZLCM5W (ORCPT ); Thu, 3 Dec 2009 07:57:22 -0500 Received: from epmmp1 (mailout1.samsung.com [203.254.224.24]) by mailout1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTP id <0KU200C85UNSNO@mailout1.samsung.com> for linux-media@vger.kernel.org; Thu, 03 Dec 2009 21:57:28 +0900 (KST) Received: from TNRNDGASPAPP1.tn.corp.samsungelectronics.net ([165.213.149.150]) by mmp1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0KU200KSSUNS31@mmp1.samsung.com> for linux-media@vger.kernel.org; Thu, 03 Dec 2009 21:57:28 +0900 (KST) Received: from [10.89.8.132] ([10.89.8.132]) by TNRNDGASPAPP1.tn.corp.samsungelectronics.net with Microsoft SMTPSVC(6.0.3790.3959); Thu, 03 Dec 2009 21:57:28 +0900 Date: Thu, 03 Dec 2009 21:57:29 +0900 From: Joonyoung Shim Subject: [PATCH v2 3/3] radio-si470x: support PM functions To: linux-media@vger.kernel.org Cc: tobias.lorenz@gmx.net, kyungmin.park@samsung.com Message-id: <4B17B5B9.6070409@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 7BIT User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) X-OriginalArrivalTime: 03 Dec 2009 12:57:28.0543 (UTC) FILETIME=[2B2606F0:01CA7418] Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c b/drivers/media/radio/si470x/radio-si470x-i2c.c index 77532e6..4c6e586 100644 --- a/drivers/media/radio/si470x/radio-si470x-i2c.c +++ b/drivers/media/radio/si470x/radio-si470x-i2c.c @@ -486,6 +486,44 @@ static __devexit int si470x_i2c_remove(struct i2c_client *client) } +#ifdef CONFIG_PM +/* + * si470x_i2c_suspend - suspend the device + */ +static int si470x_i2c_suspend(struct i2c_client *client, pm_message_t mesg) +{ + struct si470x_device *radio = i2c_get_clientdata(client); + + /* power down */ + radio->registers[POWERCFG] |= POWERCFG_DISABLE; + if (si470x_set_register(radio, POWERCFG) < 0) + return -EIO; + + return 0; +} + + +/* + * si470x_i2c_resume - resume the device + */ +static int si470x_i2c_resume(struct i2c_client *client) +{ + struct si470x_device *radio = i2c_get_clientdata(client); + + /* power up : need 110ms */ + radio->registers[POWERCFG] |= POWERCFG_ENABLE; + if (si470x_set_register(radio, POWERCFG) < 0) + return -EIO; + msleep(110); + + return 0; +} +#else +#define si470x_i2c_suspend NULL +#define si470x_i2c_resume NULL +#endif + + /* * si470x_i2c_driver - i2c driver interface */ @@ -496,6 +534,8 @@ static struct i2c_driver si470x_i2c_driver = { }, .probe = si470x_i2c_probe, .remove = __devexit_p(si470x_i2c_remove), + .suspend = si470x_i2c_suspend, + .resume = si470x_i2c_resume, .id_table = si470x_i2c_id, };