summaryrefslogtreecommitdiff
path: root/plat/marvell/a8k-p/common/plat_ble_setup.c
blob: 7e8266fa1dcf1cd6d71d074ad8cb0488b0659400 (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
/*
 * Copyright (C) 2017 Marvell International Ltd.
 *
 * SPDX-License-Identifier:	BSD-3-Clause
 * https://spdx.org/licenses
 */

#include <ap810_setup.h>
#include <a8kp_plat_def.h>
#include <debug.h>
#include <mmio.h>
#include <plat_marvell.h>
#include <plat_def.h>
#include <plat_dram.h>
#include <ap810_init_clocks.h>

/* Read Frequency Value from MPPS 15-17 and save
 * to scratch-pad Register as a temporary solution
 * in AP810 A0 revision to cover the bug in sampled-at-reset
 * register.
*/
static void ble_read_cpu_freq(void)
{
	unsigned int mpp_address, val;

	/* Relevant for A0 only */
	if (ap810_rev_id_get(MVEBU_AP0) != MVEBU_AP810_REV_ID_A0)
		return;

	/* TODO: add errata for this WA, we can't read from sample at reset
	 * register.
	 */
	mpp_address = MVEBU_AP_GPIO_DATA_IN(0);
	val = mmio_read_32(mpp_address);
	val = (val >> 15) & 0x7;
	INFO("sar option read from MPPs = 0x%x\n", val);
	mmio_write_32(SCRATCH_PAD_ADDR(0, 1), val);
}

int ble_plat_setup(int *skip)
{
	int ret = 0;

#if !PALLADIUM
	/* SW WA for AP link bring-up over JTAG connection */
	if ((ap810_get_ap_count() != 1) &&
	    (ap810_rev_id_get(MVEBU_AP0) == MVEBU_AP810_REV_ID_A0))
		jtag_init_ihb_dual_ap();
#endif

	ble_read_cpu_freq();

	/* Initialize the enumeration algorithm in BLE stage to
	 * enable access to another APs.
	 */
	ap810_enumeration_algo();

	/* init clocks for single AP */
	ap810_clocks_init(ap810_get_ap_count());

	/* TODO: need to check if need early cpu powerdown */

	/* TODO: check if recovery feature is needed */

	/* TODO: check if SVC is needed */

	/* Trigger DRAM driver initialization */
	ret = plat_dram_init();

	return ret;
}