blob: 3dbae702e255ab8df1416392c2a839263070c612 [file] [log] [blame]
John Zhaob8d66bb2017-10-20 17:44:24 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright 2017 Intel Corp.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
Lijian Zhao6ad88272017-10-23 11:01:14 -070016#include <arch/acpi.h>
John Zhaob8d66bb2017-10-20 17:44:24 -070017#include <baseboard/variants.h>
18#include <device/device.h>
Lijian Zhao6ad88272017-10-23 11:01:14 -070019#include <nhlt.h>
John Zhaob8d66bb2017-10-20 17:44:24 -070020#include <soc/gpio.h>
Lijian Zhao6ad88272017-10-23 11:01:14 -070021#include <soc/nhlt.h>
John Zhaob8d66bb2017-10-20 17:44:24 -070022#include <vendorcode/google/chromeos/chromeos.h>
23#include <variant/gpio.h>
24
25static void mainboard_init(void *chip_info)
26{
27 const struct pad_config *pads;
28 size_t num;
29
30 pads = variant_gpio_table(&num);
31 gpio_configure_pads(pads, num);
32}
33
Elyes HAOUAS5cb876c2018-06-08 18:31:43 +020034static unsigned long mainboard_write_acpi_tables(struct device *device,
35 unsigned long current,
36 acpi_rsdp_t *rsdp)
Lijian Zhao6ad88272017-10-23 11:01:14 -070037{
38 uintptr_t start_addr;
39 uintptr_t end_addr;
40 struct nhlt *nhlt;
41
42 start_addr = current;
43
44 nhlt = nhlt_init();
45
46 if (nhlt == NULL)
47 return start_addr;
48
49 variant_nhlt_init(nhlt);
50
51 end_addr = nhlt_soc_serialize(nhlt, start_addr);
52
53 if (end_addr != start_addr)
54 acpi_add_table(rsdp, (void *)start_addr);
55
56 return end_addr;
57}
58
Elyes HAOUAS5cb876c2018-06-08 18:31:43 +020059static void mainboard_enable(struct device *dev)
John Zhaob8d66bb2017-10-20 17:44:24 -070060{
Lijian Zhao6ad88272017-10-23 11:01:14 -070061 dev->ops->write_acpi_tables = mainboard_write_acpi_tables;
John Zhaob8d66bb2017-10-20 17:44:24 -070062 dev->ops->acpi_inject_dsdt_generator = chromeos_dsdt_generator;
63}
64
65struct chip_operations mainboard_ops = {
66 .init = mainboard_init,
67 .enable_dev = mainboard_enable,
68};