xref: /openbmc/linux/drivers/clk/clk-aspeed.h (revision 976e3645923bdd2fe7893aae33fd7a21098bfb28)
1*c1c4942eSJoel Stanley /* SPDX-License-Identifier: GPL-2.0-or-later */
2*c1c4942eSJoel Stanley /*
3*c1c4942eSJoel Stanley  * Structures used by ASPEED clock drivers
4*c1c4942eSJoel Stanley  *
5*c1c4942eSJoel Stanley  * Copyright 2019 IBM Corp.
6*c1c4942eSJoel Stanley  */
7*c1c4942eSJoel Stanley 
8*c1c4942eSJoel Stanley #include <linux/clk-provider.h>
9*c1c4942eSJoel Stanley #include <linux/kernel.h>
10*c1c4942eSJoel Stanley #include <linux/reset-controller.h>
11*c1c4942eSJoel Stanley #include <linux/spinlock.h>
12*c1c4942eSJoel Stanley 
13*c1c4942eSJoel Stanley struct clk_div_table;
14*c1c4942eSJoel Stanley struct regmap;
15*c1c4942eSJoel Stanley 
16*c1c4942eSJoel Stanley /**
17*c1c4942eSJoel Stanley  * struct aspeed_gate_data - Aspeed gated clocks
18*c1c4942eSJoel Stanley  * @clock_idx: bit used to gate this clock in the clock register
19*c1c4942eSJoel Stanley  * @reset_idx: bit used to reset this IP in the reset register. -1 if no
20*c1c4942eSJoel Stanley  *             reset is required when enabling the clock
21*c1c4942eSJoel Stanley  * @name: the clock name
22*c1c4942eSJoel Stanley  * @parent_name: the name of the parent clock
23*c1c4942eSJoel Stanley  * @flags: standard clock framework flags
24*c1c4942eSJoel Stanley  */
25*c1c4942eSJoel Stanley struct aspeed_gate_data {
26*c1c4942eSJoel Stanley 	u8		clock_idx;
27*c1c4942eSJoel Stanley 	s8		reset_idx;
28*c1c4942eSJoel Stanley 	const char	*name;
29*c1c4942eSJoel Stanley 	const char	*parent_name;
30*c1c4942eSJoel Stanley 	unsigned long	flags;
31*c1c4942eSJoel Stanley };
32*c1c4942eSJoel Stanley 
33*c1c4942eSJoel Stanley /**
34*c1c4942eSJoel Stanley  * struct aspeed_clk_gate - Aspeed specific clk_gate structure
35*c1c4942eSJoel Stanley  * @hw:		handle between common and hardware-specific interfaces
36*c1c4942eSJoel Stanley  * @reg:	register controlling gate
37*c1c4942eSJoel Stanley  * @clock_idx:	bit used to gate this clock in the clock register
38*c1c4942eSJoel Stanley  * @reset_idx:	bit used to reset this IP in the reset register. -1 if no
39*c1c4942eSJoel Stanley  *		reset is required when enabling the clock
40*c1c4942eSJoel Stanley  * @flags:	hardware-specific flags
41*c1c4942eSJoel Stanley  * @lock:	register lock
42*c1c4942eSJoel Stanley  *
43*c1c4942eSJoel Stanley  * Some of the clocks in the Aspeed SoC must be put in reset before enabling.
44*c1c4942eSJoel Stanley  * This modified version of clk_gate allows an optional reset bit to be
45*c1c4942eSJoel Stanley  * specified.
46*c1c4942eSJoel Stanley  */
47*c1c4942eSJoel Stanley struct aspeed_clk_gate {
48*c1c4942eSJoel Stanley 	struct clk_hw	hw;
49*c1c4942eSJoel Stanley 	struct regmap	*map;
50*c1c4942eSJoel Stanley 	u8		clock_idx;
51*c1c4942eSJoel Stanley 	s8		reset_idx;
52*c1c4942eSJoel Stanley 	u8		flags;
53*c1c4942eSJoel Stanley 	spinlock_t	*lock;
54*c1c4942eSJoel Stanley };
55*c1c4942eSJoel Stanley 
56*c1c4942eSJoel Stanley #define to_aspeed_clk_gate(_hw) container_of(_hw, struct aspeed_clk_gate, hw)
57*c1c4942eSJoel Stanley 
58*c1c4942eSJoel Stanley /**
59*c1c4942eSJoel Stanley  * struct aspeed_reset - Aspeed reset controller
60*c1c4942eSJoel Stanley  * @map: regmap to access the containing system controller
61*c1c4942eSJoel Stanley  * @rcdev: reset controller device
62*c1c4942eSJoel Stanley  */
63*c1c4942eSJoel Stanley struct aspeed_reset {
64*c1c4942eSJoel Stanley 	struct regmap			*map;
65*c1c4942eSJoel Stanley 	struct reset_controller_dev	rcdev;
66*c1c4942eSJoel Stanley };
67*c1c4942eSJoel Stanley 
68*c1c4942eSJoel Stanley #define to_aspeed_reset(p) container_of((p), struct aspeed_reset, rcdev)
69*c1c4942eSJoel Stanley 
70*c1c4942eSJoel Stanley /**
71*c1c4942eSJoel Stanley  * struct aspeed_clk_soc_data - Aspeed SoC specific divisor information
72*c1c4942eSJoel Stanley  * @div_table: Common divider lookup table
73*c1c4942eSJoel Stanley  * @eclk_div_table: Divider lookup table for ECLK
74*c1c4942eSJoel Stanley  * @mac_div_table: Divider lookup table for MAC (Ethernet) clocks
75*c1c4942eSJoel Stanley  * @calc_pll: Callback to maculate common PLL settings
76*c1c4942eSJoel Stanley  */
77*c1c4942eSJoel Stanley struct aspeed_clk_soc_data {
78*c1c4942eSJoel Stanley 	const struct clk_div_table *div_table;
79*c1c4942eSJoel Stanley 	const struct clk_div_table *eclk_div_table;
80*c1c4942eSJoel Stanley 	const struct clk_div_table *mac_div_table;
81*c1c4942eSJoel Stanley 	struct clk_hw *(*calc_pll)(const char *name, u32 val);
82*c1c4942eSJoel Stanley };
83