Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2008-2009 coresystems GmbH |
| 5 | * Copyright (C) 2014 Google Inc. |
Lee Leahy | 94b971a | 2017-03-06 08:59:23 -0800 | [diff] [blame] | 6 | * Copyright (C) 2015-2017 Intel Corporation. |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 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 | |
| 18 | #include <device/pci.h> |
| 19 | #include <device/pci_ids.h> |
| 20 | #include <soc/iomap.h> |
| 21 | #include <soc/pci_devs.h> |
| 22 | #include <soc/pm.h> |
| 23 | #include <soc/ramstage.h> |
| 24 | |
Elyes HAOUAS | 696545d | 2018-05-25 13:11:37 +0200 | [diff] [blame^] | 25 | static void pmc_read_resources(struct device *dev) |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 26 | { |
Lee Leahy | 94b971a | 2017-03-06 08:59:23 -0800 | [diff] [blame] | 27 | unsigned int index = 0; |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 28 | struct resource *res; |
| 29 | |
| 30 | /* Get the normal PCI resources of this device. */ |
| 31 | pci_dev_read_resources(dev); |
| 32 | |
Lee Leahy | 7f4b053 | 2016-05-22 11:52:28 -0700 | [diff] [blame] | 33 | /* GPE0 */ |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 34 | res = new_resource(dev, index++); |
Lee Leahy | 7f4b053 | 2016-05-22 11:52:28 -0700 | [diff] [blame] | 35 | res->base = GPE0_BASE_ADDRESS; |
| 36 | res->size = GPE0_SIZE; |
| 37 | res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 38 | |
| 39 | /* PM1BLK */ |
| 40 | res = new_resource(dev, index++); |
| 41 | res->base = PM1BLK_BASE_ADDRESS; |
| 42 | res->size = PM1BLK_SIZE; |
| 43 | res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 44 | |
| 45 | /* Legacy GPIO */ |
| 46 | res = new_resource(dev, index++); |
| 47 | res->base = LEGACY_GPIO_BASE_ADDRESS; |
| 48 | res->size = LEGACY_GPIO_SIZE; |
Lee Leahy | a6de547 | 2016-02-21 16:04:53 -0800 | [diff] [blame] | 49 | res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 50 | } |
| 51 | |
| 52 | static struct device_operations device_ops = { |
| 53 | .read_resources = &pmc_read_resources, |
| 54 | .set_resources = &pci_dev_set_resources, |
| 55 | .enable_resources = &pci_dev_enable_resources, |
| 56 | .scan_bus = &scan_lpc_bus, |
| 57 | }; |
| 58 | |
| 59 | static const struct pci_driver pmc __pci_driver = { |
| 60 | .ops = &device_ops, |
| 61 | .vendor = PCI_VENDOR_ID_INTEL, |
| 62 | .device = QUARK_V_LPC_DEVICE_ID_0, |
| 63 | }; |