From patchwork Thu Apr 5 12:44:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 150950 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-vb0-f56.google.com (mail-vb0-f56.google.com [209.85.212.56]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id DD7CFB705C for ; Thu, 5 Apr 2012 22:44:41 +1000 (EST) Received: by vbis24 with SMTP id s24sf1029740vbi.11 for ; Thu, 05 Apr 2012 05:44:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=mime-version:x-beenthere:received-spf:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references:x-sa-exim-connect-ip :x-sa-exim-mail-from:x-sa-exim-scanned:x-ptx-original-recipient :x-original-sender:x-original-authentication-results: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=PCEDwYfOjRaTS6nkwfU+4BvHmLINdLzLDvNhXI1qNRo=; b=o9DmPsxGvNogEQIRCB5FKARmHv7KMi1CMoJik6l69/6I9ruFBFmn3BrZM9/gMz5fVo k6izyZTX2wfa1N2nIRlvBuHyL2UJXKknoecZrfkuDdtcuBdv3ylDul3MKDds1qZMUID8 xp7sJ4SMHiu+ICPJxykO5zCGC+dhSUL8k8cpk= Received: by 10.50.154.130 with SMTP id vo2mr1209170igb.1.1333629877619; Thu, 05 Apr 2012 05:44:37 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.50.217.197 with SMTP id pa5ls9913481igc.4.canary; Thu, 05 Apr 2012 05:44:37 -0700 (PDT) Received: by 10.43.53.73 with SMTP id vp9mr1380583icb.0.1333629877313; Thu, 05 Apr 2012 05:44:37 -0700 (PDT) Received: by 10.43.53.73 with SMTP id vp9mr1380582icb.0.1333629877302; Thu, 05 Apr 2012 05:44:37 -0700 (PDT) Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de. [92.198.50.35]) by gmr-mx.google.com with ESMTPS id eo1si3021686igc.0.2012.04.05.05.44.37 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Apr 2012 05:44:37 -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; Received: from katana.hi.pengutronix.de ([2001:6f8:1178:2:221:70ff:fe71:1890] helo=pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1SFm3H-0000hY-Eo; Thu, 05 Apr 2012 14:44:35 +0200 From: Wolfram Sang To: rtc-linux@googlegroups.com Cc: Andrew Morton , Alessandro Zummo , Wolfram Sang Subject: [rtc-linux] [PATCH 2/2] rtc: ds1307: add trickle charger support Date: Thu, 5 Apr 2012 14:44:13 +0200 Message-Id: <1333629853-32696-3-git-send-email-w.sang@pengutronix.de> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1333629853-32696-1-git-send-email-w.sang@pengutronix.de> References: <1333629853-32696-1-git-send-email-w.sang@pengutronix.de> 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 X-Original-Sender: w.sang@pengutronix.de X-Original-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 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: , Some DS13XX devices have "trickle chargers". Its configuration register is at different locations, the setup is the same, though. Since the configuration is board specific, introduce a platform_data to this driver. Tested with a DS1339 on a custom board. Signed-off-by: Wolfram Sang --- drivers/rtc/rtc-ds1307.c | 19 ++++++++++++++++--- include/linux/rtc/ds1307.h | 22 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 include/linux/rtc/ds1307.h diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 51f1fd7..dadd410 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -17,8 +17,7 @@ #include #include #include - - +#include /* * We can't determine type by probing, but if we expect pre-Linux code @@ -92,7 +91,8 @@ enum ds_type { # define DS1337_BIT_A2I 0x02 # define DS1337_BIT_A1I 0x01 #define DS1339_REG_ALARM1_SECS 0x07 -#define DS1339_REG_TRICKLE 0x10 + +#define DS13XX_TRICKLE_CHARGER_MAGIC 0xa0 #define RX8025_REG_CTRL1 0x0e # define RX8025_BIT_2412 0x20 @@ -124,6 +124,7 @@ struct chip_desc { unsigned alarm:1; u16 nvram_offset; u16 nvram_size; + u16 trickle_charger_reg; }; static const struct chip_desc chips[last_ds_type] = { @@ -140,6 +141,13 @@ static const struct chip_desc chips[last_ds_type] = { }, [ds_1339] = { .alarm = 1, + .trickle_charger_reg = 0x10, + }, + [ds_1340] = { + .trickle_charger_reg = 0x08, + }, + [ds_1388] = { + .trickle_charger_reg = 0x0a, }, [ds_3231] = { .alarm = 1, @@ -619,6 +627,7 @@ 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; + struct ds1307_platform_data *pdata = client->dev.platform_data; static const int bbsqi_bitpos[] = { [ds_1337] = 0, [ds_1339] = DS1339_BIT_BBSQI, @@ -638,6 +647,10 @@ static int __devinit ds1307_probe(struct i2c_client *client, ds1307->client = client; ds1307->type = id->driver_data; + if (pdata && pdata->trickle_charger_setup && chip->trickle_charger_reg) + i2c_smbus_write_byte_data(client, chip->trickle_charger_reg, + DS13XX_TRICKLE_CHARGER_MAGIC | pdata->trickle_charger_setup); + buf = ds1307->regs; if (i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { ds1307->read_block_data = i2c_smbus_read_i2c_block_data; diff --git a/include/linux/rtc/ds1307.h b/include/linux/rtc/ds1307.h new file mode 100644 index 0000000..291b1c4 --- /dev/null +++ b/include/linux/rtc/ds1307.h @@ -0,0 +1,22 @@ +/* + * ds1307.h - platform_data for the ds1307 (and variants) rtc driver + * (C) Copyright 2012 by Wolfram Sang, Pengutronix e.K. + * same license as the driver + */ + +#ifndef _LINUX_DS1307_H +#define _LINUX_DS1307_H + +#include + +#define DS1307_TRICKLE_CHARGER_250_OHM 0x01 +#define DS1307_TRICKLE_CHARGER_2K_OHM 0x02 +#define DS1307_TRICKLE_CHARGER_4K_OHM 0x03 +#define DS1307_TRICKLE_CHARGER_NO_DIODE 0x04 +#define DS1307_TRICKLE_CHARGER_DIODE 0x08 + +struct ds1307_platform_data { + u8 trickle_charger_setup; +}; + +#endif /* _LINUX_DS1307_H */