device/azalia_device.c: Add codec reset helpers

Many uses of `azalia_set_bits` are used to toggle the reset bit. To
avoid having to repeat the register operations and the corresponding
comment, create two helpers with self-explanatory names. They will be
put to use in subsequent commits, with one change for each function.

Change-Id: If0594fdaf99319f08a2e272cd37958f0f216e654
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/48355
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
This commit is contained in:
Angel Pons 2020-12-05 18:52:38 +01:00 committed by Hung-Te Lin
parent f23c6a8ff5
commit 4919028e62
2 changed files with 14 additions and 0 deletions

View File

@ -34,6 +34,18 @@ int azalia_set_bits(void *port, u32 mask, u32 val)
return 0;
}
int azalia_enter_reset(u8 *base)
{
/* Set bit 0 to 0 to enter reset state (BAR + 0x8)[0] */
return azalia_set_bits(base + HDA_GCTL_REG, HDA_GCTL_CRST, 0);
}
int azalia_exit_reset(u8 *base)
{
/* Set bit 0 to 1 to exit reset state (BAR + 0x8)[0] */
return azalia_set_bits(base + HDA_GCTL_REG, HDA_GCTL_CRST, HDA_GCTL_CRST);
}
static int codec_detect(u8 *base)
{
u32 reg32;

View File

@ -19,6 +19,8 @@
#define HDA_ICII_VALID (1 << 1)
int azalia_set_bits(void *port, u32 mask, u32 val);
int azalia_enter_reset(u8 *base);
int azalia_exit_reset(u8 *base);
u32 azalia_find_verb(const u32 *verb_table, u32 verb_table_bytes, u32 viddid, const u32 **verb);
void azalia_audio_init(struct device *dev);
extern struct device_operations default_azalia_audio_ops;