#endif
/*---------------------------------------------------------------------*/
-#ifndef CONFIG_SYS_I2C_RTC_ADDR
-# define CONFIG_SYS_I2C_RTC_ADDR 0x32
-#endif
-
-#ifdef CONFIG_DM_RTC
-#define DEV_TYPE struct udevice
-#else
-/* Local udevice */
-struct ludevice {
- u8 chip;
-};
-
-#define DEV_TYPE struct ludevice
-
-#endif
-
/*
* RTC register addresses
*/
* address in a first cycle that is terminated by
* a STOP condition. The chips needs a 'restart'
* sequence (start sequence without a prior stop).
- * This driver has been written for a 4xx board.
- * U-Boot's 4xx i2c driver is currently not capable
- * to generate such cycles to some work arounds
- * are used.
*/
-/* static uchar rtc_read (uchar reg); */
-#ifdef CONFIG_DM_RTC
-/*
- * on mpc85xx based board with DM and offset len 1
- * accessing rtc works fine. May we can drop this ?
- */
#define rtc_read(reg) buf[(reg) & 0xf]
-#else
-#define rtc_read(reg) buf[((reg) + 1) & 0xf]
-#endif
-static int rtc_write(DEV_TYPE *dev, uchar reg, uchar val);
+static int rtc_write(struct udevice *dev, uchar reg, uchar val);
/*
* Get the current time from the RTC
*/
-static int rx8025_rtc_get(DEV_TYPE *dev, struct rtc_time *tmp)
+static int rx8025_rtc_get(struct udevice *dev, struct rtc_time *tmp)
{
int rel = 0;
uchar sec, min, hour, mday, wday, mon, year, ctl2;
uchar buf[16];
-#ifdef CONFIG_DM_RTC
if (dm_i2c_read(dev, 0, buf, sizeof(buf))) {
-#else
- if (i2c_read(dev->chip, 0, 0, buf, 16)) {
-#endif
printf("Error reading from RTC\n");
return -EIO;
}
/*
* Set the RTC
*/
-static int rx8025_rtc_set(DEV_TYPE *dev, const struct rtc_time *tmp)
+static int rx8025_rtc_set(struct udevice *dev, const struct rtc_time *tmp)
{
DEBUGR("Set DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n",
tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
/*
* Reset the RTC
*/
-static int rx8025_rtc_reset(DEV_TYPE *dev)
+static int rx8025_rtc_reset(struct udevice *dev)
{
uchar buf[16];
uchar ctl2;
-#ifdef CONFIG_DM_RTC
if (dm_i2c_read(dev, 0, buf, sizeof(buf))) {
-#else
- if (i2c_read(dev->chip, 0, 0, buf, 16)) {
-#endif
printf("Error reading from RTC\n");
return -EIO;
}
/*
* Helper functions
*/
-static int rtc_write(DEV_TYPE *dev, uchar reg, uchar val)
+static int rtc_write(struct udevice *dev, uchar reg, uchar val)
{
uchar buf[2];
buf[0] = reg << 4;
buf[1] = val;
-#ifdef CONFIG_DM_RTC
if (dm_i2c_write(dev, 0, buf, 2)) {
-#else
- if (i2c_write(dev->chip, 0, 0, buf, 2) != 0) {
-#endif
printf("Error writing to RTC\n");
return -EIO;
}
return 0;
}
-#ifdef CONFIG_DM_RTC
static int rx8025_probe(struct udevice *dev)
{
uchar buf[16];
.of_match = rx8025_rtc_ids,
.ops = &rx8025_rtc_ops,
};
-#else
-int rtc_get(struct rtc_time *tm)
-{
- struct ludevice dev = {
- .chip = CONFIG_SYS_I2C_RTC_ADDR,
- };
-
- return rx8025_rtc_get(&dev, tm);
-}
-
-int rtc_set(struct rtc_time *tm)
-{
- struct ludevice dev = {
- .chip = CONFIG_SYS_I2C_RTC_ADDR,
- };
-
- return rx8025_rtc_set(&dev, tm);
-}
-
-void rtc_reset(void)
-{
- struct ludevice dev = {
- .chip = CONFIG_SYS_I2C_RTC_ADDR,
- };
-
- rx8025_rtc_reset(&dev);
-}
-#endif