blob: 5ab811cda00e01267a106b8dad1637a7bb09bb70 [file] [log] [blame]
Maxime Ripard9c568102017-05-27 18:09:35 +02001/*
2 * Copyright (C) 2016 Maxime Ripard
3 *
4 * Maxime Ripard <maxime.ripard@free-electrons.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
10 */
11
12#include <drm/drmP.h>
13#include <drm/drm_atomic_helper.h>
14#include <drm/drm_crtc_helper.h>
15#include <drm/drm_edid.h>
16#include <drm/drm_encoder.h>
17#include <drm/drm_of.h>
18#include <drm/drm_panel.h>
19
20#include <linux/clk.h>
21#include <linux/component.h>
22#include <linux/iopoll.h>
23#include <linux/platform_device.h>
24#include <linux/pm_runtime.h>
Chen-Yu Tsai4b1c9242017-10-10 11:20:01 +080025#include <linux/regmap.h>
Maxime Ripard9c568102017-05-27 18:09:35 +020026
27#include "sun4i_backend.h"
28#include "sun4i_crtc.h"
29#include "sun4i_drv.h"
30#include "sun4i_hdmi.h"
31#include "sun4i_tcon.h"
32
Maxime Ripard9c568102017-05-27 18:09:35 +020033static inline struct sun4i_hdmi *
34drm_encoder_to_sun4i_hdmi(struct drm_encoder *encoder)
35{
36 return container_of(encoder, struct sun4i_hdmi,
37 encoder);
38}
39
40static inline struct sun4i_hdmi *
41drm_connector_to_sun4i_hdmi(struct drm_connector *connector)
42{
43 return container_of(connector, struct sun4i_hdmi,
44 connector);
45}
46
47static int sun4i_hdmi_setup_avi_infoframes(struct sun4i_hdmi *hdmi,
48 struct drm_display_mode *mode)
49{
50 struct hdmi_avi_infoframe frame;
51 u8 buffer[17];
52 int i, ret;
53
Shashank Sharma0c1f5282017-07-13 21:03:07 +053054 ret = drm_hdmi_avi_infoframe_from_display_mode(&frame, mode, false);
Maxime Ripard9c568102017-05-27 18:09:35 +020055 if (ret < 0) {
56 DRM_ERROR("Failed to get infoframes from mode\n");
57 return ret;
58 }
59
60 ret = hdmi_avi_infoframe_pack(&frame, buffer, sizeof(buffer));
61 if (ret < 0) {
62 DRM_ERROR("Failed to pack infoframes\n");
63 return ret;
64 }
65
66 for (i = 0; i < sizeof(buffer); i++)
67 writeb(buffer[i], hdmi->base + SUN4I_HDMI_AVI_INFOFRAME_REG(i));
68
69 return 0;
70}
71
72static int sun4i_hdmi_atomic_check(struct drm_encoder *encoder,
73 struct drm_crtc_state *crtc_state,
74 struct drm_connector_state *conn_state)
75{
76 struct drm_display_mode *mode = &crtc_state->mode;
77
78 if (mode->flags & DRM_MODE_FLAG_DBLCLK)
79 return -EINVAL;
80
81 return 0;
82}
83
84static void sun4i_hdmi_disable(struct drm_encoder *encoder)
85{
86 struct sun4i_hdmi *hdmi = drm_encoder_to_sun4i_hdmi(encoder);
87 struct sun4i_crtc *crtc = drm_crtc_to_sun4i_crtc(encoder->crtc);
88 struct sun4i_tcon *tcon = crtc->tcon;
89 u32 val;
90
91 DRM_DEBUG_DRIVER("Disabling the HDMI Output\n");
92
93 val = readl(hdmi->base + SUN4I_HDMI_VID_CTRL_REG);
94 val &= ~SUN4I_HDMI_VID_CTRL_ENABLE;
95 writel(val, hdmi->base + SUN4I_HDMI_VID_CTRL_REG);
96
97 sun4i_tcon_channel_disable(tcon, 1);
98}
99
100static void sun4i_hdmi_enable(struct drm_encoder *encoder)
101{
102 struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
103 struct sun4i_hdmi *hdmi = drm_encoder_to_sun4i_hdmi(encoder);
104 struct sun4i_crtc *crtc = drm_crtc_to_sun4i_crtc(encoder->crtc);
105 struct sun4i_tcon *tcon = crtc->tcon;
106 u32 val = 0;
107
108 DRM_DEBUG_DRIVER("Enabling the HDMI Output\n");
109
110 sun4i_tcon_channel_enable(tcon, 1);
111
112 sun4i_hdmi_setup_avi_infoframes(hdmi, mode);
113 val |= SUN4I_HDMI_PKT_CTRL_TYPE(0, SUN4I_HDMI_PKT_AVI);
114 val |= SUN4I_HDMI_PKT_CTRL_TYPE(1, SUN4I_HDMI_PKT_END);
115 writel(val, hdmi->base + SUN4I_HDMI_PKT_CTRL_REG(0));
116
117 val = SUN4I_HDMI_VID_CTRL_ENABLE;
118 if (hdmi->hdmi_monitor)
119 val |= SUN4I_HDMI_VID_CTRL_HDMI_MODE;
120
121 writel(val, hdmi->base + SUN4I_HDMI_VID_CTRL_REG);
122}
123
124static void sun4i_hdmi_mode_set(struct drm_encoder *encoder,
125 struct drm_display_mode *mode,
126 struct drm_display_mode *adjusted_mode)
127{
128 struct sun4i_hdmi *hdmi = drm_encoder_to_sun4i_hdmi(encoder);
129 struct sun4i_crtc *crtc = drm_crtc_to_sun4i_crtc(encoder->crtc);
130 struct sun4i_tcon *tcon = crtc->tcon;
131 unsigned int x, y;
132 u32 val;
133
134 sun4i_tcon1_mode_set(tcon, mode);
135 sun4i_tcon_set_mux(tcon, 1, encoder);
136
137 clk_set_rate(tcon->sclk1, mode->crtc_clock * 1000);
138 clk_set_rate(hdmi->mod_clk, mode->crtc_clock * 1000);
139 clk_set_rate(hdmi->tmds_clk, mode->crtc_clock * 1000);
140
141 /* Set input sync enable */
142 writel(SUN4I_HDMI_UNKNOWN_INPUT_SYNC,
143 hdmi->base + SUN4I_HDMI_UNKNOWN_REG);
144
145 /* Setup timing registers */
146 writel(SUN4I_HDMI_VID_TIMING_X(mode->hdisplay) |
147 SUN4I_HDMI_VID_TIMING_Y(mode->vdisplay),
148 hdmi->base + SUN4I_HDMI_VID_TIMING_ACT_REG);
149
150 x = mode->htotal - mode->hsync_start;
151 y = mode->vtotal - mode->vsync_start;
152 writel(SUN4I_HDMI_VID_TIMING_X(x) | SUN4I_HDMI_VID_TIMING_Y(y),
153 hdmi->base + SUN4I_HDMI_VID_TIMING_BP_REG);
154
155 x = mode->hsync_start - mode->hdisplay;
156 y = mode->vsync_start - mode->vdisplay;
157 writel(SUN4I_HDMI_VID_TIMING_X(x) | SUN4I_HDMI_VID_TIMING_Y(y),
158 hdmi->base + SUN4I_HDMI_VID_TIMING_FP_REG);
159
160 x = mode->hsync_end - mode->hsync_start;
161 y = mode->vsync_end - mode->vsync_start;
162 writel(SUN4I_HDMI_VID_TIMING_X(x) | SUN4I_HDMI_VID_TIMING_Y(y),
163 hdmi->base + SUN4I_HDMI_VID_TIMING_SPW_REG);
164
165 val = SUN4I_HDMI_VID_TIMING_POL_TX_CLK;
166 if (mode->flags & DRM_MODE_FLAG_PHSYNC)
167 val |= SUN4I_HDMI_VID_TIMING_POL_HSYNC;
168
169 if (mode->flags & DRM_MODE_FLAG_PVSYNC)
170 val |= SUN4I_HDMI_VID_TIMING_POL_VSYNC;
171
172 writel(val, hdmi->base + SUN4I_HDMI_VID_TIMING_POL_REG);
173}
174
175static const struct drm_encoder_helper_funcs sun4i_hdmi_helper_funcs = {
176 .atomic_check = sun4i_hdmi_atomic_check,
177 .disable = sun4i_hdmi_disable,
178 .enable = sun4i_hdmi_enable,
179 .mode_set = sun4i_hdmi_mode_set,
180};
181
182static const struct drm_encoder_funcs sun4i_hdmi_funcs = {
183 .destroy = drm_encoder_cleanup,
184};
185
Maxime Ripard9c568102017-05-27 18:09:35 +0200186static int sun4i_hdmi_get_modes(struct drm_connector *connector)
187{
188 struct sun4i_hdmi *hdmi = drm_connector_to_sun4i_hdmi(connector);
Maxime Ripard9c568102017-05-27 18:09:35 +0200189 struct edid *edid;
190 int ret;
191
Jonathan Liuf0a3dd32017-07-02 17:27:10 +1000192 edid = drm_get_edid(connector, hdmi->i2c);
Maxime Ripard9c568102017-05-27 18:09:35 +0200193 if (!edid)
194 return 0;
195
196 hdmi->hdmi_monitor = drm_detect_hdmi_monitor(edid);
197 DRM_DEBUG_DRIVER("Monitor is %s monitor\n",
198 hdmi->hdmi_monitor ? "an HDMI" : "a DVI");
199
200 drm_mode_connector_update_edid_property(connector, edid);
Hans Verkuil998140d2017-07-11 08:30:44 +0200201 cec_s_phys_addr_from_edid(hdmi->cec_adap, edid);
Maxime Ripard9c568102017-05-27 18:09:35 +0200202 ret = drm_add_edid_modes(connector, edid);
203 kfree(edid);
204
Maxime Ripard9c568102017-05-27 18:09:35 +0200205 return ret;
206}
207
208static const struct drm_connector_helper_funcs sun4i_hdmi_connector_helper_funcs = {
209 .get_modes = sun4i_hdmi_get_modes,
210};
211
212static enum drm_connector_status
213sun4i_hdmi_connector_detect(struct drm_connector *connector, bool force)
214{
215 struct sun4i_hdmi *hdmi = drm_connector_to_sun4i_hdmi(connector);
216 unsigned long reg;
217
218 if (readl_poll_timeout(hdmi->base + SUN4I_HDMI_HPD_REG, reg,
219 reg & SUN4I_HDMI_HPD_HIGH,
Hans Verkuil998140d2017-07-11 08:30:44 +0200220 0, 500000)) {
221 cec_phys_addr_invalidate(hdmi->cec_adap);
Maxime Ripard9c568102017-05-27 18:09:35 +0200222 return connector_status_disconnected;
Hans Verkuil998140d2017-07-11 08:30:44 +0200223 }
Maxime Ripard9c568102017-05-27 18:09:35 +0200224
225 return connector_status_connected;
226}
227
228static const struct drm_connector_funcs sun4i_hdmi_connector_funcs = {
Maxime Ripard9c568102017-05-27 18:09:35 +0200229 .detect = sun4i_hdmi_connector_detect,
230 .fill_modes = drm_helper_probe_single_connector_modes,
231 .destroy = drm_connector_cleanup,
232 .reset = drm_atomic_helper_connector_reset,
233 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
234 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
235};
236
Hans Verkuil998140d2017-07-11 08:30:44 +0200237#ifdef CONFIG_DRM_SUN4I_HDMI_CEC
238static bool sun4i_hdmi_cec_pin_read(struct cec_adapter *adap)
239{
240 struct sun4i_hdmi *hdmi = cec_get_drvdata(adap);
241
242 return readl(hdmi->base + SUN4I_HDMI_CEC) & SUN4I_HDMI_CEC_RX;
243}
244
245static void sun4i_hdmi_cec_pin_low(struct cec_adapter *adap)
246{
247 struct sun4i_hdmi *hdmi = cec_get_drvdata(adap);
248
249 /* Start driving the CEC pin low */
250 writel(SUN4I_HDMI_CEC_ENABLE, hdmi->base + SUN4I_HDMI_CEC);
251}
252
253static void sun4i_hdmi_cec_pin_high(struct cec_adapter *adap)
254{
255 struct sun4i_hdmi *hdmi = cec_get_drvdata(adap);
256
257 /*
258 * Stop driving the CEC pin, the pull up will take over
259 * unless another CEC device is driving the pin low.
260 */
261 writel(0, hdmi->base + SUN4I_HDMI_CEC);
262}
263
264static const struct cec_pin_ops sun4i_hdmi_cec_pin_ops = {
265 .read = sun4i_hdmi_cec_pin_read,
266 .low = sun4i_hdmi_cec_pin_low,
267 .high = sun4i_hdmi_cec_pin_high,
268};
269#endif
270
Chen-Yu Tsai4b1c9242017-10-10 11:20:01 +0800271static const struct regmap_config sun4i_hdmi_regmap_config = {
272 .reg_bits = 32,
273 .val_bits = 32,
274 .reg_stride = 4,
275 .max_register = 0x580,
276};
277
Maxime Ripard9c568102017-05-27 18:09:35 +0200278static int sun4i_hdmi_bind(struct device *dev, struct device *master,
279 void *data)
280{
281 struct platform_device *pdev = to_platform_device(dev);
282 struct drm_device *drm = data;
283 struct sun4i_drv *drv = drm->dev_private;
284 struct sun4i_hdmi *hdmi;
285 struct resource *res;
286 u32 reg;
287 int ret;
288
289 hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
290 if (!hdmi)
291 return -ENOMEM;
292 dev_set_drvdata(dev, hdmi);
293 hdmi->dev = dev;
294 hdmi->drv = drv;
295
296 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
297 hdmi->base = devm_ioremap_resource(dev, res);
298 if (IS_ERR(hdmi->base)) {
299 dev_err(dev, "Couldn't map the HDMI encoder registers\n");
300 return PTR_ERR(hdmi->base);
301 }
302
303 hdmi->bus_clk = devm_clk_get(dev, "ahb");
304 if (IS_ERR(hdmi->bus_clk)) {
305 dev_err(dev, "Couldn't get the HDMI bus clock\n");
306 return PTR_ERR(hdmi->bus_clk);
307 }
308 clk_prepare_enable(hdmi->bus_clk);
309
310 hdmi->mod_clk = devm_clk_get(dev, "mod");
311 if (IS_ERR(hdmi->mod_clk)) {
312 dev_err(dev, "Couldn't get the HDMI mod clock\n");
Chen-Yu Tsai544c5042017-10-10 11:20:00 +0800313 ret = PTR_ERR(hdmi->mod_clk);
314 goto err_disable_bus_clk;
Maxime Ripard9c568102017-05-27 18:09:35 +0200315 }
316 clk_prepare_enable(hdmi->mod_clk);
317
318 hdmi->pll0_clk = devm_clk_get(dev, "pll-0");
319 if (IS_ERR(hdmi->pll0_clk)) {
320 dev_err(dev, "Couldn't get the HDMI PLL 0 clock\n");
Chen-Yu Tsai544c5042017-10-10 11:20:00 +0800321 ret = PTR_ERR(hdmi->pll0_clk);
322 goto err_disable_mod_clk;
Maxime Ripard9c568102017-05-27 18:09:35 +0200323 }
324
325 hdmi->pll1_clk = devm_clk_get(dev, "pll-1");
326 if (IS_ERR(hdmi->pll1_clk)) {
327 dev_err(dev, "Couldn't get the HDMI PLL 1 clock\n");
Chen-Yu Tsai544c5042017-10-10 11:20:00 +0800328 ret = PTR_ERR(hdmi->pll1_clk);
329 goto err_disable_mod_clk;
Maxime Ripard9c568102017-05-27 18:09:35 +0200330 }
331
Chen-Yu Tsai4b1c9242017-10-10 11:20:01 +0800332 hdmi->regmap = devm_regmap_init_mmio(dev, hdmi->base,
333 &sun4i_hdmi_regmap_config);
334 if (IS_ERR(hdmi->regmap)) {
335 dev_err(dev, "Couldn't create HDMI encoder regmap\n");
336 return PTR_ERR(hdmi->regmap);
337 }
338
Maxime Ripard9c568102017-05-27 18:09:35 +0200339 ret = sun4i_tmds_create(hdmi);
340 if (ret) {
341 dev_err(dev, "Couldn't create the TMDS clock\n");
Chen-Yu Tsai544c5042017-10-10 11:20:00 +0800342 goto err_disable_mod_clk;
Maxime Ripard9c568102017-05-27 18:09:35 +0200343 }
344
345 writel(SUN4I_HDMI_CTRL_ENABLE, hdmi->base + SUN4I_HDMI_CTRL_REG);
346
347 writel(SUN4I_HDMI_PAD_CTRL0_TXEN | SUN4I_HDMI_PAD_CTRL0_CKEN |
348 SUN4I_HDMI_PAD_CTRL0_PWENG | SUN4I_HDMI_PAD_CTRL0_PWEND |
349 SUN4I_HDMI_PAD_CTRL0_PWENC | SUN4I_HDMI_PAD_CTRL0_LDODEN |
350 SUN4I_HDMI_PAD_CTRL0_LDOCEN | SUN4I_HDMI_PAD_CTRL0_BIASEN,
351 hdmi->base + SUN4I_HDMI_PAD_CTRL0_REG);
352
353 /*
354 * We can't just initialize the register there, we need to
355 * protect the clock bits that have already been read out and
356 * cached by the clock framework.
357 */
358 reg = readl(hdmi->base + SUN4I_HDMI_PAD_CTRL1_REG);
359 reg &= SUN4I_HDMI_PAD_CTRL1_HALVE_CLK;
360 reg |= SUN4I_HDMI_PAD_CTRL1_REG_AMP(6) |
361 SUN4I_HDMI_PAD_CTRL1_REG_EMP(2) |
362 SUN4I_HDMI_PAD_CTRL1_REG_DENCK |
363 SUN4I_HDMI_PAD_CTRL1_REG_DEN |
364 SUN4I_HDMI_PAD_CTRL1_EMPCK_OPT |
365 SUN4I_HDMI_PAD_CTRL1_EMP_OPT |
366 SUN4I_HDMI_PAD_CTRL1_AMPCK_OPT |
367 SUN4I_HDMI_PAD_CTRL1_AMP_OPT;
368 writel(reg, hdmi->base + SUN4I_HDMI_PAD_CTRL1_REG);
369
370 reg = readl(hdmi->base + SUN4I_HDMI_PLL_CTRL_REG);
371 reg &= SUN4I_HDMI_PLL_CTRL_DIV_MASK;
372 reg |= SUN4I_HDMI_PLL_CTRL_VCO_S(8) | SUN4I_HDMI_PLL_CTRL_CS(7) |
373 SUN4I_HDMI_PLL_CTRL_CP_S(15) | SUN4I_HDMI_PLL_CTRL_S(7) |
374 SUN4I_HDMI_PLL_CTRL_VCO_GAIN(4) | SUN4I_HDMI_PLL_CTRL_SDIV2 |
375 SUN4I_HDMI_PLL_CTRL_LDO2_EN | SUN4I_HDMI_PLL_CTRL_LDO1_EN |
376 SUN4I_HDMI_PLL_CTRL_HV_IS_33 | SUN4I_HDMI_PLL_CTRL_BWS |
377 SUN4I_HDMI_PLL_CTRL_PLL_EN;
378 writel(reg, hdmi->base + SUN4I_HDMI_PLL_CTRL_REG);
379
Jonathan Liuf0a3dd32017-07-02 17:27:10 +1000380 ret = sun4i_hdmi_i2c_create(dev, hdmi);
Maxime Ripard9c568102017-05-27 18:09:35 +0200381 if (ret) {
Jonathan Liuf0a3dd32017-07-02 17:27:10 +1000382 dev_err(dev, "Couldn't create the HDMI I2C adapter\n");
Chen-Yu Tsai544c5042017-10-10 11:20:00 +0800383 goto err_disable_mod_clk;
Maxime Ripard9c568102017-05-27 18:09:35 +0200384 }
385
386 drm_encoder_helper_add(&hdmi->encoder,
387 &sun4i_hdmi_helper_funcs);
388 ret = drm_encoder_init(drm,
389 &hdmi->encoder,
390 &sun4i_hdmi_funcs,
391 DRM_MODE_ENCODER_TMDS,
392 NULL);
393 if (ret) {
394 dev_err(dev, "Couldn't initialise the HDMI encoder\n");
Jonathan Liuf0a3dd32017-07-02 17:27:10 +1000395 goto err_del_i2c_adapter;
Maxime Ripard9c568102017-05-27 18:09:35 +0200396 }
397
398 hdmi->encoder.possible_crtcs = drm_of_find_possible_crtcs(drm,
399 dev->of_node);
Jonathan Liuf0a3dd32017-07-02 17:27:10 +1000400 if (!hdmi->encoder.possible_crtcs) {
401 ret = -EPROBE_DEFER;
402 goto err_del_i2c_adapter;
403 }
Maxime Ripard9c568102017-05-27 18:09:35 +0200404
Hans Verkuil998140d2017-07-11 08:30:44 +0200405#ifdef CONFIG_DRM_SUN4I_HDMI_CEC
406 hdmi->cec_adap = cec_pin_allocate_adapter(&sun4i_hdmi_cec_pin_ops,
407 hdmi, "sun4i", CEC_CAP_TRANSMIT | CEC_CAP_LOG_ADDRS |
408 CEC_CAP_PASSTHROUGH | CEC_CAP_RC);
409 ret = PTR_ERR_OR_ZERO(hdmi->cec_adap);
410 if (ret < 0)
411 goto err_cleanup_connector;
412 writel(readl(hdmi->base + SUN4I_HDMI_CEC) & ~SUN4I_HDMI_CEC_TX,
413 hdmi->base + SUN4I_HDMI_CEC);
414#endif
Maxime Ripard9c568102017-05-27 18:09:35 +0200415
416 drm_connector_helper_add(&hdmi->connector,
417 &sun4i_hdmi_connector_helper_funcs);
418 ret = drm_connector_init(drm, &hdmi->connector,
419 &sun4i_hdmi_connector_funcs,
420 DRM_MODE_CONNECTOR_HDMIA);
421 if (ret) {
422 dev_err(dev,
423 "Couldn't initialise the HDMI connector\n");
424 goto err_cleanup_connector;
425 }
426
427 /* There is no HPD interrupt, so we need to poll the controller */
428 hdmi->connector.polled = DRM_CONNECTOR_POLL_CONNECT |
429 DRM_CONNECTOR_POLL_DISCONNECT;
430
Hans Verkuil998140d2017-07-11 08:30:44 +0200431 ret = cec_register_adapter(hdmi->cec_adap, dev);
432 if (ret < 0)
433 goto err_cleanup_connector;
Maxime Ripard9c568102017-05-27 18:09:35 +0200434 drm_mode_connector_attach_encoder(&hdmi->connector, &hdmi->encoder);
435
436 return 0;
437
438err_cleanup_connector:
Hans Verkuil998140d2017-07-11 08:30:44 +0200439 cec_delete_adapter(hdmi->cec_adap);
Maxime Ripard9c568102017-05-27 18:09:35 +0200440 drm_encoder_cleanup(&hdmi->encoder);
Jonathan Liuf0a3dd32017-07-02 17:27:10 +1000441err_del_i2c_adapter:
442 i2c_del_adapter(hdmi->i2c);
Chen-Yu Tsai544c5042017-10-10 11:20:00 +0800443err_disable_mod_clk:
444 clk_disable_unprepare(hdmi->mod_clk);
445err_disable_bus_clk:
446 clk_disable_unprepare(hdmi->bus_clk);
Maxime Ripard9c568102017-05-27 18:09:35 +0200447 return ret;
448}
449
450static void sun4i_hdmi_unbind(struct device *dev, struct device *master,
451 void *data)
452{
453 struct sun4i_hdmi *hdmi = dev_get_drvdata(dev);
454
Hans Verkuil998140d2017-07-11 08:30:44 +0200455 cec_unregister_adapter(hdmi->cec_adap);
Maxime Ripard9c568102017-05-27 18:09:35 +0200456 drm_connector_cleanup(&hdmi->connector);
457 drm_encoder_cleanup(&hdmi->encoder);
Jonathan Liuf0a3dd32017-07-02 17:27:10 +1000458 i2c_del_adapter(hdmi->i2c);
Chen-Yu Tsai544c5042017-10-10 11:20:00 +0800459 clk_disable_unprepare(hdmi->mod_clk);
460 clk_disable_unprepare(hdmi->bus_clk);
Maxime Ripard9c568102017-05-27 18:09:35 +0200461}
462
463static const struct component_ops sun4i_hdmi_ops = {
464 .bind = sun4i_hdmi_bind,
465 .unbind = sun4i_hdmi_unbind,
466};
467
468static int sun4i_hdmi_probe(struct platform_device *pdev)
469{
470 return component_add(&pdev->dev, &sun4i_hdmi_ops);
471}
472
473static int sun4i_hdmi_remove(struct platform_device *pdev)
474{
475 component_del(&pdev->dev, &sun4i_hdmi_ops);
476
477 return 0;
478}
479
480static const struct of_device_id sun4i_hdmi_of_table[] = {
481 { .compatible = "allwinner,sun5i-a10s-hdmi" },
482 { }
483};
484MODULE_DEVICE_TABLE(of, sun4i_hdmi_of_table);
485
486static struct platform_driver sun4i_hdmi_driver = {
487 .probe = sun4i_hdmi_probe,
488 .remove = sun4i_hdmi_remove,
489 .driver = {
490 .name = "sun4i-hdmi",
491 .of_match_table = sun4i_hdmi_of_table,
492 },
493};
494module_platform_driver(sun4i_hdmi_driver);
495
496MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");
497MODULE_DESCRIPTION("Allwinner A10 HDMI Driver");
498MODULE_LICENSE("GPL");