diff options
author | Wolfram Sang <w.sang@pengutronix.de> | 2012-05-29 18:07:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-29 19:22:33 -0400 |
commit | eb86c3064b3c53837fdfea17df1483d825919894 (patch) | |
tree | 0d408fe43f43248477bb521fdd5b6856878199b0 /drivers/rtc/rtc-ds1307.c | |
parent | f8ae97019ff79559416dc2ae9c14af92c2054cba (diff) |
rtc: ds1307: add trickle charger support
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 <w.sang@pengutronix.de>
Cc: Alessandro Zummo <alessandro.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-ds1307.c')
-rw-r--r-- | drivers/rtc/rtc-ds1307.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 5dc1c7941199..836710ce750e 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -17,8 +17,7 @@ | |||
17 | #include <linux/string.h> | 17 | #include <linux/string.h> |
18 | #include <linux/rtc.h> | 18 | #include <linux/rtc.h> |
19 | #include <linux/bcd.h> | 19 | #include <linux/bcd.h> |
20 | 20 | #include <linux/rtc/ds1307.h> | |
21 | |||
22 | 21 | ||
23 | /* | 22 | /* |
24 | * We can't determine type by probing, but if we expect pre-Linux code | 23 | * We can't determine type by probing, but if we expect pre-Linux code |
@@ -92,7 +91,8 @@ enum ds_type { | |||
92 | # define DS1337_BIT_A2I 0x02 | 91 | # define DS1337_BIT_A2I 0x02 |
93 | # define DS1337_BIT_A1I 0x01 | 92 | # define DS1337_BIT_A1I 0x01 |
94 | #define DS1339_REG_ALARM1_SECS 0x07 | 93 | #define DS1339_REG_ALARM1_SECS 0x07 |
95 | #define DS1339_REG_TRICKLE 0x10 | 94 | |
95 | #define DS13XX_TRICKLE_CHARGER_MAGIC 0xa0 | ||
96 | 96 | ||
97 | #define RX8025_REG_CTRL1 0x0e | 97 | #define RX8025_REG_CTRL1 0x0e |
98 | # define RX8025_BIT_2412 0x20 | 98 | # define RX8025_BIT_2412 0x20 |
@@ -124,6 +124,7 @@ struct chip_desc { | |||
124 | unsigned alarm:1; | 124 | unsigned alarm:1; |
125 | u16 nvram_offset; | 125 | u16 nvram_offset; |
126 | u16 nvram_size; | 126 | u16 nvram_size; |
127 | u16 trickle_charger_reg; | ||
127 | }; | 128 | }; |
128 | 129 | ||
129 | static const struct chip_desc chips[last_ds_type] = { | 130 | static const struct chip_desc chips[last_ds_type] = { |
@@ -140,6 +141,13 @@ static const struct chip_desc chips[last_ds_type] = { | |||
140 | }, | 141 | }, |
141 | [ds_1339] = { | 142 | [ds_1339] = { |
142 | .alarm = 1, | 143 | .alarm = 1, |
144 | .trickle_charger_reg = 0x10, | ||
145 | }, | ||
146 | [ds_1340] = { | ||
147 | .trickle_charger_reg = 0x08, | ||
148 | }, | ||
149 | [ds_1388] = { | ||
150 | .trickle_charger_reg = 0x0a, | ||
143 | }, | 151 | }, |
144 | [ds_3231] = { | 152 | [ds_3231] = { |
145 | .alarm = 1, | 153 | .alarm = 1, |
@@ -619,6 +627,7 @@ static int __devinit ds1307_probe(struct i2c_client *client, | |||
619 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); | 627 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); |
620 | int want_irq = false; | 628 | int want_irq = false; |
621 | unsigned char *buf; | 629 | unsigned char *buf; |
630 | struct ds1307_platform_data *pdata = client->dev.platform_data; | ||
622 | static const int bbsqi_bitpos[] = { | 631 | static const int bbsqi_bitpos[] = { |
623 | [ds_1337] = 0, | 632 | [ds_1337] = 0, |
624 | [ds_1339] = DS1339_BIT_BBSQI, | 633 | [ds_1339] = DS1339_BIT_BBSQI, |
@@ -638,6 +647,10 @@ static int __devinit ds1307_probe(struct i2c_client *client, | |||
638 | ds1307->client = client; | 647 | ds1307->client = client; |
639 | ds1307->type = id->driver_data; | 648 | ds1307->type = id->driver_data; |
640 | 649 | ||
650 | if (pdata && pdata->trickle_charger_setup && chip->trickle_charger_reg) | ||
651 | i2c_smbus_write_byte_data(client, chip->trickle_charger_reg, | ||
652 | DS13XX_TRICKLE_CHARGER_MAGIC | pdata->trickle_charger_setup); | ||
653 | |||
641 | buf = ds1307->regs; | 654 | buf = ds1307->regs; |
642 | if (i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { | 655 | if (i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { |
643 | ds1307->read_block_data = i2c_smbus_read_i2c_block_data; | 656 | ds1307->read_block_data = i2c_smbus_read_i2c_block_data; |