rk3399_hdmi.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (c) 2017 Theobroma Systems Design und Consulting GmbH
  4. */
  5. #include <common.h>
  6. #include <clk.h>
  7. #include <display.h>
  8. #include <dm.h>
  9. #include <dw_hdmi.h>
  10. #include <edid.h>
  11. #include <regmap.h>
  12. #include <syscon.h>
  13. #include <asm/gpio.h>
  14. #include <asm/io.h>
  15. #include <asm/arch-rockchip/clock.h>
  16. #include <asm/arch-rockchip/hardware.h>
  17. #include <asm/arch-rockchip/grf_rk3399.h>
  18. #include <power/regulator.h>
  19. #include "rk_hdmi.h"
  20. static int rk3399_hdmi_enable(struct udevice *dev, int panel_bpp,
  21. const struct display_timing *edid)
  22. {
  23. struct rk_hdmi_priv *priv = dev_get_priv(dev);
  24. struct display_plat *uc_plat = dev_get_uclass_platdata(dev);
  25. int vop_id = uc_plat->source_id;
  26. struct rk3399_grf_regs *grf = priv->grf;
  27. /* select the hdmi encoder input data from our source_id */
  28. rk_clrsetreg(&grf->soc_con20, GRF_RK3399_HDMI_VOP_SEL_MASK,
  29. (vop_id == 1) ? GRF_RK3399_HDMI_VOP_SEL_L : 0);
  30. return dw_hdmi_enable(&priv->hdmi, edid);
  31. }
  32. static int rk3399_hdmi_ofdata_to_platdata(struct udevice *dev)
  33. {
  34. struct rk_hdmi_priv *priv = dev_get_priv(dev);
  35. struct dw_hdmi *hdmi = &priv->hdmi;
  36. hdmi->i2c_clk_high = 0x7a;
  37. hdmi->i2c_clk_low = 0x8d;
  38. return rk_hdmi_ofdata_to_platdata(dev);
  39. }
  40. static const char * const rk3399_regulator_names[] = {
  41. "vcc1v8_hdmi",
  42. "vcc0v9_hdmi"
  43. };
  44. static int rk3399_hdmi_probe(struct udevice *dev)
  45. {
  46. /* Enable regulators required for HDMI */
  47. rk_hdmi_probe_regulators(dev, rk3399_regulator_names,
  48. ARRAY_SIZE(rk3399_regulator_names));
  49. return rk_hdmi_probe(dev);
  50. }
  51. static const struct dm_display_ops rk3399_hdmi_ops = {
  52. .read_edid = rk_hdmi_read_edid,
  53. .enable = rk3399_hdmi_enable,
  54. };
  55. static const struct udevice_id rk3399_hdmi_ids[] = {
  56. { .compatible = "rockchip,rk3399-dw-hdmi" },
  57. { }
  58. };
  59. U_BOOT_DRIVER(rk3399_hdmi_rockchip) = {
  60. .name = "rk3399_hdmi_rockchip",
  61. .id = UCLASS_DISPLAY,
  62. .of_match = rk3399_hdmi_ids,
  63. .ops = &rk3399_hdmi_ops,
  64. .ofdata_to_platdata = rk3399_hdmi_ofdata_to_platdata,
  65. .probe = rk3399_hdmi_probe,
  66. .priv_auto_alloc_size = sizeof(struct rk_hdmi_priv),
  67. };