summaryrefslogtreecommitdiff
path: root/src/northbridge/amd/cimx/rd890/early.c
blob: eab798d69eb22836dd219d505362f9be05ea908f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
 * This file is part of the coreboot project.
 *
 * Copyright (C) 2012 Advanced Micro Devices, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include <stdint.h>
#include "NbPlatform.h"
#include "rd890_cfg.h"
#include "nb_cimx.h"


/**
 * @brief disable GPP1 Port0,1, GPP2, GPP3a Port0,1,2,3,4,5, GPP3b
 *
 * SR5650/5670/5690 RD890 chipset, read pci config space hang at POR,
 * Disable all Pcie Bridges to work around It.
 */
void sr56x0_rd890_disable_pcie_bridge(void)
{
	u32			nb_dev;
	u32			mask;
	u32			val;
	AMD_NB_CONFIG_BLOCK	cfg_block;
	AMD_NB_CONFIG_BLOCK	*cfg_ptr = &cfg_block;
	AMD_NB_CONFIG		*nb_cfg  = &(cfg_block.Northbridges[0]);

        nb_cfg->ConfigPtr = &cfg_ptr;
	nb_dev = MAKE_SBDFO(0, 0x0, 0x0, 0x0, 0x0);
	val = (1 << 2) | (1 << 3); /*GPP1*/
	val |= (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 16) | (1 << 17); /*GPP3a*/
	val |= (1 << 18) | (1 << 19); /*GPP2*/
	val |= (1 << 20); /*GPP3b*/
	mask = ~val;
	LibNbPciIndexRMW(nb_dev | NB_MISC_INDEX, NB_MISC_REG0C,
			AccessS3SaveWidth32,
			mask,
			val,
			nb_cfg);
}


/**
 * @brief South Bridge CIMx romstage entry,
 *  wrapper of AmdPowerOnResetInit entry point.
 */
void nb_Poweron_Init(void)
{
	NB_CONFIG nb_cfg[MAX_NB_COUNT];
	HT_CONFIG ht_cfg[MAX_NB_COUNT];
	PCIE_CONFIG pcie_cfg[MAX_NB_COUNT];
	AMD_NB_CONFIG_BLOCK gConfig;
	AMD_NB_CONFIG_BLOCK *ConfigPtr = &gConfig;
	AGESA_STATUS status;

	printk(BIOS_DEBUG, "cimx/rd890 early.c %s() Start\n", __func__);
	CIMX_INIT_TRACE();
	CIMX_TRACE((BIOS_DEBUG, "NbPowerOnResetInit entry\n"));
	rd890_cimx_config(&gConfig, &nb_cfg[0], &ht_cfg[0], &pcie_cfg[0]);

	if (ConfigPtr->StandardHeader.CalloutPtr != NULL) {
		ConfigPtr->StandardHeader.CalloutPtr(CB_AmdSetNbPorConfig, 0, &gConfig);
	}

	status = AmdPowerOnResetInit(&gConfig);
	printk(BIOS_DEBUG, "cimx/rd890 early.c %s() End. return status=%x\n", __func__, status);
}

/**
 * @brief South Bridge CIMx romstage entry,
 *  wrapper of AmdHtInit entry point.
 */
void nb_Ht_Init(void)
{
	AGESA_STATUS status;
	NB_CONFIG nb_cfg[MAX_NB_COUNT];
	HT_CONFIG ht_cfg[MAX_NB_COUNT];
	PCIE_CONFIG pcie_cfg[MAX_NB_COUNT];
	AMD_NB_CONFIG_BLOCK gConfig;
	AMD_NB_CONFIG_BLOCK *ConfigPtr = &gConfig;
	u32 i;

	rd890_cimx_config(&gConfig, &nb_cfg[0], &ht_cfg[0], &pcie_cfg[0]);

	//Initialize HT structure
	LibSystemApiCall(AmdHtInitializer, &gConfig);
	for (i = 0; i < MAX_NB_COUNT; i ++) {
		if (ConfigPtr->StandardHeader.CalloutPtr != NULL) {
			ConfigPtr->StandardHeader.CalloutPtr(CB_AmdSetHtConfig, 0, (VOID*)&(gConfig.Northbridges[i]));
		}
	}

	status = LibSystemApiCall(AmdHtInit, &gConfig);
	printk(BIOS_DEBUG, "AmdHtInit status: %x\n", status);
}

void nb_S3_Init(void)
{
	//TODO
}