blob: 1e1cfe0537db2cc4acf8a88f00aace0f04812953 [file] [log] [blame]
Frank Vibrans63e62b02011-02-14 18:38:14 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011 Advanced Micro Devices, Inc.
Mike Loptienc93a75a2014-06-06 15:16:29 -06005 * Copyright (C) 2014 Sage Electronic Engineering, LLC.
Frank Vibrans63e62b02011-02-14 18:38:14 +00006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Frank Vibrans63e62b02011-02-14 18:38:14 +000015 */
16
17
Kyösti Mälkki13f66502019-03-03 08:01:05 +020018#include <device/mmio.h>
Elyes HAOUAS1a4abb72018-05-19 16:49:20 +020019#include <device/device.h>
Frank Vibrans63e62b02011-02-14 18:38:14 +000020#include <device/pci.h> /* device_operations */
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020021#include <device/pci_ops.h>
Frank Vibrans63e62b02011-02-14 18:38:14 +000022#include <device/pci_ids.h>
Mike Loptienc93a75a2014-06-06 15:16:29 -060023#include <bootstate.h>
Kerry She991f8802011-06-01 01:56:49 +000024#include <arch/ioapic.h>
Frank Vibrans63e62b02011-02-14 18:38:14 +000025#include <device/smbus.h> /* smbus_bus_operations */
zbao366f0fc2012-08-03 16:58:53 +080026#include <pc80/mc146818rtc.h>
Edward O'Callaghane61dd0f2014-05-06 23:53:09 +100027#include <pc80/i8254.h>
28#include <pc80/i8259.h>
Frank Vibrans63e62b02011-02-14 18:38:14 +000029#include <console/console.h> /* printk */
zbao9bcdbf82012-04-05 13:18:49 +080030#include <arch/acpi.h>
Kyösti Mälkkie2227a22014-02-05 13:02:55 +020031#include <device/pci_ehci.h>
Frank Vibrans63e62b02011-02-14 18:38:14 +000032#include "lpc.h" /* lpc_read_resources */
Elyes HAOUASb0f19882018-06-09 11:59:00 +020033#include "SBPLATFORM.h" /* Platform Specific Definitions */
Frank Vibrans63e62b02011-02-14 18:38:14 +000034#include "cfg.h" /* sb800 Cimx configuration */
efdesign9805a89ab2011-06-20 17:38:49 -070035#include "chip.h" /* struct southbridge_amd_cimx_sb800_config */
Kerry Shefeed3292011-08-18 18:03:44 +080036#include "sb_cimx.h" /* AMD CIMX wrapper entries */
Dave Frodin23023a52012-11-13 07:09:12 -070037#include "smbus.h"
Martin Rothe899e512012-12-05 16:07:11 -070038#include "fan.h"
Tobias Diedrichd8a2c1f2017-02-20 02:46:19 +010039#include "pci_devs.h"
Stefan Reinauer13e41822015-04-27 14:02:36 -070040#include <southbridge/amd/common/amd_pci_util.h>
Frank Vibrans63e62b02011-02-14 18:38:14 +000041
Frank Vibrans63e62b02011-02-14 18:38:14 +000042static AMDSBCFG sb_late_cfg; //global, init in sb800_cimx_config
43static AMDSBCFG *sb_config = &sb_late_cfg;
44
Frank Vibrans63e62b02011-02-14 18:38:14 +000045/**
46 * @brief Entry point of Southbridge CIMx callout
47 *
48 * prototype UINT32 (*SBCIM_HOOK_ENTRY)(UINT32 Param1, UINT32 Param2, void* pConfig)
49 *
50 * @param[in] func Southbridge CIMx Function ID.
51 * @param[in] data Southbridge Input Data.
Martin Roth6355cbf2015-01-04 15:22:26 -070052 * @param[in] config Southbridge configuration structure pointer.
Frank Vibrans63e62b02011-02-14 18:38:14 +000053 *
54 */
Elyes HAOUAS251279c2018-07-08 12:41:56 +020055static u32 sb800_callout_entry(u32 func, u32 data, void *config)
Frank Vibrans63e62b02011-02-14 18:38:14 +000056{
57 u32 ret = 0;
Kerry Shefeed3292011-08-18 18:03:44 +080058 printk(BIOS_DEBUG, "SB800 - Late.c - %s - Start.\n", __func__);
Frank Vibrans63e62b02011-02-14 18:38:14 +000059 switch (func) {
60 case CB_SBGPP_RESET_ASSERT:
Frank Vibrans63e62b02011-02-14 18:38:14 +000061 break;
62
63 case CB_SBGPP_RESET_DEASSERT:
Frank Vibrans63e62b02011-02-14 18:38:14 +000064 break;
65
66 case IMC_FIRMWARE_FAIL:
67 break;
68
69 default:
70 break;
71 }
72
Kerry Shefeed3292011-08-18 18:03:44 +080073 printk(BIOS_DEBUG, "SB800 - Late.c - %s - End.\n", __func__);
Frank Vibrans63e62b02011-02-14 18:38:14 +000074 return ret;
75}
76
Kerry Sheh0e6344e2011-10-12 11:42:59 +080077#define HOST_CAP 0x00 /* host capabilities */
78#define HOST_CTL 0x04 /* global host control */
79#define HOST_IRQ_STAT 0x08 /* interrupt status */
80#define HOST_PORTS_IMPL 0x0c /* bitmap of implemented ports */
81
82#define HOST_CTL_AHCI_EN (1 << 31) /* AHCI enabled */
83static void ahci_raid_init(struct device *dev)
84{
85 u8 irq = 0;
Stefan Reinauer12bce3f2015-06-18 01:17:38 -070086 void *bar5;
87 u32 caps, ports, val;
Kerry Sheh0e6344e2011-10-12 11:42:59 +080088
89 val = pci_read_config16(dev, PCI_CLASS_DEVICE);
90 if (val == PCI_CLASS_STORAGE_SATA) {
91 printk(BIOS_DEBUG, "AHCI controller ");
92 } else if (val == PCI_CLASS_STORAGE_RAID) {
93 printk(BIOS_DEBUG, "RAID controller ");
94 } else {
95 printk(BIOS_WARNING, "device class:%x, neither in ahci or raid mode\n", val);
96 return;
97 }
98
99 irq = pci_read_config8(dev, PCI_INTERRUPT_LINE);
Stefan Reinauer12bce3f2015-06-18 01:17:38 -0700100 bar5 = (void *)(uintptr_t)pci_read_config32(dev, PCI_BASE_ADDRESS_5);
101 printk(BIOS_DEBUG, "IOMEM base: %p, IRQ: 0x%X\n", bar5, irq);
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800102
Stefan Reinauer12bce3f2015-06-18 01:17:38 -0700103 caps = read32(bar5 + HOST_CAP);
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800104 caps = (caps & 0x1F) + 1;
Stefan Reinauer12bce3f2015-06-18 01:17:38 -0700105 ports= read32(bar5 + HOST_PORTS_IMPL);
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800106 printk(BIOS_DEBUG, "Number of Ports: 0x%x, Port implemented(bit map): 0x%x\n", caps, ports);
107
108 /* make sure ahci is enabled */
Stefan Reinauer12bce3f2015-06-18 01:17:38 -0700109 val = read32(bar5 + HOST_CTL);
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800110 if (!(val & HOST_CTL_AHCI_EN)) {
Stefan Reinauer12bce3f2015-06-18 01:17:38 -0700111 write32(bar5 + HOST_CTL, val | HOST_CTL_AHCI_EN);
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800112 }
113
114 dev->command |= PCI_COMMAND_MASTER;
115 pci_write_config8(dev, PCI_COMMAND, dev->command);
116 printk(BIOS_DEBUG, "AHCI/RAID controller initialized\n");
117}
Frank Vibrans63e62b02011-02-14 18:38:14 +0000118
119static struct pci_operations lops_pci = {
Kerry Shefeed3292011-08-18 18:03:44 +0800120 .set_subsystem = pci_dev_set_subsystem,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000121};
122
Elyes HAOUAS1a4abb72018-05-19 16:49:20 +0200123static void lpc_init(struct device *dev)
zbao366f0fc2012-08-03 16:58:53 +0800124{
125 printk(BIOS_DEBUG, "SB800 - Late.c - lpc_init - Start.\n");
126
Gabe Black03abaee212014-04-30 21:31:44 -0700127 cmos_check_update_date();
zbao366f0fc2012-08-03 16:58:53 +0800128
Mike Loptienac529b12013-02-22 13:18:31 -0700129 /* Initialize the real time clock.
Gabe Blackb3f08c62014-04-30 17:12:25 -0700130 * The 0 argument tells cmos_init not to
Mike Loptienac529b12013-02-22 13:18:31 -0700131 * update CMOS unless it is invalid.
Gabe Blackb3f08c62014-04-30 17:12:25 -0700132 * 1 tells cmos_init to always initialize the CMOS.
Mike Loptienac529b12013-02-22 13:18:31 -0700133 */
Gabe Blackb3f08c62014-04-30 17:12:25 -0700134 cmos_init(0);
Mike Loptienac529b12013-02-22 13:18:31 -0700135
Edward O'Callaghane61dd0f2014-05-06 23:53:09 +1000136 setup_i8259(); /* Initialize i8259 pic */
137 setup_i8254(); /* Initialize i8254 timers */
138
zbao366f0fc2012-08-03 16:58:53 +0800139 printk(BIOS_DEBUG, "SB800 - Late.c - lpc_init - End.\n");
140}
141
Vladimir Serbinenko2a19fb12014-10-02 20:09:19 +0200142unsigned long acpi_fill_mcfg(unsigned long current)
143{
144 /* Just a dummy */
145 return current;
146}
147
Aaron Durbinaa090cb2017-09-13 16:01:52 -0600148static const char *lpc_acpi_name(const struct device *dev)
Tobias Diedrichd8a2c1f2017-02-20 02:46:19 +0100149{
150 if (dev->path.type != DEVICE_PATH_PCI)
151 return NULL;
152
153 switch (dev->path.pci.devfn) {
154 /* DSDT: acpi/lpc.asl */
155 case LPC_DEVFN:
156 return "LIBR";
157 }
158
159 return NULL;
160}
161
Frank Vibrans63e62b02011-02-14 18:38:14 +0000162static struct device_operations lpc_ops = {
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200163 .read_resources = lpc_read_resources,
164 .set_resources = lpc_set_resources,
165 .enable_resources = pci_dev_enable_resources,
Julius Wernercd49cce2019-03-05 16:53:33 -0800166#if CONFIG(HAVE_ACPI_TABLES)
Vladimir Serbinenko2a19fb12014-10-02 20:09:19 +0200167 .write_acpi_tables = acpi_write_hpet,
168#endif
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200169 .init = lpc_init,
170 .scan_bus = scan_lpc_bus,
171 .ops_pci = &lops_pci,
Tobias Diedrichd8a2c1f2017-02-20 02:46:19 +0100172 .acpi_name = lpc_acpi_name,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000173};
174
175static const struct pci_driver lpc_driver __pci_driver = {
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200176 .ops = &lpc_ops,
177 .vendor = PCI_VENDOR_ID_ATI,
178 .device = PCI_DEVICE_ID_ATI_SB800_LPC,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000179};
180
Frank Vibrans63e62b02011-02-14 18:38:14 +0000181static struct device_operations sata_ops = {
182 .read_resources = pci_dev_read_resources,
183 .set_resources = pci_dev_set_resources,
Kerry Shefeed3292011-08-18 18:03:44 +0800184 .enable_resources = pci_dev_enable_resources,
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800185 .init = ahci_raid_init,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000186 .scan_bus = 0,
187 .ops_pci = &lops_pci,
188};
189
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800190static const struct pci_driver ahci_driver __pci_driver = {
Frank Vibrans63e62b02011-02-14 18:38:14 +0000191 .ops = &sata_ops,
192 .vendor = PCI_VENDOR_ID_ATI,
Scott Duplichanf191c722011-05-15 21:38:08 +0000193 .device = PCI_DEVICE_ID_ATI_SB800_SATA_AHCI,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000194};
195
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800196static const struct pci_driver raid_driver __pci_driver = {
197 .ops = &sata_ops,
198 .vendor = PCI_VENDOR_ID_ATI,
199 .device = PCI_DEVICE_ID_ATI_SB800_SATA_RAID,
200};
201static const struct pci_driver raid5_driver __pci_driver = {
202 .ops = &sata_ops,
203 .vendor = PCI_VENDOR_ID_ATI,
204 .device = PCI_DEVICE_ID_ATI_SB800_SATA_RAID5,
205};
206
Frank Vibrans63e62b02011-02-14 18:38:14 +0000207static struct device_operations usb_ops = {
Kyösti Mälkkifb387df2013-06-07 22:16:52 +0300208 .read_resources = pci_ehci_read_resources,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000209 .set_resources = pci_dev_set_resources,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000210 .enable_resources = pci_dev_enable_resources,
Kerry Shefeed3292011-08-18 18:03:44 +0800211 .init = 0,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000212 .scan_bus = 0,
213 .ops_pci = &lops_pci,
214};
215
216/*
217 * The pci id of usb ctrl 0 and 1 are the same.
218 */
219static const struct pci_driver usb_ohci123_driver __pci_driver = {
220 .ops = &usb_ops,
221 .vendor = PCI_VENDOR_ID_ATI,
222 .device = PCI_DEVICE_ID_ATI_SB800_USB_18_0, /* OHCI-USB1, OHCI-USB2, OHCI-USB3 */
223};
224
225static const struct pci_driver usb_ehci123_driver __pci_driver = {
226 .ops = &usb_ops,
227 .vendor = PCI_VENDOR_ID_ATI,
228 .device = PCI_DEVICE_ID_ATI_SB800_USB_18_2, /* EHCI-USB1, EHCI-USB2, EHCI-USB3 */
229};
230
231static const struct pci_driver usb_ohci4_driver __pci_driver = {
232 .ops = &usb_ops,
233 .vendor = PCI_VENDOR_ID_ATI,
234 .device = PCI_DEVICE_ID_ATI_SB800_USB_20_5, /* OHCI-USB4 */
235};
236
237
Frank Vibrans63e62b02011-02-14 18:38:14 +0000238static struct device_operations azalia_ops = {
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200239 .read_resources = pci_dev_read_resources,
240 .set_resources = pci_dev_set_resources,
241 .enable_resources = pci_dev_enable_resources,
242 .init = 0,
243 .scan_bus = 0,
244 .ops_pci = &lops_pci,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000245};
246
247static const struct pci_driver azalia_driver __pci_driver = {
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200248 .ops = &azalia_ops,
249 .vendor = PCI_VENDOR_ID_ATI,
250 .device = PCI_DEVICE_ID_ATI_SB800_HDA,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000251};
252
253
Frank Vibrans63e62b02011-02-14 18:38:14 +0000254static struct device_operations gec_ops = {
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200255 .read_resources = pci_dev_read_resources,
256 .set_resources = pci_dev_set_resources,
257 .enable_resources = pci_dev_enable_resources,
258 .init = 0,
259 .scan_bus = 0,
260 .ops_pci = &lops_pci,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000261};
262
263static const struct pci_driver gec_driver __pci_driver = {
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200264 .ops = &gec_ops,
265 .vendor = PCI_VENDOR_ID_ATI,
266 .device = PCI_DEVICE_ID_ATI_SB800_GEC,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000267};
268
Kerry She3e706b62011-06-24 22:52:15 +0800269/**
Kyösti Mälkki41cd0472015-02-07 11:20:54 +0200270 * Fill build time defaults.
271 */
272static void sb800_init(void *chip_info)
273{
Kyösti Mälkki1498efe2017-03-09 16:25:24 +0200274 printk(BIOS_DEBUG, "SB800: %s\n", __func__);
Kyösti Mälkki41cd0472015-02-07 11:20:54 +0200275 sb_config->StdHeader.CALLBACK.CalloutPtr = sb800_callout_entry;
276 sb800_cimx_config(sb_config);
Kyösti Mälkki24501ca2015-02-07 17:38:45 +0200277
Paul Menzel114a9482015-10-25 22:27:42 +0100278 /* Initially enable all GPP ports 0 to 3 */
Kyösti Mälkki24501ca2015-02-07 17:38:45 +0200279 abcfg_reg(0xc0, 0x01FF, 0x0F4);
Kyösti Mälkki41cd0472015-02-07 11:20:54 +0200280}
281
282/**
Kerry Shefeed3292011-08-18 18:03:44 +0800283 * South Bridge CIMx ramstage entry point wrapper.
284 */
285void sb_Before_Pci_Init(void)
286{
Kyösti Mälkki1498efe2017-03-09 16:25:24 +0200287 printk(BIOS_DEBUG, "SB800: %s\n", __func__);
Kerry Shefeed3292011-08-18 18:03:44 +0800288 sb_config->StdHeader.Func = SB_BEFORE_PCI_INIT;
289 AmdSbDispatcher(sb_config);
290}
291
292void sb_After_Pci_Init(void)
293{
Kyösti Mälkki1498efe2017-03-09 16:25:24 +0200294 printk(BIOS_DEBUG, "SB800: %s\n", __func__);
Kerry Shefeed3292011-08-18 18:03:44 +0800295 sb_config->StdHeader.Func = SB_AFTER_PCI_INIT;
296 AmdSbDispatcher(sb_config);
297}
298
299void sb_Mid_Post_Init(void)
300{
Kyösti Mälkki1498efe2017-03-09 16:25:24 +0200301 printk(BIOS_DEBUG, "SB800: %s\n", __func__);
Kerry Shefeed3292011-08-18 18:03:44 +0800302 sb_config->StdHeader.Func = SB_MID_POST_INIT;
303 AmdSbDispatcher(sb_config);
304}
305
306void sb_Late_Post(void)
307{
Kyösti Mälkki1498efe2017-03-09 16:25:24 +0200308 printk(BIOS_DEBUG, "SB800: %s\n", __func__);
Kerry Shefeed3292011-08-18 18:03:44 +0800309 sb_config->StdHeader.Func = SB_LATE_POST_INIT;
310 AmdSbDispatcher(sb_config);
311}
312
zbao9bcdbf82012-04-05 13:18:49 +0800313void sb_Before_Pci_Restore_Init(void)
314{
Kyösti Mälkki1498efe2017-03-09 16:25:24 +0200315 printk(BIOS_DEBUG, "SB800: %s\n", __func__);
zbao9bcdbf82012-04-05 13:18:49 +0800316 sb_config->StdHeader.Func = SB_BEFORE_PCI_RESTORE_INIT;
317 AmdSbDispatcher(sb_config);
318}
319
320void sb_After_Pci_Restore_Init(void)
321{
Kyösti Mälkki1498efe2017-03-09 16:25:24 +0200322 printk(BIOS_DEBUG, "SB800: %s\n", __func__);
zbao9bcdbf82012-04-05 13:18:49 +0800323 sb_config->StdHeader.Func = SB_AFTER_PCI_RESTORE_INIT;
324 AmdSbDispatcher(sb_config);
325}
Kerry Shefeed3292011-08-18 18:03:44 +0800326
Mike Loptienc93a75a2014-06-06 15:16:29 -0600327/*
328 * Update the PCI devices with a valid IRQ number
329 * that is set in the mainboard PCI_IRQ structures.
330 */
331static void set_pci_irqs(void *unused)
332{
333 /* Write PCI_INTR regs 0xC00/0xC01 */
334 write_pci_int_table();
335
336 /* Write IRQs for all devicetree enabled devices */
337 write_pci_cfg_irqs();
338}
339
340/*
341 * Hook this function into the PCI state machine
342 * on entry into BS_DEV_ENABLE.
343 */
Aaron Durbin9ef9d852015-03-16 17:30:09 -0500344BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, set_pci_irqs, NULL);
Mike Loptienc93a75a2014-06-06 15:16:29 -0600345
Kerry Shefeed3292011-08-18 18:03:44 +0800346/**
Frank Vibrans63e62b02011-02-14 18:38:14 +0000347 * @brief SB Cimx entry point sbBeforePciInit wrapper
348 */
Elyes HAOUAS1a4abb72018-05-19 16:49:20 +0200349static void sb800_enable(struct device *dev)
Frank Vibrans63e62b02011-02-14 18:38:14 +0000350{
efdesign9805a89ab2011-06-20 17:38:49 -0700351 struct southbridge_amd_cimx_sb800_config *sb_chip =
352 (struct southbridge_amd_cimx_sb800_config *)(dev->chip_info);
Frank Vibrans63e62b02011-02-14 18:38:14 +0000353
Frank Vibrans63e62b02011-02-14 18:38:14 +0000354 switch (dev->path.pci.devfn) {
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300355 case PCI_DEVFN(0x11, 0): /* 0:11.0 SATA */
Frank Vibrans63e62b02011-02-14 18:38:14 +0000356 if (dev->enabled) {
Elyes HAOUASb0f19882018-06-09 11:59:00 +0200357 sb_config->SATAMODE.SataMode.SataController = CIMX_OPTION_ENABLED;
Elyes HAOUAS0f8b8d92019-01-03 10:23:28 +0100358 if (sb_chip->boot_switch_sata_ide == 1)
Frank Vibrans63e62b02011-02-14 18:38:14 +0000359 sb_config->SATAMODE.SataMode.SataIdeCombMdPriSecOpt = 0; //0 -IDE as primary.
Elyes HAOUAS0f8b8d92019-01-03 10:23:28 +0100360 else if (sb_chip->boot_switch_sata_ide == 0)
Frank Vibrans63e62b02011-02-14 18:38:14 +0000361 sb_config->SATAMODE.SataMode.SataIdeCombMdPriSecOpt = 1; //1 -IDE as secondary.
362 } else {
Elyes HAOUASb0f19882018-06-09 11:59:00 +0200363 sb_config->SATAMODE.SataMode.SataController = CIMX_OPTION_DISABLED;
Frank Vibrans63e62b02011-02-14 18:38:14 +0000364 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000365 break;
366
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300367 case PCI_DEVFN(0x14, 0): /* 0:14:0 SMBUS */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800368 clear_ioapic(VIO_APIC_VADDR);
Kyösti Mälkki35546de2014-04-17 15:07:32 +0300369 /* Assign the ioapic ID the next available number after the processor core local APIC IDs */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800370 setup_ioapic(VIO_APIC_VADDR, CONFIG_MAX_CPUS);
Frank Vibrans63e62b02011-02-14 18:38:14 +0000371 break;
372
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300373 case PCI_DEVFN(0x14, 1): /* 0:14:1 IDE */
Frank Vibrans63e62b02011-02-14 18:38:14 +0000374 break;
375
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300376 case PCI_DEVFN(0x14, 2): /* 0:14:2 HDA */
Frank Vibrans63e62b02011-02-14 18:38:14 +0000377 if (dev->enabled) {
Elyes HAOUAS0f8b8d92019-01-03 10:23:28 +0100378 if (sb_config->AzaliaController == AZALIA_DISABLE) {
Elyes HAOUASb0f19882018-06-09 11:59:00 +0200379 sb_config->AzaliaController = AZALIA_AUTO;
Frank Vibrans63e62b02011-02-14 18:38:14 +0000380 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000381 } else {
Elyes HAOUASb0f19882018-06-09 11:59:00 +0200382 sb_config->AzaliaController = AZALIA_DISABLE;
Frank Vibrans63e62b02011-02-14 18:38:14 +0000383 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000384 break;
385
386
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300387 case PCI_DEVFN(0x14, 3): /* 0:14:3 LPC */
Martin Rothe899e512012-12-05 16:07:11 -0700388 /* Initialize the fans */
Julius Wernercd49cce2019-03-05 16:53:33 -0800389#if CONFIG(SB800_IMC_FAN_CONTROL)
Martin Rothe899e512012-12-05 16:07:11 -0700390 init_sb800_IMC_fans(dev);
Julius Wernercd49cce2019-03-05 16:53:33 -0800391#elif CONFIG(SB800_MANUAL_FAN_CONTROL)
Martin Rothe899e512012-12-05 16:07:11 -0700392 init_sb800_MANUAL_fans(dev);
393#endif
Frank Vibrans63e62b02011-02-14 18:38:14 +0000394 break;
395
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300396 case PCI_DEVFN(0x14, 4): /* 0:14:4 PCI */
Kyösti Mälkki486c05f2015-01-17 18:08:40 +0200397 /* PcibConfig [PM_Reg: EAh], PCIDisable [Bit0]
398 * 'PCIDisable' set to 0 to enable P2P bridge.
399 * 'PCIDisable' set to 1 to disable P2P bridge and enable PCI interface pins
400 * to function as GPIO {GPIO 35:0}.
401 */
Kyösti Mälkki0b87bb72014-11-11 17:22:23 +0200402 if (!sb_chip->disconnect_pcib && dev->enabled)
Kyösti Mälkki486c05f2015-01-17 18:08:40 +0200403 RWMEM(ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REGEA, AccWidthUint8, ~BIT0, 0);
404 else
405 RWMEM(ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REGEA, AccWidthUint8, ~BIT0, BIT0);
Frank Vibrans63e62b02011-02-14 18:38:14 +0000406 break;
407
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300408 case PCI_DEVFN(0x14, 6): /* 0:14:6 GEC */
Frank Vibrans63e62b02011-02-14 18:38:14 +0000409 if (dev->enabled) {
410 sb_config->GecConfig = 0;
Frank Vibrans63e62b02011-02-14 18:38:14 +0000411 } else {
412 sb_config->GecConfig = 1;
Frank Vibrans63e62b02011-02-14 18:38:14 +0000413 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000414 break;
415
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300416 case PCI_DEVFN(0x15, 0): /* 0:15:0 PCIe PortA */
Scott Duplichan8fed77a2011-06-18 10:46:45 -0500417 {
Elyes HAOUAS1a4abb72018-05-19 16:49:20 +0200418 struct device *device;
Paul Menzele4a016f2013-03-01 13:05:04 +0100419 for (device = dev; device; device = device->sibling) {
420 if ((device->path.pci.devfn & ~3) != PCI_DEVFN(0x15,0)) break;
Kerry Shefeed3292011-08-18 18:03:44 +0800421 sb_config->PORTCONFIG[device->path.pci.devfn & 3].PortCfg.PortPresent = device->enabled;
422 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000423
Kerry Shefeed3292011-08-18 18:03:44 +0800424 /*
425 * GPP_CFGMODE_X4000: PortA Lanes[3:0]
426 * GPP_CFGMODE_X2200: PortA Lanes[1:0], PortB Lanes[3:2]
427 * GPP_CFGMODE_X2110: PortA Lanes[1:0], PortB Lane2, PortC Lane3
428 * GPP_CFGMODE_X1111: PortA Lanes0, PortB Lane1, PortC Lane2, PortD Lane3
429 */
430 sb_config->GppLinkConfig = sb_chip->gpp_configuration;
Scott Duplichan8fed77a2011-06-18 10:46:45 -0500431 }
Kerry Shefeed3292011-08-18 18:03:44 +0800432 break;
433
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300434 case PCI_DEVFN(0x12, 0): /* 0:12:0 OHCI-USB1 */
Kerry Shefeed3292011-08-18 18:03:44 +0800435 sb_config->USBMODE.UsbMode.Ohci1 = dev->enabled;
436 break;
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300437 case PCI_DEVFN(0x12, 2): /* 0:12:2 EHCI-USB1 */
Kerry Shefeed3292011-08-18 18:03:44 +0800438 sb_config->USBMODE.UsbMode.Ehci1 = dev->enabled;
439 break;
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300440 case PCI_DEVFN(0x13, 0): /* 0:13:0 OHCI-USB2 */
Kerry Shefeed3292011-08-18 18:03:44 +0800441 sb_config->USBMODE.UsbMode.Ohci2 = dev->enabled;
442 break;
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300443 case PCI_DEVFN(0x13, 2): /* 0:13:2 EHCI-USB2 */
Kerry Shefeed3292011-08-18 18:03:44 +0800444 sb_config->USBMODE.UsbMode.Ehci2 = dev->enabled;
445 break;
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300446 case PCI_DEVFN(0x14, 5): /* 0:14:5 OHCI-USB4 */
Kerry Shefeed3292011-08-18 18:03:44 +0800447 sb_config->USBMODE.UsbMode.Ohci4 = dev->enabled;
448 break;
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300449 case PCI_DEVFN(0x16, 0): /* 0:16:0 OHCI-USB3 */
Kerry Shefeed3292011-08-18 18:03:44 +0800450 sb_config->USBMODE.UsbMode.Ohci3 = dev->enabled;
451 break;
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300452 case PCI_DEVFN(0x16, 2): /* 0:16:2 EHCI-USB3 */
Kerry Shefeed3292011-08-18 18:03:44 +0800453 sb_config->USBMODE.UsbMode.Ehci3 = dev->enabled;
454
Kyösti Mälkki9de8ab92017-09-09 16:51:34 +0300455 /* FIXME: Find better callsites for these.
456 * call the CIMX entry at the last sb800 device,
Kerry Sheh75df1062011-10-10 19:19:46 +0800457 * so make sure the mainboard devicetree is complete
458 */
Kyösti Mälkkic551caa2014-06-20 12:31:23 +0300459 if (!acpi_is_wakeup_s3())
zbao9bcdbf82012-04-05 13:18:49 +0800460 sb_Before_Pci_Init();
461 else
462 sb_Before_Pci_Restore_Init();
Kerry Shefeed3292011-08-18 18:03:44 +0800463 break;
Frank Vibrans63e62b02011-02-14 18:38:14 +0000464
465 default:
466 break;
467 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000468}
469
efdesign9805a89ab2011-06-20 17:38:49 -0700470struct chip_operations southbridge_amd_cimx_sb800_ops = {
Frank Vibrans63e62b02011-02-14 18:38:14 +0000471 CHIP_NAME("ATI SB800")
Kyösti Mälkki41cd0472015-02-07 11:20:54 +0200472 .init = sb800_init,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000473 .enable_dev = sb800_enable,
474};