~funderscore blog cgit wiki get in touch
aboutsummaryrefslogtreecommitdiff
blob: dc6cdc35d15ca2b538914d74881cc8d4618e0ed1 (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
// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright (c) Aspeed Technology Inc.
 */
#include <common.h>
#include <dm.h>
#include <ram.h>
#include <timer.h>
#include <asm/io.h>
#include <asm/arch/timer.h>
#include <linux/bitops.h>
#include <linux/err.h>
#include <dm/uclass.h>
#include <asm/arch/scu_ast2600.h>
#include <asm/global_data.h>

DECLARE_GLOBAL_DATA_PTR;

/* Memory Control registers */
#define MCR_BASE			0x1e6e0000
#define MCR_CONF			(MCR_BASE + 0x004)

/* bit fields of MCR_CONF */
#define MCR_CONF_ECC_EN			BIT(7)
#define MCR_CONF_VGA_MEMSZ_MASK		GENMASK(3, 2)
#define MCR_CONF_VGA_MEMSZ_SHIFT	2
#define MCR_CONF_MEMSZ_MASK		GENMASK(1, 0)
#define MCR_CONF_MEMSZ_SHIFT		0

int dram_init(void)
{
	int ret;
	struct udevice *dev;
	struct ram_info ram;

	ret = uclass_get_device(UCLASS_RAM, 0, &dev);
	if (ret) {
		debug("cannot get DRAM driver\n");
		return ret;
	}

	ret = ram_get_info(dev, &ram);
	if (ret) {
		debug("cannot get DRAM information\n");
		return ret;
	}

	gd->ram_size = ram.size;
	return 0;
}

int board_init(void)
{
	int i = 0, rc;
	struct udevice *dev;

	gd->bd->bi_boot_params = CFG_SYS_SDRAM_BASE + 0x100;

	while (1) {
		rc = uclass_get_device(UCLASS_MISC, i++, &dev);
		if (rc)
			break;
	}

	return 0;
}

void board_add_ram_info(int use_default)
{
	int rc;
	uint32_t conf;
	uint32_t ecc, act_size, vga_rsvd;
	struct udevice *scu_dev;
	struct ast2600_scu *scu;

	rc = uclass_get_device_by_driver(UCLASS_CLK,
					 DM_DRIVER_GET(aspeed_ast2600_scu), &scu_dev);
	if (rc) {
		debug("%s: cannot find SCU device, rc=%d\n", __func__, rc);
		return;
	}

	scu = devfdt_get_addr_ptr(scu_dev);
	if (IS_ERR_OR_NULL(scu)) {
		debug("%s: cannot get SCU address pointer\n", __func__);
		return;
	}

	conf = readl(MCR_CONF);

	ecc = conf & MCR_CONF_ECC_EN;
	act_size = 0x100 << ((conf & MCR_CONF_MEMSZ_MASK) >> MCR_CONF_MEMSZ_SHIFT);
	vga_rsvd = 0x8 << ((conf & MCR_CONF_VGA_MEMSZ_MASK) >> MCR_CONF_VGA_MEMSZ_SHIFT);

	/* no VGA reservation if efuse VGA disable bit is set */
	if (readl(scu->efuse) & SCU_EFUSE_DIS_VGA)
		vga_rsvd = 0;

	printf(" (capacity:%d MiB, VGA:%d MiB), ECC %s", act_size,
	       vga_rsvd, (ecc) ? "on" : "off");
}

void enable_caches(void)
{
	/* get rid of the warning message */
}