Angel Pons | 230e4f9d | 2020-04-05 15:47:14 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 2 | |
Kyösti Mälkki | e742b68 | 2023-04-10 17:03:32 +0300 | [diff] [blame] | 3 | #include <arch/ioapic.h> |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 4 | #include <device/pci.h> |
| 5 | #include <device/pci_ids.h> |
| 6 | #include <soc/iomap.h> |
| 7 | #include <soc/pci_devs.h> |
| 8 | #include <soc/pm.h> |
| 9 | #include <soc/ramstage.h> |
| 10 | |
Elyes HAOUAS | 696545d | 2018-05-25 13:11:37 +0200 | [diff] [blame] | 11 | static void pmc_read_resources(struct device *dev) |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 12 | { |
Lee Leahy | 94b971a | 2017-03-06 08:59:23 -0800 | [diff] [blame] | 13 | unsigned int index = 0; |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 14 | struct resource *res; |
| 15 | |
| 16 | /* Get the normal PCI resources of this device. */ |
| 17 | pci_dev_read_resources(dev); |
| 18 | |
Lee Leahy | 7f4b053 | 2016-05-22 11:52:28 -0700 | [diff] [blame] | 19 | /* GPE0 */ |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 20 | res = new_resource(dev, index++); |
Lee Leahy | 7f4b053 | 2016-05-22 11:52:28 -0700 | [diff] [blame] | 21 | res->base = GPE0_BASE_ADDRESS; |
| 22 | res->size = GPE0_SIZE; |
| 23 | res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 24 | |
| 25 | /* PM1BLK */ |
| 26 | res = new_resource(dev, index++); |
| 27 | res->base = PM1BLK_BASE_ADDRESS; |
| 28 | res->size = PM1BLK_SIZE; |
| 29 | res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 30 | |
| 31 | /* Legacy GPIO */ |
| 32 | res = new_resource(dev, index++); |
| 33 | res->base = LEGACY_GPIO_BASE_ADDRESS; |
| 34 | res->size = LEGACY_GPIO_SIZE; |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 35 | res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 36 | } |
| 37 | |
Kyösti Mälkki | e742b68 | 2023-04-10 17:03:32 +0300 | [diff] [blame] | 38 | /* Implemented just to fill FADT SCI_INT as 0. */ |
| 39 | void ioapic_get_sci_pin(u8 *gsi, u8 *irq, u8 *flags) |
| 40 | { |
| 41 | *irq = 0; |
| 42 | *gsi = 0; |
| 43 | } |
| 44 | |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 45 | static struct device_operations device_ops = { |
Elyes HAOUAS | 1d19127 | 2018-11-27 12:23:48 +0100 | [diff] [blame] | 46 | .read_resources = pmc_read_resources, |
| 47 | .set_resources = pci_dev_set_resources, |
| 48 | .enable_resources = pci_dev_enable_resources, |
Nico Huber | 51b75ae | 2019-03-14 16:02:05 +0100 | [diff] [blame] | 49 | .scan_bus = scan_static_bus, |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | static const struct pci_driver pmc __pci_driver = { |
| 53 | .ops = &device_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 54 | .vendor = PCI_VID_INTEL, |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 55 | .device = QUARK_V_LPC_DEVICE_ID_0, |
| 56 | }; |