Denis Carikli (GNUtoo@no-log.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3035
-gerrit
commit d655dc139abc9005f79c06387fb756d9e49835eb Author: Denis 'GNUtoo' Carikli GNUtoo@no-log.org Date: Sat Apr 6 16:52:12 2013 +0200
Add Azalia support for non-AGESA sb700 and enable it for M4A785T-M
The code was taken and converted from configureAzaliaSetConfigD4Dword in src/vendorcode/amd/cimx/sb700/AZALIA.c
TODO: split that commit in two(one for my board and one generic). TODO: better commit message TODO: make the mainboard pin mapping semantic.
Change-Id: I333b2ebe595aacd9562ad8f4f7f7efab0386619a Signed-off-by: Denis 'GNUtoo' Carikli GNUtoo@no-log.org --- src/mainboard/asus/m4a785-m/hda.h | 38 +++++++++++++++++++++++++++++++++ src/mainboard/asus/m4a785-m/mainboard.c | 25 ++++++++++++++++++++++ src/southbridge/amd/sb700/hda.c | 30 ++++++++++++++++++++++++++ src/southbridge/amd/sb700/hda.h | 31 +++++++++++++++++++++++++++ 4 files changed, 124 insertions(+)
diff --git a/src/mainboard/asus/m4a785-m/hda.h b/src/mainboard/asus/m4a785-m/hda.h new file mode 100644 index 0000000..77d3afb --- /dev/null +++ b/src/mainboard/asus/m4a785-m/hda.h @@ -0,0 +1,38 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2011 Denis 'GNUtoo' Carikli GNUtoo@no-log.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef M4A785T_M_HDA_H +#define M4A785T_M_HDA_H +static CODECENTRY m4a785t_m_codec_vt1708s[] = /* VIA VT1708S */ +{ + {0x19, 0x01011012}, + {0x1a, 0x01a19026}, + {0x1b, 0x0181302e}, + {0x1c, 0x01014010}, + {0x1d, 0x0221401f}, + {0x1e, 0x02a19027}, + {0x1f, 0x593311f8}, + {0x20, 0x074411f0}, + {0x21, 0x985601f0}, + {0x22, 0x01016011}, + {0x23, 0x01012014}, + {0xff, 0xffffffff} /* end of table */ +}; +#endif diff --git a/src/mainboard/asus/m4a785-m/mainboard.c b/src/mainboard/asus/m4a785-m/mainboard.c index b1154ab..a8030d1 100644 --- a/src/mainboard/asus/m4a785-m/mainboard.c +++ b/src/mainboard/asus/m4a785-m/mainboard.c @@ -25,7 +25,9 @@ #include <cpu/amd/mtrr.h> #include <device/pci_def.h> #include "southbridge/amd/sb700/sb700.h" +#include "southbridge/amd/sb700/hda.h" #include "southbridge/amd/sb700/smbus.h" +#include "hda.h"
#define ADT7461_ADDRESS 0x4C #define ARA_ADDRESS 0x0C /* Alert Response Address */ @@ -186,6 +188,28 @@ static void set_thermal_config(void) */ }
+static void audio_setup(void) +{ + struct device *dev; + u8 dbPinRouting, dbChannelNum=0; + u32 bar0 = 0; + + printk(BIOS_INFO, "Configuring Azalia\n"); + + /* find BAR 0 */ + dev = dev_find_slot(0, PCI_DEVFN(0x14, 2)); + bar0 = dev->resource_list[0].base; + + dbPinRouting = pci_read_config8(dev_find_slot(0, PCI_DEVFN(0x14, 0)), 0xfc /* SB_SMBUS_REGFC */ ); + do { + if ( ( !(dbPinRouting & 0x1 /* BIT0 */) ) && (dbPinRouting & 0x2 /* BIT1 */ ) ) + azalia_set_config(m4a785t_m_codec_vt1708s, dbChannelNum, bar0); + dbPinRouting >>= 2; + dbChannelNum++; + } while (dbChannelNum != 4); + printk(BIOS_INFO, "Configuring Azalia DONE...\n"); +} + /************************************************* * enable the dedicated function in this board. * This function called early than rs780_enable. @@ -197,6 +221,7 @@ static void mainboard_enable(device_t dev) set_pcie_dereset(); /* get_ide_dma66(); */ set_thermal_config(); + audio_setup(); }
struct chip_operations mainboard_ops = { diff --git a/src/southbridge/amd/sb700/hda.c b/src/southbridge/amd/sb700/hda.c index 98cb75f..04ffd1f 100644 --- a/src/southbridge/amd/sb700/hda.c +++ b/src/southbridge/amd/sb700/hda.c @@ -24,12 +24,42 @@ #include <device/pci_ops.h> #include <arch/io.h> #include <delay.h> +#include "../../../vendorcode/amd/cimx/sb700/SB700.h" #include "sb700.h" +#include "hda.h"
#define HDA_ICII_REG 0x68 #define HDA_ICII_BUSY (1 << 0) #define HDA_ICII_VALID (1 << 1)
+void azalia_set_config(CODECENTRY* tempAzaliaCodecEntryPtr, u32 ddChannelNum, u32 ddBAR0) +{ + u8 dbtemp1,dbtemp2, i; + u32 ddtemp=0,ddtemp2=0; + + while ((tempAzaliaCodecEntryPtr->Nid) != 0xFF) + { + dbtemp1=0x20; + if ((tempAzaliaCodecEntryPtr->Nid) == 0x1) + dbtemp1=0x24; + ddtemp = tempAzaliaCodecEntryPtr->Nid; + ddtemp &= 0xff; + ddtemp <<= 20; + ddtemp |= ddChannelNum; + ddtemp |= (0x700 << 8); + for(i = 4; i > 0; i-- ){ + do { + ddtemp2 = read32(ddBAR0 + SB_AZ_BAR_REG68); + } while (ddtemp2 & 0x1 /* Bit 0 */); + dbtemp2 = ( (tempAzaliaCodecEntryPtr->Byte40) >> ((4-i) * 8 ) ) & 0xff; + ddtemp = (ddtemp & 0xFFFF0000)+ ((dbtemp1 - i) << 8) + dbtemp2; + write32(ddBAR0 + SB_AZ_BAR_REG60 /*, AccWidthUint32 | S3_SAVE, */, ddtemp); + udelay(60); + } + ++tempAzaliaCodecEntryPtr; + } +} + static int set_bits(u32 port, u32 mask, u32 val) { u32 dword; diff --git a/src/southbridge/amd/sb700/hda.h b/src/southbridge/amd/sb700/hda.h new file mode 100644 index 0000000..ed632e7 --- /dev/null +++ b/src/southbridge/amd/sb700/hda.h @@ -0,0 +1,31 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2011 Denis 'GNUtoo' Carikli GNUtoo@no-log.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef SB700_HDA_H +#define SB700_HDA_H + +typedef struct _CODECENTRY { + u8 Nid; + u32 Byte40; +} CODECENTRY; + +void azalia_set_config(CODECENTRY* tempAzaliaCodecEntryPtr, u32 ddChannelNum, u32 ddBAR0); + +#endif