sti_hdmi.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) STMicroelectronics SA 2014
  4. * Author: Vincent Abriou <[email protected]> for STMicroelectronics.
  5. */
  6. #ifndef _STI_HDMI_H_
  7. #define _STI_HDMI_H_
  8. #include <linux/hdmi.h>
  9. #include <linux/platform_device.h>
  10. #include <media/cec-notifier.h>
  11. #include <drm/drm_modes.h>
  12. #include <drm/drm_property.h>
  13. #define HDMI_STA 0x0010
  14. #define HDMI_STA_DLL_LCK BIT(5)
  15. #define HDMI_STA_HOT_PLUG BIT(4)
  16. struct sti_hdmi;
  17. struct hdmi_phy_ops {
  18. bool (*start)(struct sti_hdmi *hdmi);
  19. void (*stop)(struct sti_hdmi *hdmi);
  20. };
  21. struct hdmi_audio_params {
  22. bool enabled;
  23. unsigned int sample_width;
  24. unsigned int sample_rate;
  25. struct hdmi_audio_infoframe cea;
  26. };
  27. #define DEFAULT_COLORSPACE_MODE HDMI_COLORSPACE_RGB
  28. /**
  29. * STI hdmi structure
  30. *
  31. * @dev: driver device
  32. * @drm_dev: pointer to drm device
  33. * @mode: current display mode selected
  34. * @regs: hdmi register
  35. * @syscfg: syscfg register for pll rejection configuration
  36. * @clk_pix: hdmi pixel clock
  37. * @clk_tmds: hdmi tmds clock
  38. * @clk_phy: hdmi phy clock
  39. * @clk_audio: hdmi audio clock
  40. * @irq: hdmi interrupt number
  41. * @irq_status: interrupt status register
  42. * @phy_ops: phy start/stop operations
  43. * @enabled: true if hdmi is enabled else false
  44. * @hpd: hot plug detect status
  45. * @wait_event: wait event
  46. * @event_received: wait event status
  47. * @reset: reset control of the hdmi phy
  48. * @ddc_adapt: i2c ddc adapter
  49. * @colorspace: current colorspace selected
  50. * @hdmi_monitor: true if HDMI monitor detected else DVI monitor assumed
  51. * @audio_pdev: ASoC hdmi-codec platform device
  52. * @audio: hdmi audio parameters.
  53. * @drm_connector: hdmi connector
  54. * @notifier: hotplug detect notifier
  55. */
  56. struct sti_hdmi {
  57. struct device dev;
  58. struct drm_device *drm_dev;
  59. struct drm_display_mode mode;
  60. void __iomem *regs;
  61. void __iomem *syscfg;
  62. struct clk *clk_pix;
  63. struct clk *clk_tmds;
  64. struct clk *clk_phy;
  65. struct clk *clk_audio;
  66. int irq;
  67. u32 irq_status;
  68. struct hdmi_phy_ops *phy_ops;
  69. bool enabled;
  70. bool hpd;
  71. wait_queue_head_t wait_event;
  72. bool event_received;
  73. struct reset_control *reset;
  74. struct i2c_adapter *ddc_adapt;
  75. enum hdmi_colorspace colorspace;
  76. bool hdmi_monitor;
  77. struct platform_device *audio_pdev;
  78. struct hdmi_audio_params audio;
  79. struct drm_connector *drm_connector;
  80. struct cec_notifier *notifier;
  81. };
  82. u32 hdmi_read(struct sti_hdmi *hdmi, int offset);
  83. void hdmi_write(struct sti_hdmi *hdmi, u32 val, int offset);
  84. /**
  85. * hdmi phy config structure
  86. *
  87. * A pointer to an array of these structures is passed to a TMDS (HDMI) output
  88. * via the control interface to provide board and SoC specific
  89. * configurations of the HDMI PHY. Each entry in the array specifies a hardware
  90. * specific configuration for a given TMDS clock frequency range.
  91. *
  92. * @min_tmds_freq: Lower bound of TMDS clock frequency this entry applies to
  93. * @max_tmds_freq: Upper bound of TMDS clock frequency this entry applies to
  94. * @config: SoC specific register configuration
  95. */
  96. struct hdmi_phy_config {
  97. u32 min_tmds_freq;
  98. u32 max_tmds_freq;
  99. u32 config[4];
  100. };
  101. #endif