V Sowmya | c333b98 | 2017-11-27 11:31:14 +0530 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2017 Intel Corp. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | */ |
| 16 | |
| 17 | #include <device/device.h> |
| 18 | #include <device/pci.h> |
| 19 | #include <device/pci_ids.h> |
| 20 | #include <intelblocks/sram.h> |
| 21 | #include <soc/iomap.h> |
| 22 | |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 23 | __weak void soc_sram_init(struct device *dev) { /* no-op */ } |
V Sowmya | c333b98 | 2017-11-27 11:31:14 +0530 | [diff] [blame] | 24 | |
| 25 | static void sram_read_resources(struct device *dev) |
| 26 | { |
| 27 | struct resource *res; |
| 28 | pci_dev_read_resources(dev); |
| 29 | |
| 30 | res = new_resource(dev, PCI_BASE_ADDRESS_0); |
| 31 | res->base = SRAM_BASE_0; |
| 32 | res->size = SRAM_SIZE_0; |
| 33 | res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 34 | |
| 35 | res = new_resource(dev, PCI_BASE_ADDRESS_2); |
| 36 | res->base = SRAM_BASE_2; |
| 37 | res->size = SRAM_SIZE_2; |
| 38 | res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 39 | } |
| 40 | |
| 41 | static const struct device_operations device_ops = { |
| 42 | .read_resources = sram_read_resources, |
| 43 | .set_resources = pci_dev_set_resources, |
| 44 | .enable_resources = pci_dev_enable_resources, |
| 45 | .init = soc_sram_init, |
Subrata Banik | 6bbc91a | 2017-12-07 14:55:51 +0530 | [diff] [blame] | 46 | .ops_pci = &pci_dev_ops_pci, |
V Sowmya | c333b98 | 2017-11-27 11:31:14 +0530 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | static const unsigned short pci_device_ids[] = { |
| 50 | PCI_DEVICE_ID_INTEL_APL_SRAM, |
| 51 | PCI_DEVICE_ID_INTEL_GLK_SRAM, |
Aamir Bohra | 9eac039 | 2018-06-30 12:07:04 +0530 | [diff] [blame^] | 52 | PCI_DEVICE_ID_INTEL_ICL_SRAM, |
V Sowmya | c333b98 | 2017-11-27 11:31:14 +0530 | [diff] [blame] | 53 | 0, |
| 54 | }; |
| 55 | |
| 56 | static const struct pci_driver sram __pci_driver = { |
| 57 | .ops = &device_ops, |
| 58 | .vendor = PCI_VENDOR_ID_INTEL, |
| 59 | .devices = pci_device_ids, |
| 60 | }; |