1
0
Fork 0

Fix issues with VIA EEPROM init and bring in line with eeconfig functionality (#13243)

Co-authored-by: Ryan <fauxpark@gmail.com>
This commit is contained in:
Drashna Jael're 2021-08-20 21:02:53 -07:00 committed by GitHub
parent afd3bcbf45
commit a80d789147
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 37 deletions

View file

@ -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
*