blob: bf4831c504ff01eb115ee41d3e37e721b2079efd [file] [log] [blame]
Ben Chuangff17b312020-09-03 16:02:46 +08001/* 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 Lauriebd8bb8ea2020-11-17 10:13:05 -080013static void gl9755_enable(struct device *dev)
Ben Chuangff17b312020-09-03 16:02:46 +080014{
Duncan Lauriebd8bb8ea2020-11-17 10:13:05 -080015 uint32_t reg;
16
17 printk(BIOS_INFO, "GL9755: configure ASPM and LTR\n");
Ben Chuangff17b312020-09-03 16:02:46 +080018
19 /* Set Vendor Config to be configurable */
20 pci_or_config32(dev, CFG, CFG_EN);
Duncan Lauriebd8bb8ea2020-11-17 10:13:05 -080021
Ben Chuangff17b312020-09-03 16:02:46 +080022 /* Set LTR value */
23 pci_write_config32(dev, LTR, NO_SNOOP_SCALE|NO_SNOOP_VALUE|SNOOP_SCALE|SNOOP_VALUE);
Duncan Lauriebd8bb8ea2020-11-17 10:13:05 -080024
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 Chuang325f4312021-09-14 11:31:42 +080031 /* Disable ASPM L0s support */
32 pci_and_config32(dev, CFG2, ~CFG2_L0S_SUPPORT);
33
Ben Chuang60243502021-02-05 17:33:38 +080034 /* Turn off debug mode to enable SCP/OCP */
35 pci_and_config32(dev, CFG3, ~SCP_DEBUG);
36
Ben Chuangff17b312020-09-03 16:02:46 +080037 /* Set Vendor Config to be non-configurable */
38 pci_and_config32(dev, CFG, ~CFG_EN);
39}
40
41static 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 Lauriebd8bb8ea2020-11-17 10:13:05 -080046 .enable = gl9755_enable
Ben Chuangff17b312020-09-03 16:02:46 +080047};
48
49static const unsigned short pci_device_ids[] = {
Felix Singer43b7f412022-03-07 04:34:52 +010050 PCI_DID_GLI_9755,
Ben Chuangff17b312020-09-03 16:02:46 +080051 0
52};
53
54static const struct pci_driver genesyslogic_gl9755 __pci_driver = {
55 .ops = &gl9755_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010056 .vendor = PCI_VID_GLI,
Ben Chuangff17b312020-09-03 16:02:46 +080057 .devices = pci_device_ids,
58};
59
60struct chip_operations drivers_generic_genesyslogic_gl9755_ops = {
61 CHIP_NAME("Genesys Logic GL9755")
62};