1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (C) 2023 Loongson Technology Corporation Limited
6 #ifndef __LSDC_PIXPLL_H__
7 #define __LSDC_PIXPLL_H__
9 #include <drm/drm_device.h>
12 * Loongson Pixel PLL hardware structure
14 * refclk: reference frequency, 100 MHz from external oscillator
15 * outclk: output frequency desired.
19 * refclk +-----------+ +------------------+ +---------+ outclk
20 * ---+---> | Prescaler | ---> | Clock Multiplier | ---> | divider | -------->
21 * | +-----------+ +------------------+ +---------+ ^
25 * | div_ref loopc div_out |
27 * +---- bypass (bypass above software configurable clock if set) ----+
29 * outclk = refclk / div_ref * loopc / div_out;
31 * sel_out: PLL clock output selector(enable).
33 * If sel_out == 1, then enable output clock (turn On);
34 * If sel_out == 0, then disable output clock (turn Off);
36 * PLL working requirements:
38 * 1) 20 MHz <= refclk / div_ref <= 40Mhz
39 * 2) 1.2 GHz <= refclk /div_out * loopc <= 3.2 Ghz
42 struct lsdc_pixpll_parms {
43 unsigned int ref_clock;
51 struct lsdc_pixpll_funcs {
52 int (*setup)(struct lsdc_pixpll * const this);
54 int (*compute)(struct lsdc_pixpll * const this,
56 struct lsdc_pixpll_parms *pout);
58 int (*update)(struct lsdc_pixpll * const this,
59 struct lsdc_pixpll_parms const *pin);
61 unsigned int (*get_rate)(struct lsdc_pixpll * const this);
63 void (*print)(struct lsdc_pixpll * const this,
64 struct drm_printer *printer);
68 const struct lsdc_pixpll_funcs *funcs;
70 struct drm_device *ddev;
72 /* PLL register offset */
74 /* PLL register size in bytes */
79 struct lsdc_pixpll_parms *priv;
82 int lsdc_pixpll_init(struct lsdc_pixpll * const this,
83 struct drm_device *ddev,