1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2014-2015 The Linux Foundation. All rights reserved.
9 struct mdp5_cfg_handler {
11 struct mdp5_cfg config;
14 /* mdp5_cfg must be exposed (used in mdp5.xml.h) */
15 const struct mdp5_cfg_hw *mdp5_cfg = NULL;
17 static const struct mdp5_cfg_hw msm8x74v1_config = {
28 [SSPP_VIG0] = 1, [SSPP_VIG1] = 4, [SSPP_VIG2] = 7,
29 [SSPP_DMA0] = 10, [SSPP_DMA1] = 13,
30 [SSPP_RGB0] = 16, [SSPP_RGB1] = 17, [SSPP_RGB2] = 18,
35 .base = { 0x00500, 0x00600, 0x00700, 0x00800, 0x00900 },
36 .flush_hw_mask = 0x0003ffff,
40 .base = { 0x01100, 0x01500, 0x01900 },
41 .caps = MDP_PIPE_CAP_HFLIP |
49 .base = { 0x01d00, 0x02100, 0x02500 },
50 .caps = MDP_PIPE_CAP_HFLIP |
57 .base = { 0x02900, 0x02d00 },
58 .caps = MDP_PIPE_CAP_HFLIP |
64 .base = { 0x03100, 0x03500, 0x03900, 0x03d00, 0x04100 },
66 { .id = 0, .pp = 0, .dspp = 0,
67 .caps = MDP_LM_CAP_DISPLAY, },
68 { .id = 1, .pp = 1, .dspp = 1,
69 .caps = MDP_LM_CAP_DISPLAY, },
70 { .id = 2, .pp = 2, .dspp = 2,
71 .caps = MDP_LM_CAP_DISPLAY, },
72 { .id = 3, .pp = -1, .dspp = -1,
73 .caps = MDP_LM_CAP_WB },
74 { .id = 4, .pp = -1, .dspp = -1,
75 .caps = MDP_LM_CAP_WB },
83 .base = { 0x04500, 0x04900, 0x04d00 },
87 .base = { 0x21a00, 0x21b00, 0x21c00 },
90 .base = { 0x21000, 0x21200, 0x21400, 0x21600 },
101 static const struct mdp5_cfg_hw msm8x74v2_config = {
105 .caps = MDP_CAP_SMP |
112 [SSPP_VIG0] = 1, [SSPP_VIG1] = 4, [SSPP_VIG2] = 7,
113 [SSPP_DMA0] = 10, [SSPP_DMA1] = 13,
114 [SSPP_RGB0] = 16, [SSPP_RGB1] = 17, [SSPP_RGB2] = 18,
119 .base = { 0x00500, 0x00600, 0x00700, 0x00800, 0x00900 },
120 .flush_hw_mask = 0x0003ffff,
124 .base = { 0x01100, 0x01500, 0x01900 },
125 .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
126 MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_CSC |
127 MDP_PIPE_CAP_DECIMATION,
131 .base = { 0x01d00, 0x02100, 0x02500 },
132 .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
133 MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_DECIMATION,
137 .base = { 0x02900, 0x02d00 },
138 .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP,
142 .base = { 0x03100, 0x03500, 0x03900, 0x03d00, 0x04100 },
144 { .id = 0, .pp = 0, .dspp = 0,
145 .caps = MDP_LM_CAP_DISPLAY, },
146 { .id = 1, .pp = 1, .dspp = 1,
147 .caps = MDP_LM_CAP_DISPLAY, },
148 { .id = 2, .pp = 2, .dspp = 2,
149 .caps = MDP_LM_CAP_DISPLAY, },
150 { .id = 3, .pp = -1, .dspp = -1,
151 .caps = MDP_LM_CAP_WB, },
152 { .id = 4, .pp = -1, .dspp = -1,
153 .caps = MDP_LM_CAP_WB, },
157 .max_height = 0xFFFF,
161 .base = { 0x04500, 0x04900, 0x04d00 },
165 .base = { 0x13000, 0x13200 },
169 .base = { 0x12c00, 0x12d00, 0x12e00 },
172 .base = { 0x12400, 0x12600, 0x12800, 0x12a00 },
180 .max_clk = 200000000,
183 static const struct mdp5_cfg_hw apq8084_config = {
187 .caps = MDP_CAP_SMP |
195 [SSPP_VIG0] = 1, [SSPP_VIG1] = 4,
196 [SSPP_VIG2] = 7, [SSPP_VIG3] = 19,
197 [SSPP_DMA0] = 10, [SSPP_DMA1] = 13,
198 [SSPP_RGB0] = 16, [SSPP_RGB1] = 17,
199 [SSPP_RGB2] = 18, [SSPP_RGB3] = 22,
201 .reserved_state[0] = GENMASK(7, 0), /* first 8 MMBs */
203 /* Two SMP blocks are statically tied to RGB pipes: */
204 [16] = 2, [17] = 2, [18] = 2, [22] = 2,
209 .base = { 0x00500, 0x00600, 0x00700, 0x00800, 0x00900 },
210 .flush_hw_mask = 0x003fffff,
214 .base = { 0x01100, 0x01500, 0x01900, 0x01d00 },
215 .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
216 MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_CSC |
217 MDP_PIPE_CAP_DECIMATION,
221 .base = { 0x02100, 0x02500, 0x02900, 0x02d00 },
222 .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
223 MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_DECIMATION,
227 .base = { 0x03100, 0x03500 },
228 .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP,
232 .base = { 0x03900, 0x03d00, 0x04100, 0x04500, 0x04900, 0x04d00 },
234 { .id = 0, .pp = 0, .dspp = 0,
235 .caps = MDP_LM_CAP_DISPLAY |
237 { .id = 1, .pp = 1, .dspp = 1,
238 .caps = MDP_LM_CAP_DISPLAY, },
239 { .id = 2, .pp = 2, .dspp = 2,
240 .caps = MDP_LM_CAP_DISPLAY |
242 { .id = 3, .pp = -1, .dspp = -1,
243 .caps = MDP_LM_CAP_WB, },
244 { .id = 4, .pp = -1, .dspp = -1,
245 .caps = MDP_LM_CAP_WB, },
246 { .id = 5, .pp = 3, .dspp = 3,
247 .caps = MDP_LM_CAP_DISPLAY, },
251 .max_height = 0xFFFF,
255 .base = { 0x05100, 0x05500, 0x05900, 0x05d00 },
260 .base = { 0x13400, 0x13600, 0x13800 },
264 .base = { 0x12e00, 0x12f00, 0x13000, 0x13100 },
267 .base = { 0x12400, 0x12600, 0x12800, 0x12a00, 0x12c00 },
275 .max_clk = 320000000,
278 static const struct mdp5_cfg_hw msm8x16_config = {
283 .caps = MDP_CAP_SMP |
290 [SSPP_VIG0] = 1, [SSPP_DMA0] = 4,
291 [SSPP_RGB0] = 7, [SSPP_RGB1] = 8,
296 .base = { 0x01000, 0x01200, 0x01400, 0x01600, 0x01800 },
297 .flush_hw_mask = 0x4003ffff,
302 .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
303 MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_CSC |
304 MDP_PIPE_CAP_DECIMATION,
308 .base = { 0x14000, 0x16000 },
309 .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
310 MDP_PIPE_CAP_DECIMATION,
315 .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP,
318 .count = 2, /* LM0 and LM3 */
319 .base = { 0x44000, 0x47000 },
321 { .id = 0, .pp = 0, .dspp = 0,
322 .caps = MDP_LM_CAP_DISPLAY, },
323 { .id = 3, .pp = -1, .dspp = -1,
324 .caps = MDP_LM_CAP_WB },
328 .max_height = 0xFFFF,
336 .base = { 0x00000, 0x6a800 },
342 .max_clk = 320000000,
345 static const struct mdp5_cfg_hw msm8x94_config = {
349 .caps = MDP_CAP_SMP |
357 [SSPP_VIG0] = 1, [SSPP_VIG1] = 4,
358 [SSPP_VIG2] = 7, [SSPP_VIG3] = 19,
359 [SSPP_DMA0] = 10, [SSPP_DMA1] = 13,
360 [SSPP_RGB0] = 16, [SSPP_RGB1] = 17,
361 [SSPP_RGB2] = 18, [SSPP_RGB3] = 22,
363 .reserved_state[0] = GENMASK(23, 0), /* first 24 MMBs */
365 [1] = 1, [4] = 1, [7] = 1, [19] = 1,
366 [16] = 5, [17] = 5, [18] = 5, [22] = 5,
371 .base = { 0x01000, 0x01200, 0x01400, 0x01600, 0x01800 },
372 .flush_hw_mask = 0xf0ffffff,
376 .base = { 0x04000, 0x06000, 0x08000, 0x0a000 },
377 .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
378 MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_CSC |
379 MDP_PIPE_CAP_DECIMATION,
383 .base = { 0x14000, 0x16000, 0x18000, 0x1a000 },
384 .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP |
385 MDP_PIPE_CAP_SCALE | MDP_PIPE_CAP_DECIMATION,
389 .base = { 0x24000, 0x26000 },
390 .caps = MDP_PIPE_CAP_HFLIP | MDP_PIPE_CAP_VFLIP,
394 .base = { 0x44000, 0x45000, 0x46000, 0x47000, 0x48000, 0x49000 },
396 { .id = 0, .pp = 0, .dspp = 0,
397 .caps = MDP_LM_CAP_DISPLAY |
399 { .id = 1, .pp = 1, .dspp = 1,
400 .caps = MDP_LM_CAP_DISPLAY, },
401 { .id = 2, .pp = 2, .dspp = 2,
402 .caps = MDP_LM_CAP_DISPLAY |
404 { .id = 3, .pp = -1, .dspp = -1,
405 .caps = MDP_LM_CAP_WB, },
406 { .id = 4, .pp = -1, .dspp = -1,
407 .caps = MDP_LM_CAP_WB, },
408 { .id = 5, .pp = 3, .dspp = 3,
409 .caps = MDP_LM_CAP_DISPLAY, },
413 .max_height = 0xFFFF,
417 .base = { 0x54000, 0x56000, 0x58000, 0x5a000 },
422 .base = { 0x78000, 0x78800, 0x79000 },
426 .base = { 0x70000, 0x70800, 0x71000, 0x71800 },
429 .base = { 0x6a000, 0x6a800, 0x6b000, 0x6b800, 0x6c000 },
437 .max_clk = 400000000,
440 static const struct mdp5_cfg_hw msm8x96_config = {
444 .caps = MDP_CAP_DSC |
451 .base = { 0x01000, 0x01200, 0x01400, 0x01600, 0x01800 },
452 .flush_hw_mask = 0xf4ffffff,
456 .base = { 0x04000, 0x06000, 0x08000, 0x0a000 },
457 .caps = MDP_PIPE_CAP_HFLIP |
461 MDP_PIPE_CAP_DECIMATION |
462 MDP_PIPE_CAP_SW_PIX_EXT |
467 .base = { 0x14000, 0x16000, 0x18000, 0x1a000 },
468 .caps = MDP_PIPE_CAP_HFLIP |
471 MDP_PIPE_CAP_DECIMATION |
472 MDP_PIPE_CAP_SW_PIX_EXT |
477 .base = { 0x24000, 0x26000 },
478 .caps = MDP_PIPE_CAP_HFLIP |
480 MDP_PIPE_CAP_SW_PIX_EXT |
485 .base = { 0x34000, 0x36000 },
486 .caps = MDP_PIPE_CAP_HFLIP |
488 MDP_PIPE_CAP_SW_PIX_EXT |
489 MDP_PIPE_CAP_CURSOR |
495 .base = { 0x44000, 0x45000, 0x46000, 0x47000, 0x48000, 0x49000 },
497 { .id = 0, .pp = 0, .dspp = 0,
498 .caps = MDP_LM_CAP_DISPLAY |
500 { .id = 1, .pp = 1, .dspp = 1,
501 .caps = MDP_LM_CAP_DISPLAY, },
502 { .id = 2, .pp = 2, .dspp = -1,
503 .caps = MDP_LM_CAP_DISPLAY |
505 { .id = 3, .pp = -1, .dspp = -1,
506 .caps = MDP_LM_CAP_WB, },
507 { .id = 4, .pp = -1, .dspp = -1,
508 .caps = MDP_LM_CAP_WB, },
509 { .id = 5, .pp = 3, .dspp = -1,
510 .caps = MDP_LM_CAP_DISPLAY, },
514 .max_height = 0xFFFF,
518 .base = { 0x54000, 0x56000 },
522 .base = { 0x78000, 0x78800, 0x79000 },
526 .base = { 0x70000, 0x70800, 0x71000, 0x71800 },
534 .base = { 0x80000, 0x80400 },
537 .base = { 0x6a000, 0x6a800, 0x6b000, 0x6b800, 0x6c000 },
545 .max_clk = 412500000,
548 const struct mdp5_cfg_hw msm8x76_config = {
552 .caps = MDP_CAP_SMP |
559 .base = { 0x01000, 0x01200, 0x01400 },
560 .flush_hw_mask = 0xffffffff,
566 [SSPP_VIG0] = 1, [SSPP_VIG1] = 9,
568 [SSPP_RGB0] = 7, [SSPP_RGB1] = 8,
573 .base = { 0x04000, 0x06000 },
574 .caps = MDP_PIPE_CAP_HFLIP |
578 MDP_PIPE_CAP_DECIMATION |
579 MDP_PIPE_CAP_SW_PIX_EXT |
584 .base = { 0x14000, 0x16000 },
585 .caps = MDP_PIPE_CAP_HFLIP |
587 MDP_PIPE_CAP_DECIMATION |
588 MDP_PIPE_CAP_SW_PIX_EXT |
594 .caps = MDP_PIPE_CAP_HFLIP |
596 MDP_PIPE_CAP_SW_PIX_EXT |
602 .caps = MDP_PIPE_CAP_HFLIP |
604 MDP_PIPE_CAP_SW_PIX_EXT |
605 MDP_PIPE_CAP_CURSOR |
610 .base = { 0x44000, 0x45000 },
612 { .id = 0, .pp = 0, .dspp = 0,
613 .caps = MDP_LM_CAP_DISPLAY, },
614 { .id = 1, .pp = -1, .dspp = -1,
615 .caps = MDP_LM_CAP_WB },
619 .max_height = 0xFFFF,
628 .base = { 0x70000, 0x70800, 0x72000 },
632 .base = { 0x80000, 0x80400 },
635 .base = { 0x6a000, 0x6a800, 0x6b000 },
642 .max_clk = 360000000,
645 static const struct mdp5_cfg_hw msm8917_config = {
653 .base = { 0x01000, 0x01200, 0x01400 },
654 .flush_hw_mask = 0xffffffff,
659 .caps = MDP_PIPE_CAP_HFLIP |
663 MDP_PIPE_CAP_DECIMATION |
664 MDP_PIPE_CAP_SW_PIX_EXT |
669 .base = { 0x14000, 0x16000 },
670 .caps = MDP_PIPE_CAP_HFLIP |
672 MDP_PIPE_CAP_DECIMATION |
673 MDP_PIPE_CAP_SW_PIX_EXT |
679 .caps = MDP_PIPE_CAP_HFLIP |
681 MDP_PIPE_CAP_SW_PIX_EXT |
687 .caps = MDP_PIPE_CAP_HFLIP |
689 MDP_PIPE_CAP_SW_PIX_EXT |
690 MDP_PIPE_CAP_CURSOR |
696 .base = { 0x44000, 0x45000 },
698 { .id = 0, .pp = 0, .dspp = 0,
699 .caps = MDP_LM_CAP_DISPLAY, },
700 { .id = 1, .pp = -1, .dspp = -1,
701 .caps = MDP_LM_CAP_WB },
705 .max_height = 0xFFFF,
721 .base = { 0x6a000, 0x6a800 },
727 .max_clk = 320000000,
730 static const struct mdp5_cfg_hw msm8998_config = {
734 .caps = MDP_CAP_DSC |
741 .base = { 0x01000, 0x01200, 0x01400, 0x01600, 0x01800 },
742 .flush_hw_mask = 0xf7ffffff,
746 .base = { 0x04000, 0x06000, 0x08000, 0x0a000 },
747 .caps = MDP_PIPE_CAP_HFLIP |
751 MDP_PIPE_CAP_DECIMATION |
752 MDP_PIPE_CAP_SW_PIX_EXT |
757 .base = { 0x14000, 0x16000, 0x18000, 0x1a000 },
758 .caps = MDP_PIPE_CAP_HFLIP |
761 MDP_PIPE_CAP_DECIMATION |
762 MDP_PIPE_CAP_SW_PIX_EXT |
766 .count = 2, /* driver supports max of 2 currently */
767 .base = { 0x24000, 0x26000, 0x28000, 0x2a000 },
768 .caps = MDP_PIPE_CAP_HFLIP |
770 MDP_PIPE_CAP_SW_PIX_EXT |
775 .base = { 0x34000, 0x36000 },
776 .caps = MDP_PIPE_CAP_HFLIP |
778 MDP_PIPE_CAP_SW_PIX_EXT |
779 MDP_PIPE_CAP_CURSOR |
785 .base = { 0x44000, 0x45000, 0x46000, 0x47000, 0x48000, 0x49000 },
787 { .id = 0, .pp = 0, .dspp = 0,
788 .caps = MDP_LM_CAP_DISPLAY |
790 { .id = 1, .pp = 1, .dspp = 1,
791 .caps = MDP_LM_CAP_DISPLAY, },
792 { .id = 2, .pp = 2, .dspp = -1,
793 .caps = MDP_LM_CAP_DISPLAY |
795 { .id = 3, .pp = -1, .dspp = -1,
796 .caps = MDP_LM_CAP_WB, },
797 { .id = 4, .pp = -1, .dspp = -1,
798 .caps = MDP_LM_CAP_WB, },
799 { .id = 5, .pp = 3, .dspp = -1,
800 .caps = MDP_LM_CAP_DISPLAY, },
804 .max_height = 0xFFFF,
808 .base = { 0x54000, 0x56000 },
812 .base = { 0x78000, 0x78800, 0x79000 },
816 .base = { 0x70000, 0x70800, 0x71000, 0x71800 },
824 .base = { 0x80000, 0x80400 },
827 .base = { 0x6a000, 0x6a800, 0x6b000, 0x6b800, 0x6c000 },
835 .max_clk = 412500000,
838 static const struct mdp5_cfg_handler cfg_handlers_v1[] = {
839 { .revision = 0, .config = { .hw = &msm8x74v1_config } },
840 { .revision = 2, .config = { .hw = &msm8x74v2_config } },
841 { .revision = 3, .config = { .hw = &apq8084_config } },
842 { .revision = 6, .config = { .hw = &msm8x16_config } },
843 { .revision = 9, .config = { .hw = &msm8x94_config } },
844 { .revision = 7, .config = { .hw = &msm8x96_config } },
845 { .revision = 11, .config = { .hw = &msm8x76_config } },
846 { .revision = 15, .config = { .hw = &msm8917_config } },
849 static const struct mdp5_cfg_handler cfg_handlers_v3[] = {
850 { .revision = 0, .config = { .hw = &msm8998_config } },
853 static struct mdp5_cfg_platform *mdp5_get_config(struct platform_device *dev);
855 const struct mdp5_cfg_hw *mdp5_cfg_get_hw_config(struct mdp5_cfg_handler *cfg_handler)
857 return cfg_handler->config.hw;
860 struct mdp5_cfg *mdp5_cfg_get_config(struct mdp5_cfg_handler *cfg_handler)
862 return &cfg_handler->config;
865 int mdp5_cfg_get_hw_rev(struct mdp5_cfg_handler *cfg_handler)
867 return cfg_handler->revision;
870 void mdp5_cfg_destroy(struct mdp5_cfg_handler *cfg_handler)
875 struct mdp5_cfg_handler *mdp5_cfg_init(struct mdp5_kms *mdp5_kms,
876 uint32_t major, uint32_t minor)
878 struct drm_device *dev = mdp5_kms->dev;
879 struct platform_device *pdev = to_platform_device(dev->dev);
880 struct mdp5_cfg_handler *cfg_handler;
881 const struct mdp5_cfg_handler *cfg_handlers;
882 struct mdp5_cfg_platform *pconfig;
883 int i, ret = 0, num_handlers;
885 cfg_handler = kzalloc(sizeof(*cfg_handler), GFP_KERNEL);
886 if (unlikely(!cfg_handler)) {
893 cfg_handlers = cfg_handlers_v1;
894 num_handlers = ARRAY_SIZE(cfg_handlers_v1);
897 cfg_handlers = cfg_handlers_v3;
898 num_handlers = ARRAY_SIZE(cfg_handlers_v3);
901 DRM_DEV_ERROR(dev->dev, "unexpected MDP major version: v%d.%d\n",
907 /* only after mdp5_cfg global pointer's init can we access the hw */
908 for (i = 0; i < num_handlers; i++) {
909 if (cfg_handlers[i].revision != minor)
911 mdp5_cfg = cfg_handlers[i].config.hw;
915 if (unlikely(!mdp5_cfg)) {
916 DRM_DEV_ERROR(dev->dev, "unexpected MDP minor revision: v%d.%d\n",
922 cfg_handler->revision = minor;
923 cfg_handler->config.hw = mdp5_cfg;
925 pconfig = mdp5_get_config(pdev);
926 memcpy(&cfg_handler->config.platform, pconfig, sizeof(*pconfig));
928 DBG("MDP5: %s hw config selected", mdp5_cfg->name);
934 mdp5_cfg_destroy(cfg_handler);
939 static struct mdp5_cfg_platform *mdp5_get_config(struct platform_device *dev)
941 static struct mdp5_cfg_platform config = {};
943 config.iommu = iommu_domain_alloc(&platform_bus_type);
945 config.iommu->geometry.aperture_start = 0x1000;
946 config.iommu->geometry.aperture_end = 0xffffffff;