Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / video / fbdev / via / via_clock.h
blob4d88fd6cde3d24a98ee4219006c48f06bff43428
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
4 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
5 * Copyright 2011 Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
6 */
7 /*
8 * clock and PLL management functions
9 */
11 #ifndef __VIA_CLOCK_H__
12 #define __VIA_CLOCK_H__
14 #include <linux/types.h>
16 enum via_clksrc {
17 VIA_CLKSRC_X1 = 0,
18 VIA_CLKSRC_TVX1,
19 VIA_CLKSRC_TVPLL,
20 VIA_CLKSRC_DVP1TVCLKR,
21 VIA_CLKSRC_CAP0,
22 VIA_CLKSRC_CAP1,
25 struct via_pll_config {
26 u16 multiplier;
27 u8 divisor;
28 u8 rshift;
31 struct via_clock {
32 void (*set_primary_clock_state)(u8 state);
33 void (*set_primary_clock_source)(enum via_clksrc src, bool use_pll);
34 void (*set_primary_pll_state)(u8 state);
35 void (*set_primary_pll)(struct via_pll_config config);
37 void (*set_secondary_clock_state)(u8 state);
38 void (*set_secondary_clock_source)(enum via_clksrc src, bool use_pll);
39 void (*set_secondary_pll_state)(u8 state);
40 void (*set_secondary_pll)(struct via_pll_config config);
42 void (*set_engine_pll_state)(u8 state);
43 void (*set_engine_pll)(struct via_pll_config config);
47 static inline u32 get_pll_internal_frequency(u32 ref_freq,
48 struct via_pll_config pll)
50 return ref_freq / pll.divisor * pll.multiplier;
53 static inline u32 get_pll_output_frequency(u32 ref_freq,
54 struct via_pll_config pll)
56 return get_pll_internal_frequency(ref_freq, pll) >> pll.rshift;
59 void via_clock_init(struct via_clock *clock, int gfx_chip);
61 #endif /* __VIA_CLOCK_H__ */