Frank Vibrans | 63e62b0 | 2011-02-14 18:38:14 +0000 | [diff] [blame] | 1 | /* |
| 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 Menzel | a46a712 | 2013-02-23 18:37:27 +0100 | [diff] [blame] | 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Frank Vibrans | 63e62b0 | 2011-02-14 18:38:14 +0000 | [diff] [blame] | 18 | */ |
| 19 | |
Frank Vibrans | 63e62b0 | 2011-02-14 18:38:14 +0000 | [diff] [blame] | 20 | #include <stdint.h> |
| 21 | #include <device/pci_ids.h> |
| 22 | #include <arch/io.h> /* inl, outl */ |
zbao | 9bcdbf8 | 2012-04-05 13:18:49 +0800 | [diff] [blame] | 23 | #include <arch/acpi.h> |
Frank Vibrans | 63e62b0 | 2011-02-14 18:38:14 +0000 | [diff] [blame] | 24 | #include "SBPLATFORM.h" |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 25 | #include "sb_cimx.h" |
Frank Vibrans | 63e62b0 | 2011-02-14 18:38:14 +0000 | [diff] [blame] | 26 | #include "cfg.h" /*sb800_cimx_config*/ |
zbao | 9bcdbf8 | 2012-04-05 13:18:49 +0800 | [diff] [blame] | 27 | #include "cbmem.h" |
Frank Vibrans | 63e62b0 | 2011-02-14 18:38:14 +0000 | [diff] [blame] | 28 | |
Frank Vibrans | 63e62b0 | 2011-02-14 18:38:14 +0000 | [diff] [blame] | 29 | /** |
| 30 | * @brief Get SouthBridge device number |
| 31 | * @param[in] bus target bus number |
| 32 | * @return southbridge device number |
| 33 | */ |
| 34 | u32 get_sbdn(u32 bus) |
| 35 | { |
| 36 | device_t dev; |
| 37 | |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 38 | printk(BIOS_DEBUG, "SB800 - %s - %s - Start.\n", __FILE__, __func__); |
Frank Vibrans | 63e62b0 | 2011-02-14 18:38:14 +0000 | [diff] [blame] | 39 | //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 She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 44 | printk(BIOS_DEBUG, "SB800 - %s - %s - End.\n", __FILE__, __func__); |
Frank Vibrans | 63e62b0 | 2011-02-14 18:38:14 +0000 | [diff] [blame] | 45 | return (dev >> 15) & 0x1f; |
| 46 | } |
Frank Vibrans | 63e62b0 | 2011-02-14 18:38:14 +0000 | [diff] [blame] | 47 | |
| 48 | /** |
| 49 | * @brief South Bridge CIMx romstage entry, |
| 50 | * wrapper of sbPowerOnInit entry point. |
| 51 | */ |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 52 | void sb_Poweron_Init(void) |
Frank Vibrans | 63e62b0 | 2011-02-14 18:38:14 +0000 | [diff] [blame] | 53 | { |
| 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 Roth | d630c13 | 2014-12-17 09:14:17 -0700 | [diff] [blame^] | 61 | // VerifyImage() will fail, LocateImage() takes minutes to find the image. |
Frank Vibrans | 63e62b0 | 2011-02-14 18:38:14 +0000 | [diff] [blame] | 62 | sbPowerOnInit(&sb_early_cfg); |
| 63 | } |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 64 | |
| 65 | /** |
| 66 | * CIMX not set the clock to 48Mhz until sbBeforePciInit, |
| 67 | * coreboot may need to set this even more earlier |
| 68 | */ |
| 69 | void 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 Georgi | e166782 | 2012-05-05 15:29:32 +0200 | [diff] [blame] | 78 | #if CONFIG_HAVE_ACPI_RESUME |
zbao | 9bcdbf8 | 2012-04-05 13:18:49 +0800 | [diff] [blame] | 79 | int acpi_is_wakeup_early(void) |
| 80 | { |
| 81 | return (acpi_get_sleep_type() == 3); |
| 82 | } |
| 83 | #endif |