Lee Leahy | c421041 | 2015-06-29 11:37:56 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2007-2009 coresystems GmbH |
| 5 | * Copyright (C) 2013 Google Inc. |
| 6 | * Copyright (C) 2015 Intel Corporation. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; version 2 of the License. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
Lee Leahy | c421041 | 2015-06-29 11:37:56 -0700 | [diff] [blame] | 16 | */ |
| 17 | |
Naresh G Solanki | 06b0098 | 2015-12-02 16:21:20 +0530 | [diff] [blame] | 18 | #include <arch/acpi.h> |
| 19 | #include <console/console.h> |
Lee Leahy | c421041 | 2015-06-29 11:37:56 -0700 | [diff] [blame] | 20 | #include <device/device.h> |
Naresh G Solanki | 06b0098 | 2015-12-02 16:21:20 +0530 | [diff] [blame] | 21 | #include <gpio.h> |
pchandri | dfdd33e | 2015-08-24 13:44:19 -0700 | [diff] [blame] | 22 | #include <stdlib.h> |
Fang, Yang A | 8a0d274 | 2016-01-28 17:09:17 -0800 | [diff] [blame] | 23 | #include <string.h> |
Naresh G Solanki | 06b0098 | 2015-12-02 16:21:20 +0530 | [diff] [blame] | 24 | #include <soc/nhlt.h> |
pchandri | dfdd33e | 2015-08-24 13:44:19 -0700 | [diff] [blame] | 25 | #include "ec.h" |
Naresh G Solanki | 06b0098 | 2015-12-02 16:21:20 +0530 | [diff] [blame] | 26 | #include "gpio.h" |
pchandri | dfdd33e | 2015-08-24 13:44:19 -0700 | [diff] [blame] | 27 | |
Fang, Yang A | 8a0d274 | 2016-01-28 17:09:17 -0800 | [diff] [blame] | 28 | static const char *oem_id_maxim = "INTEL"; |
| 29 | static const char *oem_table_id_maxim = "SCRDMAX"; |
| 30 | |
pchandri | dfdd33e | 2015-08-24 13:44:19 -0700 | [diff] [blame] | 31 | static void mainboard_init(device_t dev) |
| 32 | { |
| 33 | mainboard_ec_init(); |
| 34 | } |
| 35 | |
Naresh G Solanki | 06b0098 | 2015-12-02 16:21:20 +0530 | [diff] [blame] | 36 | static uint8_t select_audio_codec(void) |
| 37 | { |
| 38 | int audio_db_sel = gpio_get(AUDIO_DB_ID); |
| 39 | |
| 40 | return audio_db_sel; |
| 41 | } |
| 42 | |
| 43 | static unsigned long mainboard_write_acpi_tables( |
| 44 | device_t device, unsigned long current, acpi_rsdp_t *rsdp) |
| 45 | { |
| 46 | uintptr_t start_addr; |
| 47 | uintptr_t end_addr; |
| 48 | struct nhlt *nhlt; |
Fang, Yang A | 8a0d274 | 2016-01-28 17:09:17 -0800 | [diff] [blame] | 49 | const char *oem_id = NULL; |
| 50 | const char *oem_table_id = NULL; |
Naresh G Solanki | 06b0098 | 2015-12-02 16:21:20 +0530 | [diff] [blame] | 51 | |
| 52 | start_addr = current; |
| 53 | |
| 54 | nhlt = nhlt_init(); |
| 55 | |
| 56 | if (nhlt == NULL) |
| 57 | return start_addr; |
| 58 | |
| 59 | /* 2 Channel DMIC array. */ |
| 60 | if (nhlt_soc_add_dmic_array(nhlt, 2)) |
| 61 | printk(BIOS_ERR, "Couldn't add 2CH DMIC array.\n"); |
| 62 | |
| 63 | |
| 64 | /* 4 Channel DMIC array. */ |
| 65 | if (nhlt_soc_add_dmic_array(nhlt, 4)) |
| 66 | printk(BIOS_ERR, "Couldn't add 4CH DMIC arrays.\n"); |
| 67 | |
| 68 | if (select_audio_codec()) { |
| 69 | /* ADI Smart Amps for left and right. */ |
| 70 | if (nhlt_soc_add_ssm4567(nhlt, AUDIO_LINK_SSP0)) |
| 71 | printk(BIOS_ERR, "Couldn't add ssm4567.\n"); |
| 72 | } else { |
| 73 | /* MAXIM Smart Amps for left and right. */ |
| 74 | if (nhlt_soc_add_max98357(nhlt, AUDIO_LINK_SSP0)) |
| 75 | printk(BIOS_ERR, "Couldn't add max98357.\n"); |
Fang, Yang A | 8a0d274 | 2016-01-28 17:09:17 -0800 | [diff] [blame] | 76 | |
| 77 | oem_id = oem_id_maxim; |
| 78 | oem_table_id = oem_table_id_maxim; |
Naresh G Solanki | 06b0098 | 2015-12-02 16:21:20 +0530 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | /* NAU88l25 Headset codec. */ |
| 82 | if (nhlt_soc_add_nau88l25(nhlt, AUDIO_LINK_SSP1)) |
| 83 | printk(BIOS_ERR, "Couldn't add headset codec.\n"); |
| 84 | |
Fang, Yang A | 8a0d274 | 2016-01-28 17:09:17 -0800 | [diff] [blame] | 85 | end_addr = nhlt_soc_serialize_oem_overrides(nhlt, start_addr, |
| 86 | oem_id, oem_table_id); |
Naresh G Solanki | 06b0098 | 2015-12-02 16:21:20 +0530 | [diff] [blame] | 87 | |
| 88 | if (end_addr != start_addr) |
| 89 | acpi_add_table(rsdp, (void *)start_addr); |
| 90 | |
| 91 | return end_addr; |
| 92 | } |
| 93 | |
pchandri | dfdd33e | 2015-08-24 13:44:19 -0700 | [diff] [blame] | 94 | /* |
| 95 | * mainboard_enable is executed as first thing after |
| 96 | * enumerate_buses(). |
| 97 | */ |
| 98 | static void mainboard_enable(device_t dev) |
| 99 | { |
| 100 | dev->ops->init = mainboard_init; |
Naresh G Solanki | 06b0098 | 2015-12-02 16:21:20 +0530 | [diff] [blame] | 101 | dev->ops->write_acpi_tables = mainboard_write_acpi_tables; |
pchandri | dfdd33e | 2015-08-24 13:44:19 -0700 | [diff] [blame] | 102 | } |
Lee Leahy | c421041 | 2015-06-29 11:37:56 -0700 | [diff] [blame] | 103 | |
| 104 | struct chip_operations mainboard_ops = { |
pchandri | dfdd33e | 2015-08-24 13:44:19 -0700 | [diff] [blame] | 105 | .enable_dev = mainboard_enable, |
Lee Leahy | c421041 | 2015-06-29 11:37:56 -0700 | [diff] [blame] | 106 | }; |