util/sconfig: Remove unused ioapic and irq keywords
[coreboot.git] / src / southbridge / intel / i82371eb / smbus.c
blob7c1ce1bc37808fe8c732586358a4efb5f4e4bfce
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #include <arch/io.h>
4 #include <device/pci_ops.h>
5 #include <console/console.h>
6 #include <stdint.h>
7 #include <device/device.h>
8 #include <device/pci.h>
9 #include <device/pci_ids.h>
10 #include <device/smbus.h>
11 #include "chip.h"
12 #include "i82371eb.h"
14 static void pwrmgt_enable(struct device *dev)
16 struct southbridge_intel_i82371eb_config *sb = dev->chip_info;
17 u32 reg, gpo = sb->gpo;
19 /* Sets the base address of power management ports. */
20 pci_write_config16(dev, PMBA, DEFAULT_PMBASE | 1);
22 /* Set Power Management IO Space Enable bit */
23 u8 val = pci_read_config8(dev, PMREGMISC);
24 pci_write_config8(dev, PMREGMISC, val | 1);
26 /* set global control:
27 * bit25 (lid_pol): 1=invert lid polarity
28 * bit24 (sm_freeze): 1=freeze idle and standby timers
29 * bit16 (end of smi): 0=disable smi assertion (cleared by hw)
30 * bits8-15,26: global standby timer initial count 127 * 4minutes
31 * bit2 (thrm_pol): 1=active low THRM#
32 * bit0 (smi_en): 1=disable smi generation upon smi event
34 reg = (sb->lid_polarity<<25)|
35 (1<<24)|
36 (0xff<<8)|
37 (sb->thrm_polarity<<2);
38 outl(reg, DEFAULT_PMBASE + GLBCTL);
40 /* set processor control:
41 * bit12 (stpclk_en): 1=enable stopping of host clk on lvl3
42 * bit11 (sleep_en): 1=enable slp# assertion on lvl3
43 * bit9 (cc_en): 1=enable clk control with lvl2 and lvl3 regs
45 outl(0, DEFAULT_PMBASE + PCNTRL);
47 /* disable smi event enables */
48 outw(0, DEFAULT_PMBASE + GLBEN);
49 outl(0, DEFAULT_PMBASE + DEVCTL);
51 /* set default gpo value.
52 * power-on default is 0x7fffbfffh */
53 if (gpo) {
54 /* only 8bit access allowed */
55 outb(gpo & 0xff, DEFAULT_PMBASE + GPO0);
56 outb((gpo >> 8) & 0xff, DEFAULT_PMBASE + GPO1);
57 outb((gpo >> 16) & 0xff, DEFAULT_PMBASE + GPO2);
58 outb((gpo >> 24) & 0xff, DEFAULT_PMBASE + GPO3);
59 } else {
60 printk(BIOS_SPEW,
61 "%s: gpo default missing in devicetree.cb!\n", __func__);
64 /* Clear status events. */
65 outw(0xffff, DEFAULT_PMBASE + PMSTS);
66 outw(0xffff, DEFAULT_PMBASE + GPSTS);
67 outw(0xffff, DEFAULT_PMBASE + GLBSTS);
68 outl(0xffffffff, DEFAULT_PMBASE + DEVSTS);
70 /* set PMCNTRL default */
71 outw(SUS_TYP_S0|SCI_EN, DEFAULT_PMBASE + PMCNTRL);
74 static void pwrmgt_read_resources(struct device *dev)
76 struct resource *res;
78 pci_dev_read_resources(dev);
80 res = new_resource(dev, 1);
81 res->base = DEFAULT_PMBASE;
82 res->size = 0x0040;
83 res->limit = 0xffff;
84 res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED |
85 IORESOURCE_RESERVE;
87 res = new_resource(dev, 2);
88 res->base = SMBUS_IO_BASE;
89 res->size = 0x0010;
90 res->limit = 0xffff;
91 res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED |
92 IORESOURCE_RESERVE;
95 static const struct smbus_bus_operations lops_smbus_bus = {
98 static const struct device_operations smbus_ops = {
99 .read_resources = pwrmgt_read_resources,
100 .set_resources = pci_dev_set_resources,
101 .enable_resources = pci_dev_enable_resources,
102 .scan_bus = scan_smbus,
103 .enable = pwrmgt_enable,
104 .ops_pci = 0, /* No subsystem IDs on 82371EB! */
105 .ops_smbus_bus = &lops_smbus_bus,
108 /* Note: There's no SMBus on 82371FB/SB/MX and 82437MX. */
110 /* Intel 82371AB/EB/MB */
111 static const struct pci_driver smbus_driver __pci_driver = {
112 .ops = &smbus_ops,
113 .vendor = PCI_VID_INTEL,
114 .device = PCI_DID_INTEL_82371AB_SMB_ACPI,