xref: /freebsd/sys/dev/clk/allwinner/aw_ccung.h (revision be82b3a0bf72ed3b5f01ac9fcd8dcd3802e3c742)
1e37e8677SEmmanuel Vadot /*-
2e37e8677SEmmanuel Vadot  * SPDX-License-Identifier: BSD-2-Clause
3e37e8677SEmmanuel Vadot  *
4e37e8677SEmmanuel Vadot  * Copyright (c) 2017,2018 Emmanuel Vadot <manu@freebsd.org>
5e37e8677SEmmanuel Vadot  *
6e37e8677SEmmanuel Vadot  * Redistribution and use in source and binary forms, with or without
7e37e8677SEmmanuel Vadot  * modification, are permitted provided that the following conditions
8e37e8677SEmmanuel Vadot  * are met:
9e37e8677SEmmanuel Vadot  * 1. Redistributions of source code must retain the above copyright
10e37e8677SEmmanuel Vadot  *    notice, this list of conditions and the following disclaimer.
11e37e8677SEmmanuel Vadot  * 2. Redistributions in binary form must reproduce the above copyright
12e37e8677SEmmanuel Vadot  *    notice, this list of conditions and the following disclaimer in the
13e37e8677SEmmanuel Vadot  *    documentation and/or other materials provided with the distribution.
14e37e8677SEmmanuel Vadot  *
15e37e8677SEmmanuel Vadot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16e37e8677SEmmanuel Vadot  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17e37e8677SEmmanuel Vadot  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18e37e8677SEmmanuel Vadot  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19e37e8677SEmmanuel Vadot  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20e37e8677SEmmanuel Vadot  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21e37e8677SEmmanuel Vadot  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
22e37e8677SEmmanuel Vadot  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23e37e8677SEmmanuel Vadot  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24e37e8677SEmmanuel Vadot  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25e37e8677SEmmanuel Vadot  * SUCH DAMAGE.
26e37e8677SEmmanuel Vadot  */
27e37e8677SEmmanuel Vadot 
28e37e8677SEmmanuel Vadot #ifndef __CCU_NG_H__
29e37e8677SEmmanuel Vadot #define __CCU_NG_H__
30e37e8677SEmmanuel Vadot 
31e37e8677SEmmanuel Vadot #include <dev/clk/allwinner/aw_clk.h>
32e37e8677SEmmanuel Vadot #include <dev/clk/allwinner/aw_clk_m.h>
33e37e8677SEmmanuel Vadot #include <dev/clk/allwinner/aw_clk_mipi.h>
34e37e8677SEmmanuel Vadot #include <dev/clk/allwinner/aw_clk_nkmp.h>
35e37e8677SEmmanuel Vadot #include <dev/clk/allwinner/aw_clk_nm.h>
36e37e8677SEmmanuel Vadot #include <dev/clk/allwinner/aw_clk_nmm.h>
37e37e8677SEmmanuel Vadot #include <dev/clk/allwinner/aw_clk_np.h>
38e37e8677SEmmanuel Vadot #include <dev/clk/allwinner/aw_clk_prediv_mux.h>
39e37e8677SEmmanuel Vadot #include <dev/clk/allwinner/aw_clk_frac.h>
40*be82b3a0SEmmanuel Vadot #include <dev/clk/clk_mux.h>
41*be82b3a0SEmmanuel Vadot #include <dev/clk/clk_div.h>
42*be82b3a0SEmmanuel Vadot #include <dev/clk/clk_fixed.h>
43e37e8677SEmmanuel Vadot 
44e37e8677SEmmanuel Vadot enum aw_ccung_clk_type {
45e37e8677SEmmanuel Vadot 	AW_CLK_UNDEFINED = 0,
46e37e8677SEmmanuel Vadot 	AW_CLK_MUX,
47e37e8677SEmmanuel Vadot 	AW_CLK_DIV,
48e37e8677SEmmanuel Vadot 	AW_CLK_FIXED,
49e37e8677SEmmanuel Vadot 	AW_CLK_NKMP,
50e37e8677SEmmanuel Vadot 	AW_CLK_NM,
51e37e8677SEmmanuel Vadot 	AW_CLK_PREDIV_MUX,
52e37e8677SEmmanuel Vadot 	AW_CLK_FRAC,
53e37e8677SEmmanuel Vadot 	AW_CLK_M,
54e37e8677SEmmanuel Vadot 	AW_CLK_MIPI,
55e37e8677SEmmanuel Vadot 	AW_CLK_NP,
56e37e8677SEmmanuel Vadot 	AW_CLK_NMM,
57e37e8677SEmmanuel Vadot };
58e37e8677SEmmanuel Vadot 
59e37e8677SEmmanuel Vadot struct aw_ccung_clk {
60e37e8677SEmmanuel Vadot 	enum aw_ccung_clk_type	type;
61e37e8677SEmmanuel Vadot 	union {
62e37e8677SEmmanuel Vadot 		struct clk_mux_def		*mux;
63e37e8677SEmmanuel Vadot 		struct clk_div_def		*div;
64e37e8677SEmmanuel Vadot 		struct clk_fixed_def		*fixed;
65e37e8677SEmmanuel Vadot 		struct aw_clk_nkmp_def		*nkmp;
66e37e8677SEmmanuel Vadot 		struct aw_clk_nm_def		*nm;
67e37e8677SEmmanuel Vadot 		struct aw_clk_prediv_mux_def	*prediv_mux;
68e37e8677SEmmanuel Vadot 		struct aw_clk_frac_def		*frac;
69e37e8677SEmmanuel Vadot 		struct aw_clk_m_def		*m;
70e37e8677SEmmanuel Vadot 		struct aw_clk_mipi_def		*mipi;
71e37e8677SEmmanuel Vadot 		struct aw_clk_np_def		*np;
72e37e8677SEmmanuel Vadot 		struct aw_clk_nmm_def		*nmm;
73e37e8677SEmmanuel Vadot 	} clk;
74e37e8677SEmmanuel Vadot };
75e37e8677SEmmanuel Vadot 
76e37e8677SEmmanuel Vadot struct aw_ccung_softc {
77e37e8677SEmmanuel Vadot 	device_t		dev;
78e37e8677SEmmanuel Vadot 	struct resource		*res;
79e37e8677SEmmanuel Vadot 	struct clkdom		*clkdom;
80e37e8677SEmmanuel Vadot 	struct mtx		mtx;
81e37e8677SEmmanuel Vadot 	struct aw_ccung_reset	*resets;
82e37e8677SEmmanuel Vadot 	int			nresets;
83e37e8677SEmmanuel Vadot 	struct aw_ccung_gate	*gates;
84e37e8677SEmmanuel Vadot 	int			ngates;
85e37e8677SEmmanuel Vadot 	struct aw_ccung_clk	*clks;
86e37e8677SEmmanuel Vadot 	int			nclks;
87e37e8677SEmmanuel Vadot 	struct aw_clk_init	*clk_init;
88e37e8677SEmmanuel Vadot 	int			n_clk_init;
89e37e8677SEmmanuel Vadot };
90e37e8677SEmmanuel Vadot 
91e37e8677SEmmanuel Vadot struct aw_ccung_reset {
92e37e8677SEmmanuel Vadot 	uint32_t	offset;
93e37e8677SEmmanuel Vadot 	uint32_t	shift;
94e37e8677SEmmanuel Vadot };
95e37e8677SEmmanuel Vadot 
96e37e8677SEmmanuel Vadot struct aw_ccung_gate {
97e37e8677SEmmanuel Vadot 	const char	*name;
98e37e8677SEmmanuel Vadot 	const char	*parent_name;
99e37e8677SEmmanuel Vadot 	uint32_t	id;
100e37e8677SEmmanuel Vadot 	uint32_t	offset;
101e37e8677SEmmanuel Vadot 	uint32_t	shift;
102e37e8677SEmmanuel Vadot };
103e37e8677SEmmanuel Vadot 
104e37e8677SEmmanuel Vadot DECLARE_CLASS(aw_ccung_driver);
105e37e8677SEmmanuel Vadot 
106e37e8677SEmmanuel Vadot int aw_ccung_attach(device_t dev);
107e37e8677SEmmanuel Vadot 
108e37e8677SEmmanuel Vadot #endif /* __CCU_NG_H__ */
109