From ec505ad21c923c114a16b2710a0113f657765430 Mon Sep 17 00:00:00 2001 From: "Jonathan A. Kollasch" Date: Tue, 7 Jul 2015 12:57:46 -0500 Subject: [PATCH] azalia: fix up and clean up shrinkage of boilerplate code Should fix regression in HDA verb setup on nvidia mcp55 and intel sch southbridges. The mcp55 code could not find the mainboard's verb table because the table was not even being compiled in. The sch boards appeared to have the same issue. Intel broadwell and fsp_bd82x6x seemed to have not gotten the boilerplate shrink, so apply it to those too. Followup-to: Ib3e09644c0ee71aacb067adaa85653d151b52078 (azalia: Shrink boilerplate) Change-Id: If7aae69f5171db67055ffe220bdff392caaa5d9f Signed-off-by: Jonathan A. Kollasch Reviewed-on: http://review.coreboot.org/10826 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/mainboard/asus/m2n-e/hda_verb.c | 2 ++ src/mainboard/gigabyte/m57sli/hda_verb.c | 7 +++++++ .../google/auron/{hda_verb.h => hda_verb.c} | 9 +++++---- src/mainboard/google/auron/mainboard.c | 18 ------------------ .../google/jecht/{hda_verb.h => hda_verb.c} | 9 +++++---- src/mainboard/google/jecht/mainboard.c | 18 ------------------ src/mainboard/intel/cougar_canyon2/hda_verb.c | 3 +++ src/mainboard/iwave/iWRainbowG6/hda_verb.c | 7 ++++++- src/mainboard/msi/ms7260/hda_verb.c | 7 +++++++ src/mainboard/msi/ms9652_fam10/hda_verb.c | 7 +++++++ src/mainboard/nvidia/l1_2pvv/hda_verb.c | 7 ++++++- src/mainboard/supermicro/h8dme/hda_verb.c | 7 +++++++ src/mainboard/supermicro/h8dmr/hda_verb.c | 7 +++++++ .../supermicro/h8dmr_fam10/hda_verb.c | 7 +++++++ src/soc/intel/broadwell/Makefile.inc | 2 ++ src/soc/intel/broadwell/hda.c | 8 ++------ src/southbridge/intel/fsp_bd82x6x/Makefile.inc | 2 ++ src/southbridge/intel/fsp_bd82x6x/azalia.c | 6 +----- src/southbridge/intel/sch/Makefile.inc | 1 + src/southbridge/intel/sch/audio.c | 4 +--- src/southbridge/nvidia/mcp55/Makefile.inc | 4 ++++ src/southbridge/nvidia/mcp55/azalia.c | 11 +++++++---- 22 files changed, 89 insertions(+), 64 deletions(-) create mode 100644 src/mainboard/gigabyte/m57sli/hda_verb.c rename src/mainboard/google/auron/{hda_verb.h => hda_verb.c} (93%) rename src/mainboard/google/jecht/{hda_verb.h => hda_verb.c} (92%) create mode 100644 src/mainboard/msi/ms7260/hda_verb.c create mode 100644 src/mainboard/msi/ms9652_fam10/hda_verb.c create mode 100644 src/mainboard/supermicro/h8dme/hda_verb.c create mode 100644 src/mainboard/supermicro/h8dmr/hda_verb.c create mode 100644 src/mainboard/supermicro/h8dmr_fam10/hda_verb.c diff --git a/src/mainboard/asus/m2n-e/hda_verb.c b/src/mainboard/asus/m2n-e/hda_verb.c index 58bb983953..7e9a53c3cd 100644 --- a/src/mainboard/asus/m2n-e/hda_verb.c +++ b/src/mainboard/asus/m2n-e/hda_verb.c @@ -78,4 +78,6 @@ const u32 cim_verb_data[] = { AZALIA_PIN_CFG(0x0, 0x25, 0x01012014), }; +const u32 pc_beep_verbs[0] = {}; + AZALIA_ARRAY_SIZES; diff --git a/src/mainboard/gigabyte/m57sli/hda_verb.c b/src/mainboard/gigabyte/m57sli/hda_verb.c new file mode 100644 index 0000000000..072a306131 --- /dev/null +++ b/src/mainboard/gigabyte/m57sli/hda_verb.c @@ -0,0 +1,7 @@ +#include + +const u32 cim_verb_data[0] = {}; + +const u32 pc_beep_verbs[0] = {}; + +AZALIA_ARRAY_SIZES; diff --git a/src/mainboard/google/auron/hda_verb.h b/src/mainboard/google/auron/hda_verb.c similarity index 93% rename from src/mainboard/google/auron/hda_verb.h rename to src/mainboard/google/auron/hda_verb.c index 275ee3a74b..e015a832ad 100644 --- a/src/mainboard/google/auron/hda_verb.h +++ b/src/mainboard/google/auron/hda_verb.c @@ -17,7 +17,9 @@ * Foundation, Inc. */ -static const u32 mainboard_cim_verb_data[] = { +#include + +const u32 cim_verb_data[] = { /* coreboot specific header */ 0x10ec0283, // Codec Vendor / Device ID: Realtek ALC283 0x10ec0283, // Subsystem ID @@ -109,7 +111,7 @@ static const u32 mainboard_cim_verb_data[] = { 0x0204081b, }; -static const u32 mainboard_pc_beep_verbs[] = { +const u32 pc_beep_verbs[] = { 0x00170500, /* power up everything (codec, dac, adc, mixers) */ 0x01470740, /* enable speaker out */ 0x01470c02, /* set speaker EAPD pin */ @@ -118,5 +120,4 @@ static const u32 mainboard_pc_beep_verbs[] = { 0x00b37410, /* unmute mixer nid 0xb beep input and set volume */ }; -static const u32 mainboard_pc_beep_verbs_size = - sizeof(mainboard_pc_beep_verbs) / sizeof(mainboard_pc_beep_verbs[0]); +AZALIA_ARRAY_SIZES; diff --git a/src/mainboard/google/auron/mainboard.c b/src/mainboard/google/auron/mainboard.c index cc9907eb0c..13eec7ebec 100644 --- a/src/mainboard/google/auron/mainboard.c +++ b/src/mainboard/google/auron/mainboard.c @@ -32,27 +32,10 @@ #include #include #include -#include "hda_verb.h" #include "ec.h" #include "onboard.h" -/* Audio Setup */ - -extern const u32 *cim_verb_data; -extern u32 cim_verb_data_size; -extern const u32 *pc_beep_verbs; -extern u32 pc_beep_verbs_size; - -static void verb_setup(void) -{ - cim_verb_data = mainboard_cim_verb_data; - cim_verb_data_size = sizeof(mainboard_cim_verb_data); - pc_beep_verbs = mainboard_pc_beep_verbs; - pc_beep_verbs_size = mainboard_pc_beep_verbs_size; - -} - static void mainboard_init(device_t dev) { mainboard_ec_init(); @@ -110,7 +93,6 @@ static void mainboard_enable(device_t dev) dev->ops->init = mainboard_init; dev->ops->get_smbios_data = mainboard_smbios_data; install_intel_vga_int15_handler(GMA_INT15_ACTIVE_LFP_EDP, GMA_INT15_PANEL_FIT_CENTERING, GMA_INT15_BOOT_DISPLAY_DEFAULT, 0); - verb_setup(); } struct chip_operations mainboard_ops = { diff --git a/src/mainboard/google/jecht/hda_verb.h b/src/mainboard/google/jecht/hda_verb.c similarity index 92% rename from src/mainboard/google/jecht/hda_verb.h rename to src/mainboard/google/jecht/hda_verb.c index bc7cf1d8dd..f4b5982399 100644 --- a/src/mainboard/google/jecht/hda_verb.h +++ b/src/mainboard/google/jecht/hda_verb.c @@ -17,7 +17,9 @@ * Foundation, Inc. */ -static const u32 mainboard_cim_verb_data[] = { +#include + +const u32 cim_verb_data[] = { /* coreboot specific header */ 0x10ec0283, // Codec Vendor / Device ID: Realtek ALC283 0x10ec0283, // Subsystem ID @@ -99,7 +101,7 @@ static const u32 mainboard_cim_verb_data[] = { 0x0204081b, }; -static const u32 mainboard_pc_beep_verbs[] = { +const u32 pc_beep_verbs[] = { 0x00170500, /* power up everything (codec, dac, adc, mixers) */ 0x01470740, /* enable speaker out */ 0x01470c02, /* set speaker EAPD pin */ @@ -108,5 +110,4 @@ static const u32 mainboard_pc_beep_verbs[] = { 0x00b37410, /* unmute mixer nid 0xb beep input and set volume */ }; -static const u32 mainboard_pc_beep_verbs_size = - sizeof(mainboard_pc_beep_verbs) / sizeof(mainboard_pc_beep_verbs[0]); +AZALIA_ARRAY_SIZES; diff --git a/src/mainboard/google/jecht/mainboard.c b/src/mainboard/google/jecht/mainboard.c index 8b3363c751..f0b2e373e3 100644 --- a/src/mainboard/google/jecht/mainboard.c +++ b/src/mainboard/google/jecht/mainboard.c @@ -34,7 +34,6 @@ #include #include #include -#include "hda_verb.h" #include "onboard.h" void mainboard_suspend_resume(void) @@ -129,22 +128,6 @@ static int int15_handler(void) } #endif -/* Audio Setup */ - -extern const u32 *cim_verb_data; -extern u32 cim_verb_data_size; -extern const u32 *pc_beep_verbs; -extern u32 pc_beep_verbs_size; - -static void verb_setup(void) -{ - cim_verb_data = mainboard_cim_verb_data; - cim_verb_data_size = sizeof(mainboard_cim_verb_data); - pc_beep_verbs = mainboard_pc_beep_verbs; - pc_beep_verbs_size = mainboard_pc_beep_verbs_size; - -} - static void mainboard_init(device_t dev) { lan_init(); @@ -160,7 +143,6 @@ static void mainboard_enable(device_t dev) /* Install custom int15 handler for VGA OPROM */ mainboard_interrupt_handlers(0x15, &int15_handler); #endif - verb_setup(); } struct chip_operations mainboard_ops = { diff --git a/src/mainboard/intel/cougar_canyon2/hda_verb.c b/src/mainboard/intel/cougar_canyon2/hda_verb.c index 51b635696e..a110246622 100644 --- a/src/mainboard/intel/cougar_canyon2/hda_verb.c +++ b/src/mainboard/intel/cougar_canyon2/hda_verb.c @@ -37,4 +37,7 @@ const u32 cim_verb_data[] = { /* Pin Complex (NID 0x07) Digital Out at Int HDMI */ AZALIA_PIN_CFG(0x3, 0x07, 0x18560030) }; + +const u32 pc_beep_verbs[0] = {}; + AZALIA_ARRAY_SIZES; diff --git a/src/mainboard/iwave/iWRainbowG6/hda_verb.c b/src/mainboard/iwave/iWRainbowG6/hda_verb.c index effc22ea8d..21b230b8ca 100644 --- a/src/mainboard/iwave/iWRainbowG6/hda_verb.c +++ b/src/mainboard/iwave/iWRainbowG6/hda_verb.c @@ -17,7 +17,9 @@ * Foundation, Inc. */ -static u32 mainboard_cim_verb_data[] = { +#include + +const u32 cim_verb_data[] = { /* coreboot specific header */ 0x111d76d5, // Codec Vendor / Device ID: IDT 92HD81 0x00000000, // Subsystem ID @@ -89,4 +91,7 @@ static u32 mainboard_cim_verb_data[] = { /* BTL Gain */ 0x017F417, /* Gain = 16.79dB */ }; + +const u32 pc_beep_verbs[0] = {}; + AZALIA_ARRAY_SIZES; diff --git a/src/mainboard/msi/ms7260/hda_verb.c b/src/mainboard/msi/ms7260/hda_verb.c new file mode 100644 index 0000000000..072a306131 --- /dev/null +++ b/src/mainboard/msi/ms7260/hda_verb.c @@ -0,0 +1,7 @@ +#include + +const u32 cim_verb_data[0] = {}; + +const u32 pc_beep_verbs[0] = {}; + +AZALIA_ARRAY_SIZES; diff --git a/src/mainboard/msi/ms9652_fam10/hda_verb.c b/src/mainboard/msi/ms9652_fam10/hda_verb.c new file mode 100644 index 0000000000..072a306131 --- /dev/null +++ b/src/mainboard/msi/ms9652_fam10/hda_verb.c @@ -0,0 +1,7 @@ +#include + +const u32 cim_verb_data[0] = {}; + +const u32 pc_beep_verbs[0] = {}; + +AZALIA_ARRAY_SIZES; diff --git a/src/mainboard/nvidia/l1_2pvv/hda_verb.c b/src/mainboard/nvidia/l1_2pvv/hda_verb.c index bb20c2bc3c..68076f9dad 100644 --- a/src/mainboard/nvidia/l1_2pvv/hda_verb.c +++ b/src/mainboard/nvidia/l1_2pvv/hda_verb.c @@ -19,7 +19,9 @@ * Foundation, Inc. */ -static u32 mainboard_cim_verb_data[] = { +#include + +const u32 cim_verb_data[] = { /* coreboot specific header */ 0x10ec0880, // Codec Vendor / Device ID: Realtek ALC880 0x00000000, // Subsystem ID @@ -64,4 +66,7 @@ static u32 mainboard_cim_verb_data[] = { /* NID 0x1f, S/PDIF-IN */ AZALIA_PIN_CFG(0x0, 0x1f, 0x01c59150), }; + +const u32 pc_beep_verbs[0] = {}; + AZALIA_ARRAY_SIZES; diff --git a/src/mainboard/supermicro/h8dme/hda_verb.c b/src/mainboard/supermicro/h8dme/hda_verb.c new file mode 100644 index 0000000000..072a306131 --- /dev/null +++ b/src/mainboard/supermicro/h8dme/hda_verb.c @@ -0,0 +1,7 @@ +#include + +const u32 cim_verb_data[0] = {}; + +const u32 pc_beep_verbs[0] = {}; + +AZALIA_ARRAY_SIZES; diff --git a/src/mainboard/supermicro/h8dmr/hda_verb.c b/src/mainboard/supermicro/h8dmr/hda_verb.c new file mode 100644 index 0000000000..072a306131 --- /dev/null +++ b/src/mainboard/supermicro/h8dmr/hda_verb.c @@ -0,0 +1,7 @@ +#include + +const u32 cim_verb_data[0] = {}; + +const u32 pc_beep_verbs[0] = {}; + +AZALIA_ARRAY_SIZES; diff --git a/src/mainboard/supermicro/h8dmr_fam10/hda_verb.c b/src/mainboard/supermicro/h8dmr_fam10/hda_verb.c new file mode 100644 index 0000000000..072a306131 --- /dev/null +++ b/src/mainboard/supermicro/h8dmr_fam10/hda_verb.c @@ -0,0 +1,7 @@ +#include + +const u32 cim_verb_data[0] = {}; + +const u32 pc_beep_verbs[0] = {}; + +AZALIA_ARRAY_SIZES; diff --git a/src/soc/intel/broadwell/Makefile.inc b/src/soc/intel/broadwell/Makefile.inc index d7845e6a2c..4b14ff809e 100644 --- a/src/soc/intel/broadwell/Makefile.inc +++ b/src/soc/intel/broadwell/Makefile.inc @@ -66,6 +66,8 @@ ramstage-y += ehci.c ramstage-y += xhci.c smm-y += xhci.c +ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/hda_verb.c + ifeq ($(CONFIG_USBDEBUG),y) ramstage-y += usbdebug.c romstage-y += usbdebug.c diff --git a/src/soc/intel/broadwell/hda.c b/src/soc/intel/broadwell/hda.c index 28b3df7cc8..43321b7108 100644 --- a/src/soc/intel/broadwell/hda.c +++ b/src/soc/intel/broadwell/hda.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -31,11 +32,6 @@ #include #include -const u32 * cim_verb_data = NULL; -u32 cim_verb_data_size = 0; -const u32 * pc_beep_verbs = NULL; -u32 pc_beep_verbs_size = 0; - static void codecs_init(u8 *base, u32 codec_mask) { int i; @@ -48,7 +44,7 @@ static void codecs_init(u8 *base, u32 codec_mask) cim_verb_data); } - if (pc_beep_verbs_size && pc_beep_verbs) + if (pc_beep_verbs_size) hda_codec_write(base, pc_beep_verbs_size, pc_beep_verbs); } diff --git a/src/southbridge/intel/fsp_bd82x6x/Makefile.inc b/src/southbridge/intel/fsp_bd82x6x/Makefile.inc index d96e641670..228b6eb5f2 100644 --- a/src/southbridge/intel/fsp_bd82x6x/Makefile.inc +++ b/src/southbridge/intel/fsp_bd82x6x/Makefile.inc @@ -39,6 +39,8 @@ smm-$(CONFIG_SPI_FLASH_SMM) += ../common/spi.c ramstage-$(CONFIG_HAVE_SMI_HANDLER) += smi.c smm-$(CONFIG_HAVE_SMI_HANDLER) += smihandler.c me.c me_8.x.c finalize.c +ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/hda_verb.c + romstage-y += early_usb.c early_smbus.c early_me.c me_status.c gpio.c early_init.c romstage-$(CONFIG_USBDEBUG) += usb_debug.c ramstage-$(CONFIG_USBDEBUG) += usb_debug.c diff --git a/src/southbridge/intel/fsp_bd82x6x/azalia.c b/src/southbridge/intel/fsp_bd82x6x/azalia.c index e6c9b27ae2..b6f728c4a8 100644 --- a/src/southbridge/intel/fsp_bd82x6x/azalia.c +++ b/src/southbridge/intel/fsp_bd82x6x/azalia.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -91,11 +92,6 @@ no_codec: return 0; } -const u32 * cim_verb_data = NULL; -u32 cim_verb_data_size = 0; -const u32 * pc_beep_verbs = NULL; -u32 pc_beep_verbs_size = 0; - static u32 find_verb(struct device *dev, u32 viddid, const u32 ** verb) { int idx=0; diff --git a/src/southbridge/intel/sch/Makefile.inc b/src/southbridge/intel/sch/Makefile.inc index db876a15d8..0b21801f2b 100644 --- a/src/southbridge/intel/sch/Makefile.inc +++ b/src/southbridge/intel/sch/Makefile.inc @@ -36,6 +36,7 @@ ramstage-$(CONFIG_HAVE_SMI_HANDLER) += smi.c ramstage-$(CONFIG_HAVE_SMI_HANDLER) += ../../../cpu/x86/smm/smmrelocate.S smm-$(CONFIG_HAVE_SMI_HANDLER) += smihandler.c +ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/hda_verb.c # We don't ship that, but booting without it is bound to fail cbfs-files-$(CONFIG_HAVE_CMC) += cmc.bin diff --git a/src/southbridge/intel/sch/audio.c b/src/southbridge/intel/sch/audio.c index 770bb753c3..bba2f7b7d0 100644 --- a/src/southbridge/intel/sch/audio.c +++ b/src/southbridge/intel/sch/audio.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -112,9 +113,6 @@ no_codec: return 0; } -const u32 *cim_verb_data = NULL; -u32 cim_verb_data_size = 0; - static u32 find_verb(struct device *dev, u32 viddid, const u32 ** verb) { printk(BIOS_DEBUG, "sch_audio: dev=%s\n", dev_path(dev)); diff --git a/src/southbridge/nvidia/mcp55/Makefile.inc b/src/southbridge/nvidia/mcp55/Makefile.inc index 3e24f1c293..fb9c3fb846 100644 --- a/src/southbridge/nvidia/mcp55/Makefile.inc +++ b/src/southbridge/nvidia/mcp55/Makefile.inc @@ -20,6 +20,10 @@ ramstage-y += reset.c romstage-$(CONFIG_USBDEBUG_IN_ROMSTAGE) += enable_usbdebug.c ramstage-$(CONFIG_USBDEBUG) += enable_usbdebug.c +ifeq ($(CONFIG_MCP55_USE_AZA),y) +ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/hda_verb.c +endif + chipset_bootblock_inc += $(src)/southbridge/nvidia/mcp55/romstrap.inc bootblock-y += romstrap.ld diff --git a/src/southbridge/nvidia/mcp55/azalia.c b/src/southbridge/nvidia/mcp55/azalia.c index 828574914c..bb4376f439 100644 --- a/src/southbridge/nvidia/mcp55/azalia.c +++ b/src/southbridge/nvidia/mcp55/azalia.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -27,6 +28,7 @@ #include #include "mcp55.h" +#if IS_ENABLED(CONFIG_MCP55_USE_AZA) #define HDA_ICII_REG 0x68 #define HDA_ICII_BUSY (1 << 0) #define HDA_ICII_VALID (1 << 1) @@ -86,10 +88,8 @@ no_codec: return 0; } -u32 *cim_verb_data = NULL; -u32 cim_verb_data_size = 0; -static u32 find_verb(struct device *dev, u32 viddid, u32 **verb) +static u32 find_verb(struct device *dev, u32 viddid, const u32 **verb) { int idx = 0; @@ -155,7 +155,7 @@ static int wait_for_valid(u8 *base) static void codec_init(struct device *dev, u8 *base, int addr) { u32 reg32, verb_size; - u32 *verb; + const u32 *verb; int i; printk(BIOS_DEBUG, "Azalia: Initializing codec #%d\n", addr); @@ -203,9 +203,11 @@ static void codecs_init(struct device *dev, u8 *base, u32 codec_mask) codec_init(dev, base, i); } } +#endif static void azalia_init(struct device *dev) { +#if IS_ENABLED(CONFIG_MCP55_USE_AZA) u8 *base; u32 codec_mask, reg32; struct resource *res; @@ -253,6 +255,7 @@ static void azalia_init(struct device *dev) printk(BIOS_DEBUG, "Azalia: codec_mask = %02x\n", codec_mask); codecs_init(dev, base, codec_mask); } +#endif } static void azalia_set_subsystem(device_t dev, unsigned vendor, unsigned device)