fvp_pwrc.c 1.67 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
8
9
#include <lib/bakery_lock.h>
#include <lib/mmio.h>

10
#include <plat_arm.h>
11

12
#include "../../fvp_def.h"
13
#include "../../fvp_private.h"
14
#include "fvp_pwrc.h"
15
16
17
18
19

/*
 * 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.
 */
20
ARM_INSTANTIATE_LOCK;
21

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

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

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

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

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

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

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

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