.. | .. |
---|
68 | 68 | }; |
---|
69 | 69 | |
---|
70 | 70 | struct rockchip_rgb_data { |
---|
71 | | - u32 max_dclk_rate; |
---|
| 71 | + u32 rgb_max_dclk_rate; |
---|
| 72 | + u32 mcu_max_dclk_rate; |
---|
72 | 73 | const struct rockchip_rgb_funcs *funcs; |
---|
73 | 74 | }; |
---|
74 | 75 | |
---|
.. | .. |
---|
129 | 130 | struct rockchip_rgb { |
---|
130 | 131 | u8 id; |
---|
131 | 132 | u32 max_dclk_rate; |
---|
| 133 | + u32 mcu_pix_total; |
---|
132 | 134 | struct device *dev; |
---|
| 135 | + struct device_node *np_mcu_panel; |
---|
133 | 136 | struct drm_panel *panel; |
---|
134 | 137 | struct drm_bridge *bridge; |
---|
135 | 138 | struct drm_connector connector; |
---|
.. | .. |
---|
137 | 140 | struct phy *phy; |
---|
138 | 141 | struct regmap *grf; |
---|
139 | 142 | bool data_sync_bypass; |
---|
140 | | - bool is_mcu_panel; |
---|
141 | 143 | bool phy_enabled; |
---|
142 | 144 | const struct rockchip_rgb_funcs *funcs; |
---|
143 | 145 | struct rockchip_drm_sub_dev sub_dev; |
---|
.. | .. |
---|
277 | 279 | s->output_mode = ROCKCHIP_OUT_MODE_P565; |
---|
278 | 280 | s->output_if = VOP_OUTPUT_IF_RGB; |
---|
279 | 281 | break; |
---|
| 282 | + case MEDIA_BUS_FMT_RGB565_2X8_LE: |
---|
| 283 | + case MEDIA_BUS_FMT_BGR565_2X8_LE: |
---|
| 284 | + s->output_mode = ROCKCHIP_OUT_MODE_S565; |
---|
| 285 | + s->output_if = VOP_OUTPUT_IF_RGB; |
---|
| 286 | + break; |
---|
| 287 | + case MEDIA_BUS_FMT_RGB666_3X6: |
---|
| 288 | + s->output_mode = ROCKCHIP_OUT_MODE_S666; |
---|
| 289 | + s->output_if = VOP_OUTPUT_IF_RGB; |
---|
| 290 | + break; |
---|
280 | 291 | case MEDIA_BUS_FMT_RGB888_3X8: |
---|
281 | 292 | case MEDIA_BUS_FMT_BGR888_3X8: |
---|
282 | 293 | s->output_mode = ROCKCHIP_OUT_MODE_S888; |
---|
.. | .. |
---|
323 | 334 | { |
---|
324 | 335 | struct rockchip_rgb *rgb = encoder_to_rgb(encoder); |
---|
325 | 336 | |
---|
326 | | - if (rgb->is_mcu_panel) { |
---|
| 337 | + if (rgb->np_mcu_panel) { |
---|
327 | 338 | struct rockchip_mcu_panel *mcu_panel = to_rockchip_mcu_panel(rgb->panel); |
---|
328 | 339 | |
---|
329 | 340 | mcu_panel->prepared = true; |
---|
.. | .. |
---|
358 | 369 | { |
---|
359 | 370 | struct rockchip_rgb *rgb = encoder_to_rgb(encoder); |
---|
360 | 371 | struct device *dev = rgb->dev; |
---|
| 372 | + struct drm_display_info *info = &rgb->connector.display_info; |
---|
361 | 373 | u32 request_clock = mode->clock; |
---|
362 | 374 | u32 max_clock = rgb->max_dclk_rate; |
---|
| 375 | + u32 bus_format; |
---|
| 376 | + |
---|
| 377 | + if (info->num_bus_formats) |
---|
| 378 | + bus_format = info->bus_formats[0]; |
---|
| 379 | + else |
---|
| 380 | + bus_format = MEDIA_BUS_FMT_RGB888_1X24; |
---|
363 | 381 | |
---|
364 | 382 | if (mode->flags & DRM_MODE_FLAG_DBLCLK) |
---|
365 | 383 | request_clock *= 2; |
---|
| 384 | + |
---|
| 385 | + if (rgb->np_mcu_panel) |
---|
| 386 | + request_clock *= rockchip_drm_get_cycles_per_pixel(bus_format) * |
---|
| 387 | + (rgb->mcu_pix_total + 1); |
---|
366 | 388 | |
---|
367 | 389 | if (max_clock != 0 && request_clock > max_clock) { |
---|
368 | 390 | DRM_DEV_ERROR(dev, "mode [%dx%d] clock %d is higher than max_clock %d\n", |
---|
.. | .. |
---|
444 | 466 | return 0; |
---|
445 | 467 | } |
---|
446 | 468 | |
---|
447 | | -static int rockchip_mcu_panel_init(struct rockchip_rgb *rgb, struct device_node *np_mcu_panel) |
---|
| 469 | +static int rockchip_mcu_panel_init(struct rockchip_rgb *rgb) |
---|
448 | 470 | { |
---|
449 | 471 | struct device *dev = rgb->dev; |
---|
450 | | - struct device_node *port, *endpoint, *np_crtc, *remote; |
---|
| 472 | + struct device_node *np_mcu_panel = rgb->np_mcu_panel; |
---|
| 473 | + struct device_node *port, *endpoint, *np_crtc, *remote, *np_mcu_timing; |
---|
451 | 474 | struct rockchip_mcu_panel *mcu_panel = to_rockchip_mcu_panel(rgb->panel); |
---|
452 | 475 | struct drm_display_mode *mode; |
---|
453 | 476 | const void *data; |
---|
454 | 477 | int len; |
---|
455 | 478 | int ret; |
---|
456 | 479 | u32 bus_flags; |
---|
| 480 | + u32 val; |
---|
457 | 481 | |
---|
458 | 482 | mcu_panel->enable_gpio = devm_fwnode_gpiod_get_index(dev, &np_mcu_panel->fwnode, |
---|
459 | 483 | "enable", 0, GPIOD_ASIS, |
---|
.. | .. |
---|
544 | 568 | if (remote) { |
---|
545 | 569 | np_crtc = of_get_next_parent(remote); |
---|
546 | 570 | mcu_panel->np_crtc = np_crtc; |
---|
| 571 | + |
---|
| 572 | + of_node_put(np_crtc); |
---|
547 | 573 | break; |
---|
548 | 574 | } |
---|
549 | 575 | } |
---|
.. | .. |
---|
553 | 579 | DRM_DEV_ERROR(dev, "failed to find available crtc for mcu panel\n"); |
---|
554 | 580 | return -EINVAL; |
---|
555 | 581 | } |
---|
| 582 | + |
---|
| 583 | + np_mcu_timing = of_get_child_by_name(mcu_panel->np_crtc, "mcu-timing"); |
---|
| 584 | + if (!np_mcu_timing) { |
---|
| 585 | + np_crtc = of_get_parent(mcu_panel->np_crtc); |
---|
| 586 | + if (np_crtc) |
---|
| 587 | + np_mcu_timing = of_get_child_by_name(np_crtc, "mcu-timing"); |
---|
| 588 | + |
---|
| 589 | + if (!np_mcu_timing) { |
---|
| 590 | + DRM_DEV_ERROR(dev, "failed to find timing config for mcu panel\n"); |
---|
| 591 | + of_node_put(np_crtc); |
---|
| 592 | + return -EINVAL; |
---|
| 593 | + } |
---|
| 594 | + |
---|
| 595 | + of_node_put(np_crtc); |
---|
| 596 | + } |
---|
| 597 | + |
---|
| 598 | + ret = of_property_read_u32(np_mcu_timing, "mcu-pix-total", &val); |
---|
| 599 | + if (ret || val == 0) { |
---|
| 600 | + DRM_DEV_ERROR(dev, "failed to parse mcu_pix_total config\n"); |
---|
| 601 | + of_node_put(np_mcu_timing); |
---|
| 602 | + return -EINVAL; |
---|
| 603 | + } |
---|
| 604 | + rgb->mcu_pix_total = val; |
---|
| 605 | + |
---|
| 606 | + of_node_put(np_mcu_timing); |
---|
556 | 607 | } |
---|
557 | 608 | |
---|
558 | 609 | return 0; |
---|
.. | .. |
---|
741 | 792 | .get_modes = rockchip_mcu_panel_get_modes, |
---|
742 | 793 | }; |
---|
743 | 794 | |
---|
744 | | -static struct backlight_device *rockchip_mcu_panel_find_backlight(struct device_node *np_mcu_panel) |
---|
| 795 | +static struct backlight_device *rockchip_mcu_panel_find_backlight(struct rockchip_rgb *rgb) |
---|
745 | 796 | { |
---|
746 | 797 | struct backlight_device *bd = NULL; |
---|
| 798 | + struct device_node *np_mcu_panel = rgb->np_mcu_panel; |
---|
747 | 799 | struct device_node *np = NULL; |
---|
748 | 800 | |
---|
749 | 801 | np = of_parse_phandle(np_mcu_panel, "backlight", 0); |
---|
.. | .. |
---|
768 | 820 | struct drm_device *drm_dev = data; |
---|
769 | 821 | struct drm_encoder *encoder = &rgb->encoder; |
---|
770 | 822 | struct drm_connector *connector; |
---|
771 | | - struct fwnode_handle *fwnode_mcu_panel; |
---|
772 | 823 | int ret; |
---|
773 | 824 | |
---|
774 | | - fwnode_mcu_panel = device_get_named_child_node(dev, "mcu-panel"); |
---|
775 | | - if (fwnode_mcu_panel) { |
---|
| 825 | + if (rgb->np_mcu_panel) { |
---|
776 | 826 | struct rockchip_mcu_panel *mcu_panel; |
---|
777 | | - struct device_node *np_mcu_panel = to_of_node(fwnode_mcu_panel); |
---|
778 | 827 | |
---|
779 | 828 | mcu_panel = devm_kzalloc(dev, sizeof(*mcu_panel), GFP_KERNEL); |
---|
780 | 829 | if (!mcu_panel) { |
---|
781 | | - of_node_put(np_mcu_panel); |
---|
782 | 830 | return -ENOMEM; |
---|
783 | 831 | } |
---|
784 | 832 | mcu_panel->drm_dev = drm_dev; |
---|
785 | 833 | |
---|
786 | 834 | rgb->panel = &mcu_panel->base; |
---|
787 | 835 | |
---|
788 | | - ret = rockchip_mcu_panel_init(rgb, np_mcu_panel); |
---|
| 836 | + ret = rockchip_mcu_panel_init(rgb); |
---|
789 | 837 | if (ret < 0) { |
---|
790 | 838 | DRM_DEV_ERROR(dev, "failed to init mcu panel: %d\n", ret); |
---|
791 | | - of_node_put(np_mcu_panel); |
---|
792 | 839 | return ret; |
---|
793 | 840 | } |
---|
794 | 841 | |
---|
795 | | - rgb->panel->backlight = rockchip_mcu_panel_find_backlight(np_mcu_panel); |
---|
| 842 | + rgb->panel->backlight = rockchip_mcu_panel_find_backlight(rgb); |
---|
796 | 843 | if (!rgb->panel->backlight) { |
---|
797 | 844 | DRM_DEV_ERROR(dev, "failed to find backlight device"); |
---|
798 | | - of_node_put(np_mcu_panel); |
---|
799 | 845 | return -EINVAL; |
---|
800 | 846 | } |
---|
801 | | - |
---|
802 | | - of_node_put(np_mcu_panel); |
---|
803 | 847 | |
---|
804 | 848 | drm_panel_init(&mcu_panel->base, dev, &rockchip_mcu_panel_funcs, |
---|
805 | 849 | DRM_MODE_CONNECTOR_DPI); |
---|
806 | 850 | |
---|
807 | 851 | drm_panel_add(&mcu_panel->base); |
---|
808 | | - |
---|
809 | | - rgb->is_mcu_panel = true; |
---|
810 | 852 | } else { |
---|
811 | 853 | ret = drm_of_find_panel_or_bridge(dev->of_node, 1, -1, |
---|
812 | 854 | &rgb->panel, &rgb->bridge); |
---|
.. | .. |
---|
899 | 941 | struct device *dev = &pdev->dev; |
---|
900 | 942 | struct rockchip_rgb *rgb; |
---|
901 | 943 | const struct rockchip_rgb_data *rgb_data; |
---|
| 944 | + struct fwnode_handle *fwnode_mcu_panel; |
---|
902 | 945 | int ret, id; |
---|
903 | 946 | |
---|
904 | 947 | rgb = devm_kzalloc(&pdev->dev, sizeof(*rgb), GFP_KERNEL); |
---|
.. | .. |
---|
909 | 952 | if (id < 0) |
---|
910 | 953 | id = 0; |
---|
911 | 954 | |
---|
| 955 | + rgb->data_sync_bypass = of_property_read_bool(dev->of_node, "rockchip,data-sync-bypass"); |
---|
| 956 | + |
---|
| 957 | + fwnode_mcu_panel = device_get_named_child_node(dev, "mcu-panel"); |
---|
| 958 | + if (fwnode_mcu_panel) |
---|
| 959 | + rgb->np_mcu_panel = to_of_node(fwnode_mcu_panel); |
---|
| 960 | + |
---|
912 | 961 | rgb_data = of_device_get_match_data(dev); |
---|
913 | 962 | if (rgb_data) { |
---|
914 | | - rgb->max_dclk_rate = rgb_data->max_dclk_rate; |
---|
915 | 963 | rgb->funcs = rgb_data->funcs; |
---|
| 964 | + if (rgb->np_mcu_panel) |
---|
| 965 | + rgb->max_dclk_rate = rgb_data->mcu_max_dclk_rate; |
---|
| 966 | + else |
---|
| 967 | + rgb->max_dclk_rate = rgb_data->rgb_max_dclk_rate; |
---|
916 | 968 | } |
---|
917 | 969 | rgb->id = id; |
---|
918 | 970 | rgb->dev = dev; |
---|
919 | 971 | platform_set_drvdata(pdev, rgb); |
---|
920 | | - |
---|
921 | | - rgb->data_sync_bypass = |
---|
922 | | - of_property_read_bool(dev->of_node, "rockchip,data-sync-bypass"); |
---|
923 | 972 | |
---|
924 | 973 | if (dev->parent && dev->parent->of_node) { |
---|
925 | 974 | rgb->grf = syscon_node_to_regmap(dev->parent->of_node); |
---|
.. | .. |
---|
1061 | 1110 | }; |
---|
1062 | 1111 | |
---|
1063 | 1112 | static const struct rockchip_rgb_data rv1106_rgb = { |
---|
1064 | | - .max_dclk_rate = 74250, |
---|
| 1113 | + .rgb_max_dclk_rate = 74250, |
---|
| 1114 | + .mcu_max_dclk_rate = 150000, |
---|
1065 | 1115 | .funcs = &rv1106_rgb_funcs, |
---|
1066 | 1116 | }; |
---|
1067 | 1117 | |
---|