blob: 77edb73a56e4a6aa2e06b464ca8d802c62c3ea87 [file] [log] [blame]
Benjamin Gaignard54026262014-07-30 19:24:55 +02001/*
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
7#ifndef _STI_HDMI_H_
8#define _STI_HDMI_H_
9
Vincent Abriou5671cefb2016-02-10 11:24:28 +010010#include <linux/hdmi.h>
Benjamin Gaignard54026262014-07-30 19:24:55 +020011#include <linux/platform_device.h>
12
13#include <drm/drmP.h>
14
15#define HDMI_STA 0x0010
16#define HDMI_STA_DLL_LCK BIT(5)
17
Benjamin Gaignard76569202014-10-09 08:53:35 +020018#define HDMI_STA_HOT_PLUG_SHIFT 4
19#define HDMI_STA_HOT_PLUG (1 << HDMI_STA_HOT_PLUG_SHIFT)
20
Benjamin Gaignard54026262014-07-30 19:24:55 +020021struct sti_hdmi;
22
23struct hdmi_phy_ops {
24 bool (*start)(struct sti_hdmi *hdmi);
25 void (*stop)(struct sti_hdmi *hdmi);
26};
27
Vincent Abriouffc4a6a2016-02-10 11:21:37 +010028/* values for the framing mode property */
29enum sti_hdmi_modes {
30 HDMI_MODE_HDMI,
31 HDMI_MODE_DVI,
32};
33
34static const struct drm_prop_enum_list hdmi_mode_names[] = {
35 { HDMI_MODE_HDMI, "hdmi" },
36 { HDMI_MODE_DVI, "dvi" },
37};
38
39#define DEFAULT_HDMI_MODE HDMI_MODE_HDMI
40
Vincent Abriou5671cefb2016-02-10 11:24:28 +010041static const struct drm_prop_enum_list colorspace_mode_names[] = {
42 { HDMI_COLORSPACE_RGB, "rgb" },
43 { HDMI_COLORSPACE_YUV422, "yuv422" },
44 { HDMI_COLORSPACE_YUV444, "yuv444" },
45};
46
47#define DEFAULT_COLORSPACE_MODE HDMI_COLORSPACE_RGB
48
Benjamin Gaignard54026262014-07-30 19:24:55 +020049/**
50 * STI hdmi structure
51 *
52 * @dev: driver device
53 * @drm_dev: pointer to drm device
54 * @mode: current display mode selected
55 * @regs: hdmi register
56 * @syscfg: syscfg register for pll rejection configuration
57 * @clk_pix: hdmi pixel clock
58 * @clk_tmds: hdmi tmds clock
59 * @clk_phy: hdmi phy clock
60 * @clk_audio: hdmi audio clock
61 * @irq: hdmi interrupt number
62 * @irq_status: interrupt status register
63 * @phy_ops: phy start/stop operations
64 * @enabled: true if hdmi is enabled else false
Benjamin Gaignard54026262014-07-30 19:24:55 +020065 * @hpd: hot plug detect status
66 * @wait_event: wait event
67 * @event_received: wait event status
68 * @reset: reset control of the hdmi phy
Vincent Abriou5671cefb2016-02-10 11:24:28 +010069 * @ddc_adapt: i2c ddc adapter
70 * @colorspace: current colorspace selected
Vincent Abriouffc4a6a2016-02-10 11:21:37 +010071 * @hdmi_mode: select framing for HDMI or DVI
Benjamin Gaignard54026262014-07-30 19:24:55 +020072 */
73struct sti_hdmi {
74 struct device dev;
75 struct drm_device *drm_dev;
76 struct drm_display_mode mode;
77 void __iomem *regs;
78 void __iomem *syscfg;
79 struct clk *clk_pix;
80 struct clk *clk_tmds;
81 struct clk *clk_phy;
82 struct clk *clk_audio;
83 int irq;
84 u32 irq_status;
85 struct hdmi_phy_ops *phy_ops;
86 bool enabled;
Benjamin Gaignard54026262014-07-30 19:24:55 +020087 bool hpd;
88 wait_queue_head_t wait_event;
89 bool event_received;
90 struct reset_control *reset;
Benjamin Gaignard41a14622014-09-08 15:52:08 +020091 struct i2c_adapter *ddc_adapt;
Vincent Abriou5671cefb2016-02-10 11:24:28 +010092 enum hdmi_colorspace colorspace;
Vincent Abriouffc4a6a2016-02-10 11:21:37 +010093 enum sti_hdmi_modes hdmi_mode;
Benjamin Gaignard54026262014-07-30 19:24:55 +020094};
95
96u32 hdmi_read(struct sti_hdmi *hdmi, int offset);
97void hdmi_write(struct sti_hdmi *hdmi, u32 val, int offset);
98
99/**
100 * hdmi phy config structure
101 *
102 * A pointer to an array of these structures is passed to a TMDS (HDMI) output
103 * via the control interface to provide board and SoC specific
104 * configurations of the HDMI PHY. Each entry in the array specifies a hardware
105 * specific configuration for a given TMDS clock frequency range.
106 *
107 * @min_tmds_freq: Lower bound of TMDS clock frequency this entry applies to
108 * @max_tmds_freq: Upper bound of TMDS clock frequency this entry applies to
109 * @config: SoC specific register configuration
110 */
111struct hdmi_phy_config {
112 u32 min_tmds_freq;
113 u32 max_tmds_freq;
114 u32 config[4];
115};
116
117#endif