summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/loongson/lsdc_gfxpll.h
blob: 9d59cbfc145dd66c6787d3650309300773d49a7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * Copyright (C) 2023 Loongson Technology Corporation Limited
 */

#ifndef __LSDC_GFXPLL_H__
#define __LSDC_GFXPLL_H__

#include <drm/drm_device.h>

struct loongson_gfxpll;

struct loongson_gfxpll_parms {
	unsigned int ref_clock;
	unsigned int div_ref;
	unsigned int loopc;
	unsigned int div_out_dc;
	unsigned int div_out_gmc;
	unsigned int div_out_gpu;
};

struct loongson_gfxpll_funcs {
	int (*init)(struct loongson_gfxpll * const this);

	int (*update)(struct loongson_gfxpll * const this,
		      struct loongson_gfxpll_parms const *pin);

	void (*get_rates)(struct loongson_gfxpll * const this,
			  unsigned int *dc, unsigned int *gmc, unsigned int *gpu);

	void (*print)(struct loongson_gfxpll * const this,
		      struct drm_printer *printer, bool verbose);
};

struct loongson_gfxpll {
	struct drm_device *ddev;
	void __iomem *mmio;

	/* PLL register offset */
	u32 reg_base;
	/* PLL register size in bytes */
	u32 reg_size;

	const struct loongson_gfxpll_funcs *funcs;

	struct loongson_gfxpll_parms parms;
};

int loongson_gfxpll_create(struct drm_device *ddev,
			   struct loongson_gfxpll **ppout);

#endif