ath79/mikrotik: use routerbootpart partitions
[oweals/openwrt.git] / target / linux / layerscape / patches-5.4 / 805-display-0010-drm-bridge-cadence-move-struct-imx_mhdp_device-to-dr.patch
1 From fe1824851dd6f7d3ee6d5411edba4102dacea873 Mon Sep 17 00:00:00 2001
2 From: Sandor Yu <Sandor.yu@nxp.com>
3 Date: Wed, 11 Sep 2019 17:16:47 +0800
4 Subject: [PATCH] drm: bridge: cadence: move struct imx_mhdp_device to drm/imx
5
6 move struct imx_mhdp_device to drm/imx folder.
7 change the base address name from regs to regs_base.
8 add mhdp bus access function.
9 uniform variable name.
10
11 Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
12 ---
13  drivers/gpu/drm/bridge/cadence/cdns-dp-core.c     | 188 ++++++++++-----------
14  drivers/gpu/drm/bridge/cadence/cdns-hdmi-core.c   | 190 ++++++++++------------
15  drivers/gpu/drm/bridge/cadence/cdns-mhdp-audio.c  |   1 -
16  drivers/gpu/drm/bridge/cadence/cdns-mhdp-cec.c    |   2 +-
17  drivers/gpu/drm/bridge/cadence/cdns-mhdp-common.c |  43 ++---
18  drivers/gpu/drm/bridge/cadence/cdns-mhdp-hdmi.c   |   1 -
19  include/drm/bridge/cdns-mhdp-common.h             |  67 +++++++-
20  include/drm/bridge/cdns-mhdp-imx.h                | 121 --------------
21  8 files changed, 258 insertions(+), 355 deletions(-)
22  delete mode 100644 include/drm/bridge/cdns-mhdp-imx.h
23
24 --- a/drivers/gpu/drm/bridge/cadence/cdns-dp-core.c
25 +++ b/drivers/gpu/drm/bridge/cadence/cdns-dp-core.c
26 @@ -9,8 +9,7 @@
27   * (at your option) any later version.
28   *
29   */
30 -
31 -#include <drm/bridge/cdns-mhdp-imx.h>
32 +#include <drm/bridge/cdns-mhdp-common.h>
33  #include <drm/drm_atomic_helper.h>
34  #include <drm/drm_crtc_helper.h>
35  #include <drm/drm_edid.h>
36 @@ -25,8 +24,6 @@
37  #include <linux/mutex.h>
38  #include <linux/of_device.h>
39  
40 -#define aux_to_hdp(x) container_of(x, struct imx_mhdp_device, aux)
41 -
42  /*
43   * This function only implements native DPDC reads and writes
44   */
45 @@ -111,24 +108,24 @@ static void dp_pixel_clk_reset(struct cd
46         cdns_mhdp_reg_write(mhdp, SOURCE_HDTX_CAR, val);
47  }
48  
49 -static void cdns_dp_mode_set(struct imx_mhdp_device *dp,
50 +static void cdns_dp_mode_set(struct cdns_mhdp_device *mhdp,
51                         const struct drm_display_mode *mode)
52  {
53         struct drm_dp_link link;
54 -       struct cdns_mhdp_device *mhdp = &dp->mhdp;
55         u32 lane_mapping = mhdp->lane_mapping;
56         int ret;
57         char linkid[6];
58  
59         memcpy(&mhdp->mode, mode, sizeof(struct drm_display_mode));
60  
61 -       dp->dual_mode = video_is_dual_mode(mode);
62 +       //Sandor TODO
63 +//     mhdp->dual_mode = video_is_dual_mode(mode);
64  
65         dp_pixel_clk_reset(mhdp);
66  
67 -       hdp_plat_call(dp, pclock_change);
68 +       cdns_mhdp_plat_call(mhdp, pclk_rate);
69  
70 -       hdp_plat_call(dp, phy_init);
71 +       cdns_mhdp_plat_call(mhdp, phy_set);
72  
73         ret = drm_dp_downstream_id(&mhdp->dp.aux, linkid);
74         if (ret < 0) {
75 @@ -168,7 +165,7 @@ static void cdns_dp_mode_set(struct imx_
76         /* initialize phy if lanes or link rate differnt */
77         if (mhdp->dp.link.num_lanes != mhdp->dp.num_lanes ||
78                         mhdp->dp.link.rate != mhdp->dp.link_rate)
79 -               hdp_plat_call(dp, phy_init);
80 +               cdns_mhdp_plat_call(mhdp, phy_set);
81  
82         /* Video off */
83         ret = cdns_mhdp_set_video_status(mhdp, CONTROL_VIDEO_IDLE);
84 @@ -215,11 +212,11 @@ static void cdns_dp_mode_set(struct imx_
85  static enum drm_connector_status
86  cdns_dp_connector_detect(struct drm_connector *connector, bool force)
87  {
88 -       struct imx_mhdp_device *dp = container_of(connector,
89 -                                       struct imx_mhdp_device, mhdp.connector.base);
90 +       struct cdns_mhdp_device *mhdp = container_of(connector,
91 +                                       struct cdns_mhdp_device, connector.base);
92         u8 hpd = 0xf;
93  
94 -       hpd = cdns_mhdp_read_hpd(&dp->mhdp);
95 +       hpd = cdns_mhdp_read_hpd(mhdp);
96         if (hpd == 1)
97                 /* Cable Connected */
98                 return connector_status_connected;
99 @@ -235,15 +232,15 @@ cdns_dp_connector_detect(struct drm_conn
100  
101  static int cdns_dp_connector_get_modes(struct drm_connector *connector)
102  {
103 -       struct imx_mhdp_device *dp = container_of(connector,
104 -                                               struct imx_mhdp_device, mhdp.connector.base);
105 +       struct cdns_mhdp_device *mhdp = container_of(connector,
106 +                                       struct cdns_mhdp_device, connector.base);
107         int num_modes = 0;
108         struct edid *edid;
109  
110 -       edid = drm_do_get_edid(&dp->mhdp.connector.base,
111 -                                  cdns_mhdp_get_edid_block, &dp->mhdp);
112 +       edid = drm_do_get_edid(&mhdp->connector.base,
113 +                                  cdns_mhdp_get_edid_block, mhdp);
114         if (edid) {
115 -               dev_info(dp->mhdp.dev, "%x,%x,%x,%x,%x,%x,%x,%x\n",
116 +               dev_info(mhdp->dev, "%x,%x,%x,%x,%x,%x,%x,%x\n",
117                          edid->header[0], edid->header[1],
118                          edid->header[2], edid->header[3],
119                          edid->header[4], edid->header[5],
120 @@ -273,9 +270,9 @@ static const struct drm_connector_helper
121  
122  static int cdns_dp_bridge_attach(struct drm_bridge *bridge)
123  {
124 -       struct imx_mhdp_device *dp = bridge->driver_private;
125 +       struct cdns_mhdp_device *mhdp = bridge->driver_private;
126         struct drm_encoder *encoder = bridge->encoder;
127 -       struct drm_connector *connector = &dp->mhdp.connector.base;
128 +       struct drm_connector *connector = &mhdp->connector.base;
129  
130         connector->interlace_allowed = 1;
131         connector->polled = DRM_CONNECTOR_POLL_HPD;
132 @@ -319,9 +316,9 @@ static void cdns_dp_bridge_mode_set(stru
133                                     const struct drm_display_mode *orig_mode,
134                                     const struct drm_display_mode *mode)
135  {
136 -       struct imx_mhdp_device *dp = bridge->driver_private;
137 -       struct drm_display_info *display_info = &dp->mhdp.connector.base.display_info;
138 -       struct video_info *video = &dp->mhdp.video_info;
139 +       struct cdns_mhdp_device *mhdp = bridge->driver_private;
140 +       struct drm_display_info *display_info = &mhdp->connector.base.display_info;
141 +       struct video_info *video = &mhdp->video_info;
142  
143         switch (display_info->bpc) {
144         case 10:
145 @@ -341,11 +338,11 @@ static void cdns_dp_bridge_mode_set(stru
146  
147         DRM_INFO("Mode: %dx%dp%d\n", mode->hdisplay, mode->vdisplay, mode->clock); 
148  
149 -       mutex_lock(&dp->lock);
150 +       mutex_lock(&mhdp->lock);
151  
152 -       cdns_dp_mode_set(dp, mode);
153 +       cdns_dp_mode_set(mhdp, mode);
154  
155 -       mutex_unlock(&dp->lock);
156 +       mutex_unlock(&mhdp->lock);
157  }
158  
159  static void cdn_hdp_bridge_enable(struct drm_bridge *bridge)
160 @@ -354,8 +351,7 @@ static void cdn_hdp_bridge_enable(struct
161  
162  static void cdn_hdp_bridge_disable(struct drm_bridge *bridge)
163  {      
164 -       struct imx_mhdp_device *dp = bridge->driver_private;
165 -       struct cdns_mhdp_device *mhdp = &dp->mhdp;
166 +       struct cdns_mhdp_device *mhdp = bridge->driver_private;
167  
168         cdns_mhdp_set_video_status(mhdp, CONTROL_VIDEO_IDLE);
169         drm_dp_link_power_down(&mhdp->dp.aux, &mhdp->dp.link);
170 @@ -371,29 +367,29 @@ static const struct drm_bridge_funcs cdn
171  
172  static void hotplug_work_func(struct work_struct *work)
173  {
174 -       struct imx_mhdp_device *dp = container_of(work,
175 -                                          struct imx_mhdp_device, hotplug_work.work);
176 -       struct drm_connector *connector = &dp->mhdp.connector.base;
177 +       struct cdns_mhdp_device *mhdp = container_of(work,
178 +                                          struct cdns_mhdp_device, hotplug_work.work);
179 +       struct drm_connector *connector = &mhdp->connector.base;
180  
181         drm_helper_hpd_irq_event(connector->dev);
182  
183         if (connector->status == connector_status_connected) {
184                 DRM_INFO("HDMI/DP Cable Plug In\n");
185 -               enable_irq(dp->irq[IRQ_OUT]);
186 +               enable_irq(mhdp->irq[IRQ_OUT]);
187         } else if (connector->status == connector_status_disconnected) {
188                 /* Cable Disconnedted  */
189                 DRM_INFO("HDMI/DP Cable Plug Out\n");
190 -               enable_irq(dp->irq[IRQ_IN]);
191 +               enable_irq(mhdp->irq[IRQ_IN]);
192         }
193  }
194  
195  static irqreturn_t cdns_dp_irq_thread(int irq, void *data)
196  {
197 -       struct imx_mhdp_device *dp = data;
198 +       struct cdns_mhdp_device *mhdp = data;
199  
200         disable_irq_nosync(irq);
201  
202 -       mod_delayed_work(system_wq, &dp->hotplug_work,
203 +       mod_delayed_work(system_wq, &mhdp->hotplug_work,
204                         msecs_to_jiffies(HOTPLUG_DEBOUNCE_MS));
205  
206         return IRQ_HANDLED;
207 @@ -430,111 +426,92 @@ static void cdns_dp_parse_dt(struct cdns
208         mhdp->dp.link.rate= mhdp->dp.link_rate;
209  }
210  
211 -static struct imx_mhdp_device *
212 -__cdns_dp_probe(struct platform_device *pdev,
213 -               const struct cdn_plat_data *plat_data)
214 +static int __cdns_dp_probe(struct platform_device *pdev,
215 +               struct cdns_mhdp_device *mhdp)
216  {
217         struct device *dev = &pdev->dev;
218 -       struct imx_mhdp_device *dp;
219         struct resource *iores = NULL;
220         int ret;
221  
222 -       dp = devm_kzalloc(dev, sizeof(*dp), GFP_KERNEL);
223 -       if (!dp)
224 -               return ERR_PTR(-ENOMEM);
225 -
226 -       dp->plat_data = plat_data;
227 -       dp->mhdp.dev = dev;
228 -
229 -       mutex_init(&dp->lock);
230 -       mutex_init(&dp->audio_mutex);
231 -       spin_lock_init(&dp->audio_lock);
232 +       mutex_init(&mhdp->lock);
233  
234 -       INIT_DELAYED_WORK(&dp->hotplug_work, hotplug_work_func);
235 +       INIT_DELAYED_WORK(&mhdp->hotplug_work, hotplug_work_func);
236  
237         iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
238 -       dp->mhdp.regs = devm_ioremap(dev, iores->start, resource_size(iores));
239 -       if (IS_ERR(dp->mhdp.regs)) {
240 -               ret = PTR_ERR(dp->mhdp.regs);
241 -               goto err_out;
242 -       }
243 +       mhdp->regs_base = devm_ioremap(dev, iores->start, resource_size(iores));
244 +       if (IS_ERR(mhdp->regs_base))
245 +               return -ENOMEM;
246  
247 -#if 0
248         iores = platform_get_resource(pdev, IORESOURCE_MEM, 1);
249 -       dp->regs_ss = devm_ioremap(dev, iores->start, resource_size(iores));
250 -       if (IS_ERR(dp->regs_ss)) {
251 -               ret = PTR_ERR(dp->regs_ss);
252 -               goto err_out;
253 -       }
254 -#endif
255 +       mhdp->regs_sec = devm_ioremap(dev, iores->start, resource_size(iores));
256 +       if (IS_ERR(mhdp->regs_sec))
257 +               return -ENOMEM;
258  
259 -       dp->irq[IRQ_IN] = platform_get_irq_byname(pdev, "plug_in");
260 -       if (dp->irq[IRQ_IN] < 0)
261 +       mhdp->irq[IRQ_IN] = platform_get_irq_byname(pdev, "plug_in");
262 +       if (mhdp->irq[IRQ_IN] < 0)
263                 dev_info(dev, "No plug_in irq number\n");
264  
265 -       dp->irq[IRQ_OUT] = platform_get_irq_byname(pdev, "plug_out");
266 -       if (dp->irq[IRQ_OUT] < 0)
267 +       mhdp->irq[IRQ_OUT] = platform_get_irq_byname(pdev, "plug_out");
268 +       if (mhdp->irq[IRQ_OUT] < 0)
269                 dev_info(dev, "No plug_out irq number\n");
270  
271 -       cdns_dp_parse_dt(&dp->mhdp);
272 +       cdns_dp_parse_dt(mhdp);
273  
274 -       dp->dual_mode = false;
275 -       hdp_plat_call(dp, fw_init);
276 +//     mhdp->dual_mode = false;
277 +       cdns_mhdp_plat_call(mhdp, firmware_init);
278  
279         /* DP FW alive check */
280 -       ret = cdns_mhdp_check_alive(&dp->mhdp);
281 +       ret = cdns_mhdp_check_alive(mhdp);
282         if (ret == false) {
283                 DRM_ERROR("NO dp FW running\n");
284 -               return ERR_PTR(-ENXIO);
285 +               return -ENXIO;
286         }
287  
288         /* DP PHY init before AUX init */
289 -       hdp_plat_call(dp, phy_init);
290 +       cdns_mhdp_plat_call(mhdp, phy_set);
291  
292         /* Enable Hotplug Detect IRQ thread */
293 -       irq_set_status_flags(dp->irq[IRQ_IN], IRQ_NOAUTOEN);
294 -       ret = devm_request_threaded_irq(dev, dp->irq[IRQ_IN],
295 +       irq_set_status_flags(mhdp->irq[IRQ_IN], IRQ_NOAUTOEN);
296 +       ret = devm_request_threaded_irq(dev, mhdp->irq[IRQ_IN],
297                                         NULL, cdns_dp_irq_thread,
298                                         IRQF_ONESHOT, dev_name(dev),
299 -                                       dp);
300 +                                       mhdp);
301         if (ret) {
302                 dev_err(dev, "can't claim irq %d\n",
303 -                                               dp->irq[IRQ_IN]);
304 -               goto err_out;
305 +                                               mhdp->irq[IRQ_IN]);
306 +               return -EINVAL;
307         }
308         
309 -       irq_set_status_flags(dp->irq[IRQ_OUT], IRQ_NOAUTOEN);
310 -       ret = devm_request_threaded_irq(dev, dp->irq[IRQ_OUT],
311 +       irq_set_status_flags(mhdp->irq[IRQ_OUT], IRQ_NOAUTOEN);
312 +       ret = devm_request_threaded_irq(dev, mhdp->irq[IRQ_OUT],
313                                         NULL, cdns_dp_irq_thread,
314                                         IRQF_ONESHOT, dev_name(dev),
315 -                                       dp);
316 +                                       mhdp);
317         if (ret) {
318                 dev_err(dev, "can't claim irq %d\n",
319 -                                               dp->irq[IRQ_OUT]);
320 -               goto err_out;
321 +                                               mhdp->irq[IRQ_OUT]);
322 +               return -EINVAL;
323         }
324 -       if (cdns_mhdp_read_hpd(&dp->mhdp))
325 -               enable_irq(dp->irq[IRQ_OUT]);
326 +
327 +       if (cdns_mhdp_read_hpd(mhdp))
328 +               enable_irq(mhdp->irq[IRQ_OUT]);
329         else
330 -               enable_irq(dp->irq[IRQ_IN]);
331 +               enable_irq(mhdp->irq[IRQ_IN]);
332  
333 -       dp->mhdp.bridge.base.driver_private = dp;
334 -       dp->mhdp.bridge.base.funcs = &cdns_dp_bridge_funcs;
335 +       mhdp->bridge.base.driver_private = mhdp;
336 +       mhdp->bridge.base.funcs = &cdns_dp_bridge_funcs;
337  #ifdef CONFIG_OF
338 -       dp->mhdp.bridge.base.of_node = dev->of_node;
339 +       mhdp->bridge.base.of_node = dev->of_node;
340  #endif
341  
342 -       dev_set_drvdata(dev, &dp->mhdp);
343 +       dev_set_drvdata(dev, mhdp);
344         
345         /* register audio driver */
346         cdns_mhdp_register_audio_driver(dev);
347  
348 -       dp_aux_init(&dp->mhdp, dev);
349 -
350 -       return dp;
351 +       dp_aux_init(mhdp, dev);
352  
353 -err_out:
354 -       return ERR_PTR(ret);
355 +       return 0;
356  }
357  
358  static void __cdns_dp_remove(struct cdns_mhdp_device *mhdp)
359 @@ -547,15 +524,15 @@ static void __cdns_dp_remove(struct cdns
360   * Probe/remove API, used from platforms based on the DRM bridge API.
361   */
362  int cdns_dp_probe(struct platform_device *pdev,
363 -                 const struct cdn_plat_data *plat_data)
364 +                 struct cdns_mhdp_device *mhdp)
365  {
366 -       struct imx_mhdp_device *dp;
367 +       int ret;
368  
369 -       dp = __cdns_dp_probe(pdev, plat_data);
370 -       if (IS_ERR(dp))
371 -               return PTR_ERR(dp);
372 +       ret = __cdns_dp_probe(pdev, mhdp);
373 +       if (ret)
374 +               return ret;
375  
376 -       drm_bridge_add(&dp->mhdp.bridge.base);
377 +       drm_bridge_add(&mhdp->bridge.base);
378  
379         return 0;
380  }
381 @@ -575,16 +552,15 @@ EXPORT_SYMBOL_GPL(cdns_dp_remove);
382   * Bind/unbind API, used from platforms based on the component framework.
383   */
384  int cdns_dp_bind(struct platform_device *pdev, struct drm_encoder *encoder,
385 -                const struct cdn_plat_data *plat_data)
386 +               struct cdns_mhdp_device *mhdp)
387  {
388 -       struct imx_mhdp_device *dp;
389         int ret;
390  
391 -       dp = __cdns_dp_probe(pdev, plat_data);
392 -       if (IS_ERR(dp))
393 -               return PTR_ERR(dp);
394 +       ret = __cdns_dp_probe(pdev, mhdp);
395 +       if (ret < 0)
396 +               return ret;
397  
398 -       ret = drm_bridge_attach(encoder, &dp->mhdp.bridge.base, NULL);
399 +       ret = drm_bridge_attach(encoder, &mhdp->bridge.base, NULL);
400         if (ret) {
401                 cdns_dp_remove(pdev);
402                 DRM_ERROR("Failed to initialize bridge with drm\n");
403 --- a/drivers/gpu/drm/bridge/cadence/cdns-hdmi-core.c
404 +++ b/drivers/gpu/drm/bridge/cadence/cdns-hdmi-core.c
405 @@ -9,7 +9,7 @@
406   * (at your option) any later version.
407   *
408   */
409 -#include <drm/bridge/cdns-mhdp-imx.h>
410 +#include <drm/bridge/cdns-mhdp-common.h>
411  #include <drm/drm_atomic_helper.h>
412  #include <drm/drm_crtc_helper.h>
413  #include <drm/drm_edid.h>
414 @@ -60,8 +60,6 @@ static int hdmi_sink_config(struct cdns_
415  static void hdmi_lanes_config(struct cdns_mhdp_device *mhdp)
416  {
417         /* Line swaping */
418 -       /* For imx8qm lane_mapping = 0x93
419 -        * For imx8mq lane_mapping = 0xe4*/
420         cdns_mhdp_reg_write(mhdp, LANES_CONFIG, 0x00400000 | mhdp->lane_mapping);
421  }
422  
423 @@ -216,12 +214,12 @@ void cdns_hdmi_mode_set(struct cdns_mhdp
424  static enum drm_connector_status
425  cdns_hdmi_connector_detect(struct drm_connector *connector, bool force)
426  {
427 -       struct imx_mhdp_device *hdmi =
428 -                               container_of(connector, struct imx_mhdp_device, mhdp.connector.base);
429 +       struct cdns_mhdp_device *mhdp =
430 +                               container_of(connector, struct cdns_mhdp_device, connector.base);
431  
432         u8 hpd = 0xf;
433  
434 -       hpd = cdns_mhdp_read_hpd(&hdmi->mhdp);
435 +       hpd = cdns_mhdp_read_hpd(mhdp);
436  
437         if (hpd == 1)
438                 /* Cable Connected */
439 @@ -238,15 +236,15 @@ cdns_hdmi_connector_detect(struct drm_co
440  
441  static int cdns_hdmi_connector_get_modes(struct drm_connector *connector)
442  {
443 -       struct imx_mhdp_device *hdmi = container_of(connector, struct imx_mhdp_device,
444 -                                            mhdp.connector.base);
445 +       struct cdns_mhdp_device *mhdp =
446 +                               container_of(connector, struct cdns_mhdp_device, connector.base);
447         int num_modes = 0;
448         struct edid *edid;
449  
450 -       edid = drm_do_get_edid(&hdmi->mhdp.connector.base,
451 -                                  cdns_hdmi_get_edid_block, &hdmi->mhdp);
452 +       edid = drm_do_get_edid(&mhdp->connector.base,
453 +                                  cdns_hdmi_get_edid_block, mhdp);
454         if (edid) {
455 -               dev_info(hdmi->mhdp.dev, "%x,%x,%x,%x,%x,%x,%x,%x\n",
456 +               dev_info(mhdp->dev, "%x,%x,%x,%x,%x,%x,%x,%x\n",
457                          edid->header[0], edid->header[1],
458                          edid->header[2], edid->header[3],
459                          edid->header[4], edid->header[5],
460 @@ -276,9 +274,9 @@ static const struct drm_connector_helper
461  
462  static int cdns_hdmi_bridge_attach(struct drm_bridge *bridge)
463  {
464 -       struct imx_mhdp_device *hdmi = bridge->driver_private;
465 +       struct cdns_mhdp_device *mhdp = bridge->driver_private;
466         struct drm_encoder *encoder = bridge->encoder;
467 -       struct drm_connector *connector = &hdmi->mhdp.connector.base;
468 +       struct drm_connector *connector = &mhdp->connector.base;
469  
470         connector->interlace_allowed = 1;
471         connector->polled = DRM_CONNECTOR_POLL_HPD;
472 @@ -319,9 +317,9 @@ static void cdns_hdmi_bridge_mode_set(st
473                                     const struct drm_display_mode *orig_mode,
474                                     const struct drm_display_mode *mode)
475  {
476 -       struct imx_mhdp_device *hdmi = bridge->driver_private;
477 -       struct drm_display_info *display_info = &hdmi->mhdp.connector.base.display_info;
478 -       struct video_info *video = &hdmi->mhdp.video_info;
479 +       struct cdns_mhdp_device *mhdp = bridge->driver_private;
480 +       struct drm_display_info *display_info = &mhdp->connector.base.display_info;
481 +       struct video_info *video = &mhdp->video_info;
482  
483         switch (display_info->bpc) {
484         case 10:
485 @@ -339,23 +337,24 @@ static void cdns_hdmi_bridge_mode_set(st
486         video->v_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NVSYNC);
487         video->h_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NHSYNC);
488  
489 -       mutex_lock(&hdmi->lock);
490 +       mutex_lock(&mhdp->lock);
491  
492         DRM_INFO("Mode: %dx%dp%d\n", mode->hdisplay, mode->vdisplay, mode->clock); 
493  
494 -       memcpy(&hdmi->mhdp.mode, mode, sizeof(struct drm_display_mode));
495 +       memcpy(&mhdp->mode, mode, sizeof(struct drm_display_mode));
496  
497 -       hdmi->dual_mode = video_is_dual_mode(mode);
498 +       //Sandor TODO
499 +//     hdmi->dual_mode = video_is_dual_mode(mode);
500  
501 -       hdmi_lanes_config(&hdmi->mhdp);
502 +       hdmi_lanes_config(mhdp);
503  
504 -       hdp_plat_call(hdmi, pclock_change);
505 +       cdns_mhdp_plat_call(mhdp, pclk_rate);
506  
507 -       hdp_plat_call(hdmi, phy_init);
508 +       cdns_mhdp_plat_call(mhdp, phy_set);
509  
510 -       cdns_hdmi_mode_set(&hdmi->mhdp);
511 +       cdns_hdmi_mode_set(mhdp);
512  
513 -       mutex_unlock(&hdmi->lock);
514 +       mutex_unlock(&mhdp->lock);
515  }
516  
517  static const struct drm_bridge_funcs cdns_hdmi_bridge_funcs = {
518 @@ -366,30 +365,30 @@ static const struct drm_bridge_funcs cdn
519  
520  static void hotplug_work_func(struct work_struct *work)
521  {
522 -       struct imx_mhdp_device *hdmi = container_of(work,
523 -                                          struct imx_mhdp_device, hotplug_work.work);
524 -       struct drm_connector *connector = &hdmi->mhdp.connector.base;
525 +       struct cdns_mhdp_device *mhdp = container_of(work,
526 +                                          struct cdns_mhdp_device, hotplug_work.work);
527 +       struct drm_connector *connector = &mhdp->connector.base;
528  
529         drm_helper_hpd_irq_event(connector->dev);
530  
531         if (connector->status == connector_status_connected) {
532                 /* Cable Connected */
533                 DRM_INFO("HDMI Cable Plug In\n");
534 -               enable_irq(hdmi->irq[IRQ_OUT]);
535 +               enable_irq(mhdp->irq[IRQ_OUT]);
536         } else if (connector->status == connector_status_disconnected) {
537                 /* Cable Disconnedted  */
538                 DRM_INFO("HDMI Cable Plug Out\n");
539 -               enable_irq(hdmi->irq[IRQ_IN]);
540 +               enable_irq(mhdp->irq[IRQ_IN]);
541         }
542  }
543  
544  static irqreturn_t cdns_hdmi_irq_thread(int irq, void *data)
545  {
546 -       struct imx_mhdp_device *hdmi = data;
547 +       struct cdns_mhdp_device *mhdp = data;
548  
549         disable_irq_nosync(irq);
550  
551 -       mod_delayed_work(system_wq, &hdmi->hotplug_work,
552 +       mod_delayed_work(system_wq, &mhdp->hotplug_work,
553                         msecs_to_jiffies(HOTPLUG_DEBOUNCE_MS));
554  
555         return IRQ_HANDLED;
556 @@ -408,109 +407,99 @@ static void cdns_hdmi_parse_dt(struct cd
557         dev_info(mhdp->dev, "lane-mapping 0x%02x\n", mhdp->lane_mapping);
558  }
559  
560 -static struct imx_mhdp_device *
561 -__cdns_hdmi_probe(struct platform_device *pdev,
562 -                       const struct cdn_plat_data *plat_data)
563 +static int __cdns_hdmi_probe(struct platform_device *pdev,
564 +                 struct cdns_mhdp_device *mhdp)
565  {
566         struct device *dev = &pdev->dev;
567 -       struct device_node *np = dev->of_node;
568         struct platform_device_info pdevinfo;
569 -       struct imx_mhdp_device *hdmi;
570         struct resource *iores = NULL;
571         int ret;
572  
573 -       hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
574 -       if (!hdmi)
575 -               return ERR_PTR(-ENOMEM);
576 -
577 -       hdmi->plat_data = plat_data;
578 -       hdmi->mhdp.dev = dev;
579 -
580 -       mutex_init(&hdmi->lock);
581 -       mutex_init(&hdmi->audio_mutex);
582 -       spin_lock_init(&hdmi->audio_lock);
583 +       mutex_init(&mhdp->lock);
584  
585 -       INIT_DELAYED_WORK(&hdmi->hotplug_work, hotplug_work_func);
586 +       INIT_DELAYED_WORK(&mhdp->hotplug_work, hotplug_work_func);
587  
588         iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
589 -       hdmi->mhdp.regs = devm_ioremap(dev, iores->start, resource_size(iores));
590 -       if (IS_ERR(hdmi->mhdp.regs)) {
591 -               ret = PTR_ERR(hdmi->mhdp.regs);
592 -               goto err_out;
593 +       mhdp->regs_base = devm_ioremap(dev, iores->start, resource_size(iores));
594 +       if (IS_ERR(mhdp->regs_base)) {
595 +               dev_err(dev, "No regs_base memory\n");
596 +               return -ENOMEM;
597 +       }
598 +
599 +       /* sec register base */
600 +       iores = platform_get_resource(pdev, IORESOURCE_MEM, 1);
601 +       mhdp->regs_sec = devm_ioremap(dev, iores->start, resource_size(iores));
602 +       if (IS_ERR(mhdp->regs_sec)) {
603 +               dev_err(dev, "No regs_sec memory\n");
604 +               return -ENOMEM;
605         }
606  
607 -       /* csr register base */
608 -       hdmi->regmap_csr = syscon_regmap_lookup_by_phandle(np, "csr");
609 -       if (IS_ERR(hdmi->regmap_csr)) {
610 -               dev_info(dev, "No csr regmap\n");
611 -       }
612 -
613 -       hdmi->irq[IRQ_IN] = platform_get_irq_byname(pdev, "plug_in");
614 -       if (hdmi->irq[IRQ_IN] < 0) {
615 +       mhdp->irq[IRQ_IN] = platform_get_irq_byname(pdev, "plug_in");
616 +       if (mhdp->irq[IRQ_IN] < 0) {
617                 dev_info(dev, "No plug_in irq number\n");
618 -               return ERR_PTR(-EPROBE_DEFER);
619 +               return -EPROBE_DEFER;
620         }
621  
622 -       hdmi->irq[IRQ_OUT] = platform_get_irq_byname(pdev, "plug_out");
623 -       if (hdmi->irq[IRQ_OUT] < 0) {
624 +       mhdp->irq[IRQ_OUT] = platform_get_irq_byname(pdev, "plug_out");
625 +       if (mhdp->irq[IRQ_OUT] < 0) {
626                 dev_info(dev, "No plug_out irq number\n");
627 -               return ERR_PTR(-EPROBE_DEFER);
628 +               return -EPROBE_DEFER;
629         }
630  
631         /* Initialize dual_mode to false */
632 -       hdmi->dual_mode = false;
633 +//     hdmi->dual_mode = false;
634  
635         /* Initialize FW */
636 -       hdp_plat_call(hdmi, fw_init);
637 +       cdns_mhdp_plat_call(mhdp, firmware_init);
638  
639         /* HDMI FW alive check */
640 -       ret = cdns_mhdp_check_alive(&hdmi->mhdp);
641 +       ret = cdns_mhdp_check_alive(mhdp);
642         if (ret == false) {
643 -               DRM_ERROR("NO HDMI FW running\n");
644 -               return ERR_PTR(-ENXIO);
645 +               dev_err(dev, "NO HDMI FW running\n");
646 +               return -ENXIO;
647         }
648  
649         /* Enable Hotplug Detect thread */
650 -       irq_set_status_flags(hdmi->irq[IRQ_IN], IRQ_NOAUTOEN);
651 -       ret = devm_request_threaded_irq(dev, hdmi->irq[IRQ_IN],
652 +       irq_set_status_flags(mhdp->irq[IRQ_IN], IRQ_NOAUTOEN);
653 +       ret = devm_request_threaded_irq(dev, mhdp->irq[IRQ_IN],
654                                         NULL, cdns_hdmi_irq_thread,
655                                         IRQF_ONESHOT, dev_name(dev),
656 -                                       hdmi);
657 -       if (ret) {
658 +                                       mhdp);
659 +       if (ret < 0) {
660                 dev_err(dev, "can't claim irq %d\n",
661 -                                               hdmi->irq[IRQ_IN]);
662 -               goto err_out;
663 +                                               mhdp->irq[IRQ_IN]);
664 +               return -EINVAL;
665         }
666         
667 -       irq_set_status_flags(hdmi->irq[IRQ_OUT], IRQ_NOAUTOEN);
668 -       ret = devm_request_threaded_irq(dev, hdmi->irq[IRQ_OUT],
669 +       irq_set_status_flags(mhdp->irq[IRQ_OUT], IRQ_NOAUTOEN);
670 +       ret = devm_request_threaded_irq(dev, mhdp->irq[IRQ_OUT],
671                                         NULL, cdns_hdmi_irq_thread,
672                                         IRQF_ONESHOT, dev_name(dev),
673 -                                       hdmi);
674 -       if (ret) {
675 +                                       mhdp);
676 +       if (ret < 0) {
677                 dev_err(dev, "can't claim irq %d\n",
678 -                                               hdmi->irq[IRQ_OUT]);
679 -               goto err_out;
680 +                                               mhdp->irq[IRQ_OUT]);
681 +               return -EINVAL;
682         }
683  
684 -       cdns_hdmi_parse_dt(&hdmi->mhdp);
685 +       cdns_hdmi_parse_dt(mhdp);
686  
687 -       if (cdns_mhdp_read_hpd(&hdmi->mhdp))
688 -               enable_irq(hdmi->irq[IRQ_OUT]);
689 +       if (cdns_mhdp_read_hpd(mhdp))
690 +               enable_irq(mhdp->irq[IRQ_OUT]);
691         else
692 -               enable_irq(hdmi->irq[IRQ_IN]);
693 +               enable_irq(mhdp->irq[IRQ_IN]);
694  
695 -       hdmi->mhdp.bridge.base.driver_private = hdmi;
696 -       hdmi->mhdp.bridge.base.funcs = &cdns_hdmi_bridge_funcs;
697 +       mhdp->bridge.base.driver_private = mhdp;
698 +       mhdp->bridge.base.funcs = &cdns_hdmi_bridge_funcs;
699  #ifdef CONFIG_OF
700 -       hdmi->mhdp.bridge.base.of_node = dev->of_node;
701 +       mhdp->bridge.base.of_node = dev->of_node;
702  #endif
703  
704         memset(&pdevinfo, 0, sizeof(pdevinfo));
705         pdevinfo.parent = dev;
706         pdevinfo.id = PLATFORM_DEVID_AUTO;
707  
708 -       dev_set_drvdata(dev, &hdmi->mhdp);
709 +       dev_set_drvdata(dev, mhdp);
710  
711         /* register audio driver */
712         cdns_mhdp_register_audio_driver(dev);
713 @@ -520,11 +509,7 @@ __cdns_hdmi_probe(struct platform_device
714         cdns_mhdp_register_cec_driver(dev);
715  #endif
716  
717 -       return hdmi;
718 -
719 -err_out:
720 -
721 -       return ERR_PTR(ret);
722 +       return 0;
723  }
724  
725  static void __cdns_hdmi_remove(struct cdns_mhdp_device *mhdp)
726 @@ -540,15 +525,15 @@ static void __cdns_hdmi_remove(struct cd
727   * Probe/remove API, used from platforms based on the DRM bridge API.
728   */
729  int cdns_hdmi_probe(struct platform_device *pdev,
730 -                 const struct cdn_plat_data *plat_data)
731 +               struct cdns_mhdp_device *mhdp)
732  {
733 -       struct imx_mhdp_device *hdmi;
734 +       int ret;
735  
736 -       hdmi = __cdns_hdmi_probe(pdev, plat_data);
737 -       if (IS_ERR(hdmi))
738 -               return PTR_ERR(hdmi);
739 +       ret  = __cdns_hdmi_probe(pdev, mhdp);
740 +       if (ret < 0)
741 +               return ret;
742  
743 -       drm_bridge_add(&hdmi->mhdp.bridge.base);
744 +       drm_bridge_add(&mhdp->bridge.base);
745  
746         return 0;
747  }
748 @@ -568,16 +553,15 @@ EXPORT_SYMBOL_GPL(cdns_hdmi_remove);
749   * Bind/unbind API, used from platforms based on the component framework.
750   */
751  int cdns_hdmi_bind(struct platform_device *pdev, struct drm_encoder *encoder,
752 -                const struct cdn_plat_data *plat_data)
753 +                       struct cdns_mhdp_device *mhdp)
754  {
755 -       struct imx_mhdp_device *hdmi;
756         int ret;
757  
758 -       hdmi = __cdns_hdmi_probe(pdev, plat_data);
759 -       if (IS_ERR(hdmi))
760 -               return PTR_ERR(hdmi);
761 +       ret = __cdns_hdmi_probe(pdev, mhdp);
762 +       if (ret)
763 +               return ret;
764  
765 -       ret = drm_bridge_attach(encoder, &hdmi->mhdp.bridge.base, NULL);
766 +       ret = drm_bridge_attach(encoder, &mhdp->bridge.base, NULL);
767         if (ret) {
768                 cdns_hdmi_remove(pdev);
769                 DRM_ERROR("Failed to initialize bridge with drm\n");
770 --- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp-audio.c
771 +++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp-audio.c
772 @@ -16,7 +16,6 @@
773  #include <linux/reset.h>
774  #include <drm/bridge/cdns-mhdp-common.h>
775  #include <sound/hdmi-codec.h>
776 -#include <drm/bridge/cdns-mhdp-imx.h>
777  #include <drm/drm_of.h>
778  #include <drm/drmP.h>
779  
780 --- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp-cec.c
781 +++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp-cec.c
782 @@ -344,4 +344,4 @@ int cdns_mhdp_unregister_cec_driver(stru
783  
784  MODULE_AUTHOR("Sandor.Yu@NXP.com");
785  MODULE_LICENSE("GPL");
786 -MODULE_DESCRIPTION("NXP CDNS MHDP CEC driver");
787 +MODULE_DESCRIPTION("NXP CDNS MHDP HDMI CEC driver");
788 --- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp-common.c
789 +++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp-common.c
790 @@ -23,7 +23,6 @@
791  #include <asm/unaligned.h>
792  
793  #include <drm/bridge/cdns-mhdp-common.h>
794 -#include <drm/bridge/cdns-mhdp-imx.h>
795  #include <drm/drm_modes.h>
796  #include <drm/drm_print.h>
797  #include <linux/regmap.h>
798 @@ -74,18 +73,20 @@ static inline void put_unaligned_be24(u3
799  
800  u32 cdns_mhdp_bus_read(struct cdns_mhdp_device *mhdp, u32 offset)
801  {
802 -       struct imx_mhdp_device *hdmi = container_of(mhdp, struct imx_mhdp_device, mhdp);
803         u32 val;
804  
805 -       /* TODO */
806 -       if (offset >= 0x1000 && hdmi->regmap_csr) {
807 +       if (mhdp->bus_type == BUS_TYPE_LOW4K_SAPB) {
808 +               /* Remap address to low 4K SAPB bus */
809 +               writel(offset >> 12, mhdp->regs_sec + 0xc);
810 +               val = readl((offset & 0xfff) + mhdp->regs_base);
811 +       } else if (mhdp->bus_type == BUS_TYPE_LOW4K_APB) {
812                 /* Remap address to low 4K memory */
813 -               regmap_write(hdmi->regmap_csr, hdmi->csr_ctrl0_reg, offset >> 12);
814 -               val = readl((offset & 0xfff) + mhdp->regs);
815 -               /* Restore address mapping */
816 -               regmap_write(hdmi->regmap_csr, hdmi->csr_ctrl0_reg, 0);
817 -       } else
818 -               val = readl(mhdp->regs + offset);
819 +               writel(offset >> 12, mhdp->regs_sec + 8);
820 +               val = readl((offset & 0xfff) + mhdp->regs_base);
821 +       } else if (mhdp->bus_type == BUS_TYPE_NORMAL_SAPB)
822 +               val = readl(mhdp->regs_sec + offset);
823 +       else
824 +               val = readl(mhdp->regs_base + offset);
825  
826         return val;
827  }
828 @@ -93,18 +94,18 @@ EXPORT_SYMBOL(cdns_mhdp_bus_read);
829  
830  void cdns_mhdp_bus_write(u32 val, struct cdns_mhdp_device *mhdp, u32 offset)
831  {
832 -       struct imx_mhdp_device *hdmi = container_of(mhdp, struct imx_mhdp_device, mhdp);
833 -
834 -       /* TODO */
835 -       if (offset >= 0x1000 && hdmi->regmap_csr) {
836 +       if (mhdp->bus_type == BUS_TYPE_LOW4K_SAPB) {
837 +               /* Remap address to low 4K SAPB bus */
838 +               writel(offset >> 12, mhdp->regs_sec + 0xc);
839 +               writel(val, (offset & 0xfff) + mhdp->regs_base);
840 +       } else if (mhdp->bus_type == BUS_TYPE_LOW4K_APB) {
841                 /* Remap address to low 4K memory */
842 -               regmap_write(hdmi->regmap_csr, hdmi->csr_ctrl0_reg, offset >> 12);
843 -               writel(val, (offset & 0xfff) + mhdp->regs);
844 -               /* Restore address mapping */
845 -               regmap_write(hdmi->regmap_csr, hdmi->csr_ctrl0_reg, 0);
846 -
847 -       } else
848 -               writel(val, mhdp->regs + offset);
849 +               writel(offset >> 12, mhdp->regs_sec + 8);
850 +               writel(val, (offset & 0xfff) + mhdp->regs_base);
851 +       } else if (mhdp->bus_type == BUS_TYPE_NORMAL_SAPB)
852 +               writel(val, mhdp->regs_sec + offset);
853 +       else
854 +               writel(val, mhdp->regs_base + offset);
855  }
856  EXPORT_SYMBOL(cdns_mhdp_bus_write);
857  
858 --- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp-hdmi.c
859 +++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp-hdmi.c
860 @@ -10,7 +10,6 @@
861  #include <drm/drmP.h>
862  #include <linux/io.h>
863  #include <drm/bridge/cdns-mhdp-common.h>
864 -#include <drm/bridge/cdns-mhdp-imx.h>
865  #include <linux/regmap.h>
866  
867  void cdns_mhdp_infoframe_set(struct cdns_mhdp_device *mhdp,
868 --- a/include/drm/bridge/cdns-mhdp-common.h
869 +++ b/include/drm/bridge/cdns-mhdp-common.h
870 @@ -495,6 +495,22 @@
871  
872  #define HOTPLUG_DEBOUNCE_MS            200
873  
874 +#define IRQ_IN    0
875 +#define IRQ_OUT   1
876 +#define IRQ_NUM   2
877 +
878 +#define cdns_mhdp_plat_call(mhdp, operation)                   \
879 +       (!(mhdp) ? -ENODEV : (((mhdp)->plat_data && (mhdp)->plat_data->operation) ?     \
880 +        (mhdp)->plat_data->operation(mhdp) : ENOIOCTLCMD))
881 +
882 +/* bus access type */
883 +enum {
884 +       BUS_TYPE_NORMAL_APB = 0,
885 +       BUS_TYPE_NORMAL_SAPB = 1,
886 +       BUS_TYPE_LOW4K_APB = 2,
887 +       BUS_TYPE_LOW4K_SAPB = 3,
888 +};
889 +
890  enum voltage_swing_level {
891         VOLTAGE_LEVEL_0,
892         VOLTAGE_LEVEL_1,
893 @@ -616,8 +632,33 @@ struct cdns_mhdp_cec {
894  };
895  #endif
896  
897 +struct cdns_plat_data {
898 +       /* Vendor PHY support */
899 +       int (*bind)(struct platform_device *pdev,
900 +                       struct drm_encoder *encoder,
901 +                       struct cdns_mhdp_device *mhdp);
902 +       void (*unbind)(struct device *dev);
903 +
904 +       void (*plat_init)(struct cdns_mhdp_device *mhdp);
905 +       void (*plat_deinit)(struct cdns_mhdp_device *mhdp);
906 +
907 +       int (*phy_set)(struct cdns_mhdp_device *mhdp);
908 +       int (*firmware_init)(struct cdns_mhdp_device *mhdp);
909 +       void (*pclk_rate)(struct cdns_mhdp_device *mhdp);
910 +
911 +       int (*power_on)(struct cdns_mhdp_device *mhdp);
912 +       int (*power_off)(struct cdns_mhdp_device *mhdp);
913 +
914 +       int bus_type;
915 +       int video_format;
916 +       char is_dp;
917 +};
918 +
919  struct cdns_mhdp_device {
920 -       void __iomem            *regs;
921 +       void __iomem            *regs_base;
922 +       void __iomem            *regs_sec;
923 +
924 +       int bus_type;
925  
926         struct device           *dev;
927  
928 @@ -642,6 +683,9 @@ struct cdns_mhdp_device {
929         bool link_up;
930         bool power_up;
931         bool plugged;
932 +       struct mutex lock;
933 +
934 +       int irq[IRQ_NUM];
935  
936         union {
937                 struct _dp_data {
938 @@ -663,6 +707,8 @@ struct cdns_mhdp_device {
939                         u32 hdmi_type;
940                 } hdmi;
941         };
942 +       const struct cdns_plat_data *plat_data;
943 +
944  };
945  
946  u32 cdns_mhdp_bus_read(struct cdns_mhdp_device *mhdp, u32 offset);
947 @@ -727,6 +773,25 @@ int cdns_hdmi_disable_gcp(struct cdns_mh
948  int cdns_hdmi_enable_gcp(struct cdns_mhdp_device *mhdp);
949  
950  bool cdns_mhdp_check_alive(struct cdns_mhdp_device *mhdp);
951 +
952 +/* HDMI */
953 +int cdns_hdmi_probe(struct platform_device *pdev,
954 +                struct cdns_mhdp_device *mhdp);
955 +void cdns_hdmi_remove(struct platform_device *pdev);
956 +void cdns_hdmi_unbind(struct device *dev);
957 +int cdns_hdmi_bind(struct platform_device *pdev,
958 +                       struct drm_encoder *encoder, struct cdns_mhdp_device *mhdp);
959 +void cdns_hdmi_set_sample_rate(struct cdns_mhdp_device *mhdp, unsigned int rate);
960 +void cdns_hdmi_audio_enable(struct cdns_mhdp_device *mhdp);
961 +void cdns_hdmi_audio_disable(struct cdns_mhdp_device *mhdp);
962 +/* DP  */
963 +int cdns_dp_probe(struct platform_device *pdev,
964 +                struct cdns_mhdp_device *mhdp);
965 +void cdns_dp_remove(struct platform_device *pdev);
966 +void cdns_dp_unbind(struct device *dev);
967 +int cdns_dp_bind(struct platform_device *pdev,
968 +                       struct drm_encoder *encoder, struct cdns_mhdp_device *mhdp);
969 +
970  /* CEC */
971  #ifdef CONFIG_DRM_CDNS_HDMI_CEC
972  int cdns_mhdp_register_cec_driver(struct device *dev);
973 --- a/include/drm/bridge/cdns-mhdp-imx.h
974 +++ /dev/null
975 @@ -1,121 +0,0 @@
976 -/*
977 - * Cadence High-Definition Multimedia Interface (HDMI) driver
978 - *
979 - * Copyright (C) 2019 NXP Semiconductor, Inc.
980 - *
981 - * This program is free software; you can redistribute it and/or modify
982 - * it under the terms of the GNU General Public License as published by
983 - * the Free Software Foundation; either version 2 of the License, or
984 - * (at your option) any later version.
985 - *
986 - */
987 -#ifndef CDNS_MHDP_IMX_H_
988 -#define CDNS_MHDP_IMX_H_
989 -
990 -#include <drm/bridge/cdns-mhdp-common.h>
991 -
992 -#define IRQ_IN    0
993 -#define IRQ_OUT   1
994 -#define IRQ_NUM   2
995 -
996 -#define hdp_plat_call(hdp, operation)                  \
997 -       (!(hdp) ? -ENODEV : (((hdp)->plat_data && (hdp)->plat_data->operation) ?        \
998 -        (hdp)->plat_data->operation(hdp) : ENOIOCTLCMD))
999 -
1000 -#define HDP_DUAL_MODE_MIN_PCLK_RATE    300000  /* KHz */
1001 -#define HDP_SINGLE_MODE_MAX_WIDTH      1920
1002 -
1003 -static inline bool video_is_dual_mode(const struct drm_display_mode *mode)
1004 -{
1005 -       return (mode->clock > HDP_DUAL_MODE_MIN_PCLK_RATE ||
1006 -               mode->hdisplay > HDP_SINGLE_MODE_MAX_WIDTH) ? true : false;
1007 -}
1008 -
1009 -struct imx_mhdp_device;
1010 -
1011 -struct imx_hdp_clks {
1012 -       struct clk *av_pll;
1013 -       struct clk *dig_pll;
1014 -       struct clk *clk_ipg;
1015 -       struct clk *clk_core;
1016 -       struct clk *clk_pxl;
1017 -       struct clk *clk_pxl_mux;
1018 -       struct clk *clk_pxl_link;
1019 -
1020 -       struct clk *lpcg_hdp;
1021 -       struct clk *lpcg_msi;
1022 -       struct clk *lpcg_pxl;
1023 -       struct clk *lpcg_vif;
1024 -       struct clk *lpcg_lis;
1025 -       struct clk *lpcg_apb;
1026 -       struct clk *lpcg_apb_csr;
1027 -       struct clk *lpcg_apb_ctrl;
1028 -
1029 -       struct clk *lpcg_i2s;
1030 -       struct clk *clk_i2s_bypass;
1031 -};
1032 -
1033 -struct cdn_plat_data {
1034 -       /* Vendor PHY support */
1035 -       int (*phy_init)(struct imx_mhdp_device *hdmi);
1036 -       int (*bind)(struct platform_device *pdev,
1037 -                       struct drm_encoder *encoder,
1038 -                       const struct cdn_plat_data *plat_data);
1039 -       void (*unbind)(struct device *dev);
1040 -       int (*fw_init)(struct imx_mhdp_device *hdp);
1041 -       void (*pclock_change)(struct imx_mhdp_device *hdp);
1042 -       char is_dp;
1043 -};
1044 -
1045 -struct imx_mhdp_device {
1046 -       struct cdns_mhdp_device mhdp;
1047 -
1048 -       struct mutex lock;
1049 -       struct mutex audio_mutex;
1050 -       spinlock_t audio_lock;
1051 -       bool connected;
1052 -       bool active;
1053 -       bool suspended;
1054 -       struct imx_hdp_clks clks;
1055 -
1056 -       const struct cdn_plat_data *plat_data;
1057 -
1058 -       int irq[IRQ_NUM];
1059 -       struct delayed_work hotplug_work;
1060 -       //void __iomem *regmap_csr;
1061 -       struct regmap *regmap_csr;
1062 -       u32 csr_pxl_mux_reg;
1063 -       u32 csr_ctrl0_reg;
1064 -       u32 csr_ctrl0_sec;
1065 -
1066 -       struct audio_info audio_info;
1067 -       bool sink_has_audio;
1068 -       u32 dual_mode;
1069 -
1070 -       struct device           *pd_mhdp_dev;
1071 -       struct device           *pd_pll0_dev;
1072 -       struct device           *pd_pll1_dev;
1073 -       struct device_link      *pd_mhdp_link;
1074 -       struct device_link      *pd_pll0_link;
1075 -       struct device_link      *pd_pll1_link;
1076 -
1077 -       u32 phy_init;
1078 -};
1079 -
1080 -int cdns_hdmi_probe(struct platform_device *pdev,
1081 -                 const struct cdn_plat_data *plat_data);
1082 -void cdns_hdmi_remove(struct platform_device *pdev);
1083 -void cdns_hdmi_unbind(struct device *dev);
1084 -int cdns_hdmi_bind(struct platform_device *pdev, struct drm_encoder *encoder,
1085 -                const struct cdn_plat_data *plat_data);
1086 -void cdns_hdmi_set_sample_rate(struct imx_mhdp_device *hdmi, unsigned int rate);
1087 -void cdns_hdmi_audio_enable(struct imx_mhdp_device *hdmi);
1088 -void cdns_hdmi_audio_disable(struct imx_mhdp_device *hdmi);
1089 -int cdns_dp_probe(struct platform_device *pdev,
1090 -                 const struct cdn_plat_data *plat_data);
1091 -void cdns_dp_remove(struct platform_device *pdev);
1092 -void cdns_dp_unbind(struct device *dev);
1093 -int cdns_dp_bind(struct platform_device *pdev, struct drm_encoder *encoder,
1094 -                const struct cdn_plat_data *plat_data);
1095 -
1096 -#endif /* CDNS_MHDP_IMX_H_ */