]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/linux/nslu2-kernel/2.6.14/30-i2c-x1205.patch
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / linux / nslu2-kernel / 2.6.14 / 30-i2c-x1205.patch
1 --- linux-2.6.14-rc2/drivers/i2c/chips/Kconfig  2005-09-24 13:17:13.000000000 +0200
2 +++ test3/drivers/i2c/chips/Kconfig     2005-09-24 16:09:51.000000000 +0200
3 @@ -126,4 +126,14 @@
4           This driver can also be built as a module.  If so, the module
5           will be called max6875.
6  
7 +config SENSORS_X1205
8 +       tristate "Xicor X1205 RTC chip"
9 +       depends on I2C
10 +       select I2C_SENSOR
11 +       help
12 +         If you say yes here you get support for the Xicor X1205 RTC chip.
13 +
14 +         This driver can also be built as a module.  If so, the module
15 +         will be called x1205
16 +
17  endmenu
18 --- linux-2.6.14-rc2/drivers/i2c/chips/Makefile 2005-09-17 12:42:33.000000000 +0200
19 +++ test3/drivers/i2c/chips/Makefile    2005-09-24 16:49:34.000000000 +0200
20 @@ -13,6 +13,7 @@
21  obj-$(CONFIG_SENSORS_RTC8564)  += rtc8564.o
22  obj-$(CONFIG_ISP1301_OMAP)     += isp1301_omap.o
23  obj-$(CONFIG_TPS65010)         += tps65010.o
24 +obj-$(CONFIG_SENSORS_X1205)     += x1205.o
25  
26  ifeq ($(CONFIG_I2C_DEBUG_CHIP),y)
27  EXTRA_CFLAGS += -DDEBUG
28 diff -urN linux-2.6.14-rc2/drivers/i2c/chips/x1205.c test3/drivers/i2c/chips/x1205.c
29 --- linux-2.6.14-rc2/drivers/i2c/chips/x1205.c  1970-01-01 01:00:00.000000000 +0100
30 +++ test3/drivers/i2c/chips/x1205.c     2005-09-24 16:11:16.000000000 +0200
31 @@ -0,0 +1,522 @@
32 +/*
33 + *  linux/drivers/i2c/chips/x1205.c
34 + *
35 + *  x1205.c - An 12c driver for the Xicor X1205 RTC
36 + *  Copyright 2004 Karen Spearel
37 + *  Copyright 2005 Alessandro Zummo
38 + *
39 + *  please send all reports to:
40 + *     kas11 at tampabay dot rr dot com
41 + *      a dot zummo at towertech dot it
42 + *     
43 + *  based on the other drivers in this same directory.
44 + *   
45 + *  This program is free software; you can redistribute it and/or modify
46 + *  it under the terms of the GNU General Public License as published by
47 + *  the Free Software Foundation; either version 2 of the License, or
48 + *  (at your option) any later version.
49 + */
50 +
51 +#include <linux/module.h>
52 +#include <linux/init.h>
53 +#include <linux/slab.h>
54 +#include <linux/i2c.h>
55 +#include <linux/string.h>
56 +#include <linux/bcd.h>
57 +#include <linux/rtc.h>
58 +#include <linux/list.h>
59 +
60 +#include <linux/x1205.h>
61 +
62 +#define        EPOCH_1900      1900
63 +#define        EPOCH_1970      1970
64 +
65 +#define DRIVER_VERSION "0.9.5"
66 +#define DRIVER_NAME    (x1205_driver.name)
67 +
68 +
69 +/* Addresses to scan */
70 +static unsigned short normal_i2c[] = { X1205_I2C_BUS_ADDR, I2C_CLIENT_END };
71 +
72 +/* Insmod parameters */
73 +I2C_CLIENT_INSMOD;
74 +I2C_CLIENT_MODULE_PARM(hctosys,
75 +       "Set the system time from the hardware clock upon initialization");
76 +
77 +/* Prototypes */
78 +
79 +static int x1205_attach(struct i2c_adapter *adapter);
80 +static int x1205_detach(struct i2c_client *client);
81 +static int x1205_probe(struct i2c_adapter *adapter, int address, int kind);
82 +static int x1205_validate_client(struct i2c_client *client);
83 +
84 +static int x1205_get_datetime(struct i2c_client *client, struct rtc_time *tm,
85 +                               u8 reg_base);
86 +static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm,
87 +                               int datetoo, u8 reg_base);
88 +static int x1205_validate_tm(struct rtc_time *tm);
89 +static int x1205_command(struct i2c_client *client, unsigned int cmd, void *arg);
90 +static int x1205_hctosys(struct i2c_client *client);
91 +
92 +
93 +static struct i2c_driver x1205_driver = {
94 +       .owner          = THIS_MODULE,
95 +       .name           = "x1205",
96 +       .flags          = I2C_DF_NOTIFY,
97 +       .attach_adapter = &x1205_attach,
98 +       .detach_client  = &x1205_detach,
99 +/*     .command        = &x1205_command,*/
100 +};
101 +
102 +struct x1205_data {
103 +       struct i2c_client client;
104 +       struct list_head list;
105 +       unsigned int epoch;
106 +};
107 +
108 +
109 +static const unsigned char days_in_mo[] = 
110 +{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
111 +
112 +static LIST_HEAD(x1205_clients);
113 +
114 +/* Workaround until the I2C subsytem will allow to send
115 + * commands to a specific client. This function will send the command
116 + * to the first client.
117 + */
118 +
119 +int x1205_do_command(unsigned int cmd, void *arg)
120 +{
121 +       struct list_head *walk;
122 +       struct list_head *tmp;
123 +       struct x1205_data *data;
124 +
125 +       list_for_each_safe(walk, tmp, &x1205_clients) {
126 +               data = list_entry(walk, struct x1205_data, list);
127 +               return x1205_command(&data->client, cmd, arg);
128 +       }
129 +
130 +       return -ENODEV;
131 +}
132 +
133 +
134 +/*
135 + * in the routines that deal directly with the x1205 hardware, we use
136 + * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch
137 + * Epoch is inited as 2000. Time is set to UT
138 + */
139 +
140 +static int x1205_get_datetime(struct i2c_client *client, struct rtc_time *tm,
141 +                               u8 reg_base)
142 +{
143 +       static unsigned char addr[2] = { 0, };
144 +       unsigned char buf[8];   
145 +
146 +       struct i2c_msg msgs[2] = {
147 +               { client->addr, 0, 2, addr },           /* random read */
148 +               { client->addr, I2C_M_RD, 8, buf },
149 +       };
150 +
151 +       struct x1205_data *xdata = i2c_get_clientdata(client);
152 +
153 +       addr[1] = reg_base;
154 +
155 +       if ((i2c_transfer(client->adapter, msgs, 2)) == 2) {
156 +               /* did we read 2 messages? */
157 +
158 +               dev_dbg(&client->dev,
159 +                       "%s: raw read data - sec-%02x min-%02x hr-%02x"
160 +                       " mday-%02x mon-%02x year-%02x wday-%02x y2k-%02x\n", 
161 +                       __FUNCTION__,
162 +                       buf[0], buf[1], buf[2], buf[3],
163 +                       buf[4], buf[5], buf[6], buf[7]);
164 +
165 +               tm->tm_sec  = BCD2BIN(buf[CCR_SEC]);
166 +               tm->tm_min  = BCD2BIN(buf[CCR_MIN]);
167 +               buf[CCR_HOUR] &= ~X1205_HR_MIL;
168 +               tm->tm_hour = BCD2BIN(buf[CCR_HOUR]); /* hr is 0-23 */
169 +               tm->tm_mday = BCD2BIN(buf[CCR_MDAY]);
170 +               tm->tm_mon  = BCD2BIN(buf[CCR_MONTH]);
171 +               xdata->epoch   = BCD2BIN(buf[CCR_Y2K]) * 100;
172 +               tm->tm_year = BCD2BIN(buf[CCR_YEAR]) + xdata->epoch - EPOCH_1900;
173 +               tm->tm_wday = buf[CCR_WDAY];
174 +
175 +               dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, "
176 +                       "mday=%d, mon=%d, year=%d, wday=%d\n",
177 +                       __FUNCTION__,
178 +                       tm->tm_sec, tm->tm_min, tm->tm_hour,
179 +                       tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
180 +
181 +       } else {
182 +               dev_dbg(&client->dev, "%s: read error\n", __FUNCTION__);
183 +               return -EIO;
184 +       }               
185 +       
186 +       return 0;
187 +}
188 +
189 +
190 +static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm,
191 +                               int datetoo, u8 reg_base)
192 +{
193 +       int i, err, xfer;
194 +
195 +       static unsigned char wel[3]   = { 0, X1205_REG_SR,
196 +                                       X1205_SR_WEL };
197 +
198 +
199 +       static unsigned char rwel[3]  = { 0, X1205_REG_SR,
200 +                                       X1205_SR_WEL | X1205_SR_RWEL };
201 +
202 +       static unsigned char diswe[3] = { 0, X1205_REG_SR, 0 };
203 +
204 +       static unsigned char data[3]  = { 0, };
205 +       static unsigned char buf[8];
206 +
207 +       struct x1205_data *xdata = i2c_get_clientdata(client);
208 +
209 +       if ((err = x1205_validate_tm(tm)) < 0)
210 +               return err;
211 +
212 +       dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d, "
213 +               "mday=%d, mon=%d, year=%d, wday=%d\n",
214 +               __FUNCTION__,
215 +               tm->tm_sec, tm->tm_min, tm->tm_hour,
216 +               tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
217 +
218 +
219 +       buf[CCR_SEC]  = BIN2BCD(tm->tm_sec);
220 +       buf[CCR_MIN]  = BIN2BCD(tm->tm_min);
221 +
222 +       /* Set 24HR format */
223 +       buf[CCR_HOUR] = BIN2BCD(tm->tm_hour) | X1205_HR_MIL;
224 +
225 +       if (datetoo == X1205_DATETOO) {
226 +               buf[CCR_MDAY]  = BIN2BCD(tm->tm_mday);
227 +
228 +               /* month, 0 - 11 */
229 +               buf[CCR_MONTH] = BIN2BCD(tm->tm_mon);   /* input is 0-11 */
230 +
231 +               /* year, since 1900 */
232 +               buf[CCR_YEAR]  = BIN2BCD((tm->tm_year + EPOCH_1900 - xdata->epoch));
233 +               buf[CCR_WDAY]  = tm->tm_wday & 7;
234 +               buf[CCR_Y2K]   = BIN2BCD(xdata->epoch / 100);
235 +       }
236 +
237 +       xfer = i2c_master_send(client, wel, 3);
238 +       dev_dbg(&client->dev, "%s: wen - %x\n", __FUNCTION__, xfer);
239 +       if (xfer != 3)
240 +               return -EIO;
241 +
242 +       xfer = i2c_master_send(client, rwel, 3);
243 +       dev_dbg(&client->dev, "%s: wenb - %x\n", __FUNCTION__, xfer);
244 +       if (xfer != 3)
245 +               return -EIO;
246 +
247 +       for (i = 0; i < 8; i++) {
248 +               data[1] = i + reg_base;
249 +               data[2] =  buf[i];
250 +               xfer = i2c_master_send(client, data, 3);
251 +
252 +               dev_dbg(&client->dev, "%s: xfer %d addr, %02x,  data %02x\n",
253 +                       __FUNCTION__,
254 +                        xfer, data[1], data[2]);
255 +
256 +               if (xfer != 3)
257 +                       return -EIO;
258 +       };
259 +
260 +       xfer = i2c_master_send(client, diswe, 3);
261 +       dev_dbg(&client->dev, "%s: wdis - %x\n", __FUNCTION__, xfer);
262 +       if (xfer != 3)
263 +               return -EIO;            
264 +
265 +       return 0;
266 +}
267 +
268 +static int x1205_hctosys(struct i2c_client *client)
269 +{
270 +       int err;
271 +
272 +       struct rtc_time tm;
273 +       struct timespec tv;
274 +       
275 +
276 +       err = x1205_command(client, X1205_CMD_GETDATETIME, &tm);
277 +
278 +       if (err)
279 +       {
280 +               dev_info(&client->adapter->dev,
281 +                       "%s: Unable to set the system clock\n",
282 +                       DRIVER_NAME);
283 +
284 +               return err;
285 +
286 +       }
287 +
288 +       /* IMPORTANT: the RTC only stores whole seconds.  It is arbitrary whether
289 +        * it stores the most close value or the value with partial seconds
290 +        * truncated, however it is important for x1205_sync_rtc that it be
291 +        * defined to store the truncated value.  This is because otherwise it
292 +        * is necessary to read both xtime.tv_sec and xtime.tv_nsec in the
293 +        * sync function, and atomic reads of >32bits on ARM are not possible.
294 +        * So storing the most close value would slow down the sync API.  So
295 +        * Here we have the truncated value and the best guess is to add 0.5s
296 +        */
297 +
298 +       tv.tv_nsec = NSEC_PER_SEC >> 1;
299 +
300 +       /* WARNING: this is not the C library 'mktime' call, it is a built in
301 +        * inline function from include/linux/time.h.  It expects (requires)
302 +        * the month to be in the range 1-12
303 +        */
304 +
305 +       tv.tv_sec  = mktime(tm.tm_year + EPOCH_1900, tm.tm_mon + 1,
306 +                               tm.tm_mday, tm.tm_hour,
307 +                               tm.tm_min, tm.tm_sec);
308 +
309 +       do_settimeofday(&tv);
310 +
311 +       dev_info(&client->adapter->dev,
312 +               "%s: Setting the system clock to %d-%d-%d %d:%d:%d\n",
313 +               DRIVER_NAME,
314 +               tm.tm_year + EPOCH_1900, tm.tm_mon + 1,
315 +               tm.tm_mday, tm.tm_hour, tm.tm_min,
316 +               tm.tm_sec);
317 +
318 +       return 0;
319 +}
320 +
321 +static int x1205_validate_client(struct i2c_client *client)
322 +{
323 +       int i, xfer;
324 +
325 +       /* Probe array. We will read the register at the specified
326 +        * address and check if the given bits are zero.
327 +        */
328 +
329 +       const unsigned char probe_pattern[] = {
330 +
331 +               X1205_REG_SR,   0x18,
332 +               X1205_REG_Y2K,  0xC6,
333 +               X1205_REG_DW,   0xF8,
334 +               X1205_REG_MO,   0xE0,
335 +               X1205_REG_DT,   0xC0,
336 +               X1205_REG_HR,   0x40,
337 +               X1205_REG_MN,   0x80,
338 +               X1205_REG_SC,   0x80,
339 +               X1205_REG_DTR,  0xF8,
340 +               X1205_REG_ATR,  0x18,
341 +               X1205_REG_INT,  0x18,
342 +               X1205_REG_0,    0xFF,
343 +               X1205_REG_Y2K1, 0xC6,
344 +               X1205_REG_DWA1, 0x78,
345 +               X1205_REG_MOA1, 0x60,
346 +               X1205_REG_DTA1, 0x40,
347 +               X1205_REG_HRA1, 0x40,
348 +               X1205_REG_Y2K0, 0xC6,
349 +               X1205_REG_DWA0, 0x78,
350 +               X1205_REG_MOA0, 0x60,
351 +               X1205_REG_DTA0, 0x40,
352 +               X1205_REG_HRA0, 0x40,
353 +       };
354 +
355 +       for (i = 0; i < sizeof(probe_pattern); i += 2)
356 +       {
357 +               unsigned char buf;
358 +
359 +               static unsigned char addr[2];
360 +
361 +               struct i2c_msg msgs[2] = {
362 +                       { client->addr, 0, 2, addr },   /* random read */
363 +                       { client->addr, I2C_M_RD, 1, &buf },
364 +               };
365 +
366 +               addr[0] = 0x00;
367 +               addr[1] = probe_pattern[i];
368 +
369 +               xfer = i2c_transfer(client->adapter, msgs, 2);
370 +
371 +               if (xfer != 2) {
372 +                       dev_dbg(&client->adapter->dev, 
373 +                               "%s: could not read register %x\n",
374 +                               __FUNCTION__, addr[1]);
375 +
376 +                       return -EIO;
377 +               }
378 +
379 +               if ((buf & probe_pattern[i+1]) != 0) {
380 +                       dev_dbg(&client->adapter->dev,
381 +                               "%s: register %x, pattern %d: %x\n",
382 +                               __FUNCTION__, addr[1], i, buf);
383 +
384 +                       return -ENODEV;
385 +               }
386 +       }
387 +
388 +       return 0;
389 +}
390 +
391 +static int x1205_attach(struct i2c_adapter *adapter)
392 +{
393 +       dev_dbg(&adapter->dev, "%s\n", __FUNCTION__);
394 +
395 +       return i2c_probe(adapter, &addr_data, x1205_probe);
396 +}
397 +
398 +static int x1205_probe(struct i2c_adapter *adapter, int address, int kind)
399 +{
400 +       struct i2c_client *new_client;
401 +       struct x1205_data *xdata;
402 +
403 +       int err = 0;
404 +
405 +       dev_dbg(&adapter->dev, "%s\n", __FUNCTION__);
406 +
407 +       if (!(xdata = kmalloc(sizeof(struct x1205_data), GFP_KERNEL))) {
408 +               err = -ENOMEM;
409 +               goto exit;
410 +       }
411 +
412 +       /* Fill our data structure */
413 +
414 +       memset(xdata, 0, sizeof(struct x1205_data));
415 +
416 +       xdata->epoch = 2000;
417 +
418 +
419 +       /* Prepare i2c_client structure */
420 +
421 +       new_client              = &xdata->client;
422 +       i2c_set_clientdata(new_client, xdata);
423 +       new_client->addr        = address;
424 +       new_client->adapter     = adapter;
425 +       new_client->driver      = &x1205_driver;
426 +       new_client->flags       = 0;
427 +       
428 +       strlcpy(new_client->name, "x1205", I2C_NAME_SIZE);
429 +
430 +
431 +       /* Verify the chip is really an X1205 */
432 +
433 +       if (kind < 0)
434 +       {
435 +               if (x1205_validate_client(new_client) < 0) {
436 +                       err = -ENODEV;
437 +                       goto exit_kfree;
438 +               }
439 +       }
440 +
441 +       /* Inform the i2c layer */
442 +       if ((err = i2c_attach_client(new_client)))
443 +               goto exit_kfree;
444 +
445 +       list_add(&xdata->list, &x1205_clients);
446 +
447 +       dev_info(&adapter->dev, "%s: chip found, driver " DRIVER_VERSION "\n",
448 +                       DRIVER_NAME);
449 +
450 +       /* If requested, se the system time */
451 +       if (hctosys)
452 +               x1205_hctosys(new_client);
453 +
454 +       return 0;
455 +
456 +exit_kfree:
457 +       kfree(xdata);
458 +
459 +exit:
460 +       return err;
461 +}
462 +
463 +static int x1205_detach(struct i2c_client *client)
464 +{
465 +       int err;
466 +       struct x1205_data *data = i2c_get_clientdata(client);
467 +       
468 +       dev_dbg(&client->dev, "%s\n", __FUNCTION__);
469 +
470 +       if ((err = i2c_detach_client(client)))
471 +               return err;
472 +
473 +       list_del(&data->list);
474 +       kfree(data);
475 +       return 0;
476 +}
477 +
478 +/* make sure the rtc_time values are in bounds */
479 +static int x1205_validate_tm(struct rtc_time *tm)
480 +{
481 +       tm->tm_year += 1900;
482 +
483 +       if (tm->tm_year < EPOCH_1970)
484 +               return -EINVAL;
485 +
486 +       if ((tm->tm_mon > 11) || (tm->tm_mday == 0))
487 +               return -EINVAL;
488 +
489 +       if (tm->tm_mday > (days_in_mo[tm->tm_mon] + ( (tm->tm_mon == 1) && 
490 +               ((!(tm->tm_year % 4) && (tm->tm_year % 100) ) || !(tm->tm_year % 400)))))
491 +               return -EINVAL;
492 +
493 +       if ((tm->tm_year -= EPOCH_1900) > 255)
494 +               return -EINVAL;
495 +                       
496 +       if ((tm->tm_hour >= 24) || (tm->tm_min >= 60) || (tm->tm_sec >= 60))
497 +               return -EINVAL;
498 +
499 +       return 0;
500 +}
501 +
502 +static int x1205_command(struct i2c_client *client, unsigned int cmd, void *tm)
503 +{
504 +       if (client == NULL || tm == NULL)
505 +               return -EINVAL;
506 +
507 +       if (!capable(CAP_SYS_TIME))
508 +               return -EACCES;
509 +
510 +       dev_dbg(&client->dev, "%s: cmd=%d\n", __FUNCTION__, cmd);
511 +
512 +       switch (cmd) {
513 +       case X1205_CMD_GETDATETIME:
514 +               return x1205_get_datetime(client, tm, X1205_CCR_BASE);
515 +
516 +       case X1205_CMD_SETTIME:
517 +               return x1205_set_datetime(client, tm, X1205_NODATE, X1205_CCR_BASE);
518 +
519 +       case X1205_CMD_SETDATETIME:
520 +               return x1205_set_datetime(client, tm, X1205_DATETOO, X1205_CCR_BASE);
521 +
522 +       case X1205_CMD_GETALARM:
523 +               return x1205_get_datetime(client, tm, X1205_ALM0_BASE);
524 +
525 +       case X1205_CMD_SETALARM:
526 +               return x1205_set_datetime(client, tm, X1205_DATETOO, X1205_ALM0_BASE);
527 +
528 +       default:
529 +               return -EINVAL;
530 +       }
531 +}
532 +
533 +
534 +static int __init x1205_init(void)
535 +{
536 +       return i2c_add_driver(&x1205_driver);
537 +}
538 +
539 +static void __exit x1205_exit(void)
540 +{
541 +       i2c_del_driver(&x1205_driver);
542 +}
543 +
544 +MODULE_AUTHOR(
545 +       "Karen Spearel <kas11@tampabay.rr.com>, "
546 +       "Alessandro Zummo <a.zummo@towertech.it>");
547 +MODULE_DESCRIPTION("Xicor X1205 RTC driver");
548 +MODULE_LICENSE("GPL");
549 +
550 +EXPORT_SYMBOL_GPL(x1205_do_command);
551 +
552 +module_init(x1205_init);
553 +module_exit(x1205_exit);
554 --- linux-2.6.14-rc2/include/linux/x1205.h      1970-01-01 01:00:00.000000000 +0100
555 +++ test3/include/linux/x1205.h 2005-09-24 16:59:28.000000000 +0200
556 @@ -0,0 +1,66 @@
557 +
558 +/* commands */
559 +
560 +#define        X1205_CMD_GETDATETIME   0
561 +#define        X1205_CMD_SETTIME       1
562 +#define        X1205_CMD_SETDATETIME   2
563 +#define X1205_CMD_GETALARM     3
564 +#define X1205_CMD_SETALARM     4
565 +
566 +/* flags */
567 +
568 +#define        X1205_NODATE            0
569 +#define        X1205_DATETOO           1
570 +
571 +/*  offsets into read buf - add 2 for write buf */
572 +
573 +#define        CCR_SEC                 0
574 +#define        CCR_MIN                 1
575 +#define        CCR_HOUR                2
576 +#define        CCR_MDAY                3
577 +#define        CCR_MONTH               4
578 +#define        CCR_YEAR                5
579 +#define        CCR_WDAY                6
580 +#define        CCR_Y2K                 7
581 +
582 +#define        X1205_REG_SR            0x3F    /* status register */
583 +#define        X1205_REG_Y2K           0x37
584 +#define        X1205_REG_DW            0x36
585 +#define        X1205_REG_YR            0x35
586 +#define        X1205_REG_MO            0x34
587 +#define        X1205_REG_DT            0x33
588 +#define        X1205_REG_HR            0x32
589 +#define        X1205_REG_MN            0x31
590 +#define        X1205_REG_SC            0x30
591 +#define        X1205_REG_DTR           0x13
592 +#define        X1205_REG_ATR           0x12
593 +#define        X1205_REG_INT           0x11
594 +#define        X1205_REG_0             0x10
595 +#define        X1205_REG_Y2K1          0x0F
596 +#define        X1205_REG_DWA1          0x0E
597 +#define        X1205_REG_YRA1          0x0D
598 +#define        X1205_REG_MOA1          0x0C
599 +#define        X1205_REG_DTA1          0x0B
600 +#define        X1205_REG_HRA1          0x0A
601 +#define        X1205_REG_MNA1          0x09
602 +#define        X1205_REG_SCA1          0x08
603 +#define        X1205_REG_Y2K0          0x07
604 +#define        X1205_REG_DWA0          0x06
605 +#define        X1205_REG_YRA0          0x05
606 +#define        X1205_REG_MOA0          0x04
607 +#define        X1205_REG_DTA0          0x03
608 +#define        X1205_REG_HRA0          0x02
609 +#define        X1205_REG_MNA0          0x01
610 +#define        X1205_REG_SCA0          0x00
611 +
612 +#define        X1205_I2C_BUS_ADDR      0x6f    /* hardwired into x1205 */
613 +#define        X1205_CCR_BASE          0x30    /* Base address of CCR */
614 +#define        X1205_ALM0_BASE         0x00    /* Base address of ALARM0 */
615 +
616 +#define        X1205_SR_WEL            0x02    /* Write Enable Latch bit */
617 +#define        X1205_SR_RWEL           0x04    /* Register Write Enable Bit */
618 +
619 +#define        X1205_HR_MIL            0x80    /* set in ccr.hour for 24 hr mode */
620 +
621 +extern int x1205_do_command(unsigned int cmd, void *arg);
622 +