From patchwork Thu Mar 17 10:56:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Ni X-Patchwork-Id: 87361 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-gy0-f184.google.com (mail-gy0-f184.google.com [209.85.160.184]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id E72F5B6FD1 for ; Thu, 17 Mar 2011 21:56:13 +1100 (EST) Received: by gyg10 with SMTP id 10sf2089989gyg.11 for ; Thu, 17 Mar 2011 03:56:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:x-beenthere:mime-version:date:in-reply-to:x-ip :references:user-agent:x-http-useragent:message-id:subject:from:to :x-original-sender:reply-to:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type; bh=IpfFCeiHJbsjh1N0lJRC3crUTwRKtOem7D2l8iKoKTE=; b=XFXikcvlkEGoR/tQXK2p1LZzsDFRZJPrP7gJFj8uhycRtnEpXA7Br2AUx0/G8IPi04 H+Kc4RVDUiYwfZ0CDOrQhC9zrZNuGBJG+hTDR7a4AJqlzUUiJfL8Ez3K4nk/QbeQmeuu lSXZbISdiiFPoxDwQUJNFUBPqnfmjMjtZrecQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-beenthere:mime-version:date:in-reply-to:x-ip:references :user-agent:x-http-useragent:message-id:subject:from:to :x-original-sender:reply-to:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type; b=d3gnCiVpvmvptJRM8Uif54oK0s+wty040ETxLSzyaS3TYEYmoOT/9vNJZ4IiTJH5C7 LTwydkQ5r4lxlxraZNMahSL5h6b/Y1VXDyGeT3+oTNkKfiJHRhSyL8UkkA56xT+NFpa1 doMJ0QTjWRZXm1n38RpqgIMkTwAS1yed4dQ/I= Received: by 10.91.32.16 with SMTP id k16mr170986agj.12.1300359369275; Thu, 17 Mar 2011 03:56:09 -0700 (PDT) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.91.44.8 with SMTP id w8ls362362agj.5.p; Thu, 17 Mar 2011 03:56:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.91.108.1 with SMTP id k1mr176936agm.2.1300359368835; Thu, 17 Mar 2011 03:56:08 -0700 (PDT) Received: by r19g2000prm.googlegroups.com with HTTP; Thu, 17 Mar 2011 03:56:08 -0700 (PDT) Date: Thu, 17 Mar 2011 03:56:08 -0700 (PDT) In-Reply-To: <1299677042-4576-1-git-send-email-vwadekar@nvidia.com> X-IP: 203.18.50.4 References: <1299677042-4576-1-git-send-email-vwadekar@nvidia.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100402 Ubuntu/9.10 (karmic) Firefox/3.5.9,gzip(gfe) Message-ID: <0b35872f-1965-48e3-903e-37aac37f14ae@r19g2000prm.googlegroups.com> Subject: [rtc-linux] Re: mfd: tps6586x: add RTC driver for TI TPS6586x From: niwei To: rtc-linux X-Original-Sender: wni@nvidia.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , Hi, Varun As comments in https://code.google.com/p/chrome-os-partner/issues/detail?id=1937#makechanges, I update the rtc-tps6586x.c as following: 1. add OSC_SRC_SEL to select external crystal clock 2. there have some error when using the function tps6586x_update(), we should set the right value and mask 3. set alrm->enabled, this value didn't be set, but be used in some function 4. init the rtc->irq_en in the probe callback 5. add suspend/resume callback, and call disable/enable_irq_wake() in here. Please check it Thanks .name = "tps6586x-rtc", @@ -334,6 +355,8 @@ }, .probe = tps6586x_rtc_probe, .remove = __devexit_p(tps6586x_rtc_remove), + .suspend = tps6586x_rtc_suspend, + .resume = tps6586x_rtc_resume, }; static int __init tps6586x_rtc_init(void) @@ -351,4 +374,4 @@ MODULE_DESCRIPTION("TI TPS6586x RTC driver"); MODULE_AUTHOR("NVIDIA Corporation"); MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:rtc-tps6586x") +MODULE_ALIAS("platform:rtc-tps6586x"); --- rtc-tps6586x.c-orig 2011-03-17 18:19:37.783627510 +0800 +++ rtc-tps6586x.c 2011-03-17 18:43:51.293624552 +0800 @@ -30,6 +30,7 @@ #include #define RTC_CTRL 0xc0 +#define OSC_SRC_SEL BIT(6) /* select internal or external clock */ #define RTC_ENABLE BIT(5) /* enables alarm */ #define RTC_HIRES BIT(4) /* 1Khz or 32Khz updates */ #define RTC_ALARM1_HI 0xc1 @@ -180,6 +181,7 @@ seconds += rtc->epoch_start; rtc_time_to_tm(seconds, &alrm->time); + alrm->enabled = rtc->irq_en; return 0; } @@ -286,7 +288,8 @@ /* disable high-res mode, enable tick counting */ err = tps6586x_update(tps_dev, RTC_CTRL, - (RTC_ENABLE | RTC_HIRES), RTC_ENABLE); + (RTC_ENABLE | OSC_SRC_SEL), (RTC_ENABLE | OSC_SRC_SEL)); + if (err < 0) { dev_err(&pdev->dev, "unable to start counter\n"); goto fail; @@ -303,7 +306,7 @@ rtc->irq = -1; } else { disable_irq(rtc->irq); - enable_irq_wake(rtc->irq); + rtc->irq_en = false; } } @@ -327,6 +330,24 @@ return 0; } +static int tps6586x_rtc_suspend(struct platform_device *pdev, pm_message_t state) +{ + struct tps6586x_rtc *rtc = dev_get_drvdata(&pdev->dev); + + if (device_may_wakeup(pdev)) + enable_irq_wake(rtc->irq); + return 0; +} + +static int tps6586x_rtc_resume(struct platform_device *pdev) +{ + struct tps6586x_rtc *rtc = dev_get_drvdata(&pdev->dev); + + if (device_may_wakeup(pdev)) + disable_irq_wake(rtc->irq); + return 0; +} + static struct platform_driver tps6586x_rtc_driver = { .driver = {