summaryrefslogtreecommitdiff
path: root/src/soc/mediatek/common/lastbus_v1.c
blob: cf3fb1db39f00c619c2e998540921a28f3eec7a5 (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
/* SPDX-License-Identifier: GPL-2.0-only */

#include <console/console.h>
#include <device/mmio.h>
#include <soc/addressmap.h>
#include <soc/lastbus_v1.h>

static unsigned long preisys_dump_offset[] = {
	0x500, /* PERIBUS_DBG0 */
	0x504, /* PERIBUS_DBG1 */
	0x508, /* PERIBUS_DBG2 */
	0x50C, /* PERIBUS_DBG3 */
	0x510, /* PERIBUS_DBG4 */
	0x514, /* PERIBUS_DBG5 */
	0x518, /* PERIBUS_DBG6 */
	0x51C, /* PERIBUS_DBG7 */
	0x520, /* PERIBUS_DBG8 */
	0x524, /* PERIBUS_DBG9 */
	0x528, /* PERIBUS_DBG10 */
	0x52C, /* PERIBUS_DBG11 */
	0x530, /* PERIBUS_DBG12 */
	0x534, /* PERIBUS_DBG13 */
	0x538, /* PERIBUS_DBG14 */
	0x53C, /* PERIBUS_DBG15 */
	0x580, /* PERIBUS_DBG16 */
	0x584, /* PERIBUS_DBG17 */
};

static void lastbus_setup(void)
{
	/* peri lastbus init */
	write32p(PERICFG_BASE + BUS_PERI_R0, PERISYS_TIMEOUT);
	write32p(PERICFG_BASE + BUS_PERI_R1, PERISYS_ENABLE);

	/* infra lastbus init */
	write32p(INFRACFG_AO_BASE + BUS_INFRA_CTRL, INFRASYS_CONFIG);
}

static void lastbus_dump(void)
{
	unsigned int i;
	uintptr_t reg;

	if (read32p(INFRACFG_AO_BASE + BUS_INFRA_CTRL) & 0x1) {
		printk(BIOS_DEBUG, "** Dump lastbus infra debug registers start **\n");
		for (i = 0; i < INFRA_NUM; i++) {
			reg = INFRACFG_AO_BASE + BUS_INFRA_SNAPSHOT + 4 * i;
			printk(BIOS_DEBUG, "%08x\n", read32p(reg));
		}
	}

	if (read32p(PERICFG_BASE + BUS_PERI_R1) & 0x1) {
		printk(BIOS_DEBUG, "** Dump lastbus peri debug registers start **\n");
		for (i = 0; i < PERI_NUM; i++) {
			reg = PERICFG_BASE + preisys_dump_offset[i];
			printk(BIOS_DEBUG, "%08x\n", read32p(reg));
		}
	}
}

void lastbus_init(void)
{
	lastbus_dump();
	lastbus_setup();
}