xref: /freebsd/sys/dev/clk/rockchip/rk_clk_composite.h (revision 77f222415832c58c2e307f74f1200941efe868d9)
1*77f22241SEmmanuel Vadot /*-
2*77f22241SEmmanuel Vadot  * SPDX-License-Identifier: BSD-2-Clause
3*77f22241SEmmanuel Vadot  *
4*77f22241SEmmanuel Vadot  * Copyright 2018 Emmanuel Vadot <manu@FreeBSD.org>
5*77f22241SEmmanuel Vadot  *
6*77f22241SEmmanuel Vadot  * Redistribution and use in source and binary forms, with or without
7*77f22241SEmmanuel Vadot  * modification, are permitted provided that the following conditions
8*77f22241SEmmanuel Vadot  * are met:
9*77f22241SEmmanuel Vadot  * 1. Redistributions of source code must retain the above copyright
10*77f22241SEmmanuel Vadot  *    notice, this list of conditions and the following disclaimer.
11*77f22241SEmmanuel Vadot  * 2. Redistributions in binary form must reproduce the above copyright
12*77f22241SEmmanuel Vadot  *    notice, this list of conditions and the following disclaimer in the
13*77f22241SEmmanuel Vadot  *    documentation and/or other materials provided with the distribution.
14*77f22241SEmmanuel Vadot  *
15*77f22241SEmmanuel Vadot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16*77f22241SEmmanuel Vadot  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17*77f22241SEmmanuel Vadot  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18*77f22241SEmmanuel Vadot  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19*77f22241SEmmanuel Vadot  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20*77f22241SEmmanuel Vadot  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21*77f22241SEmmanuel Vadot  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22*77f22241SEmmanuel Vadot  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23*77f22241SEmmanuel Vadot  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24*77f22241SEmmanuel Vadot  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25*77f22241SEmmanuel Vadot  * SUCH DAMAGE.
26*77f22241SEmmanuel Vadot  */
27*77f22241SEmmanuel Vadot 
28*77f22241SEmmanuel Vadot #ifndef _RK_CLK_COMPOSITE_H_
29*77f22241SEmmanuel Vadot #define _RK_CLK_COMPOSITE_H_
30*77f22241SEmmanuel Vadot 
31*77f22241SEmmanuel Vadot #include <dev/extres/clk/clk.h>
32*77f22241SEmmanuel Vadot 
33*77f22241SEmmanuel Vadot struct rk_clk_composite_def {
34*77f22241SEmmanuel Vadot 	struct clknode_init_def	clkdef;
35*77f22241SEmmanuel Vadot 
36*77f22241SEmmanuel Vadot 	uint32_t	muxdiv_offset;
37*77f22241SEmmanuel Vadot 
38*77f22241SEmmanuel Vadot 	uint32_t	mux_shift;
39*77f22241SEmmanuel Vadot 	uint32_t	mux_width;
40*77f22241SEmmanuel Vadot 
41*77f22241SEmmanuel Vadot 	uint32_t	div_shift;
42*77f22241SEmmanuel Vadot 	uint32_t	div_width;
43*77f22241SEmmanuel Vadot 
44*77f22241SEmmanuel Vadot 	uint32_t	flags;
45*77f22241SEmmanuel Vadot };
46*77f22241SEmmanuel Vadot 
47*77f22241SEmmanuel Vadot #define	RK_CLK_COMPOSITE_HAVE_MUX	0x0001
48*77f22241SEmmanuel Vadot #define	RK_CLK_COMPOSITE_DIV_EXP	0x0002	/* Register   0, 1, 2, 2, ... */
49*77f22241SEmmanuel Vadot 						/* Divider    1, 2, 4, 8, ... */
50*77f22241SEmmanuel Vadot #define	RK_CLK_COMPOSITE_GRF		0x0004 /* Use syscon registers instead of CRU's */
51*77f22241SEmmanuel Vadot int rk_clk_composite_register(struct clkdom *clkdom,
52*77f22241SEmmanuel Vadot     struct rk_clk_composite_def *clkdef);
53*77f22241SEmmanuel Vadot 
54*77f22241SEmmanuel Vadot #endif /* _RK_CLK_COMPOSITE_H_ */
55