Angel Pons | 230e4f9d | 2020-04-05 15:47:14 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Lee Leahy | 87df8d0 | 2016-02-07 14:37:13 -0800 | [diff] [blame] | 2 | |
Lee Leahy | 87df8d0 | 2016-02-07 14:37:13 -0800 | [diff] [blame] | 3 | #include <console/uart.h> |
| 4 | #include <device/pci.h> |
| 5 | #include <device/pci_def.h> |
Lee Leahy | 654fd07 | 2016-02-17 08:47:58 -0800 | [diff] [blame] | 6 | #include <device/pci_ids.h> |
Lee Leahy | f55f3e6 | 2016-02-17 08:47:58 -0800 | [diff] [blame] | 7 | #include <soc/pci_devs.h> |
Lee Leahy | 87df8d0 | 2016-02-07 14:37:13 -0800 | [diff] [blame] | 8 | |
Elyes HAOUAS | 756a0bd | 2018-09-19 14:50:54 +0200 | [diff] [blame] | 9 | static void uart_read_resources(struct device *dev) |
Lee Leahy | 87df8d0 | 2016-02-07 14:37:13 -0800 | [diff] [blame] | 10 | { |
Lee Leahy | 654fd07 | 2016-02-17 08:47:58 -0800 | [diff] [blame] | 11 | struct resource *res; |
| 12 | |
| 13 | /* Read the resources */ |
| 14 | pci_dev_read_resources(dev); |
| 15 | |
| 16 | /* Set the debug port configuration */ |
| 17 | res = find_resource(dev, PCI_BASE_ADDRESS_0); |
| 18 | res->base = uart_platform_base(CONFIG_UART_FOR_CONSOLE); |
| 19 | res->size = 0x100; |
| 20 | res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
Lee Leahy | 87df8d0 | 2016-02-07 14:37:13 -0800 | [diff] [blame] | 21 | } |
| 22 | |
Lee Leahy | 654fd07 | 2016-02-17 08:47:58 -0800 | [diff] [blame] | 23 | static struct device_operations device_ops = { |
Elyes HAOUAS | 1d19127 | 2018-11-27 12:23:48 +0100 | [diff] [blame] | 24 | .read_resources = uart_read_resources, |
| 25 | .set_resources = pci_dev_set_resources, |
| 26 | .enable_resources = pci_dev_enable_resources, |
Lee Leahy | 654fd07 | 2016-02-17 08:47:58 -0800 | [diff] [blame] | 27 | }; |
Lee Leahy | 87df8d0 | 2016-02-07 14:37:13 -0800 | [diff] [blame] | 28 | |
Lee Leahy | 654fd07 | 2016-02-17 08:47:58 -0800 | [diff] [blame] | 29 | static const struct pci_driver uart_driver __pci_driver = { |
Lee Leahy | f55f3e6 | 2016-02-17 08:47:58 -0800 | [diff] [blame] | 30 | .ops = &device_ops, |
| 31 | .vendor = PCI_VENDOR_ID_INTEL, |
| 32 | .device = HSUART_DEVID, |
Lee Leahy | 654fd07 | 2016-02-17 08:47:58 -0800 | [diff] [blame] | 33 | }; |