blob: fa47a96f2ee04d8aa7f3c92a5def488b38461ec7 [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
18#include <device/device.h> /* device_t */
19#include <device/pci.h> /* device_operations */
20#include <device/pci_ids.h>
Mike Loptienc93a75a2014-06-06 15:16:29 -060021#include <bootstate.h>
Kerry She991f8802011-06-01 01:56:49 +000022#include <arch/ioapic.h>
Frank Vibrans63e62b02011-02-14 18:38:14 +000023#include <device/smbus.h> /* smbus_bus_operations */
zbao366f0fc2012-08-03 16:58:53 +080024#include <pc80/mc146818rtc.h>
Edward O'Callaghane61dd0f2014-05-06 23:53:09 +100025#include <pc80/i8254.h>
26#include <pc80/i8259.h>
Frank Vibrans63e62b02011-02-14 18:38:14 +000027#include <console/console.h> /* printk */
zbao9bcdbf82012-04-05 13:18:49 +080028#include <arch/acpi.h>
Kyösti Mälkkie2227a22014-02-05 13:02:55 +020029#include <device/pci_ehci.h>
Frank Vibrans63e62b02011-02-14 18:38:14 +000030#include "lpc.h" /* lpc_read_resources */
Martin Roth3c3a50c2014-12-16 20:50:26 -070031#include "SBPLATFORM.h" /* Platform Specific Definitions */
Frank Vibrans63e62b02011-02-14 18:38:14 +000032#include "cfg.h" /* sb800 Cimx configuration */
efdesign9805a89ab2011-06-20 17:38:49 -070033#include "chip.h" /* struct southbridge_amd_cimx_sb800_config */
Kerry Shefeed3292011-08-18 18:03:44 +080034#include "sb_cimx.h" /* AMD CIMX wrapper entries */
Dave Frodin23023a52012-11-13 07:09:12 -070035#include "smbus.h"
Martin Rothe899e512012-12-05 16:07:11 -070036#include "fan.h"
Stefan Reinauer13e41822015-04-27 14:02:36 -070037#include <southbridge/amd/common/amd_pci_util.h>
Frank Vibrans63e62b02011-02-14 18:38:14 +000038
39/*implement in mainboard.c*/
Frank Vibrans63e62b02011-02-14 18:38:14 +000040void set_pcie_reset(void);
41void set_pcie_dereset(void);
42
43
Frank Vibrans63e62b02011-02-14 18:38:14 +000044static AMDSBCFG sb_late_cfg; //global, init in sb800_cimx_config
45static AMDSBCFG *sb_config = &sb_late_cfg;
46
47
48/**
49 * @brief Entry point of Southbridge CIMx callout
50 *
51 * prototype UINT32 (*SBCIM_HOOK_ENTRY)(UINT32 Param1, UINT32 Param2, void* pConfig)
52 *
53 * @param[in] func Southbridge CIMx Function ID.
54 * @param[in] data Southbridge Input Data.
Martin Roth6355cbf2015-01-04 15:22:26 -070055 * @param[in] config Southbridge configuration structure pointer.
Frank Vibrans63e62b02011-02-14 18:38:14 +000056 *
57 */
Kyösti Mälkki41cd0472015-02-07 11:20:54 +020058static u32 sb800_callout_entry(u32 func, u32 data, void* config)
Frank Vibrans63e62b02011-02-14 18:38:14 +000059{
60 u32 ret = 0;
Kerry Shefeed3292011-08-18 18:03:44 +080061 printk(BIOS_DEBUG, "SB800 - Late.c - %s - Start.\n", __func__);
Frank Vibrans63e62b02011-02-14 18:38:14 +000062 switch (func) {
63 case CB_SBGPP_RESET_ASSERT:
Frank Vibrans63e62b02011-02-14 18:38:14 +000064 set_pcie_reset();
65 break;
66
67 case CB_SBGPP_RESET_DEASSERT:
Frank Vibrans63e62b02011-02-14 18:38:14 +000068 set_pcie_dereset();
69 break;
70
71 case IMC_FIRMWARE_FAIL:
72 break;
73
74 default:
75 break;
76 }
77
Kerry Shefeed3292011-08-18 18:03:44 +080078 printk(BIOS_DEBUG, "SB800 - Late.c - %s - End.\n", __func__);
Frank Vibrans63e62b02011-02-14 18:38:14 +000079 return ret;
80}
81
Kerry Sheh0e6344e2011-10-12 11:42:59 +080082#define HOST_CAP 0x00 /* host capabilities */
83#define HOST_CTL 0x04 /* global host control */
84#define HOST_IRQ_STAT 0x08 /* interrupt status */
85#define HOST_PORTS_IMPL 0x0c /* bitmap of implemented ports */
86
87#define HOST_CTL_AHCI_EN (1 << 31) /* AHCI enabled */
88static void ahci_raid_init(struct device *dev)
89{
90 u8 irq = 0;
Stefan Reinauer12bce3f2015-06-18 01:17:38 -070091 void *bar5;
92 u32 caps, ports, val;
Kerry Sheh0e6344e2011-10-12 11:42:59 +080093
94 val = pci_read_config16(dev, PCI_CLASS_DEVICE);
95 if (val == PCI_CLASS_STORAGE_SATA) {
96 printk(BIOS_DEBUG, "AHCI controller ");
97 } else if (val == PCI_CLASS_STORAGE_RAID) {
98 printk(BIOS_DEBUG, "RAID controller ");
99 } else {
100 printk(BIOS_WARNING, "device class:%x, neither in ahci or raid mode\n", val);
101 return;
102 }
103
104 irq = pci_read_config8(dev, PCI_INTERRUPT_LINE);
Stefan Reinauer12bce3f2015-06-18 01:17:38 -0700105 bar5 = (void *)(uintptr_t)pci_read_config32(dev, PCI_BASE_ADDRESS_5);
106 printk(BIOS_DEBUG, "IOMEM base: %p, IRQ: 0x%X\n", bar5, irq);
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800107
Stefan Reinauer12bce3f2015-06-18 01:17:38 -0700108 caps = read32(bar5 + HOST_CAP);
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800109 caps = (caps & 0x1F) + 1;
Stefan Reinauer12bce3f2015-06-18 01:17:38 -0700110 ports= read32(bar5 + HOST_PORTS_IMPL);
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800111 printk(BIOS_DEBUG, "Number of Ports: 0x%x, Port implemented(bit map): 0x%x\n", caps, ports);
112
113 /* make sure ahci is enabled */
Stefan Reinauer12bce3f2015-06-18 01:17:38 -0700114 val = read32(bar5 + HOST_CTL);
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800115 if (!(val & HOST_CTL_AHCI_EN)) {
Stefan Reinauer12bce3f2015-06-18 01:17:38 -0700116 write32(bar5 + HOST_CTL, val | HOST_CTL_AHCI_EN);
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800117 }
118
119 dev->command |= PCI_COMMAND_MASTER;
120 pci_write_config8(dev, PCI_COMMAND, dev->command);
121 printk(BIOS_DEBUG, "AHCI/RAID controller initialized\n");
122}
Frank Vibrans63e62b02011-02-14 18:38:14 +0000123
124static struct pci_operations lops_pci = {
Kerry Shefeed3292011-08-18 18:03:44 +0800125 .set_subsystem = pci_dev_set_subsystem,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000126};
127
zbao366f0fc2012-08-03 16:58:53 +0800128static void lpc_init(device_t dev)
129{
130 printk(BIOS_DEBUG, "SB800 - Late.c - lpc_init - Start.\n");
131
Gabe Black03abaee212014-04-30 21:31:44 -0700132 cmos_check_update_date();
zbao366f0fc2012-08-03 16:58:53 +0800133
Mike Loptienac529b12013-02-22 13:18:31 -0700134 /* Initialize the real time clock.
Gabe Blackb3f08c62014-04-30 17:12:25 -0700135 * The 0 argument tells cmos_init not to
Mike Loptienac529b12013-02-22 13:18:31 -0700136 * update CMOS unless it is invalid.
Gabe Blackb3f08c62014-04-30 17:12:25 -0700137 * 1 tells cmos_init to always initialize the CMOS.
Mike Loptienac529b12013-02-22 13:18:31 -0700138 */
Gabe Blackb3f08c62014-04-30 17:12:25 -0700139 cmos_init(0);
Mike Loptienac529b12013-02-22 13:18:31 -0700140
Edward O'Callaghane61dd0f2014-05-06 23:53:09 +1000141 setup_i8259(); /* Initialize i8259 pic */
142 setup_i8254(); /* Initialize i8254 timers */
143
zbao366f0fc2012-08-03 16:58:53 +0800144 printk(BIOS_DEBUG, "SB800 - Late.c - lpc_init - End.\n");
145}
146
Vladimir Serbinenko2a19fb12014-10-02 20:09:19 +0200147unsigned long acpi_fill_mcfg(unsigned long current)
148{
149 /* Just a dummy */
150 return current;
151}
152
Frank Vibrans63e62b02011-02-14 18:38:14 +0000153static struct device_operations lpc_ops = {
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200154 .read_resources = lpc_read_resources,
155 .set_resources = lpc_set_resources,
156 .enable_resources = pci_dev_enable_resources,
Vladimir Serbinenko83f81ca2014-11-09 13:30:50 +0100157#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
Vladimir Serbinenko2a19fb12014-10-02 20:09:19 +0200158 .write_acpi_tables = acpi_write_hpet,
159#endif
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200160 .init = lpc_init,
161 .scan_bus = scan_lpc_bus,
162 .ops_pci = &lops_pci,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000163};
164
165static const struct pci_driver lpc_driver __pci_driver = {
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200166 .ops = &lpc_ops,
167 .vendor = PCI_VENDOR_ID_ATI,
168 .device = PCI_DEVICE_ID_ATI_SB800_LPC,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000169};
170
Frank Vibrans63e62b02011-02-14 18:38:14 +0000171static struct device_operations sata_ops = {
172 .read_resources = pci_dev_read_resources,
173 .set_resources = pci_dev_set_resources,
Kerry Shefeed3292011-08-18 18:03:44 +0800174 .enable_resources = pci_dev_enable_resources,
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800175 .init = ahci_raid_init,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000176 .scan_bus = 0,
177 .ops_pci = &lops_pci,
178};
179
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800180static const struct pci_driver ahci_driver __pci_driver = {
Frank Vibrans63e62b02011-02-14 18:38:14 +0000181 .ops = &sata_ops,
182 .vendor = PCI_VENDOR_ID_ATI,
Scott Duplichanf191c722011-05-15 21:38:08 +0000183 .device = PCI_DEVICE_ID_ATI_SB800_SATA_AHCI,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000184};
185
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800186static const struct pci_driver raid_driver __pci_driver = {
187 .ops = &sata_ops,
188 .vendor = PCI_VENDOR_ID_ATI,
189 .device = PCI_DEVICE_ID_ATI_SB800_SATA_RAID,
190};
191static const struct pci_driver raid5_driver __pci_driver = {
192 .ops = &sata_ops,
193 .vendor = PCI_VENDOR_ID_ATI,
194 .device = PCI_DEVICE_ID_ATI_SB800_SATA_RAID5,
195};
196
Frank Vibrans63e62b02011-02-14 18:38:14 +0000197static struct device_operations usb_ops = {
Kyösti Mälkkifb387df2013-06-07 22:16:52 +0300198 .read_resources = pci_ehci_read_resources,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000199 .set_resources = pci_dev_set_resources,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000200 .enable_resources = pci_dev_enable_resources,
Kerry Shefeed3292011-08-18 18:03:44 +0800201 .init = 0,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000202 .scan_bus = 0,
203 .ops_pci = &lops_pci,
204};
205
206/*
207 * The pci id of usb ctrl 0 and 1 are the same.
208 */
209static const struct pci_driver usb_ohci123_driver __pci_driver = {
210 .ops = &usb_ops,
211 .vendor = PCI_VENDOR_ID_ATI,
212 .device = PCI_DEVICE_ID_ATI_SB800_USB_18_0, /* OHCI-USB1, OHCI-USB2, OHCI-USB3 */
213};
214
215static const struct pci_driver usb_ehci123_driver __pci_driver = {
216 .ops = &usb_ops,
217 .vendor = PCI_VENDOR_ID_ATI,
218 .device = PCI_DEVICE_ID_ATI_SB800_USB_18_2, /* EHCI-USB1, EHCI-USB2, EHCI-USB3 */
219};
220
221static const struct pci_driver usb_ohci4_driver __pci_driver = {
222 .ops = &usb_ops,
223 .vendor = PCI_VENDOR_ID_ATI,
224 .device = PCI_DEVICE_ID_ATI_SB800_USB_20_5, /* OHCI-USB4 */
225};
226
227
Frank Vibrans63e62b02011-02-14 18:38:14 +0000228static struct device_operations azalia_ops = {
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200229 .read_resources = pci_dev_read_resources,
230 .set_resources = pci_dev_set_resources,
231 .enable_resources = pci_dev_enable_resources,
232 .init = 0,
233 .scan_bus = 0,
234 .ops_pci = &lops_pci,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000235};
236
237static const struct pci_driver azalia_driver __pci_driver = {
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200238 .ops = &azalia_ops,
239 .vendor = PCI_VENDOR_ID_ATI,
240 .device = PCI_DEVICE_ID_ATI_SB800_HDA,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000241};
242
243
Frank Vibrans63e62b02011-02-14 18:38:14 +0000244static struct device_operations gec_ops = {
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200245 .read_resources = pci_dev_read_resources,
246 .set_resources = pci_dev_set_resources,
247 .enable_resources = pci_dev_enable_resources,
248 .init = 0,
249 .scan_bus = 0,
250 .ops_pci = &lops_pci,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000251};
252
253static const struct pci_driver gec_driver __pci_driver = {
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200254 .ops = &gec_ops,
255 .vendor = PCI_VENDOR_ID_ATI,
256 .device = PCI_DEVICE_ID_ATI_SB800_GEC,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000257};
258
Kerry She3e706b62011-06-24 22:52:15 +0800259/**
Kyösti Mälkki41cd0472015-02-07 11:20:54 +0200260 * Fill build time defaults.
261 */
262static void sb800_init(void *chip_info)
263{
264 sb_config->StdHeader.CALLBACK.CalloutPtr = sb800_callout_entry;
265 sb800_cimx_config(sb_config);
Kyösti Mälkki24501ca2015-02-07 17:38:45 +0200266
Paul Menzel114a9482015-10-25 22:27:42 +0100267 /* Initially enable all GPP ports 0 to 3 */
Kyösti Mälkki24501ca2015-02-07 17:38:45 +0200268 abcfg_reg(0xc0, 0x01FF, 0x0F4);
Kyösti Mälkki41cd0472015-02-07 11:20:54 +0200269}
270
271/**
Kerry Shefeed3292011-08-18 18:03:44 +0800272 * South Bridge CIMx ramstage entry point wrapper.
273 */
274void sb_Before_Pci_Init(void)
275{
276 sb_config->StdHeader.Func = SB_BEFORE_PCI_INIT;
277 AmdSbDispatcher(sb_config);
278}
279
280void sb_After_Pci_Init(void)
281{
282 sb_config->StdHeader.Func = SB_AFTER_PCI_INIT;
283 AmdSbDispatcher(sb_config);
284}
285
286void sb_Mid_Post_Init(void)
287{
288 sb_config->StdHeader.Func = SB_MID_POST_INIT;
289 AmdSbDispatcher(sb_config);
290}
291
292void sb_Late_Post(void)
293{
294 sb_config->StdHeader.Func = SB_LATE_POST_INIT;
295 AmdSbDispatcher(sb_config);
296}
297
zbao9bcdbf82012-04-05 13:18:49 +0800298void sb_Before_Pci_Restore_Init(void)
299{
300 sb_config->StdHeader.Func = SB_BEFORE_PCI_RESTORE_INIT;
301 AmdSbDispatcher(sb_config);
302}
303
304void sb_After_Pci_Restore_Init(void)
305{
306 sb_config->StdHeader.Func = SB_AFTER_PCI_RESTORE_INIT;
307 AmdSbDispatcher(sb_config);
308}
Kerry Shefeed3292011-08-18 18:03:44 +0800309
Mike Loptienc93a75a2014-06-06 15:16:29 -0600310/*
311 * Update the PCI devices with a valid IRQ number
312 * that is set in the mainboard PCI_IRQ structures.
313 */
314static void set_pci_irqs(void *unused)
315{
316 /* Write PCI_INTR regs 0xC00/0xC01 */
317 write_pci_int_table();
318
319 /* Write IRQs for all devicetree enabled devices */
320 write_pci_cfg_irqs();
321}
322
323/*
324 * Hook this function into the PCI state machine
325 * on entry into BS_DEV_ENABLE.
326 */
Aaron Durbin9ef9d852015-03-16 17:30:09 -0500327BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, set_pci_irqs, NULL);
Mike Loptienc93a75a2014-06-06 15:16:29 -0600328
Kerry Shefeed3292011-08-18 18:03:44 +0800329/**
Frank Vibrans63e62b02011-02-14 18:38:14 +0000330 * @brief SB Cimx entry point sbBeforePciInit wrapper
331 */
332static void sb800_enable(device_t dev)
333{
efdesign9805a89ab2011-06-20 17:38:49 -0700334 struct southbridge_amd_cimx_sb800_config *sb_chip =
335 (struct southbridge_amd_cimx_sb800_config *)(dev->chip_info);
Frank Vibrans63e62b02011-02-14 18:38:14 +0000336
Frank Vibrans63e62b02011-02-14 18:38:14 +0000337 switch (dev->path.pci.devfn) {
338 case (0x11 << 3) | 0: /* 0:11.0 SATA */
339 if (dev->enabled) {
Kerry She991f8802011-06-01 01:56:49 +0000340 sb_config->SATAMODE.SataMode.SataController = CIMX_OPTION_ENABLED;
Frank Vibrans63e62b02011-02-14 18:38:14 +0000341 if (1 == sb_chip->boot_switch_sata_ide)
342 sb_config->SATAMODE.SataMode.SataIdeCombMdPriSecOpt = 0; //0 -IDE as primary.
343 else if (0 == sb_chip->boot_switch_sata_ide)
344 sb_config->SATAMODE.SataMode.SataIdeCombMdPriSecOpt = 1; //1 -IDE as secondary.
345 } else {
Kerry She991f8802011-06-01 01:56:49 +0000346 sb_config->SATAMODE.SataMode.SataController = CIMX_OPTION_DISABLED;
Frank Vibrans63e62b02011-02-14 18:38:14 +0000347 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000348 break;
349
350 case (0x14 << 3) | 0: /* 0:14:0 SMBUS */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800351 clear_ioapic(VIO_APIC_VADDR);
Kyösti Mälkki35546de2014-04-17 15:07:32 +0300352#if CONFIG_CPU_AMD_AGESA
353 /* Assign the ioapic ID the next available number after the processor core local APIC IDs */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800354 setup_ioapic(VIO_APIC_VADDR, CONFIG_MAX_CPUS);
Kyösti Mälkki35546de2014-04-17 15:07:32 +0300355#else
Kerry Shefeed3292011-08-18 18:03:44 +0800356 /* I/O APIC IDs are normally limited to 4-bits. Enforce this limit. */
357#if (CONFIG_APIC_ID_OFFSET == 0 && CONFIG_MAX_CPUS * CONFIG_MAX_PHYSICAL_CPUS < 16)
358 /* Assign the ioapic ID the next available number after the processor core local APIC IDs */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800359 setup_ioapic(VIO_APIC_VADDR,
360 CONFIG_MAX_CPUS * CONFIG_MAX_PHYSICAL_CPUS);
Kerry Shefeed3292011-08-18 18:03:44 +0800361#elif (CONFIG_APIC_ID_OFFSET > 0)
362 /* Assign the ioapic ID the value 0. Processor APIC IDs follow. */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800363 setup_ioapic(VIO_APIC_VADDR, 0);
Kerry Shefeed3292011-08-18 18:03:44 +0800364#else
365#error "The processor APIC IDs must be lifted to make room for the I/O APIC ID"
366#endif
Kyösti Mälkki35546de2014-04-17 15:07:32 +0300367#endif
Frank Vibrans63e62b02011-02-14 18:38:14 +0000368 break;
369
370 case (0x14 << 3) | 1: /* 0:14:1 IDE */
Frank Vibrans63e62b02011-02-14 18:38:14 +0000371 break;
372
373 case (0x14 << 3) | 2: /* 0:14:2 HDA */
374 if (dev->enabled) {
375 if (AZALIA_DISABLE == sb_config->AzaliaController) {
376 sb_config->AzaliaController = AZALIA_AUTO;
377 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000378 } else {
379 sb_config->AzaliaController = AZALIA_DISABLE;
Frank Vibrans63e62b02011-02-14 18:38:14 +0000380 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000381 break;
382
383
384 case (0x14 << 3) | 3: /* 0:14:3 LPC */
Martin Rothe899e512012-12-05 16:07:11 -0700385 /* Initialize the fans */
386#if CONFIG_SB800_IMC_FAN_CONTROL
387 init_sb800_IMC_fans(dev);
388#elif CONFIG_SB800_MANUAL_FAN_CONTROL
389 init_sb800_MANUAL_fans(dev);
390#endif
Frank Vibrans63e62b02011-02-14 18:38:14 +0000391 break;
392
393 case (0x14 << 3) | 4: /* 0:14:4 PCI */
Kyösti Mälkki486c05f2015-01-17 18:08:40 +0200394 /* PcibConfig [PM_Reg: EAh], PCIDisable [Bit0]
395 * 'PCIDisable' set to 0 to enable P2P bridge.
396 * 'PCIDisable' set to 1 to disable P2P bridge and enable PCI interface pins
397 * to function as GPIO {GPIO 35:0}.
398 */
Kyösti Mälkki0b87bb72014-11-11 17:22:23 +0200399 if (!sb_chip->disconnect_pcib && dev->enabled)
Kyösti Mälkki486c05f2015-01-17 18:08:40 +0200400 RWMEM(ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REGEA, AccWidthUint8, ~BIT0, 0);
401 else
402 RWMEM(ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REGEA, AccWidthUint8, ~BIT0, BIT0);
Frank Vibrans63e62b02011-02-14 18:38:14 +0000403 break;
404
405 case (0x14 << 3) | 6: /* 0:14:6 GEC */
406 if (dev->enabled) {
407 sb_config->GecConfig = 0;
Frank Vibrans63e62b02011-02-14 18:38:14 +0000408 } else {
409 sb_config->GecConfig = 1;
Frank Vibrans63e62b02011-02-14 18:38:14 +0000410 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000411 break;
412
413 case (0x15 << 3) | 0: /* 0:15:0 PCIe PortA */
Scott Duplichan8fed77a2011-06-18 10:46:45 -0500414 {
Kerry Shefeed3292011-08-18 18:03:44 +0800415 device_t device;
416 for (device = dev; device; device = device->next) {
417 if (dev->path.type != DEVICE_PATH_PCI) continue;
418 if ((device->path.pci.devfn & ~7) != PCI_DEVFN(0x15,0)) break;
419 sb_config->PORTCONFIG[device->path.pci.devfn & 3].PortCfg.PortPresent = device->enabled;
420 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000421
Kerry Shefeed3292011-08-18 18:03:44 +0800422 /*
423 * GPP_CFGMODE_X4000: PortA Lanes[3:0]
424 * GPP_CFGMODE_X2200: PortA Lanes[1:0], PortB Lanes[3:2]
425 * GPP_CFGMODE_X2110: PortA Lanes[1:0], PortB Lane2, PortC Lane3
426 * GPP_CFGMODE_X1111: PortA Lanes0, PortB Lane1, PortC Lane2, PortD Lane3
427 */
428 sb_config->GppLinkConfig = sb_chip->gpp_configuration;
Scott Duplichan8fed77a2011-06-18 10:46:45 -0500429 }
Kerry Shefeed3292011-08-18 18:03:44 +0800430 break;
431
432 case (0x12 << 3) | 0: /* 0:12:0 OHCI-USB1 */
433 sb_config->USBMODE.UsbMode.Ohci1 = dev->enabled;
434 break;
435 case (0x12 << 3) | 2: /* 0:12:2 EHCI-USB1 */
436 sb_config->USBMODE.UsbMode.Ehci1 = dev->enabled;
437 break;
438 case (0x13 << 3) | 0: /* 0:13:0 OHCI-USB2 */
439 sb_config->USBMODE.UsbMode.Ohci2 = dev->enabled;
440 break;
441 case (0x13 << 3) | 2: /* 0:13:2 EHCI-USB2 */
442 sb_config->USBMODE.UsbMode.Ehci2 = dev->enabled;
443 break;
444 case (0x14 << 3) | 5: /* 0:14:5 OHCI-USB4 */
445 sb_config->USBMODE.UsbMode.Ohci4 = dev->enabled;
446 break;
447 case (0x16 << 3) | 0: /* 0:16:0 OHCI-USB3 */
448 sb_config->USBMODE.UsbMode.Ohci3 = dev->enabled;
449 break;
450 case (0x16 << 3) | 2: /* 0:16:2 EHCI-USB3 */
451 sb_config->USBMODE.UsbMode.Ehci3 = dev->enabled;
452
Kerry Sheh75df1062011-10-10 19:19:46 +0800453 /* call the CIMX entry at the last sb800 device,
454 * so make sure the mainboard devicetree is complete
455 */
Kyösti Mälkkic551caa2014-06-20 12:31:23 +0300456 if (!acpi_is_wakeup_s3())
zbao9bcdbf82012-04-05 13:18:49 +0800457 sb_Before_Pci_Init();
458 else
459 sb_Before_Pci_Restore_Init();
Kerry Shefeed3292011-08-18 18:03:44 +0800460 break;
Frank Vibrans63e62b02011-02-14 18:38:14 +0000461
462 default:
463 break;
464 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000465}
466
efdesign9805a89ab2011-06-20 17:38:49 -0700467struct chip_operations southbridge_amd_cimx_sb800_ops = {
Frank Vibrans63e62b02011-02-14 18:38:14 +0000468 CHIP_NAME("ATI SB800")
Kyösti Mälkki41cd0472015-02-07 11:20:54 +0200469 .init = sb800_init,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000470 .enable_dev = sb800_enable,
471};