RTC subsystem
Subsystems (2)
cover RTC subsystem
RTC subsystem.
- general cleanup of white spaces and error messages
- new NEC VR41XX driver
- fixed some sysfs error codes
- oscillator handling in ds1672
--
Best regards,
Alessandro Zummo,
Tower Technologies - Turin, Italy
--
PATCH 1/10 RTC subsystem, DS1672 oscillator handling
From: Kumar Gala <[email protected]>
* Always enable the oscillator when we set the time
* If the oscillator is disable when we probe the RTC report back a warning to the user
* Added sysfs attribute to represent the state of the oscillator
---
commit 3acc1a4629e70bce7493b5463f3c785379ae8b6b
tree 34463406603ac788697d8d228a2caf2c0ea40b3a
parent 329b10bb0feacb7fb9a41389313ff0a51ae56f2a
author Kumar Gala <[email protected]> Tue, 28 Mar 2006 16:53:43 -0600 committer Kumar Gala <[email protected]> Tue, 28 Mar 2006 16:53:43 -0600
drivers/rtc/rtc-ds1672.c | 61 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 3 deletions(-)
drivers/rtc/rtc-ds1672.c +58 -3
@@ -23,6 +23,7 @@ I2C_CLIENT_INSMOD;#define DS1672_REG_CNT_BASE 0#define DS1672_REG_CONTROL 4 +#define DS1672_REG_CONTROL_EOSC 0x80#define DS1672_REG_TRICKLE 5
@@ -72,16 +73,17 @@ static int ds1672_get_datetime(struct i2static int ds1672_set_mmss (struct i2c_client *client,unsigned long secs) {int xfer; -unsigned char buf[5 ]; +unsigned char buf[6 ]; buf[0 ] =DS1672_REG_CNT_BASE ; buf[1 ] = secs &0x000000FF ; buf[2 ] = (secs &0x0000FF00 ) >>8 ; buf[3 ] = (secs &0x00FF0000 ) >>16 ; buf[4 ] = (secs &0xFF000000 ) >>24 ; + buf[5 ] =0 ;/* set control reg to enable counting */ - xfer =i2c_master_send (client, buf,5 ); -if (xfer !=5 ) { + xfer =i2c_master_send (client, buf,6 ); +if (xfer !=6 ) {dev_err (&client->dev,"%s: send: %d\n" , __FUNCTION__, xfer);return -EIO ; }
@@ -120,6 +122,44 @@ static int ds1672_rtc_set_mmss(struct dereturn ds1672_set_mmss (to_i2c_client (dev), secs); } +static int ds1672_get_control (struct i2c_client *client,u8 *status) +{ +unsigned char addr =DS1672_REG_CONTROL ; + +struct i2c_msg msgs[] = { + { client->addr,0 ,1 , &addr },/* setup read ptr */ + { client->addr,I2C_M_RD ,1 , status },/* read control */ + }; + +/* read control register */ +if ((i2c_transfer (client->adapter, &msgs[0 ],2 )) !=2 ) { +dev_err (&client->dev,"%s: read error\n" , __FUNCTION__); +return -EIO ; + } + +return 0 ; +} + +/* following are the sysfs callback functions */ +static ssize_t show_control (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct i2c_client *client =to_i2c_client (dev); +char *state ="enabled" ; +u8 control; +int err; + + err =ds1672_get_control (client, &control); +if (err) +return err; + +if (control &DS1672_REG_CONTROL_EOSC ) + state ="disabled" ; + +return sprintf (buf,"%s\n" , state); +} + +static DEVICE_ATTR(control, S_IRUGO, show_control, NULL); +static struct rtc_class_ops ds1672_rtc_ops = { .read_time = ds1672_rtc_read_time, .set_time = ds1672_rtc_set_time,
@@ -162,6 +202,7 @@ static struct i2c_driver ds1672_driver =static int ds1672_probe (struct i2c_adapter *adapter,int address,int kind) {int err =0 ; +u8 control;struct i2c_client *client;struct rtc_device *rtc;
@@ -202,6 +243,20 @@ static int ds1672_probe(struct i2c_adapti2c_set_clientdata (client, rtc); +/* read control register */ + err =ds1672_get_control (client, &control); +if (err) { +dev_err (&client->dev,"%s: read error\n" , __FUNCTION__); + goto exit_detach; + } + +if (control &DS1672_REG_CONTROL_EOSC ) +dev_warn (&client->dev,"Oscillator not enabled. " +"Set time to enable.\n" ); + +/* Register sysfs hooks */ +device_create_file (&client->dev, &dev_attr_control); +return 0 ; exit_detach:
--
PATCH 2/10 RTC subsystem, DS1672 cleanup
In reply to Alessandro Zummo - removed a duplicate error message
- bumped driver version
- removed some debugging messages in excess
- refined the formatting
- adjusted copyright notice
--- drivers/rtc/rtc-ds1672.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-)
drivers/rtc/rtc-ds1672.c +10 -19
@@ -1,6 +1,8 @@/* * An rtc/i2c driver for the Dallas DS1672 -* Copyright 2005 Alessandro Zummo +* Copyright 2005-06 Tower Technologies +* +* Author: Alessandro Zummo <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
@@ -11,7 +13,7 @@#include <linux/i2c.h> #include <linux/rtc.h> -#define DRV_VERSION "0.2" +#define DRV_VERSION "0.3"/* Addresses to scan: none. This chip cannot be detected. */ static unsigned short normal_i2c[] = {I2C_CLIENT_END };
@@ -23,9 +25,9 @@ I2C_CLIENT_INSMOD;#define DS1672_REG_CNT_BASE 0#define DS1672_REG_CONTROL 4 -#define DS1672_REG_CONTROL_EOSC 0x80#define DS1672_REG_TRICKLE 5 +#define DS1672_REG_CONTROL_EOSC 0x80/* Prototypes */ static int ds1672_probe (struct i2c_adapter *adapter,int address,int kind);
@@ -54,8 +56,7 @@ static int ds1672_get_datetime(struct i2dev_dbg (&client->dev,"%s: raw read data - counters=%02x,%02x,%02x,%02x\n" - __FUNCTION__, - buf[0 ], buf[1 ], buf[2 ], buf[3 ]); + __FUNCTION__, buf[0 ], buf[1 ], buf[2 ], buf[3 ]); time = (buf[3 ] <<24 ) | (buf[2 ] <<16 ) | (buf[1 ] <<8 ) | buf[0 ];
@@ -63,8 +64,7 @@ static int ds1672_get_datetime(struct i2dev_dbg (&client->dev,"%s: tm is secs=%d, mins=%d, hours=%d, " "mday=%d, mon=%d, year=%d, wday=%d\n" , - __FUNCTION__, - tm->tm_sec, tm->tm_min, tm->tm_hour, + __FUNCTION__, tm->tm_sec, tm->tm_min, tm->tm_hour, tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);return 0 ;
@@ -144,7 +144,6 @@ static int ds1672_get_control(struct i2cstatic ssize_t show_control (struct device *dev,struct device_attribute *attr,char *buf) {struct i2c_client *client =to_i2c_client (dev); -char *state ="enabled" ;u8 control;int err;
@@ -152,12 +151,9 @@ static ssize_t show_control(struct devicif (err)return err; -if (control &DS1672_REG_CONTROL_EOSC ) - state ="disabled" ; - -return sprintf (buf,"%s\n" , state); +return sprintf (buf,"%s\n" , (control &DS1672_REG_CONTROL_EOSC ) + ?"disabled" :"enabled" ); } - static DEVICE_ATTR(control, S_IRUGO, show_control, NULL);static struct rtc_class_ops ds1672_rtc_ops = {
@@ -168,7 +164,6 @@ static struct rtc_class_ops ds1672_rtc_ostatic int ds1672_attach (struct i2c_adapter *adapter) { -dev_dbg (&adapter->dev,"%s\n" , __FUNCTION__);return i2c_probe (adapter, &addr_data, ds1672_probe); }
@@ -177,8 +172,6 @@ static int ds1672_detach(struct i2c_clieint err;struct rtc_device *rtc =i2c_get_clientdata (client); -dev_dbg (&client->dev,"%s\n" , __FUNCTION__); -if (rtc)rtc_device_unregister (rtc);
@@ -245,10 +238,8 @@ static int ds1672_probe(struct i2c_adapt/* read control register */ err =ds1672_get_control (client, &control); -if (err) { -dev_err (&client->dev,"%s: read error\n" , __FUNCTION__); +if (err) goto exit_detach; - }if (control &DS1672_REG_CONTROL_EOSC ) dev_warn(&client->dev, "Oscillator not enabled. "
--
PATCH 3/10 RTC subsystem, X1205 sysfs cleanup
In reply to Alessandro Zummo fixed sysfs show() return code
--- drivers/rtc/rtc-x1205.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/rtc/rtc-x1205.c +12 -10
@@ -19,7 +19,7 @@#include <linux/rtc.h> #include <linux/delay.h> -#define DRV_VERSION "1.0.6" +#define DRV_VERSION "1.0.7"/* Addresses to scan: none. This chip is located at * 0x6f and uses a two bytes register addressing.
@@ -473,24 +473,26 @@ static struct rtc_class_ops x1205_rtc_opstatic ssize_t x1205_sysfs_show_atrim (struct device *dev,struct device_attribute *attr,char *buf) { -int atrim; +int err, atrim; -if (x1205_get_atrim (to_i2c_client (dev), &atrim) ==0 ) -return sprintf (buf,"%d.%02d pF\n" , - atrim /1000 , atrim %1000 ); -return 0 ; + err =x1205_get_atrim (to_i2c_client (dev), &atrim); +if (err) +return err; + +return sprintf (buf,"%d.%02d pF\n" , atrim /1000 , atrim %1000 ); } static DEVICE_ATTR(atrim, S_IRUGO, x1205_sysfs_show_atrim, NULL);static ssize_t x1205_sysfs_show_dtrim (struct device *dev,struct device_attribute *attr,char *buf) { -int dtrim; +int err, dtrim; -if (x1205_get_dtrim (to_i2c_client (dev), &dtrim) ==0 ) -return sprintf (buf,"%d ppm\n" , dtrim); + err =x1205_get_dtrim (to_i2c_client (dev), &dtrim); +if (err) +return err; -return 0 ; +return sprintf (buf,"%d ppm\n" , dtrim); } static DEVICE_ATTR(dtrim, S_IRUGO, x1205_sysfs_show_dtrim, NULL);
--
PATCH 4/10 RTC subsystem, whitespaces and error messages cleanup
In reply to Alessandro Zummo - fixed whitespaces
- removed some debugging in excess
--- drivers/rtc/rtc-m48t86.c | 2 +- drivers/rtc/rtc-pcf8563.c | 2 -- drivers/rtc/rtc-rs5c372.c | 3 --- drivers/rtc/rtc-x1205.c | 3 --- 4 files changed, 1 insertion(+), 9 deletions(-)
drivers/rtc/rtc-x1205.c +0 -3
@@ -498,7 +498,6 @@ static DEVICE_ATTR(dtrim, S_IRUGO, x1205static int x1205_attach (struct i2c_adapter *adapter) { -dev_dbg (&adapter->dev,"%s\n" , __FUNCTION__);return i2c_probe (adapter, &addr_data, x1205_probe); }
@@ -587,8 +586,6 @@ static int x1205_detach(struct i2c_clienint err;struct rtc_device *rtc =i2c_get_clientdata (client); -dev_dbg (&client->dev,"%s\n" , __FUNCTION__); -if (rtc)rtc_device_unregister (rtc);
drivers/rtc/rtc-rs5c372.c +0 -3
@@ -193,7 +193,6 @@ static DEVICE_ATTR(osc, S_IRUGO, rs5c372static int rs5c372_attach (struct i2c_adapter *adapter) { -dev_dbg (&adapter->dev,"%s\n" , __FUNCTION__);return i2c_probe (adapter, &addr_data, rs5c372_probe); }
@@ -260,8 +259,6 @@ static int rs5c372_detach(struct i2c_cliint err;struct rtc_device *rtc =i2c_get_clientdata (client); -dev_dbg (&client->dev,"%s\n" , __FUNCTION__); -if (rtc)rtc_device_unregister (rtc);
drivers/rtc/rtc-pcf8563.c +0 -2
@@ -321,8 +321,6 @@ static int pcf8563_detach(struct i2c_cliint err;struct rtc_device *rtc =i2c_get_clientdata (client); -dev_dbg (&client->dev,"%s\n" , __FUNCTION__); -if (rtc)rtc_device_unregister (rtc);
drivers/rtc/rtc-m48t86.c +1 -1
@@ -23,7 +23,7 @@#define M48T86_REG_SECALRM 0x01#define M48T86_REG_MIN 0x02#define M48T86_REG_MINALRM 0x03 -#define M48T86_REG_HOUR 0x04 +#define M48T86_REG_HOUR 0x04#define M48T86_REG_HOURALRM 0x05#define M48T86_REG_DOW 0x06/* 1 = sunday */ #define M48T86_REG_DOM 0x07
--
PATCH 5/10 RTC subsystem, fix proc output
In reply to Alessandro ZummoMoved the "24hr: yes" proc output from drivers to rtc proc code. This is required because the time value in the proc output is always in 24hr mode regardless of the driver.
--- drivers/rtc/rtc-ep93xx.c | 1 - drivers/rtc/rtc-m48t86.c | 3 --- drivers/rtc/rtc-pcf8563.c | 7 ------- drivers/rtc/rtc-proc.c | 2 ++ drivers/rtc/rtc-rs5c372.c | 5 ++--- drivers/rtc/rtc-test.c | 1 - drivers/rtc/rtc-x1205.c | 2 -- 7 files changed, 4 insertions(+), 17 deletions(-)
drivers/rtc/rtc-ep93xx.c +0 -1
@@ -67,7 +67,6 @@ static int ep93xx_rtc_proc(struct deviceep93xx_get_swcomp (dev, &preload, &delete); -seq_printf (seq,"24hr\t\t: yes\n" );seq_printf (seq,"preload\t\t: %d\n" , preload);seq_printf (seq,"delete\t\t: %d\n" , delete);
drivers/rtc/rtc-pcf8563.c +0 -7
@@ -227,14 +227,7 @@ static int pcf8563_rtc_set_time(struct dreturn pcf8563_set_datetime (to_i2c_client (dev), tm); } -static int pcf8563_rtc_proc (struct device *dev,struct seq_file *seq) -{ -seq_printf (seq,"24hr\t\t: yes\n" ); -return 0 ; -} -static struct rtc_class_ops pcf8563_rtc_ops = { - .proc = pcf8563_rtc_proc, .read_time = pcf8563_rtc_read_time, .set_time = pcf8563_rtc_set_time, };
drivers/rtc/rtc-proc.c +2 -0
@@ -71,6 +71,8 @@ static int rtc_proc_show(struct seq_file alrm.pending ? "yes" : "no"); } +seq_printf (seq,"24hr\t\t: yes\n" ); +if (ops->proc) ops->proc (class_dev->dev, seq);
drivers/rtc/rtc-rs5c372.c +2 -3
@@ -151,9 +151,8 @@ static int rs5c372_rtc_proc(struct devic {int err, osc, trim; -seq_printf (seq,"24hr\t\t: yes\n" ); - -if ((err =rs5c372_get_trim (to_i2c_client (dev), &osc, &trim)) ==0 ) { + err =rs5c372_get_trim (to_i2c_client (dev), &osc, &trim); +if (err ==0 ) {seq_printf (seq,"%d.%03d KHz\n" , osc /1000 , osc %1000 );seq_printf (seq,"trim\t: %d\n" , trim); }
drivers/rtc/rtc-x1205.c +0 -2
@@ -451,8 +451,6 @@ static int x1205_rtc_proc(struct device {int err, dtrim, atrim; -seq_printf (seq,"24hr\t\t: yes\n" ); -if ((err =x1205_get_dtrim (to_i2c_client (dev), &dtrim)) ==0 )seq_printf (seq,"digital_trim\t: %d ppm\n" , dtrim);
drivers/rtc/rtc-m48t86.c +0 -3
@@ -127,9 +127,6 @@ static int m48t86_rtc_proc(struct device reg = ops->readb (M48T86_REG_B ); -seq_printf (seq,"24hr\t\t: %s\n" , - (reg &M48T86_REG_B_H24 ) ?"yes" :"no" ); -seq_printf (seq,"mode\t\t: %s\n" , (reg &M48T86_REG_B_DM ) ?"binary" :"bcd" );
drivers/rtc/rtc-test.c +0 -1
@@ -49,7 +49,6 @@ static int test_rtc_proc(struct device * {struct platform_device *plat_dev =to_platform_device (dev); -seq_printf (seq,"24hr\t\t: yes\n" );seq_printf (seq,"test\t\t: yes\n" );seq_printf (seq,"id\t\t: %d\n" , plat_dev->id);
--
PATCH 6/10 RTC subsystem, RS5C372 sysfs fix
In reply to Alessandro Zummo fixed sysfs show() return code
--- drivers/rtc/rtc-rs5c372.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/rtc/rtc-rs5c372.c +10 -8
@@ -169,24 +169,26 @@ static struct rtc_class_ops rs5c372_rtc_static ssize_t rs5c372_sysfs_show_trim (struct device *dev,struct device_attribute *attr,char *buf) { -int trim; +int err, trim; -if (rs5c372_get_trim (to_i2c_client (dev),NULL , &trim) ==0 ) -return sprintf (buf,"0x%2x\n" , trim); + err =rs5c372_get_trim (to_i2c_client (dev),NULL , &trim); +if (err) +return err; -return 0 ; +return sprintf (buf,"0x%2x\n" , trim); } static DEVICE_ATTR(trim, S_IRUGO, rs5c372_sysfs_show_trim, NULL);static ssize_t rs5c372_sysfs_show_osc (struct device *dev,struct device_attribute *attr,char *buf) { -int osc; +int err, osc; -if (rs5c372_get_trim (to_i2c_client (dev), &osc,NULL ) ==0 ) -return sprintf (buf,"%d.%03d KHz\n" , osc /1000 , osc %1000 ); + err =rs5c372_get_trim (to_i2c_client (dev), &osc,NULL ); +if (err) +return err; -return 0 ; +return sprintf (buf,"%d.%03d KHz\n" , osc /1000 , osc %1000 ); } static DEVICE_ATTR(osc, S_IRUGO, rs5c372_sysfs_show_osc, NULL);
--
PATCH 7/10 RTC subsystem, compact error messages
In reply to Alessandro Zummo - move registration error message from drivers
to core.
--- drivers/rtc/class.c | 2 ++ drivers/rtc/rtc-ds1672.c | 2 -- drivers/rtc/rtc-ep93xx.c | 1 - drivers/rtc/rtc-m48t86.c | 4 +--- drivers/rtc/rtc-pcf8563.c | 2 -- drivers/rtc/rtc-rs5c372.c | 2 -- drivers/rtc/rtc-sa1100.c | 1 - drivers/rtc/rtc-test.c | 2 -- drivers/rtc/rtc-x1205.c | 2 -- 9 files changed, 3 insertions(+), 15 deletions(-)
drivers/rtc/class.c +2 -0
@@ -96,6 +96,8 @@ exit_idr:idr_remove (&rtc_idr, id); exit: +dev_err (dev,"rtc core: unable to register %s, err = %d\n" , + name, err);return ERR_PTR (err); }EXPORT_SYMBOL_GPL (rtc_device_register);
drivers/rtc/rtc-x1205.c +0 -2
@@ -544,8 +544,6 @@ static int x1205_probe(struct i2c_adapteif (IS_ERR (rtc)) { err =PTR_ERR (rtc); -dev_err (&client->dev, -"unable to register the class device\n" ); goto exit_detach; }
drivers/rtc/rtc-ds1672.c +0 -2
@@ -229,8 +229,6 @@ static int ds1672_probe(struct i2c_adaptif (IS_ERR (rtc)) { err =PTR_ERR (rtc); -dev_err (&client->dev, -"unable to register the class device\n" ); goto exit_detach; }
drivers/rtc/rtc-m48t86.c +1 -3
@@ -151,10 +151,8 @@ static int __devinit m48t86_rtc_probe(ststruct rtc_device *rtc =rtc_device_register ("m48t86" , &dev->dev, &m48t86_rtc_ops,THIS_MODULE ); -if (IS_ERR (rtc)) { -dev_err (&dev->dev,"unable to register\n" ); +if (IS_ERR (rtc))return PTR_ERR (rtc); - }platform_set_drvdata (dev, rtc);
drivers/rtc/rtc-pcf8563.c +0 -2
@@ -290,8 +290,6 @@ static int pcf8563_probe(struct i2c_adapif (IS_ERR (rtc)) { err =PTR_ERR (rtc); -dev_err (&client->dev, -"unable to register the class device\n" ); goto exit_detach; }
drivers/rtc/rtc-test.c +0 -2
@@ -119,8 +119,6 @@ static int test_probe(struct platform_de &test_rtc_ops, THIS_MODULE);if (IS_ERR (rtc)) { err =PTR_ERR (rtc); -dev_err (&plat_dev->dev, -"unable to register the class device\n" );return err; }device_create_file (&plat_dev->dev, &dev_attr_irq);
drivers/rtc/rtc-ep93xx.c +0 -1
@@ -109,7 +109,6 @@ static int __devinit ep93xx_rtc_probe(st &dev->dev, &ep93xx_rtc_ops, THIS_MODULE);if (IS_ERR (rtc)) { -dev_err (&dev->dev,"unable to register\n" );return PTR_ERR (rtc); }
drivers/rtc/rtc-sa1100.c +0 -1
@@ -341,7 +341,6 @@ static int sa1100_rtc_probe(struct platf THIS_MODULE);if (IS_ERR (rtc)) { -dev_err (&pdev->dev,"Unable to register the RTC device\n" );return PTR_ERR (rtc); }
drivers/rtc/rtc-rs5c372.c +0 -2
@@ -233,8 +233,6 @@ static int rs5c372_probe(struct i2c_adapif (IS_ERR (rtc)) { err =PTR_ERR (rtc); -dev_err (&client->dev, -"unable to register the class device\n" ); goto exit_detach; }
--
PATCH 8/10 RTC subsystem, SA1100 cleanup
In reply to Alessandro Zummo - converted printks to dev_xxx
- removed messages in excess
--- drivers/rtc/rtc-sa1100.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/rtc/rtc-sa1100.c +5 -8
@@ -160,19 +160,19 @@ static int sa1100_rtc_open(struct device ret =request_irq (IRQ_RTC1Hz, sa1100_rtc_interrupt,SA_INTERRUPT ,"rtc 1Hz" , dev);if (ret) { -printk (KERN_ERR "rtc: IRQ%d already in use.\n" , IRQ_RTC1Hz); +dev_err (dev,"IRQ %d already in use.\n" , IRQ_RTC1Hz); goto fail_ui; } ret =request_irq (IRQ_RTCAlrm, sa1100_rtc_interrupt,SA_INTERRUPT ,"rtc Alrm" , dev);if (ret) { -printk (KERN_ERR "rtc: IRQ%d already in use.\n" , IRQ_RTCAlrm); +dev_err (dev,"IRQ %d already in use.\n" , IRQ_RTCAlrm); goto fail_ai; } ret =request_irq (IRQ_OST1 , timer1_interrupt,SA_INTERRUPT ,"rtc timer" , dev);if (ret) { -printk (KERN_ERR "rtc: IRQ%d already in use.\n" ,IRQ_OST1 ); +dev_err (dev,"IRQ %d already in use.\n" ,IRQ_OST1 ); goto fail_pi; }return 0 ;
@@ -332,7 +332,7 @@ static int sa1100_rtc_probe(struct platf*/ if (RTTR ==0 ) {RTTR =RTC_DEF_DIVIDER + (RTC_DEF_TRIM <<16 ); -printk (KERN_WARNING "rtc: warning: initializing default clock divider/trim value\n" ); +dev_warn (&pdev->dev,"warning: initializing default clock divider/trim value\n" );/* The current RTC value probably doesn't make sense either */ RCNR =0 ; }
@@ -340,14 +340,11 @@ static int sa1100_rtc_probe(struct platf rtc =rtc_device_register (pdev->name, &pdev->dev, &sa1100_rtc_ops,THIS_MODULE ); -if (IS_ERR (rtc)) { +if (IS_ERR (rtc))return PTR_ERR (rtc); - }platform_set_drvdata (pdev, rtc); -dev_info (&pdev->dev,"SA11xx/PXA2xx RTC Registered\n" ); -return 0 ; }
--
Re: [PATCH 08/10] RTC subsystem, SA1100 cleanup
Quoted 5 lines · Alessandro Zummo
- converted printks to
dev_xxx
- removed messages in excessSigned-off-by Alessandro Zummo <[email protected]>Cc Richard Purdie <[email protected]>
Looks good to me.
Pavel
Signature · 1 line
Picture of sleeping (Linux) penguin wanted...
PATCH 9/10 RTC subsystem, VR41XX driver
In reply to Alessandro ZummoFrom: Yoichi Yuasa <[email protected]>
Hi,
This patch updates VR4100 series RTC driver.
* This driver supports new RTC subsystem.
* Simple set time/read time test worked fine.
Yoichi
drivers/char/Kconfig +0 -4
@@ -788,10 +788,6 @@ config S3C2410_RTC Samsung S3C2410. This can provide periodic interrupt rates from 1Hz to 64Hz for user programs, and wakeup from Alarm. -config RTC_VR41XX - tristate "NEC VR4100 series Real Time Clock Support" - depends on CPU_VR41XX - config COBALT_LCD bool "Support for Cobalt LCD" depends on MIPS_COBALT
drivers/char/Makefile +0 -1
@@ -65,7 +65,6 @@ obj-$(CONFIG_SGI_DS1286) += ds1286.o obj-$(CONFIG_SGI_IP27_RTC) += ip27-rtc.o obj-$(CONFIG_DS1302) += ds1302.o obj-$(CONFIG_S3C2410_RTC) += s3c2410-rtc.o -obj-$(CONFIG_RTC_VR41XX) += vr41xx_rtc.o ifeq ($(CONFIG_GENERIC_NVRAM),y) obj-$(CONFIG_NVRAM) += generic_nvram.o else
drivers/char/vr41xx_rtc.c +0 -717
717 lines not on this page · raw message
drivers/rtc/Kconfig +4 -0
@@ -147,6 +147,10 @@ config RTC_DRV_SA1100 To compile this driver as a module, choose M here: the module will be called rtc-sa1100. +config RTC_DRV_VR41XX + tristate "NEC VR4100 series RTC" + depends on RTC_CLASS && CPU_VR41XX + config RTC_DRV_TEST tristate "Test driver/device" depends on RTC_CLASS
drivers/rtc/Makefile +1 -0
@@ -19,3 +19,4 @@ obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5 obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o obj-$(CONFIG_RTC_DRV_EP93XX) += rtc-ep93xx.o obj-$(CONFIG_RTC_DRV_SA1100) += rtc-sa1100.o +obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o
drivers/rtc/rtc-vr41xx.c +471 -0
471 lines not on this page · raw message
--
Re: [PATCH 09/10] RTC subsystem, VR41XX driver
Quoted 2 lines · Alessandro Zummo
This patch updates VR4100 series RTC driver.
It also renames the driver's .c file. This makes it quite hard for reviewers to see what was changed.
When you have patches which move large amounts of code around, please make sure that the patch does *only* that. Functional changes should happen in later patches.
PATCH 10/10 RTC subsystem, VR41XX cleanup
In reply to Alessandro ZummoCleaned up kconfig entry for the rtc-vr41xx.
--- drivers/rtc/Kconfig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/rtc/Kconfig +7 -1
@@ -148,8 +148,14 @@ config RTC_DRV_SA1100 module will be called rtc-sa1100. config RTC_DRV_VR41XX - tristate "NEC VR4100 series RTC" + tristate "NEC VR41XX" depends on RTC_CLASS && CPU_VR41XX + help + If you say Y here you will get access to the real time clock + built into your NEC VR41XX CPU. + + To compile this driver as a module, choose M here: the + module will be called rtc-vr41xx. config RTC_DRV_TEST tristate "Test driver/device"
--
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): 20060503105816.65f309f8@inspiron
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): 20060503121354.61bf3558@inspiron
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): 20060503122555.5337523f@inspiron
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): 20060503132301.52a75dcd@inspiron
Re: drivers/acorn/char/pcf8583.[hc] vs. RTC subsystem
Quoted 10 lines · Guennadi Liakhovetski
Quoted 4 lines · Russell King
I doubt we could switch - we need to read the year from the memory part and that's specific to Acorn machines. The PCF8583 has a 2 bit year counter which is totally useless, so Acorn machines keep track of the year in the CMOS part of the chip.
The driver I've submitted does exactly this. It is a CMOS built into the pcf, so, why not just use it for that?
Quoted 6 lines
Quoted 4 lines
Hence to _correctly_ interpret the time and date from the clock, you _have_ to have this special knowledge built in to the driver. That won't be suitable for other setups, so I don't see how you could sanely combine the drivers and keep the functionality.
Why do you think it is unsuitable for others?
Russell, as you haven't replied, I take it as an agreement with this patch, leaving the original driver under drivers/acorn so far alone.
Quoted 9 lines · Alessandro Zummo
Quoted 6 lines · On Wed, 3 May 2006 12:49:16 +0200 (CEST) Guennadi Liakhovetski <[email protected]>…
Ok, the patch is attached (sorry, this my pine is still not configured properly for inlining, if it is a problem, will resend from home), so the interested parties can already review it, but I would still wait for Russell's opinion, I am not quite excited by the idea of having 2 drivers for pcf8583 in the kernel:-)
Quoted 6 lines
ok. here is my
Signed-off-by Alessandro Zummo <[email protected]>when you feel ready, you can send it to Andrew Morton for inclusion in -mm.
The unmodified patch is below. Andrew, please, apply.
Thanks
Guennadi
---
Guennadi Liakhovetski
drivers/rtc/rtc-pcf8583.c new file +394 -0
@@ -0,0 +1,394 @@ +/* +* drivers/rtc/rtc-pcf8583.c +* +* Copyright (C) 2000 Russell King +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* Driver for PCF8583 RTC & RAM chip +* +* Converted to the generic RTC susbsystem by G. Liakhovetski (2006) +*/ +#include <linux/module.h> +#include <linux/i2c.h> +#include <linux/slab.h> +#include <linux/string.h> +#include <linux/mc146818rtc.h> +#include <linux/init.h> +#include <linux/errno.h> +#include <linux/bcd.h> + +struct rtc_mem { +unsigned int loc; +unsigned int nr; +unsigned char *data; +}; + +struct pcf8583 { +struct i2c_client client; +struct rtc_device *rtc; +unsigned char ctrl; +}; + +#define CTRL_STOP 0x80 +#define CTRL_HOLD 0x40 +#define CTRL_32KHZ 0x00 +#define CTRL_MASK 0x08 +#define CTRL_ALARMEN 0x04 +#define CTRL_ALARM 0x02 +#define CTRL_TIMER 0x01 + +static unsigned short normal_i2c[] = {I2C_CLIENT_END }; + +/* Module parameters */ +I2C_CLIENT_INSMOD ; + +static struct i2c_driver pcf8583_driver; + +#define get_ctrl (x) ((struct pcf8583 *)i2c_get_clientdata(x))->ctrl +#define set_ctrl (x, v) get_ctrl(x) = v + +#define CMOS_YEAR (64 + 128) +#define CMOS_CHECKSUM (63) + +static int pcf8583_get_datetime (struct i2c_client *client,struct rtc_time *dt) +{ +unsigned char buf[8 ], addr[1 ] = {1 }; +struct i2c_msg msgs[2 ] = { + { + .addr = client->addr, + .flags =0 , + .len =1 , + .buf = addr, + }, { + .addr = client->addr, + .flags =I2C_M_RD , + .len =6 , + .buf = buf, + } + }; +int ret; + +memset (buf,0 ,sizeof (buf)); + + ret =i2c_transfer (client->adapter, msgs,2 ); +if (ret ==2 ) { + dt->tm_year = buf[4 ] >>6 ; + dt->tm_wday = buf[5 ] >>5 ; + + buf[4 ] &=0x3f ; + buf[5 ] &=0x1f ; + + dt->tm_sec =BCD_TO_BIN (buf[1 ]); + dt->tm_min =BCD_TO_BIN (buf[2 ]); + dt->tm_hour =BCD_TO_BIN (buf[3 ]); + dt->tm_mday =BCD_TO_BIN (buf[4 ]); + dt->tm_mon =BCD_TO_BIN (buf[5 ]); + } + +return ret ==2 ?0 : -EIO ; +} + +static int pcf8583_set_datetime (struct i2c_client *client,struct rtc_time *dt,int datetoo) +{ +unsigned char buf[8 ]; +int ret, len =6 ; + + buf[0 ] =0 ; + buf[1 ] =get_ctrl (client) |0x80 ; + buf[2 ] =0 ; + buf[3 ] =BIN_TO_BCD (dt->tm_sec); + buf[4 ] =BIN_TO_BCD (dt->tm_min); + buf[5 ] =BIN_TO_BCD (dt->tm_hour); + +if (datetoo) { + len =8 ; + buf[6 ] =BIN_TO_BCD (dt->tm_mday) | (dt->tm_year <<6 ); + buf[7 ] =BIN_TO_BCD (dt->tm_mon) | (dt->tm_wday <<5 ); + } + + ret =i2c_master_send (client, (char *)buf, len); +if (ret != len) +return -EIO ; + + buf[1 ] =get_ctrl (client); + ret =i2c_master_send (client, (char *)buf,2 ); + +return ret ==2 ?0 : -EIO ; +} + +static int pcf8583_get_ctrl (struct i2c_client *client,unsigned char *ctrl) +{ + *ctrl =get_ctrl (client); +return 0 ; +} + +static int pcf8583_set_ctrl (struct i2c_client *client,unsigned char *ctrl) +{ +unsigned char buf[2 ]; + + buf[0 ] =0 ; + buf[1 ] = *ctrl; +set_ctrl (client, *ctrl); + +return i2c_master_send (client, (char *)buf,2 ); +} + +static int pcf8583_read_mem (struct i2c_client *client,struct rtc_mem *mem) +{ +unsigned char addr[1 ]; +struct i2c_msg msgs[2 ] = { + { + .addr = client->addr, + .flags =0 , + .len =1 , + .buf = addr, + }, { + .addr = client->addr, + .flags =I2C_M_RD , + .len = mem->nr, + .buf = mem->data, + } + }; + +if (mem->loc <8 ) +return -EINVAL ; + + addr[0 ] = mem->loc; + +return i2c_transfer (client->adapter, msgs,2 ) ==2 ?0 : -EIO ; +} + +static int pcf8583_write_mem (struct i2c_client *client,struct rtc_mem *mem) +{ +unsigned char addr[1 ]; +struct i2c_msg msgs[2 ] = { + { + .addr = client->addr, + .flags =0 , + .len =1 , + .buf = addr, + }, { + .addr = client->addr, + .flags =I2C_M_NOSTART , + .len = mem->nr, + .buf = mem->data, + } + }; + +if (mem->loc <8 ) +return -EINVAL ; + + addr[0 ] = mem->loc; + +return i2c_transfer (client->adapter, msgs,2 ) ==2 ?0 : -EIO ; +} + +static int pcf8583_rtc_read_time (struct device *dev,struct rtc_time *tm) +{ +struct i2c_client *client =to_i2c_client (dev); +unsigned char ctrl, year[2 ]; +struct rtc_mem mem = {CMOS_YEAR ,sizeof (year), year }; +int real_year, year_offset, err; + +/* +* Ensure that the RTC is running. +*/ +pcf8583_get_ctrl (client, &ctrl); +if (ctrl & (CTRL_STOP |CTRL_HOLD )) { +unsigned char new_ctrl = ctrl & ~(CTRL_STOP |CTRL_HOLD ); + +printk (KERN_WARNING "RTC: resetting control %02x -> %02x\n" , + ctrl, new_ctrl); + +if ((err =pcf8583_set_ctrl (client, &new_ctrl)) <0 ) +return err; + } + +if (pcf8583_get_datetime (client, tm) || +pcf8583_read_mem (client, &mem)) +return -EIO ; + + real_year = year[0 ]; + +/* +* The RTC year holds the LSB two bits of the current +* year, which should reflect the LSB two bits of the +* CMOS copy of the year. Any difference indicates +* that we have to correct the CMOS version. +*/ + year_offset = tm->tm_year - (real_year &3 ); +if (year_offset <0 ) +/* +* RTC year wrapped. Adjust it appropriately. +*/ + year_offset +=4 ; + + tm->tm_year = real_year + year_offset + year[1 ] *100 ; + +return 0 ; +} + +static int pcf8583_rtc_set_time (struct device *dev,struct rtc_time *tm) +{ +struct i2c_client *client =to_i2c_client (dev); +unsigned char year[2 ], chk; +struct rtc_mem cmos_year = {CMOS_YEAR ,sizeof (year), year }; +struct rtc_mem cmos_check = {CMOS_CHECKSUM ,1 , &chk }; +int ret; + +/* +* The RTC's own 2-bit year must reflect the least +* significant two bits of the CMOS year. +*/ + + ret =pcf8583_set_datetime (client, tm,1 ); +if (ret) +return ret; + + ret =pcf8583_read_mem (client, &cmos_check); +if (ret) +return ret; + + ret =pcf8583_read_mem (client, &cmos_year); +if (ret) +return ret; + + chk -= year[1 ] + year[0 ]; + + year[1 ] = tm->tm_year /100 ; + year[0 ] = tm->tm_year %100 ; + + chk += year[1 ] + year[0 ]; + + ret =pcf8583_write_mem (client, &cmos_year); + +if (ret) +return ret; + + ret =pcf8583_write_mem (client, &cmos_check); + +return ret; +} + +static struct rtc_class_ops pcf8583_rtc_ops = { + .read_time = pcf8583_rtc_read_time, + .set_time = pcf8583_rtc_set_time, +}; + +static int pcf8583_probe (struct i2c_adapter *adap,int addr,int kind); + +static int pcf8583_attach (struct i2c_adapter *adap) +{ +return i2c_probe (adap, &addr_data, pcf8583_probe); +} + +static int pcf8583_detach (struct i2c_client *client) +{ +int err; +struct pcf8583 *pcf =i2c_get_clientdata (client); +struct rtc_device *rtc = pcf->rtc; + +if (rtc) +rtc_device_unregister (rtc); + +if ((err =i2c_detach_client (client))) +return err; + +kfree (pcf); +return 0 ; +} + +static struct i2c_driver pcf8583_driver = { + .driver = { + .name ="pcf8583" , + }, + .id =I2C_DRIVERID_PCF8583 , + .attach_adapter = pcf8583_attach, + .detach_client = pcf8583_detach, +}; + +static int pcf8583_probe (struct i2c_adapter *adap,int addr,int kind) +{ +struct pcf8583 *pcf; +struct i2c_client *client; +struct rtc_device *rtc; +unsigned char buf[1 ], ad[1 ] = {0 }; +int err; +struct i2c_msg msgs[2 ] = { + { + .addr = addr, + .flags =0 , + .len =1 , + .buf = ad, + }, { + .addr = addr, + .flags =I2C_M_RD , + .len =1 , + .buf = buf, + } + }; + + pcf =kzalloc (sizeof (*pcf),GFP_KERNEL ); +if (!pcf) +return -ENOMEM ; + + client = &pcf->client; + + client->addr = addr; + client->adapter = adap; + client->driver = &pcf8583_driver; + +strlcpy (client->name, pcf8583_driver.driver.name,I2C_NAME_SIZE ); + +if (i2c_transfer (client->adapter, msgs,2 ) !=2 ) { + err = -EIO ; + goto exit_kfree; + } + + err =i2c_attach_client (client); + +if (err) + goto exit_kfree; + + rtc =rtc_device_register (pcf8583_driver.driver.name, &client->dev, + &pcf8583_rtc_ops,THIS_MODULE ); + +if (IS_ERR (rtc)) { + err =PTR_ERR (rtc); + goto exit_detach; + } + + pcf->rtc = rtc; +i2c_set_clientdata (client, pcf); +set_ctrl (client, buf[0 ]); + +return 0 ; + +exit_detach: +i2c_detach_client (client); + +exit_kfree: +kfree (pcf); + +return err; +} + +static __init int pcf8583_init (void ) +{ +return i2c_add_driver (&pcf8583_driver); +} + +static __exit void pcf8583_exit(void) +{ +i2c_del_driver (&pcf8583_driver); +} + +module_init (pcf8583_init); +module_exit (pcf8583_exit); + +MODULE_AUTHOR ("Russell King" ); +MODULE_DESCRIPTION ("PCF8583 I2C RTC driver" ); +MODULE_LICENSE ("GPL" );
drivers/rtc/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_RTC_DRV_TEST) += rtc-test.o obj-$(CONFIG_RTC_DRV_DS1672) += rtc-ds1672.o obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o +obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5c372.o obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o obj-$(CONFIG_RTC_DRV_EP93XX) += rtc-ep93xx.o
drivers/rtc/Kconfig +10 -0
@@ -107,6 +107,16 @@ This driver can also be built as a module. If so, the module will be called rtc-pcf8563. +config RTC_DRV_PCF8583 + tristate "Philips PCF8583" + depends on RTC_CLASS && I2C + help + If you say yes here you get support for the + Philips PCF8583 RTC chip. + + This driver can also be built as a module. If so, the module + will be called rtc-pcf8583. + config RTC_DRV_RS5C372 tristate "Ricoh RS5C372A/B" depends on RTC_CLASS && I2C