aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-ds1302.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-ds1302.c')
-rw-r--r--drivers/rtc/rtc-ds1302.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/rtc/rtc-ds1302.c b/drivers/rtc/rtc-ds1302.c
index d13954346286..07e8d79b4a09 100644
--- a/drivers/rtc/rtc-ds1302.c
+++ b/drivers/rtc/rtc-ds1302.c
@@ -23,8 +23,12 @@
23#define RTC_CMD_READ 0x81 /* Read command */ 23#define RTC_CMD_READ 0x81 /* Read command */
24#define RTC_CMD_WRITE 0x80 /* Write command */ 24#define RTC_CMD_WRITE 0x80 /* Write command */
25 25
26#define RTC_CMD_WRITE_ENABLE 0x00 /* Write enable */
27#define RTC_CMD_WRITE_DISABLE 0x80 /* Write disable */
28
26#define RTC_ADDR_RAM0 0x20 /* Address of RAM0 */ 29#define RTC_ADDR_RAM0 0x20 /* Address of RAM0 */
27#define RTC_ADDR_TCR 0x08 /* Address of trickle charge register */ 30#define RTC_ADDR_TCR 0x08 /* Address of trickle charge register */
31#define RTC_ADDR_CTRL 0x07 /* Address of control register */
28#define RTC_ADDR_YEAR 0x06 /* Address of year register */ 32#define RTC_ADDR_YEAR 0x06 /* Address of year register */
29#define RTC_ADDR_DAY 0x05 /* Address of day of week register */ 33#define RTC_ADDR_DAY 0x05 /* Address of day of week register */
30#define RTC_ADDR_MON 0x04 /* Address of month register */ 34#define RTC_ADDR_MON 0x04 /* Address of month register */
@@ -161,6 +165,7 @@ static int ds1302_rtc_read_time(struct device *dev, struct rtc_time *tm)
161 165
162static int ds1302_rtc_set_time(struct device *dev, struct rtc_time *tm) 166static int ds1302_rtc_set_time(struct device *dev, struct rtc_time *tm)
163{ 167{
168 ds1302_writebyte(RTC_ADDR_CTRL, RTC_CMD_WRITE_ENABLE);
164 /* Stop RTC */ 169 /* Stop RTC */
165 ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) | 0x80); 170 ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) | 0x80);
166 171
@@ -175,6 +180,8 @@ static int ds1302_rtc_set_time(struct device *dev, struct rtc_time *tm)
175 /* Start RTC */ 180 /* Start RTC */
176 ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) & ~0x80); 181 ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) & ~0x80);
177 182
183 ds1302_writebyte(RTC_ADDR_CTRL, RTC_CMD_WRITE_DISABLE);
184
178 return 0; 185 return 0;
179} 186}
180 187
@@ -234,19 +241,11 @@ static int __init ds1302_rtc_probe(struct platform_device *pdev)
234 return 0; 241 return 0;
235} 242}
236 243
237static int __exit ds1302_rtc_remove(struct platform_device *pdev)
238{
239 platform_set_drvdata(pdev, NULL);
240
241 return 0;
242}
243
244static struct platform_driver ds1302_platform_driver = { 244static struct platform_driver ds1302_platform_driver = {
245 .driver = { 245 .driver = {
246 .name = DRV_NAME, 246 .name = DRV_NAME,
247 .owner = THIS_MODULE, 247 .owner = THIS_MODULE,
248 }, 248 },
249 .remove = __exit_p(ds1302_rtc_remove),
250}; 249};
251 250
252module_platform_driver_probe(ds1302_platform_driver, ds1302_rtc_probe); 251module_platform_driver_probe(ds1302_platform_driver, ds1302_rtc_probe);