device/azalia_device.c: Add option to lock down GCAP

On Intel 6-series PCHs, the GCAP register is R/WO (Read / Write Once),
and needs to be written to after the HD Audio controller is taken out
of reset. Add a Kconfig option to read and write back GCAP in order to
lock it down. Follow-up commits will select this option when switching
platforms to use common Azalia code, to preserve original behaviour.

Change-Id: I70bab20816fb6c0bf7bff35c3d2f5828cd96172d
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/50794
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/src/device/azalia_device.c b/src/device/azalia_device.c
index 013a49a..9202f72 100644
--- a/src/device/azalia_device.c
+++ b/src/device/azalia_device.c
@@ -56,6 +56,11 @@
 	if (azalia_exit_reset(base) < 0)
 		goto no_codec;
 
+	if (CONFIG(AZALIA_LOCK_DOWN_R_WO_GCAP)) {
+		/* If GCAP is R/WO, lock it down after deasserting controller reset */
+		write16(base + HDA_GCAP_REG, read16(base + HDA_GCAP_REG));
+	}
+
 	/* clear STATESTS bits (BAR + 0xe)[2:0] */
 	reg16 = read16(base + HDA_STATESTS_REG);
 	reg16 |= codec_mask;