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 | |
| 3 | #include <device/pci.h> |
| 4 | #include <device/pci_ids.h> |
| 5 | #include <soc/iomap.h> |
| 6 | #include <soc/pci_devs.h> |
| 7 | #include <soc/pm.h> |
| 8 | #include <soc/ramstage.h> |
| 9 | |
Elyes HAOUAS | 696545d | 2018-05-25 13:11:37 +0200 | [diff] [blame] | 10 | static void pmc_read_resources(struct device *dev) |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 11 | { |
Lee Leahy | 94b971a | 2017-03-06 08:59:23 -0800 | [diff] [blame] | 12 | unsigned int index = 0; |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 13 | struct resource *res; |
| 14 | |
| 15 | /* Get the normal PCI resources of this device. */ |
| 16 | pci_dev_read_resources(dev); |
| 17 | |
Lee Leahy | 7f4b053 | 2016-05-22 11:52:28 -0700 | [diff] [blame] | 18 | /* GPE0 */ |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 19 | res = new_resource(dev, index++); |
Lee Leahy | 7f4b053 | 2016-05-22 11:52:28 -0700 | [diff] [blame] | 20 | res->base = GPE0_BASE_ADDRESS; |
| 21 | res->size = GPE0_SIZE; |
| 22 | res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 23 | |
| 24 | /* PM1BLK */ |
| 25 | res = new_resource(dev, index++); |
| 26 | res->base = PM1BLK_BASE_ADDRESS; |
| 27 | res->size = PM1BLK_SIZE; |
| 28 | res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 29 | |
| 30 | /* Legacy GPIO */ |
| 31 | res = new_resource(dev, index++); |
| 32 | res->base = LEGACY_GPIO_BASE_ADDRESS; |
| 33 | res->size = LEGACY_GPIO_SIZE; |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 34 | res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 35 | } |
| 36 | |
| 37 | static struct device_operations device_ops = { |
Elyes HAOUAS | 1d19127 | 2018-11-27 12:23:48 +0100 | [diff] [blame] | 38 | .read_resources = pmc_read_resources, |
| 39 | .set_resources = pci_dev_set_resources, |
| 40 | .enable_resources = pci_dev_enable_resources, |
Nico Huber | 51b75ae | 2019-03-14 16:02:05 +0100 | [diff] [blame] | 41 | .scan_bus = scan_static_bus, |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | static const struct pci_driver pmc __pci_driver = { |
| 45 | .ops = &device_ops, |
| 46 | .vendor = PCI_VENDOR_ID_INTEL, |
| 47 | .device = QUARK_V_LPC_DEVICE_ID_0, |
| 48 | }; |