blob: d8db07697886c9c7aff6b2b792ca89a645da56ba [file] [log] [blame]
Lee Leahy87df8d02016-02-07 14:37:13 -08001/*
2 * This file is part of the coreboot project.
3 *
Lee Leahy87df8d02016-02-07 14:37:13 -08004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
Lee Leahy87df8d02016-02-07 14:37:13 -080015#include <console/uart.h>
16#include <device/pci.h>
17#include <device/pci_def.h>
Lee Leahy654fd072016-02-17 08:47:58 -080018#include <device/pci_ids.h>
Lee Leahyf55f3e62016-02-17 08:47:58 -080019#include <soc/pci_devs.h>
Lee Leahy87df8d02016-02-07 14:37:13 -080020
Elyes HAOUAS756a0bd2018-09-19 14:50:54 +020021static void uart_read_resources(struct device *dev)
Lee Leahy87df8d02016-02-07 14:37:13 -080022{
Lee Leahy654fd072016-02-17 08:47:58 -080023 struct resource *res;
24
25 /* Read the resources */
26 pci_dev_read_resources(dev);
27
28 /* Set the debug port configuration */
29 res = find_resource(dev, PCI_BASE_ADDRESS_0);
30 res->base = uart_platform_base(CONFIG_UART_FOR_CONSOLE);
31 res->size = 0x100;
32 res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
Lee Leahy87df8d02016-02-07 14:37:13 -080033}
34
Lee Leahy654fd072016-02-17 08:47:58 -080035static struct device_operations device_ops = {
Elyes HAOUAS1d191272018-11-27 12:23:48 +010036 .read_resources = uart_read_resources,
37 .set_resources = pci_dev_set_resources,
38 .enable_resources = pci_dev_enable_resources,
Lee Leahy654fd072016-02-17 08:47:58 -080039};
Lee Leahy87df8d02016-02-07 14:37:13 -080040
Lee Leahy654fd072016-02-17 08:47:58 -080041static const struct pci_driver uart_driver __pci_driver = {
Lee Leahyf55f3e62016-02-17 08:47:58 -080042 .ops = &device_ops,
43 .vendor = PCI_VENDOR_ID_INTEL,
44 .device = HSUART_DEVID,
Lee Leahy654fd072016-02-17 08:47:58 -080045};