blob: 7492f9942da7ee84417c297fb2200a40c33c7af0 [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.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
Paul Menzela46a7122013-02-23 18:37:27 +010017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Frank Vibrans63e62b02011-02-14 18:38:14 +000018 */
19
Frank Vibrans63e62b02011-02-14 18:38:14 +000020#include <stdint.h>
21#include <device/pci_ids.h>
22#include <arch/io.h> /* inl, outl */
zbao9bcdbf82012-04-05 13:18:49 +080023#include <arch/acpi.h>
Frank Vibrans63e62b02011-02-14 18:38:14 +000024#include "SBPLATFORM.h"
Kerry Shefeed3292011-08-18 18:03:44 +080025#include "sb_cimx.h"
Frank Vibrans63e62b02011-02-14 18:38:14 +000026#include "cfg.h" /*sb800_cimx_config*/
zbao9bcdbf82012-04-05 13:18:49 +080027#include "cbmem.h"
Frank Vibrans63e62b02011-02-14 18:38:14 +000028
Frank Vibrans63e62b02011-02-14 18:38:14 +000029/**
30 * @brief Get SouthBridge device number
31 * @param[in] bus target bus number
32 * @return southbridge device number
33 */
34u32 get_sbdn(u32 bus)
35{
36 device_t dev;
37
Kerry Shefeed3292011-08-18 18:03:44 +080038 printk(BIOS_DEBUG, "SB800 - %s - %s - Start.\n", __FILE__, __func__);
Frank Vibrans63e62b02011-02-14 18:38:14 +000039 //dev = PCI_DEV(bus, 0x14, 0);
40 dev = pci_locate_device_on_bus(
41 PCI_ID(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SB800_SM),
42 bus);
43
Kerry Shefeed3292011-08-18 18:03:44 +080044 printk(BIOS_DEBUG, "SB800 - %s - %s - End.\n", __FILE__, __func__);
Frank Vibrans63e62b02011-02-14 18:38:14 +000045 return (dev >> 15) & 0x1f;
46}
Frank Vibrans63e62b02011-02-14 18:38:14 +000047
48/**
49 * @brief South Bridge CIMx romstage entry,
50 * wrapper of sbPowerOnInit entry point.
51 */
Kerry Shefeed3292011-08-18 18:03:44 +080052void sb_Poweron_Init(void)
Frank Vibrans63e62b02011-02-14 18:38:14 +000053{
54 AMDSBCFG sb_early_cfg;
55
56 sb800_cimx_config(&sb_early_cfg);
57 //sb_early_cfg.StdHeader.Func = SB_POWERON_INIT;
58 //AmdSbDispatcher(&sb_early_cfg);
59 //TODO
60 //AMD_IMAGE_HEADER was missing, when using AmdSbDispatcher,
Martin Rothd630c132014-12-17 09:14:17 -070061 // VerifyImage() will fail, LocateImage() takes minutes to find the image.
Frank Vibrans63e62b02011-02-14 18:38:14 +000062 sbPowerOnInit(&sb_early_cfg);
63}
Kerry Shefeed3292011-08-18 18:03:44 +080064
65/**
66 * CIMX not set the clock to 48Mhz until sbBeforePciInit,
67 * coreboot may need to set this even more earlier
68 */
69void sb800_clk_output_48Mhz(void)
70{
71 /* AcpiMMioDecodeEn */
72 RWPMIO(SB_PMIOA_REG24, AccWidthUint8, ~(BIT0 + BIT1), BIT0);
73
74 *(volatile u32 *)(ACPI_MMIO_BASE + MISC_BASE + 0x40) &= ~((1 << 0) | (1 << 2)); /* 48Mhz */
75 *(volatile u32 *)(ACPI_MMIO_BASE + MISC_BASE + 0x40) |= 1 << 1; /* 48Mhz */
76}
77
Patrick Georgie1667822012-05-05 15:29:32 +020078#if CONFIG_HAVE_ACPI_RESUME
zbao9bcdbf82012-04-05 13:18:49 +080079int acpi_is_wakeup_early(void)
80{
81 return (acpi_get_sleep_type() == 3);
82}
83#endif