xref: /openbmc/linux/drivers/gpu/drm/msm/dsi/dsi_cfg.c (revision 6e0eb52e)
1 /*
2  * Copyright (c) 2015, The Linux Foundation. All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 and
6  * only version 2 as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  */
13 
14 #include "dsi_cfg.h"
15 
16 /* DSI v2 has not been supported by now */
17 static const struct msm_dsi_config dsi_v2_cfg = {
18 	.io_offset = 0,
19 };
20 
21 static const char * const dsi_6g_bus_clk_names[] = {
22 	"mdp_core_clk", "iface_clk", "bus_clk", "core_mmss_clk",
23 };
24 
25 static const struct msm_dsi_config msm8974_apq8084_dsi_cfg = {
26 	.io_offset = DSI_6G_REG_SHIFT,
27 	.reg_cfg = {
28 		.num = 4,
29 		.regs = {
30 			{"gdsc", -1, -1, -1, -1},
31 			{"vdd", 3000000, 3000000, 150000, 100},
32 			{"vdda", 1200000, 1200000, 100000, 100},
33 			{"vddio", 1800000, 1800000, 100000, 100},
34 		},
35 	},
36 	.bus_clk_names = dsi_6g_bus_clk_names,
37 	.num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names),
38 };
39 
40 static const char * const dsi_8916_bus_clk_names[] = {
41 	"mdp_core_clk", "iface_clk", "bus_clk",
42 };
43 
44 static const struct msm_dsi_config msm8916_dsi_cfg = {
45 	.io_offset = DSI_6G_REG_SHIFT,
46 	.reg_cfg = {
47 		.num = 4,
48 		.regs = {
49 			{"gdsc", -1, -1, -1, -1},
50 			{"vdd", 2850000, 2850000, 100000, 100},
51 			{"vdda", 1200000, 1200000, 100000, 100},
52 			{"vddio", 1800000, 1800000, 100000, 100},
53 		},
54 	},
55 	.bus_clk_names = dsi_8916_bus_clk_names,
56 	.num_bus_clks = ARRAY_SIZE(dsi_8916_bus_clk_names),
57 };
58 
59 static const struct msm_dsi_config msm8994_dsi_cfg = {
60 	.io_offset = DSI_6G_REG_SHIFT,
61 	.reg_cfg = {
62 		.num = 7,
63 		.regs = {
64 			{"gdsc", -1, -1, -1, -1},
65 			{"vdda", 1250000, 1250000, 100000, 100},
66 			{"vddio", 1800000, 1800000, 100000, 100},
67 			{"vcca", 1000000, 1000000, 10000, 100},
68 			{"vdd", 1800000, 1800000, 100000, 100},
69 			{"lab_reg", -1, -1, -1, -1},
70 			{"ibb_reg", -1, -1, -1, -1},
71 		},
72 	},
73 	.bus_clk_names = dsi_6g_bus_clk_names,
74 	.num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names),
75 };
76 
77 static const struct msm_dsi_cfg_handler dsi_cfg_handlers[] = {
78 	{MSM_DSI_VER_MAJOR_V2, U32_MAX, &dsi_v2_cfg},
79 	{MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V1_0,
80 						&msm8974_apq8084_dsi_cfg},
81 	{MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V1_1,
82 						&msm8974_apq8084_dsi_cfg},
83 	{MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V1_1_1,
84 						&msm8974_apq8084_dsi_cfg},
85 	{MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V1_2,
86 						&msm8974_apq8084_dsi_cfg},
87 	{MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V1_3, &msm8994_dsi_cfg},
88 	{MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V1_3_1, &msm8916_dsi_cfg},
89 };
90 
91 const struct msm_dsi_cfg_handler *msm_dsi_cfg_get(u32 major, u32 minor)
92 {
93 	const struct msm_dsi_cfg_handler *cfg_hnd = NULL;
94 	int i;
95 
96 	for (i = ARRAY_SIZE(dsi_cfg_handlers) - 1; i >= 0; i--) {
97 		if ((dsi_cfg_handlers[i].major == major) &&
98 			(dsi_cfg_handlers[i].minor == minor)) {
99 			cfg_hnd = &dsi_cfg_handlers[i];
100 			break;
101 		}
102 	}
103 
104 	return cfg_hnd;
105 }
106 
107