coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
hudson.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <amdblocks/acpimmio.h>
4 #include <console/console.h>
5 #include <arch/io.h>
6 #include <device/mmio.h>
7 #include <acpi/acpi.h>
8 #include <device/device.h>
9 #include <device/pci.h>
10 #include <device/pci_def.h>
11 #include <device/pci_ids.h>
12 #include <device/pci_ops.h>
13 #include <types.h>
14 
15 #include "hudson.h"
16 #include "smbus.h"
17 #include "smi.h"
18 #include "fchec.h"
19 
21 {
22  u16 tmp = inw(ACPI_PM1_CNT_BLK);
23  tmp = ((tmp & (7 << 10)) >> 10);
24  return (int)tmp;
25 }
26 
27 void hudson_enable(struct device *dev)
28 {
29  printk(BIOS_DEBUG, "%s()\n", __func__);
30  switch (dev->path.pci.devfn) {
31  case PCI_DEVFN(0x14, 7): /* SD */
32  if (dev->enabled == 0) {
33  u32 sd_device_id = pci_read_config16(dev, PCI_DEVICE_ID);
34  /* turn off the SDHC controller in the PM reg */
35  u8 reg8;
36  if (sd_device_id == PCI_DID_AMD_HUDSON_SD) {
38  reg8 &= ~BIT(0);
40  } else if (sd_device_id == PCI_DID_AMD_YANGTZE_SD) {
42  reg8 &= ~BIT(0);
44  }
45  /* remove device 0:14.7 from PCI space */
46  reg8 = pm_read8(PM_MANUAL_RESET);
47  reg8 &= ~BIT(6);
49  }
50  break;
51  default:
52  break;
53  }
54 }
55 
56 static void hudson_init_acpi_ports(void)
57 {
58  /* We use some of these ports in SMM regardless of whether or not
59  * ACPI tables are generated. Enable these ports indiscriminately.
60  */
61 
66  /* CpuControl is in \_PR.CP00, 6 bytes */
68 
69  if (CONFIG(HAVE_SMI_HANDLER)) {
72  } else {
74  }
75 
76  /* AcpiDecodeEnable, When set, SB uses the contents of the PM registers
77  * at index 60-6B to decode ACPI I/O address. AcpiSmiEn & SmiCmdEn
78  */
79  pm_write8(PM_ACPI_CONF, BIT(0) | BIT(1) | BIT(4) | BIT(2));
80 }
81 
82 static void hudson_init(void *chip_info)
83 {
85 }
86 
87 static void hudson_final(void *chip_info)
88 {
89  if (CONFIG(HUDSON_IMC_FWM)) {
91  if (!CONFIG(ACPI_ENABLE_THERMAL_ZONE))
93  }
94 }
95 
97  CHIP_NAME("ATI HUDSON")
98  .enable_dev = hudson_enable,
99  .init = hudson_init,
100  .final = hudson_final
101 };
static uint8_t pm_read8(uint8_t reg)
Definition: acpimmio.h:166
static void pm_write16(uint8_t reg, uint16_t value)
Definition: acpimmio.h:186
static void pm_write8(uint8_t reg, uint8_t value)
Definition: acpimmio.h:181
void hudson_enable(struct device *dev)
Definition: hudson.c:39
#define ACPI_SMI_CTL_PORT
Definition: hudson.h:25
void enable_imc_thermal_zone(void)
Definition: imc.c:43
#define ACPI_CPU_CONTROL
Definition: iomap.h:45
#define ACPI_PM1_CNT_BLK
Definition: iomap.h:43
#define ACPI_PM_TMR_BLK
Definition: iomap.h:44
#define ACPI_GPE0_BLK
Definition: iomap.h:46
#define ACPI_PM_EVT_BLK
Definition: iomap.h:40
#define PM_TMR_BLK
Definition: southbridge.h:40
#define PM_ACPI_CONF
Definition: southbridge.h:43
#define PM_EVT_BLK
Definition: southbridge.h:26
#define PM_GPE0_BLK
Definition: southbridge.h:41
#define PM_ACPI_SMI_CMD
Definition: southbridge.h:42
#define PM1_CNT_BLK
Definition: southbridge.h:39
#define printk(level,...)
Definition: stdlib.h:16
u16 inw(u16 port)
@ CONFIG
Definition: dsi_common.h:201
#define BIT(nr)
Definition: ec_commands.h:45
void agesawrapper_fchecfancontrolservice(void)
#define CHIP_NAME(X)
Definition: device.h:32
static __always_inline u16 pci_read_config16(const struct device *dev, u16 reg)
Definition: pci_ops.h:52
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define PCI_DEVFN(slot, func)
Definition: pci_def.h:548
#define PCI_DEVICE_ID
Definition: pci_def.h:9
#define PCI_DID_AMD_HUDSON_SD
Definition: pci_ids.h:539
#define PCI_DID_AMD_YANGTZE_SD
Definition: pci_ids.h:540
struct chip_operations southbridge_amd_pi_hudson_ops
Definition: hudson.c:96
static void hudson_init_acpi_ports(void)
Definition: hudson.c:56
static void hudson_init(void *chip_info)
Definition: hudson.c:82
int acpi_get_sleep_type(void)
Definition: hudson.c:20
static void hudson_final(void *chip_info)
Definition: hudson.c:87
#define PM_MANUAL_RESET
Definition: hudson.h:33
#define PM_HUD_SD_FLASH_CTRL
Definition: hudson.h:34
#define PM_YANG_SD_FLASH_CTRL
Definition: hudson.h:35
#define PM_CPU_CTRL
Definition: southbridge.h:50
void hudson_enable_acpi_cmd_smi(void)
Enable SMIs on writes to ACPI SMI command port.
Definition: smi_util.c:76
uint32_t u32
Definition: stdint.h:51
uint16_t u16
Definition: stdint.h:48
uint8_t u8
Definition: stdint.h:45
struct pci_path pci
Definition: path.h:116
Definition: device.h:107
struct device_path path
Definition: device.h:115
unsigned int enabled
Definition: device.h:122
unsigned int devfn
Definition: path.h:54