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
8
#include <lib/bakery_lock.h>
#include <lib/mmio.h>
9
#include <platform_def.h>
10

11
#include <plat_arm.h>
12
#include "../../fvp_private.h"
13
#include "fvp_pwrc.h"
14
15
16
17
18

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

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

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

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

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

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

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

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

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