summaryrefslogtreecommitdiff
path: root/src/southbridge/intel/bd82x6x
diff options
context:
space:
mode:
authorElyes HAOUAS <ehaouas@noos.fr>2020-08-11 09:21:24 +0200
committerPatrick Georgi <pgeorgi@google.com>2020-08-17 06:58:45 +0000
commit6ea24ffa8f40f27c5ffdedd03853fb78315dfc7a (patch)
treeb3f5838abfcd379ca0e41c8cd5654980a1ecc133 /src/southbridge/intel/bd82x6x
parent59236d526a9028eda7832450d8958a8bdcad8f2b (diff)
{sb/intel/*/azalia.c,device/azalia_device.c}: Reduce differences
Remaining notable differences at function 'codec_detect(u8 *base)'. Change-Id: Ia64e0ba10f145cf2eae0cb2ff4951b1455963d5d Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr> Reviewed-on: https://review.coreboot.org/c/coreboot/+/44370 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'src/southbridge/intel/bd82x6x')
-rw-r--r--src/southbridge/intel/bd82x6x/azalia.c49
1 files changed, 20 insertions, 29 deletions
diff --git a/src/southbridge/intel/bd82x6x/azalia.c b/src/southbridge/intel/bd82x6x/azalia.c
index 3d4f7ca7e6..15be4abaef 100644
--- a/src/southbridge/intel/bd82x6x/azalia.c
+++ b/src/southbridge/intel/bd82x6x/azalia.c
@@ -26,9 +26,7 @@ static int set_bits(void *port, u32 mask, u32 val)
reg32 |= val;
write32(port, reg32);
- /* Wait for readback of register to
- * match what was just written to it
- */
+ /* Wait for readback of register to match what was just written to it */
count = 50;
do {
/* Wait 1ms based on BKDG wait time */
@@ -48,14 +46,13 @@ static int codec_detect(u8 *base)
u8 reg8;
/* Set Bit 0 to 1 to exit reset state (BAR + 0x8)[0] */
- if (set_bits(base + HDA_GCTL_REG, 1, 1) == -1)
+ if (set_bits(base + HDA_GCTL_REG, 1, HDA_GCTL_CRST) == -1)
goto no_codec;
/* Write back the value once reset bit is set. */
- write16(base + HDA_GCAP_REG,
- read16(base + HDA_GCAP_REG));
+ write16(base + HDA_GCAP_REG, read16(base + HDA_GCAP_REG));
- /* Read in Codec location (BAR + 0xe)[2..0]*/
+ /* Read in Codec location (BAR + 0xe)[2..0] */
reg8 = read8(base + HDA_STATESTS_REG);
reg8 &= 0x0f;
if (!reg8)
@@ -73,15 +70,15 @@ no_codec:
static u32 find_verb(struct device *dev, u32 viddid, const u32 **verb)
{
- int idx=0;
+ int idx = 0;
while (idx < (cim_verb_data_size / sizeof(u32))) {
- u32 verb_size = 4 * cim_verb_data[idx+2]; // in u32
+ u32 verb_size = 4 * cim_verb_data[idx + 2]; // in u32
if (cim_verb_data[idx] != viddid) {
- idx += verb_size + 3; // skip verb + header
+ idx += verb_size + 3; // skip verb + header
continue;
}
- *verb = &cim_verb_data[idx+3];
+ *verb = &cim_verb_data[idx + 3];
return verb_size;
}
@@ -89,15 +86,14 @@ static u32 find_verb(struct device *dev, u32 viddid, const u32 **verb)
return 0;
}
-/**
- * Wait 50usec for the codec to indicate it is ready
- * no response would imply that the codec is non-operative
+/*
+ * Wait 50usec for the codec to indicate it is ready.
+ * No response would imply that the codec is non-operative.
*/
static int wait_for_ready(u8 *base)
{
/* Use a 1msec timeout */
-
int timeout = 1000;
while (timeout--) {
@@ -110,28 +106,25 @@ static int wait_for_ready(u8 *base)
return -1;
}
-/**
- * Wait 50usec for the codec to indicate that it accepted
- * the previous command. No response would imply that the code
- * is non-operative
+/*
+ * Wait 50usec for the codec to indicate that it accepted the previous command.
+ * No response would imply that the code is non-operative.
*/
static int wait_for_valid(u8 *base)
{
u32 reg32;
+ /* Use a 1msec timeout */
+ int timeout = 1000;
/* Send the verb to the codec */
reg32 = read32(base + HDA_ICII_REG);
reg32 |= HDA_ICII_BUSY | HDA_ICII_VALID;
write32(base + HDA_ICII_REG, reg32);
- /* Use a 1msec timeout */
-
- int timeout = 1000;
while (timeout--) {
reg32 = read32(base + HDA_ICII_REG);
- if ((reg32 & (HDA_ICII_VALID | HDA_ICII_BUSY)) ==
- HDA_ICII_VALID)
+ if ((reg32 & (HDA_ICII_VALID | HDA_ICII_BUSY)) == HDA_ICII_VALID)
return 0;
udelay(1);
}
@@ -162,9 +155,8 @@ static void codec_init(struct device *dev, u8 *base, int addr)
return;
}
- reg32 = read32(base + HDA_IR_REG);
-
/* 2 */
+ reg32 = read32(base + HDA_IR_REG);
printk(BIOS_DEBUG, "Azalia: codec viddid: %08x\n", reg32);
verb_size = find_verb(dev, reg32, &verb);
@@ -213,13 +205,12 @@ static void azalia_init(struct device *dev)
u32 codec_mask;
u32 reg32;
- /* Find base address */
res = find_resource(dev, PCI_BASE_ADDRESS_0);
if (!res)
return;
- // NOTE this will break as soon as the Azalia get's a bar above
- // 4G. Is there anything we can do about it?
+ // NOTE this will break as soon as the Azalia get's a bar above 4G.
+ // Is there anything we can do about it?
base = res2mmio(res, 0, 0);
printk(BIOS_DEBUG, "Azalia: base = %08x\n", (u32)base);