coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
early_reset.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <types.h>
4 #include <cf9_reset.h>
5 #include <device/pci_ops.h>
6 
7 #include "gm45.h"
8 
9 void gm45_early_reset(void/*const timings_t *const timings*/)
10 {
11  int ch, r;
12 
13  /* Reset DRAM power-up settings in CLKCFG (they are not
14  affected by system reset but may disrupt raminit). */
15  mchbar_clrsetbits32(CLKCFG_MCHBAR, 3 << 21, 1 << 3);
16 
17  /*\ Next settings are the real purpose of this function:
18  If these steps are not performed, reset results in power off. \*/
19 
20  /* Initialize some DRAM settings to 1 populated rank of 128MB. */
22  /* Configure DRAM control mode. */
24  (ch ? 0 : CxDRC0_RANKEN(0)));
27  ~(ch ? 0 : CxDRC1_NOTPOP(0)));
30  ~(ch ? 0 : CxDRC2_NOTPOP(0)));
31  /*if (timings && (timings->mem_clock == MEM_CLOCK_1067MT))
32  mchbar_setbits32(CxDRC2_MCHBAR(ch), CxDRC2_CLK1067MT);*/
33 
34  /* Program rank boundaries (CxDRBy). */
35  for (r = 0; r < RANKS_PER_CHANNEL; r += 2)
37  CxDRBy_BOUND_MB(r, 128) | CxDRBy_BOUND_MB(r + 1, 128));
38  }
39  /* Set DCC mode to no operation and do magic 0xf0 thing. */
41 
42  pci_and_config8(PCI_DEV(0, 0, 0), 0xf0, ~(1 << 2));
43 
44  pci_or_config8(PCI_DEV(0, 0, 0), 0xf0, (1 << 2));
45 
46  /* Normally, we would set this after successful raminit. */
47  mchbar_setbits32(DCC_MCHBAR, 1 << 19);
48 
49  system_reset();
50 }
void system_reset(void)
Definition: cf9_reset.c:37
void gm45_early_reset(void)
Definition: early_reset.c:9
#define mchbar_setbits32(addr, set)
Definition: fixed_bars.h:58
static __always_inline void mchbar_write32(const uintptr_t offset, const uint32_t value)
Definition: fixed_bars.h:36
static __always_inline void mchbar_clrsetbits32(uintptr_t offset, uint32_t clear, uint32_t set)
Definition: fixed_bars.h:51
static __always_inline uint32_t mchbar_read32(const uintptr_t offset)
Definition: fixed_bars.h:21
#define CxDRC0_MCHBAR(x)
Definition: gm45.h:280
#define CxDRBy_BOUND_MB(r, b)
Definition: gm45.h:277
#define DCC_CMD_MASK
Definition: gm45.h:244
#define CLKCFG_MCHBAR
Definition: gm45.h:229
#define DCC_CMD_NOP
Definition: gm45.h:245
#define CxDRC2_NOTPOP(r)
Definition: gm45.h:302
#define FOR_EACH_CHANNEL(idx)
Definition: gm45.h:136
#define CxDRBy_MCHBAR(x, r)
Definition: gm45.h:274
#define RANKS_PER_CHANNEL
Definition: gm45.h:141
#define CxDRC0_RANKEN(r)
Definition: gm45.h:285
#define CxDRC2_NOTPOP_MASK
Definition: gm45.h:303
#define CxDRC0_RANKEN_MASK
Definition: gm45.h:286
#define CxDRC1_MCHBAR(x)
Definition: gm45.h:292
#define CxDRC1_NOTPOP_MASK
Definition: gm45.h:298
#define DCC_MCHBAR
Definition: gm45.h:240
#define CxDRC1_NOTPOP(r)
Definition: gm45.h:297
#define CxDRC2_MCHBAR(x)
Definition: gm45.h:301
static __always_inline void pci_and_config8(const struct device *dev, u16 reg, u8 andmask)
Definition: pci_ops.h:136
static __always_inline void pci_or_config8(const struct device *dev, u16 reg, u8 ormask)
Definition: pci_ops.h:169
static struct dramc_channel const ch[2]
#define PCI_DEV(SEGBUS, DEV, FN)
Definition: pci_type.h:14