superio/ite/common: Add options to enable beeps
Add device tree options to enable beeps when exceeding temperature, voltage, and fan limits. As of this commit, setting voltage and fan limits is not implemented. Change-Id: I57ce622ee4498b75f00e678c2e6d72e499925bce Signed-off-by: Vagiz Trakhanov <rakkin@autistici.org> Reviewed-on: https://review.coreboot.org/22141 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
parent
8f6ea30597
commit
41aa5ec2d6
|
@ -232,6 +232,30 @@ static void enable_fan(const u16 base, const u8 fan,
|
||||||
ite_ec_write(base, ITE_EC_FAN_MAIN_CTL, reg);
|
ite_ec_write(base, ITE_EC_FAN_MAIN_CTL, reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void enable_beeps(const u16 base, const struct ite_ec_config *const conf)
|
||||||
|
{
|
||||||
|
u8 reg = 0;
|
||||||
|
u8 freq = ITE_EC_BEEP_TONE_DIVISOR(10) | ITE_EC_BEEP_FREQ_DIVISOR(10);
|
||||||
|
|
||||||
|
if (conf->tmpin_beep) {
|
||||||
|
reg |= ITE_EC_BEEP_ON_TMP_LIMIT;
|
||||||
|
ite_ec_write(base, ITE_EC_BEEP_FREQ_DIV_OF_TMPIN, freq);
|
||||||
|
}
|
||||||
|
if (conf->fan_beep) {
|
||||||
|
reg |= ITE_EC_BEEP_ON_FAN_LIMIT;
|
||||||
|
ite_ec_write(base, ITE_EC_BEEP_FREQ_DIV_OF_FAN, freq);
|
||||||
|
}
|
||||||
|
if (conf->vin_beep) {
|
||||||
|
reg |= ITE_EC_BEEP_ON_VIN_LIMIT;
|
||||||
|
ite_ec_write(base, ITE_EC_BEEP_FREQ_DIV_OF_VIN, freq);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reg) {
|
||||||
|
reg |= ite_ec_read(base, ITE_EC_BEEP_ENABLE);
|
||||||
|
ite_ec_write(base, ITE_EC_BEEP_ENABLE, reg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ite_ec_init(const u16 base, const struct ite_ec_config *const conf)
|
void ite_ec_init(const u16 base, const struct ite_ec_config *const conf)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
@ -254,6 +278,9 @@ void ite_ec_init(const u16 base, const struct ite_ec_config *const conf)
|
||||||
for (i = 0; i < ITE_EC_FAN_CNT; ++i)
|
for (i = 0; i < ITE_EC_FAN_CNT; ++i)
|
||||||
enable_fan(base, i + 1, &conf->fan[i]);
|
enable_fan(base, i + 1, &conf->fan[i]);
|
||||||
|
|
||||||
|
/* Enable beeps if configured */
|
||||||
|
enable_beeps(base, conf);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* System may get wrong temperature data when SIO is in
|
* System may get wrong temperature data when SIO is in
|
||||||
* busy state. Therefore, check the status and terminate
|
* busy state. Therefore, check the status and terminate
|
||||||
|
|
|
@ -114,8 +114,10 @@ static const u8 ITE_EC_TEMP_ADJUST[] = { 0x56, 0x57, 0x59 };
|
||||||
#define ITE_EC_BEEP_ON_VIN_LIMIT (1 << 1)
|
#define ITE_EC_BEEP_ON_VIN_LIMIT (1 << 1)
|
||||||
#define ITE_EC_BEEP_ON_FAN_LIMIT (1 << 0)
|
#define ITE_EC_BEEP_ON_FAN_LIMIT (1 << 0)
|
||||||
#define ITE_EC_BEEP_FREQ_DIV_OF_FAN 0x5D
|
#define ITE_EC_BEEP_FREQ_DIV_OF_FAN 0x5D
|
||||||
#define ITE_EC_BEEP_FREQ_DIV_OF_VOLT 0x5E
|
#define ITE_EC_BEEP_FREQ_DIV_OF_VIN 0x5E
|
||||||
#define ITE_EC_BEEP_FREQ_DIV_OF_TEMP 0x5F
|
#define ITE_EC_BEEP_FREQ_DIV_OF_TMPIN 0x5F
|
||||||
|
#define ITE_EC_BEEP_TONE_DIVISOR(x) (((x) & 0x0f) << 4)
|
||||||
|
#define ITE_EC_BEEP_FREQ_DIVISOR(x) (((x) & 0x0f) << 0)
|
||||||
|
|
||||||
#define ITE_EC_FAN_CTL_TEMP_LIMIT_OFF(x) (0x60 + ((x)-1) * 8)
|
#define ITE_EC_FAN_CTL_TEMP_LIMIT_OFF(x) (0x60 + ((x)-1) * 8)
|
||||||
#define ITE_EC_FAN_CTL_TEMP_LIMIT_START(x) (0x61 + ((x)-1) * 8)
|
#define ITE_EC_FAN_CTL_TEMP_LIMIT_START(x) (0x61 + ((x)-1) * 8)
|
||||||
|
|
|
@ -92,7 +92,9 @@ struct ite_ec_config {
|
||||||
*/
|
*/
|
||||||
struct ite_ec_fan_config fan[ITE_EC_FAN_CNT];
|
struct ite_ec_fan_config fan[ITE_EC_FAN_CNT];
|
||||||
|
|
||||||
/* FIXME: enable beep when exceeding TMPIN, VIN, FAN limits */
|
bool tmpin_beep;
|
||||||
|
bool fan_beep;
|
||||||
|
bool vin_beep;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Some shorthands for device trees */
|
/* Some shorthands for device trees */
|
||||||
|
|
Loading…
Reference in New Issue