17b7ad5c3SSimon Glass /* 27b7ad5c3SSimon Glass * Copyright (c) 2015 Google, Inc 37b7ad5c3SSimon Glass * Copyright 2014 Rockchip Inc. 47b7ad5c3SSimon Glass * 57b7ad5c3SSimon Glass * SPDX-License-Identifier: GPL-2.0+ 67b7ad5c3SSimon Glass */ 77b7ad5c3SSimon Glass 87b7ad5c3SSimon Glass #include <common.h> 97b7ad5c3SSimon Glass #include <clk.h> 107b7ad5c3SSimon Glass #include <display.h> 117b7ad5c3SSimon Glass #include <dm.h> 127b7ad5c3SSimon Glass #include <edid.h> 137b7ad5c3SSimon Glass #include <regmap.h> 147b7ad5c3SSimon Glass #include <syscon.h> 157b7ad5c3SSimon Glass #include <video.h> 167b7ad5c3SSimon Glass #include <asm/gpio.h> 177b7ad5c3SSimon Glass #include <asm/hardware.h> 187b7ad5c3SSimon Glass #include <asm/io.h> 197b7ad5c3SSimon Glass #include <asm/arch/clock.h> 207b7ad5c3SSimon Glass #include <asm/arch/edp_rk3288.h> 217b7ad5c3SSimon Glass #include <asm/arch/vop_rk3288.h> 227b7ad5c3SSimon Glass #include <dm/device-internal.h> 237b7ad5c3SSimon Glass #include <dm/uclass-internal.h> 247b7ad5c3SSimon Glass #include <power/regulator.h> 25d46d4047SPhilipp Tomsich #include "rk_vop.h" 267b7ad5c3SSimon Glass 277b7ad5c3SSimon Glass DECLARE_GLOBAL_DATA_PTR; 287b7ad5c3SSimon Glass 29d46d4047SPhilipp Tomsich enum vop_pol { 30d46d4047SPhilipp Tomsich HSYNC_POSITIVE = 0, 31d46d4047SPhilipp Tomsich VSYNC_POSITIVE = 1, 32d46d4047SPhilipp Tomsich DEN_NEGATIVE = 2, 33d46d4047SPhilipp Tomsich DCLK_INVERT = 3 347b7ad5c3SSimon Glass }; 357b7ad5c3SSimon Glass 36d46d4047SPhilipp Tomsich static void rkvop_enable(struct rk3288_vop *regs, ulong fbbase, 37d46d4047SPhilipp Tomsich int fb_bits_per_pixel, 38d46d4047SPhilipp Tomsich const struct display_timing *edid) 397b7ad5c3SSimon Glass { 407b7ad5c3SSimon Glass u32 lb_mode; 417b7ad5c3SSimon Glass u32 rgb_mode; 427b7ad5c3SSimon Glass u32 hactive = edid->hactive.typ; 437b7ad5c3SSimon Glass u32 vactive = edid->vactive.typ; 447b7ad5c3SSimon Glass 457b7ad5c3SSimon Glass writel(V_ACT_WIDTH(hactive - 1) | V_ACT_HEIGHT(vactive - 1), 467b7ad5c3SSimon Glass ®s->win0_act_info); 477b7ad5c3SSimon Glass 487b7ad5c3SSimon Glass writel(V_DSP_XST(edid->hsync_len.typ + edid->hback_porch.typ) | 497b7ad5c3SSimon Glass V_DSP_YST(edid->vsync_len.typ + edid->vback_porch.typ), 507b7ad5c3SSimon Glass ®s->win0_dsp_st); 517b7ad5c3SSimon Glass 527b7ad5c3SSimon Glass writel(V_DSP_WIDTH(hactive - 1) | 537b7ad5c3SSimon Glass V_DSP_HEIGHT(vactive - 1), 547b7ad5c3SSimon Glass ®s->win0_dsp_info); 557b7ad5c3SSimon Glass 567b7ad5c3SSimon Glass clrsetbits_le32(®s->win0_color_key, M_WIN0_KEY_EN | M_WIN0_KEY_COLOR, 577b7ad5c3SSimon Glass V_WIN0_KEY_EN(0) | V_WIN0_KEY_COLOR(0)); 587b7ad5c3SSimon Glass 597b7ad5c3SSimon Glass switch (fb_bits_per_pixel) { 607b7ad5c3SSimon Glass case 16: 617b7ad5c3SSimon Glass rgb_mode = RGB565; 627b7ad5c3SSimon Glass writel(V_RGB565_VIRWIDTH(hactive), ®s->win0_vir); 637b7ad5c3SSimon Glass break; 647b7ad5c3SSimon Glass case 24: 657b7ad5c3SSimon Glass rgb_mode = RGB888; 667b7ad5c3SSimon Glass writel(V_RGB888_VIRWIDTH(hactive), ®s->win0_vir); 677b7ad5c3SSimon Glass break; 687b7ad5c3SSimon Glass case 32: 697b7ad5c3SSimon Glass default: 707b7ad5c3SSimon Glass rgb_mode = ARGB8888; 717b7ad5c3SSimon Glass writel(V_ARGB888_VIRWIDTH(hactive), ®s->win0_vir); 727b7ad5c3SSimon Glass break; 737b7ad5c3SSimon Glass } 747b7ad5c3SSimon Glass 757b7ad5c3SSimon Glass if (hactive > 2560) 767b7ad5c3SSimon Glass lb_mode = LB_RGB_3840X2; 777b7ad5c3SSimon Glass else if (hactive > 1920) 787b7ad5c3SSimon Glass lb_mode = LB_RGB_2560X4; 797b7ad5c3SSimon Glass else if (hactive > 1280) 807b7ad5c3SSimon Glass lb_mode = LB_RGB_1920X5; 817b7ad5c3SSimon Glass else 827b7ad5c3SSimon Glass lb_mode = LB_RGB_1280X8; 837b7ad5c3SSimon Glass 847b7ad5c3SSimon Glass clrsetbits_le32(®s->win0_ctrl0, 857b7ad5c3SSimon Glass M_WIN0_LB_MODE | M_WIN0_DATA_FMT | M_WIN0_EN, 867b7ad5c3SSimon Glass V_WIN0_LB_MODE(lb_mode) | V_WIN0_DATA_FMT(rgb_mode) | 877b7ad5c3SSimon Glass V_WIN0_EN(1)); 887b7ad5c3SSimon Glass 897b7ad5c3SSimon Glass writel(fbbase, ®s->win0_yrgb_mst); 907b7ad5c3SSimon Glass writel(0x01, ®s->reg_cfg_done); /* enable reg config */ 917b7ad5c3SSimon Glass } 927b7ad5c3SSimon Glass 93d46d4047SPhilipp Tomsich static void rkvop_set_pin_polarity(struct udevice *dev, 94d46d4047SPhilipp Tomsich enum vop_modes mode, u32 polarity) 957b7ad5c3SSimon Glass { 96d46d4047SPhilipp Tomsich struct rkvop_driverdata *ops = 97d46d4047SPhilipp Tomsich (struct rkvop_driverdata *)dev_get_driver_data(dev); 98d46d4047SPhilipp Tomsich 99d46d4047SPhilipp Tomsich if (ops->set_pin_polarity) 100d46d4047SPhilipp Tomsich ops->set_pin_polarity(dev, mode, polarity); 101d46d4047SPhilipp Tomsich } 102d46d4047SPhilipp Tomsich 103d46d4047SPhilipp Tomsich static void rkvop_enable_output(struct udevice *dev, enum vop_modes mode) 104d46d4047SPhilipp Tomsich { 105d46d4047SPhilipp Tomsich struct rk_vop_priv *priv = dev_get_priv(dev); 106d46d4047SPhilipp Tomsich struct rk3288_vop *regs = priv->regs; 107d46d4047SPhilipp Tomsich 108*6b5a09aaSSimon Glass /* remove from standby */ 109*6b5a09aaSSimon Glass clrbits_le32(®s->sys_ctrl, V_STANDBY_EN(1)); 110*6b5a09aaSSimon Glass 111d46d4047SPhilipp Tomsich switch (mode) { 112d46d4047SPhilipp Tomsich case VOP_MODE_HDMI: 113d46d4047SPhilipp Tomsich clrsetbits_le32(®s->sys_ctrl, M_ALL_OUT_EN, 114d46d4047SPhilipp Tomsich V_HDMI_OUT_EN(1)); 115d46d4047SPhilipp Tomsich break; 116d46d4047SPhilipp Tomsich 117d46d4047SPhilipp Tomsich case VOP_MODE_EDP: 118d46d4047SPhilipp Tomsich clrsetbits_le32(®s->sys_ctrl, M_ALL_OUT_EN, 119d46d4047SPhilipp Tomsich V_EDP_OUT_EN(1)); 120d46d4047SPhilipp Tomsich break; 121d46d4047SPhilipp Tomsich 122d46d4047SPhilipp Tomsich case VOP_MODE_LVDS: 123d46d4047SPhilipp Tomsich clrsetbits_le32(®s->sys_ctrl, M_ALL_OUT_EN, 124d46d4047SPhilipp Tomsich V_RGB_OUT_EN(1)); 125d46d4047SPhilipp Tomsich break; 126d46d4047SPhilipp Tomsich 127d46d4047SPhilipp Tomsich case VOP_MODE_MIPI: 128d46d4047SPhilipp Tomsich clrsetbits_le32(®s->sys_ctrl, M_ALL_OUT_EN, 129d46d4047SPhilipp Tomsich V_MIPI_OUT_EN(1)); 130d46d4047SPhilipp Tomsich break; 131d46d4047SPhilipp Tomsich 132d46d4047SPhilipp Tomsich default: 133d46d4047SPhilipp Tomsich debug("%s: unsupported output mode %x\n", __func__, mode); 134d46d4047SPhilipp Tomsich } 135d46d4047SPhilipp Tomsich } 136d46d4047SPhilipp Tomsich 137d46d4047SPhilipp Tomsich static void rkvop_mode_set(struct udevice *dev, 138d46d4047SPhilipp Tomsich const struct display_timing *edid, 139d46d4047SPhilipp Tomsich enum vop_modes mode) 140d46d4047SPhilipp Tomsich { 141d46d4047SPhilipp Tomsich struct rk_vop_priv *priv = dev_get_priv(dev); 142d46d4047SPhilipp Tomsich struct rk3288_vop *regs = priv->regs; 143d46d4047SPhilipp Tomsich struct rkvop_driverdata *data = 144d46d4047SPhilipp Tomsich (struct rkvop_driverdata *)dev_get_driver_data(dev); 145d46d4047SPhilipp Tomsich 1467b7ad5c3SSimon Glass u32 hactive = edid->hactive.typ; 1477b7ad5c3SSimon Glass u32 vactive = edid->vactive.typ; 1487b7ad5c3SSimon Glass u32 hsync_len = edid->hsync_len.typ; 1497b7ad5c3SSimon Glass u32 hback_porch = edid->hback_porch.typ; 1507b7ad5c3SSimon Glass u32 vsync_len = edid->vsync_len.typ; 1517b7ad5c3SSimon Glass u32 vback_porch = edid->vback_porch.typ; 1527b7ad5c3SSimon Glass u32 hfront_porch = edid->hfront_porch.typ; 1537b7ad5c3SSimon Glass u32 vfront_porch = edid->vfront_porch.typ; 15485307835SJacob Chen int mode_flags; 155d46d4047SPhilipp Tomsich u32 pin_polarity; 1567b7ad5c3SSimon Glass 157d46d4047SPhilipp Tomsich pin_polarity = BIT(DCLK_INVERT); 158d46d4047SPhilipp Tomsich if (edid->flags & DISPLAY_FLAGS_HSYNC_HIGH) 159d46d4047SPhilipp Tomsich pin_polarity |= BIT(HSYNC_POSITIVE); 160d46d4047SPhilipp Tomsich if (edid->flags & DISPLAY_FLAGS_VSYNC_HIGH) 161d46d4047SPhilipp Tomsich pin_polarity |= BIT(VSYNC_POSITIVE); 1627b7ad5c3SSimon Glass 163d46d4047SPhilipp Tomsich rkvop_set_pin_polarity(dev, mode, pin_polarity); 164d46d4047SPhilipp Tomsich rkvop_enable_output(dev, mode); 16585307835SJacob Chen 166d46d4047SPhilipp Tomsich mode_flags = 0; /* RGB888 */ 167d46d4047SPhilipp Tomsich if ((data->features & VOP_FEATURE_OUTPUT_10BIT) && 168d46d4047SPhilipp Tomsich (mode == VOP_MODE_HDMI || mode == VOP_MODE_EDP)) 169d46d4047SPhilipp Tomsich mode_flags = 15; /* RGBaaa */ 1707b7ad5c3SSimon Glass 171d46d4047SPhilipp Tomsich clrsetbits_le32(®s->dsp_ctrl0, M_DSP_OUT_MODE, 172d46d4047SPhilipp Tomsich V_DSP_OUT_MODE(mode_flags)); 1737b7ad5c3SSimon Glass 1747b7ad5c3SSimon Glass writel(V_HSYNC(hsync_len) | 1757b7ad5c3SSimon Glass V_HORPRD(hsync_len + hback_porch + hactive + hfront_porch), 1767b7ad5c3SSimon Glass ®s->dsp_htotal_hs_end); 1777b7ad5c3SSimon Glass 1787b7ad5c3SSimon Glass writel(V_HEAP(hsync_len + hback_porch + hactive) | 1797b7ad5c3SSimon Glass V_HASP(hsync_len + hback_porch), 1807b7ad5c3SSimon Glass ®s->dsp_hact_st_end); 1817b7ad5c3SSimon Glass 1827b7ad5c3SSimon Glass writel(V_VSYNC(vsync_len) | 1837b7ad5c3SSimon Glass V_VERPRD(vsync_len + vback_porch + vactive + vfront_porch), 1847b7ad5c3SSimon Glass ®s->dsp_vtotal_vs_end); 1857b7ad5c3SSimon Glass 1867b7ad5c3SSimon Glass writel(V_VAEP(vsync_len + vback_porch + vactive)| 1877b7ad5c3SSimon Glass V_VASP(vsync_len + vback_porch), 1887b7ad5c3SSimon Glass ®s->dsp_vact_st_end); 1897b7ad5c3SSimon Glass 1907b7ad5c3SSimon Glass writel(V_HEAP(hsync_len + hback_porch + hactive) | 1917b7ad5c3SSimon Glass V_HASP(hsync_len + hback_porch), 1927b7ad5c3SSimon Glass ®s->post_dsp_hact_info); 1937b7ad5c3SSimon Glass 1947b7ad5c3SSimon Glass writel(V_VAEP(vsync_len + vback_porch + vactive)| 1957b7ad5c3SSimon Glass V_VASP(vsync_len + vback_porch), 1967b7ad5c3SSimon Glass ®s->post_dsp_vact_info); 1977b7ad5c3SSimon Glass 1987b7ad5c3SSimon Glass writel(0x01, ®s->reg_cfg_done); /* enable reg config */ 1997b7ad5c3SSimon Glass } 2007b7ad5c3SSimon Glass 2017b7ad5c3SSimon Glass /** 2027b7ad5c3SSimon Glass * rk_display_init() - Try to enable the given display device 2037b7ad5c3SSimon Glass * 2047b7ad5c3SSimon Glass * This function performs many steps: 2057b7ad5c3SSimon Glass * - Finds the display device being referenced by @ep_node 2067b7ad5c3SSimon Glass * - Puts the VOP's ID into its uclass platform data 2077b7ad5c3SSimon Glass * - Probes the device to set it up 2087b7ad5c3SSimon Glass * - Reads the EDID timing information 2097b7ad5c3SSimon Glass * - Sets up the VOP clocks, etc. for the selected pixel clock and display mode 2107b7ad5c3SSimon Glass * - Enables the display (the display device handles this and will do different 2117b7ad5c3SSimon Glass * things depending on the display type) 2127b7ad5c3SSimon Glass * - Tells the uclass about the display resolution so that the console will 2137b7ad5c3SSimon Glass * appear correctly 2147b7ad5c3SSimon Glass * 2157b7ad5c3SSimon Glass * @dev: VOP device that we want to connect to the display 2167b7ad5c3SSimon Glass * @fbbase: Frame buffer address 2177b7ad5c3SSimon Glass * @ep_node: Device tree node to process - this is the offset of an endpoint 2187b7ad5c3SSimon Glass * node within the VOP's 'port' list. 2197b7ad5c3SSimon Glass * @return 0 if OK, -ve if something went wrong 2207b7ad5c3SSimon Glass */ 221d46d4047SPhilipp Tomsich static int rk_display_init(struct udevice *dev, ulong fbbase, int ep_node) 2227b7ad5c3SSimon Glass { 2237b7ad5c3SSimon Glass struct video_priv *uc_priv = dev_get_uclass_priv(dev); 2247b7ad5c3SSimon Glass const void *blob = gd->fdt_blob; 2257b7ad5c3SSimon Glass struct rk_vop_priv *priv = dev_get_priv(dev); 2267b7ad5c3SSimon Glass int vop_id, remote_vop_id; 2277b7ad5c3SSimon Glass struct rk3288_vop *regs = priv->regs; 2287b7ad5c3SSimon Glass struct display_timing timing; 2297b7ad5c3SSimon Glass struct udevice *disp; 2307b7ad5c3SSimon Glass int ret, remote, i, offset; 2317b7ad5c3SSimon Glass struct display_plat *disp_uc_plat; 232135aa950SStephen Warren struct clk clk; 2338aed0d77SEric Gao enum video_log2_bpp l2bpp; 2347b7ad5c3SSimon Glass 2357b7ad5c3SSimon Glass vop_id = fdtdec_get_int(blob, ep_node, "reg", -1); 2367b7ad5c3SSimon Glass debug("vop_id=%d\n", vop_id); 2377b7ad5c3SSimon Glass remote = fdtdec_lookup_phandle(blob, ep_node, "remote-endpoint"); 2387b7ad5c3SSimon Glass if (remote < 0) 2397b7ad5c3SSimon Glass return -EINVAL; 2407b7ad5c3SSimon Glass remote_vop_id = fdtdec_get_int(blob, remote, "reg", -1); 2417b7ad5c3SSimon Glass debug("remote vop_id=%d\n", remote_vop_id); 2427b7ad5c3SSimon Glass 2437b7ad5c3SSimon Glass for (i = 0, offset = remote; i < 3 && offset > 0; i++) 2447b7ad5c3SSimon Glass offset = fdt_parent_offset(blob, offset); 2457b7ad5c3SSimon Glass if (offset < 0) { 2467b7ad5c3SSimon Glass debug("%s: Invalid remote-endpoint position\n", dev->name); 2477b7ad5c3SSimon Glass return -EINVAL; 2487b7ad5c3SSimon Glass } 2497b7ad5c3SSimon Glass 2507b7ad5c3SSimon Glass ret = uclass_find_device_by_of_offset(UCLASS_DISPLAY, offset, &disp); 2517b7ad5c3SSimon Glass if (ret) { 2527b7ad5c3SSimon Glass debug("%s: device '%s' display not found (ret=%d)\n", __func__, 2537b7ad5c3SSimon Glass dev->name, ret); 2547b7ad5c3SSimon Glass return ret; 2557b7ad5c3SSimon Glass } 2567b7ad5c3SSimon Glass 2577b7ad5c3SSimon Glass disp_uc_plat = dev_get_uclass_platdata(disp); 2587b7ad5c3SSimon Glass debug("Found device '%s', disp_uc_priv=%p\n", disp->name, disp_uc_plat); 259987a404aSSimon Glass if (display_in_use(disp)) { 260987a404aSSimon Glass debug(" - device in use\n"); 261987a404aSSimon Glass return -EBUSY; 262987a404aSSimon Glass } 263987a404aSSimon Glass 2647b7ad5c3SSimon Glass disp_uc_plat->source_id = remote_vop_id; 2657b7ad5c3SSimon Glass disp_uc_plat->src_dev = dev; 2667b7ad5c3SSimon Glass 2677b7ad5c3SSimon Glass ret = device_probe(disp); 2687b7ad5c3SSimon Glass if (ret) { 2697b7ad5c3SSimon Glass debug("%s: device '%s' display won't probe (ret=%d)\n", 2707b7ad5c3SSimon Glass __func__, dev->name, ret); 2717b7ad5c3SSimon Glass return ret; 2727b7ad5c3SSimon Glass } 2737b7ad5c3SSimon Glass 2747b7ad5c3SSimon Glass ret = display_read_timing(disp, &timing); 2757b7ad5c3SSimon Glass if (ret) { 2767b7ad5c3SSimon Glass debug("%s: Failed to read timings\n", __func__); 2777b7ad5c3SSimon Glass return ret; 2787b7ad5c3SSimon Glass } 2797b7ad5c3SSimon Glass 2809ed68260SSimon Glass ret = clk_get_by_index(dev, 1, &clk); 281135aa950SStephen Warren if (!ret) 282135aa950SStephen Warren ret = clk_set_rate(&clk, timing.pixelclock.typ); 283e07e5bdeSEric Gao if (IS_ERR_VALUE(ret)) { 2847b7ad5c3SSimon Glass debug("%s: Failed to set pixel clock: ret=%d\n", __func__, ret); 2857b7ad5c3SSimon Glass return ret; 2867b7ad5c3SSimon Glass } 2877b7ad5c3SSimon Glass 2888aed0d77SEric Gao /* Set bitwidth for vop display according to vop mode */ 2898aed0d77SEric Gao switch (vop_id) { 2908aed0d77SEric Gao case VOP_MODE_EDP: 2918aed0d77SEric Gao case VOP_MODE_LVDS: 2928aed0d77SEric Gao l2bpp = VIDEO_BPP16; 2938aed0d77SEric Gao break; 294d46d4047SPhilipp Tomsich case VOP_MODE_HDMI: 2958aed0d77SEric Gao case VOP_MODE_MIPI: 2968aed0d77SEric Gao l2bpp = VIDEO_BPP32; 2978aed0d77SEric Gao break; 2988aed0d77SEric Gao default: 2998aed0d77SEric Gao l2bpp = VIDEO_BPP16; 3008aed0d77SEric Gao } 3017b7ad5c3SSimon Glass 302d46d4047SPhilipp Tomsich rkvop_mode_set(dev, &timing, vop_id); 3037b7ad5c3SSimon Glass rkvop_enable(regs, fbbase, 1 << l2bpp, &timing); 3047b7ad5c3SSimon Glass 3057b7ad5c3SSimon Glass ret = display_enable(disp, 1 << l2bpp, &timing); 3067b7ad5c3SSimon Glass if (ret) 3077b7ad5c3SSimon Glass return ret; 3087b7ad5c3SSimon Glass 3097b7ad5c3SSimon Glass uc_priv->xsize = timing.hactive.typ; 3107b7ad5c3SSimon Glass uc_priv->ysize = timing.vactive.typ; 3117b7ad5c3SSimon Glass uc_priv->bpix = l2bpp; 3127b7ad5c3SSimon Glass debug("fb=%lx, size=%d %d\n", fbbase, uc_priv->xsize, uc_priv->ysize); 3137b7ad5c3SSimon Glass 3147b7ad5c3SSimon Glass return 0; 3157b7ad5c3SSimon Glass } 3167b7ad5c3SSimon Glass 317d46d4047SPhilipp Tomsich void rk_vop_probe_regulators(struct udevice *dev, 318d46d4047SPhilipp Tomsich const char * const *names, int cnt) 319d46d4047SPhilipp Tomsich { 320d46d4047SPhilipp Tomsich int i, ret; 321d46d4047SPhilipp Tomsich const char *name; 322d46d4047SPhilipp Tomsich struct udevice *reg; 323d46d4047SPhilipp Tomsich 324d46d4047SPhilipp Tomsich for (i = 0; i < cnt; ++i) { 325d46d4047SPhilipp Tomsich name = names[i]; 326d46d4047SPhilipp Tomsich debug("%s: probing regulator '%s'\n", dev->name, name); 327d46d4047SPhilipp Tomsich 328d46d4047SPhilipp Tomsich ret = regulator_autoset_by_name(name, ®); 329d46d4047SPhilipp Tomsich if (!ret) 330d46d4047SPhilipp Tomsich ret = regulator_set_enable(reg, true); 331d46d4047SPhilipp Tomsich } 332d46d4047SPhilipp Tomsich } 333d46d4047SPhilipp Tomsich 334d46d4047SPhilipp Tomsich int rk_vop_probe(struct udevice *dev) 3357b7ad5c3SSimon Glass { 3367b7ad5c3SSimon Glass struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); 3377b7ad5c3SSimon Glass const void *blob = gd->fdt_blob; 3387b7ad5c3SSimon Glass struct rk_vop_priv *priv = dev_get_priv(dev); 339d46d4047SPhilipp Tomsich int ret = 0; 340d46d4047SPhilipp Tomsich int port, node; 3417b7ad5c3SSimon Glass 3427b7ad5c3SSimon Glass /* Before relocation we don't need to do anything */ 3437b7ad5c3SSimon Glass if (!(gd->flags & GD_FLG_RELOC)) 3447b7ad5c3SSimon Glass return 0; 3457b7ad5c3SSimon Glass 346a821c4afSSimon Glass priv->regs = (struct rk3288_vop *)devfdt_get_addr(dev); 3477b7ad5c3SSimon Glass 3487b7ad5c3SSimon Glass /* 3497b7ad5c3SSimon Glass * Try all the ports until we find one that works. In practice this 3507b7ad5c3SSimon Glass * tries EDP first if available, then HDMI. 351987a404aSSimon Glass * 352987a404aSSimon Glass * Note that rockchip_vop_set_clk() always uses NPLL as the source 353987a404aSSimon Glass * clock so it is currently not possible to use more than one display 354987a404aSSimon Glass * device simultaneously. 3557b7ad5c3SSimon Glass */ 356e160f7d4SSimon Glass port = fdt_subnode_offset(blob, dev_of_offset(dev), "port"); 3577b7ad5c3SSimon Glass if (port < 0) 3587b7ad5c3SSimon Glass return -EINVAL; 3597b7ad5c3SSimon Glass for (node = fdt_first_subnode(blob, port); 3607b7ad5c3SSimon Glass node > 0; 3617b7ad5c3SSimon Glass node = fdt_next_subnode(blob, node)) { 3628aed0d77SEric Gao ret = rk_display_init(dev, plat->base, node); 3637b7ad5c3SSimon Glass if (ret) 3647b7ad5c3SSimon Glass debug("Device failed: ret=%d\n", ret); 3657b7ad5c3SSimon Glass if (!ret) 3667b7ad5c3SSimon Glass break; 3677b7ad5c3SSimon Glass } 368b55e04a0SSimon Glass video_set_flush_dcache(dev, 1); 3697b7ad5c3SSimon Glass 3707b7ad5c3SSimon Glass return ret; 3717b7ad5c3SSimon Glass } 3727b7ad5c3SSimon Glass 373d46d4047SPhilipp Tomsich int rk_vop_bind(struct udevice *dev) 3747b7ad5c3SSimon Glass { 3757b7ad5c3SSimon Glass struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); 3767b7ad5c3SSimon Glass 37789b2b618SPhilipp Tomsich plat->size = 4 * (CONFIG_VIDEO_ROCKCHIP_MAX_XRES * 37889b2b618SPhilipp Tomsich CONFIG_VIDEO_ROCKCHIP_MAX_YRES); 3797b7ad5c3SSimon Glass 3807b7ad5c3SSimon Glass return 0; 3817b7ad5c3SSimon Glass } 382