blob: 0d86284564385b444c3199ae21cef1af4935e932 [file] [log] [blame]
Lee Leahy87df8d02016-02-07 14:37:13 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2003 Eric Biederman
5 * Copyright (C) 2006-2010 coresystems GmbH
6 * Copyright (C) 2015-2016 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.
16 */
17
Lee Leahy87df8d02016-02-07 14:37:13 -080018#include <console/uart.h>
19#include <device/pci.h>
20#include <device/pci_def.h>
Lee Leahy654fd072016-02-17 08:47:58 -080021#include <device/pci_ids.h>
Lee Leahyf55f3e62016-02-17 08:47:58 -080022#include <soc/pci_devs.h>
Lee Leahy87df8d02016-02-07 14:37:13 -080023
Elyes HAOUAS756a0bd2018-09-19 14:50:54 +020024static void uart_read_resources(struct device *dev)
Lee Leahy87df8d02016-02-07 14:37:13 -080025{
Lee Leahy654fd072016-02-17 08:47:58 -080026 struct resource *res;
27
28 /* Read the resources */
29 pci_dev_read_resources(dev);
30
31 /* Set the debug port configuration */
32 res = find_resource(dev, PCI_BASE_ADDRESS_0);
33 res->base = uart_platform_base(CONFIG_UART_FOR_CONSOLE);
34 res->size = 0x100;
35 res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
Lee Leahy87df8d02016-02-07 14:37:13 -080036}
37
Lee Leahy654fd072016-02-17 08:47:58 -080038static struct device_operations device_ops = {
39 .read_resources = &uart_read_resources,
40 .set_resources = &pci_dev_set_resources,
41 .enable_resources = &pci_dev_enable_resources,
42};
Lee Leahy87df8d02016-02-07 14:37:13 -080043
Lee Leahy654fd072016-02-17 08:47:58 -080044static const struct pci_driver uart_driver __pci_driver = {
Lee Leahyf55f3e62016-02-17 08:47:58 -080045 .ops = &device_ops,
46 .vendor = PCI_VENDOR_ID_INTEL,
47 .device = HSUART_DEVID,
Lee Leahy654fd072016-02-17 08:47:58 -080048};