blob: 872e045a1dd47f61b0f38813ecf60614dc359bdb [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
Elyes HAOUAS1a4abb72018-05-19 16:49:20 +020018#include <device/device.h>
Frank Vibrans63e62b02011-02-14 18:38:14 +000019#include <device/pci.h> /* device_operations */
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020020#include <device/pci_ops.h>
Frank Vibrans63e62b02011-02-14 18:38:14 +000021#include <device/pci_ids.h>
Mike Loptienc93a75a2014-06-06 15:16:29 -060022#include <bootstate.h>
Kerry She991f8802011-06-01 01:56:49 +000023#include <arch/ioapic.h>
Frank Vibrans63e62b02011-02-14 18:38:14 +000024#include <device/smbus.h> /* smbus_bus_operations */
zbao366f0fc2012-08-03 16:58:53 +080025#include <pc80/mc146818rtc.h>
Edward O'Callaghane61dd0f2014-05-06 23:53:09 +100026#include <pc80/i8254.h>
27#include <pc80/i8259.h>
Frank Vibrans63e62b02011-02-14 18:38:14 +000028#include <console/console.h> /* printk */
zbao9bcdbf82012-04-05 13:18:49 +080029#include <arch/acpi.h>
Kyösti Mälkkie2227a22014-02-05 13:02:55 +020030#include <device/pci_ehci.h>
Frank Vibrans63e62b02011-02-14 18:38:14 +000031#include "lpc.h" /* lpc_read_resources */
Elyes HAOUASb0f19882018-06-09 11:59:00 +020032#include "SBPLATFORM.h" /* Platform Specific Definitions */
Frank Vibrans63e62b02011-02-14 18:38:14 +000033#include "cfg.h" /* sb800 Cimx configuration */
efdesign9805a89ab2011-06-20 17:38:49 -070034#include "chip.h" /* struct southbridge_amd_cimx_sb800_config */
Kerry Shefeed3292011-08-18 18:03:44 +080035#include "sb_cimx.h" /* AMD CIMX wrapper entries */
Dave Frodin23023a52012-11-13 07:09:12 -070036#include "smbus.h"
Martin Rothe899e512012-12-05 16:07:11 -070037#include "fan.h"
Tobias Diedrichd8a2c1f2017-02-20 02:46:19 +010038#include "pci_devs.h"
Stefan Reinauer13e41822015-04-27 14:02:36 -070039#include <southbridge/amd/common/amd_pci_util.h>
Frank Vibrans63e62b02011-02-14 18:38:14 +000040
Frank Vibrans63e62b02011-02-14 18:38:14 +000041static AMDSBCFG sb_late_cfg; //global, init in sb800_cimx_config
42static AMDSBCFG *sb_config = &sb_late_cfg;
43
Frank Vibrans63e62b02011-02-14 18:38:14 +000044/**
45 * @brief Entry point of Southbridge CIMx callout
46 *
47 * prototype UINT32 (*SBCIM_HOOK_ENTRY)(UINT32 Param1, UINT32 Param2, void* pConfig)
48 *
49 * @param[in] func Southbridge CIMx Function ID.
50 * @param[in] data Southbridge Input Data.
Martin Roth6355cbf2015-01-04 15:22:26 -070051 * @param[in] config Southbridge configuration structure pointer.
Frank Vibrans63e62b02011-02-14 18:38:14 +000052 *
53 */
Elyes HAOUAS251279c2018-07-08 12:41:56 +020054static u32 sb800_callout_entry(u32 func, u32 data, void *config)
Frank Vibrans63e62b02011-02-14 18:38:14 +000055{
56 u32 ret = 0;
Kerry Shefeed3292011-08-18 18:03:44 +080057 printk(BIOS_DEBUG, "SB800 - Late.c - %s - Start.\n", __func__);
Frank Vibrans63e62b02011-02-14 18:38:14 +000058 switch (func) {
59 case CB_SBGPP_RESET_ASSERT:
Frank Vibrans63e62b02011-02-14 18:38:14 +000060 break;
61
62 case CB_SBGPP_RESET_DEASSERT:
Frank Vibrans63e62b02011-02-14 18:38:14 +000063 break;
64
65 case IMC_FIRMWARE_FAIL:
66 break;
67
68 default:
69 break;
70 }
71
Kerry Shefeed3292011-08-18 18:03:44 +080072 printk(BIOS_DEBUG, "SB800 - Late.c - %s - End.\n", __func__);
Frank Vibrans63e62b02011-02-14 18:38:14 +000073 return ret;
74}
75
Kerry Sheh0e6344e2011-10-12 11:42:59 +080076#define HOST_CAP 0x00 /* host capabilities */
77#define HOST_CTL 0x04 /* global host control */
78#define HOST_IRQ_STAT 0x08 /* interrupt status */
79#define HOST_PORTS_IMPL 0x0c /* bitmap of implemented ports */
80
81#define HOST_CTL_AHCI_EN (1 << 31) /* AHCI enabled */
82static void ahci_raid_init(struct device *dev)
83{
84 u8 irq = 0;
Stefan Reinauer12bce3f2015-06-18 01:17:38 -070085 void *bar5;
86 u32 caps, ports, val;
Kerry Sheh0e6344e2011-10-12 11:42:59 +080087
88 val = pci_read_config16(dev, PCI_CLASS_DEVICE);
89 if (val == PCI_CLASS_STORAGE_SATA) {
90 printk(BIOS_DEBUG, "AHCI controller ");
91 } else if (val == PCI_CLASS_STORAGE_RAID) {
92 printk(BIOS_DEBUG, "RAID controller ");
93 } else {
94 printk(BIOS_WARNING, "device class:%x, neither in ahci or raid mode\n", val);
95 return;
96 }
97
98 irq = pci_read_config8(dev, PCI_INTERRUPT_LINE);
Stefan Reinauer12bce3f2015-06-18 01:17:38 -070099 bar5 = (void *)(uintptr_t)pci_read_config32(dev, PCI_BASE_ADDRESS_5);
100 printk(BIOS_DEBUG, "IOMEM base: %p, IRQ: 0x%X\n", bar5, irq);
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800101
Stefan Reinauer12bce3f2015-06-18 01:17:38 -0700102 caps = read32(bar5 + HOST_CAP);
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800103 caps = (caps & 0x1F) + 1;
Stefan Reinauer12bce3f2015-06-18 01:17:38 -0700104 ports= read32(bar5 + HOST_PORTS_IMPL);
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800105 printk(BIOS_DEBUG, "Number of Ports: 0x%x, Port implemented(bit map): 0x%x\n", caps, ports);
106
107 /* make sure ahci is enabled */
Stefan Reinauer12bce3f2015-06-18 01:17:38 -0700108 val = read32(bar5 + HOST_CTL);
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800109 if (!(val & HOST_CTL_AHCI_EN)) {
Stefan Reinauer12bce3f2015-06-18 01:17:38 -0700110 write32(bar5 + HOST_CTL, val | HOST_CTL_AHCI_EN);
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800111 }
112
113 dev->command |= PCI_COMMAND_MASTER;
114 pci_write_config8(dev, PCI_COMMAND, dev->command);
115 printk(BIOS_DEBUG, "AHCI/RAID controller initialized\n");
116}
Frank Vibrans63e62b02011-02-14 18:38:14 +0000117
118static struct pci_operations lops_pci = {
Kerry Shefeed3292011-08-18 18:03:44 +0800119 .set_subsystem = pci_dev_set_subsystem,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000120};
121
Elyes HAOUAS1a4abb72018-05-19 16:49:20 +0200122static void lpc_init(struct device *dev)
zbao366f0fc2012-08-03 16:58:53 +0800123{
124 printk(BIOS_DEBUG, "SB800 - Late.c - lpc_init - Start.\n");
125
Gabe Black03abaee212014-04-30 21:31:44 -0700126 cmos_check_update_date();
zbao366f0fc2012-08-03 16:58:53 +0800127
Mike Loptienac529b12013-02-22 13:18:31 -0700128 /* Initialize the real time clock.
Gabe Blackb3f08c62014-04-30 17:12:25 -0700129 * The 0 argument tells cmos_init not to
Mike Loptienac529b12013-02-22 13:18:31 -0700130 * update CMOS unless it is invalid.
Gabe Blackb3f08c62014-04-30 17:12:25 -0700131 * 1 tells cmos_init to always initialize the CMOS.
Mike Loptienac529b12013-02-22 13:18:31 -0700132 */
Gabe Blackb3f08c62014-04-30 17:12:25 -0700133 cmos_init(0);
Mike Loptienac529b12013-02-22 13:18:31 -0700134
Edward O'Callaghane61dd0f2014-05-06 23:53:09 +1000135 setup_i8259(); /* Initialize i8259 pic */
136 setup_i8254(); /* Initialize i8254 timers */
137
zbao366f0fc2012-08-03 16:58:53 +0800138 printk(BIOS_DEBUG, "SB800 - Late.c - lpc_init - End.\n");
139}
140
Vladimir Serbinenko2a19fb12014-10-02 20:09:19 +0200141unsigned long acpi_fill_mcfg(unsigned long current)
142{
143 /* Just a dummy */
144 return current;
145}
146
Aaron Durbinaa090cb2017-09-13 16:01:52 -0600147static const char *lpc_acpi_name(const struct device *dev)
Tobias Diedrichd8a2c1f2017-02-20 02:46:19 +0100148{
149 if (dev->path.type != DEVICE_PATH_PCI)
150 return NULL;
151
152 switch (dev->path.pci.devfn) {
153 /* DSDT: acpi/lpc.asl */
154 case LPC_DEVFN:
155 return "LIBR";
156 }
157
158 return NULL;
159}
160
Frank Vibrans63e62b02011-02-14 18:38:14 +0000161static struct device_operations lpc_ops = {
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200162 .read_resources = lpc_read_resources,
163 .set_resources = lpc_set_resources,
164 .enable_resources = pci_dev_enable_resources,
Vladimir Serbinenko83f81ca2014-11-09 13:30:50 +0100165#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
Vladimir Serbinenko2a19fb12014-10-02 20:09:19 +0200166 .write_acpi_tables = acpi_write_hpet,
167#endif
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200168 .init = lpc_init,
169 .scan_bus = scan_lpc_bus,
170 .ops_pci = &lops_pci,
Tobias Diedrichd8a2c1f2017-02-20 02:46:19 +0100171 .acpi_name = lpc_acpi_name,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000172};
173
174static const struct pci_driver lpc_driver __pci_driver = {
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200175 .ops = &lpc_ops,
176 .vendor = PCI_VENDOR_ID_ATI,
177 .device = PCI_DEVICE_ID_ATI_SB800_LPC,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000178};
179
Frank Vibrans63e62b02011-02-14 18:38:14 +0000180static struct device_operations sata_ops = {
181 .read_resources = pci_dev_read_resources,
182 .set_resources = pci_dev_set_resources,
Kerry Shefeed3292011-08-18 18:03:44 +0800183 .enable_resources = pci_dev_enable_resources,
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800184 .init = ahci_raid_init,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000185 .scan_bus = 0,
186 .ops_pci = &lops_pci,
187};
188
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800189static const struct pci_driver ahci_driver __pci_driver = {
Frank Vibrans63e62b02011-02-14 18:38:14 +0000190 .ops = &sata_ops,
191 .vendor = PCI_VENDOR_ID_ATI,
Scott Duplichanf191c722011-05-15 21:38:08 +0000192 .device = PCI_DEVICE_ID_ATI_SB800_SATA_AHCI,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000193};
194
Kerry Sheh0e6344e2011-10-12 11:42:59 +0800195static const struct pci_driver raid_driver __pci_driver = {
196 .ops = &sata_ops,
197 .vendor = PCI_VENDOR_ID_ATI,
198 .device = PCI_DEVICE_ID_ATI_SB800_SATA_RAID,
199};
200static const struct pci_driver raid5_driver __pci_driver = {
201 .ops = &sata_ops,
202 .vendor = PCI_VENDOR_ID_ATI,
203 .device = PCI_DEVICE_ID_ATI_SB800_SATA_RAID5,
204};
205
Frank Vibrans63e62b02011-02-14 18:38:14 +0000206static struct device_operations usb_ops = {
Kyösti Mälkkifb387df2013-06-07 22:16:52 +0300207 .read_resources = pci_ehci_read_resources,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000208 .set_resources = pci_dev_set_resources,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000209 .enable_resources = pci_dev_enable_resources,
Kerry Shefeed3292011-08-18 18:03:44 +0800210 .init = 0,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000211 .scan_bus = 0,
212 .ops_pci = &lops_pci,
213};
214
215/*
216 * The pci id of usb ctrl 0 and 1 are the same.
217 */
218static const struct pci_driver usb_ohci123_driver __pci_driver = {
219 .ops = &usb_ops,
220 .vendor = PCI_VENDOR_ID_ATI,
221 .device = PCI_DEVICE_ID_ATI_SB800_USB_18_0, /* OHCI-USB1, OHCI-USB2, OHCI-USB3 */
222};
223
224static const struct pci_driver usb_ehci123_driver __pci_driver = {
225 .ops = &usb_ops,
226 .vendor = PCI_VENDOR_ID_ATI,
227 .device = PCI_DEVICE_ID_ATI_SB800_USB_18_2, /* EHCI-USB1, EHCI-USB2, EHCI-USB3 */
228};
229
230static const struct pci_driver usb_ohci4_driver __pci_driver = {
231 .ops = &usb_ops,
232 .vendor = PCI_VENDOR_ID_ATI,
233 .device = PCI_DEVICE_ID_ATI_SB800_USB_20_5, /* OHCI-USB4 */
234};
235
236
Frank Vibrans63e62b02011-02-14 18:38:14 +0000237static struct device_operations azalia_ops = {
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200238 .read_resources = pci_dev_read_resources,
239 .set_resources = pci_dev_set_resources,
240 .enable_resources = pci_dev_enable_resources,
241 .init = 0,
242 .scan_bus = 0,
243 .ops_pci = &lops_pci,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000244};
245
246static const struct pci_driver azalia_driver __pci_driver = {
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200247 .ops = &azalia_ops,
248 .vendor = PCI_VENDOR_ID_ATI,
249 .device = PCI_DEVICE_ID_ATI_SB800_HDA,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000250};
251
252
Frank Vibrans63e62b02011-02-14 18:38:14 +0000253static struct device_operations gec_ops = {
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200254 .read_resources = pci_dev_read_resources,
255 .set_resources = pci_dev_set_resources,
256 .enable_resources = pci_dev_enable_resources,
257 .init = 0,
258 .scan_bus = 0,
259 .ops_pci = &lops_pci,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000260};
261
262static const struct pci_driver gec_driver __pci_driver = {
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200263 .ops = &gec_ops,
264 .vendor = PCI_VENDOR_ID_ATI,
265 .device = PCI_DEVICE_ID_ATI_SB800_GEC,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000266};
267
Kerry She3e706b62011-06-24 22:52:15 +0800268/**
Kyösti Mälkki41cd0472015-02-07 11:20:54 +0200269 * Fill build time defaults.
270 */
271static void sb800_init(void *chip_info)
272{
Kyösti Mälkki1498efe2017-03-09 16:25:24 +0200273 printk(BIOS_DEBUG, "SB800: %s\n", __func__);
Kyösti Mälkki41cd0472015-02-07 11:20:54 +0200274 sb_config->StdHeader.CALLBACK.CalloutPtr = sb800_callout_entry;
275 sb800_cimx_config(sb_config);
Kyösti Mälkki24501ca2015-02-07 17:38:45 +0200276
Paul Menzel114a9482015-10-25 22:27:42 +0100277 /* Initially enable all GPP ports 0 to 3 */
Kyösti Mälkki24501ca2015-02-07 17:38:45 +0200278 abcfg_reg(0xc0, 0x01FF, 0x0F4);
Kyösti Mälkki41cd0472015-02-07 11:20:54 +0200279}
280
281/**
Kerry Shefeed3292011-08-18 18:03:44 +0800282 * South Bridge CIMx ramstage entry point wrapper.
283 */
284void sb_Before_Pci_Init(void)
285{
Kyösti Mälkki1498efe2017-03-09 16:25:24 +0200286 printk(BIOS_DEBUG, "SB800: %s\n", __func__);
Kerry Shefeed3292011-08-18 18:03:44 +0800287 sb_config->StdHeader.Func = SB_BEFORE_PCI_INIT;
288 AmdSbDispatcher(sb_config);
289}
290
291void sb_After_Pci_Init(void)
292{
Kyösti Mälkki1498efe2017-03-09 16:25:24 +0200293 printk(BIOS_DEBUG, "SB800: %s\n", __func__);
Kerry Shefeed3292011-08-18 18:03:44 +0800294 sb_config->StdHeader.Func = SB_AFTER_PCI_INIT;
295 AmdSbDispatcher(sb_config);
296}
297
298void sb_Mid_Post_Init(void)
299{
Kyösti Mälkki1498efe2017-03-09 16:25:24 +0200300 printk(BIOS_DEBUG, "SB800: %s\n", __func__);
Kerry Shefeed3292011-08-18 18:03:44 +0800301 sb_config->StdHeader.Func = SB_MID_POST_INIT;
302 AmdSbDispatcher(sb_config);
303}
304
305void sb_Late_Post(void)
306{
Kyösti Mälkki1498efe2017-03-09 16:25:24 +0200307 printk(BIOS_DEBUG, "SB800: %s\n", __func__);
Kerry Shefeed3292011-08-18 18:03:44 +0800308 sb_config->StdHeader.Func = SB_LATE_POST_INIT;
309 AmdSbDispatcher(sb_config);
310}
311
zbao9bcdbf82012-04-05 13:18:49 +0800312void sb_Before_Pci_Restore_Init(void)
313{
Kyösti Mälkki1498efe2017-03-09 16:25:24 +0200314 printk(BIOS_DEBUG, "SB800: %s\n", __func__);
zbao9bcdbf82012-04-05 13:18:49 +0800315 sb_config->StdHeader.Func = SB_BEFORE_PCI_RESTORE_INIT;
316 AmdSbDispatcher(sb_config);
317}
318
319void sb_After_Pci_Restore_Init(void)
320{
Kyösti Mälkki1498efe2017-03-09 16:25:24 +0200321 printk(BIOS_DEBUG, "SB800: %s\n", __func__);
zbao9bcdbf82012-04-05 13:18:49 +0800322 sb_config->StdHeader.Func = SB_AFTER_PCI_RESTORE_INIT;
323 AmdSbDispatcher(sb_config);
324}
Kerry Shefeed3292011-08-18 18:03:44 +0800325
Mike Loptienc93a75a2014-06-06 15:16:29 -0600326/*
327 * Update the PCI devices with a valid IRQ number
328 * that is set in the mainboard PCI_IRQ structures.
329 */
330static void set_pci_irqs(void *unused)
331{
332 /* Write PCI_INTR regs 0xC00/0xC01 */
333 write_pci_int_table();
334
335 /* Write IRQs for all devicetree enabled devices */
336 write_pci_cfg_irqs();
337}
338
339/*
340 * Hook this function into the PCI state machine
341 * on entry into BS_DEV_ENABLE.
342 */
Aaron Durbin9ef9d852015-03-16 17:30:09 -0500343BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, set_pci_irqs, NULL);
Mike Loptienc93a75a2014-06-06 15:16:29 -0600344
Kerry Shefeed3292011-08-18 18:03:44 +0800345/**
Frank Vibrans63e62b02011-02-14 18:38:14 +0000346 * @brief SB Cimx entry point sbBeforePciInit wrapper
347 */
Elyes HAOUAS1a4abb72018-05-19 16:49:20 +0200348static void sb800_enable(struct device *dev)
Frank Vibrans63e62b02011-02-14 18:38:14 +0000349{
efdesign9805a89ab2011-06-20 17:38:49 -0700350 struct southbridge_amd_cimx_sb800_config *sb_chip =
351 (struct southbridge_amd_cimx_sb800_config *)(dev->chip_info);
Frank Vibrans63e62b02011-02-14 18:38:14 +0000352
Frank Vibrans63e62b02011-02-14 18:38:14 +0000353 switch (dev->path.pci.devfn) {
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300354 case PCI_DEVFN(0x11, 0): /* 0:11.0 SATA */
Frank Vibrans63e62b02011-02-14 18:38:14 +0000355 if (dev->enabled) {
Elyes HAOUASb0f19882018-06-09 11:59:00 +0200356 sb_config->SATAMODE.SataMode.SataController = CIMX_OPTION_ENABLED;
Elyes HAOUAS0f8b8d92019-01-03 10:23:28 +0100357 if (sb_chip->boot_switch_sata_ide == 1)
Frank Vibrans63e62b02011-02-14 18:38:14 +0000358 sb_config->SATAMODE.SataMode.SataIdeCombMdPriSecOpt = 0; //0 -IDE as primary.
Elyes HAOUAS0f8b8d92019-01-03 10:23:28 +0100359 else if (sb_chip->boot_switch_sata_ide == 0)
Frank Vibrans63e62b02011-02-14 18:38:14 +0000360 sb_config->SATAMODE.SataMode.SataIdeCombMdPriSecOpt = 1; //1 -IDE as secondary.
361 } else {
Elyes HAOUASb0f19882018-06-09 11:59:00 +0200362 sb_config->SATAMODE.SataMode.SataController = CIMX_OPTION_DISABLED;
Frank Vibrans63e62b02011-02-14 18:38:14 +0000363 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000364 break;
365
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300366 case PCI_DEVFN(0x14, 0): /* 0:14:0 SMBUS */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800367 clear_ioapic(VIO_APIC_VADDR);
Kyösti Mälkki35546de2014-04-17 15:07:32 +0300368 /* Assign the ioapic ID the next available number after the processor core local APIC IDs */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800369 setup_ioapic(VIO_APIC_VADDR, CONFIG_MAX_CPUS);
Frank Vibrans63e62b02011-02-14 18:38:14 +0000370 break;
371
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300372 case PCI_DEVFN(0x14, 1): /* 0:14:1 IDE */
Frank Vibrans63e62b02011-02-14 18:38:14 +0000373 break;
374
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300375 case PCI_DEVFN(0x14, 2): /* 0:14:2 HDA */
Frank Vibrans63e62b02011-02-14 18:38:14 +0000376 if (dev->enabled) {
Elyes HAOUAS0f8b8d92019-01-03 10:23:28 +0100377 if (sb_config->AzaliaController == AZALIA_DISABLE) {
Elyes HAOUASb0f19882018-06-09 11:59:00 +0200378 sb_config->AzaliaController = AZALIA_AUTO;
Frank Vibrans63e62b02011-02-14 18:38:14 +0000379 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000380 } else {
Elyes HAOUASb0f19882018-06-09 11:59:00 +0200381 sb_config->AzaliaController = AZALIA_DISABLE;
Frank Vibrans63e62b02011-02-14 18:38:14 +0000382 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000383 break;
384
385
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300386 case PCI_DEVFN(0x14, 3): /* 0:14:3 LPC */
Martin Rothe899e512012-12-05 16:07:11 -0700387 /* Initialize the fans */
Martin Roth083504b2017-06-24 21:30:14 -0600388#if IS_ENABLED(CONFIG_SB800_IMC_FAN_CONTROL)
Martin Rothe899e512012-12-05 16:07:11 -0700389 init_sb800_IMC_fans(dev);
Martin Roth083504b2017-06-24 21:30:14 -0600390#elif IS_ENABLED(CONFIG_SB800_MANUAL_FAN_CONTROL)
Martin Rothe899e512012-12-05 16:07:11 -0700391 init_sb800_MANUAL_fans(dev);
392#endif
Frank Vibrans63e62b02011-02-14 18:38:14 +0000393 break;
394
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300395 case PCI_DEVFN(0x14, 4): /* 0:14:4 PCI */
Kyösti Mälkki486c05f2015-01-17 18:08:40 +0200396 /* PcibConfig [PM_Reg: EAh], PCIDisable [Bit0]
397 * 'PCIDisable' set to 0 to enable P2P bridge.
398 * 'PCIDisable' set to 1 to disable P2P bridge and enable PCI interface pins
399 * to function as GPIO {GPIO 35:0}.
400 */
Kyösti Mälkki0b87bb72014-11-11 17:22:23 +0200401 if (!sb_chip->disconnect_pcib && dev->enabled)
Kyösti Mälkki486c05f2015-01-17 18:08:40 +0200402 RWMEM(ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REGEA, AccWidthUint8, ~BIT0, 0);
403 else
404 RWMEM(ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REGEA, AccWidthUint8, ~BIT0, BIT0);
Frank Vibrans63e62b02011-02-14 18:38:14 +0000405 break;
406
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300407 case PCI_DEVFN(0x14, 6): /* 0:14:6 GEC */
Frank Vibrans63e62b02011-02-14 18:38:14 +0000408 if (dev->enabled) {
409 sb_config->GecConfig = 0;
Frank Vibrans63e62b02011-02-14 18:38:14 +0000410 } else {
411 sb_config->GecConfig = 1;
Frank Vibrans63e62b02011-02-14 18:38:14 +0000412 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000413 break;
414
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300415 case PCI_DEVFN(0x15, 0): /* 0:15:0 PCIe PortA */
Scott Duplichan8fed77a2011-06-18 10:46:45 -0500416 {
Elyes HAOUAS1a4abb72018-05-19 16:49:20 +0200417 struct device *device;
Paul Menzele4a016f2013-03-01 13:05:04 +0100418 for (device = dev; device; device = device->sibling) {
419 if ((device->path.pci.devfn & ~3) != PCI_DEVFN(0x15,0)) break;
Kerry Shefeed3292011-08-18 18:03:44 +0800420 sb_config->PORTCONFIG[device->path.pci.devfn & 3].PortCfg.PortPresent = device->enabled;
421 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000422
Kerry Shefeed3292011-08-18 18:03:44 +0800423 /*
424 * GPP_CFGMODE_X4000: PortA Lanes[3:0]
425 * GPP_CFGMODE_X2200: PortA Lanes[1:0], PortB Lanes[3:2]
426 * GPP_CFGMODE_X2110: PortA Lanes[1:0], PortB Lane2, PortC Lane3
427 * GPP_CFGMODE_X1111: PortA Lanes0, PortB Lane1, PortC Lane2, PortD Lane3
428 */
429 sb_config->GppLinkConfig = sb_chip->gpp_configuration;
Scott Duplichan8fed77a2011-06-18 10:46:45 -0500430 }
Kerry Shefeed3292011-08-18 18:03:44 +0800431 break;
432
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300433 case PCI_DEVFN(0x12, 0): /* 0:12:0 OHCI-USB1 */
Kerry Shefeed3292011-08-18 18:03:44 +0800434 sb_config->USBMODE.UsbMode.Ohci1 = dev->enabled;
435 break;
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300436 case PCI_DEVFN(0x12, 2): /* 0:12:2 EHCI-USB1 */
Kerry Shefeed3292011-08-18 18:03:44 +0800437 sb_config->USBMODE.UsbMode.Ehci1 = dev->enabled;
438 break;
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300439 case PCI_DEVFN(0x13, 0): /* 0:13:0 OHCI-USB2 */
Kerry Shefeed3292011-08-18 18:03:44 +0800440 sb_config->USBMODE.UsbMode.Ohci2 = dev->enabled;
441 break;
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300442 case PCI_DEVFN(0x13, 2): /* 0:13:2 EHCI-USB2 */
Kerry Shefeed3292011-08-18 18:03:44 +0800443 sb_config->USBMODE.UsbMode.Ehci2 = dev->enabled;
444 break;
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300445 case PCI_DEVFN(0x14, 5): /* 0:14:5 OHCI-USB4 */
Kerry Shefeed3292011-08-18 18:03:44 +0800446 sb_config->USBMODE.UsbMode.Ohci4 = dev->enabled;
447 break;
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300448 case PCI_DEVFN(0x16, 0): /* 0:16:0 OHCI-USB3 */
Kerry Shefeed3292011-08-18 18:03:44 +0800449 sb_config->USBMODE.UsbMode.Ohci3 = dev->enabled;
450 break;
Kyösti Mälkkidda0fc42018-05-20 14:17:19 +0300451 case PCI_DEVFN(0x16, 2): /* 0:16:2 EHCI-USB3 */
Kerry Shefeed3292011-08-18 18:03:44 +0800452 sb_config->USBMODE.UsbMode.Ehci3 = dev->enabled;
453
Kyösti Mälkki9de8ab92017-09-09 16:51:34 +0300454 /* FIXME: Find better callsites for these.
455 * call the CIMX entry at the last sb800 device,
Kerry Sheh75df1062011-10-10 19:19:46 +0800456 * so make sure the mainboard devicetree is complete
457 */
Kyösti Mälkkic551caa2014-06-20 12:31:23 +0300458 if (!acpi_is_wakeup_s3())
zbao9bcdbf82012-04-05 13:18:49 +0800459 sb_Before_Pci_Init();
460 else
461 sb_Before_Pci_Restore_Init();
Kerry Shefeed3292011-08-18 18:03:44 +0800462 break;
Frank Vibrans63e62b02011-02-14 18:38:14 +0000463
464 default:
465 break;
466 }
Frank Vibrans63e62b02011-02-14 18:38:14 +0000467}
468
efdesign9805a89ab2011-06-20 17:38:49 -0700469struct chip_operations southbridge_amd_cimx_sb800_ops = {
Frank Vibrans63e62b02011-02-14 18:38:14 +0000470 CHIP_NAME("ATI SB800")
Kyösti Mälkki41cd0472015-02-07 11:20:54 +0200471 .init = sb800_init,
Frank Vibrans63e62b02011-02-14 18:38:14 +0000472 .enable_dev = sb800_enable,
473};