rk3399_vop.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (c) 2017 Theobroma Systems Design und Consulting GmbH
  4. * Copyright (c) 2015 Google, Inc
  5. * Copyright 2014 Rockchip Inc.
  6. */
  7. #include <common.h>
  8. #include <display.h>
  9. #include <dm.h>
  10. #include <regmap.h>
  11. #include <video.h>
  12. #include <asm/hardware.h>
  13. #include <asm/io.h>
  14. #include "rk_vop.h"
  15. DECLARE_GLOBAL_DATA_PTR;
  16. static void rk3399_set_pin_polarity(struct udevice *dev,
  17. enum vop_modes mode, u32 polarity)
  18. {
  19. struct rk_vop_priv *priv = dev_get_priv(dev);
  20. struct rk3288_vop *regs = priv->regs;
  21. /*
  22. * The RK3399 VOPs (v3.5 and v3.6) require a per-mode setting of
  23. * the polarity configuration (in ctrl1).
  24. */
  25. switch (mode) {
  26. case VOP_MODE_HDMI:
  27. clrsetbits_le32(&regs->dsp_ctrl1,
  28. M_RK3399_DSP_HDMI_POL,
  29. V_RK3399_DSP_HDMI_POL(polarity));
  30. break;
  31. case VOP_MODE_EDP:
  32. clrsetbits_le32(&regs->dsp_ctrl1,
  33. M_RK3399_DSP_EDP_POL,
  34. V_RK3399_DSP_EDP_POL(polarity));
  35. break;
  36. case VOP_MODE_MIPI:
  37. clrsetbits_le32(&regs->dsp_ctrl1,
  38. M_RK3399_DSP_MIPI_POL,
  39. V_RK3399_DSP_MIPI_POL(polarity));
  40. break;
  41. case VOP_MODE_LVDS:
  42. /* The RK3399 has neither parallel RGB nor LVDS output. */
  43. default:
  44. debug("%s: unsupported output mode %x\n", __func__, mode);
  45. }
  46. }
  47. /*
  48. * Try some common regulators. We should really get these from the
  49. * device tree somehow.
  50. */
  51. static const char * const rk3399_regulator_names[] = {
  52. "vcc33_lcd"
  53. };
  54. static int rk3399_vop_probe(struct udevice *dev)
  55. {
  56. /* Before relocation we don't need to do anything */
  57. if (!(gd->flags & GD_FLG_RELOC))
  58. return 0;
  59. /* Probe regulators required for the RK3399 VOP */
  60. rk_vop_probe_regulators(dev, rk3399_regulator_names,
  61. ARRAY_SIZE(rk3399_regulator_names));
  62. return rk_vop_probe(dev);
  63. }
  64. struct rkvop_driverdata rk3399_lit_driverdata = {
  65. .set_pin_polarity = rk3399_set_pin_polarity,
  66. };
  67. struct rkvop_driverdata rk3399_big_driverdata = {
  68. .features = VOP_FEATURE_OUTPUT_10BIT,
  69. .set_pin_polarity = rk3399_set_pin_polarity,
  70. };
  71. static const struct udevice_id rk3399_vop_ids[] = {
  72. { .compatible = "rockchip,rk3399-vop-big",
  73. .data = (ulong)&rk3399_big_driverdata },
  74. { .compatible = "rockchip,rk3399-vop-lit",
  75. .data = (ulong)&rk3399_lit_driverdata },
  76. { }
  77. };
  78. static const struct video_ops rk3399_vop_ops = {
  79. };
  80. U_BOOT_DRIVER(rk3399_vop) = {
  81. .name = "rk3399_vop",
  82. .id = UCLASS_VIDEO,
  83. .of_match = rk3399_vop_ids,
  84. .ops = &rk3399_vop_ops,
  85. .bind = rk_vop_bind,
  86. .probe = rk3399_vop_probe,
  87. .priv_auto_alloc_size = sizeof(struct rk_vop_priv),
  88. };