From patchwork Wed Mar 11 14:53:56 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 24304 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from mail-qy0-f142.google.com (mail-qy0-f142.google.com [209.85.221.142]) by ozlabs.org (Postfix) with ESMTP id B4050DE114 for ; Thu, 12 Mar 2009 01:54:04 +1100 (EST) Received: by qyk6 with SMTP id 6so39211qyk.29 for ; Wed, 11 Mar 2009 07:54:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:received:x-sender:x-apparently-to :received:received:received-spf:authentication-results:received:from :to:cc:subject:date:message-id:x-mailer:x-sa-exim-connect-ip :x-sa-exim-mail-from:x-sa-exim-scanned:x-ptx-original-recipient :reply-to:sender:precedence:x-google-loop:mailing-list:list-id :list-post:list-help:list-unsubscribe:x-beenthere-env:x-beenthere; bh=JDhlVk5p9EjfRmnrShBiNz/T9j7ShQQjHdG8hKuoSCs=; b=K9oewLMFRO9aJO/Lvs9hx1g4MRiYaPQJy2gJrWZkDmw3WUD/ZM1ldM26VoOUwLQzup rqcKceNsutGgoNU2Ca5YelAplU3vrt9zIQpGSOLYXFCyHOVW0LLpgF2ykMpyHGRirzAh DMwdNGMK1X6BNQXZ8ZK47DrRAw+2CvCXiAmCg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-sender:x-apparently-to:received-spf:authentication-results:from :to:cc:subject:date:message-id:x-mailer:x-sa-exim-connect-ip :x-sa-exim-mail-from:x-sa-exim-scanned:x-ptx-original-recipient :reply-to:sender:precedence:x-google-loop:mailing-list:list-id :list-post:list-help:list-unsubscribe:x-beenthere-env:x-beenthere; b=Nmn/rij2sjRDs5b7uVa1gw4FmU9T9Fk0mQCMBh2+JRV7r9AK3r2T+6tb/EPwVoUs+k mh3ST1QAmxQoMN09LVK8Norn89wlhLKnkrua6pWaAODV6sdTXy+LmtCQcD43M45NyeeX 5IEhIxwRrp7o6DyuOYPK+5M+X5IvWOtt/Lx1Q= Received: by 10.224.19.135 with SMTP id a7mr1172707qab.13.1236783240316; Wed, 11 Mar 2009 07:54:00 -0700 (PDT) Received: by 10.176.150.42 with SMTP id x42gr2010yqd.0; Wed, 11 Mar 2009 07:54:00 -0700 (PDT) X-Sender: w.sang@pengutronix.de X-Apparently-To: rtc-linux@googlegroups.com Received: by 10.223.112.14 with SMTP id u14mr131586fap.18.1236783239323; Wed, 11 Mar 2009 07:53:59 -0700 (PDT) Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [92.198.50.35]) by gmr-mx.google.com with ESMTP id 13si632290fxm.0.2009.03.11.07.53.59; Wed, 11 Mar 2009 07:53:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of w.sang@pengutronix.de designates 92.198.50.35 as permitted sender) client-ip=92.198.50.35; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of w.sang@pengutronix.de designates 92.198.50.35 as permitted sender) smtp.mail=w.sang@pengutronix.de Received: from [2001:6f8:1178:2:221:70ff:fe71:1890] (helo=localhost) by metis.ext.pengutronix.de with esmtp (Exim 4.63) (envelope-from ) id 1LhPok-00016L-NM; Wed, 11 Mar 2009 15:53:58 +0100 From: Wolfram Sang To: rtc-linux@googlegroups.com Cc: a.zummo@towertech.it, dbrownell@users.sourceforge.net, Wolfram Sang Subject: [rtc-linux] [PATCH] rtc/ds1307: add ds3231 Date: Wed, 11 Mar 2009 15:53:56 +0100 Message-Id: <1236783236-10335-1-git-send-email-w.sang@pengutronix.de> X-Mailer: git-send-email 1.5.6.5 X-SA-Exim-Connect-IP: 2001:6f8:1178:2:221:70ff:fe71:1890 X-SA-Exim-Mail-From: w.sang@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: rtc-linux@googlegroups.com Reply-To: rtc-linux@googlegroups.com Sender: rtc-linux@googlegroups.com Precedence: bulk X-Google-Loop: groups Mailing-List: list rtc-linux@googlegroups.com; contact rtc-linux+owner@googlegroups.com List-Id: List-Post: List-Help: List-Unsubscribe: , X-BeenThere-Env: rtc-linux@googlegroups.com X-BeenThere: rtc-linux@googlegroups.com Add ds3231 variant. For that, the BBSQI usage was changed from a simple define into a lookup-array as it differs. This also removes writing to an unused bit in case of the ds1337. Signed-off-by: Wolfram Sang --- drivers/rtc/rtc-ds1307.c | 22 ++++++++++++++++++---- 1 files changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 7e5155e..ffc0bbb 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -30,6 +30,7 @@ enum ds_type { ds_1338, ds_1339, ds_1340, + ds_3231, m41t00, // rs5c372 too? different address... }; @@ -64,6 +65,7 @@ enum ds_type { #define DS1337_REG_CONTROL 0x0e # define DS1337_BIT_nEOSC 0x80 # define DS1339_BIT_BBSQI 0x20 +# define DS3231_BIT_BBSQW 0x40 /* same as BBSQI */ # define DS1337_BIT_RS2 0x10 # define DS1337_BIT_RS1 0x08 # define DS1337_BIT_INTCN 0x04 @@ -116,6 +118,9 @@ static const struct chip_desc chips[] = { }, [ds_1340] = { }, +[ds_3231] = { + .alarm = 1, +}, [m41t00] = { }, }; @@ -124,6 +129,7 @@ static const struct i2c_device_id ds1307_id[] = { { "ds1337", ds_1337 }, { "ds1338", ds_1338 }, { "ds1339", ds_1339 }, + { "ds3231", ds_3231 }, { "ds1340", ds_1340 }, { "m41t00", m41t00 }, { } @@ -265,6 +271,7 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t) switch (ds1307->type) { case ds_1337: case ds_1339: + case ds_3231: buf[DS1307_REG_MONTH] |= DS1337_BIT_CENTURY; break; case ds_1340: @@ -534,6 +541,11 @@ static int __devinit ds1307_probe(struct i2c_client *client, struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); int want_irq = false; unsigned char *buf; + const int bbsqi_bitpos[] = { + [ds_1337] = 0, + [ds_1339] = DS1339_BIT_BBSQI, + [ds_3231] = DS3231_BIT_BBSQW, + }; if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA | @@ -551,6 +563,7 @@ static int __devinit ds1307_probe(struct i2c_client *client, switch (ds1307->type) { case ds_1337: case ds_1339: + case ds_3231: /* has IRQ? */ if (ds1307->client->irq > 0 && chip->alarm) { INIT_WORK(&ds1307->work, ds1307_work); @@ -570,12 +583,12 @@ static int __devinit ds1307_probe(struct i2c_client *client, ds1307->regs[0] &= ~DS1337_BIT_nEOSC; /* Using IRQ? Disable the square wave and both alarms. - * For ds1339, be sure alarms can trigger when we're - * running on Vbackup (BBSQI); we assume ds1337 will - * ignore that bit + * For some variants, be sure alarms can trigger when we're + * running on Vbackup (BBSQI/BBSQW) */ if (want_irq) { - ds1307->regs[0] |= DS1337_BIT_INTCN | DS1339_BIT_BBSQI; + ds1307->regs[0] |= DS1337_BIT_INTCN + | bbsqi_bitpos[ds1307->type]; ds1307->regs[0] &= ~(DS1337_BIT_A2IE | DS1337_BIT_A1IE); } @@ -651,6 +664,7 @@ read_rtc: break; case ds_1337: case ds_1339: + case ds_3231: break; }