blob: 080f0535219502306774ea799c10cc30793006ca [file] [log] [blame]
Yakir Yang9e32e162016-03-29 09:57:30 +08001/*
2 * Rockchip SoC DP (Display Port) interface driver.
3 *
4 * Copyright (C) Fuzhou Rockchip Electronics Co., Ltd.
5 * Author: Andy Yan <andy.yan@rock-chips.com>
6 * Yakir Yang <ykk@rock-chips.com>
7 * Jeff Chen <jeff.chen@rock-chips.com>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 */
14
15#include <linux/component.h>
16#include <linux/mfd/syscon.h>
Yakir Yangd9c900b2016-06-29 17:15:01 +080017#include <linux/of_device.h>
Yakir Yang9e32e162016-03-29 09:57:30 +080018#include <linux/of_graph.h>
19#include <linux/regmap.h>
20#include <linux/reset.h>
21#include <linux/clk.h>
22
23#include <drm/drmP.h>
24#include <drm/drm_crtc_helper.h>
25#include <drm/drm_dp_helper.h>
26#include <drm/drm_of.h>
27#include <drm/drm_panel.h>
28
29#include <video/of_videomode.h>
30#include <video/videomode.h>
31
32#include <drm/bridge/analogix_dp.h>
33
34#include "rockchip_drm_drv.h"
Yakir Yang8f0ac5c2016-07-24 14:57:52 +080035#include "rockchip_drm_psr.h"
Yakir Yang9e32e162016-03-29 09:57:30 +080036#include "rockchip_drm_vop.h"
37
Yakir Yangd9c900b2016-06-29 17:15:01 +080038#define RK3288_GRF_SOC_CON6 0x25c
39#define RK3288_EDP_LCDC_SEL BIT(5)
Yakir Yang82872e42016-06-29 17:15:26 +080040#define RK3399_GRF_SOC_CON20 0x6250
41#define RK3399_EDP_LCDC_SEL BIT(5)
Yakir Yangd9c900b2016-06-29 17:15:01 +080042
43#define HIWORD_UPDATE(val, mask) (val | (mask) << 16)
44
Yakir Yang8f0ac5c2016-07-24 14:57:52 +080045#define PSR_WAIT_LINE_FLAG_TIMEOUT_MS 100
46
Yakir Yang9e32e162016-03-29 09:57:30 +080047#define to_dp(nm) container_of(nm, struct rockchip_dp_device, nm)
48
Yakir Yangd9c900b2016-06-29 17:15:01 +080049/**
50 * struct rockchip_dp_chip_data - splite the grf setting of kind of chips
51 * @lcdsel_grf_reg: grf register offset of lcdc select
52 * @lcdsel_big: reg value of selecting vop big for eDP
53 * @lcdsel_lit: reg value of selecting vop little for eDP
54 * @chip_type: specific chip type
55 */
56struct rockchip_dp_chip_data {
57 u32 lcdsel_grf_reg;
58 u32 lcdsel_big;
59 u32 lcdsel_lit;
60 u32 chip_type;
61};
Yakir Yang9e32e162016-03-29 09:57:30 +080062
63struct rockchip_dp_device {
64 struct drm_device *drm_dev;
65 struct device *dev;
66 struct drm_encoder encoder;
67 struct drm_display_mode mode;
68
69 struct clk *pclk;
Yakir Yangdc1c93b2016-06-29 17:16:05 +080070 struct clk *grfclk;
Yakir Yang9e32e162016-03-29 09:57:30 +080071 struct regmap *grf;
72 struct reset_control *rst;
73
Yakir Yangd9c900b2016-06-29 17:15:01 +080074 const struct rockchip_dp_chip_data *data;
75
Jeffy Chen6b2d8fd2018-01-10 17:23:41 +010076 struct analogix_dp_device *adp;
Yakir Yang9e32e162016-03-29 09:57:30 +080077 struct analogix_dp_plat_data plat_data;
78};
79
zain wang2a7b44c2018-04-23 12:49:49 +020080static int analogix_dp_psr_set(struct drm_encoder *encoder, bool enabled)
Yakir Yang8f0ac5c2016-07-24 14:57:52 +080081{
82 struct rockchip_dp_device *dp = to_dp(encoder);
Sean Paulbaa2f022018-03-09 23:22:53 +010083 int ret;
Yakir Yang8f0ac5c2016-07-24 14:57:52 +080084
zain wang243e3982018-03-09 23:22:54 +010085 if (!analogix_dp_psr_enabled(dp->adp))
zain wang2a7b44c2018-04-23 12:49:49 +020086 return 0;
Tomeu Vizoso0546d682016-09-23 16:06:40 +020087
Haneen Mohammedd8dd6802017-09-15 02:36:03 -060088 DRM_DEV_DEBUG(dp->dev, "%s PSR...\n", enabled ? "Entry" : "Exit");
Yakir Yang8f0ac5c2016-07-24 14:57:52 +080089
Jeffy Chen459b0862017-04-27 14:54:17 +080090 ret = rockchip_drm_wait_vact_end(dp->encoder.crtc,
91 PSR_WAIT_LINE_FLAG_TIMEOUT_MS);
Yakir Yang8f0ac5c2016-07-24 14:57:52 +080092 if (ret) {
Haneen Mohammedd8dd6802017-09-15 02:36:03 -060093 DRM_DEV_ERROR(dp->dev, "line flag interrupt did not arrive\n");
zain wang2a7b44c2018-04-23 12:49:49 +020094 return -ETIMEDOUT;
Yakir Yang8f0ac5c2016-07-24 14:57:52 +080095 }
96
Sean Paulbaa2f022018-03-09 23:22:53 +010097 if (enabled)
zain wang2a7b44c2018-04-23 12:49:49 +020098 return analogix_dp_enable_psr(dp->adp);
Yakir Yang8f0ac5c2016-07-24 14:57:52 +080099 else
zain wang2a7b44c2018-04-23 12:49:49 +0200100 return analogix_dp_disable_psr(dp->adp);
Yakir Yang8f0ac5c2016-07-24 14:57:52 +0800101}
102
Yakir Yang9e32e162016-03-29 09:57:30 +0800103static int rockchip_dp_pre_init(struct rockchip_dp_device *dp)
104{
105 reset_control_assert(dp->rst);
106 usleep_range(10, 20);
107 reset_control_deassert(dp->rst);
108
109 return 0;
110}
111
Douglas Anderson7bb3bb42018-04-23 12:49:58 +0200112static int rockchip_dp_poweron_start(struct analogix_dp_plat_data *plat_data)
Yakir Yang9e32e162016-03-29 09:57:30 +0800113{
114 struct rockchip_dp_device *dp = to_dp(plat_data);
115 int ret;
116
117 ret = clk_prepare_enable(dp->pclk);
118 if (ret < 0) {
Haneen Mohammedd8dd6802017-09-15 02:36:03 -0600119 DRM_DEV_ERROR(dp->dev, "failed to enable pclk %d\n", ret);
Yakir Yang9e32e162016-03-29 09:57:30 +0800120 return ret;
121 }
122
123 ret = rockchip_dp_pre_init(dp);
124 if (ret < 0) {
Haneen Mohammedd8dd6802017-09-15 02:36:03 -0600125 DRM_DEV_ERROR(dp->dev, "failed to dp pre init %d\n", ret);
Wei Yongjun3694c5c2016-07-19 11:32:43 +0000126 clk_disable_unprepare(dp->pclk);
Yakir Yang9e32e162016-03-29 09:57:30 +0800127 return ret;
128 }
129
Douglas Anderson7bb3bb42018-04-23 12:49:58 +0200130 return ret;
131}
132
133static int rockchip_dp_poweron_end(struct analogix_dp_plat_data *plat_data)
134{
135 struct rockchip_dp_device *dp = to_dp(plat_data);
136
Tomasz Figa6e6cf3e2018-04-23 12:50:01 +0200137 return rockchip_drm_psr_inhibit_put(&dp->encoder);
Yakir Yang9e32e162016-03-29 09:57:30 +0800138}
139
140static int rockchip_dp_powerdown(struct analogix_dp_plat_data *plat_data)
141{
142 struct rockchip_dp_device *dp = to_dp(plat_data);
zain wang7f3c1912018-03-05 23:22:53 +0100143 int ret;
144
Tomasz Figa6e6cf3e2018-04-23 12:50:01 +0200145 ret = rockchip_drm_psr_inhibit_get(&dp->encoder);
zain wang7f3c1912018-03-05 23:22:53 +0100146 if (ret != 0)
147 return ret;
Yakir Yang9e32e162016-03-29 09:57:30 +0800148
149 clk_disable_unprepare(dp->pclk);
150
151 return 0;
152}
153
Yakir Yangdb8a9ae2016-06-29 17:15:39 +0800154static int rockchip_dp_get_modes(struct analogix_dp_plat_data *plat_data,
155 struct drm_connector *connector)
156{
157 struct drm_display_info *di = &connector->display_info;
158 /* VOP couldn't output YUV video format for eDP rightly */
159 u32 mask = DRM_COLOR_FORMAT_YCRCB444 | DRM_COLOR_FORMAT_YCRCB422;
160
161 if ((di->color_formats & mask)) {
162 DRM_DEBUG_KMS("Swapping display color format from YUV to RGB\n");
163 di->color_formats &= ~mask;
164 di->color_formats |= DRM_COLOR_FORMAT_RGB444;
165 di->bpc = 8;
166 }
167
168 return 0;
169}
170
Yakir Yang9e32e162016-03-29 09:57:30 +0800171static bool
172rockchip_dp_drm_encoder_mode_fixup(struct drm_encoder *encoder,
173 const struct drm_display_mode *mode,
174 struct drm_display_mode *adjusted_mode)
175{
176 /* do nothing */
177 return true;
178}
179
180static void rockchip_dp_drm_encoder_mode_set(struct drm_encoder *encoder,
181 struct drm_display_mode *mode,
182 struct drm_display_mode *adjusted)
183{
184 /* do nothing */
185}
186
187static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder)
188{
189 struct rockchip_dp_device *dp = to_dp(encoder);
190 int ret;
191 u32 val;
192
Yakir Yang9e32e162016-03-29 09:57:30 +0800193 ret = drm_of_encoder_active_endpoint_id(dp->dev->of_node, encoder);
194 if (ret < 0)
195 return;
196
197 if (ret)
Yakir Yangd9c900b2016-06-29 17:15:01 +0800198 val = dp->data->lcdsel_lit;
Yakir Yang9e32e162016-03-29 09:57:30 +0800199 else
Yakir Yangd9c900b2016-06-29 17:15:01 +0800200 val = dp->data->lcdsel_big;
Yakir Yang9e32e162016-03-29 09:57:30 +0800201
Haneen Mohammedd8dd6802017-09-15 02:36:03 -0600202 DRM_DEV_DEBUG(dp->dev, "vop %s output to dp\n", (ret) ? "LIT" : "BIG");
Yakir Yang9e32e162016-03-29 09:57:30 +0800203
Yakir Yangdc1c93b2016-06-29 17:16:05 +0800204 ret = clk_prepare_enable(dp->grfclk);
205 if (ret < 0) {
Haneen Mohammedd8dd6802017-09-15 02:36:03 -0600206 DRM_DEV_ERROR(dp->dev, "failed to enable grfclk %d\n", ret);
Yakir Yang9e32e162016-03-29 09:57:30 +0800207 return;
208 }
Yakir Yangdc1c93b2016-06-29 17:16:05 +0800209
210 ret = regmap_write(dp->grf, dp->data->lcdsel_grf_reg, val);
211 if (ret != 0)
Haneen Mohammedd8dd6802017-09-15 02:36:03 -0600212 DRM_DEV_ERROR(dp->dev, "Could not write to GRF: %d\n", ret);
Yakir Yangdc1c93b2016-06-29 17:16:05 +0800213
214 clk_disable_unprepare(dp->grfclk);
Yakir Yang9e32e162016-03-29 09:57:30 +0800215}
216
217static void rockchip_dp_drm_encoder_nop(struct drm_encoder *encoder)
218{
219 /* do nothing */
220}
221
Mark Yao4e257d92016-04-20 10:41:42 +0800222static int
223rockchip_dp_drm_encoder_atomic_check(struct drm_encoder *encoder,
224 struct drm_crtc_state *crtc_state,
225 struct drm_connector_state *conn_state)
226{
227 struct rockchip_crtc_state *s = to_rockchip_crtc_state(crtc_state);
Mark Yao6bda8112018-04-23 12:49:57 +0200228 struct drm_display_info *di = &conn_state->connector->display_info;
Mark Yao4e257d92016-04-20 10:41:42 +0800229
230 /*
Yakir Yangd698f0e2016-06-29 17:15:44 +0800231 * The hardware IC designed that VOP must output the RGB10 video
232 * format to eDP controller, and if eDP panel only support RGB8,
233 * then eDP controller should cut down the video data, not via VOP
234 * controller, that's why we need to hardcode the VOP output mode
235 * to RGA10 here.
Mark Yao4e257d92016-04-20 10:41:42 +0800236 */
Yakir Yang82872e42016-06-29 17:15:26 +0800237
Mark Yao4e257d92016-04-20 10:41:42 +0800238 s->output_mode = ROCKCHIP_OUT_MODE_AAAA;
239 s->output_type = DRM_MODE_CONNECTOR_eDP;
Mark Yao6bda8112018-04-23 12:49:57 +0200240 s->output_bpc = di->bpc;
Mark Yao4e257d92016-04-20 10:41:42 +0800241
242 return 0;
243}
244
Yakir Yang9e32e162016-03-29 09:57:30 +0800245static struct drm_encoder_helper_funcs rockchip_dp_encoder_helper_funcs = {
246 .mode_fixup = rockchip_dp_drm_encoder_mode_fixup,
247 .mode_set = rockchip_dp_drm_encoder_mode_set,
248 .enable = rockchip_dp_drm_encoder_enable,
249 .disable = rockchip_dp_drm_encoder_nop,
Mark Yao4e257d92016-04-20 10:41:42 +0800250 .atomic_check = rockchip_dp_drm_encoder_atomic_check,
Yakir Yang9e32e162016-03-29 09:57:30 +0800251};
252
Yakir Yang9e32e162016-03-29 09:57:30 +0800253static struct drm_encoder_funcs rockchip_dp_encoder_funcs = {
Jeffy Chen7fe201c2018-01-10 17:23:42 +0100254 .destroy = drm_encoder_cleanup,
Yakir Yang9e32e162016-03-29 09:57:30 +0800255};
256
Jeffy Chen102712a2017-10-19 11:48:04 +0800257static int rockchip_dp_of_probe(struct rockchip_dp_device *dp)
Yakir Yang9e32e162016-03-29 09:57:30 +0800258{
259 struct device *dev = dp->dev;
260 struct device_node *np = dev->of_node;
Yakir Yang9e32e162016-03-29 09:57:30 +0800261
262 dp->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf");
263 if (IS_ERR(dp->grf)) {
Haneen Mohammedd8dd6802017-09-15 02:36:03 -0600264 DRM_DEV_ERROR(dev, "failed to get rockchip,grf property\n");
Yakir Yang9e32e162016-03-29 09:57:30 +0800265 return PTR_ERR(dp->grf);
266 }
267
Yakir Yangdc1c93b2016-06-29 17:16:05 +0800268 dp->grfclk = devm_clk_get(dev, "grf");
269 if (PTR_ERR(dp->grfclk) == -ENOENT) {
270 dp->grfclk = NULL;
271 } else if (PTR_ERR(dp->grfclk) == -EPROBE_DEFER) {
272 return -EPROBE_DEFER;
273 } else if (IS_ERR(dp->grfclk)) {
Haneen Mohammedd8dd6802017-09-15 02:36:03 -0600274 DRM_DEV_ERROR(dev, "failed to get grf clock\n");
Yakir Yangdc1c93b2016-06-29 17:16:05 +0800275 return PTR_ERR(dp->grfclk);
276 }
277
Yakir Yang9e32e162016-03-29 09:57:30 +0800278 dp->pclk = devm_clk_get(dev, "pclk");
279 if (IS_ERR(dp->pclk)) {
Haneen Mohammedd8dd6802017-09-15 02:36:03 -0600280 DRM_DEV_ERROR(dev, "failed to get pclk property\n");
Yakir Yang9e32e162016-03-29 09:57:30 +0800281 return PTR_ERR(dp->pclk);
282 }
283
284 dp->rst = devm_reset_control_get(dev, "dp");
285 if (IS_ERR(dp->rst)) {
Haneen Mohammedd8dd6802017-09-15 02:36:03 -0600286 DRM_DEV_ERROR(dev, "failed to get dp reset control\n");
Yakir Yang9e32e162016-03-29 09:57:30 +0800287 return PTR_ERR(dp->rst);
288 }
289
Yakir Yang9e32e162016-03-29 09:57:30 +0800290 return 0;
291}
292
293static int rockchip_dp_drm_create_encoder(struct rockchip_dp_device *dp)
294{
295 struct drm_encoder *encoder = &dp->encoder;
296 struct drm_device *drm_dev = dp->drm_dev;
297 struct device *dev = dp->dev;
298 int ret;
299
300 encoder->possible_crtcs = drm_of_find_possible_crtcs(drm_dev,
301 dev->of_node);
302 DRM_DEBUG_KMS("possible_crtcs = 0x%x\n", encoder->possible_crtcs);
303
304 ret = drm_encoder_init(drm_dev, encoder, &rockchip_dp_encoder_funcs,
305 DRM_MODE_ENCODER_TMDS, NULL);
306 if (ret) {
307 DRM_ERROR("failed to initialize encoder with drm\n");
308 return ret;
309 }
310
311 drm_encoder_helper_add(encoder, &rockchip_dp_encoder_helper_funcs);
312
313 return 0;
314}
315
316static int rockchip_dp_bind(struct device *dev, struct device *master,
317 void *data)
318{
319 struct rockchip_dp_device *dp = dev_get_drvdata(dev);
Yakir Yangd9c900b2016-06-29 17:15:01 +0800320 const struct rockchip_dp_chip_data *dp_data;
Yakir Yang9e32e162016-03-29 09:57:30 +0800321 struct drm_device *drm_dev = data;
322 int ret;
323
Yakir Yangd9c900b2016-06-29 17:15:01 +0800324 dp_data = of_device_get_match_data(dev);
325 if (!dp_data)
326 return -ENODEV;
327
Yakir Yangd9c900b2016-06-29 17:15:01 +0800328 dp->data = dp_data;
Yakir Yang9e32e162016-03-29 09:57:30 +0800329 dp->drm_dev = drm_dev;
330
331 ret = rockchip_dp_drm_create_encoder(dp);
332 if (ret) {
333 DRM_ERROR("failed to create drm encoder\n");
334 return ret;
335 }
336
337 dp->plat_data.encoder = &dp->encoder;
338
Yakir Yangd9c900b2016-06-29 17:15:01 +0800339 dp->plat_data.dev_type = dp->data->chip_type;
Douglas Anderson7bb3bb42018-04-23 12:49:58 +0200340 dp->plat_data.power_on_start = rockchip_dp_poweron_start;
341 dp->plat_data.power_on_end = rockchip_dp_poweron_end;
Yakir Yang9e32e162016-03-29 09:57:30 +0800342 dp->plat_data.power_off = rockchip_dp_powerdown;
Yakir Yangdb8a9ae2016-06-29 17:15:39 +0800343 dp->plat_data.get_modes = rockchip_dp_get_modes;
Yakir Yang9e32e162016-03-29 09:57:30 +0800344
Jeffy Chenc8c04512018-01-10 17:23:43 +0100345 ret = rockchip_drm_psr_register(&dp->encoder, analogix_dp_psr_set);
346 if (ret < 0)
347 goto err_cleanup_encoder;
Yakir Yang8f0ac5c2016-07-24 14:57:52 +0800348
Jeffy Chen6b2d8fd2018-01-10 17:23:41 +0100349 dp->adp = analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data);
Jeffy Chen7fe201c2018-01-10 17:23:42 +0100350 if (IS_ERR(dp->adp)) {
Jeffy Chenc8c04512018-01-10 17:23:43 +0100351 ret = PTR_ERR(dp->adp);
352 goto err_unreg_psr;
Jeffy Chen7fe201c2018-01-10 17:23:42 +0100353 }
Jeffy Chen6b2d8fd2018-01-10 17:23:41 +0100354
355 return 0;
Jeffy Chenc8c04512018-01-10 17:23:43 +0100356err_unreg_psr:
357 rockchip_drm_psr_unregister(&dp->encoder);
358err_cleanup_encoder:
359 dp->encoder.funcs->destroy(&dp->encoder);
360 return ret;
Yakir Yang9e32e162016-03-29 09:57:30 +0800361}
362
363static void rockchip_dp_unbind(struct device *dev, struct device *master,
364 void *data)
365{
Yakir Yang8f0ac5c2016-07-24 14:57:52 +0800366 struct rockchip_dp_device *dp = dev_get_drvdata(dev);
367
Jeffy Chen6b2d8fd2018-01-10 17:23:41 +0100368 analogix_dp_unbind(dp->adp);
Jeffy Chend8e7e732018-03-01 16:25:58 +0100369 rockchip_drm_psr_unregister(&dp->encoder);
Jeffy Chen7fe201c2018-01-10 17:23:42 +0100370 dp->encoder.funcs->destroy(&dp->encoder);
Tomasz Figaa4169602018-04-23 12:49:59 +0200371
372 dp->adp = ERR_PTR(-ENODEV);
Yakir Yang9e32e162016-03-29 09:57:30 +0800373}
374
375static const struct component_ops rockchip_dp_component_ops = {
376 .bind = rockchip_dp_bind,
377 .unbind = rockchip_dp_unbind,
378};
379
380static int rockchip_dp_probe(struct platform_device *pdev)
381{
382 struct device *dev = &pdev->dev;
Yakir Yangeb87c912016-06-29 17:15:30 +0800383 struct drm_panel *panel = NULL;
Yakir Yang9e32e162016-03-29 09:57:30 +0800384 struct rockchip_dp_device *dp;
Rob Herringebc94462017-03-29 13:55:46 -0500385 int ret;
Yakir Yang9e32e162016-03-29 09:57:30 +0800386
Rob Herringebc94462017-03-29 13:55:46 -0500387 ret = drm_of_find_panel_or_bridge(dev->of_node, 1, 0, &panel, NULL);
Jeffy Chen102712a2017-10-19 11:48:04 +0800388 if (ret < 0)
Rob Herringebc94462017-03-29 13:55:46 -0500389 return ret;
Yakir Yang9e32e162016-03-29 09:57:30 +0800390
Yakir Yang9e32e162016-03-29 09:57:30 +0800391 dp = devm_kzalloc(dev, sizeof(*dp), GFP_KERNEL);
392 if (!dp)
393 return -ENOMEM;
394
395 dp->dev = dev;
Tomasz Figaa4169602018-04-23 12:49:59 +0200396 dp->adp = ERR_PTR(-ENODEV);
Yakir Yang9e32e162016-03-29 09:57:30 +0800397 dp->plat_data.panel = panel;
398
Jeffy Chen102712a2017-10-19 11:48:04 +0800399 ret = rockchip_dp_of_probe(dp);
400 if (ret < 0)
401 return ret;
402
Yakir Yang9e32e162016-03-29 09:57:30 +0800403 platform_set_drvdata(pdev, dp);
404
405 return component_add(dev, &rockchip_dp_component_ops);
406}
407
408static int rockchip_dp_remove(struct platform_device *pdev)
409{
410 component_del(&pdev->dev, &rockchip_dp_component_ops);
411
412 return 0;
413}
414
Jeffy Chen6b2d8fd2018-01-10 17:23:41 +0100415#ifdef CONFIG_PM_SLEEP
416static int rockchip_dp_suspend(struct device *dev)
417{
418 struct rockchip_dp_device *dp = dev_get_drvdata(dev);
419
Tomasz Figaa4169602018-04-23 12:49:59 +0200420 if (IS_ERR(dp->adp))
421 return 0;
422
Jeffy Chen6b2d8fd2018-01-10 17:23:41 +0100423 return analogix_dp_suspend(dp->adp);
424}
425
426static int rockchip_dp_resume(struct device *dev)
427{
428 struct rockchip_dp_device *dp = dev_get_drvdata(dev);
429
Tomasz Figaa4169602018-04-23 12:49:59 +0200430 if (IS_ERR(dp->adp))
431 return 0;
432
Jeffy Chen6b2d8fd2018-01-10 17:23:41 +0100433 return analogix_dp_resume(dp->adp);
434}
435#endif
436
Yakir Yang9e32e162016-03-29 09:57:30 +0800437static const struct dev_pm_ops rockchip_dp_pm_ops = {
Tomeu Vizosofe64ba52016-06-06 16:53:33 +0200438#ifdef CONFIG_PM_SLEEP
Jeffy Chen6b2d8fd2018-01-10 17:23:41 +0100439 .suspend = rockchip_dp_suspend,
440 .resume_early = rockchip_dp_resume,
Tomeu Vizosofe64ba52016-06-06 16:53:33 +0200441#endif
Yakir Yang9e32e162016-03-29 09:57:30 +0800442};
443
Yakir Yang82872e42016-06-29 17:15:26 +0800444static const struct rockchip_dp_chip_data rk3399_edp = {
445 .lcdsel_grf_reg = RK3399_GRF_SOC_CON20,
446 .lcdsel_big = HIWORD_UPDATE(0, RK3399_EDP_LCDC_SEL),
447 .lcdsel_lit = HIWORD_UPDATE(RK3399_EDP_LCDC_SEL, RK3399_EDP_LCDC_SEL),
448 .chip_type = RK3399_EDP,
449};
450
Yakir Yangd9c900b2016-06-29 17:15:01 +0800451static const struct rockchip_dp_chip_data rk3288_dp = {
452 .lcdsel_grf_reg = RK3288_GRF_SOC_CON6,
453 .lcdsel_big = HIWORD_UPDATE(0, RK3288_EDP_LCDC_SEL),
454 .lcdsel_lit = HIWORD_UPDATE(RK3288_EDP_LCDC_SEL, RK3288_EDP_LCDC_SEL),
455 .chip_type = RK3288_DP,
456};
457
Yakir Yang9e32e162016-03-29 09:57:30 +0800458static const struct of_device_id rockchip_dp_dt_ids[] = {
Yakir Yangd9c900b2016-06-29 17:15:01 +0800459 {.compatible = "rockchip,rk3288-dp", .data = &rk3288_dp },
Yakir Yang82872e42016-06-29 17:15:26 +0800460 {.compatible = "rockchip,rk3399-edp", .data = &rk3399_edp },
Yakir Yang9e32e162016-03-29 09:57:30 +0800461 {}
462};
463MODULE_DEVICE_TABLE(of, rockchip_dp_dt_ids);
464
Jeffy Chen8820b682017-03-22 11:21:20 +0800465struct platform_driver rockchip_dp_driver = {
Yakir Yang9e32e162016-03-29 09:57:30 +0800466 .probe = rockchip_dp_probe,
467 .remove = rockchip_dp_remove,
468 .driver = {
469 .name = "rockchip-dp",
Yakir Yang9e32e162016-03-29 09:57:30 +0800470 .pm = &rockchip_dp_pm_ops,
471 .of_match_table = of_match_ptr(rockchip_dp_dt_ids),
472 },
473};