rk3288_vop.c 2.6 KB

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