static int __init ds1302_probe(void) { int retval, res, baur; baur=(boot_cpu_data.bus_clock/(2*1000*1000)); printk("%s: Set PLD_RTCBAUR = %d\n", ds1302_name,baur); outw(0x0000,(unsigned long)PLD_RTCCR); outw(0x0000,(unsigned long)PLD_RTCRSTODT); outw(baur,(unsigned long)PLD_RTCBAUR); /* Try to talk to timekeeper. */ ds1302_wenable(); /* write RAM byte 0 */ /* write something magic */ out_byte_rtc(0xc0,MAGIC_PATTERN); /* read RAM byte 0 */ if((res = in_byte_rtc(0xc1)) == MAGIC_PATTERN) { char buf[100]; ds1302_wdisable(); printk("%s: RTC found.\n", ds1302_name); get_rtc_status(buf); printk(buf); retval = 1; } else { printk("%s: RTC not found.\n", ds1302_name); retval = 0; } return retval; }
void ds1302_writereg(int reg, unsigned char val) { ds1302_wenable(); out_byte_rtc((0x80 | (reg << 1)),val); ds1302_wdisable(); }
void ds1302_writereg(int reg, unsigned char val) { ds1302_wenable(); start(); out_byte(0x80 | (reg << 1)); /* write register */ out_byte(val); stop(); ds1302_wdisable(); }
static int ds1302_probe(void) { int retval, res; TK_RST_DIR(1); TK_SCL_DIR(1); TK_SDA_DIR(0); /* Try to talk to timekeeper. */ ds1302_wenable(); start(); out_byte(0xc0); /* write RAM byte 0 */ out_byte(MAGIC_PATTERN); /* write something magic */ start(); out_byte(0xc1); /* read RAM byte 0 */ if((res = in_byte()) == MAGIC_PATTERN) { char buf[100]; stop(); ds1302_wdisable(); printk("%s: RTC found.\n", ds1302_name); printk("%s: SDA, SCL, RST on PB%i, PB%i, %s%i\n", ds1302_name, CONFIG_ETRAX_DS1302_SDABIT, CONFIG_ETRAX_DS1302_SCLBIT, #ifdef CONFIG_ETRAX_DS1302_RST_ON_GENERIC_PORT "GENIO", #else "PB", #endif CONFIG_ETRAX_DS1302_RSTBIT); get_rtc_status(buf); printk(buf); retval = 1; } else { stop(); printk("%s: RTC not found.\n", ds1302_name); retval = 0; } return retval; }
void ds1302_writereg(int reg, unsigned char val) { #ifndef CONFIG_ETRAX_RTC_READONLY int do_writereg = 1; #else int do_writereg = 0; if (reg == RTC_TRICKLECHARGER) do_writereg = 1; #endif if (do_writereg) { ds1302_wenable(); start(); out_byte(0x80 | (reg << 1)); /* write register */ out_byte(val); stop(); ds1302_wdisable(); } }