blob: a5778e392433e52d03cbffb27f4a31a05d990b10 [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 Chuang60243502021-02-05 17:33:38 +080031 /* Turn off debug mode to enable SCP/OCP */
32 pci_and_config32(dev, CFG3, ~SCP_DEBUG);
33
Ben Chuangff17b312020-09-03 16:02:46 +080034 /* Set Vendor Config to be non-configurable */
35 pci_and_config32(dev, CFG, ~CFG_EN);
36}
37
38static struct device_operations gl9755_ops = {
39 .read_resources = pci_dev_read_resources,
40 .set_resources = pci_dev_set_resources,
41 .enable_resources = pci_dev_enable_resources,
42 .ops_pci = &pci_dev_ops_pci,
Duncan Lauriebd8bb8ea2020-11-17 10:13:05 -080043 .enable = gl9755_enable
Ben Chuangff17b312020-09-03 16:02:46 +080044};
45
46static const unsigned short pci_device_ids[] = {
47 PCI_DEVICE_ID_GLI_9755,
48 0
49};
50
51static const struct pci_driver genesyslogic_gl9755 __pci_driver = {
52 .ops = &gl9755_ops,
53 .vendor = PCI_VENDOR_ID_GLI,
54 .devices = pci_device_ids,
55};
56
57struct chip_operations drivers_generic_genesyslogic_gl9755_ops = {
58 CHIP_NAME("Genesys Logic GL9755")
59};