sti_hdmi.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Copyright (C) STMicroelectronics SA 2014
  3. * Author: Vincent Abriou <vincent.abriou@st.com> for STMicroelectronics.
  4. * License terms: GNU General Public License (GPL), version 2
  5. */
  6. #ifndef _STI_HDMI_H_
  7. #define _STI_HDMI_H_
  8. #include <linux/hdmi.h>
  9. #include <linux/platform_device.h>
  10. #include <drm/drmP.h>
  11. #define HDMI_STA 0x0010
  12. #define HDMI_STA_DLL_LCK BIT(5)
  13. #define HDMI_STA_HOT_PLUG BIT(4)
  14. struct sti_hdmi;
  15. struct hdmi_phy_ops {
  16. bool (*start)(struct sti_hdmi *hdmi);
  17. void (*stop)(struct sti_hdmi *hdmi);
  18. };
  19. /* values for the framing mode property */
  20. enum sti_hdmi_modes {
  21. HDMI_MODE_HDMI,
  22. HDMI_MODE_DVI,
  23. };
  24. static const struct drm_prop_enum_list hdmi_mode_names[] = {
  25. { HDMI_MODE_HDMI, "hdmi" },
  26. { HDMI_MODE_DVI, "dvi" },
  27. };
  28. #define DEFAULT_HDMI_MODE HDMI_MODE_HDMI
  29. static const struct drm_prop_enum_list colorspace_mode_names[] = {
  30. { HDMI_COLORSPACE_RGB, "rgb" },
  31. { HDMI_COLORSPACE_YUV422, "yuv422" },
  32. { HDMI_COLORSPACE_YUV444, "yuv444" },
  33. };
  34. #define DEFAULT_COLORSPACE_MODE HDMI_COLORSPACE_RGB
  35. /**
  36. * STI hdmi structure
  37. *
  38. * @dev: driver device
  39. * @drm_dev: pointer to drm device
  40. * @mode: current display mode selected
  41. * @regs: hdmi register
  42. * @syscfg: syscfg register for pll rejection configuration
  43. * @clk_pix: hdmi pixel clock
  44. * @clk_tmds: hdmi tmds clock
  45. * @clk_phy: hdmi phy clock
  46. * @clk_audio: hdmi audio clock
  47. * @irq: hdmi interrupt number
  48. * @irq_status: interrupt status register
  49. * @phy_ops: phy start/stop operations
  50. * @enabled: true if hdmi is enabled else false
  51. * @hpd: hot plug detect status
  52. * @wait_event: wait event
  53. * @event_received: wait event status
  54. * @reset: reset control of the hdmi phy
  55. * @ddc_adapt: i2c ddc adapter
  56. * @colorspace: current colorspace selected
  57. * @hdmi_mode: select framing for HDMI or DVI
  58. */
  59. struct sti_hdmi {
  60. struct device dev;
  61. struct drm_device *drm_dev;
  62. struct drm_display_mode mode;
  63. void __iomem *regs;
  64. void __iomem *syscfg;
  65. struct clk *clk_pix;
  66. struct clk *clk_tmds;
  67. struct clk *clk_phy;
  68. struct clk *clk_audio;
  69. int irq;
  70. u32 irq_status;
  71. struct hdmi_phy_ops *phy_ops;
  72. bool enabled;
  73. bool hpd;
  74. wait_queue_head_t wait_event;
  75. bool event_received;
  76. struct reset_control *reset;
  77. struct i2c_adapter *ddc_adapt;
  78. enum hdmi_colorspace colorspace;
  79. enum sti_hdmi_modes hdmi_mode;
  80. };
  81. u32 hdmi_read(struct sti_hdmi *hdmi, int offset);
  82. void hdmi_write(struct sti_hdmi *hdmi, u32 val, int offset);
  83. /**
  84. * hdmi phy config structure
  85. *
  86. * A pointer to an array of these structures is passed to a TMDS (HDMI) output
  87. * via the control interface to provide board and SoC specific
  88. * configurations of the HDMI PHY. Each entry in the array specifies a hardware
  89. * specific configuration for a given TMDS clock frequency range.
  90. *
  91. * @min_tmds_freq: Lower bound of TMDS clock frequency this entry applies to
  92. * @max_tmds_freq: Upper bound of TMDS clock frequency this entry applies to
  93. * @config: SoC specific register configuration
  94. */
  95. struct hdmi_phy_config {
  96. u32 min_tmds_freq;
  97. u32 max_tmds_freq;
  98. u32 config[4];
  99. };
  100. #endif