aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-x1205.c
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /drivers/rtc/rtc-x1205.c
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'drivers/rtc/rtc-x1205.c')
-rw-r--r--drivers/rtc/rtc-x1205.c106
1 files changed, 26 insertions, 80 deletions
diff --git a/drivers/rtc/rtc-x1205.c b/drivers/rtc/rtc-x1205.c
index f36e59c6bc0..b00aad2620d 100644
--- a/drivers/rtc/rtc-x1205.c
+++ b/drivers/rtc/rtc-x1205.c
@@ -21,7 +21,6 @@
21#include <linux/bcd.h> 21#include <linux/bcd.h>
22#include <linux/rtc.h> 22#include <linux/rtc.h>
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/module.h>
25 24
26#define DRV_VERSION "1.0.8" 25#define DRV_VERSION "1.0.8"
27 26
@@ -97,17 +96,8 @@ static int x1205_get_datetime(struct i2c_client *client, struct rtc_time *tm,
97 int i; 96 int i;
98 97
99 struct i2c_msg msgs[] = { 98 struct i2c_msg msgs[] = {
100 {/* setup read ptr */ 99 { client->addr, 0, 2, dt_addr }, /* setup read ptr */
101 .addr = client->addr, 100 { client->addr, I2C_M_RD, 8, buf }, /* read date */
102 .len = 2,
103 .buf = dt_addr
104 },
105 {/* read date */
106 .addr = client->addr,
107 .flags = I2C_M_RD,
108 .len = 8,
109 .buf = buf
110 },
111 }; 101 };
112 102
113 /* read date registers */ 103 /* read date registers */
@@ -151,17 +141,8 @@ static int x1205_get_status(struct i2c_client *client, unsigned char *sr)
151 static unsigned char sr_addr[2] = { 0, X1205_REG_SR }; 141 static unsigned char sr_addr[2] = { 0, X1205_REG_SR };
152 142
153 struct i2c_msg msgs[] = { 143 struct i2c_msg msgs[] = {
154 { /* setup read ptr */ 144 { client->addr, 0, 2, sr_addr }, /* setup read ptr */
155 .addr = client->addr, 145 { client->addr, I2C_M_RD, 1, sr }, /* read status */
156 .len = 2,
157 .buf = sr_addr
158 },
159 { /* read status */
160 .addr = client->addr,
161 .flags = I2C_M_RD,
162 .len = 1,
163 .buf = sr
164 },
165 }; 146 };
166 147
167 /* read status register */ 148 /* read status register */
@@ -297,17 +278,8 @@ static int x1205_get_dtrim(struct i2c_client *client, int *trim)
297 static unsigned char dtr_addr[2] = { 0, X1205_REG_DTR }; 278 static unsigned char dtr_addr[2] = { 0, X1205_REG_DTR };
298 279
299 struct i2c_msg msgs[] = { 280 struct i2c_msg msgs[] = {
300 { /* setup read ptr */ 281 { client->addr, 0, 2, dtr_addr }, /* setup read ptr */
301 .addr = client->addr, 282 { client->addr, I2C_M_RD, 1, &dtr }, /* read dtr */
302 .len = 2,
303 .buf = dtr_addr
304 },
305 { /* read dtr */
306 .addr = client->addr,
307 .flags = I2C_M_RD,
308 .len = 1,
309 .buf = &dtr
310 },
311 }; 283 };
312 284
313 /* read dtr register */ 285 /* read dtr register */
@@ -338,17 +310,8 @@ static int x1205_get_atrim(struct i2c_client *client, int *trim)
338 static unsigned char atr_addr[2] = { 0, X1205_REG_ATR }; 310 static unsigned char atr_addr[2] = { 0, X1205_REG_ATR };
339 311
340 struct i2c_msg msgs[] = { 312 struct i2c_msg msgs[] = {
341 {/* setup read ptr */ 313 { client->addr, 0, 2, atr_addr }, /* setup read ptr */
342 .addr = client->addr, 314 { client->addr, I2C_M_RD, 1, &atr }, /* read atr */
343 .len = 2,
344 .buf = atr_addr
345 },
346 {/* read atr */
347 .addr = client->addr,
348 .flags = I2C_M_RD,
349 .len = 1,
350 .buf = &atr
351 },
352 }; 315 };
353 316
354 /* read atr register */ 317 /* read atr register */
@@ -417,17 +380,8 @@ static int x1205_validate_client(struct i2c_client *client)
417 unsigned char addr[2] = { 0, probe_zero_pattern[i] }; 380 unsigned char addr[2] = { 0, probe_zero_pattern[i] };
418 381
419 struct i2c_msg msgs[2] = { 382 struct i2c_msg msgs[2] = {
420 { 383 { client->addr, 0, 2, addr },
421 .addr = client->addr, 384 { client->addr, I2C_M_RD, 1, &buf },
422 .len = 2,
423 .buf = addr
424 },
425 {
426 .addr = client->addr,
427 .flags = I2C_M_RD,
428 .len = 1,
429 .buf = &buf
430 },
431 }; 385 };
432 386
433 if ((xfer = i2c_transfer(client->adapter, msgs, 2)) != 2) { 387 if ((xfer = i2c_transfer(client->adapter, msgs, 2)) != 2) {
@@ -454,17 +408,8 @@ static int x1205_validate_client(struct i2c_client *client)
454 unsigned char addr[2] = { 0, probe_limits_pattern[i].reg }; 408 unsigned char addr[2] = { 0, probe_limits_pattern[i].reg };
455 409
456 struct i2c_msg msgs[2] = { 410 struct i2c_msg msgs[2] = {
457 { 411 { client->addr, 0, 2, addr },
458 .addr = client->addr, 412 { client->addr, I2C_M_RD, 1, &reg },
459 .len = 2,
460 .buf = addr
461 },
462 {
463 .addr = client->addr,
464 .flags = I2C_M_RD,
465 .len = 1,
466 .buf = &reg
467 },
468 }; 413 };
469 414
470 if ((xfer = i2c_transfer(client->adapter, msgs, 2)) != 2) { 415 if ((xfer = i2c_transfer(client->adapter, msgs, 2)) != 2) {
@@ -498,18 +443,8 @@ static int x1205_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
498 static unsigned char int_addr[2] = { 0, X1205_REG_INT }; 443 static unsigned char int_addr[2] = { 0, X1205_REG_INT };
499 struct i2c_client *client = to_i2c_client(dev); 444 struct i2c_client *client = to_i2c_client(dev);
500 struct i2c_msg msgs[] = { 445 struct i2c_msg msgs[] = {
501 { /* setup read ptr */ 446 { client->addr, 0, 2, int_addr }, /* setup read ptr */
502 .addr = client->addr, 447 { client->addr, I2C_M_RD, 1, &intreg }, /* read INT register */
503 .len = 2,
504 .buf = int_addr
505 },
506 {/* read INT register */
507
508 .addr = client->addr,
509 .flags = I2C_M_RD,
510 .len = 1,
511 .buf = &intreg
512 },
513 }; 448 };
514 449
515 /* read interrupt register and status register */ 450 /* read interrupt register and status register */
@@ -687,7 +622,15 @@ static struct i2c_driver x1205_driver = {
687 .id_table = x1205_id, 622 .id_table = x1205_id,
688}; 623};
689 624
690module_i2c_driver(x1205_driver); 625static int __init x1205_init(void)
626{
627 return i2c_add_driver(&x1205_driver);
628}
629
630static void __exit x1205_exit(void)
631{
632 i2c_del_driver(&x1205_driver);
633}
691 634
692MODULE_AUTHOR( 635MODULE_AUTHOR(
693 "Karen Spearel <kas111 at gmail dot com>, " 636 "Karen Spearel <kas111 at gmail dot com>, "
@@ -695,3 +638,6 @@ MODULE_AUTHOR(
695MODULE_DESCRIPTION("Xicor/Intersil X1205 RTC driver"); 638MODULE_DESCRIPTION("Xicor/Intersil X1205 RTC driver");
696MODULE_LICENSE("GPL"); 639MODULE_LICENSE("GPL");
697MODULE_VERSION(DRV_VERSION); 640MODULE_VERSION(DRV_VERSION);
641
642module_init(x1205_init);
643module_exit(x1205_exit);