/* * linux/include/linux/m41t00.h * * Copyright (C) 2002 ABB * * Author: Christoph Suter * fels@datacomm.ch * * Based on the work of * Gérard Basler * gbasler@ee.ethz.ch * * Based on m41t11 driver by George Davis * * 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. */ #define EXPORT_SYMTAB #define M41T00_DEBUG // turn debug messages on / off #define M41T00_PATCH_KERNEL #include #define M41T00_DEBUG #undef PDEBUG #if defined M41T00_DEBUG # define PDEBUG(fmt, args...) printk(KERN_DEBUG "%s, %s [%d]: " fmt, __FILE__, __FUNCTION__ , __LINE__ , ## args) #else # define PDEBUG(fmt, args...) #endif /* internal definitions not for use in user space programs */ #ifdef __KERNEL__ /* undefined similar functions from other headers... */ #undef BCD_TO_BIN(val) #define BCD_TO_BIN(val) (((val)&15) + ((val)>>4)*10) #undef BIN_TO_BCD(val) #define BIN_TO_BCD(val) ((((val)/10)<<4) + (val)%10) #undef IS_LOWNIBBLE_BCD(x) #define IS_LOWNIBBLE_BCD(x) ( (x & 0x0f) < 10 ) #undef IS_BCD(x) #define IS_BCD(x) ( ( (x & 0x0f) < 10) && ( (x & 0xf0) <10) ) ) #undef DAT(x) #define DAT(x) ((unsigned int)(x->data)) /* x: i2c_client->data */ #define M41T00_IOC_MAGIC 0xcc #define CTRL_STOP 0x80 /* structure used for reading */ struct rtc_registers_cs { unsigned char secs __attribute__ ((packed)); unsigned char mins __attribute__ ((packed)); unsigned char hours __attribute__ ((packed)); unsigned char wday __attribute__ ((packed)); unsigned char mday __attribute__ ((packed)); unsigned char mon __attribute__ ((packed)); unsigned char year __attribute__ ((packed)); unsigned char cs __attribute__ ((packed)); }; /* * Function prototypes */ static int __init m41t00_init(void); static void __exit m41t00_exit(void); static int m41t00_detect_client(struct i2c_adapter *adap, int addr, unsigned short flags, int kind); static int m41t00_attach(struct i2c_adapter *adap); static int m41t00_detach(struct i2c_client *client); static int m41t00_get_datetime(struct i2c_client *client, struct rtc_time *dt); static int m41t00_set_datetime(struct i2c_client *client, struct rtc_time *dt); static int checkdate(struct rtc_time *dt); static int m41t00_command(struct i2c_client *client, unsigned int cmd, void *arg); static int m41t00_open(struct inode *minode, struct file *mfile); static int m41t00_release(struct inode *minode, struct file *mfile); static int m41t00_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); #ifdef CONFIG_PROC_FS static int m41t00_proc_output (char *buf); #endif // CONFIG_PROC_FS static void m41t00_print_info(struct rtc_registers_cs *rtc); #ifdef M41T00_DEBUG static void m41t00_print_content(struct rtc_registers_cs *rtc); #endif // M41T00_DEBUG static int m41t00_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data); static void m41t00_rtc_to_tm(struct rtc_registers_cs *rtc, struct rtc_time *dt); static void m41t00_tm_to_rtc(struct rtc_time *dt, struct rtc_registers_cs *rtc); #if defined CONFIG_PPC static int set_rtc_time_interrupt(unsigned long nowtime); static void set_rtc_time_task(void *p); #endif // CONFIG_PPC #endif // __KERNEL__