diff options
author | Drashna Jaelre <drashna@live.com> | 2021-08-20 21:02:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-20 21:02:53 -0700 |
commit | a80d7891472335ec297082daecc6fbf90042c38c (patch) | |
tree | 04d34e9dd3658bf471ca9b11db3fa1095b4aa2c0 /quantum/eeconfig.c | |
parent | afd3bcbf45a9b7de097d7666ced2c674192949e5 (diff) |
Fix issues with VIA EEPROM init and bring in line with eeconfig functionality (#13243)
Co-authored-by: Ryan <fauxpark@gmail.com>
Diffstat (limited to 'quantum/eeconfig.c')
-rw-r--r-- | quantum/eeconfig.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/quantum/eeconfig.c b/quantum/eeconfig.c index ffa56ab56d..92f0ac4439 100644 --- a/quantum/eeconfig.c +++ b/quantum/eeconfig.c @@ -17,6 +17,12 @@ # include "haptic.h" #endif +#if defined(VIA_ENABLE) +bool via_eeprom_is_valid(void); +void via_eeprom_set_valid(bool valid); +void eeconfig_init_via(void); +#endif + /** \brief eeconfig enable * * FIXME: needs doc @@ -77,6 +83,13 @@ void eeconfig_init_quantum(void) { // when a haptic-enabled firmware is loaded onto the keyboard. eeprom_update_dword(EECONFIG_HAPTIC, 0); #endif +#if defined(VIA_ENABLE) + // Invalidate VIA eeprom config, and then reset. + // Just in case if power is lost mid init, this makes sure that it pets + // properly re-initialized. + via_eeprom_set_valid(false); + eeconfig_init_via(); +#endif eeconfig_init_kb(); } @@ -111,13 +124,29 @@ void eeconfig_disable(void) { * * FIXME: needs doc */ -bool eeconfig_is_enabled(void) { return (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER); } +bool eeconfig_is_enabled(void) { + bool is_eeprom_enabled = (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER); +#ifdef VIA_ENABLE + if (is_eeprom_enabled) { + is_eeprom_enabled = via_eeprom_is_valid(); + } +#endif + return is_eeprom_enabled; +} /** \brief eeconfig is disabled * * FIXME: needs doc */ -bool eeconfig_is_disabled(void) { return (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER_OFF); } +bool eeconfig_is_disabled(void) { + bool is_eeprom_disabled = (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER_OFF); +#ifdef VIA_ENABLE + if (!is_eeprom_disabled) { + is_eeprom_disabled = !via_eeprom_is_valid(); + } +#endif + return is_eeprom_disabled; +} /** \brief eeconfig read debug * |