File: clk.c

package info (click to toggle)
arm-trusted-firmware 2.8.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 34,708 kB
  • sloc: ansic: 373,544; asm: 29,383; makefile: 1,912; python: 621; javascript: 136; sh: 33
file content (65 lines) | stat: -rw-r--r-- 1,302 bytes parent folder | download
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
/*
 * Copyright (c) 2021, STMicroelectronics - All Rights Reserved
 * Author(s): Ludovic Barre, <ludovic.barre@st.com> for STMicroelectronics.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <assert.h>
#include <errno.h>
#include <stdbool.h>

#include <drivers/clk.h>

static const struct clk_ops *ops;

int clk_enable(unsigned long id)
{
	assert((ops != NULL) && (ops->enable != NULL));

	return ops->enable(id);
}

void clk_disable(unsigned long id)
{
	assert((ops != NULL) && (ops->disable != NULL));

	ops->disable(id);
}

unsigned long clk_get_rate(unsigned long id)
{
	assert((ops != NULL) && (ops->get_rate != NULL));

	return ops->get_rate(id);
}

int clk_get_parent(unsigned long id)
{
	assert((ops != NULL) && (ops->get_parent != NULL));

	return ops->get_parent(id);
}

bool clk_is_enabled(unsigned long id)
{
	assert((ops != NULL) && (ops->is_enabled != NULL));

	return ops->is_enabled(id);
}

/*
 * Initialize the clk. The fields in the provided clk
 * ops pointer must be valid.
 */
void clk_register(const struct clk_ops *ops_ptr)
{
	assert((ops_ptr != NULL) &&
	       (ops_ptr->enable != NULL) &&
	       (ops_ptr->disable != NULL) &&
	       (ops_ptr->get_rate != NULL) &&
	       (ops_ptr->get_parent != NULL) &&
	       (ops_ptr->is_enabled != NULL));

	ops = ops_ptr;
}