Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; version 2 of the License. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | */ |
| 14 | |
| 15 | #include <device/pci.h> |
| 16 | #include <device/pci_ids.h> |
| 17 | #include <soc/iomap.h> |
| 18 | #include <soc/pci_devs.h> |
| 19 | #include <soc/pm.h> |
| 20 | #include <soc/ramstage.h> |
| 21 | |
Elyes HAOUAS | 696545d | 2018-05-25 13:11:37 +0200 | [diff] [blame] | 22 | static void pmc_read_resources(struct device *dev) |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 23 | { |
Lee Leahy | 94b971a | 2017-03-06 08:59:23 -0800 | [diff] [blame] | 24 | unsigned int index = 0; |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 25 | struct resource *res; |
| 26 | |
| 27 | /* Get the normal PCI resources of this device. */ |
| 28 | pci_dev_read_resources(dev); |
| 29 | |
Lee Leahy | 7f4b053 | 2016-05-22 11:52:28 -0700 | [diff] [blame] | 30 | /* GPE0 */ |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 31 | res = new_resource(dev, index++); |
Lee Leahy | 7f4b053 | 2016-05-22 11:52:28 -0700 | [diff] [blame] | 32 | res->base = GPE0_BASE_ADDRESS; |
| 33 | res->size = GPE0_SIZE; |
| 34 | res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 35 | |
| 36 | /* PM1BLK */ |
| 37 | res = new_resource(dev, index++); |
| 38 | res->base = PM1BLK_BASE_ADDRESS; |
| 39 | res->size = PM1BLK_SIZE; |
| 40 | res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 41 | |
| 42 | /* Legacy GPIO */ |
| 43 | res = new_resource(dev, index++); |
| 44 | res->base = LEGACY_GPIO_BASE_ADDRESS; |
| 45 | res->size = LEGACY_GPIO_SIZE; |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 46 | res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 47 | } |
| 48 | |
| 49 | static struct device_operations device_ops = { |
Elyes HAOUAS | 1d19127 | 2018-11-27 12:23:48 +0100 | [diff] [blame] | 50 | .read_resources = pmc_read_resources, |
| 51 | .set_resources = pci_dev_set_resources, |
| 52 | .enable_resources = pci_dev_enable_resources, |
Nico Huber | 51b75ae | 2019-03-14 16:02:05 +0100 | [diff] [blame] | 53 | .scan_bus = scan_static_bus, |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | static const struct pci_driver pmc __pci_driver = { |
| 57 | .ops = &device_ops, |
| 58 | .vendor = PCI_VENDOR_ID_INTEL, |
| 59 | .device = QUARK_V_LPC_DEVICE_ID_0, |
| 60 | }; |