xref: /rk3399_ARM-atf/plat/rockchip/common/scmi/scmi_clock.h (revision 04b2fb42b171e3fbf2ef823558ac5b0119663dc7)
1 /*
2  * Copyright (c) 2025, Rockchip, Inc. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef RK_SCMI_CLOCK_H
8 #define RK_SCMI_CLOCK_H
9 
10 #include <stdint.h>
11 
12 #include <common.h>
13 
14 struct rk_scmi_clock;
15 
16 struct rk_clk_ops {
17 	unsigned long (*get_rate)(struct rk_scmi_clock *clock);
18 	int (*set_rate)(struct rk_scmi_clock *clock, unsigned long rate);
19 	int (*set_status)(struct rk_scmi_clock *clock, bool status);
20 };
21 
22 typedef struct rk_scmi_clock {
23 	char name[SCMI_CLOCK_NAME_LENGTH_MAX];
24 	uint8_t enable;
25 	int8_t is_security;
26 	int8_t is_dynamic_prate;
27 	uint32_t id;
28 	uint32_t rate_cnt;
29 	uint64_t cur_rate;
30 	uint32_t enable_count;
31 	const struct rk_clk_ops *clk_ops;
32 	const unsigned long *parent_table;
33 	const uint32_t *info;
34 	unsigned long *rate_table;
35 } rk_scmi_clock_t;
36 
37 /*
38  * Return number of clock controllers for an agent
39  * @agent_id: SCMI agent ID
40  * Return number of clock controllers
41  */
42 size_t rockchip_scmi_clock_count(unsigned int agent_id);
43 
44 /*
45  * Get rk_scmi_clock_t point
46  * @agent_id: SCMI agent ID
47  * @scmi_id: SCMI clock ID
48  * Return a rk_scmi_clock_t point
49  */
50 rk_scmi_clock_t *rockchip_scmi_get_clock(uint32_t agent_id,
51 					 uint32_t scmi_id);
52 
53 unsigned long clk_scmi_common_get_rate(rk_scmi_clock_t *clock);
54 int clk_scmi_common_set_rate(rk_scmi_clock_t *clock, unsigned long rate);
55 int clk_scmi_common_set_status(rk_scmi_clock_t *clock, bool status);
56 #endif /* RK_SCMI_CLOCK_H */
57