Patrick Georgi | 02363b5 | 2020-05-05 20:48:50 +0200 | [diff] [blame] | 1 | /* This file is part of the coreboot project. */ |
Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame^] | 2 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
V Sowmya | c333b98 | 2017-11-27 11:31:14 +0530 | [diff] [blame] | 3 | |
| 4 | #include <device/device.h> |
| 5 | #include <device/pci.h> |
| 6 | #include <device/pci_ids.h> |
| 7 | #include <intelblocks/sram.h> |
| 8 | #include <soc/iomap.h> |
| 9 | |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 10 | __weak void soc_sram_init(struct device *dev) { /* no-op */ } |
V Sowmya | c333b98 | 2017-11-27 11:31:14 +0530 | [diff] [blame] | 11 | |
| 12 | static void sram_read_resources(struct device *dev) |
| 13 | { |
| 14 | struct resource *res; |
| 15 | pci_dev_read_resources(dev); |
| 16 | |
| 17 | res = new_resource(dev, PCI_BASE_ADDRESS_0); |
| 18 | res->base = SRAM_BASE_0; |
| 19 | res->size = SRAM_SIZE_0; |
| 20 | res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 21 | |
| 22 | res = new_resource(dev, PCI_BASE_ADDRESS_2); |
| 23 | res->base = SRAM_BASE_2; |
| 24 | res->size = SRAM_SIZE_2; |
| 25 | res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 26 | } |
| 27 | |
| 28 | static const struct device_operations device_ops = { |
| 29 | .read_resources = sram_read_resources, |
| 30 | .set_resources = pci_dev_set_resources, |
| 31 | .enable_resources = pci_dev_enable_resources, |
| 32 | .init = soc_sram_init, |
Subrata Banik | 6bbc91a | 2017-12-07 14:55:51 +0530 | [diff] [blame] | 33 | .ops_pci = &pci_dev_ops_pci, |
V Sowmya | c333b98 | 2017-11-27 11:31:14 +0530 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | static const unsigned short pci_device_ids[] = { |
| 37 | PCI_DEVICE_ID_INTEL_APL_SRAM, |
| 38 | PCI_DEVICE_ID_INTEL_GLK_SRAM, |
Aamir Bohra | 9eac039 | 2018-06-30 12:07:04 +0530 | [diff] [blame] | 39 | PCI_DEVICE_ID_INTEL_ICL_SRAM, |
Ronak Kanabar | da7ffb48 | 2019-02-05 01:51:13 +0530 | [diff] [blame] | 40 | PCI_DEVICE_ID_INTEL_CMP_SRAM, |
Gaggery Tsai | 12a651c | 2019-12-05 11:23:20 -0800 | [diff] [blame] | 41 | PCI_DEVICE_ID_INTEL_CMP_H_SRAM, |
Ravi Sarawadi | 6b5bf40 | 2019-10-21 22:25:04 -0700 | [diff] [blame] | 42 | PCI_DEVICE_ID_INTEL_TGL_SRAM, |
Tan, Lean Sheng | 2613609 | 2020-01-20 19:13:56 -0800 | [diff] [blame] | 43 | PCI_DEVICE_ID_INTEL_MCC_SRAM, |
Meera Ravindranath | 3f4af0d | 2020-02-12 16:01:22 +0530 | [diff] [blame] | 44 | PCI_DEVICE_ID_INTEL_JSP_SRAM, |
V Sowmya | c333b98 | 2017-11-27 11:31:14 +0530 | [diff] [blame] | 45 | 0, |
| 46 | }; |
| 47 | |
| 48 | static const struct pci_driver sram __pci_driver = { |
| 49 | .ops = &device_ops, |
| 50 | .vendor = PCI_VENDOR_ID_INTEL, |
| 51 | .devices = pci_device_ids, |
| 52 | }; |