From patchwork Fri Sep 23 22:57:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Anders X-Patchwork-Id: 116194 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-yx0-f184.google.com (mail-yx0-f184.google.com [209.85.213.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 6C405B6F81 for ; Sat, 24 Sep 2011 08:57:28 +1000 (EST) Received: by yxl11 with SMTP id 11sf4351565yxl.11 for ; Fri, 23 Sep 2011 15:57:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:x-yahoo-newman-property:x-yahoo-newman-id :x-ymail-osg:x-mailer:message-id:date:from:reply-to:subject:to:cc :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-google-group-id:list-post :list-help:list-archive:sender:list-subscribe:list-unsubscribe :content-type:content-transfer-encoding; bh=6TLfyEtPoN4LOtCral/NUMHcSCwOfPQgE0paT+cBU2g=; b=VtrCjWUaSGjQMV83AMUgugRJ5FlkQI9cZO93Hb4Uel7P8R4lgIQBqnJ77qMEf91bxm AdxwIew9cQAi2FHh6NBomlBIxq7F7DfQcHxbWhk/Fwb7q9OALP2FK/1uhryZlRi4bjJU nSN2prCxjMLj4CnucPHSNdOpCfp1sAiGrkW9c= Received: by 10.150.163.8 with SMTP id l8mr155654ybe.52.1316818645480; Fri, 23 Sep 2011 15:57:25 -0700 (PDT) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.231.123.88 with SMTP id o24ls1088618ibr.3.gmail; Fri, 23 Sep 2011 15:57:24 -0700 (PDT) Received: by 10.42.144.133 with SMTP id b5mr1706077icv.35.1316818644070; Fri, 23 Sep 2011 15:57:24 -0700 (PDT) Received: by 10.42.144.133 with SMTP id b5mr1706076icv.35.1316818644060; Fri, 23 Sep 2011 15:57:24 -0700 (PDT) Received: from nm14-vm3.bullet.mail.ne1.yahoo.com (nm14-vm3.bullet.mail.ne1.yahoo.com. [98.138.91.144]) by gmr-mx.google.com with SMTP id q7si2299991icc.4.2011.09.23.15.57.23; Fri, 23 Sep 2011 15:57:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dave123rad@yahoo.com designates 98.138.91.144 as permitted sender) client-ip=98.138.91.144; Received: from [98.138.90.57] by nm14.bullet.mail.ne1.yahoo.com with NNFMP; 23 Sep 2011 22:57:23 -0000 Received: from [98.138.88.234] by tm10.bullet.mail.ne1.yahoo.com with NNFMP; 23 Sep 2011 22:57:23 -0000 Received: from [127.0.0.1] by omp1034.mail.ne1.yahoo.com with NNFMP; 23 Sep 2011 22:57:23 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 714575.11613.bm@omp1034.mail.ne1.yahoo.com Received: (qmail 91100 invoked by uid 60001); 23 Sep 2011 22:57:23 -0000 X-YMail-OSG: E83B9BYVM1nqVfKqC3Tkj0VR57FceO0zkhsVUr5aP7el3ht hAcwVCckDni82jc0KvFJPpv_f6hVCIWfFNOiBjobmBLkdivqUXnJA_gsmKhv 5ukxgpfV883CFjzr5PQGlmYs2dZMBtHNEbZ_I_dx33G_xhrXINP9GosTvkZq K2FJB5C1uc9K7VtcyFIUX1SdnzkF5SmLp0NgBs3q_vgSLuBwn5EU4GTbFkhE SzDUqIB8wN.K1wg.DijjRgvW8IFbgoZha_BOpowEcD2o0SNIaIyNgT1Tn8NK 1qO6WaBMlcZXsBjr2kO6ERKwimPhy0_6PVJZ8.lp9KU.1iVTLufhohF4RDIK 4bgzCDRKraiLcFGw1Vkp2OH66x8Yme4skHcrebsH2ATRLOTWWJTNYT4md3ov ZdNPsZFBmI5NaSIyRPA-- Received: from [192.94.92.14] by web120018.mail.ne1.yahoo.com via HTTP; Fri, 23 Sep 2011 15:57:23 PDT X-Mailer: YahooMailWebService/0.8.114.317681 Message-ID: <1316818643.55745.YahooMailNeo@web120018.mail.ne1.yahoo.com> Date: Fri, 23 Sep 2011 15:57:23 -0700 (PDT) From: David Anders Reply-To: rtc-linux@googlegroups.com Subject: [rtc-linux] [PATCH] rtc: add initial support for mcp7941x parts To: "rtc-linux@googlegroups.com" Cc: "w.sang@pengutronix.de" , "a.zummo@towertech.it" , "danders@tincantools.com" MIME-Version: 1.0 X-Original-Sender: dave123rad@yahoo.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of dave123rad@yahoo.com designates 98.138.91.144 as permitted sender) smtp.mail=dave123rad@yahoo.com; dkim=pass (test mode) header.i=@yahoo.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: , From 691dc915a8de8cb52c5d3e5a4e27c724d393f2d4 Mon Sep 17 00:00:00 2001 From: David Anders Date: Fri, 23 Sep 2011 17:32:47 -0500 Subject: [PATCH] rtc: add initial support for mcp7941x parts this patch adds initial support for the microchip mcp7941x series of real time clocks. the mcp7941x series is generally compatible with the ds1307 and ds1337 rtc devices from dallas semiconductor. minor differences include a backup battery enable bit, and the polarity of the oscillator enable bit. Signed-off-by: David Anders ---  drivers/rtc/rtc-ds1307.c |   27 +++++++++++++++++++++++++++  1 files changed, 27 insertions(+), 0 deletions(-) diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index b2005b4..52a8c8c 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -35,6 +35,7 @@ enum ds_type {      ds_3231,      m41t00,      rx_8025, +    mcp7941x,      // rs5c372 too?  different address...  };   @@ -42,6 +43,7 @@ enum ds_type {  /* RTC registers don't differ much, except for the century flag */  #define DS1307_REG_SECS        0x00    /* 00-59 */  #    define DS1307_BIT_CH        0x80 +#    define MCP7941X_BIT_ST        0x80  #    define DS1340_BIT_nEOSC        0x80  #define DS1307_REG_MIN        0x01    /* 00-59 */  #define DS1307_REG_HOUR        0x02    /* 00-23, or 1-12{am,pm} */ @@ -50,6 +52,7 @@ enum ds_type {  #    define DS1340_BIT_CENTURY_EN    0x80    /* in REG_HOUR */  #    define DS1340_BIT_CENTURY    0x40    /* in REG_HOUR */  #define DS1307_REG_WDAY        0x03    /* 01-07 */ +#    define MCP7941X_BIT_VBATEN    0x08  #define DS1307_REG_MDAY        0x04    /* 01-31 */  #define DS1307_REG_MONTH    0x05    /* 01-12 */  #    define DS1337_BIT_CENTURY    0x80    /* in REG_MONTH */ @@ -138,6 +141,8 @@ static const struct chip_desc chips[] = {  [m41t00] = {  },  [rx_8025] = { +}, +[mcp7941x] = {  }, };    static const struct i2c_device_id ds1307_id[] = { @@ -151,6 +156,7 @@ static const struct i2c_device_id ds1307_id[] = {      { "m41t00", m41t00 },      { "pt7c4338", ds_1307 },      { "rx8025", rx_8025 }, +    { "mcp7941x", mcp7941x },      { }  };  MODULE_DEVICE_TABLE(i2c, ds1307_id); @@ -365,6 +371,10 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t)          buf[DS1307_REG_HOUR] |= DS1340_BIT_CENTURY_EN                  | DS1340_BIT_CENTURY;          break; +    case mcp7941x: +        buf[DS1307_REG_SECS] |= MCP7941X_BIT_ST; +        buf[DS1307_REG_WDAY] |= MCP7941X_BIT_VBATEN; +        break;      default:          break;      } @@ -809,6 +819,23 @@ read_rtc:              dev_warn(&client->dev, "SET TIME!\n");          }          break; +    case mcp7941x: +        /* make sure that the backup battery is enabled */ +        if (!(ds1307->regs[DS1307_REG_WDAY] & MCP7941X_BIT_VBATEN)) { +            i2c_smbus_write_byte_data(client, DS1307_REG_WDAY, +                    ds1307->regs[DS1307_REG_WDAY] +                    | MCP7941X_BIT_VBATEN); +        } + +        /* clock halted?  turn it on, so clock can tick. */ +        if (!(tmp & MCP7941X_BIT_ST)) { +            i2c_smbus_write_byte_data(client, DS1307_REG_SECS, +                    MCP7941X_BIT_ST); +            dev_warn(&client->dev, "SET TIME!\n"); +            goto read_rtc; +        } + +        break;      case rx_8025:      case ds_1337:      case ds_1339: