fvp_pwrc.c 1.66 KB
Newer Older
1
/*
2
 * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
3
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
5
6
7
 */

#include <bakery_lock.h>
8
#include <mmio.h>
9
#include <plat_arm.h>
10
#include "../../fvp_def.h"
11
#include "../../fvp_private.h"
12
#include "fvp_pwrc.h"
13
14
15
16
17

/*
 * TODO: Someday there will be a generic power controller api. At the moment
 * each platform has its own pwrc so just exporting functions is fine.
 */
18
ARM_INSTANTIATE_LOCK;
19

20
unsigned int fvp_pwrc_get_cpu_wkr(u_register_t mpidr)
21
{
22
	return PSYSR_WK(fvp_pwrc_read_psysr(mpidr));
23
24
}

25
unsigned int fvp_pwrc_read_psysr(u_register_t mpidr)
26
{
27
	unsigned int rc;
28
	arm_lock_get();
29
30
	mmio_write_32(PWRC_BASE + PSYSR_OFF, (unsigned int) mpidr);
	rc = mmio_read_32(PWRC_BASE + PSYSR_OFF);
31
	arm_lock_release();
32
33
34
	return rc;
}

35
void fvp_pwrc_write_pponr(u_register_t mpidr)
36
{
37
	arm_lock_get();
38
	mmio_write_32(PWRC_BASE + PPONR_OFF, (unsigned int) mpidr);
39
	arm_lock_release();
40
41
}

42
void fvp_pwrc_write_ppoffr(u_register_t mpidr)
43
{
44
	arm_lock_get();
45
	mmio_write_32(PWRC_BASE + PPOFFR_OFF, (unsigned int) mpidr);
46
	arm_lock_release();
47
48
}

49
void fvp_pwrc_set_wen(u_register_t mpidr)
50
{
51
	arm_lock_get();
52
53
	mmio_write_32(PWRC_BASE + PWKUPR_OFF,
		      (unsigned int) (PWKUPR_WEN | mpidr));
54
	arm_lock_release();
55
56
}

57
void fvp_pwrc_clr_wen(u_register_t mpidr)
58
{
59
	arm_lock_get();
60
61
	mmio_write_32(PWRC_BASE + PWKUPR_OFF,
		      (unsigned int) mpidr);
62
	arm_lock_release();
63
64
}

65
void fvp_pwrc_write_pcoffr(u_register_t mpidr)
66
{
67
	arm_lock_get();
68
	mmio_write_32(PWRC_BASE + PCOFFR_OFF, (unsigned int) mpidr);
69
	arm_lock_release();
70
71
72
}

/* Nothing else to do here apart from initializing the lock */
73
void __init plat_arm_pwrc_setup(void)
74
{
75
	arm_lock_init();
76
77
78
79
}