Message ID | 1316817861.58485.YahooMailClassic@web120012.mail.ne1.yahoo.com |
---|---|
State | Superseded |
Headers | show |
On Fri, Sep 23, 2011 at 03:44:21PM -0700, David Anders wrote: > From 691dc915a8de8cb52c5d3e5a4e27c724d393f2d4 Mon Sep 17 00:00:00 2001 > From: David Anders <danders@tincantools.com> > 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. So, using at24 on the other addresses worked? > Signed-off-by: David Anders <danders@tincantools.com> > --- > 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, That breaks the alphabetical sorting. Happened in other places, too, please check. > // 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; Why did you put it here? ... > 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; > + } ... It needs to be done here I'd say. > + > + break; > case rx_8025: > case ds_1337: > case ds_1339: > -- > 1.7.0.4 > Regards, Wolfram
On Sep 24, 2:06 am, Wolfram Sang <w.s...@pengutronix.de> wrote: > On Fri, Sep 23, 2011 at 03:44:21PM -0700, David Anders wrote: > > From 691dc915a8de8cb52c5d3e5a4e27c724d393f2d4 Mon Sep 17 00:00:00 2001 > > From: David Anders <dand...@tincantools.com> > > 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. > > So, using at24 on the other addresses worked? > yes that was already working prior to my posting on the rtc-list. > > Signed-off-by: David Anders <dand...@tincantools.com> > > --- > > 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, > > That breaks the alphabetical sorting. Happened in other places, too, please > check. > i'll correct that and resubmit. i find some subsystem prefer to add to the bottom, and some prefer to have alphabetical. > > > > // 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; > > Why did you put it here? ... similar to how the DS1337 and DS1340 need to have these bits reset each time the set_time is called as the valued written to these registers isn't masked in anyway. > > > > > 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; > > + } > > ... It needs to be done here I'd say. > > > + > > + break; > > case rx_8025: > > case ds_1337: > > case ds_1339: > > -- > > 1.7.0.4 > > Regards, > > Wolfram > > -- > Pengutronix e.K. | Wolfram Sang | > Industrial Linux Solutions |http://www.pengutronix.de/ | > > signature.asc > < 1KViewDownload i will prepare v2 of the patch and get it submitted to the list. thanks Dave
From 691dc915a8de8cb52c5d3e5a4e27c724d393f2d4 Mon Sep 17 00:00:00 2001 From: David Anders <danders@tincantools.com> 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 <danders@tincantools.com> --- 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: -- 1.7.0.4