ingenic-dw-hdmi.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // SPDX-License-Identifier: GPL-2.0
  2. /* Copyright (C) 2011-2013 Freescale Semiconductor, Inc.
  3. * Copyright (C) 2019, 2020 Paul Boddie <[email protected]>
  4. *
  5. * Derived from dw_hdmi-imx.c with i.MX portions removed.
  6. */
  7. #include <linux/module.h>
  8. #include <linux/of_platform.h>
  9. #include <linux/platform_device.h>
  10. #include <drm/bridge/dw_hdmi.h>
  11. #include <drm/drm_of.h>
  12. #include <drm/drm_print.h>
  13. static const struct dw_hdmi_mpll_config ingenic_mpll_cfg[] = {
  14. { 45250000, { { 0x01e0, 0x0000 }, { 0x21e1, 0x0000 }, { 0x41e2, 0x0000 } } },
  15. { 92500000, { { 0x0140, 0x0005 }, { 0x2141, 0x0005 }, { 0x4142, 0x0005 } } },
  16. { 148500000, { { 0x00a0, 0x000a }, { 0x20a1, 0x000a }, { 0x40a2, 0x000a } } },
  17. { 216000000, { { 0x00a0, 0x000a }, { 0x2001, 0x000f }, { 0x4002, 0x000f } } },
  18. { ~0UL, { { 0x0000, 0x0000 }, { 0x0000, 0x0000 }, { 0x0000, 0x0000 } } }
  19. };
  20. static const struct dw_hdmi_curr_ctrl ingenic_cur_ctr[] = {
  21. /*pixelclk bpp8 bpp10 bpp12 */
  22. { 54000000, { 0x091c, 0x091c, 0x06dc } },
  23. { 58400000, { 0x091c, 0x06dc, 0x06dc } },
  24. { 72000000, { 0x06dc, 0x06dc, 0x091c } },
  25. { 74250000, { 0x06dc, 0x0b5c, 0x091c } },
  26. { 118800000, { 0x091c, 0x091c, 0x06dc } },
  27. { 216000000, { 0x06dc, 0x0b5c, 0x091c } },
  28. { ~0UL, { 0x0000, 0x0000, 0x0000 } },
  29. };
  30. /*
  31. * Resistance term 133Ohm Cfg
  32. * PREEMP config 0.00
  33. * TX/CK level 10
  34. */
  35. static const struct dw_hdmi_phy_config ingenic_phy_config[] = {
  36. /*pixelclk symbol term vlev */
  37. { 216000000, 0x800d, 0x0005, 0x01ad},
  38. { ~0UL, 0x0000, 0x0000, 0x0000}
  39. };
  40. static enum drm_mode_status
  41. ingenic_dw_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
  42. const struct drm_display_info *info,
  43. const struct drm_display_mode *mode)
  44. {
  45. if (mode->clock < 13500)
  46. return MODE_CLOCK_LOW;
  47. /* FIXME: Hardware is capable of 270MHz, but setup data is missing. */
  48. if (mode->clock > 216000)
  49. return MODE_CLOCK_HIGH;
  50. return MODE_OK;
  51. }
  52. static struct dw_hdmi_plat_data ingenic_dw_hdmi_plat_data = {
  53. .mpll_cfg = ingenic_mpll_cfg,
  54. .cur_ctr = ingenic_cur_ctr,
  55. .phy_config = ingenic_phy_config,
  56. .mode_valid = ingenic_dw_hdmi_mode_valid,
  57. .output_port = 1,
  58. };
  59. static const struct of_device_id ingenic_dw_hdmi_dt_ids[] = {
  60. { .compatible = "ingenic,jz4780-dw-hdmi" },
  61. { /* Sentinel */ },
  62. };
  63. MODULE_DEVICE_TABLE(of, ingenic_dw_hdmi_dt_ids);
  64. static void ingenic_dw_hdmi_cleanup(void *data)
  65. {
  66. struct dw_hdmi *hdmi = (struct dw_hdmi *)data;
  67. dw_hdmi_remove(hdmi);
  68. }
  69. static int ingenic_dw_hdmi_probe(struct platform_device *pdev)
  70. {
  71. struct dw_hdmi *hdmi;
  72. hdmi = dw_hdmi_probe(pdev, &ingenic_dw_hdmi_plat_data);
  73. if (IS_ERR(hdmi))
  74. return PTR_ERR(hdmi);
  75. return devm_add_action_or_reset(&pdev->dev, ingenic_dw_hdmi_cleanup, hdmi);
  76. }
  77. static struct platform_driver ingenic_dw_hdmi_driver = {
  78. .probe = ingenic_dw_hdmi_probe,
  79. .driver = {
  80. .name = "dw-hdmi-ingenic",
  81. .of_match_table = ingenic_dw_hdmi_dt_ids,
  82. },
  83. };
  84. module_platform_driver(ingenic_dw_hdmi_driver);
  85. MODULE_DESCRIPTION("JZ4780 Specific DW-HDMI Driver Extension");
  86. MODULE_LICENSE("GPL v2");
  87. MODULE_ALIAS("platform:dw-hdmi-ingenic");