xref: /optee_os/core/drivers/clk/sam/at91_sckc.c (revision 8411e6ad673d20c4742ed30c785e3f5cdea54dfa)
1 // SPDX-License-Identifier: GPL-2.0+ or BSD-3-Clause
2 /*
3  *  Copyright (C) 2013 Boris BREZILLON <b.brezillon@overkiz.com>
4  *  Copyright (C) 2021 Microchip
5  */
6 
7 #include <drivers/clk.h>
8 #include <drivers/clk_dt.h>
9 
10 #define SLOW_CLOCK_FREQ			32768
11 
12 static unsigned long sckc_get_rate(struct clk *clk __unused,
13 				   unsigned long parent_rate __unused)
14 {
15 	return SLOW_CLOCK_FREQ;
16 }
17 
18 static const struct clk_ops sckc_clk_ops = {
19 	.get_rate = sckc_get_rate,
20 };
21 
22 static TEE_Result sckc_pmc_setup(const void *fdt __unused, int offs,
23 				 const void *data __unused)
24 {
25 	struct clk *clk = NULL;
26 	TEE_Result res = TEE_ERROR_GENERIC;
27 
28 	clk = clk_alloc("slowck", &sckc_clk_ops, NULL, 0);
29 	if (!clk)
30 		return TEE_ERROR_OUT_OF_MEMORY;
31 
32 	res = clk_register(clk);
33 	if (res) {
34 		clk_free(clk);
35 		return res;
36 	}
37 
38 	return clk_dt_register_clk_provider(fdt, offs, clk_dt_get_simple_clk,
39 					    clk);
40 }
41 
42 CLK_DT_DECLARE(at91_sckc, "atmel,sama5d4-sckc", sckc_pmc_setup);
43