File indexing completed on 2025-05-11 08:23:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <i2c.h>
0015 #include <libchip/rtc.h>
0016 #include <ds1307.h>
0017
0018
0019 bool mcf5206elite_ds1307_probe(int minor);
0020
0021 extern rtc_fns ds1307_fns;
0022
0023
0024 rtc_tbl RTC_Table[] = {
0025 {
0026 "/dev/rtc",
0027 RTC_CUSTOM,
0028 &ds1307_fns,
0029 mcf5206elite_ds1307_probe,
0030 NULL,
0031 0x00,
0032 DS1307_I2C_ADDRESS,
0033 NULL,
0034 NULL
0035 }
0036 };
0037
0038
0039
0040 #define NUM_RTCS (sizeof(RTC_Table)/sizeof(rtc_tbl))
0041
0042 size_t RTC_Count = NUM_RTCS;
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054 bool
0055 mcf5206elite_ds1307_probe(int minor)
0056 {
0057 int try = 0;
0058 i2c_message_status status;
0059 rtc_tbl *rtc;
0060 i2c_bus_number bus;
0061 i2c_address addr;
0062
0063 if (minor >= NUM_RTCS)
0064 return false;
0065
0066 rtc = RTC_Table + minor;
0067
0068 bus = rtc->ulCtrlPort1;
0069 addr = rtc->ulDataPort;
0070 do {
0071 status = i2c_wrbyte(bus, addr, 0);
0072 if (status == I2C_NO_DEVICE)
0073 return false;
0074 try++;
0075 } while ((try < 15) && (status != I2C_SUCCESSFUL));
0076 if (status == I2C_SUCCESSFUL)
0077 return true;
0078 else
0079 return false;
0080 }