@@ -293,7 +293,11 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t)
293
293
t -> tm_min = bcd2bin (regs [DS1307_REG_MIN ] & 0x7f );
294
294
tmp = regs [DS1307_REG_HOUR ] & 0x3f ;
295
295
t -> tm_hour = bcd2bin (tmp );
296
- t -> tm_wday = bcd2bin (regs [DS1307_REG_WDAY ] & 0x07 ) - 1 ;
296
+ /* rx8130 is bit position, not BCD */
297
+ if (ds1307 -> type == rx_8130 )
298
+ t -> tm_wday = fls (regs [DS1307_REG_WDAY ] & 0x7f );
299
+ else
300
+ t -> tm_wday = bcd2bin (regs [DS1307_REG_WDAY ] & 0x07 ) - 1 ;
297
301
t -> tm_mday = bcd2bin (regs [DS1307_REG_MDAY ] & 0x3f );
298
302
tmp = regs [DS1307_REG_MONTH ] & 0x1f ;
299
303
t -> tm_mon = bcd2bin (tmp ) - 1 ;
@@ -340,7 +344,11 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t)
340
344
regs [DS1307_REG_SECS ] = bin2bcd (t -> tm_sec );
341
345
regs [DS1307_REG_MIN ] = bin2bcd (t -> tm_min );
342
346
regs [DS1307_REG_HOUR ] = bin2bcd (t -> tm_hour );
343
- regs [DS1307_REG_WDAY ] = bin2bcd (t -> tm_wday + 1 );
347
+ /* rx8130 is bit position, not BCD */
348
+ if (ds1307 -> type == rx_8130 )
349
+ regs [DS1307_REG_WDAY ] = 1 << t -> tm_wday ;
350
+ else
351
+ regs [DS1307_REG_WDAY ] = bin2bcd (t -> tm_wday + 1 );
344
352
regs [DS1307_REG_MDAY ] = bin2bcd (t -> tm_mday );
345
353
regs [DS1307_REG_MONTH ] = bin2bcd (t -> tm_mon + 1 );
346
354
0 commit comments