[PATCH] Proper RTC emulation and time sync stuff
Posted: Fri 08 Jul, 2016 11:56 pm
Based on this PCem pull request by Mahod, that has these changes:
- Replaces linux-time and win-time with rtc, making future changes simpler;
- Adds RTC binary and 12-hour modes;
- Adds RTC century register;
- Improves readability of nvr.c by replacing literals with enums.
My patch takes his work and improves on it further, with these changes:
- Changes the NVR one second ticker to work at 32768 Hz per the datasheet instead of 100 Hz and set the update ended flag at update end (73 ticks / 244+1984 µs after the one second hit);
- Changes the register A bit 7 hack to proper setting of the bit at second hit and clearing at update end;
- Adds alarm support;
- Adds ability to disable time synchronization with host (enabled by default) and use the internal clock instead that is updated when the date and time NVR registers are written to;
- Makes the date and time NVR registers initialized to sane values (1980-01-01 00:00:00) if the NVR is being initialized from scratch and time synchronization is disabled.
The patch is attached. A huge thanks goes to Mahod for both his original patch and bearing with me as I was researching the RTC stuff, as well as for making me think in order to make my internal clock state stuff less complex.
- Replaces linux-time and win-time with rtc, making future changes simpler;
- Adds RTC binary and 12-hour modes;
- Adds RTC century register;
- Improves readability of nvr.c by replacing literals with enums.
My patch takes his work and improves on it further, with these changes:
- Changes the NVR one second ticker to work at 32768 Hz per the datasheet instead of 100 Hz and set the update ended flag at update end (73 ticks / 244+1984 µs after the one second hit);
- Changes the register A bit 7 hack to proper setting of the bit at second hit and clearing at update end;
- Adds alarm support;
- Adds ability to disable time synchronization with host (enabled by default) and use the internal clock instead that is updated when the date and time NVR registers are written to;
- Makes the date and time NVR registers initialized to sane values (1980-01-01 00:00:00) if the NVR is being initialized from scratch and time synchronization is disabled.
The patch is attached. A huge thanks goes to Mahod for both his original patch and bearing with me as I was researching the RTC stuff, as well as for making me think in order to make my internal clock state stuff less complex.