rk3288_vop.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 <syscon.h>
  12. #include <video.h>
  13. #include <asm/io.h>
  14. #include <asm/arch-rockchip/clock.h>
  15. #include <asm/arch-rockchip/grf_rk3288.h>
  16. #include <asm/arch-rockchip/hardware.h>
  17. #include "rk_vop.h"
  18. DECLARE_GLOBAL_DATA_PTR;
  19. static void rk3288_set_pin_polarity(struct udevice *dev,
  20. enum vop_modes mode, u32 polarity)
  21. {
  22. struct rk_vop_priv *priv = dev_get_priv(dev);
  23. struct rk3288_vop *regs = priv->regs;
  24. /* The RK3328 VOP (v3.1) has its polarity configuration in ctrl0 */
  25. clrsetbits_le32(&regs->dsp_ctrl0,
  26. M_DSP_DCLK_POL | M_DSP_DEN_POL |
  27. M_DSP_VSYNC_POL | M_DSP_HSYNC_POL,
  28. V_DSP_PIN_POL(polarity));
  29. }
  30. static void rk3288_set_io_vsel(struct udevice *dev)
  31. {
  32. struct rk3288_grf *grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
  33. /* lcdc(vop) iodomain select 1.8V */
  34. rk_setreg(&grf->io_vsel, 1 << 0);
  35. }
  36. /*
  37. * Try some common regulators. We should really get these from the
  38. * device tree somehow.
  39. */
  40. static const char * const rk3288_regulator_names[] = {
  41. "vcc18_lcd",
  42. "VCC18_LCD",
  43. "vdd10_lcd_pwren_h",
  44. "vdd10_lcd",
  45. "VDD10_LCD",
  46. "vcc33_lcd"
  47. };
  48. static int rk3288_vop_probe(struct udevice *dev)
  49. {
  50. /* Before relocation we don't need to do anything */
  51. if (!(gd->flags & GD_FLG_RELOC))
  52. return 0;
  53. /* Set the LCDC(vop) iodomain to 1.8V */
  54. rk3288_set_io_vsel(dev);
  55. /* Probe regulators required for the RK3288 VOP */
  56. rk_vop_probe_regulators(dev, rk3288_regulator_names,
  57. ARRAY_SIZE(rk3288_regulator_names));
  58. return rk_vop_probe(dev);
  59. }
  60. static int rk_vop_remove(struct udevice *dev)
  61. {
  62. struct rk_vop_priv *priv = dev_get_priv(dev);
  63. struct rk3288_vop *regs = priv->regs;
  64. setbits_le32(&regs->sys_ctrl, V_STANDBY_EN(1));
  65. /* wait frame complete (60Hz) to enter standby */
  66. mdelay(17);
  67. return 0;
  68. }
  69. struct rkvop_driverdata rk3288_driverdata = {
  70. .features = VOP_FEATURE_OUTPUT_10BIT,
  71. .set_pin_polarity = rk3288_set_pin_polarity,
  72. };
  73. static const struct udevice_id rk3288_vop_ids[] = {
  74. { .compatible = "rockchip,rk3288-vop",
  75. .data = (ulong)&rk3288_driverdata },
  76. { }
  77. };
  78. static const struct video_ops rk3288_vop_ops = {
  79. };
  80. U_BOOT_DRIVER(rk_vop) = {
  81. .name = "rk3288_vop",
  82. .id = UCLASS_VIDEO,
  83. .of_match = rk3288_vop_ids,
  84. .ops = &rk3288_vop_ops,
  85. .bind = rk_vop_bind,
  86. .probe = rk3288_vop_probe,
  87. .remove = rk_vop_remove,
  88. .priv_auto_alloc_size = sizeof(struct rk_vop_priv),
  89. };