blob: cbadc2e08ee20ed9d8c005dde1fd4ce4c4d67ee7 [file] [log] [blame]
Lee Leahyc4210412015-06-29 11:37:56 -07001/*
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 Leahyc4210412015-06-29 11:37:56 -070016 */
17
Naresh G Solanki06b00982015-12-02 16:21:20 +053018#include <arch/acpi.h>
19#include <console/console.h>
Lee Leahyc4210412015-06-29 11:37:56 -070020#include <device/device.h>
Naresh G Solanki06b00982015-12-02 16:21:20 +053021#include <gpio.h>
pchandridfdd33e2015-08-24 13:44:19 -070022#include <stdlib.h>
Fang, Yang A8a0d2742016-01-28 17:09:17 -080023#include <string.h>
Naresh G Solanki06b00982015-12-02 16:21:20 +053024#include <soc/nhlt.h>
Aaron Durbinb0f81512016-07-25 21:31:41 -050025#include <vendorcode/google/chromeos/chromeos.h>
pchandridfdd33e2015-08-24 13:44:19 -070026#include "ec.h"
Naresh G Solanki06b00982015-12-02 16:21:20 +053027#include "gpio.h"
pchandridfdd33e2015-08-24 13:44:19 -070028
Fang, Yang A8a0d2742016-01-28 17:09:17 -080029static const char *oem_id_maxim = "INTEL";
30static const char *oem_table_id_maxim = "SCRDMAX";
31
pchandridfdd33e2015-08-24 13:44:19 -070032static void mainboard_init(device_t dev)
33{
34 mainboard_ec_init();
35}
36
Naresh G Solanki06b00982015-12-02 16:21:20 +053037static uint8_t select_audio_codec(void)
38{
39 int audio_db_sel = gpio_get(AUDIO_DB_ID);
40
41 return audio_db_sel;
42}
43
44static unsigned long mainboard_write_acpi_tables(
45 device_t device, unsigned long current, acpi_rsdp_t *rsdp)
46{
47 uintptr_t start_addr;
48 uintptr_t end_addr;
49 struct nhlt *nhlt;
Fang, Yang A8a0d2742016-01-28 17:09:17 -080050 const char *oem_id = NULL;
51 const char *oem_table_id = NULL;
Naresh G Solanki06b00982015-12-02 16:21:20 +053052
53 start_addr = current;
54
55 nhlt = nhlt_init();
56
57 if (nhlt == NULL)
58 return start_addr;
59
60 /* 2 Channel DMIC array. */
61 if (nhlt_soc_add_dmic_array(nhlt, 2))
62 printk(BIOS_ERR, "Couldn't add 2CH DMIC array.\n");
63
64
65 /* 4 Channel DMIC array. */
66 if (nhlt_soc_add_dmic_array(nhlt, 4))
67 printk(BIOS_ERR, "Couldn't add 4CH DMIC arrays.\n");
68
69 if (select_audio_codec()) {
70 /* ADI Smart Amps for left and right. */
71 if (nhlt_soc_add_ssm4567(nhlt, AUDIO_LINK_SSP0))
72 printk(BIOS_ERR, "Couldn't add ssm4567.\n");
73 } else {
74 /* MAXIM Smart Amps for left and right. */
75 if (nhlt_soc_add_max98357(nhlt, AUDIO_LINK_SSP0))
76 printk(BIOS_ERR, "Couldn't add max98357.\n");
Fang, Yang A8a0d2742016-01-28 17:09:17 -080077
78 oem_id = oem_id_maxim;
79 oem_table_id = oem_table_id_maxim;
Naresh G Solanki06b00982015-12-02 16:21:20 +053080 }
81
82 /* NAU88l25 Headset codec. */
83 if (nhlt_soc_add_nau88l25(nhlt, AUDIO_LINK_SSP1))
84 printk(BIOS_ERR, "Couldn't add headset codec.\n");
85
Fang, Yang A8a0d2742016-01-28 17:09:17 -080086 end_addr = nhlt_soc_serialize_oem_overrides(nhlt, start_addr,
Aaron Durbinb4afe3c2016-11-29 23:14:25 -060087 oem_id, oem_table_id, 0);
Naresh G Solanki06b00982015-12-02 16:21:20 +053088
89 if (end_addr != start_addr)
90 acpi_add_table(rsdp, (void *)start_addr);
91
92 return end_addr;
93}
94
pchandridfdd33e2015-08-24 13:44:19 -070095/*
96 * mainboard_enable is executed as first thing after
97 * enumerate_buses().
98 */
99static void mainboard_enable(device_t dev)
100{
101 dev->ops->init = mainboard_init;
Naresh G Solanki06b00982015-12-02 16:21:20 +0530102 dev->ops->write_acpi_tables = mainboard_write_acpi_tables;
Aaron Durbinb0f81512016-07-25 21:31:41 -0500103 dev->ops->acpi_inject_dsdt_generator = chromeos_dsdt_generator;
pchandridfdd33e2015-08-24 13:44:19 -0700104}
Lee Leahyc4210412015-06-29 11:37:56 -0700105
106struct chip_operations mainboard_ops = {
pchandridfdd33e2015-08-24 13:44:19 -0700107 .enable_dev = mainboard_enable,
Lee Leahyc4210412015-06-29 11:37:56 -0700108};