2 * Copyright (c) 2014-2015 The Linux Foundation. All rights reserved.
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.
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.
17 struct mdp5_cfg_handler
{
19 struct mdp5_cfg config
;
22 /* mdp5_cfg must be exposed (used in mdp5.xml.h) */
23 const struct mdp5_cfg_hw
*mdp5_cfg
= NULL
;
25 const struct mdp5_cfg_hw msm8x74_config
= {
35 [SSPP_VIG0
] = 1, [SSPP_VIG1
] = 4, [SSPP_VIG2
] = 7,
36 [SSPP_DMA0
] = 10, [SSPP_DMA1
] = 13,
37 [SSPP_RGB0
] = 16, [SSPP_RGB1
] = 17, [SSPP_RGB2
] = 18,
42 .base
= { 0x00600, 0x00700, 0x00800, 0x00900, 0x00a00 },
43 .flush_hw_mask
= 0x0003ffff,
47 .base
= { 0x01200, 0x01600, 0x01a00 },
51 .base
= { 0x01e00, 0x02200, 0x02600 },
55 .base
= { 0x02a00, 0x02e00 },
59 .base
= { 0x03200, 0x03600, 0x03a00, 0x03e00, 0x04200 },
64 .base
= { 0x04600, 0x04a00, 0x04e00 },
68 .base
= { 0x13100, 0x13300 }, /* NOTE: no ad in v1.0 */
72 .base
= { 0x12d00, 0x12e00, 0x12f00 },
76 .base
= { 0x12500, 0x12700, 0x12900, 0x12b00 },
87 const struct mdp5_cfg_hw apq8084_config
= {
97 [SSPP_VIG0
] = 1, [SSPP_VIG1
] = 4,
98 [SSPP_VIG2
] = 7, [SSPP_VIG3
] = 19,
99 [SSPP_DMA0
] = 10, [SSPP_DMA1
] = 13,
100 [SSPP_RGB0
] = 16, [SSPP_RGB1
] = 17,
101 [SSPP_RGB2
] = 18, [SSPP_RGB3
] = 22,
103 .reserved_state
[0] = GENMASK(7, 0), /* first 8 MMBs */
105 /* Two SMP blocks are statically tied to RGB pipes: */
106 [16] = 2, [17] = 2, [18] = 2, [22] = 2,
111 .base
= { 0x00600, 0x00700, 0x00800, 0x00900, 0x00a00 },
112 .flush_hw_mask
= 0x003fffff,
116 .base
= { 0x01200, 0x01600, 0x01a00, 0x01e00 },
120 .base
= { 0x02200, 0x02600, 0x02a00, 0x02e00 },
124 .base
= { 0x03200, 0x03600 },
128 .base
= { 0x03a00, 0x03e00, 0x04200, 0x04600, 0x04a00, 0x04e00 },
133 .base
= { 0x05200, 0x05600, 0x05a00, 0x05e00 },
138 .base
= { 0x13500, 0x13700, 0x13900 },
142 .base
= { 0x12f00, 0x13000, 0x13100, 0x13200 },
146 .base
= { 0x12500, 0x12700, 0x12900, 0x12b00, 0x12d00 },
154 .max_clk
= 320000000,
157 const struct mdp5_cfg_hw msm8x16_config
= {
167 [SSPP_VIG0
] = 1, [SSPP_DMA0
] = 4,
168 [SSPP_RGB0
] = 7, [SSPP_RGB1
] = 8,
173 .base
= { 0x02000, 0x02200, 0x02400, 0x02600, 0x02800 },
174 .flush_hw_mask
= 0x4003ffff,
182 .base
= { 0x15000, 0x17000 },
189 .count
= 2, /* LM0 and LM3 */
190 .base
= { 0x45000, 0x48000 },
199 .count
= 1, /* INTF_1 */
202 /* TODO enable .intfs[] with [1] = INTF_DSI, once DSI is implemented */
203 .max_clk
= 320000000,
206 static const struct mdp5_cfg_handler cfg_handlers
[] = {
207 { .revision
= 0, .config
= { .hw
= &msm8x74_config
} },
208 { .revision
= 2, .config
= { .hw
= &msm8x74_config
} },
209 { .revision
= 3, .config
= { .hw
= &apq8084_config
} },
210 { .revision
= 6, .config
= { .hw
= &msm8x16_config
} },
214 static struct mdp5_cfg_platform
*mdp5_get_config(struct platform_device
*dev
);
216 const struct mdp5_cfg_hw
*mdp5_cfg_get_hw_config(struct mdp5_cfg_handler
*cfg_handler
)
218 return cfg_handler
->config
.hw
;
221 struct mdp5_cfg
*mdp5_cfg_get_config(struct mdp5_cfg_handler
*cfg_handler
)
223 return &cfg_handler
->config
;
226 int mdp5_cfg_get_hw_rev(struct mdp5_cfg_handler
*cfg_handler
)
228 return cfg_handler
->revision
;
231 void mdp5_cfg_destroy(struct mdp5_cfg_handler
*cfg_handler
)
236 struct mdp5_cfg_handler
*mdp5_cfg_init(struct mdp5_kms
*mdp5_kms
,
237 uint32_t major
, uint32_t minor
)
239 struct drm_device
*dev
= mdp5_kms
->dev
;
240 struct platform_device
*pdev
= dev
->platformdev
;
241 struct mdp5_cfg_handler
*cfg_handler
;
242 struct mdp5_cfg_platform
*pconfig
;
245 cfg_handler
= kzalloc(sizeof(*cfg_handler
), GFP_KERNEL
);
246 if (unlikely(!cfg_handler
)) {
252 dev_err(dev
->dev
, "unexpected MDP major version: v%d.%d\n",
258 /* only after mdp5_cfg global pointer's init can we access the hw */
259 for (i
= 0; i
< ARRAY_SIZE(cfg_handlers
); i
++) {
260 if (cfg_handlers
[i
].revision
!= minor
)
262 mdp5_cfg
= cfg_handlers
[i
].config
.hw
;
266 if (unlikely(!mdp5_cfg
)) {
267 dev_err(dev
->dev
, "unexpected MDP minor revision: v%d.%d\n",
273 cfg_handler
->revision
= minor
;
274 cfg_handler
->config
.hw
= mdp5_cfg
;
276 pconfig
= mdp5_get_config(pdev
);
277 memcpy(&cfg_handler
->config
.platform
, pconfig
, sizeof(*pconfig
));
279 DBG("MDP5: %s hw config selected", mdp5_cfg
->name
);
285 mdp5_cfg_destroy(cfg_handler
);
290 static struct mdp5_cfg_platform
*mdp5_get_config(struct platform_device
*dev
)
292 static struct mdp5_cfg_platform config
= {};
296 config
.iommu
= iommu_domain_alloc(&platform_bus_type
);