blob: 92b7249293ac8641d887222e84d0c9f39b6985bf [file] [log] [blame]
Angel Pons230e4f9d2020-04-05 15:47:14 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Lee Leahya6de5472016-02-21 16:04:53 -08002
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 HAOUAS696545d2018-05-25 13:11:37 +020010static void pmc_read_resources(struct device *dev)
Lee Leahya6de5472016-02-21 16:04:53 -080011{
Lee Leahy94b971a2017-03-06 08:59:23 -080012 unsigned int index = 0;
Lee Leahya6de5472016-02-21 16:04:53 -080013 struct resource *res;
14
15 /* Get the normal PCI resources of this device. */
16 pci_dev_read_resources(dev);
17
Lee Leahy7f4b0532016-05-22 11:52:28 -070018 /* GPE0 */
Lee Leahya6de5472016-02-21 16:04:53 -080019 res = new_resource(dev, index++);
Lee Leahy7f4b0532016-05-22 11:52:28 -070020 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 Leahya6de5472016-02-21 16:04:53 -080034 res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
35}
36
37static struct device_operations device_ops = {
Elyes HAOUAS1d191272018-11-27 12:23:48 +010038 .read_resources = pmc_read_resources,
39 .set_resources = pci_dev_set_resources,
40 .enable_resources = pci_dev_enable_resources,
Nico Huber51b75ae2019-03-14 16:02:05 +010041 .scan_bus = scan_static_bus,
Lee Leahya6de5472016-02-21 16:04:53 -080042};
43
44static const struct pci_driver pmc __pci_driver = {
45 .ops = &device_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010046 .vendor = PCI_VID_INTEL,
Lee Leahya6de5472016-02-21 16:04:53 -080047 .device = QUARK_V_LPC_DEVICE_ID_0,
48};