blob: cbb3797636e7b9d42f14a5809f089ec2bee33956 [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.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
Paul Menzela46a7122013-02-23 18:37:27 +010018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Frank Vibrans63e62b02011-02-14 18:38:14 +000019 */
20
21
22#include <device/device.h> /* device_t */
23#include <device/pci.h> /* device_operations */
24#include <device/pci_ids.h>
Mike Loptienc93a75a2014-06-06 15:16:29 -060025#include <bootstate.h>
Kerry She991f8802011-06-01 01:56:49 +000026#include <arch/ioapic.h>
Frank Vibrans63e62b02011-02-14 18:38:14 +000027#include <device/smbus.h> /* smbus_bus_operations */
zbao366f0fc2012-08-03 16:58:53 +080028#include <pc80/mc146818rtc.h>
Edward O'Callaghane61dd0f2014-05-06 23:53:09 +100029#include <pc80/i8254.h>
30#include <pc80/i8259.h>
Frank Vibrans63e62b02011-02-14 18:38:14 +000031#include <console/console.h> /* printk */
zbao9bcdbf82012-04-05 13:18:49 +080032#include <arch/acpi.h>
Kyösti Mälkkie2227a22014-02-05 13:02:55 +020033#include <device/pci_ehci.h>
Frank Vibrans63e62b02011-02-14 18:38:14 +000034#include "lpc.h" /* lpc_read_resources */
35#include "SBPLATFORM.h" /* Platfrom Specific Definitions */
36#include "cfg.h" /* sb800 Cimx configuration */
efdesign9805a89ab2011-06-20 17:38:49 -070037#include "chip.h" /* struct southbridge_amd_cimx_sb800_config */
Kerry Shefeed3292011-08-18 18:03:44 +080038#include "sb_cimx.h" /* AMD CIMX wrapper entries */
Dave Frodin23023a52012-11-13 07:09:12 -070039#include "smbus.h"
Martin Rothe899e512012-12-05 16:07:11 -070040#include "fan.h"
Dave Frodin2093c4f2014-06-13 08:12:48 -060041#include <southbridge/amd/amd_pci_util.h>
Frank Vibrans63e62b02011-02-14 18:38:14 +000042
43/*implement in mainboard.c*/
Frank Vibrans63e62b02011-02-14 18:38:14 +000044void set_pcie_reset(void);
45void set_pcie_dereset(void);
46
47
Frank Vibrans63e62b02011-02-14 18:38:14 +000048static AMDSBCFG sb_late_cfg; //global, init in sb800_cimx_config
49static AMDSBCFG *sb_config = &sb_late_cfg;
50
51
52/**
53 * @brief Entry point of Southbridge CIMx callout
54 *
55 * prototype UINT32 (*SBCIM_HOOK_ENTRY)(UINT32 Param1, UINT32 Param2, void* pConfig)
56 *
57 * @param[in] func Southbridge CIMx Function ID.
58 * @param[in] data Southbridge Input Data.
59 * @param[in] sb_config Southbridge configuration structure pointer.
60 *
61 */
62u32 sb800_callout_entry(u32 func, u32 data, void* config)
63{
64 u32 ret = 0;
Kerry Shefeed3292011-08-18 18:03:44 +080065 printk(BIOS_DEBUG, "SB800 - Late.c - %s - Start.\n", __func__);
Frank Vibrans63e62b02011-02-14 18:38:14 +000066 switch (func) {
67 case CB_SBGPP_RESET_ASSERT:
Frank Vibrans63e62b02011-02-14 18:38:14 +000068 set_pcie_reset();
69 break;
70
71 case CB_SBGPP_RESET_DEASSERT:
Frank Vibrans63e62b02011-02-14 18:38:14 +000072 set_pcie_dereset();
73 break;
74
75 case IMC_FIRMWARE_FAIL:
76 break;
77
78 default:
79 break;
80 }
81
Kerry Shefeed3292011-08-18 18:03:44 +080082 printk(BIOS_DEBUG, "SB800 - Late.c - %s - End.\n", __func__);
Frank Vibrans63e62b02011-02-14 18:38:14 +000083 return ret;
84}
85
Kerry Sheh0e6344e2011-10-12 11:42:59 +080086#define HOST_CAP 0x00 /* host capabilities */
87#define HOST_CTL 0x04 /* global host control */
88#define HOST_IRQ_STAT 0x08 /* interrupt status */
89#define HOST_PORTS_IMPL 0x0c /* bitmap of implemented ports */
90
91#define HOST_CTL_AHCI_EN (1 << 31) /* AHCI enabled */
92static void ahci_raid_init(struct device *dev)
93{
94 u8 irq = 0;
95 u32 bar5, caps, ports, val;
96
97 val = pci_read_config16(dev, PCI_CLASS_DEVICE);
98 if (val == PCI_CLASS_STORAGE_SATA) {
99 printk(BIOS_DEBUG, "AHCI controller ");
100 } else if (val == PCI_CLASS_STORAGE_RAID) {
101 printk(BIOS_DEBUG, "RAID controller ");
102 } else {
103 printk(BIOS_WARNING, "device class:%x, neither in ahci or raid mode\n", val);
104 return;
105 }
106
107 irq = pci_read_config8(dev, PCI_INTERRUPT_LINE);
108 bar5 = pci_read_config32(dev, PCI_BASE_ADDRESS_5);
109 printk(BIOS_DEBUG, "IOMEM base: 0x%X, IRQ: 0x%X\n", bar5, irq);
110
111 caps = *(volatile u32 *)(bar5 + HOST_CAP);
112 caps = (caps & 0x1F) + 1;
113 ports= *(volatile u32 *)(bar5 + HOST_PORTS_IMPL);
114 printk(BIOS_DEBUG, "Number of Ports: 0x%x, Port implemented(bit map): 0x%x\n", caps, ports);
115
116 /* make sure ahci is enabled */
117 val = *(volatile u32 *)(bar5 + HOST_CTL);
118 if (!(val & HOST_CTL_AHCI_EN)) {
119 *(volatile u32 *)(bar5 + HOST_CTL) = val | HOST_CTL_AHCI_EN;
120 }
121
122 dev->command |= PCI_COMMAND_MASTER;
123 pci_write_config8(dev, PCI_COMMAND, dev->command);
124 printk(BIOS_DEBUG, "AHCI/RAID controller initialized\n");
125}
Frank Vibrans63e62b02011-02-14 18:38:14 +0000126
127static struct pci_operations lops_pci = {
Kerry Shefeed3292011-08-18 18:03:44 +0800128 .set_subsystem = pci_dev_set_subsystem,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000129};
130
zbao366f0fc2012-08-03 16:58:53 +0800131static void lpc_init(device_t dev)
132{
133 printk(BIOS_DEBUG, "SB800 - Late.c - lpc_init - Start.\n");
134
Gabe Blackb3f08c62014-04-30 17:12:25 -0700135 cmos_check_update_date(RTC_HAS_ALTCENTURY);
zbao366f0fc2012-08-03 16:58:53 +0800136
Mike Loptienac529b12013-02-22 13:18:31 -0700137 /* Initialize the real time clock.
Gabe Blackb3f08c62014-04-30 17:12:25 -0700138 * The 0 argument tells cmos_init not to
Mike Loptienac529b12013-02-22 13:18:31 -0700139 * update CMOS unless it is invalid.
Gabe Blackb3f08c62014-04-30 17:12:25 -0700140 * 1 tells cmos_init to always initialize the CMOS.
Mike Loptienac529b12013-02-22 13:18:31 -0700141 */
Gabe Blackb3f08c62014-04-30 17:12:25 -0700142 cmos_init(0);
Mike Loptienac529b12013-02-22 13:18:31 -0700143
Edward O'Callaghane61dd0f2014-05-06 23:53:09 +1000144 setup_i8259(); /* Initialize i8259 pic */
145 setup_i8254(); /* Initialize i8254 timers */
146
zbao366f0fc2012-08-03 16:58:53 +0800147 printk(BIOS_DEBUG, "SB800 - Late.c - lpc_init - End.\n");
148}
149
Vladimir Serbinenko2a19fb12014-10-02 20:09:19 +0200150unsigned long acpi_fill_mcfg(unsigned long current)
151{
152 /* Just a dummy */
153 return current;
154}
155
Frank Vibrans63e62b02011-02-14 18:38:14 +0000156static struct device_operations lpc_ops = {
157 .read_resources = lpc_read_resources,
158 .set_resources = lpc_set_resources,
Kerry Shefeed3292011-08-18 18:03:44 +0800159 .enable_resources = pci_dev_enable_resources,
Vladimir Serbinenko2a19fb12014-10-02 20:09:19 +0200160#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES) && IS_ENABLED(CONFIG_PER_DEVICE_ACPI_TABLES)
161 .write_acpi_tables = acpi_write_hpet,
162#endif
zbao366f0fc2012-08-03 16:58:53 +0800163 .init = lpc_init,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000164 .scan_bus = scan_static_bus,
165 .ops_pci = &lops_pci,
166};
167
168static const struct pci_driver lpc_driver __pci_driver = {
169 .ops = &lpc_ops,
170 .vendor = PCI_VENDOR_ID_ATI,
171 .device = PCI_DEVICE_ID_ATI_SB800_LPC,
172};
173
Frank Vibrans63e62b02011-02-14 18:38:14 +0000174static struct device_operations sata_ops = {
175 .read_resources = pci_dev_read_resources,
176 .set_resources = pci_dev_set_resources,
Kerry Shefeed3292011-08-18 18:03:44 +0800177 .enable_resources = pci_dev_enable_resources,
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800178 .init = ahci_raid_init,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000179 .scan_bus = 0,
180 .ops_pci = &lops_pci,
181};
182
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800183static const struct pci_driver ahci_driver __pci_driver = {
Frank Vibrans63e62b02011-02-14 18:38:14 +0000184 .ops = &sata_ops,
185 .vendor = PCI_VENDOR_ID_ATI,
Scott Duplichanf191c722011-05-15 21:38:08 +0000186 .device = PCI_DEVICE_ID_ATI_SB800_SATA_AHCI,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000187};
188
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800189static const struct pci_driver raid_driver __pci_driver = {
190 .ops = &sata_ops,
191 .vendor = PCI_VENDOR_ID_ATI,
192 .device = PCI_DEVICE_ID_ATI_SB800_SATA_RAID,
193};
194static const struct pci_driver raid5_driver __pci_driver = {
195 .ops = &sata_ops,
196 .vendor = PCI_VENDOR_ID_ATI,
197 .device = PCI_DEVICE_ID_ATI_SB800_SATA_RAID5,
198};
199
Frank Vibrans63e62b02011-02-14 18:38:14 +0000200static struct device_operations usb_ops = {
Kyösti Mälkkifb387df2013-06-07 22:16:52 +0300201 .read_resources = pci_ehci_read_resources,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000202 .set_resources = pci_dev_set_resources,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000203 .enable_resources = pci_dev_enable_resources,
Kerry Shefeed3292011-08-18 18:03:44 +0800204 .init = 0,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000205 .scan_bus = 0,
206 .ops_pci = &lops_pci,
207};
208
209/*
210 * The pci id of usb ctrl 0 and 1 are the same.
211 */
212static const struct pci_driver usb_ohci123_driver __pci_driver = {
213 .ops = &usb_ops,
214 .vendor = PCI_VENDOR_ID_ATI,
215 .device = PCI_DEVICE_ID_ATI_SB800_USB_18_0, /* OHCI-USB1, OHCI-USB2, OHCI-USB3 */
216};
217
218static const struct pci_driver usb_ehci123_driver __pci_driver = {
219 .ops = &usb_ops,
220 .vendor = PCI_VENDOR_ID_ATI,
221 .device = PCI_DEVICE_ID_ATI_SB800_USB_18_2, /* EHCI-USB1, EHCI-USB2, EHCI-USB3 */
222};
223
224static const struct pci_driver usb_ohci4_driver __pci_driver = {
225 .ops = &usb_ops,
226 .vendor = PCI_VENDOR_ID_ATI,
227 .device = PCI_DEVICE_ID_ATI_SB800_USB_20_5, /* OHCI-USB4 */
228};
229
230
Frank Vibrans63e62b02011-02-14 18:38:14 +0000231static struct device_operations azalia_ops = {
232 .read_resources = pci_dev_read_resources,
233 .set_resources = pci_dev_set_resources,
234 .enable_resources = pci_dev_enable_resources,
Kerry Shefeed3292011-08-18 18:03:44 +0800235 .init = 0,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000236 .scan_bus = 0,
237 .ops_pci = &lops_pci,
238};
239
240static const struct pci_driver azalia_driver __pci_driver = {
241 .ops = &azalia_ops,
242 .vendor = PCI_VENDOR_ID_ATI,
243 .device = PCI_DEVICE_ID_ATI_SB800_HDA,
244};
245
246
Frank Vibrans63e62b02011-02-14 18:38:14 +0000247static struct device_operations gec_ops = {
248 .read_resources = pci_dev_read_resources,
249 .set_resources = pci_dev_set_resources,
250 .enable_resources = pci_dev_enable_resources,
Kerry Shefeed3292011-08-18 18:03:44 +0800251 .init = 0,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000252 .scan_bus = 0,
253 .ops_pci = &lops_pci,
254};
255
256static const struct pci_driver gec_driver __pci_driver = {
257 .ops = &gec_ops,
258 .vendor = PCI_VENDOR_ID_ATI,
259 .device = PCI_DEVICE_ID_ATI_SB800_GEC,
260};
261
Kerry She3e706b62011-06-24 22:52:15 +0800262/**
263 * @brief Enable PCI Bridge
264 *
265 * PcibConfig [PM_Reg: EAh], PCIDisable [Bit0]
266 * 'PCIDisable' set to 0 to enable P2P bridge.
267 * 'PCIDisable' set to 1 to disable P2P bridge and enable PCI interface pins
268 * to function as GPIO {GPIO 35:0}.
269 */
270static void pci_init(device_t dev)
271{
272 /* PCI Bridge SHOULD be enabled by default according to SB800 rrg,
273 * but actually was disabled in some platform, so I have to enabled it.
274 */
275 RWMEM(ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REGEA, AccWidthUint8, ~BIT0, 0);
276}
Frank Vibrans63e62b02011-02-14 18:38:14 +0000277
Frank Vibrans63e62b02011-02-14 18:38:14 +0000278
279static struct device_operations pci_ops = {
280 .read_resources = pci_bus_read_resources,
281 .set_resources = pci_dev_set_resources,
282 .enable_resources = pci_bus_enable_resources,
Kerry She3e706b62011-06-24 22:52:15 +0800283 .init = pci_init,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000284 .scan_bus = pci_scan_bridge,
285 .reset_bus = pci_bus_reset,
286 .ops_pci = &lops_pci,
287};
288
289static const struct pci_driver pci_driver __pci_driver = {
290 .ops = &pci_ops,
291 .vendor = PCI_VENDOR_ID_ATI,
292 .device = PCI_DEVICE_ID_ATI_SB800_PCI,
293};
294
295
296struct device_operations bridge_ops = {
297 .read_resources = pci_bus_read_resources,
298 .set_resources = pci_dev_set_resources,
299 .enable_resources = pci_bus_enable_resources,
Kerry Shefeed3292011-08-18 18:03:44 +0800300 .init = 0,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000301 .scan_bus = pci_scan_bridge,
302 .enable = 0,
303 .reset_bus = pci_bus_reset,
304 .ops_pci = &lops_pci,
305};
306
Frank Vibrans63e62b02011-02-14 18:38:14 +0000307/**
Kerry Shefeed3292011-08-18 18:03:44 +0800308 * South Bridge CIMx ramstage entry point wrapper.
309 */
310void sb_Before_Pci_Init(void)
311{
312 sb_config->StdHeader.Func = SB_BEFORE_PCI_INIT;
313 AmdSbDispatcher(sb_config);
314}
315
316void sb_After_Pci_Init(void)
317{
318 sb_config->StdHeader.Func = SB_AFTER_PCI_INIT;
319 AmdSbDispatcher(sb_config);
320}
321
322void sb_Mid_Post_Init(void)
323{
324 sb_config->StdHeader.Func = SB_MID_POST_INIT;
325 AmdSbDispatcher(sb_config);
326}
327
328void sb_Late_Post(void)
329{
330 sb_config->StdHeader.Func = SB_LATE_POST_INIT;
331 AmdSbDispatcher(sb_config);
332}
333
zbao9bcdbf82012-04-05 13:18:49 +0800334void sb_Before_Pci_Restore_Init(void)
335{
336 sb_config->StdHeader.Func = SB_BEFORE_PCI_RESTORE_INIT;
337 AmdSbDispatcher(sb_config);
338}
339
340void sb_After_Pci_Restore_Init(void)
341{
342 sb_config->StdHeader.Func = SB_AFTER_PCI_RESTORE_INIT;
343 AmdSbDispatcher(sb_config);
344}
Kerry Shefeed3292011-08-18 18:03:44 +0800345
Mike Loptienc93a75a2014-06-06 15:16:29 -0600346/*
347 * Update the PCI devices with a valid IRQ number
348 * that is set in the mainboard PCI_IRQ structures.
349 */
350static void set_pci_irqs(void *unused)
351{
352 /* Write PCI_INTR regs 0xC00/0xC01 */
353 write_pci_int_table();
354
355 /* Write IRQs for all devicetree enabled devices */
356 write_pci_cfg_irqs();
357}
358
359/*
360 * Hook this function into the PCI state machine
361 * on entry into BS_DEV_ENABLE.
362 */
363BOOT_STATE_INIT_ENTRIES(pci_irq_update) = {
364 BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY,
365 set_pci_irqs, NULL),
366};
367
Kerry Shefeed3292011-08-18 18:03:44 +0800368/**
Frank Vibrans63e62b02011-02-14 18:38:14 +0000369 * @brief SB Cimx entry point sbBeforePciInit wrapper
370 */
371static void sb800_enable(device_t dev)
372{
efdesign9805a89ab2011-06-20 17:38:49 -0700373 struct southbridge_amd_cimx_sb800_config *sb_chip =
374 (struct southbridge_amd_cimx_sb800_config *)(dev->chip_info);
Frank Vibrans63e62b02011-02-14 18:38:14 +0000375
Frank Vibrans63e62b02011-02-14 18:38:14 +0000376 printk(BIOS_DEBUG, "sb800_enable() ");
377
Frank Vibrans63e62b02011-02-14 18:38:14 +0000378 switch (dev->path.pci.devfn) {
379 case (0x11 << 3) | 0: /* 0:11.0 SATA */
Kerry Shefeed3292011-08-18 18:03:44 +0800380 /* the first sb800 device */
Dave Frodin23023a52012-11-13 07:09:12 -0700381 switch (GPP_CFGMODE) { /* config the GPP PCIe ports */
382 case GPP_CFGMODE_X2200:
Dave Frodin8a6f7a72013-04-17 18:21:09 -0600383 abcfg_reg(0xc0, 0x01FF, 0x032); /* x2 Port_0, x2 Port_1 */
Dave Frodin23023a52012-11-13 07:09:12 -0700384 break;
385 case GPP_CFGMODE_X2110:
Dave Frodin8a6f7a72013-04-17 18:21:09 -0600386 abcfg_reg(0xc0, 0x01FF, 0x073); /* x2 Port_0, x1 Port_1&2 */
Dave Frodin23023a52012-11-13 07:09:12 -0700387 break;
388 case GPP_CFGMODE_X1111:
Dave Frodin8a6f7a72013-04-17 18:21:09 -0600389 abcfg_reg(0xc0, 0x01FF, 0x0F4); /* x1 Port_0&1&2&3 */
Dave Frodin23023a52012-11-13 07:09:12 -0700390 break;
391 case GPP_CFGMODE_X4000:
392 default:
393 abcfg_reg(0xc0, 0x01FF, 0x010); /* x4 Port_0 */
394 break;
395 }
Kerry Shefeed3292011-08-18 18:03:44 +0800396 sb800_cimx_config(sb_config);
397
Frank Vibrans63e62b02011-02-14 18:38:14 +0000398 if (dev->enabled) {
Kerry She991f8802011-06-01 01:56:49 +0000399 sb_config->SATAMODE.SataMode.SataController = CIMX_OPTION_ENABLED;
Frank Vibrans63e62b02011-02-14 18:38:14 +0000400 if (1 == sb_chip->boot_switch_sata_ide)
401 sb_config->SATAMODE.SataMode.SataIdeCombMdPriSecOpt = 0; //0 -IDE as primary.
402 else if (0 == sb_chip->boot_switch_sata_ide)
403 sb_config->SATAMODE.SataMode.SataIdeCombMdPriSecOpt = 1; //1 -IDE as secondary.
404 } else {
Kerry She991f8802011-06-01 01:56:49 +0000405 sb_config->SATAMODE.SataMode.SataController = CIMX_OPTION_DISABLED;
Frank Vibrans63e62b02011-02-14 18:38:14 +0000406 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000407 break;
408
409 case (0x14 << 3) | 0: /* 0:14:0 SMBUS */
Kerry Shefeed3292011-08-18 18:03:44 +0800410 printk(BIOS_INFO, "sm_init().\n");
411 clear_ioapic(IO_APIC_ADDR);
Kyösti Mälkki35546de2014-04-17 15:07:32 +0300412#if CONFIG_CPU_AMD_AGESA
413 /* Assign the ioapic ID the next available number after the processor core local APIC IDs */
414 setup_ioapic(IO_APIC_ADDR, CONFIG_MAX_CPUS);
415#else
Kerry Shefeed3292011-08-18 18:03:44 +0800416 /* I/O APIC IDs are normally limited to 4-bits. Enforce this limit. */
417#if (CONFIG_APIC_ID_OFFSET == 0 && CONFIG_MAX_CPUS * CONFIG_MAX_PHYSICAL_CPUS < 16)
418 /* Assign the ioapic ID the next available number after the processor core local APIC IDs */
419 setup_ioapic(IO_APIC_ADDR, CONFIG_MAX_CPUS * CONFIG_MAX_PHYSICAL_CPUS);
420#elif (CONFIG_APIC_ID_OFFSET > 0)
421 /* Assign the ioapic ID the value 0. Processor APIC IDs follow. */
422 setup_ioapic(IO_APIC_ADDR, 0);
423#else
424#error "The processor APIC IDs must be lifted to make room for the I/O APIC ID"
425#endif
Kyösti Mälkki35546de2014-04-17 15:07:32 +0300426#endif
Frank Vibrans63e62b02011-02-14 18:38:14 +0000427 break;
428
429 case (0x14 << 3) | 1: /* 0:14:1 IDE */
Frank Vibrans63e62b02011-02-14 18:38:14 +0000430 break;
431
432 case (0x14 << 3) | 2: /* 0:14:2 HDA */
433 if (dev->enabled) {
434 if (AZALIA_DISABLE == sb_config->AzaliaController) {
435 sb_config->AzaliaController = AZALIA_AUTO;
436 }
437 printk(BIOS_DEBUG, "hda enabled\n");
438 } else {
439 sb_config->AzaliaController = AZALIA_DISABLE;
440 printk(BIOS_DEBUG, "hda disabled\n");
441 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000442 break;
443
444
445 case (0x14 << 3) | 3: /* 0:14:3 LPC */
Martin Rothe899e512012-12-05 16:07:11 -0700446 /* Initialize the fans */
447#if CONFIG_SB800_IMC_FAN_CONTROL
448 init_sb800_IMC_fans(dev);
449#elif CONFIG_SB800_MANUAL_FAN_CONTROL
450 init_sb800_MANUAL_fans(dev);
451#endif
Frank Vibrans63e62b02011-02-14 18:38:14 +0000452 break;
453
454 case (0x14 << 3) | 4: /* 0:14:4 PCI */
455 break;
456
457 case (0x14 << 3) | 6: /* 0:14:6 GEC */
458 if (dev->enabled) {
459 sb_config->GecConfig = 0;
460 printk(BIOS_DEBUG, "gec enabled\n");
461 } else {
462 sb_config->GecConfig = 1;
463 printk(BIOS_DEBUG, "gec disabled\n");
464 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000465 break;
466
467 case (0x15 << 3) | 0: /* 0:15:0 PCIe PortA */
Scott Duplichan8fed77a2011-06-18 10:46:45 -0500468 {
Kerry Shefeed3292011-08-18 18:03:44 +0800469 device_t device;
470 for (device = dev; device; device = device->next) {
471 if (dev->path.type != DEVICE_PATH_PCI) continue;
472 if ((device->path.pci.devfn & ~7) != PCI_DEVFN(0x15,0)) break;
473 sb_config->PORTCONFIG[device->path.pci.devfn & 3].PortCfg.PortPresent = device->enabled;
474 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000475
Kerry Shefeed3292011-08-18 18:03:44 +0800476 /*
477 * GPP_CFGMODE_X4000: PortA Lanes[3:0]
478 * GPP_CFGMODE_X2200: PortA Lanes[1:0], PortB Lanes[3:2]
479 * GPP_CFGMODE_X2110: PortA Lanes[1:0], PortB Lane2, PortC Lane3
480 * GPP_CFGMODE_X1111: PortA Lanes0, PortB Lane1, PortC Lane2, PortD Lane3
481 */
482 sb_config->GppLinkConfig = sb_chip->gpp_configuration;
Scott Duplichan8fed77a2011-06-18 10:46:45 -0500483 }
Kerry Shefeed3292011-08-18 18:03:44 +0800484 break;
485
486 case (0x12 << 3) | 0: /* 0:12:0 OHCI-USB1 */
487 sb_config->USBMODE.UsbMode.Ohci1 = dev->enabled;
488 break;
489 case (0x12 << 3) | 2: /* 0:12:2 EHCI-USB1 */
490 sb_config->USBMODE.UsbMode.Ehci1 = dev->enabled;
491 break;
492 case (0x13 << 3) | 0: /* 0:13:0 OHCI-USB2 */
493 sb_config->USBMODE.UsbMode.Ohci2 = dev->enabled;
494 break;
495 case (0x13 << 3) | 2: /* 0:13:2 EHCI-USB2 */
496 sb_config->USBMODE.UsbMode.Ehci2 = dev->enabled;
497 break;
498 case (0x14 << 3) | 5: /* 0:14:5 OHCI-USB4 */
499 sb_config->USBMODE.UsbMode.Ohci4 = dev->enabled;
500 break;
501 case (0x16 << 3) | 0: /* 0:16:0 OHCI-USB3 */
502 sb_config->USBMODE.UsbMode.Ohci3 = dev->enabled;
503 break;
504 case (0x16 << 3) | 2: /* 0:16:2 EHCI-USB3 */
505 sb_config->USBMODE.UsbMode.Ehci3 = dev->enabled;
506
Kerry Sheh75df1062011-10-10 19:19:46 +0800507 /* call the CIMX entry at the last sb800 device,
508 * so make sure the mainboard devicetree is complete
509 */
Kyösti Mälkkic551caa2014-06-20 12:31:23 +0300510 if (!acpi_is_wakeup_s3())
zbao9bcdbf82012-04-05 13:18:49 +0800511 sb_Before_Pci_Init();
512 else
513 sb_Before_Pci_Restore_Init();
Kerry Shefeed3292011-08-18 18:03:44 +0800514 break;
Frank Vibrans63e62b02011-02-14 18:38:14 +0000515
516 default:
517 break;
518 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000519}
520
efdesign9805a89ab2011-06-20 17:38:49 -0700521struct chip_operations southbridge_amd_cimx_sb800_ops = {
Frank Vibrans63e62b02011-02-14 18:38:14 +0000522 CHIP_NAME("ATI SB800")
523 .enable_dev = sb800_enable,
524};