* [PATCH 0/4] rtc: ds1307: add support for device tree and mcp7940x @ 2014-11-24 15:49 ` Tomas Novotny 0 siblings, 0 replies; 11+ messages in thread From: Tomas Novotny @ 2014-11-24 15:49 UTC (permalink / raw) To: Alessandro Zummo, rtc-linux-/JYPxA39Uh5TLH3MbocFFw Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Tomas Novotny This series is tested with MCP79401 and it is based on 3.18-rc6. Tomas Novotny (4): rtc: ds1307: add support for mcp7940x chips of: add vendor prefix for Pericom Technology rtc: ds1307: add device tree bindings documentation rtc: ds1307: add device tree support .../devicetree/bindings/rtc/maxim,ds1307.txt | 23 ++++ .../devicetree/bindings/vendor-prefixes.txt | 1 + drivers/rtc/rtc-ds1307.c | 149 ++++++++++++--------- 3 files changed, 110 insertions(+), 63 deletions(-) create mode 100644 Documentation/devicetree/bindings/rtc/maxim,ds1307.txt -- 2.1.2 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 0/4] rtc: ds1307: add support for device tree and mcp7940x @ 2014-11-24 15:49 ` Tomas Novotny 0 siblings, 0 replies; 11+ messages in thread From: Tomas Novotny @ 2014-11-24 15:49 UTC (permalink / raw) To: Alessandro Zummo, rtc-linux; +Cc: devicetree, linux-kernel, Tomas Novotny This series is tested with MCP79401 and it is based on 3.18-rc6. Tomas Novotny (4): rtc: ds1307: add support for mcp7940x chips of: add vendor prefix for Pericom Technology rtc: ds1307: add device tree bindings documentation rtc: ds1307: add device tree support .../devicetree/bindings/rtc/maxim,ds1307.txt | 23 ++++ .../devicetree/bindings/vendor-prefixes.txt | 1 + drivers/rtc/rtc-ds1307.c | 149 ++++++++++++--------- 3 files changed, 110 insertions(+), 63 deletions(-) create mode 100644 Documentation/devicetree/bindings/rtc/maxim,ds1307.txt -- 2.1.2 ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <1416844164-16782-1-git-send-email-tomas-P46umIhNmdHrBKCeMvbIDA@public.gmane.org>]
* [PATCH 1/4] rtc: ds1307: add support for mcp7940x chips 2014-11-24 15:49 ` Tomas Novotny @ 2014-11-24 15:49 ` Tomas Novotny -1 siblings, 0 replies; 11+ messages in thread From: Tomas Novotny @ 2014-11-24 15:49 UTC (permalink / raw) To: Alessandro Zummo, rtc-linux-/JYPxA39Uh5TLH3MbocFFw Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Tomas Novotny MCP7940x is same RTC as MCP7941x. The difference is that MCP7941x chips contain additional EEPROM on a different i2c address. DS1307 driver already supports MCP7941x, so just add a new i2c device id and rename functions and defines accordingly. Signed-off-by: Tomas Novotny <tomas-P46umIhNmdHrBKCeMvbIDA@public.gmane.org> --- drivers/rtc/rtc-ds1307.c | 127 ++++++++++++++++++++++++----------------------- 1 file changed, 64 insertions(+), 63 deletions(-) diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index bb43cf7..4ffabb3 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -35,7 +35,7 @@ enum ds_type { ds_1388, ds_3231, m41t00, - mcp7941x, + mcp794xx, rx_8025, last_ds_type /* always last */ /* rs5c372 too? different address... */ @@ -46,7 +46,7 @@ enum ds_type { #define DS1307_REG_SECS 0x00 /* 00-59 */ # define DS1307_BIT_CH 0x80 # define DS1340_BIT_nEOSC 0x80 -# define MCP7941X_BIT_ST 0x80 +# define MCP794XX_BIT_ST 0x80 #define DS1307_REG_MIN 0x01 /* 00-59 */ #define DS1307_REG_HOUR 0x02 /* 00-23, or 1-12{am,pm} */ # define DS1307_BIT_12HR 0x40 /* in REG_HOUR */ @@ -54,7 +54,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 MCP794XX_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 */ @@ -159,7 +159,7 @@ static struct chip_desc chips[last_ds_type] = { [ds_3231] = { .alarm = 1, }, - [mcp7941x] = { + [mcp794xx] = { .alarm = 1, /* this is battery backed SRAM */ .nvram_offset = 0x20, @@ -176,7 +176,8 @@ static const struct i2c_device_id ds1307_id[] = { { "ds1340", ds_1340 }, { "ds3231", ds_3231 }, { "m41t00", m41t00 }, - { "mcp7941x", mcp7941x }, + { "mcp7940x", mcp794xx }, + { "mcp7941x", mcp794xx }, { "pt7c4338", ds_1307 }, { "rx8025", rx_8025 }, { } @@ -439,14 +440,14 @@ 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: + case mcp794xx: /* * these bits were cleared when preparing the date/time * values and need to be set again before writing the * buffer out to the device. */ - buf[DS1307_REG_SECS] |= MCP7941X_BIT_ST; - buf[DS1307_REG_WDAY] |= MCP7941X_BIT_VBATEN; + buf[DS1307_REG_SECS] |= MCP794XX_BIT_ST; + buf[DS1307_REG_WDAY] |= MCP794XX_BIT_VBATEN; break; default: break; @@ -614,26 +615,26 @@ static const struct rtc_class_ops ds13xx_rtc_ops = { /*----------------------------------------------------------------------*/ /* - * Alarm support for mcp7941x devices. + * Alarm support for mcp794xx devices. */ -#define MCP7941X_REG_CONTROL 0x07 -# define MCP7941X_BIT_ALM0_EN 0x10 -# define MCP7941X_BIT_ALM1_EN 0x20 -#define MCP7941X_REG_ALARM0_BASE 0x0a -#define MCP7941X_REG_ALARM0_CTRL 0x0d -#define MCP7941X_REG_ALARM1_BASE 0x11 -#define MCP7941X_REG_ALARM1_CTRL 0x14 -# define MCP7941X_BIT_ALMX_IF (1 << 3) -# define MCP7941X_BIT_ALMX_C0 (1 << 4) -# define MCP7941X_BIT_ALMX_C1 (1 << 5) -# define MCP7941X_BIT_ALMX_C2 (1 << 6) -# define MCP7941X_BIT_ALMX_POL (1 << 7) -# define MCP7941X_MSK_ALMX_MATCH (MCP7941X_BIT_ALMX_C0 | \ - MCP7941X_BIT_ALMX_C1 | \ - MCP7941X_BIT_ALMX_C2) - -static void mcp7941x_work(struct work_struct *work) +#define MCP794XX_REG_CONTROL 0x07 +# define MCP794XX_BIT_ALM0_EN 0x10 +# define MCP794XX_BIT_ALM1_EN 0x20 +#define MCP794XX_REG_ALARM0_BASE 0x0a +#define MCP794XX_REG_ALARM0_CTRL 0x0d +#define MCP794XX_REG_ALARM1_BASE 0x11 +#define MCP794XX_REG_ALARM1_CTRL 0x14 +# define MCP794XX_BIT_ALMX_IF (1 << 3) +# define MCP794XX_BIT_ALMX_C0 (1 << 4) +# define MCP794XX_BIT_ALMX_C1 (1 << 5) +# define MCP794XX_BIT_ALMX_C2 (1 << 6) +# define MCP794XX_BIT_ALMX_POL (1 << 7) +# define MCP794XX_MSK_ALMX_MATCH (MCP794XX_BIT_ALMX_C0 | \ + MCP794XX_BIT_ALMX_C1 | \ + MCP794XX_BIT_ALMX_C2) + +static void mcp794xx_work(struct work_struct *work) { struct ds1307 *ds1307 = container_of(work, struct ds1307, work); struct i2c_client *client = ds1307->client; @@ -642,22 +643,22 @@ static void mcp7941x_work(struct work_struct *work) mutex_lock(&ds1307->rtc->ops_lock); /* Check and clear alarm 0 interrupt flag. */ - reg = i2c_smbus_read_byte_data(client, MCP7941X_REG_ALARM0_CTRL); + reg = i2c_smbus_read_byte_data(client, MCP794XX_REG_ALARM0_CTRL); if (reg < 0) goto out; - if (!(reg & MCP7941X_BIT_ALMX_IF)) + if (!(reg & MCP794XX_BIT_ALMX_IF)) goto out; - reg &= ~MCP7941X_BIT_ALMX_IF; - ret = i2c_smbus_write_byte_data(client, MCP7941X_REG_ALARM0_CTRL, reg); + reg &= ~MCP794XX_BIT_ALMX_IF; + ret = i2c_smbus_write_byte_data(client, MCP794XX_REG_ALARM0_CTRL, reg); if (ret < 0) goto out; /* Disable alarm 0. */ - reg = i2c_smbus_read_byte_data(client, MCP7941X_REG_CONTROL); + reg = i2c_smbus_read_byte_data(client, MCP794XX_REG_CONTROL); if (reg < 0) goto out; - reg &= ~MCP7941X_BIT_ALM0_EN; - ret = i2c_smbus_write_byte_data(client, MCP7941X_REG_CONTROL, reg); + reg &= ~MCP794XX_BIT_ALM0_EN; + ret = i2c_smbus_write_byte_data(client, MCP794XX_REG_CONTROL, reg); if (ret < 0) goto out; @@ -669,7 +670,7 @@ out: mutex_unlock(&ds1307->rtc->ops_lock); } -static int mcp7941x_read_alarm(struct device *dev, struct rtc_wkalrm *t) +static int mcp794xx_read_alarm(struct device *dev, struct rtc_wkalrm *t) { struct i2c_client *client = to_i2c_client(dev); struct ds1307 *ds1307 = i2c_get_clientdata(client); @@ -680,11 +681,11 @@ static int mcp7941x_read_alarm(struct device *dev, struct rtc_wkalrm *t) return -EINVAL; /* Read control and alarm 0 registers. */ - ret = ds1307->read_block_data(client, MCP7941X_REG_CONTROL, 10, regs); + ret = ds1307->read_block_data(client, MCP794XX_REG_CONTROL, 10, regs); if (ret < 0) return ret; - t->enabled = !!(regs[0] & MCP7941X_BIT_ALM0_EN); + t->enabled = !!(regs[0] & MCP794XX_BIT_ALM0_EN); /* Report alarm 0 time assuming 24-hour and day-of-month modes. */ t->time.tm_sec = bcd2bin(ds1307->regs[3] & 0x7f); @@ -701,14 +702,14 @@ static int mcp7941x_read_alarm(struct device *dev, struct rtc_wkalrm *t) "enabled=%d polarity=%d irq=%d match=%d\n", __func__, t->time.tm_sec, t->time.tm_min, t->time.tm_hour, t->time.tm_wday, t->time.tm_mday, t->time.tm_mon, t->enabled, - !!(ds1307->regs[6] & MCP7941X_BIT_ALMX_POL), - !!(ds1307->regs[6] & MCP7941X_BIT_ALMX_IF), - (ds1307->regs[6] & MCP7941X_MSK_ALMX_MATCH) >> 4); + !!(ds1307->regs[6] & MCP794XX_BIT_ALMX_POL), + !!(ds1307->regs[6] & MCP794XX_BIT_ALMX_IF), + (ds1307->regs[6] & MCP794XX_MSK_ALMX_MATCH) >> 4); return 0; } -static int mcp7941x_set_alarm(struct device *dev, struct rtc_wkalrm *t) +static int mcp794xx_set_alarm(struct device *dev, struct rtc_wkalrm *t) { struct i2c_client *client = to_i2c_client(dev); struct ds1307 *ds1307 = i2c_get_clientdata(client); @@ -725,7 +726,7 @@ static int mcp7941x_set_alarm(struct device *dev, struct rtc_wkalrm *t) t->enabled, t->pending); /* Read control and alarm 0 registers. */ - ret = ds1307->read_block_data(client, MCP7941X_REG_CONTROL, 10, regs); + ret = ds1307->read_block_data(client, MCP794XX_REG_CONTROL, 10, regs); if (ret < 0) return ret; @@ -738,23 +739,23 @@ static int mcp7941x_set_alarm(struct device *dev, struct rtc_wkalrm *t) regs[8] = bin2bcd(t->time.tm_mon) + 1; /* Clear the alarm 0 interrupt flag. */ - regs[6] &= ~MCP7941X_BIT_ALMX_IF; + regs[6] &= ~MCP794XX_BIT_ALMX_IF; /* Set alarm match: second, minute, hour, day, date, month. */ - regs[6] |= MCP7941X_MSK_ALMX_MATCH; + regs[6] |= MCP794XX_MSK_ALMX_MATCH; if (t->enabled) - regs[0] |= MCP7941X_BIT_ALM0_EN; + regs[0] |= MCP794XX_BIT_ALM0_EN; else - regs[0] &= ~MCP7941X_BIT_ALM0_EN; + regs[0] &= ~MCP794XX_BIT_ALM0_EN; - ret = ds1307->write_block_data(client, MCP7941X_REG_CONTROL, 10, regs); + ret = ds1307->write_block_data(client, MCP794XX_REG_CONTROL, 10, regs); if (ret < 0) return ret; return 0; } -static int mcp7941x_alarm_irq_enable(struct device *dev, unsigned int enabled) +static int mcp794xx_alarm_irq_enable(struct device *dev, unsigned int enabled) { struct i2c_client *client = to_i2c_client(dev); struct ds1307 *ds1307 = i2c_get_clientdata(client); @@ -763,24 +764,24 @@ static int mcp7941x_alarm_irq_enable(struct device *dev, unsigned int enabled) if (!test_bit(HAS_ALARM, &ds1307->flags)) return -EINVAL; - reg = i2c_smbus_read_byte_data(client, MCP7941X_REG_CONTROL); + reg = i2c_smbus_read_byte_data(client, MCP794XX_REG_CONTROL); if (reg < 0) return reg; if (enabled) - reg |= MCP7941X_BIT_ALM0_EN; + reg |= MCP794XX_BIT_ALM0_EN; else - reg &= ~MCP7941X_BIT_ALM0_EN; + reg &= ~MCP794XX_BIT_ALM0_EN; - return i2c_smbus_write_byte_data(client, MCP7941X_REG_CONTROL, reg); + return i2c_smbus_write_byte_data(client, MCP794XX_REG_CONTROL, reg); } -static const struct rtc_class_ops mcp7941x_rtc_ops = { +static const struct rtc_class_ops mcp794xx_rtc_ops = { .read_time = ds1307_get_time, .set_time = ds1307_set_time, - .read_alarm = mcp7941x_read_alarm, - .set_alarm = mcp7941x_set_alarm, - .alarm_irq_enable = mcp7941x_alarm_irq_enable, + .read_alarm = mcp794xx_read_alarm, + .set_alarm = mcp794xx_set_alarm, + .alarm_irq_enable = mcp794xx_alarm_irq_enable, }; /*----------------------------------------------------------------------*/ @@ -1049,10 +1050,10 @@ static int ds1307_probe(struct i2c_client *client, case ds_1388: ds1307->offset = 1; /* Seconds starts at 1 */ break; - case mcp7941x: - rtc_ops = &mcp7941x_rtc_ops; + case mcp794xx: + rtc_ops = &mcp794xx_rtc_ops; if (ds1307->client->irq > 0 && chip->alarm) { - INIT_WORK(&ds1307->work, mcp7941x_work); + INIT_WORK(&ds1307->work, mcp794xx_work); want_irq = true; } break; @@ -1117,18 +1118,18 @@ read_rtc: dev_warn(&client->dev, "SET TIME!\n"); } break; - case mcp7941x: + case mcp794xx: /* make sure that the backup battery is enabled */ - if (!(ds1307->regs[DS1307_REG_WDAY] & MCP7941X_BIT_VBATEN)) { + if (!(ds1307->regs[DS1307_REG_WDAY] & MCP794XX_BIT_VBATEN)) { i2c_smbus_write_byte_data(client, DS1307_REG_WDAY, ds1307->regs[DS1307_REG_WDAY] - | MCP7941X_BIT_VBATEN); + | MCP794XX_BIT_VBATEN); } /* clock halted? turn it on, so clock can tick. */ - if (!(tmp & MCP7941X_BIT_ST)) { + if (!(tmp & MCP794XX_BIT_ST)) { i2c_smbus_write_byte_data(client, DS1307_REG_SECS, - MCP7941X_BIT_ST); + MCP794XX_BIT_ST); dev_warn(&client->dev, "SET TIME!\n"); goto read_rtc; } -- 2.1.2 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 1/4] rtc: ds1307: add support for mcp7940x chips @ 2014-11-24 15:49 ` Tomas Novotny 0 siblings, 0 replies; 11+ messages in thread From: Tomas Novotny @ 2014-11-24 15:49 UTC (permalink / raw) To: Alessandro Zummo, rtc-linux; +Cc: devicetree, linux-kernel, Tomas Novotny MCP7940x is same RTC as MCP7941x. The difference is that MCP7941x chips contain additional EEPROM on a different i2c address. DS1307 driver already supports MCP7941x, so just add a new i2c device id and rename functions and defines accordingly. Signed-off-by: Tomas Novotny <tomas@novotny.cz> --- drivers/rtc/rtc-ds1307.c | 127 ++++++++++++++++++++++++----------------------- 1 file changed, 64 insertions(+), 63 deletions(-) diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index bb43cf7..4ffabb3 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -35,7 +35,7 @@ enum ds_type { ds_1388, ds_3231, m41t00, - mcp7941x, + mcp794xx, rx_8025, last_ds_type /* always last */ /* rs5c372 too? different address... */ @@ -46,7 +46,7 @@ enum ds_type { #define DS1307_REG_SECS 0x00 /* 00-59 */ # define DS1307_BIT_CH 0x80 # define DS1340_BIT_nEOSC 0x80 -# define MCP7941X_BIT_ST 0x80 +# define MCP794XX_BIT_ST 0x80 #define DS1307_REG_MIN 0x01 /* 00-59 */ #define DS1307_REG_HOUR 0x02 /* 00-23, or 1-12{am,pm} */ # define DS1307_BIT_12HR 0x40 /* in REG_HOUR */ @@ -54,7 +54,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 MCP794XX_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 */ @@ -159,7 +159,7 @@ static struct chip_desc chips[last_ds_type] = { [ds_3231] = { .alarm = 1, }, - [mcp7941x] = { + [mcp794xx] = { .alarm = 1, /* this is battery backed SRAM */ .nvram_offset = 0x20, @@ -176,7 +176,8 @@ static const struct i2c_device_id ds1307_id[] = { { "ds1340", ds_1340 }, { "ds3231", ds_3231 }, { "m41t00", m41t00 }, - { "mcp7941x", mcp7941x }, + { "mcp7940x", mcp794xx }, + { "mcp7941x", mcp794xx }, { "pt7c4338", ds_1307 }, { "rx8025", rx_8025 }, { } @@ -439,14 +440,14 @@ 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: + case mcp794xx: /* * these bits were cleared when preparing the date/time * values and need to be set again before writing the * buffer out to the device. */ - buf[DS1307_REG_SECS] |= MCP7941X_BIT_ST; - buf[DS1307_REG_WDAY] |= MCP7941X_BIT_VBATEN; + buf[DS1307_REG_SECS] |= MCP794XX_BIT_ST; + buf[DS1307_REG_WDAY] |= MCP794XX_BIT_VBATEN; break; default: break; @@ -614,26 +615,26 @@ static const struct rtc_class_ops ds13xx_rtc_ops = { /*----------------------------------------------------------------------*/ /* - * Alarm support for mcp7941x devices. + * Alarm support for mcp794xx devices. */ -#define MCP7941X_REG_CONTROL 0x07 -# define MCP7941X_BIT_ALM0_EN 0x10 -# define MCP7941X_BIT_ALM1_EN 0x20 -#define MCP7941X_REG_ALARM0_BASE 0x0a -#define MCP7941X_REG_ALARM0_CTRL 0x0d -#define MCP7941X_REG_ALARM1_BASE 0x11 -#define MCP7941X_REG_ALARM1_CTRL 0x14 -# define MCP7941X_BIT_ALMX_IF (1 << 3) -# define MCP7941X_BIT_ALMX_C0 (1 << 4) -# define MCP7941X_BIT_ALMX_C1 (1 << 5) -# define MCP7941X_BIT_ALMX_C2 (1 << 6) -# define MCP7941X_BIT_ALMX_POL (1 << 7) -# define MCP7941X_MSK_ALMX_MATCH (MCP7941X_BIT_ALMX_C0 | \ - MCP7941X_BIT_ALMX_C1 | \ - MCP7941X_BIT_ALMX_C2) - -static void mcp7941x_work(struct work_struct *work) +#define MCP794XX_REG_CONTROL 0x07 +# define MCP794XX_BIT_ALM0_EN 0x10 +# define MCP794XX_BIT_ALM1_EN 0x20 +#define MCP794XX_REG_ALARM0_BASE 0x0a +#define MCP794XX_REG_ALARM0_CTRL 0x0d +#define MCP794XX_REG_ALARM1_BASE 0x11 +#define MCP794XX_REG_ALARM1_CTRL 0x14 +# define MCP794XX_BIT_ALMX_IF (1 << 3) +# define MCP794XX_BIT_ALMX_C0 (1 << 4) +# define MCP794XX_BIT_ALMX_C1 (1 << 5) +# define MCP794XX_BIT_ALMX_C2 (1 << 6) +# define MCP794XX_BIT_ALMX_POL (1 << 7) +# define MCP794XX_MSK_ALMX_MATCH (MCP794XX_BIT_ALMX_C0 | \ + MCP794XX_BIT_ALMX_C1 | \ + MCP794XX_BIT_ALMX_C2) + +static void mcp794xx_work(struct work_struct *work) { struct ds1307 *ds1307 = container_of(work, struct ds1307, work); struct i2c_client *client = ds1307->client; @@ -642,22 +643,22 @@ static void mcp7941x_work(struct work_struct *work) mutex_lock(&ds1307->rtc->ops_lock); /* Check and clear alarm 0 interrupt flag. */ - reg = i2c_smbus_read_byte_data(client, MCP7941X_REG_ALARM0_CTRL); + reg = i2c_smbus_read_byte_data(client, MCP794XX_REG_ALARM0_CTRL); if (reg < 0) goto out; - if (!(reg & MCP7941X_BIT_ALMX_IF)) + if (!(reg & MCP794XX_BIT_ALMX_IF)) goto out; - reg &= ~MCP7941X_BIT_ALMX_IF; - ret = i2c_smbus_write_byte_data(client, MCP7941X_REG_ALARM0_CTRL, reg); + reg &= ~MCP794XX_BIT_ALMX_IF; + ret = i2c_smbus_write_byte_data(client, MCP794XX_REG_ALARM0_CTRL, reg); if (ret < 0) goto out; /* Disable alarm 0. */ - reg = i2c_smbus_read_byte_data(client, MCP7941X_REG_CONTROL); + reg = i2c_smbus_read_byte_data(client, MCP794XX_REG_CONTROL); if (reg < 0) goto out; - reg &= ~MCP7941X_BIT_ALM0_EN; - ret = i2c_smbus_write_byte_data(client, MCP7941X_REG_CONTROL, reg); + reg &= ~MCP794XX_BIT_ALM0_EN; + ret = i2c_smbus_write_byte_data(client, MCP794XX_REG_CONTROL, reg); if (ret < 0) goto out; @@ -669,7 +670,7 @@ out: mutex_unlock(&ds1307->rtc->ops_lock); } -static int mcp7941x_read_alarm(struct device *dev, struct rtc_wkalrm *t) +static int mcp794xx_read_alarm(struct device *dev, struct rtc_wkalrm *t) { struct i2c_client *client = to_i2c_client(dev); struct ds1307 *ds1307 = i2c_get_clientdata(client); @@ -680,11 +681,11 @@ static int mcp7941x_read_alarm(struct device *dev, struct rtc_wkalrm *t) return -EINVAL; /* Read control and alarm 0 registers. */ - ret = ds1307->read_block_data(client, MCP7941X_REG_CONTROL, 10, regs); + ret = ds1307->read_block_data(client, MCP794XX_REG_CONTROL, 10, regs); if (ret < 0) return ret; - t->enabled = !!(regs[0] & MCP7941X_BIT_ALM0_EN); + t->enabled = !!(regs[0] & MCP794XX_BIT_ALM0_EN); /* Report alarm 0 time assuming 24-hour and day-of-month modes. */ t->time.tm_sec = bcd2bin(ds1307->regs[3] & 0x7f); @@ -701,14 +702,14 @@ static int mcp7941x_read_alarm(struct device *dev, struct rtc_wkalrm *t) "enabled=%d polarity=%d irq=%d match=%d\n", __func__, t->time.tm_sec, t->time.tm_min, t->time.tm_hour, t->time.tm_wday, t->time.tm_mday, t->time.tm_mon, t->enabled, - !!(ds1307->regs[6] & MCP7941X_BIT_ALMX_POL), - !!(ds1307->regs[6] & MCP7941X_BIT_ALMX_IF), - (ds1307->regs[6] & MCP7941X_MSK_ALMX_MATCH) >> 4); + !!(ds1307->regs[6] & MCP794XX_BIT_ALMX_POL), + !!(ds1307->regs[6] & MCP794XX_BIT_ALMX_IF), + (ds1307->regs[6] & MCP794XX_MSK_ALMX_MATCH) >> 4); return 0; } -static int mcp7941x_set_alarm(struct device *dev, struct rtc_wkalrm *t) +static int mcp794xx_set_alarm(struct device *dev, struct rtc_wkalrm *t) { struct i2c_client *client = to_i2c_client(dev); struct ds1307 *ds1307 = i2c_get_clientdata(client); @@ -725,7 +726,7 @@ static int mcp7941x_set_alarm(struct device *dev, struct rtc_wkalrm *t) t->enabled, t->pending); /* Read control and alarm 0 registers. */ - ret = ds1307->read_block_data(client, MCP7941X_REG_CONTROL, 10, regs); + ret = ds1307->read_block_data(client, MCP794XX_REG_CONTROL, 10, regs); if (ret < 0) return ret; @@ -738,23 +739,23 @@ static int mcp7941x_set_alarm(struct device *dev, struct rtc_wkalrm *t) regs[8] = bin2bcd(t->time.tm_mon) + 1; /* Clear the alarm 0 interrupt flag. */ - regs[6] &= ~MCP7941X_BIT_ALMX_IF; + regs[6] &= ~MCP794XX_BIT_ALMX_IF; /* Set alarm match: second, minute, hour, day, date, month. */ - regs[6] |= MCP7941X_MSK_ALMX_MATCH; + regs[6] |= MCP794XX_MSK_ALMX_MATCH; if (t->enabled) - regs[0] |= MCP7941X_BIT_ALM0_EN; + regs[0] |= MCP794XX_BIT_ALM0_EN; else - regs[0] &= ~MCP7941X_BIT_ALM0_EN; + regs[0] &= ~MCP794XX_BIT_ALM0_EN; - ret = ds1307->write_block_data(client, MCP7941X_REG_CONTROL, 10, regs); + ret = ds1307->write_block_data(client, MCP794XX_REG_CONTROL, 10, regs); if (ret < 0) return ret; return 0; } -static int mcp7941x_alarm_irq_enable(struct device *dev, unsigned int enabled) +static int mcp794xx_alarm_irq_enable(struct device *dev, unsigned int enabled) { struct i2c_client *client = to_i2c_client(dev); struct ds1307 *ds1307 = i2c_get_clientdata(client); @@ -763,24 +764,24 @@ static int mcp7941x_alarm_irq_enable(struct device *dev, unsigned int enabled) if (!test_bit(HAS_ALARM, &ds1307->flags)) return -EINVAL; - reg = i2c_smbus_read_byte_data(client, MCP7941X_REG_CONTROL); + reg = i2c_smbus_read_byte_data(client, MCP794XX_REG_CONTROL); if (reg < 0) return reg; if (enabled) - reg |= MCP7941X_BIT_ALM0_EN; + reg |= MCP794XX_BIT_ALM0_EN; else - reg &= ~MCP7941X_BIT_ALM0_EN; + reg &= ~MCP794XX_BIT_ALM0_EN; - return i2c_smbus_write_byte_data(client, MCP7941X_REG_CONTROL, reg); + return i2c_smbus_write_byte_data(client, MCP794XX_REG_CONTROL, reg); } -static const struct rtc_class_ops mcp7941x_rtc_ops = { +static const struct rtc_class_ops mcp794xx_rtc_ops = { .read_time = ds1307_get_time, .set_time = ds1307_set_time, - .read_alarm = mcp7941x_read_alarm, - .set_alarm = mcp7941x_set_alarm, - .alarm_irq_enable = mcp7941x_alarm_irq_enable, + .read_alarm = mcp794xx_read_alarm, + .set_alarm = mcp794xx_set_alarm, + .alarm_irq_enable = mcp794xx_alarm_irq_enable, }; /*----------------------------------------------------------------------*/ @@ -1049,10 +1050,10 @@ static int ds1307_probe(struct i2c_client *client, case ds_1388: ds1307->offset = 1; /* Seconds starts at 1 */ break; - case mcp7941x: - rtc_ops = &mcp7941x_rtc_ops; + case mcp794xx: + rtc_ops = &mcp794xx_rtc_ops; if (ds1307->client->irq > 0 && chip->alarm) { - INIT_WORK(&ds1307->work, mcp7941x_work); + INIT_WORK(&ds1307->work, mcp794xx_work); want_irq = true; } break; @@ -1117,18 +1118,18 @@ read_rtc: dev_warn(&client->dev, "SET TIME!\n"); } break; - case mcp7941x: + case mcp794xx: /* make sure that the backup battery is enabled */ - if (!(ds1307->regs[DS1307_REG_WDAY] & MCP7941X_BIT_VBATEN)) { + if (!(ds1307->regs[DS1307_REG_WDAY] & MCP794XX_BIT_VBATEN)) { i2c_smbus_write_byte_data(client, DS1307_REG_WDAY, ds1307->regs[DS1307_REG_WDAY] - | MCP7941X_BIT_VBATEN); + | MCP794XX_BIT_VBATEN); } /* clock halted? turn it on, so clock can tick. */ - if (!(tmp & MCP7941X_BIT_ST)) { + if (!(tmp & MCP794XX_BIT_ST)) { i2c_smbus_write_byte_data(client, DS1307_REG_SECS, - MCP7941X_BIT_ST); + MCP794XX_BIT_ST); dev_warn(&client->dev, "SET TIME!\n"); goto read_rtc; } -- 2.1.2 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 0/4] rtc: ds1307: add support for device tree and mcp7940x 2014-11-24 15:49 ` Tomas Novotny @ 2014-11-27 15:17 ` Tomas Novotny -1 siblings, 0 replies; 11+ messages in thread From: Tomas Novotny @ 2014-11-27 15:17 UTC (permalink / raw) To: rtc-linux-/JYPxA39Uh5TLH3MbocFFw Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Alessandro Zummo, grant.likely-QSEj5FYQhm4dnm+yROfE0A, robh+dt-DgEjT+Ai2ygdnm+yROfE0A, akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b On Mon, 24 Nov 2014 16:49:20 +0100 Tomas Novotny <tomas-P46umIhNmdHrBKCeMvbIDA@public.gmane.org> wrote: > This series is tested with MCP79401 and it is based on 3.18-rc6. > > Tomas Novotny (4): > rtc: ds1307: add support for mcp7940x chips > of: add vendor prefix for Pericom Technology > rtc: ds1307: add device tree bindings documentation > rtc: ds1307: add device tree support > > .../devicetree/bindings/rtc/maxim,ds1307.txt | 23 ++++ > .../devicetree/bindings/vendor-prefixes.txt | 1 + > drivers/rtc/rtc-ds1307.c | 149 ++++++++++++--------- > 3 files changed, 110 insertions(+), 63 deletions(-) > create mode 100644 Documentation/devicetree/bindings/rtc/maxim,ds1307.txt It is now in the -mm and linux-next. Thanks to Andrew for pick up, Tomas -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/4] rtc: ds1307: add support for device tree and mcp7940x @ 2014-11-27 15:17 ` Tomas Novotny 0 siblings, 0 replies; 11+ messages in thread From: Tomas Novotny @ 2014-11-27 15:17 UTC (permalink / raw) To: rtc-linux Cc: devicetree, linux-kernel, Alessandro Zummo, grant.likely, robh+dt, akpm On Mon, 24 Nov 2014 16:49:20 +0100 Tomas Novotny <tomas@novotny.cz> wrote: > This series is tested with MCP79401 and it is based on 3.18-rc6. > > Tomas Novotny (4): > rtc: ds1307: add support for mcp7940x chips > of: add vendor prefix for Pericom Technology > rtc: ds1307: add device tree bindings documentation > rtc: ds1307: add device tree support > > .../devicetree/bindings/rtc/maxim,ds1307.txt | 23 ++++ > .../devicetree/bindings/vendor-prefixes.txt | 1 + > drivers/rtc/rtc-ds1307.c | 149 ++++++++++++--------- > 3 files changed, 110 insertions(+), 63 deletions(-) > create mode 100644 Documentation/devicetree/bindings/rtc/maxim,ds1307.txt It is now in the -mm and linux-next. Thanks to Andrew for pick up, Tomas ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/4] rtc: ds1307: add support for device tree and mcp7940x 2014-11-27 15:17 ` Tomas Novotny @ 2014-11-28 12:14 ` Tomas Novotny -1 siblings, 0 replies; 11+ messages in thread From: Tomas Novotny @ 2014-11-28 12:14 UTC (permalink / raw) To: akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b Cc: rtc-linux-/JYPxA39Uh5TLH3MbocFFw, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Alessandro Zummo, grant.likely-QSEj5FYQhm4dnm+yROfE0A, robh+dt-DgEjT+Ai2ygdnm+yROfE0A Hi Andrew, On Thu, 27 Nov 2014 16:17:41 +0100, Tomas Novotny <tomas-P46umIhNmdHrBKCeMvbIDA@public.gmane.org> wrote: > On Mon, 24 Nov 2014 16:49:20 +0100 > Tomas Novotny <tomas-P46umIhNmdHrBKCeMvbIDA@public.gmane.org> wrote: > > > This series is tested with MCP79401 and it is based on 3.18-rc6. > > > > Tomas Novotny (4): > > rtc: ds1307: add support for mcp7940x chips > > of: add vendor prefix for Pericom Technology > > rtc: ds1307: add device tree bindings documentation > > rtc: ds1307: add device tree support > > > > .../devicetree/bindings/rtc/maxim,ds1307.txt | 23 ++++ > > .../devicetree/bindings/vendor-prefixes.txt | 1 + > > drivers/rtc/rtc-ds1307.c | 149 ++++++++++++--------- > > 3 files changed, 110 insertions(+), 63 deletions(-) > > create mode 100644 Documentation/devicetree/bindings/rtc/maxim,ds1307.txt > > It is now in the -mm and linux-next. > Thanks to Andrew for pick up, > > Tomas could you please remove my last two patches: rtc-ds1307-add-device-tree-bindings-documentation.patch rtc-ds1307-add-device-tree-support.patch from the -mm? I missed that some compatible RTC's are already listed in i2c/trivial-devices.txt. These two patches shouldn't break anything, but document and handle already working thing. Better would be to follow the trivial-devices.txt and add the missing compatibles there. The first two patches are ok. Sorry for the noise and thanks, Tomas -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/4] rtc: ds1307: add support for device tree and mcp7940x @ 2014-11-28 12:14 ` Tomas Novotny 0 siblings, 0 replies; 11+ messages in thread From: Tomas Novotny @ 2014-11-28 12:14 UTC (permalink / raw) To: akpm Cc: rtc-linux, devicetree, linux-kernel, Alessandro Zummo, grant.likely, robh+dt Hi Andrew, On Thu, 27 Nov 2014 16:17:41 +0100, Tomas Novotny <tomas@novotny.cz> wrote: > On Mon, 24 Nov 2014 16:49:20 +0100 > Tomas Novotny <tomas@novotny.cz> wrote: > > > This series is tested with MCP79401 and it is based on 3.18-rc6. > > > > Tomas Novotny (4): > > rtc: ds1307: add support for mcp7940x chips > > of: add vendor prefix for Pericom Technology > > rtc: ds1307: add device tree bindings documentation > > rtc: ds1307: add device tree support > > > > .../devicetree/bindings/rtc/maxim,ds1307.txt | 23 ++++ > > .../devicetree/bindings/vendor-prefixes.txt | 1 + > > drivers/rtc/rtc-ds1307.c | 149 ++++++++++++--------- > > 3 files changed, 110 insertions(+), 63 deletions(-) > > create mode 100644 Documentation/devicetree/bindings/rtc/maxim,ds1307.txt > > It is now in the -mm and linux-next. > Thanks to Andrew for pick up, > > Tomas could you please remove my last two patches: rtc-ds1307-add-device-tree-bindings-documentation.patch rtc-ds1307-add-device-tree-support.patch from the -mm? I missed that some compatible RTC's are already listed in i2c/trivial-devices.txt. These two patches shouldn't break anything, but document and handle already working thing. Better would be to follow the trivial-devices.txt and add the missing compatibles there. The first two patches are ok. Sorry for the noise and thanks, Tomas ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/4] of: add vendor prefix for Pericom Technology 2014-11-24 15:49 ` Tomas Novotny (?) (?) @ 2014-11-24 15:49 ` Tomas Novotny -1 siblings, 0 replies; 11+ messages in thread From: Tomas Novotny @ 2014-11-24 15:49 UTC (permalink / raw) To: Alessandro Zummo, rtc-linux; +Cc: devicetree, linux-kernel, Tomas Novotny Signed-off-by: Tomas Novotny <tomas@novotny.cz> --- Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index a344ec2..8ebd82f 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt @@ -112,6 +112,7 @@ nxp NXP Semiconductors onnn ON Semiconductor Corp. opencores OpenCores.org panasonic Panasonic Corporation +pericom Pericom Technology Inc. phytec PHYTEC Messtechnik GmbH picochip Picochip Ltd plathome Plat'Home Co., Ltd. -- 2.1.2 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/4] rtc: ds1307: add device tree bindings documentation 2014-11-24 15:49 ` Tomas Novotny ` (2 preceding siblings ...) (?) @ 2014-11-24 15:49 ` Tomas Novotny -1 siblings, 0 replies; 11+ messages in thread From: Tomas Novotny @ 2014-11-24 15:49 UTC (permalink / raw) To: Alessandro Zummo, rtc-linux; +Cc: devicetree, linux-kernel, Tomas Novotny Signed-off-by: Tomas Novotny <tomas@novotny.cz> --- .../devicetree/bindings/rtc/maxim,ds1307.txt | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/maxim,ds1307.txt diff --git a/Documentation/devicetree/bindings/rtc/maxim,ds1307.txt b/Documentation/devicetree/bindings/rtc/maxim,ds1307.txt new file mode 100644 index 0000000..eb6164c --- /dev/null +++ b/Documentation/devicetree/bindings/rtc/maxim,ds1307.txt @@ -0,0 +1,23 @@ +* Maxim (Dallas) DS1307 and compatible Real Time Clock + +For example, compatible chips are Maxim DS1337, Microchip MCP794xx, +STMicroelectronics M41T00 and Epson RX-8025. + +Required properties: +- compatible: For example "maxim,ds1307" (see rtc-ds1307.c driver for a full + list). +- reg: i2c address + +Example for DS1307: + +ds1307: rtc@68 { + compatible = "maxim,ds1307"; + reg = <0x68>; +}; + +Example for MCP79401: + +mcp7940x: rtc@6f { + compatible = "microchip,mcp7940x"; + reg = <0x6f>; +}; -- 2.1.2 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/4] rtc: ds1307: add device tree support 2014-11-24 15:49 ` Tomas Novotny ` (3 preceding siblings ...) (?) @ 2014-11-24 15:49 ` Tomas Novotny -1 siblings, 0 replies; 11+ messages in thread From: Tomas Novotny @ 2014-11-24 15:49 UTC (permalink / raw) To: Alessandro Zummo, rtc-linux; +Cc: devicetree, linux-kernel, Tomas Novotny Note that alarm interrupt and trickle charger are not handled (I have no hardware with these features). Signed-off-by: Tomas Novotny <tomas@novotny.cz> --- Only the "common" compatible string for that driver (maxim,ds1307) is documented, so checkpatch complains for the rest. If it is better to document every compatible, I will post a new series with documentation files pointing to the maxim,ds1307.txt. drivers/rtc/rtc-ds1307.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 4ffabb3..3bb6a20 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -18,6 +18,7 @@ #include <linux/string.h> #include <linux/rtc.h> #include <linux/bcd.h> +#include <linux/of.h> #include <linux/rtc/ds1307.h> /* @@ -1242,10 +1243,31 @@ static int ds1307_remove(struct i2c_client *client) return 0; } +#ifdef CONFIG_OF +static const struct of_device_id ds1307_driver_dt_ids[] = { + /* driver_data are passed through ds1307_id */ + { .compatible = "maxim,ds1307" }, + { .compatible = "maxim,ds1337" }, + { .compatible = "maxim,ds1338" }, + { .compatible = "maxim,ds1339" }, + { .compatible = "maxim,ds1388" }, + { .compatible = "maxim,ds1340" }, + { .compatible = "maxim,ds3231" }, + { .compatible = "st,m41t00" }, + { .compatible = "microchip,mcp7940x" }, + { .compatible = "microchip,mcp7941x" }, + { .compatible = "pericom,pt7c4338" }, + { .compatible = "epson,rx8025" }, + { } +}; +MODULE_DEVICE_TABLE(of, ds1307_driver_dt_ids); +#endif + static struct i2c_driver ds1307_driver = { .driver = { .name = "rtc-ds1307", .owner = THIS_MODULE, + .of_match_table = of_match_ptr(ds1307_driver_dt_ids), }, .probe = ds1307_probe, .remove = ds1307_remove, -- 2.1.2 ^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-11-28 12:15 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-24 15:49 [PATCH 0/4] rtc: ds1307: add support for device tree and mcp7940x Tomas Novotny
2014-11-24 15:49 ` Tomas Novotny
[not found] ` <1416844164-16782-1-git-send-email-tomas-P46umIhNmdHrBKCeMvbIDA@public.gmane.org>
2014-11-24 15:49 ` [PATCH 1/4] rtc: ds1307: add support for mcp7940x chips Tomas Novotny
2014-11-24 15:49 ` Tomas Novotny
2014-11-27 15:17 ` [PATCH 0/4] rtc: ds1307: add support for device tree and mcp7940x Tomas Novotny
2014-11-27 15:17 ` Tomas Novotny
2014-11-28 12:14 ` Tomas Novotny
2014-11-28 12:14 ` Tomas Novotny
2014-11-24 15:49 ` [PATCH 2/4] of: add vendor prefix for Pericom Technology Tomas Novotny
2014-11-24 15:49 ` [PATCH 3/4] rtc: ds1307: add device tree bindings documentation Tomas Novotny
2014-11-24 15:49 ` [PATCH 4/4] rtc: ds1307: add device tree support Tomas Novotny
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.