xref: /linux/drivers/gpu/drm/loongson/loongson_device.c (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2023 Loongson Technology Corporation Limited
4  */
5 
6 #include <linux/pci.h>
7 
8 #include "lsdc_drv.h"
9 
10 static const struct lsdc_kms_funcs ls7a1000_kms_funcs = {
11 	.create_i2c = lsdc_create_i2c_chan,
12 	.irq_handler = ls7a1000_dc_irq_handler,
13 	.output_init = ls7a1000_output_init,
14 	.cursor_plane_init = ls7a1000_cursor_plane_init,
15 	.primary_plane_init = lsdc_primary_plane_init,
16 	.crtc_init = ls7a1000_crtc_init,
17 };
18 
19 static const struct lsdc_kms_funcs ls7a2000_kms_funcs = {
20 	.create_i2c = lsdc_create_i2c_chan,
21 	.irq_handler = ls7a2000_dc_irq_handler,
22 	.output_init = ls7a2000_output_init,
23 	.cursor_plane_init = ls7a2000_cursor_plane_init,
24 	.primary_plane_init = lsdc_primary_plane_init,
25 	.crtc_init = ls7a2000_crtc_init,
26 };
27 
28 static const struct loongson_gfx_desc ls7a1000_gfx = {
29 	.dc = {
30 		.num_of_crtc = 2,
31 		.max_pixel_clk = 200000,
32 		.max_width = 2048,
33 		.max_height = 2048,
34 		.num_of_hw_cursor = 1,
35 		.hw_cursor_w = 32,
36 		.hw_cursor_h = 32,
37 		.pitch_align = 256,
38 		.has_vblank_counter = false,
39 		.funcs = &ls7a1000_kms_funcs,
40 	},
41 	.conf_reg_base = LS7A1000_CONF_REG_BASE,
42 	.gfxpll = {
43 		.reg_offset = LS7A1000_PLL_GFX_REG,
44 		.reg_size = 8,
45 	},
46 	.pixpll = {
47 		[0] = {
48 			.reg_offset = LS7A1000_PIXPLL0_REG,
49 			.reg_size = 8,
50 		},
51 		[1] = {
52 			.reg_offset = LS7A1000_PIXPLL1_REG,
53 			.reg_size = 8,
54 		},
55 	},
56 	.chip_id = CHIP_LS7A1000,
57 	.model = "LS7A1000 bridge chipset",
58 };
59 
60 static const struct loongson_gfx_desc ls7a2000_gfx = {
61 	.dc = {
62 		.num_of_crtc = 2,
63 		.max_pixel_clk = 350000,
64 		.max_width = 4096,
65 		.max_height = 4096,
66 		.num_of_hw_cursor = 2,
67 		.hw_cursor_w = 64,
68 		.hw_cursor_h = 64,
69 		.pitch_align = 64,
70 		.has_vblank_counter = true,
71 		.funcs = &ls7a2000_kms_funcs,
72 	},
73 	.conf_reg_base = LS7A2000_CONF_REG_BASE,
74 	.gfxpll = {
75 		.reg_offset = LS7A2000_PLL_GFX_REG,
76 		.reg_size = 8,
77 	},
78 	.pixpll = {
79 		[0] = {
80 			.reg_offset = LS7A2000_PIXPLL0_REG,
81 			.reg_size = 8,
82 		},
83 		[1] = {
84 			.reg_offset = LS7A2000_PIXPLL1_REG,
85 			.reg_size = 8,
86 		},
87 	},
88 	.chip_id = CHIP_LS7A2000,
89 	.model = "LS7A2000 bridge chipset",
90 };
91 
92 static const struct lsdc_desc *__chip_id_desc_table[] = {
93 	[CHIP_LS7A1000] = &ls7a1000_gfx.dc,
94 	[CHIP_LS7A2000] = &ls7a2000_gfx.dc,
95 	[CHIP_LS_LAST] = NULL,
96 };
97 
98 const struct lsdc_desc *
99 lsdc_device_probe(struct pci_dev *pdev, enum loongson_chip_id chip_id)
100 {
101 	return __chip_id_desc_table[chip_id];
102 }
103