Ben Chuang | ff17b31 | 2020-09-03 16:02:46 +0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | /* Driver for Genesys Logic GL9755 */ |
| 4 | |
| 5 | #include <console/console.h> |
| 6 | #include <device/device.h> |
| 7 | #include <device/path.h> |
| 8 | #include <device/pci.h> |
| 9 | #include <device/pci_ops.h> |
| 10 | #include <device/pci_ids.h> |
| 11 | #include "gl9755.h" |
| 12 | |
Duncan Laurie | bd8bb8ea | 2020-11-17 10:13:05 -0800 | [diff] [blame] | 13 | static void gl9755_enable(struct device *dev) |
Ben Chuang | ff17b31 | 2020-09-03 16:02:46 +0800 | [diff] [blame] | 14 | { |
Duncan Laurie | bd8bb8ea | 2020-11-17 10:13:05 -0800 | [diff] [blame] | 15 | uint32_t reg; |
| 16 | |
| 17 | printk(BIOS_INFO, "GL9755: configure ASPM and LTR\n"); |
Ben Chuang | ff17b31 | 2020-09-03 16:02:46 +0800 | [diff] [blame] | 18 | |
| 19 | /* Set Vendor Config to be configurable */ |
| 20 | pci_or_config32(dev, CFG, CFG_EN); |
Duncan Laurie | bd8bb8ea | 2020-11-17 10:13:05 -0800 | [diff] [blame] | 21 | |
Ben Chuang | ff17b31 | 2020-09-03 16:02:46 +0800 | [diff] [blame] | 22 | /* Set LTR value */ |
| 23 | pci_write_config32(dev, LTR, NO_SNOOP_SCALE|NO_SNOOP_VALUE|SNOOP_SCALE|SNOOP_VALUE); |
Duncan Laurie | bd8bb8ea | 2020-11-17 10:13:05 -0800 | [diff] [blame] | 24 | |
| 25 | /* Adjust L1 exit latency to enable ASPM */ |
| 26 | reg = pci_read_config32(dev, CFG2); |
| 27 | reg &= ~CFG2_LAT_L1_MASK; |
| 28 | reg |= CFG2_LAT_L1_64US; |
| 29 | pci_write_config32(dev, CFG2, reg); |
| 30 | |
Ben Chuang | 325f431 | 2021-09-14 11:31:42 +0800 | [diff] [blame] | 31 | /* Disable ASPM L0s support */ |
| 32 | pci_and_config32(dev, CFG2, ~CFG2_L0S_SUPPORT); |
| 33 | |
Ben Chuang | 6024350 | 2021-02-05 17:33:38 +0800 | [diff] [blame] | 34 | /* Turn off debug mode to enable SCP/OCP */ |
| 35 | pci_and_config32(dev, CFG3, ~SCP_DEBUG); |
| 36 | |
Ben Chuang | ff17b31 | 2020-09-03 16:02:46 +0800 | [diff] [blame] | 37 | /* Set Vendor Config to be non-configurable */ |
| 38 | pci_and_config32(dev, CFG, ~CFG_EN); |
| 39 | } |
| 40 | |
| 41 | static struct device_operations gl9755_ops = { |
| 42 | .read_resources = pci_dev_read_resources, |
| 43 | .set_resources = pci_dev_set_resources, |
| 44 | .enable_resources = pci_dev_enable_resources, |
| 45 | .ops_pci = &pci_dev_ops_pci, |
Duncan Laurie | bd8bb8ea | 2020-11-17 10:13:05 -0800 | [diff] [blame] | 46 | .enable = gl9755_enable |
Ben Chuang | ff17b31 | 2020-09-03 16:02:46 +0800 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | static const unsigned short pci_device_ids[] = { |
| 50 | PCI_DEVICE_ID_GLI_9755, |
| 51 | 0 |
| 52 | }; |
| 53 | |
| 54 | static const struct pci_driver genesyslogic_gl9755 __pci_driver = { |
| 55 | .ops = &gl9755_ops, |
| 56 | .vendor = PCI_VENDOR_ID_GLI, |
| 57 | .devices = pci_device_ids, |
| 58 | }; |
| 59 | |
| 60 | struct chip_operations drivers_generic_genesyslogic_gl9755_ops = { |
| 61 | CHIP_NAME("Genesys Logic GL9755") |
| 62 | }; |