Lee Leahy | 87df8d0 | 2016-02-07 14:37:13 -0800 | [diff] [blame] | 1 | /* |
| 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 Leahy | 87df8d0 | 2016-02-07 14:37:13 -0800 | [diff] [blame] | 18 | #include <console/uart.h> |
| 19 | #include <device/pci.h> |
| 20 | #include <device/pci_def.h> |
Lee Leahy | 654fd07 | 2016-02-17 08:47:58 -0800 | [diff] [blame] | 21 | #include <device/pci_ids.h> |
Lee Leahy | 87df8d0 | 2016-02-07 14:37:13 -0800 | [diff] [blame] | 22 | |
Lee Leahy | 654fd07 | 2016-02-17 08:47:58 -0800 | [diff] [blame] | 23 | static void uart_read_resources(device_t dev) |
Lee Leahy | 87df8d0 | 2016-02-07 14:37:13 -0800 | [diff] [blame] | 24 | { |
Lee Leahy | 654fd07 | 2016-02-17 08:47:58 -0800 | [diff] [blame] | 25 | struct resource *res; |
| 26 | |
| 27 | /* Read the resources */ |
| 28 | pci_dev_read_resources(dev); |
| 29 | |
| 30 | /* Set the debug port configuration */ |
| 31 | res = find_resource(dev, PCI_BASE_ADDRESS_0); |
| 32 | res->base = uart_platform_base(CONFIG_UART_FOR_CONSOLE); |
| 33 | res->size = 0x100; |
| 34 | res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
Lee Leahy | 87df8d0 | 2016-02-07 14:37:13 -0800 | [diff] [blame] | 35 | } |
| 36 | |
Lee Leahy | 654fd07 | 2016-02-17 08:47:58 -0800 | [diff] [blame] | 37 | static struct device_operations device_ops = { |
| 38 | .read_resources = &uart_read_resources, |
| 39 | .set_resources = &pci_dev_set_resources, |
| 40 | .enable_resources = &pci_dev_enable_resources, |
| 41 | }; |
Lee Leahy | 87df8d0 | 2016-02-07 14:37:13 -0800 | [diff] [blame] | 42 | |
Lee Leahy | 654fd07 | 2016-02-17 08:47:58 -0800 | [diff] [blame] | 43 | static const unsigned short uart_ids[] = { |
| 44 | 0x0936, /* HSUART0, HSUART1 */ |
| 45 | 0 |
| 46 | }; |
| 47 | |
| 48 | static const struct pci_driver uart_driver __pci_driver = { |
| 49 | .ops = &device_ops, |
| 50 | .vendor = PCI_VENDOR_ID_INTEL, |
| 51 | .devices = uart_ids, |
| 52 | }; |