#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
MODULE_AUTHOR("David S. Miller <davem@davemloft.net>");
MODULE_DESCRIPTION("TI BQ4802 RTC driver");
u8 (*read)(struct bq4802 *, int);
void (*write)(struct bq4802 *, int, u8);
static u8 bq4802_read_io(struct bq4802 *p, int off)
return inb(p->ioport + off);
static void bq4802_write_io(struct bq4802 *p, int off, u8 val)
outb(val, p->ioport + off);
static u8 bq4802_read_mem(struct bq4802 *p, int off)
return readb(p->regs + off);
static void bq4802_write_mem(struct bq4802 *p, int off, u8 val)
writeb(val, p->regs + off);
static int bq4802_read_time(struct device *dev, struct rtc_time *tm)
struct bq4802 *p = dev_get_drvdata(dev);
spin_lock_irqsave(&p->lock, flags);
p->write(p, 0xe, val | 0x08);
tm->tm_sec = p->read(p, 0x00);
tm->tm_min = p->read(p, 0x02);
tm->tm_hour = p->read(p, 0x04);
tm->tm_mday = p->read(p, 0x06);
tm->tm_mon = p->read(p, 0x09);
tm->tm_year = p->read(p, 0x0a);
tm->tm_wday = p->read(p, 0x08);
century = p->read(p, 0x0f);
spin_unlock_irqrestore(&p->lock, flags);
tm->tm_sec = bcd2bin(tm->tm_sec);
tm->tm_min = bcd2bin(tm->tm_min);
tm->tm_hour = bcd2bin(tm->tm_hour);
tm->tm_mday = bcd2bin(tm->tm_mday);
tm->tm_mon = bcd2bin(tm->tm_mon);
tm->tm_year = bcd2bin(tm->tm_year);
tm->tm_wday = bcd2bin(tm->tm_wday);
century = bcd2bin(century);
tm->tm_year += (century * 100);
static int bq4802_set_time(struct device *dev, struct rtc_time *tm)