aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2014-11-25 18:19:36 -0500
committerDave Airlie <airlied@redhat.com>2014-11-25 18:19:36 -0500
commit0364d4fef4d19bdddca9a649ea83bc4bf458324f (patch)
tree1208529cb501a04899ecc66b4e22624fb29e7ba5
parent955289c7cfad158dc939e150896a240f549ccc60 (diff)
parent5baf5d44fbcde002d7f3f8148e69305f520770dd (diff)
Merge branch 'exynos-drm-next' of git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos into drm-next
Add Exynos4415 SoC support, some fixups and cleanups. Summary: - Resolve kernel lockup issue incurred by probe request in probe context. . For this, it moves all register codes of sub drivers into init function and adds component binding support for vidi driver. - Add Exynos4415 SoC support. - Make each manager and display object to be embedded in each driver context. - Fix and clean up FIMD and MIPI-DSI drivers. - Clean up unnecesary or wrong descriptions. - And trivial cleanups. * 'exynos-drm-next' of git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos: (58 commits) drm/exynos: avoid leak if exynos_dpi_probe() fails drm/exynos: Fix exynos_dpi_remove() parameter drm/exynos: vidi: add component support drm/exynos: fix exynos_drm_component_del drm/exynos/ipp: fix error return code drm/exynos: clean up machine compatible string check drm/exynos: move Exynos platform drivers registration to init Revert "drm/exynos: fix null pointer dereference issue" drm/exynos/dpi: stop using display->ctx pointer drm/exynos/dpi: embed display into private context drm/exynos/dp: stop using display->ctx pointer drm/exynos/dp: embed display into private context drm/exynos/vidi: stop using display->ctx pointer drm/exynos/vidi: embed display into private context drm/exynos/hdmi: stop using display->ctx pointer drm/exynos/hdmi: embed display into private context drm/exynos/fimd: stop using manager->ctx pointer drm/exynos/fimd: embed manager into private context drm/exynos/vidi: stop using manager->ctx pointer drm/exynos/vidi: embed manager into private context ...
-rw-r--r--Documentation/devicetree/bindings/video/exynos_dsim.txt1
-rw-r--r--Documentation/devicetree/bindings/video/samsung-fimd.txt1
-rw-r--r--drivers/gpu/drm/exynos/exynos_dp_core.c132
-rw-r--r--drivers/gpu/drm/exynos/exynos_dp_core.h5
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_crtc.h5
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_dpi.c42
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.c257
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.h83
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_dsi.c127
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_encoder.h2
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fimd.c266
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_g2d.c9
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_iommu.h1
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_ipp.c3
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_vidi.c150
-rw-r--r--drivers/gpu/drm/exynos/exynos_hdmi.c65
-rw-r--r--drivers/gpu/drm/exynos/exynos_mixer.c126
17 files changed, 609 insertions, 666 deletions
diff --git a/Documentation/devicetree/bindings/video/exynos_dsim.txt b/Documentation/devicetree/bindings/video/exynos_dsim.txt
index e74243b4b317..ca2b4aacd9af 100644
--- a/Documentation/devicetree/bindings/video/exynos_dsim.txt
+++ b/Documentation/devicetree/bindings/video/exynos_dsim.txt
@@ -4,6 +4,7 @@ Required properties:
4 - compatible: value should be one of the following 4 - compatible: value should be one of the following
5 "samsung,exynos3250-mipi-dsi" /* for Exynos3250/3472 SoCs */ 5 "samsung,exynos3250-mipi-dsi" /* for Exynos3250/3472 SoCs */
6 "samsung,exynos4210-mipi-dsi" /* for Exynos4 SoCs */ 6 "samsung,exynos4210-mipi-dsi" /* for Exynos4 SoCs */
7 "samsung,exynos4415-mipi-dsi" /* for Exynos4415 SoC */
7 "samsung,exynos5410-mipi-dsi" /* for Exynos5410/5420/5440 SoCs */ 8 "samsung,exynos5410-mipi-dsi" /* for Exynos5410/5420/5440 SoCs */
8 - reg: physical base address and length of the registers set for the device 9 - reg: physical base address and length of the registers set for the device
9 - interrupts: should contain DSI interrupt 10 - interrupts: should contain DSI interrupt
diff --git a/Documentation/devicetree/bindings/video/samsung-fimd.txt b/Documentation/devicetree/bindings/video/samsung-fimd.txt
index 4e6c77c85546..cf1af6371021 100644
--- a/Documentation/devicetree/bindings/video/samsung-fimd.txt
+++ b/Documentation/devicetree/bindings/video/samsung-fimd.txt
@@ -11,6 +11,7 @@ Required properties:
11 "samsung,s5pv210-fimd"; /* for S5PV210 SoC */ 11 "samsung,s5pv210-fimd"; /* for S5PV210 SoC */
12 "samsung,exynos3250-fimd"; /* for Exynos3250/3472 SoCs */ 12 "samsung,exynos3250-fimd"; /* for Exynos3250/3472 SoCs */
13 "samsung,exynos4210-fimd"; /* for Exynos4 SoCs */ 13 "samsung,exynos4210-fimd"; /* for Exynos4 SoCs */
14 "samsung,exynos4415-fimd"; /* for Exynos4415 SoC */
14 "samsung,exynos5250-fimd"; /* for Exynos5 SoCs */ 15 "samsung,exynos5250-fimd"; /* for Exynos5 SoCs */
15 16
16- reg: physical base address and length of the FIMD registers set. 17- reg: physical base address and length of the FIMD registers set.
diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.c b/drivers/gpu/drm/exynos/exynos_dp_core.c
index 6adb1e5cfb08..34d46aa75416 100644
--- a/drivers/gpu/drm/exynos/exynos_dp_core.c
+++ b/drivers/gpu/drm/exynos/exynos_dp_core.c
@@ -30,12 +30,17 @@
30#include <drm/drm_panel.h> 30#include <drm/drm_panel.h>
31#include <drm/bridge/ptn3460.h> 31#include <drm/bridge/ptn3460.h>
32 32
33#include "exynos_drm_drv.h"
34#include "exynos_dp_core.h" 33#include "exynos_dp_core.h"
35 34
36#define ctx_from_connector(c) container_of(c, struct exynos_dp_device, \ 35#define ctx_from_connector(c) container_of(c, struct exynos_dp_device, \
37 connector) 36 connector)
38 37
38static inline struct exynos_dp_device *
39display_to_dp(struct exynos_drm_display *d)
40{
41 return container_of(d, struct exynos_dp_device, display);
42}
43
39struct bridge_init { 44struct bridge_init {
40 struct i2c_client *client; 45 struct i2c_client *client;
41 struct device_node *node; 46 struct device_node *node;
@@ -882,7 +887,7 @@ static void exynos_dp_hotplug(struct work_struct *work)
882 887
883static void exynos_dp_commit(struct exynos_drm_display *display) 888static void exynos_dp_commit(struct exynos_drm_display *display)
884{ 889{
885 struct exynos_dp_device *dp = display->ctx; 890 struct exynos_dp_device *dp = display_to_dp(display);
886 int ret; 891 int ret;
887 892
888 /* Keep the panel disabled while we configure video */ 893 /* Keep the panel disabled while we configure video */
@@ -1020,7 +1025,7 @@ static int exynos_drm_attach_lcd_bridge(struct drm_device *dev,
1020static int exynos_dp_create_connector(struct exynos_drm_display *display, 1025static int exynos_dp_create_connector(struct exynos_drm_display *display,
1021 struct drm_encoder *encoder) 1026 struct drm_encoder *encoder)
1022{ 1027{
1023 struct exynos_dp_device *dp = display->ctx; 1028 struct exynos_dp_device *dp = display_to_dp(display);
1024 struct drm_connector *connector = &dp->connector; 1029 struct drm_connector *connector = &dp->connector;
1025 int ret; 1030 int ret;
1026 1031
@@ -1052,33 +1057,19 @@ static int exynos_dp_create_connector(struct exynos_drm_display *display,
1052 1057
1053static void exynos_dp_phy_init(struct exynos_dp_device *dp) 1058static void exynos_dp_phy_init(struct exynos_dp_device *dp)
1054{ 1059{
1055 if (dp->phy) { 1060 if (dp->phy)
1056 phy_power_on(dp->phy); 1061 phy_power_on(dp->phy);
1057 } else if (dp->phy_addr) {
1058 u32 reg;
1059
1060 reg = __raw_readl(dp->phy_addr);
1061 reg |= dp->enable_mask;
1062 __raw_writel(reg, dp->phy_addr);
1063 }
1064} 1062}
1065 1063
1066static void exynos_dp_phy_exit(struct exynos_dp_device *dp) 1064static void exynos_dp_phy_exit(struct exynos_dp_device *dp)
1067{ 1065{
1068 if (dp->phy) { 1066 if (dp->phy)
1069 phy_power_off(dp->phy); 1067 phy_power_off(dp->phy);
1070 } else if (dp->phy_addr) {
1071 u32 reg;
1072
1073 reg = __raw_readl(dp->phy_addr);
1074 reg &= ~(dp->enable_mask);
1075 __raw_writel(reg, dp->phy_addr);
1076 }
1077} 1068}
1078 1069
1079static void exynos_dp_poweron(struct exynos_drm_display *display) 1070static void exynos_dp_poweron(struct exynos_drm_display *display)
1080{ 1071{
1081 struct exynos_dp_device *dp = display->ctx; 1072 struct exynos_dp_device *dp = display_to_dp(display);
1082 1073
1083 if (dp->dpms_mode == DRM_MODE_DPMS_ON) 1074 if (dp->dpms_mode == DRM_MODE_DPMS_ON)
1084 return; 1075 return;
@@ -1099,7 +1090,7 @@ static void exynos_dp_poweron(struct exynos_drm_display *display)
1099 1090
1100static void exynos_dp_poweroff(struct exynos_drm_display *display) 1091static void exynos_dp_poweroff(struct exynos_drm_display *display)
1101{ 1092{
1102 struct exynos_dp_device *dp = display->ctx; 1093 struct exynos_dp_device *dp = display_to_dp(display);
1103 1094
1104 if (dp->dpms_mode != DRM_MODE_DPMS_ON) 1095 if (dp->dpms_mode != DRM_MODE_DPMS_ON)
1105 return; 1096 return;
@@ -1124,7 +1115,7 @@ static void exynos_dp_poweroff(struct exynos_drm_display *display)
1124 1115
1125static void exynos_dp_dpms(struct exynos_drm_display *display, int mode) 1116static void exynos_dp_dpms(struct exynos_drm_display *display, int mode)
1126{ 1117{
1127 struct exynos_dp_device *dp = display->ctx; 1118 struct exynos_dp_device *dp = display_to_dp(display);
1128 1119
1129 switch (mode) { 1120 switch (mode) {
1130 case DRM_MODE_DPMS_ON: 1121 case DRM_MODE_DPMS_ON:
@@ -1147,11 +1138,6 @@ static struct exynos_drm_display_ops exynos_dp_display_ops = {
1147 .commit = exynos_dp_commit, 1138 .commit = exynos_dp_commit,
1148}; 1139};
1149 1140
1150static struct exynos_drm_display exynos_dp_display = {
1151 .type = EXYNOS_DISPLAY_TYPE_LCD,
1152 .ops = &exynos_dp_display_ops,
1153};
1154
1155static struct video_info *exynos_dp_dt_parse_pdata(struct device *dev) 1141static struct video_info *exynos_dp_dt_parse_pdata(struct device *dev)
1156{ 1142{
1157 struct device_node *dp_node = dev->of_node; 1143 struct device_node *dp_node = dev->of_node;
@@ -1210,44 +1196,6 @@ static struct video_info *exynos_dp_dt_parse_pdata(struct device *dev)
1210 return dp_video_config; 1196 return dp_video_config;
1211} 1197}
1212 1198
1213static int exynos_dp_dt_parse_phydata(struct exynos_dp_device *dp)
1214{
1215 struct device_node *dp_phy_node = of_node_get(dp->dev->of_node);
1216 u32 phy_base;
1217 int ret = 0;
1218
1219 dp_phy_node = of_find_node_by_name(dp_phy_node, "dptx-phy");
1220 if (!dp_phy_node) {
1221 dp->phy = devm_phy_get(dp->dev, "dp");
1222 return PTR_ERR_OR_ZERO(dp->phy);
1223 }
1224
1225 if (of_property_read_u32(dp_phy_node, "reg", &phy_base)) {
1226 dev_err(dp->dev, "failed to get reg for dptx-phy\n");
1227 ret = -EINVAL;
1228 goto err;
1229 }
1230
1231 if (of_property_read_u32(dp_phy_node, "samsung,enable-mask",
1232 &dp->enable_mask)) {
1233 dev_err(dp->dev, "failed to get enable-mask for dptx-phy\n");
1234 ret = -EINVAL;
1235 goto err;
1236 }
1237
1238 dp->phy_addr = ioremap(phy_base, SZ_4);
1239 if (!dp->phy_addr) {
1240 dev_err(dp->dev, "failed to ioremap dp-phy\n");
1241 ret = -ENOMEM;
1242 goto err;
1243 }
1244
1245err:
1246 of_node_put(dp_phy_node);
1247
1248 return ret;
1249}
1250
1251static int exynos_dp_dt_parse_panel(struct exynos_dp_device *dp) 1199static int exynos_dp_dt_parse_panel(struct exynos_dp_device *dp)
1252{ 1200{
1253 int ret; 1201 int ret;
@@ -1263,10 +1211,10 @@ static int exynos_dp_dt_parse_panel(struct exynos_dp_device *dp)
1263 1211
1264static int exynos_dp_bind(struct device *dev, struct device *master, void *data) 1212static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
1265{ 1213{
1214 struct exynos_dp_device *dp = dev_get_drvdata(dev);
1266 struct platform_device *pdev = to_platform_device(dev); 1215 struct platform_device *pdev = to_platform_device(dev);
1267 struct drm_device *drm_dev = data; 1216 struct drm_device *drm_dev = data;
1268 struct resource *res; 1217 struct resource *res;
1269 struct exynos_dp_device *dp = exynos_dp_display.ctx;
1270 unsigned int irq_flags; 1218 unsigned int irq_flags;
1271 int ret = 0; 1219 int ret = 0;
1272 1220
@@ -1277,9 +1225,21 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
1277 if (IS_ERR(dp->video_info)) 1225 if (IS_ERR(dp->video_info))
1278 return PTR_ERR(dp->video_info); 1226 return PTR_ERR(dp->video_info);
1279 1227
1280 ret = exynos_dp_dt_parse_phydata(dp); 1228 dp->phy = devm_phy_get(dp->dev, "dp");
1281 if (ret) 1229 if (IS_ERR(dp->phy)) {
1282 return ret; 1230 dev_err(dp->dev, "no DP phy configured\n");
1231 ret = PTR_ERR(dp->phy);
1232 if (ret) {
1233 /*
1234 * phy itself is not enabled, so we can move forward
1235 * assigning NULL to phy pointer.
1236 */
1237 if (ret == -ENOSYS || ret == -ENODEV)
1238 dp->phy = NULL;
1239 else
1240 return ret;
1241 }
1242 }
1283 1243
1284 if (!dp->panel) { 1244 if (!dp->panel) {
1285 ret = exynos_dp_dt_parse_panel(dp); 1245 ret = exynos_dp_dt_parse_panel(dp);
@@ -1346,17 +1306,15 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
1346 1306
1347 dp->drm_dev = drm_dev; 1307 dp->drm_dev = drm_dev;
1348 1308
1349 platform_set_drvdata(pdev, &exynos_dp_display); 1309 return exynos_drm_create_enc_conn(drm_dev, &dp->display);
1350
1351 return exynos_drm_create_enc_conn(drm_dev, &exynos_dp_display);
1352} 1310}
1353 1311
1354static void exynos_dp_unbind(struct device *dev, struct device *master, 1312static void exynos_dp_unbind(struct device *dev, struct device *master,
1355 void *data) 1313 void *data)
1356{ 1314{
1357 struct exynos_drm_display *display = dev_get_drvdata(dev); 1315 struct exynos_dp_device *dp = dev_get_drvdata(dev);
1358 1316
1359 exynos_dp_dpms(display, DRM_MODE_DPMS_OFF); 1317 exynos_dp_dpms(&dp->display, DRM_MODE_DPMS_OFF);
1360} 1318}
1361 1319
1362static const struct component_ops exynos_dp_ops = { 1320static const struct component_ops exynos_dp_ops = {
@@ -1371,16 +1329,20 @@ static int exynos_dp_probe(struct platform_device *pdev)
1371 struct exynos_dp_device *dp; 1329 struct exynos_dp_device *dp;
1372 int ret; 1330 int ret;
1373 1331
1374 ret = exynos_drm_component_add(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR,
1375 exynos_dp_display.type);
1376 if (ret)
1377 return ret;
1378
1379 dp = devm_kzalloc(&pdev->dev, sizeof(struct exynos_dp_device), 1332 dp = devm_kzalloc(&pdev->dev, sizeof(struct exynos_dp_device),
1380 GFP_KERNEL); 1333 GFP_KERNEL);
1381 if (!dp) 1334 if (!dp)
1382 return -ENOMEM; 1335 return -ENOMEM;
1383 1336
1337 dp->display.type = EXYNOS_DISPLAY_TYPE_LCD;
1338 dp->display.ops = &exynos_dp_display_ops;
1339 platform_set_drvdata(pdev, dp);
1340
1341 ret = exynos_drm_component_add(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR,
1342 dp->display.type);
1343 if (ret)
1344 return ret;
1345
1384 panel_node = of_parse_phandle(dev->of_node, "panel", 0); 1346 panel_node = of_parse_phandle(dev->of_node, "panel", 0);
1385 if (panel_node) { 1347 if (panel_node) {
1386 dp->panel = of_drm_find_panel(panel_node); 1348 dp->panel = of_drm_find_panel(panel_node);
@@ -1389,8 +1351,6 @@ static int exynos_dp_probe(struct platform_device *pdev)
1389 return -EPROBE_DEFER; 1351 return -EPROBE_DEFER;
1390 } 1352 }
1391 1353
1392 exynos_dp_display.ctx = dp;
1393
1394 ret = component_add(&pdev->dev, &exynos_dp_ops); 1354 ret = component_add(&pdev->dev, &exynos_dp_ops);
1395 if (ret) 1355 if (ret)
1396 exynos_drm_component_del(&pdev->dev, 1356 exynos_drm_component_del(&pdev->dev,
@@ -1410,19 +1370,17 @@ static int exynos_dp_remove(struct platform_device *pdev)
1410#ifdef CONFIG_PM_SLEEP 1370#ifdef CONFIG_PM_SLEEP
1411static int exynos_dp_suspend(struct device *dev) 1371static int exynos_dp_suspend(struct device *dev)
1412{ 1372{
1413 struct platform_device *pdev = to_platform_device(dev); 1373 struct exynos_dp_device *dp = dev_get_drvdata(dev);
1414 struct exynos_drm_display *display = platform_get_drvdata(pdev);
1415 1374
1416 exynos_dp_dpms(display, DRM_MODE_DPMS_OFF); 1375 exynos_dp_dpms(&dp->display, DRM_MODE_DPMS_OFF);
1417 return 0; 1376 return 0;
1418} 1377}
1419 1378
1420static int exynos_dp_resume(struct device *dev) 1379static int exynos_dp_resume(struct device *dev)
1421{ 1380{
1422 struct platform_device *pdev = to_platform_device(dev); 1381 struct exynos_dp_device *dp = dev_get_drvdata(dev);
1423 struct exynos_drm_display *display = platform_get_drvdata(pdev);
1424 1382
1425 exynos_dp_dpms(display, DRM_MODE_DPMS_ON); 1383 exynos_dp_dpms(&dp->display, DRM_MODE_DPMS_ON);
1426 return 0; 1384 return 0;
1427} 1385}
1428#endif 1386#endif
diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.h b/drivers/gpu/drm/exynos/exynos_dp_core.h
index a1aee6931bd7..164f171168e7 100644
--- a/drivers/gpu/drm/exynos/exynos_dp_core.h
+++ b/drivers/gpu/drm/exynos/exynos_dp_core.h
@@ -17,6 +17,8 @@
17#include <drm/drm_dp_helper.h> 17#include <drm/drm_dp_helper.h>
18#include <drm/exynos_drm.h> 18#include <drm/exynos_drm.h>
19 19
20#include "exynos_drm_drv.h"
21
20#define DP_TIMEOUT_LOOP_COUNT 100 22#define DP_TIMEOUT_LOOP_COUNT 100
21#define MAX_CR_LOOP 5 23#define MAX_CR_LOOP 5
22#define MAX_EQ_LOOP 5 24#define MAX_EQ_LOOP 5
@@ -145,6 +147,7 @@ struct link_train {
145}; 147};
146 148
147struct exynos_dp_device { 149struct exynos_dp_device {
150 struct exynos_drm_display display;
148 struct device *dev; 151 struct device *dev;
149 struct drm_device *drm_dev; 152 struct drm_device *drm_dev;
150 struct drm_connector connector; 153 struct drm_connector connector;
@@ -153,8 +156,6 @@ struct exynos_dp_device {
153 struct clk *clock; 156 struct clk *clock;
154 unsigned int irq; 157 unsigned int irq;
155 void __iomem *reg_base; 158 void __iomem *reg_base;
156 void __iomem *phy_addr;
157 unsigned int enable_mask;
158 159
159 struct video_info *video_info; 160 struct video_info *video_info;
160 struct link_train link_train; 161 struct link_train link_train;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.h b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
index 690dcddab725..e353d353836f 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
@@ -15,10 +15,7 @@
15#ifndef _EXYNOS_DRM_CRTC_H_ 15#ifndef _EXYNOS_DRM_CRTC_H_
16#define _EXYNOS_DRM_CRTC_H_ 16#define _EXYNOS_DRM_CRTC_H_
17 17
18struct drm_device; 18#include "exynos_drm_drv.h"
19struct drm_crtc;
20struct exynos_drm_manager;
21struct exynos_drm_overlay;
22 19
23int exynos_drm_crtc_create(struct exynos_drm_manager *manager); 20int exynos_drm_crtc_create(struct exynos_drm_manager *manager);
24int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe); 21int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dpi.c b/drivers/gpu/drm/exynos/exynos_drm_dpi.c
index 3dc678ed9949..37678cf4425a 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dpi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dpi.c
@@ -22,6 +22,7 @@
22#include "exynos_drm_drv.h" 22#include "exynos_drm_drv.h"
23 23
24struct exynos_dpi { 24struct exynos_dpi {
25 struct exynos_drm_display display;
25 struct device *dev; 26 struct device *dev;
26 struct device_node *panel_node; 27 struct device_node *panel_node;
27 28
@@ -35,6 +36,11 @@ struct exynos_dpi {
35 36
36#define connector_to_dpi(c) container_of(c, struct exynos_dpi, connector) 37#define connector_to_dpi(c) container_of(c, struct exynos_dpi, connector)
37 38
39static inline struct exynos_dpi *display_to_dpi(struct exynos_drm_display *d)
40{
41 return container_of(d, struct exynos_dpi, display);
42}
43
38static enum drm_connector_status 44static enum drm_connector_status
39exynos_dpi_detect(struct drm_connector *connector, bool force) 45exynos_dpi_detect(struct drm_connector *connector, bool force)
40{ 46{
@@ -100,7 +106,7 @@ static struct drm_connector_helper_funcs exynos_dpi_connector_helper_funcs = {
100static int exynos_dpi_create_connector(struct exynos_drm_display *display, 106static int exynos_dpi_create_connector(struct exynos_drm_display *display,
101 struct drm_encoder *encoder) 107 struct drm_encoder *encoder)
102{ 108{
103 struct exynos_dpi *ctx = display->ctx; 109 struct exynos_dpi *ctx = display_to_dpi(display);
104 struct drm_connector *connector = &ctx->connector; 110 struct drm_connector *connector = &ctx->connector;
105 int ret; 111 int ret;
106 112
@@ -141,7 +147,7 @@ static void exynos_dpi_poweroff(struct exynos_dpi *ctx)
141 147
142static void exynos_dpi_dpms(struct exynos_drm_display *display, int mode) 148static void exynos_dpi_dpms(struct exynos_drm_display *display, int mode)
143{ 149{
144 struct exynos_dpi *ctx = display->ctx; 150 struct exynos_dpi *ctx = display_to_dpi(display);
145 151
146 switch (mode) { 152 switch (mode) {
147 case DRM_MODE_DPMS_ON: 153 case DRM_MODE_DPMS_ON:
@@ -165,11 +171,6 @@ static struct exynos_drm_display_ops exynos_dpi_display_ops = {
165 .dpms = exynos_dpi_dpms 171 .dpms = exynos_dpi_dpms
166}; 172};
167 173
168static struct exynos_drm_display exynos_dpi_display = {
169 .type = EXYNOS_DISPLAY_TYPE_LCD,
170 .ops = &exynos_dpi_display_ops,
171};
172
173/* of_* functions will be removed after merge of of_graph patches */ 174/* of_* functions will be removed after merge of of_graph patches */
174static struct device_node * 175static struct device_node *
175of_get_child_by_name_reg(struct device_node *parent, const char *name, u32 reg) 176of_get_child_by_name_reg(struct device_node *parent, const char *name, u32 reg)
@@ -299,20 +300,21 @@ struct exynos_drm_display *exynos_dpi_probe(struct device *dev)
299 struct exynos_dpi *ctx; 300 struct exynos_dpi *ctx;
300 int ret; 301 int ret;
301 302
302 ret = exynos_drm_component_add(dev,
303 EXYNOS_DEVICE_TYPE_CONNECTOR,
304 exynos_dpi_display.type);
305 if (ret)
306 return ERR_PTR(ret);
307
308 ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); 303 ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
309 if (!ctx) 304 if (!ctx)
310 goto err_del_component; 305 return ERR_PTR(-ENOMEM);
311 306
307 ctx->display.type = EXYNOS_DISPLAY_TYPE_LCD;
308 ctx->display.ops = &exynos_dpi_display_ops;
312 ctx->dev = dev; 309 ctx->dev = dev;
313 exynos_dpi_display.ctx = ctx;
314 ctx->dpms_mode = DRM_MODE_DPMS_OFF; 310 ctx->dpms_mode = DRM_MODE_DPMS_OFF;
315 311
312 ret = exynos_drm_component_add(dev,
313 EXYNOS_DEVICE_TYPE_CONNECTOR,
314 ctx->display.type);
315 if (ret)
316 return ERR_PTR(ret);
317
316 ret = exynos_dpi_parse_dt(ctx); 318 ret = exynos_dpi_parse_dt(ctx);
317 if (ret < 0) { 319 if (ret < 0) {
318 devm_kfree(dev, ctx); 320 devm_kfree(dev, ctx);
@@ -328,7 +330,7 @@ struct exynos_drm_display *exynos_dpi_probe(struct device *dev)
328 } 330 }
329 } 331 }
330 332
331 return &exynos_dpi_display; 333 return &ctx->display;
332 334
333err_del_component: 335err_del_component:
334 exynos_drm_component_del(dev, EXYNOS_DEVICE_TYPE_CONNECTOR); 336 exynos_drm_component_del(dev, EXYNOS_DEVICE_TYPE_CONNECTOR);
@@ -336,16 +338,16 @@ err_del_component:
336 return NULL; 338 return NULL;
337} 339}
338 340
339int exynos_dpi_remove(struct device *dev) 341int exynos_dpi_remove(struct exynos_drm_display *display)
340{ 342{
341 struct exynos_dpi *ctx = exynos_dpi_display.ctx; 343 struct exynos_dpi *ctx = display_to_dpi(display);
342 344
343 exynos_dpi_dpms(&exynos_dpi_display, DRM_MODE_DPMS_OFF); 345 exynos_dpi_dpms(&ctx->display, DRM_MODE_DPMS_OFF);
344 346
345 if (ctx->panel) 347 if (ctx->panel)
346 drm_panel_detach(ctx->panel); 348 drm_panel_detach(ctx->panel);
347 349
348 exynos_drm_component_del(dev, EXYNOS_DEVICE_TYPE_CONNECTOR); 350 exynos_drm_component_del(ctx->dev, EXYNOS_DEVICE_TYPE_CONNECTOR);
349 351
350 return 0; 352 return 0;
351} 353}
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index c57466edf45b..d71fb54582d2 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -203,8 +203,6 @@ static int exynos_drm_resume(struct drm_device *dev)
203 } 203 }
204 drm_modeset_unlock_all(dev); 204 drm_modeset_unlock_all(dev);
205 205
206 drm_helper_resume_force_mode(dev);
207
208 return 0; 206 return 0;
209} 207}
210 208
@@ -475,8 +473,6 @@ void exynos_drm_component_del(struct device *dev,
475 list_del(&cdev->list); 473 list_del(&cdev->list);
476 kfree(cdev); 474 kfree(cdev);
477 } 475 }
478
479 break;
480 } 476 }
481 477
482 mutex_unlock(&drm_component_lock); 478 mutex_unlock(&drm_component_lock);
@@ -495,6 +491,12 @@ static struct component_match *exynos_drm_match_add(struct device *dev)
495 491
496 mutex_lock(&drm_component_lock); 492 mutex_lock(&drm_component_lock);
497 493
494 /* Do not retry to probe if there is no any kms driver regitered. */
495 if (list_empty(&drm_component_list)) {
496 mutex_unlock(&drm_component_lock);
497 return ERR_PTR(-ENODEV);
498 }
499
498 list_for_each_entry(cdev, &drm_component_list, list) { 500 list_for_each_entry(cdev, &drm_component_list, list) {
499 /* 501 /*
500 * Add components to master only in case that crtc and 502 * Add components to master only in case that crtc and
@@ -550,183 +552,68 @@ static const struct component_master_ops exynos_drm_ops = {
550 .unbind = exynos_drm_unbind, 552 .unbind = exynos_drm_unbind,
551}; 553};
552 554
553static int exynos_drm_platform_probe(struct platform_device *pdev) 555static struct platform_driver *const exynos_drm_kms_drivers[] = {
554{
555 struct component_match *match;
556 int ret;
557
558 pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
559 exynos_drm_driver.num_ioctls = ARRAY_SIZE(exynos_ioctls);
560
561#ifdef CONFIG_DRM_EXYNOS_FIMD 556#ifdef CONFIG_DRM_EXYNOS_FIMD
562 ret = platform_driver_register(&fimd_driver); 557 &fimd_driver,
563 if (ret < 0)
564 return ret;
565#endif 558#endif
566
567#ifdef CONFIG_DRM_EXYNOS_DP 559#ifdef CONFIG_DRM_EXYNOS_DP
568 ret = platform_driver_register(&dp_driver); 560 &dp_driver,
569 if (ret < 0)
570 goto err_unregister_fimd_drv;
571#endif 561#endif
572
573#ifdef CONFIG_DRM_EXYNOS_DSI 562#ifdef CONFIG_DRM_EXYNOS_DSI
574 ret = platform_driver_register(&dsi_driver); 563 &dsi_driver,
575 if (ret < 0)
576 goto err_unregister_dp_drv;
577#endif 564#endif
578
579#ifdef CONFIG_DRM_EXYNOS_HDMI 565#ifdef CONFIG_DRM_EXYNOS_HDMI
580 ret = platform_driver_register(&mixer_driver); 566 &mixer_driver,
581 if (ret < 0) 567 &hdmi_driver,
582 goto err_unregister_dsi_drv;
583 ret = platform_driver_register(&hdmi_driver);
584 if (ret < 0)
585 goto err_unregister_mixer_drv;
586#endif 568#endif
569};
587 570
571static struct platform_driver *const exynos_drm_non_kms_drivers[] = {
588#ifdef CONFIG_DRM_EXYNOS_G2D 572#ifdef CONFIG_DRM_EXYNOS_G2D
589 ret = platform_driver_register(&g2d_driver); 573 &g2d_driver,
590 if (ret < 0)
591 goto err_unregister_hdmi_drv;
592#endif 574#endif
593
594#ifdef CONFIG_DRM_EXYNOS_FIMC 575#ifdef CONFIG_DRM_EXYNOS_FIMC
595 ret = platform_driver_register(&fimc_driver); 576 &fimc_driver,
596 if (ret < 0)
597 goto err_unregister_g2d_drv;
598#endif 577#endif
599
600#ifdef CONFIG_DRM_EXYNOS_ROTATOR 578#ifdef CONFIG_DRM_EXYNOS_ROTATOR
601 ret = platform_driver_register(&rotator_driver); 579 &rotator_driver,
602 if (ret < 0)
603 goto err_unregister_fimc_drv;
604#endif 580#endif
605
606#ifdef CONFIG_DRM_EXYNOS_GSC 581#ifdef CONFIG_DRM_EXYNOS_GSC
607 ret = platform_driver_register(&gsc_driver); 582 &gsc_driver,
608 if (ret < 0)
609 goto err_unregister_rotator_drv;
610#endif 583#endif
611
612#ifdef CONFIG_DRM_EXYNOS_IPP 584#ifdef CONFIG_DRM_EXYNOS_IPP
613 ret = platform_driver_register(&ipp_driver); 585 &ipp_driver,
614 if (ret < 0)
615 goto err_unregister_gsc_drv;
616
617 ret = exynos_platform_device_ipp_register();
618 if (ret < 0)
619 goto err_unregister_ipp_drv;
620#endif 586#endif
587};
588
589static int exynos_drm_platform_probe(struct platform_device *pdev)
590{
591 struct component_match *match;
592
593 pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
594 exynos_drm_driver.num_ioctls = ARRAY_SIZE(exynos_ioctls);
621 595
622 match = exynos_drm_match_add(&pdev->dev); 596 match = exynos_drm_match_add(&pdev->dev);
623 if (IS_ERR(match)) { 597 if (IS_ERR(match)) {
624 ret = PTR_ERR(match); 598 return PTR_ERR(match);
625 goto err_unregister_resources;
626 } 599 }
627 600
628 ret = component_master_add_with_match(&pdev->dev, &exynos_drm_ops, 601 return component_master_add_with_match(&pdev->dev, &exynos_drm_ops,
629 match); 602 match);
630 if (ret < 0)
631 goto err_unregister_resources;
632
633 return ret;
634
635err_unregister_resources:
636
637#ifdef CONFIG_DRM_EXYNOS_IPP
638 exynos_platform_device_ipp_unregister();
639err_unregister_ipp_drv:
640 platform_driver_unregister(&ipp_driver);
641err_unregister_gsc_drv:
642#endif
643
644#ifdef CONFIG_DRM_EXYNOS_GSC
645 platform_driver_unregister(&gsc_driver);
646err_unregister_rotator_drv:
647#endif
648
649#ifdef CONFIG_DRM_EXYNOS_ROTATOR
650 platform_driver_unregister(&rotator_driver);
651err_unregister_fimc_drv:
652#endif
653
654#ifdef CONFIG_DRM_EXYNOS_FIMC
655 platform_driver_unregister(&fimc_driver);
656err_unregister_g2d_drv:
657#endif
658
659#ifdef CONFIG_DRM_EXYNOS_G2D
660 platform_driver_unregister(&g2d_driver);
661err_unregister_hdmi_drv:
662#endif
663
664#ifdef CONFIG_DRM_EXYNOS_HDMI
665 platform_driver_unregister(&hdmi_driver);
666err_unregister_mixer_drv:
667 platform_driver_unregister(&mixer_driver);
668err_unregister_dsi_drv:
669#endif
670
671#ifdef CONFIG_DRM_EXYNOS_DSI
672 platform_driver_unregister(&dsi_driver);
673err_unregister_dp_drv:
674#endif
675
676#ifdef CONFIG_DRM_EXYNOS_DP
677 platform_driver_unregister(&dp_driver);
678err_unregister_fimd_drv:
679#endif
680
681#ifdef CONFIG_DRM_EXYNOS_FIMD
682 platform_driver_unregister(&fimd_driver);
683#endif
684 return ret;
685} 603}
686 604
687static int exynos_drm_platform_remove(struct platform_device *pdev) 605static int exynos_drm_platform_remove(struct platform_device *pdev)
688{ 606{
689#ifdef CONFIG_DRM_EXYNOS_IPP
690 exynos_platform_device_ipp_unregister();
691 platform_driver_unregister(&ipp_driver);
692#endif
693
694#ifdef CONFIG_DRM_EXYNOS_GSC
695 platform_driver_unregister(&gsc_driver);
696#endif
697
698#ifdef CONFIG_DRM_EXYNOS_ROTATOR
699 platform_driver_unregister(&rotator_driver);
700#endif
701
702#ifdef CONFIG_DRM_EXYNOS_FIMC
703 platform_driver_unregister(&fimc_driver);
704#endif
705
706#ifdef CONFIG_DRM_EXYNOS_G2D
707 platform_driver_unregister(&g2d_driver);
708#endif
709
710#ifdef CONFIG_DRM_EXYNOS_HDMI
711 platform_driver_unregister(&mixer_driver);
712 platform_driver_unregister(&hdmi_driver);
713#endif
714
715#ifdef CONFIG_DRM_EXYNOS_FIMD
716 platform_driver_unregister(&fimd_driver);
717#endif
718
719#ifdef CONFIG_DRM_EXYNOS_DSI
720 platform_driver_unregister(&dsi_driver);
721#endif
722
723#ifdef CONFIG_DRM_EXYNOS_DP
724 platform_driver_unregister(&dp_driver);
725#endif
726 component_master_del(&pdev->dev, &exynos_drm_ops); 607 component_master_del(&pdev->dev, &exynos_drm_ops);
727 return 0; 608 return 0;
728} 609}
729 610
611static const char * const strings[] = {
612 "samsung,exynos3",
613 "samsung,exynos4",
614 "samsung,exynos5",
615};
616
730static struct platform_driver exynos_drm_platform_driver = { 617static struct platform_driver exynos_drm_platform_driver = {
731 .probe = exynos_drm_platform_probe, 618 .probe = exynos_drm_platform_probe,
732 .remove = exynos_drm_platform_remove, 619 .remove = exynos_drm_platform_remove,
@@ -739,31 +626,75 @@ static struct platform_driver exynos_drm_platform_driver = {
739 626
740static int exynos_drm_init(void) 627static int exynos_drm_init(void)
741{ 628{
742 int ret; 629 bool is_exynos = false;
630 int ret, i, j;
631
632 /*
633 * Register device object only in case of Exynos SoC.
634 *
635 * Below codes resolves temporarily infinite loop issue incurred
636 * by Exynos drm driver when using multi-platform kernel.
637 * So these codes will be replaced with more generic way later.
638 */
639 for (i = 0; i < ARRAY_SIZE(strings); i++) {
640 if (of_machine_is_compatible(strings[i])) {
641 is_exynos = true;
642 break;
643 }
644 }
645
646 if (!is_exynos)
647 return -ENODEV;
743 648
744 exynos_drm_pdev = platform_device_register_simple("exynos-drm", -1, 649 exynos_drm_pdev = platform_device_register_simple("exynos-drm", -1,
745 NULL, 0); 650 NULL, 0);
746 if (IS_ERR(exynos_drm_pdev)) 651 if (IS_ERR(exynos_drm_pdev))
747 return PTR_ERR(exynos_drm_pdev); 652 return PTR_ERR(exynos_drm_pdev);
748 653
749#ifdef CONFIG_DRM_EXYNOS_VIDI
750 ret = exynos_drm_probe_vidi(); 654 ret = exynos_drm_probe_vidi();
751 if (ret < 0) 655 if (ret < 0)
752 goto err_unregister_pd; 656 goto err_unregister_pd;
657
658 for (i = 0; i < ARRAY_SIZE(exynos_drm_kms_drivers); ++i) {
659 ret = platform_driver_register(exynos_drm_kms_drivers[i]);
660 if (ret < 0)
661 goto err_unregister_kms_drivers;
662 }
663
664 for (j = 0; j < ARRAY_SIZE(exynos_drm_non_kms_drivers); ++j) {
665 ret = platform_driver_register(exynos_drm_non_kms_drivers[j]);
666 if (ret < 0)
667 goto err_unregister_non_kms_drivers;
668 }
669
670#ifdef CONFIG_DRM_EXYNOS_IPP
671 ret = exynos_platform_device_ipp_register();
672 if (ret < 0)
673 goto err_unregister_non_kms_drivers;
753#endif 674#endif
754 675
755 ret = platform_driver_register(&exynos_drm_platform_driver); 676 ret = platform_driver_register(&exynos_drm_platform_driver);
756 if (ret) 677 if (ret)
757 goto err_remove_vidi; 678 goto err_unregister_resources;
758 679
759 return 0; 680 return 0;
760 681
761err_remove_vidi: 682err_unregister_resources:
762#ifdef CONFIG_DRM_EXYNOS_VIDI 683#ifdef CONFIG_DRM_EXYNOS_IPP
684 exynos_platform_device_ipp_unregister();
685#endif
686
687err_unregister_non_kms_drivers:
688 while (--j >= 0)
689 platform_driver_unregister(exynos_drm_non_kms_drivers[j]);
690
691err_unregister_kms_drivers:
692 while (--i >= 0)
693 platform_driver_unregister(exynos_drm_kms_drivers[i]);
694
763 exynos_drm_remove_vidi(); 695 exynos_drm_remove_vidi();
764 696
765err_unregister_pd: 697err_unregister_pd:
766#endif
767 platform_device_unregister(exynos_drm_pdev); 698 platform_device_unregister(exynos_drm_pdev);
768 699
769 return ret; 700 return ret;
@@ -771,10 +702,22 @@ err_unregister_pd:
771 702
772static void exynos_drm_exit(void) 703static void exynos_drm_exit(void)
773{ 704{
705 int i;
706
707#ifdef CONFIG_DRM_EXYNOS_IPP
708 exynos_platform_device_ipp_unregister();
709#endif
710
711 for (i = ARRAY_SIZE(exynos_drm_non_kms_drivers) - 1; i >= 0; --i)
712 platform_driver_unregister(exynos_drm_non_kms_drivers[i]);
713
714 for (i = ARRAY_SIZE(exynos_drm_kms_drivers) - 1; i >= 0; --i)
715 platform_driver_unregister(exynos_drm_kms_drivers[i]);
716
774 platform_driver_unregister(&exynos_drm_platform_driver); 717 platform_driver_unregister(&exynos_drm_platform_driver);
775#ifdef CONFIG_DRM_EXYNOS_VIDI 718
776 exynos_drm_remove_vidi(); 719 exynos_drm_remove_vidi();
777#endif 720
778 platform_device_unregister(exynos_drm_pdev); 721 platform_device_unregister(exynos_drm_pdev);
779} 722}
780 723
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index d22e640f59a0..2e5063488c50 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -15,6 +15,7 @@
15#ifndef _EXYNOS_DRM_DRV_H_ 15#ifndef _EXYNOS_DRM_DRV_H_
16#define _EXYNOS_DRM_DRV_H_ 16#define _EXYNOS_DRM_DRV_H_
17 17
18#include <drm/drmP.h>
18#include <linux/module.h> 19#include <linux/module.h>
19 20
20#define MAX_CRTC 3 21#define MAX_CRTC 3
@@ -22,24 +23,6 @@
22#define MAX_FB_BUFFER 4 23#define MAX_FB_BUFFER 4
23#define DEFAULT_ZPOS -1 24#define DEFAULT_ZPOS -1
24 25
25#define _wait_for(COND, MS) ({ \
26 unsigned long timeout__ = jiffies + msecs_to_jiffies(MS); \
27 int ret__ = 0; \
28 while (!(COND)) { \
29 if (time_after(jiffies, timeout__)) { \
30 ret__ = -ETIMEDOUT; \
31 break; \
32 } \
33 } \
34 ret__; \
35})
36
37#define wait_for(COND, MS) _wait_for(COND, MS)
38
39struct drm_device;
40struct exynos_drm_overlay;
41struct drm_connector;
42
43/* This enumerates device type. */ 26/* This enumerates device type. */
44enum exynos_drm_device_type { 27enum exynos_drm_device_type {
45 EXYNOS_DEVICE_TYPE_NONE, 28 EXYNOS_DEVICE_TYPE_NONE,
@@ -83,10 +66,10 @@ enum exynos_drm_output_type {
83 * @dma_addr: array of bus(accessed by dma) address to the memory region 66 * @dma_addr: array of bus(accessed by dma) address to the memory region
84 * allocated for a overlay. 67 * allocated for a overlay.
85 * @zpos: order of overlay layer(z position). 68 * @zpos: order of overlay layer(z position).
86 * @default_win: a window to be enabled.
87 * @color_key: color key on or off.
88 * @index_color: if using color key feature then this value would be used 69 * @index_color: if using color key feature then this value would be used
89 * as index color. 70 * as index color.
71 * @default_win: a window to be enabled.
72 * @color_key: color key on or off.
90 * @local_path: in case of lcd type, local path mode on or off. 73 * @local_path: in case of lcd type, local path mode on or off.
91 * @transparency: transparency on or off. 74 * @transparency: transparency on or off.
92 * @activated: activated or not. 75 * @activated: activated or not.
@@ -114,19 +97,20 @@ struct exynos_drm_overlay {
114 uint32_t pixel_format; 97 uint32_t pixel_format;
115 dma_addr_t dma_addr[MAX_FB_BUFFER]; 98 dma_addr_t dma_addr[MAX_FB_BUFFER];
116 int zpos; 99 int zpos;
117
118 bool default_win;
119 bool color_key;
120 unsigned int index_color; 100 unsigned int index_color;
121 bool local_path; 101
122 bool transparency; 102 bool default_win:1;
123 bool activated; 103 bool color_key:1;
104 bool local_path:1;
105 bool transparency:1;
106 bool activated:1;
124}; 107};
125 108
126/* 109/*
127 * Exynos DRM Display Structure. 110 * Exynos DRM Display Structure.
128 * - this structure is common to analog tv, digital tv and lcd panel. 111 * - this structure is common to analog tv, digital tv and lcd panel.
129 * 112 *
113 * @create_connector: initialize and register a new connector
130 * @remove: cleans up the display for removal 114 * @remove: cleans up the display for removal
131 * @mode_fixup: fix mode data comparing to hw specific display mode. 115 * @mode_fixup: fix mode data comparing to hw specific display mode.
132 * @mode_set: convert drm_display_mode to hw specific display mode and 116 * @mode_set: convert drm_display_mode to hw specific display mode and
@@ -168,7 +152,6 @@ struct exynos_drm_display {
168 struct drm_encoder *encoder; 152 struct drm_encoder *encoder;
169 struct drm_connector *connector; 153 struct drm_connector *connector;
170 struct exynos_drm_display_ops *ops; 154 struct exynos_drm_display_ops *ops;
171 void *ctx;
172}; 155};
173 156
174/* 157/*
@@ -227,7 +210,6 @@ struct exynos_drm_manager {
227 struct drm_crtc *crtc; 210 struct drm_crtc *crtc;
228 int pipe; 211 int pipe;
229 struct exynos_drm_manager_ops *ops; 212 struct exynos_drm_manager_ops *ops;
230 void *ctx;
231}; 213};
232 214
233struct exynos_drm_g2d_private { 215struct exynos_drm_g2d_private {
@@ -279,8 +261,6 @@ struct exynos_drm_private {
279 * @dev: pointer to device object for subdrv device driver. 261 * @dev: pointer to device object for subdrv device driver.
280 * @drm_dev: pointer to drm_device and this pointer would be set 262 * @drm_dev: pointer to drm_device and this pointer would be set
281 * when sub driver calls exynos_drm_subdrv_register(). 263 * when sub driver calls exynos_drm_subdrv_register().
282 * @manager: subdrv has its own manager to control a hardware appropriately
283 * and we can access a hardware drawing on this manager.
284 * @probe: this callback would be called by exynos drm driver after 264 * @probe: this callback would be called by exynos drm driver after
285 * subdrv is registered to it. 265 * subdrv is registered to it.
286 * @remove: this callback is used to release resources created 266 * @remove: this callback is used to release resources created
@@ -312,45 +292,34 @@ int exynos_drm_device_subdrv_remove(struct drm_device *dev);
312int exynos_drm_subdrv_open(struct drm_device *dev, struct drm_file *file); 292int exynos_drm_subdrv_open(struct drm_device *dev, struct drm_file *file);
313void exynos_drm_subdrv_close(struct drm_device *dev, struct drm_file *file); 293void exynos_drm_subdrv_close(struct drm_device *dev, struct drm_file *file);
314 294
315/* 295#ifdef CONFIG_DRM_EXYNOS_IPP
316 * this function registers exynos drm hdmi platform device. It ensures only one
317 * instance of the device is created.
318 */
319int exynos_platform_device_hdmi_register(void);
320
321/*
322 * this function unregisters exynos drm hdmi platform device if it exists.
323 */
324void exynos_platform_device_hdmi_unregister(void);
325
326/*
327 * this function registers exynos drm ipp platform device.
328 */
329int exynos_platform_device_ipp_register(void); 296int exynos_platform_device_ipp_register(void);
330
331/*
332 * this function unregisters exynos drm ipp platform device if it exists.
333 */
334void exynos_platform_device_ipp_unregister(void); 297void exynos_platform_device_ipp_unregister(void);
298#else
299static inline int exynos_platform_device_ipp_register(void) { return 0; }
300static inline void exynos_platform_device_ipp_unregister(void) {}
301#endif
302
335 303
336#ifdef CONFIG_DRM_EXYNOS_DPI 304#ifdef CONFIG_DRM_EXYNOS_DPI
337struct exynos_drm_display * exynos_dpi_probe(struct device *dev); 305struct exynos_drm_display * exynos_dpi_probe(struct device *dev);
338int exynos_dpi_remove(struct device *dev); 306int exynos_dpi_remove(struct exynos_drm_display *display);
339#else 307#else
340static inline struct exynos_drm_display * 308static inline struct exynos_drm_display *
341exynos_dpi_probe(struct device *dev) { return NULL; } 309exynos_dpi_probe(struct device *dev) { return NULL; }
342static inline int exynos_dpi_remove(struct device *dev) { return 0; } 310static inline int exynos_dpi_remove(struct exynos_drm_display *display)
311{
312 return 0;
313}
343#endif 314#endif
344 315
345/* 316#ifdef CONFIG_DRM_EXYNOS_VIDI
346 * this function registers exynos drm vidi platform device/driver.
347 */
348int exynos_drm_probe_vidi(void); 317int exynos_drm_probe_vidi(void);
349
350/*
351 * this function unregister exynos drm vidi platform device/driver.
352 */
353void exynos_drm_remove_vidi(void); 318void exynos_drm_remove_vidi(void);
319#else
320static inline int exynos_drm_probe_vidi(void) { return 0; }
321static inline void exynos_drm_remove_vidi(void) {}
322#endif
354 323
355/* This function creates a encoder and a connector, and initializes them. */ 324/* This function creates a encoder and a connector, and initializes them. */
356int exynos_drm_create_enc_conn(struct drm_device *dev, 325int exynos_drm_create_enc_conn(struct drm_device *dev,
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
index f43d25896f3b..05fe93dc57a8 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
@@ -268,9 +268,9 @@ struct exynos_dsi_driver_data {
268}; 268};
269 269
270struct exynos_dsi { 270struct exynos_dsi {
271 struct exynos_drm_display display;
271 struct mipi_dsi_host dsi_host; 272 struct mipi_dsi_host dsi_host;
272 struct drm_connector connector; 273 struct drm_connector connector;
273 struct drm_encoder *encoder;
274 struct device_node *panel_node; 274 struct device_node *panel_node;
275 struct drm_panel *panel; 275 struct drm_panel *panel;
276 struct device *dev; 276 struct device *dev;
@@ -304,6 +304,11 @@ struct exynos_dsi {
304#define host_to_dsi(host) container_of(host, struct exynos_dsi, dsi_host) 304#define host_to_dsi(host) container_of(host, struct exynos_dsi, dsi_host)
305#define connector_to_dsi(c) container_of(c, struct exynos_dsi, connector) 305#define connector_to_dsi(c) container_of(c, struct exynos_dsi, connector)
306 306
307static inline struct exynos_dsi *display_to_dsi(struct exynos_drm_display *d)
308{
309 return container_of(d, struct exynos_dsi, display);
310}
311
307static struct exynos_dsi_driver_data exynos3_dsi_driver_data = { 312static struct exynos_dsi_driver_data exynos3_dsi_driver_data = {
308 .plltmr_reg = 0x50, 313 .plltmr_reg = 0x50,
309 .has_freqband = 1, 314 .has_freqband = 1,
@@ -316,6 +321,11 @@ static struct exynos_dsi_driver_data exynos4_dsi_driver_data = {
316 .has_clklane_stop = 1, 321 .has_clklane_stop = 1,
317}; 322};
318 323
324static struct exynos_dsi_driver_data exynos4415_dsi_driver_data = {
325 .plltmr_reg = 0x58,
326 .has_clklane_stop = 1,
327};
328
319static struct exynos_dsi_driver_data exynos5_dsi_driver_data = { 329static struct exynos_dsi_driver_data exynos5_dsi_driver_data = {
320 .plltmr_reg = 0x58, 330 .plltmr_reg = 0x58,
321}; 331};
@@ -325,6 +335,8 @@ static struct of_device_id exynos_dsi_of_match[] = {
325 .data = &exynos3_dsi_driver_data }, 335 .data = &exynos3_dsi_driver_data },
326 { .compatible = "samsung,exynos4210-mipi-dsi", 336 { .compatible = "samsung,exynos4210-mipi-dsi",
327 .data = &exynos4_dsi_driver_data }, 337 .data = &exynos4_dsi_driver_data },
338 { .compatible = "samsung,exynos4415-mipi-dsi",
339 .data = &exynos4415_dsi_driver_data },
328 { .compatible = "samsung,exynos5410-mipi-dsi", 340 { .compatible = "samsung,exynos5410-mipi-dsi",
329 .data = &exynos5_dsi_driver_data }, 341 .data = &exynos5_dsi_driver_data },
330 { } 342 { }
@@ -1104,7 +1116,7 @@ static irqreturn_t exynos_dsi_irq(int irq, void *dev_id)
1104static irqreturn_t exynos_dsi_te_irq_handler(int irq, void *dev_id) 1116static irqreturn_t exynos_dsi_te_irq_handler(int irq, void *dev_id)
1105{ 1117{
1106 struct exynos_dsi *dsi = (struct exynos_dsi *)dev_id; 1118 struct exynos_dsi *dsi = (struct exynos_dsi *)dev_id;
1107 struct drm_encoder *encoder = dsi->encoder; 1119 struct drm_encoder *encoder = dsi->display.encoder;
1108 1120
1109 if (dsi->state & DSIM_STATE_ENABLED) 1121 if (dsi->state & DSIM_STATE_ENABLED)
1110 exynos_drm_crtc_te_handler(encoder->crtc); 1122 exynos_drm_crtc_te_handler(encoder->crtc);
@@ -1143,6 +1155,7 @@ static int exynos_dsi_init(struct exynos_dsi *dsi)
1143static int exynos_dsi_register_te_irq(struct exynos_dsi *dsi) 1155static int exynos_dsi_register_te_irq(struct exynos_dsi *dsi)
1144{ 1156{
1145 int ret; 1157 int ret;
1158 int te_gpio_irq;
1146 1159
1147 dsi->te_gpio = of_get_named_gpio(dsi->panel_node, "te-gpios", 0); 1160 dsi->te_gpio = of_get_named_gpio(dsi->panel_node, "te-gpios", 0);
1148 if (!gpio_is_valid(dsi->te_gpio)) { 1161 if (!gpio_is_valid(dsi->te_gpio)) {
@@ -1157,14 +1170,10 @@ static int exynos_dsi_register_te_irq(struct exynos_dsi *dsi)
1157 goto out; 1170 goto out;
1158 } 1171 }
1159 1172
1160 /* 1173 te_gpio_irq = gpio_to_irq(dsi->te_gpio);
1161 * This TE GPIO IRQ should not be set to IRQ_NOAUTOEN, because panel 1174
1162 * calls drm_panel_init() first then calls mipi_dsi_attach() in probe(). 1175 irq_set_status_flags(te_gpio_irq, IRQ_NOAUTOEN);
1163 * It means that te_gpio is invalid when exynos_dsi_enable_irq() is 1176 ret = request_threaded_irq(te_gpio_irq, exynos_dsi_te_irq_handler, NULL,
1164 * called by drm_panel_init() before panel is attached.
1165 */
1166 ret = request_threaded_irq(gpio_to_irq(dsi->te_gpio),
1167 exynos_dsi_te_irq_handler, NULL,
1168 IRQF_TRIGGER_RISING, "TE", dsi); 1177 IRQF_TRIGGER_RISING, "TE", dsi);
1169 if (ret) { 1178 if (ret) {
1170 dev_err(dsi->dev, "request interrupt failed with %d\n", ret); 1179 dev_err(dsi->dev, "request interrupt failed with %d\n", ret);
@@ -1195,9 +1204,6 @@ static int exynos_dsi_host_attach(struct mipi_dsi_host *host,
1195 dsi->mode_flags = device->mode_flags; 1204 dsi->mode_flags = device->mode_flags;
1196 dsi->panel_node = device->dev.of_node; 1205 dsi->panel_node = device->dev.of_node;
1197 1206
1198 if (dsi->connector.dev)
1199 drm_helper_hpd_irq_event(dsi->connector.dev);
1200
1201 /* 1207 /*
1202 * This is a temporary solution and should be made by more generic way. 1208 * This is a temporary solution and should be made by more generic way.
1203 * 1209 *
@@ -1211,6 +1217,9 @@ static int exynos_dsi_host_attach(struct mipi_dsi_host *host,
1211 return ret; 1217 return ret;
1212 } 1218 }
1213 1219
1220 if (dsi->connector.dev)
1221 drm_helper_hpd_irq_event(dsi->connector.dev);
1222
1214 return 0; 1223 return 0;
1215} 1224}
1216 1225
@@ -1369,16 +1378,17 @@ static int exynos_dsi_enable(struct exynos_dsi *dsi)
1369 exynos_dsi_set_display_mode(dsi); 1378 exynos_dsi_set_display_mode(dsi);
1370 exynos_dsi_set_display_enable(dsi, true); 1379 exynos_dsi_set_display_enable(dsi, true);
1371 1380
1381 dsi->state |= DSIM_STATE_ENABLED;
1382
1372 ret = drm_panel_enable(dsi->panel); 1383 ret = drm_panel_enable(dsi->panel);
1373 if (ret < 0) { 1384 if (ret < 0) {
1385 dsi->state &= ~DSIM_STATE_ENABLED;
1374 exynos_dsi_set_display_enable(dsi, false); 1386 exynos_dsi_set_display_enable(dsi, false);
1375 drm_panel_unprepare(dsi->panel); 1387 drm_panel_unprepare(dsi->panel);
1376 exynos_dsi_poweroff(dsi); 1388 exynos_dsi_poweroff(dsi);
1377 return ret; 1389 return ret;
1378 } 1390 }
1379 1391
1380 dsi->state |= DSIM_STATE_ENABLED;
1381
1382 return 0; 1392 return 0;
1383} 1393}
1384 1394
@@ -1397,7 +1407,7 @@ static void exynos_dsi_disable(struct exynos_dsi *dsi)
1397 1407
1398static void exynos_dsi_dpms(struct exynos_drm_display *display, int mode) 1408static void exynos_dsi_dpms(struct exynos_drm_display *display, int mode)
1399{ 1409{
1400 struct exynos_dsi *dsi = display->ctx; 1410 struct exynos_dsi *dsi = display_to_dsi(display);
1401 1411
1402 if (dsi->panel) { 1412 if (dsi->panel) {
1403 switch (mode) { 1413 switch (mode) {
@@ -1474,7 +1484,7 @@ exynos_dsi_best_encoder(struct drm_connector *connector)
1474{ 1484{
1475 struct exynos_dsi *dsi = connector_to_dsi(connector); 1485 struct exynos_dsi *dsi = connector_to_dsi(connector);
1476 1486
1477 return dsi->encoder; 1487 return dsi->display.encoder;
1478} 1488}
1479 1489
1480static struct drm_connector_helper_funcs exynos_dsi_connector_helper_funcs = { 1490static struct drm_connector_helper_funcs exynos_dsi_connector_helper_funcs = {
@@ -1486,12 +1496,10 @@ static struct drm_connector_helper_funcs exynos_dsi_connector_helper_funcs = {
1486static int exynos_dsi_create_connector(struct exynos_drm_display *display, 1496static int exynos_dsi_create_connector(struct exynos_drm_display *display,
1487 struct drm_encoder *encoder) 1497 struct drm_encoder *encoder)
1488{ 1498{
1489 struct exynos_dsi *dsi = display->ctx; 1499 struct exynos_dsi *dsi = display_to_dsi(display);
1490 struct drm_connector *connector = &dsi->connector; 1500 struct drm_connector *connector = &dsi->connector;
1491 int ret; 1501 int ret;
1492 1502
1493 dsi->encoder = encoder;
1494
1495 connector->polled = DRM_CONNECTOR_POLL_HPD; 1503 connector->polled = DRM_CONNECTOR_POLL_HPD;
1496 1504
1497 ret = drm_connector_init(encoder->dev, connector, 1505 ret = drm_connector_init(encoder->dev, connector,
@@ -1512,7 +1520,7 @@ static int exynos_dsi_create_connector(struct exynos_drm_display *display,
1512static void exynos_dsi_mode_set(struct exynos_drm_display *display, 1520static void exynos_dsi_mode_set(struct exynos_drm_display *display,
1513 struct drm_display_mode *mode) 1521 struct drm_display_mode *mode)
1514{ 1522{
1515 struct exynos_dsi *dsi = display->ctx; 1523 struct exynos_dsi *dsi = display_to_dsi(display);
1516 struct videomode *vm = &dsi->vm; 1524 struct videomode *vm = &dsi->vm;
1517 1525
1518 vm->hactive = mode->hdisplay; 1526 vm->hactive = mode->hdisplay;
@@ -1531,10 +1539,6 @@ static struct exynos_drm_display_ops exynos_dsi_display_ops = {
1531 .dpms = exynos_dsi_dpms 1539 .dpms = exynos_dsi_dpms
1532}; 1540};
1533 1541
1534static struct exynos_drm_display exynos_dsi_display = {
1535 .type = EXYNOS_DISPLAY_TYPE_LCD,
1536 .ops = &exynos_dsi_display_ops,
1537};
1538MODULE_DEVICE_TABLE(of, exynos_dsi_of_match); 1542MODULE_DEVICE_TABLE(of, exynos_dsi_of_match);
1539 1543
1540/* of_* functions will be removed after merge of of_graph patches */ 1544/* of_* functions will be removed after merge of of_graph patches */
@@ -1640,28 +1644,28 @@ end:
1640static int exynos_dsi_bind(struct device *dev, struct device *master, 1644static int exynos_dsi_bind(struct device *dev, struct device *master,
1641 void *data) 1645 void *data)
1642{ 1646{
1647 struct exynos_drm_display *display = dev_get_drvdata(dev);
1648 struct exynos_dsi *dsi = display_to_dsi(display);
1643 struct drm_device *drm_dev = data; 1649 struct drm_device *drm_dev = data;
1644 struct exynos_dsi *dsi;
1645 int ret; 1650 int ret;
1646 1651
1647 ret = exynos_drm_create_enc_conn(drm_dev, &exynos_dsi_display); 1652 ret = exynos_drm_create_enc_conn(drm_dev, display);
1648 if (ret) { 1653 if (ret) {
1649 DRM_ERROR("Encoder create [%d] failed with %d\n", 1654 DRM_ERROR("Encoder create [%d] failed with %d\n",
1650 exynos_dsi_display.type, ret); 1655 display->type, ret);
1651 return ret; 1656 return ret;
1652 } 1657 }
1653 1658
1654 dsi = exynos_dsi_display.ctx;
1655
1656 return mipi_dsi_host_register(&dsi->dsi_host); 1659 return mipi_dsi_host_register(&dsi->dsi_host);
1657} 1660}
1658 1661
1659static void exynos_dsi_unbind(struct device *dev, struct device *master, 1662static void exynos_dsi_unbind(struct device *dev, struct device *master,
1660 void *data) 1663 void *data)
1661{ 1664{
1662 struct exynos_dsi *dsi = exynos_dsi_display.ctx; 1665 struct exynos_drm_display *display = dev_get_drvdata(dev);
1666 struct exynos_dsi *dsi = display_to_dsi(display);
1663 1667
1664 exynos_dsi_dpms(&exynos_dsi_display, DRM_MODE_DPMS_OFF); 1668 exynos_dsi_dpms(display, DRM_MODE_DPMS_OFF);
1665 1669
1666 mipi_dsi_host_unregister(&dsi->dsi_host); 1670 mipi_dsi_host_unregister(&dsi->dsi_host);
1667} 1671}
@@ -1673,22 +1677,23 @@ static const struct component_ops exynos_dsi_component_ops = {
1673 1677
1674static int exynos_dsi_probe(struct platform_device *pdev) 1678static int exynos_dsi_probe(struct platform_device *pdev)
1675{ 1679{
1680 struct device *dev = &pdev->dev;
1676 struct resource *res; 1681 struct resource *res;
1677 struct exynos_dsi *dsi; 1682 struct exynos_dsi *dsi;
1678 int ret; 1683 int ret;
1679 1684
1680 ret = exynos_drm_component_add(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR, 1685 dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL);
1681 exynos_dsi_display.type); 1686 if (!dsi)
1687 return -ENOMEM;
1688
1689 dsi->display.type = EXYNOS_DISPLAY_TYPE_LCD;
1690 dsi->display.ops = &exynos_dsi_display_ops;
1691
1692 ret = exynos_drm_component_add(dev, EXYNOS_DEVICE_TYPE_CONNECTOR,
1693 dsi->display.type);
1682 if (ret) 1694 if (ret)
1683 return ret; 1695 return ret;
1684 1696
1685 dsi = devm_kzalloc(&pdev->dev, sizeof(*dsi), GFP_KERNEL);
1686 if (!dsi) {
1687 dev_err(&pdev->dev, "failed to allocate dsi object.\n");
1688 ret = -ENOMEM;
1689 goto err_del_component;
1690 }
1691
1692 /* To be checked as invalid one */ 1697 /* To be checked as invalid one */
1693 dsi->te_gpio = -ENOENT; 1698 dsi->te_gpio = -ENOENT;
1694 1699
@@ -1697,9 +1702,9 @@ static int exynos_dsi_probe(struct platform_device *pdev)
1697 INIT_LIST_HEAD(&dsi->transfer_list); 1702 INIT_LIST_HEAD(&dsi->transfer_list);
1698 1703
1699 dsi->dsi_host.ops = &exynos_dsi_ops; 1704 dsi->dsi_host.ops = &exynos_dsi_ops;
1700 dsi->dsi_host.dev = &pdev->dev; 1705 dsi->dsi_host.dev = dev;
1701 1706
1702 dsi->dev = &pdev->dev; 1707 dsi->dev = dev;
1703 dsi->driver_data = exynos_dsi_get_driver_data(pdev); 1708 dsi->driver_data = exynos_dsi_get_driver_data(pdev);
1704 1709
1705 ret = exynos_dsi_parse_dt(dsi); 1710 ret = exynos_dsi_parse_dt(dsi);
@@ -1708,70 +1713,68 @@ static int exynos_dsi_probe(struct platform_device *pdev)
1708 1713
1709 dsi->supplies[0].supply = "vddcore"; 1714 dsi->supplies[0].supply = "vddcore";
1710 dsi->supplies[1].supply = "vddio"; 1715 dsi->supplies[1].supply = "vddio";
1711 ret = devm_regulator_bulk_get(&pdev->dev, ARRAY_SIZE(dsi->supplies), 1716 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(dsi->supplies),
1712 dsi->supplies); 1717 dsi->supplies);
1713 if (ret) { 1718 if (ret) {
1714 dev_info(&pdev->dev, "failed to get regulators: %d\n", ret); 1719 dev_info(dev, "failed to get regulators: %d\n", ret);
1715 return -EPROBE_DEFER; 1720 return -EPROBE_DEFER;
1716 } 1721 }
1717 1722
1718 dsi->pll_clk = devm_clk_get(&pdev->dev, "pll_clk"); 1723 dsi->pll_clk = devm_clk_get(dev, "pll_clk");
1719 if (IS_ERR(dsi->pll_clk)) { 1724 if (IS_ERR(dsi->pll_clk)) {
1720 dev_info(&pdev->dev, "failed to get dsi pll input clock\n"); 1725 dev_info(dev, "failed to get dsi pll input clock\n");
1721 ret = PTR_ERR(dsi->pll_clk); 1726 ret = PTR_ERR(dsi->pll_clk);
1722 goto err_del_component; 1727 goto err_del_component;
1723 } 1728 }
1724 1729
1725 dsi->bus_clk = devm_clk_get(&pdev->dev, "bus_clk"); 1730 dsi->bus_clk = devm_clk_get(dev, "bus_clk");
1726 if (IS_ERR(dsi->bus_clk)) { 1731 if (IS_ERR(dsi->bus_clk)) {
1727 dev_info(&pdev->dev, "failed to get dsi bus clock\n"); 1732 dev_info(dev, "failed to get dsi bus clock\n");
1728 ret = PTR_ERR(dsi->bus_clk); 1733 ret = PTR_ERR(dsi->bus_clk);
1729 goto err_del_component; 1734 goto err_del_component;
1730 } 1735 }
1731 1736
1732 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1737 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1733 dsi->reg_base = devm_ioremap_resource(&pdev->dev, res); 1738 dsi->reg_base = devm_ioremap_resource(dev, res);
1734 if (IS_ERR(dsi->reg_base)) { 1739 if (IS_ERR(dsi->reg_base)) {
1735 dev_err(&pdev->dev, "failed to remap io region\n"); 1740 dev_err(dev, "failed to remap io region\n");
1736 ret = PTR_ERR(dsi->reg_base); 1741 ret = PTR_ERR(dsi->reg_base);
1737 goto err_del_component; 1742 goto err_del_component;
1738 } 1743 }
1739 1744
1740 dsi->phy = devm_phy_get(&pdev->dev, "dsim"); 1745 dsi->phy = devm_phy_get(dev, "dsim");
1741 if (IS_ERR(dsi->phy)) { 1746 if (IS_ERR(dsi->phy)) {
1742 dev_info(&pdev->dev, "failed to get dsim phy\n"); 1747 dev_info(dev, "failed to get dsim phy\n");
1743 ret = PTR_ERR(dsi->phy); 1748 ret = PTR_ERR(dsi->phy);
1744 goto err_del_component; 1749 goto err_del_component;
1745 } 1750 }
1746 1751
1747 dsi->irq = platform_get_irq(pdev, 0); 1752 dsi->irq = platform_get_irq(pdev, 0);
1748 if (dsi->irq < 0) { 1753 if (dsi->irq < 0) {
1749 dev_err(&pdev->dev, "failed to request dsi irq resource\n"); 1754 dev_err(dev, "failed to request dsi irq resource\n");
1750 ret = dsi->irq; 1755 ret = dsi->irq;
1751 goto err_del_component; 1756 goto err_del_component;
1752 } 1757 }
1753 1758
1754 irq_set_status_flags(dsi->irq, IRQ_NOAUTOEN); 1759 irq_set_status_flags(dsi->irq, IRQ_NOAUTOEN);
1755 ret = devm_request_threaded_irq(&pdev->dev, dsi->irq, NULL, 1760 ret = devm_request_threaded_irq(dev, dsi->irq, NULL,
1756 exynos_dsi_irq, IRQF_ONESHOT, 1761 exynos_dsi_irq, IRQF_ONESHOT,
1757 dev_name(&pdev->dev), dsi); 1762 dev_name(dev), dsi);
1758 if (ret) { 1763 if (ret) {
1759 dev_err(&pdev->dev, "failed to request dsi irq\n"); 1764 dev_err(dev, "failed to request dsi irq\n");
1760 goto err_del_component; 1765 goto err_del_component;
1761 } 1766 }
1762 1767
1763 exynos_dsi_display.ctx = dsi; 1768 platform_set_drvdata(pdev, &dsi->display);
1764
1765 platform_set_drvdata(pdev, &exynos_dsi_display);
1766 1769
1767 ret = component_add(&pdev->dev, &exynos_dsi_component_ops); 1770 ret = component_add(dev, &exynos_dsi_component_ops);
1768 if (ret) 1771 if (ret)
1769 goto err_del_component; 1772 goto err_del_component;
1770 1773
1771 return ret; 1774 return ret;
1772 1775
1773err_del_component: 1776err_del_component:
1774 exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR); 1777 exynos_drm_component_del(dev, EXYNOS_DEVICE_TYPE_CONNECTOR);
1775 return ret; 1778 return ret;
1776} 1779}
1777 1780
diff --git a/drivers/gpu/drm/exynos/exynos_drm_encoder.h b/drivers/gpu/drm/exynos/exynos_drm_encoder.h
index b7a1620a7e79..26305d8dd93a 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_encoder.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_encoder.h
@@ -14,8 +14,6 @@
14#ifndef _EXYNOS_DRM_ENCODER_H_ 14#ifndef _EXYNOS_DRM_ENCODER_H_
15#define _EXYNOS_DRM_ENCODER_H_ 15#define _EXYNOS_DRM_ENCODER_H_
16 16
17struct exynos_drm_manager;
18
19void exynos_drm_encoder_setup(struct drm_device *dev); 17void exynos_drm_encoder_setup(struct drm_device *dev);
20struct drm_encoder *exynos_drm_encoder_create(struct drm_device *dev, 18struct drm_encoder *exynos_drm_encoder_create(struct drm_device *dev,
21 struct exynos_drm_display *mgr, 19 struct exynos_drm_display *mgr,
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index 085b066a9993..e5810d13bf9c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -84,8 +84,6 @@
84/* FIMD has totally five hardware windows. */ 84/* FIMD has totally five hardware windows. */
85#define WINDOWS_NR 5 85#define WINDOWS_NR 5
86 86
87#define get_fimd_manager(mgr) platform_get_drvdata(to_platform_device(dev))
88
89struct fimd_driver_data { 87struct fimd_driver_data {
90 unsigned int timing_base; 88 unsigned int timing_base;
91 unsigned int lcdblk_offset; 89 unsigned int lcdblk_offset;
@@ -96,6 +94,7 @@ struct fimd_driver_data {
96 unsigned int has_clksel:1; 94 unsigned int has_clksel:1;
97 unsigned int has_limited_fmt:1; 95 unsigned int has_limited_fmt:1;
98 unsigned int has_vidoutcon:1; 96 unsigned int has_vidoutcon:1;
97 unsigned int has_vtsel:1;
99}; 98};
100 99
101static struct fimd_driver_data s3c64xx_fimd_driver_data = { 100static struct fimd_driver_data s3c64xx_fimd_driver_data = {
@@ -118,6 +117,17 @@ static struct fimd_driver_data exynos4_fimd_driver_data = {
118 .lcdblk_vt_shift = 10, 117 .lcdblk_vt_shift = 10,
119 .lcdblk_bypass_shift = 1, 118 .lcdblk_bypass_shift = 1,
120 .has_shadowcon = 1, 119 .has_shadowcon = 1,
120 .has_vtsel = 1,
121};
122
123static struct fimd_driver_data exynos4415_fimd_driver_data = {
124 .timing_base = 0x20000,
125 .lcdblk_offset = 0x210,
126 .lcdblk_vt_shift = 10,
127 .lcdblk_bypass_shift = 1,
128 .has_shadowcon = 1,
129 .has_vidoutcon = 1,
130 .has_vtsel = 1,
121}; 131};
122 132
123static struct fimd_driver_data exynos5_fimd_driver_data = { 133static struct fimd_driver_data exynos5_fimd_driver_data = {
@@ -127,6 +137,7 @@ static struct fimd_driver_data exynos5_fimd_driver_data = {
127 .lcdblk_bypass_shift = 15, 137 .lcdblk_bypass_shift = 15,
128 .has_shadowcon = 1, 138 .has_shadowcon = 1,
129 .has_vidoutcon = 1, 139 .has_vidoutcon = 1,
140 .has_vtsel = 1,
130}; 141};
131 142
132struct fimd_win_data { 143struct fimd_win_data {
@@ -146,6 +157,7 @@ struct fimd_win_data {
146}; 157};
147 158
148struct fimd_context { 159struct fimd_context {
160 struct exynos_drm_manager manager;
149 struct device *dev; 161 struct device *dev;
150 struct drm_device *drm_dev; 162 struct drm_device *drm_dev;
151 struct clk *bus_clk; 163 struct clk *bus_clk;
@@ -173,6 +185,11 @@ struct fimd_context {
173 struct exynos_drm_display *display; 185 struct exynos_drm_display *display;
174}; 186};
175 187
188static inline struct fimd_context *mgr_to_fimd(struct exynos_drm_manager *mgr)
189{
190 return container_of(mgr, struct fimd_context, manager);
191}
192
176static const struct of_device_id fimd_driver_dt_match[] = { 193static const struct of_device_id fimd_driver_dt_match[] = {
177 { .compatible = "samsung,s3c6400-fimd", 194 { .compatible = "samsung,s3c6400-fimd",
178 .data = &s3c64xx_fimd_driver_data }, 195 .data = &s3c64xx_fimd_driver_data },
@@ -180,6 +197,8 @@ static const struct of_device_id fimd_driver_dt_match[] = {
180 .data = &exynos3_fimd_driver_data }, 197 .data = &exynos3_fimd_driver_data },
181 { .compatible = "samsung,exynos4210-fimd", 198 { .compatible = "samsung,exynos4210-fimd",
182 .data = &exynos4_fimd_driver_data }, 199 .data = &exynos4_fimd_driver_data },
200 { .compatible = "samsung,exynos4415-fimd",
201 .data = &exynos4415_fimd_driver_data },
183 { .compatible = "samsung,exynos5250-fimd", 202 { .compatible = "samsung,exynos5250-fimd",
184 .data = &exynos5_fimd_driver_data }, 203 .data = &exynos5_fimd_driver_data },
185 {}, 204 {},
@@ -197,7 +216,7 @@ static inline struct fimd_driver_data *drm_fimd_get_driver_data(
197 216
198static void fimd_wait_for_vblank(struct exynos_drm_manager *mgr) 217static void fimd_wait_for_vblank(struct exynos_drm_manager *mgr)
199{ 218{
200 struct fimd_context *ctx = mgr->ctx; 219 struct fimd_context *ctx = mgr_to_fimd(mgr);
201 220
202 if (ctx->suspended) 221 if (ctx->suspended)
203 return; 222 return;
@@ -214,9 +233,35 @@ static void fimd_wait_for_vblank(struct exynos_drm_manager *mgr)
214 DRM_DEBUG_KMS("vblank wait timed out.\n"); 233 DRM_DEBUG_KMS("vblank wait timed out.\n");
215} 234}
216 235
236static void fimd_enable_video_output(struct fimd_context *ctx, int win,
237 bool enable)
238{
239 u32 val = readl(ctx->regs + WINCON(win));
240
241 if (enable)
242 val |= WINCONx_ENWIN;
243 else
244 val &= ~WINCONx_ENWIN;
245
246 writel(val, ctx->regs + WINCON(win));
247}
248
249static void fimd_enable_shadow_channel_path(struct fimd_context *ctx, int win,
250 bool enable)
251{
252 u32 val = readl(ctx->regs + SHADOWCON);
253
254 if (enable)
255 val |= SHADOWCON_CHx_ENABLE(win);
256 else
257 val &= ~SHADOWCON_CHx_ENABLE(win);
258
259 writel(val, ctx->regs + SHADOWCON);
260}
261
217static void fimd_clear_channel(struct exynos_drm_manager *mgr) 262static void fimd_clear_channel(struct exynos_drm_manager *mgr)
218{ 263{
219 struct fimd_context *ctx = mgr->ctx; 264 struct fimd_context *ctx = mgr_to_fimd(mgr);
220 int win, ch_enabled = 0; 265 int win, ch_enabled = 0;
221 266
222 DRM_DEBUG_KMS("%s\n", __FILE__); 267 DRM_DEBUG_KMS("%s\n", __FILE__);
@@ -226,16 +271,12 @@ static void fimd_clear_channel(struct exynos_drm_manager *mgr)
226 u32 val = readl(ctx->regs + WINCON(win)); 271 u32 val = readl(ctx->regs + WINCON(win));
227 272
228 if (val & WINCONx_ENWIN) { 273 if (val & WINCONx_ENWIN) {
229 /* wincon */ 274 fimd_enable_video_output(ctx, win, false);
230 val &= ~WINCONx_ENWIN; 275
231 writel(val, ctx->regs + WINCON(win)); 276 if (ctx->driver_data->has_shadowcon)
232 277 fimd_enable_shadow_channel_path(ctx, win,
233 /* unprotect windows */ 278 false);
234 if (ctx->driver_data->has_shadowcon) { 279
235 val = readl(ctx->regs + SHADOWCON);
236 val &= ~SHADOWCON_CHx_ENABLE(win);
237 writel(val, ctx->regs + SHADOWCON);
238 }
239 ch_enabled = 1; 280 ch_enabled = 1;
240 } 281 }
241 } 282 }
@@ -253,7 +294,7 @@ static void fimd_clear_channel(struct exynos_drm_manager *mgr)
253static int fimd_mgr_initialize(struct exynos_drm_manager *mgr, 294static int fimd_mgr_initialize(struct exynos_drm_manager *mgr,
254 struct drm_device *drm_dev) 295 struct drm_device *drm_dev)
255{ 296{
256 struct fimd_context *ctx = mgr->ctx; 297 struct fimd_context *ctx = mgr_to_fimd(mgr);
257 struct exynos_drm_private *priv; 298 struct exynos_drm_private *priv;
258 priv = drm_dev->dev_private; 299 priv = drm_dev->dev_private;
259 300
@@ -275,7 +316,7 @@ static int fimd_mgr_initialize(struct exynos_drm_manager *mgr,
275 316
276static void fimd_mgr_remove(struct exynos_drm_manager *mgr) 317static void fimd_mgr_remove(struct exynos_drm_manager *mgr)
277{ 318{
278 struct fimd_context *ctx = mgr->ctx; 319 struct fimd_context *ctx = mgr_to_fimd(mgr);
279 320
280 /* detach this sub driver from iommu mapping if supported. */ 321 /* detach this sub driver from iommu mapping if supported. */
281 if (is_drm_iommu_supported(ctx->drm_dev)) 322 if (is_drm_iommu_supported(ctx->drm_dev))
@@ -315,14 +356,14 @@ static bool fimd_mode_fixup(struct exynos_drm_manager *mgr,
315static void fimd_mode_set(struct exynos_drm_manager *mgr, 356static void fimd_mode_set(struct exynos_drm_manager *mgr,
316 const struct drm_display_mode *in_mode) 357 const struct drm_display_mode *in_mode)
317{ 358{
318 struct fimd_context *ctx = mgr->ctx; 359 struct fimd_context *ctx = mgr_to_fimd(mgr);
319 360
320 drm_mode_copy(&ctx->mode, in_mode); 361 drm_mode_copy(&ctx->mode, in_mode);
321} 362}
322 363
323static void fimd_commit(struct exynos_drm_manager *mgr) 364static void fimd_commit(struct exynos_drm_manager *mgr)
324{ 365{
325 struct fimd_context *ctx = mgr->ctx; 366 struct fimd_context *ctx = mgr_to_fimd(mgr);
326 struct drm_display_mode *mode = &ctx->mode; 367 struct drm_display_mode *mode = &ctx->mode;
327 struct fimd_driver_data *driver_data = ctx->driver_data; 368 struct fimd_driver_data *driver_data = ctx->driver_data;
328 void *timing_base = ctx->regs + driver_data->timing_base; 369 void *timing_base = ctx->regs + driver_data->timing_base;
@@ -343,7 +384,8 @@ static void fimd_commit(struct exynos_drm_manager *mgr)
343 writel(0, timing_base + I80IFCONFBx(0)); 384 writel(0, timing_base + I80IFCONFBx(0));
344 385
345 /* set video type selection to I80 interface */ 386 /* set video type selection to I80 interface */
346 if (ctx->sysreg && regmap_update_bits(ctx->sysreg, 387 if (driver_data->has_vtsel && ctx->sysreg &&
388 regmap_update_bits(ctx->sysreg,
347 driver_data->lcdblk_offset, 389 driver_data->lcdblk_offset,
348 0x3 << driver_data->lcdblk_vt_shift, 390 0x3 << driver_data->lcdblk_vt_shift,
349 0x1 << driver_data->lcdblk_vt_shift)) { 391 0x1 << driver_data->lcdblk_vt_shift)) {
@@ -421,7 +463,7 @@ static void fimd_commit(struct exynos_drm_manager *mgr)
421 463
422static int fimd_enable_vblank(struct exynos_drm_manager *mgr) 464static int fimd_enable_vblank(struct exynos_drm_manager *mgr)
423{ 465{
424 struct fimd_context *ctx = mgr->ctx; 466 struct fimd_context *ctx = mgr_to_fimd(mgr);
425 u32 val; 467 u32 val;
426 468
427 if (ctx->suspended) 469 if (ctx->suspended)
@@ -431,12 +473,19 @@ static int fimd_enable_vblank(struct exynos_drm_manager *mgr)
431 val = readl(ctx->regs + VIDINTCON0); 473 val = readl(ctx->regs + VIDINTCON0);
432 474
433 val |= VIDINTCON0_INT_ENABLE; 475 val |= VIDINTCON0_INT_ENABLE;
434 val |= VIDINTCON0_INT_FRAME;
435 476
436 val &= ~VIDINTCON0_FRAMESEL0_MASK; 477 if (ctx->i80_if) {
437 val |= VIDINTCON0_FRAMESEL0_VSYNC; 478 val |= VIDINTCON0_INT_I80IFDONE;
438 val &= ~VIDINTCON0_FRAMESEL1_MASK; 479 val |= VIDINTCON0_INT_SYSMAINCON;
439 val |= VIDINTCON0_FRAMESEL1_NONE; 480 val &= ~VIDINTCON0_INT_SYSSUBCON;
481 } else {
482 val |= VIDINTCON0_INT_FRAME;
483
484 val &= ~VIDINTCON0_FRAMESEL0_MASK;
485 val |= VIDINTCON0_FRAMESEL0_VSYNC;
486 val &= ~VIDINTCON0_FRAMESEL1_MASK;
487 val |= VIDINTCON0_FRAMESEL1_NONE;
488 }
440 489
441 writel(val, ctx->regs + VIDINTCON0); 490 writel(val, ctx->regs + VIDINTCON0);
442 } 491 }
@@ -446,7 +495,7 @@ static int fimd_enable_vblank(struct exynos_drm_manager *mgr)
446 495
447static void fimd_disable_vblank(struct exynos_drm_manager *mgr) 496static void fimd_disable_vblank(struct exynos_drm_manager *mgr)
448{ 497{
449 struct fimd_context *ctx = mgr->ctx; 498 struct fimd_context *ctx = mgr_to_fimd(mgr);
450 u32 val; 499 u32 val;
451 500
452 if (ctx->suspended) 501 if (ctx->suspended)
@@ -455,9 +504,15 @@ static void fimd_disable_vblank(struct exynos_drm_manager *mgr)
455 if (test_and_clear_bit(0, &ctx->irq_flags)) { 504 if (test_and_clear_bit(0, &ctx->irq_flags)) {
456 val = readl(ctx->regs + VIDINTCON0); 505 val = readl(ctx->regs + VIDINTCON0);
457 506
458 val &= ~VIDINTCON0_INT_FRAME;
459 val &= ~VIDINTCON0_INT_ENABLE; 507 val &= ~VIDINTCON0_INT_ENABLE;
460 508
509 if (ctx->i80_if) {
510 val &= ~VIDINTCON0_INT_I80IFDONE;
511 val &= ~VIDINTCON0_INT_SYSMAINCON;
512 val &= ~VIDINTCON0_INT_SYSSUBCON;
513 } else
514 val &= ~VIDINTCON0_INT_FRAME;
515
461 writel(val, ctx->regs + VIDINTCON0); 516 writel(val, ctx->regs + VIDINTCON0);
462 } 517 }
463} 518}
@@ -465,7 +520,7 @@ static void fimd_disable_vblank(struct exynos_drm_manager *mgr)
465static void fimd_win_mode_set(struct exynos_drm_manager *mgr, 520static void fimd_win_mode_set(struct exynos_drm_manager *mgr,
466 struct exynos_drm_overlay *overlay) 521 struct exynos_drm_overlay *overlay)
467{ 522{
468 struct fimd_context *ctx = mgr->ctx; 523 struct fimd_context *ctx = mgr_to_fimd(mgr);
469 struct fimd_win_data *win_data; 524 struct fimd_win_data *win_data;
470 int win; 525 int win;
471 unsigned long offset; 526 unsigned long offset;
@@ -623,7 +678,7 @@ static void fimd_shadow_protect_win(struct fimd_context *ctx,
623 678
624static void fimd_win_commit(struct exynos_drm_manager *mgr, int zpos) 679static void fimd_win_commit(struct exynos_drm_manager *mgr, int zpos)
625{ 680{
626 struct fimd_context *ctx = mgr->ctx; 681 struct fimd_context *ctx = mgr_to_fimd(mgr);
627 struct fimd_win_data *win_data; 682 struct fimd_win_data *win_data;
628 int win = zpos; 683 int win = zpos;
629 unsigned long val, alpha, size; 684 unsigned long val, alpha, size;
@@ -730,20 +785,14 @@ static void fimd_win_commit(struct exynos_drm_manager *mgr, int zpos)
730 if (win != 0) 785 if (win != 0)
731 fimd_win_set_colkey(ctx, win); 786 fimd_win_set_colkey(ctx, win);
732 787
733 /* wincon */ 788 fimd_enable_video_output(ctx, win, true);
734 val = readl(ctx->regs + WINCON(win)); 789
735 val |= WINCONx_ENWIN; 790 if (ctx->driver_data->has_shadowcon)
736 writel(val, ctx->regs + WINCON(win)); 791 fimd_enable_shadow_channel_path(ctx, win, true);
737 792
738 /* Enable DMA channel and unprotect windows */ 793 /* Enable DMA channel and unprotect windows */
739 fimd_shadow_protect_win(ctx, win, false); 794 fimd_shadow_protect_win(ctx, win, false);
740 795
741 if (ctx->driver_data->has_shadowcon) {
742 val = readl(ctx->regs + SHADOWCON);
743 val |= SHADOWCON_CHx_ENABLE(win);
744 writel(val, ctx->regs + SHADOWCON);
745 }
746
747 win_data->enabled = true; 796 win_data->enabled = true;
748 797
749 if (ctx->i80_if) 798 if (ctx->i80_if)
@@ -752,10 +801,9 @@ static void fimd_win_commit(struct exynos_drm_manager *mgr, int zpos)
752 801
753static void fimd_win_disable(struct exynos_drm_manager *mgr, int zpos) 802static void fimd_win_disable(struct exynos_drm_manager *mgr, int zpos)
754{ 803{
755 struct fimd_context *ctx = mgr->ctx; 804 struct fimd_context *ctx = mgr_to_fimd(mgr);
756 struct fimd_win_data *win_data; 805 struct fimd_win_data *win_data;
757 int win = zpos; 806 int win = zpos;
758 u32 val;
759 807
760 if (win == DEFAULT_ZPOS) 808 if (win == DEFAULT_ZPOS)
761 win = ctx->default_win; 809 win = ctx->default_win;
@@ -774,18 +822,12 @@ static void fimd_win_disable(struct exynos_drm_manager *mgr, int zpos)
774 /* protect windows */ 822 /* protect windows */
775 fimd_shadow_protect_win(ctx, win, true); 823 fimd_shadow_protect_win(ctx, win, true);
776 824
777 /* wincon */ 825 fimd_enable_video_output(ctx, win, false);
778 val = readl(ctx->regs + WINCON(win));
779 val &= ~WINCONx_ENWIN;
780 writel(val, ctx->regs + WINCON(win));
781 826
782 /* unprotect windows */ 827 if (ctx->driver_data->has_shadowcon)
783 if (ctx->driver_data->has_shadowcon) { 828 fimd_enable_shadow_channel_path(ctx, win, false);
784 val = readl(ctx->regs + SHADOWCON);
785 val &= ~SHADOWCON_CHx_ENABLE(win);
786 writel(val, ctx->regs + SHADOWCON);
787 }
788 829
830 /* unprotect windows */
789 fimd_shadow_protect_win(ctx, win, false); 831 fimd_shadow_protect_win(ctx, win, false);
790 832
791 win_data->enabled = false; 833 win_data->enabled = false;
@@ -793,7 +835,7 @@ static void fimd_win_disable(struct exynos_drm_manager *mgr, int zpos)
793 835
794static void fimd_window_suspend(struct exynos_drm_manager *mgr) 836static void fimd_window_suspend(struct exynos_drm_manager *mgr)
795{ 837{
796 struct fimd_context *ctx = mgr->ctx; 838 struct fimd_context *ctx = mgr_to_fimd(mgr);
797 struct fimd_win_data *win_data; 839 struct fimd_win_data *win_data;
798 int i; 840 int i;
799 841
@@ -803,12 +845,11 @@ static void fimd_window_suspend(struct exynos_drm_manager *mgr)
803 if (win_data->enabled) 845 if (win_data->enabled)
804 fimd_win_disable(mgr, i); 846 fimd_win_disable(mgr, i);
805 } 847 }
806 fimd_wait_for_vblank(mgr);
807} 848}
808 849
809static void fimd_window_resume(struct exynos_drm_manager *mgr) 850static void fimd_window_resume(struct exynos_drm_manager *mgr)
810{ 851{
811 struct fimd_context *ctx = mgr->ctx; 852 struct fimd_context *ctx = mgr_to_fimd(mgr);
812 struct fimd_win_data *win_data; 853 struct fimd_win_data *win_data;
813 int i; 854 int i;
814 855
@@ -821,7 +862,7 @@ static void fimd_window_resume(struct exynos_drm_manager *mgr)
821 862
822static void fimd_apply(struct exynos_drm_manager *mgr) 863static void fimd_apply(struct exynos_drm_manager *mgr)
823{ 864{
824 struct fimd_context *ctx = mgr->ctx; 865 struct fimd_context *ctx = mgr_to_fimd(mgr);
825 struct fimd_win_data *win_data; 866 struct fimd_win_data *win_data;
826 int i; 867 int i;
827 868
@@ -838,7 +879,7 @@ static void fimd_apply(struct exynos_drm_manager *mgr)
838 879
839static int fimd_poweron(struct exynos_drm_manager *mgr) 880static int fimd_poweron(struct exynos_drm_manager *mgr)
840{ 881{
841 struct fimd_context *ctx = mgr->ctx; 882 struct fimd_context *ctx = mgr_to_fimd(mgr);
842 int ret; 883 int ret;
843 884
844 if (!ctx->suspended) 885 if (!ctx->suspended)
@@ -886,7 +927,7 @@ bus_clk_err:
886 927
887static int fimd_poweroff(struct exynos_drm_manager *mgr) 928static int fimd_poweroff(struct exynos_drm_manager *mgr)
888{ 929{
889 struct fimd_context *ctx = mgr->ctx; 930 struct fimd_context *ctx = mgr_to_fimd(mgr);
890 931
891 if (ctx->suspended) 932 if (ctx->suspended)
892 return 0; 933 return 0;
@@ -928,39 +969,41 @@ static void fimd_dpms(struct exynos_drm_manager *mgr, int mode)
928 969
929static void fimd_trigger(struct device *dev) 970static void fimd_trigger(struct device *dev)
930{ 971{
931 struct exynos_drm_manager *mgr = get_fimd_manager(dev); 972 struct fimd_context *ctx = dev_get_drvdata(dev);
932 struct fimd_context *ctx = mgr->ctx;
933 struct fimd_driver_data *driver_data = ctx->driver_data; 973 struct fimd_driver_data *driver_data = ctx->driver_data;
934 void *timing_base = ctx->regs + driver_data->timing_base; 974 void *timing_base = ctx->regs + driver_data->timing_base;
935 u32 reg; 975 u32 reg;
936 976
937 atomic_set(&ctx->triggering, 1); 977 /*
978 * Skips triggering if in triggering state, because multiple triggering
979 * requests can cause panel reset.
980 */
981 if (atomic_read(&ctx->triggering))
982 return;
938 983
939 reg = readl(ctx->regs + VIDINTCON0); 984 /* Enters triggering mode */
940 reg |= (VIDINTCON0_INT_ENABLE | VIDINTCON0_INT_I80IFDONE | 985 atomic_set(&ctx->triggering, 1);
941 VIDINTCON0_INT_SYSMAINCON);
942 writel(reg, ctx->regs + VIDINTCON0);
943 986
944 reg = readl(timing_base + TRIGCON); 987 reg = readl(timing_base + TRIGCON);
945 reg |= (TRGMODE_I80_RGB_ENABLE_I80 | SWTRGCMD_I80_RGB_ENABLE); 988 reg |= (TRGMODE_I80_RGB_ENABLE_I80 | SWTRGCMD_I80_RGB_ENABLE);
946 writel(reg, timing_base + TRIGCON); 989 writel(reg, timing_base + TRIGCON);
990
991 /*
992 * Exits triggering mode if vblank is not enabled yet, because when the
993 * VIDINTCON0 register is not set, it can not exit from triggering mode.
994 */
995 if (!test_bit(0, &ctx->irq_flags))
996 atomic_set(&ctx->triggering, 0);
947} 997}
948 998
949static void fimd_te_handler(struct exynos_drm_manager *mgr) 999static void fimd_te_handler(struct exynos_drm_manager *mgr)
950{ 1000{
951 struct fimd_context *ctx = mgr->ctx; 1001 struct fimd_context *ctx = mgr_to_fimd(mgr);
952 1002
953 /* Checks the crtc is detached already from encoder */ 1003 /* Checks the crtc is detached already from encoder */
954 if (ctx->pipe < 0 || !ctx->drm_dev) 1004 if (ctx->pipe < 0 || !ctx->drm_dev)
955 return; 1005 return;
956 1006
957 /*
958 * Skips to trigger if in triggering state, because multiple triggering
959 * requests can cause panel reset.
960 */
961 if (atomic_read(&ctx->triggering))
962 return;
963
964 /* 1007 /*
965 * If there is a page flip request, triggers and handles the page flip 1008 * If there is a page flip request, triggers and handles the page flip
966 * event so that current fb can be updated into panel GRAM. 1009 * event so that current fb can be updated into panel GRAM.
@@ -972,10 +1015,10 @@ static void fimd_te_handler(struct exynos_drm_manager *mgr)
972 if (atomic_read(&ctx->wait_vsync_event)) { 1015 if (atomic_read(&ctx->wait_vsync_event)) {
973 atomic_set(&ctx->wait_vsync_event, 0); 1016 atomic_set(&ctx->wait_vsync_event, 0);
974 wake_up(&ctx->wait_vsync_queue); 1017 wake_up(&ctx->wait_vsync_queue);
975
976 if (!atomic_read(&ctx->triggering))
977 drm_handle_vblank(ctx->drm_dev, ctx->pipe);
978 } 1018 }
1019
1020 if (test_bit(0, &ctx->irq_flags))
1021 drm_handle_vblank(ctx->drm_dev, ctx->pipe);
979} 1022}
980 1023
981static struct exynos_drm_manager_ops fimd_manager_ops = { 1024static struct exynos_drm_manager_ops fimd_manager_ops = {
@@ -992,11 +1035,6 @@ static struct exynos_drm_manager_ops fimd_manager_ops = {
992 .te_handler = fimd_te_handler, 1035 .te_handler = fimd_te_handler,
993}; 1036};
994 1037
995static struct exynos_drm_manager fimd_manager = {
996 .type = EXYNOS_DISPLAY_TYPE_LCD,
997 .ops = &fimd_manager_ops,
998};
999
1000static irqreturn_t fimd_irq_handler(int irq, void *dev_id) 1038static irqreturn_t fimd_irq_handler(int irq, void *dev_id)
1001{ 1039{
1002 struct fimd_context *ctx = (struct fimd_context *)dev_id; 1040 struct fimd_context *ctx = (struct fimd_context *)dev_id;
@@ -1013,16 +1051,10 @@ static irqreturn_t fimd_irq_handler(int irq, void *dev_id)
1013 goto out; 1051 goto out;
1014 1052
1015 if (ctx->i80_if) { 1053 if (ctx->i80_if) {
1016 /* unset I80 frame done interrupt */ 1054 exynos_drm_crtc_finish_pageflip(ctx->drm_dev, ctx->pipe);
1017 val = readl(ctx->regs + VIDINTCON0);
1018 val &= ~(VIDINTCON0_INT_I80IFDONE | VIDINTCON0_INT_SYSMAINCON);
1019 writel(val, ctx->regs + VIDINTCON0);
1020 1055
1021 /* exit triggering mode */ 1056 /* Exits triggering mode */
1022 atomic_set(&ctx->triggering, 0); 1057 atomic_set(&ctx->triggering, 0);
1023
1024 drm_handle_vblank(ctx->drm_dev, ctx->pipe);
1025 exynos_drm_crtc_finish_pageflip(ctx->drm_dev, ctx->pipe);
1026 } else { 1058 } else {
1027 drm_handle_vblank(ctx->drm_dev, ctx->pipe); 1059 drm_handle_vblank(ctx->drm_dev, ctx->pipe);
1028 exynos_drm_crtc_finish_pageflip(ctx->drm_dev, ctx->pipe); 1060 exynos_drm_crtc_finish_pageflip(ctx->drm_dev, ctx->pipe);
@@ -1040,11 +1072,11 @@ out:
1040 1072
1041static int fimd_bind(struct device *dev, struct device *master, void *data) 1073static int fimd_bind(struct device *dev, struct device *master, void *data)
1042{ 1074{
1043 struct fimd_context *ctx = fimd_manager.ctx; 1075 struct fimd_context *ctx = dev_get_drvdata(dev);
1044 struct drm_device *drm_dev = data; 1076 struct drm_device *drm_dev = data;
1045 1077
1046 fimd_mgr_initialize(&fimd_manager, drm_dev); 1078 fimd_mgr_initialize(&ctx->manager, drm_dev);
1047 exynos_drm_crtc_create(&fimd_manager); 1079 exynos_drm_crtc_create(&ctx->manager);
1048 if (ctx->display) 1080 if (ctx->display)
1049 exynos_drm_create_enc_conn(drm_dev, ctx->display); 1081 exynos_drm_create_enc_conn(drm_dev, ctx->display);
1050 1082
@@ -1055,15 +1087,14 @@ static int fimd_bind(struct device *dev, struct device *master, void *data)
1055static void fimd_unbind(struct device *dev, struct device *master, 1087static void fimd_unbind(struct device *dev, struct device *master,
1056 void *data) 1088 void *data)
1057{ 1089{
1058 struct exynos_drm_manager *mgr = dev_get_drvdata(dev); 1090 struct fimd_context *ctx = dev_get_drvdata(dev);
1059 struct fimd_context *ctx = fimd_manager.ctx;
1060 1091
1061 fimd_dpms(mgr, DRM_MODE_DPMS_OFF); 1092 fimd_dpms(&ctx->manager, DRM_MODE_DPMS_OFF);
1062 1093
1063 if (ctx->display) 1094 if (ctx->display)
1064 exynos_dpi_remove(dev); 1095 exynos_dpi_remove(ctx->display);
1065 1096
1066 fimd_mgr_remove(mgr); 1097 fimd_mgr_remove(&ctx->manager);
1067} 1098}
1068 1099
1069static const struct component_ops fimd_component_ops = { 1100static const struct component_ops fimd_component_ops = {
@@ -1079,21 +1110,20 @@ static int fimd_probe(struct platform_device *pdev)
1079 struct resource *res; 1110 struct resource *res;
1080 int ret = -EINVAL; 1111 int ret = -EINVAL;
1081 1112
1082 ret = exynos_drm_component_add(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC, 1113 if (!dev->of_node)
1083 fimd_manager.type); 1114 return -ENODEV;
1084 if (ret)
1085 return ret;
1086
1087 if (!dev->of_node) {
1088 ret = -ENODEV;
1089 goto err_del_component;
1090 }
1091 1115
1092 ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); 1116 ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
1093 if (!ctx) { 1117 if (!ctx)
1094 ret = -ENOMEM; 1118 return -ENOMEM;
1095 goto err_del_component; 1119
1096 } 1120 ctx->manager.type = EXYNOS_DISPLAY_TYPE_LCD;
1121 ctx->manager.ops = &fimd_manager_ops;
1122
1123 ret = exynos_drm_component_add(dev, EXYNOS_DEVICE_TYPE_CRTC,
1124 ctx->manager.type);
1125 if (ret)
1126 return ret;
1097 1127
1098 ctx->dev = dev; 1128 ctx->dev = dev;
1099 ctx->suspended = true; 1129 ctx->suspended = true;
@@ -1182,27 +1212,27 @@ static int fimd_probe(struct platform_device *pdev)
1182 init_waitqueue_head(&ctx->wait_vsync_queue); 1212 init_waitqueue_head(&ctx->wait_vsync_queue);
1183 atomic_set(&ctx->wait_vsync_event, 0); 1213 atomic_set(&ctx->wait_vsync_event, 0);
1184 1214
1185 platform_set_drvdata(pdev, &fimd_manager); 1215 platform_set_drvdata(pdev, ctx);
1186
1187 fimd_manager.ctx = ctx;
1188 1216
1189 ctx->display = exynos_dpi_probe(dev); 1217 ctx->display = exynos_dpi_probe(dev);
1190 if (IS_ERR(ctx->display)) 1218 if (IS_ERR(ctx->display)) {
1191 return PTR_ERR(ctx->display); 1219 ret = PTR_ERR(ctx->display);
1220 goto err_del_component;
1221 }
1192 1222
1193 pm_runtime_enable(&pdev->dev); 1223 pm_runtime_enable(dev);
1194 1224
1195 ret = component_add(&pdev->dev, &fimd_component_ops); 1225 ret = component_add(dev, &fimd_component_ops);
1196 if (ret) 1226 if (ret)
1197 goto err_disable_pm_runtime; 1227 goto err_disable_pm_runtime;
1198 1228
1199 return ret; 1229 return ret;
1200 1230
1201err_disable_pm_runtime: 1231err_disable_pm_runtime:
1202 pm_runtime_disable(&pdev->dev); 1232 pm_runtime_disable(dev);
1203 1233
1204err_del_component: 1234err_del_component:
1205 exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC); 1235 exynos_drm_component_del(dev, EXYNOS_DEVICE_TYPE_CRTC);
1206 return ret; 1236 return ret;
1207} 1237}
1208 1238
diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
index df7a77d3eff8..6ff8599f6cbf 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
@@ -302,9 +302,12 @@ static void g2d_fini_cmdlist(struct g2d_data *g2d)
302 struct exynos_drm_subdrv *subdrv = &g2d->subdrv; 302 struct exynos_drm_subdrv *subdrv = &g2d->subdrv;
303 303
304 kfree(g2d->cmdlist_node); 304 kfree(g2d->cmdlist_node);
305 dma_free_attrs(subdrv->drm_dev->dev, G2D_CMDLIST_POOL_SIZE, 305
306 g2d->cmdlist_pool_virt, 306 if (g2d->cmdlist_pool_virt && g2d->cmdlist_pool) {
307 g2d->cmdlist_pool, &g2d->cmdlist_dma_attrs); 307 dma_free_attrs(subdrv->drm_dev->dev, G2D_CMDLIST_POOL_SIZE,
308 g2d->cmdlist_pool_virt,
309 g2d->cmdlist_pool, &g2d->cmdlist_dma_attrs);
310 }
308} 311}
309 312
310static struct g2d_cmdlist_node *g2d_get_cmdlist(struct g2d_data *g2d) 313static struct g2d_cmdlist_node *g2d_get_cmdlist(struct g2d_data *g2d)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_iommu.h b/drivers/gpu/drm/exynos/exynos_drm_iommu.h
index 72376d41c512..35d25889b476 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_iommu.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_iommu.h
@@ -40,7 +40,6 @@ static inline bool is_drm_iommu_supported(struct drm_device *drm_dev)
40 40
41#else 41#else
42 42
43struct dma_iommu_mapping;
44static inline int drm_create_iommu_mapping(struct drm_device *drm_dev) 43static inline int drm_create_iommu_mapping(struct drm_device *drm_dev)
45{ 44{
46 return 0; 45 return 0;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
index 00d74b18f7cb..d5ad17dfc24d 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_ipp.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
@@ -426,18 +426,21 @@ int exynos_drm_ipp_set_property(struct drm_device *drm_dev, void *data,
426 c_node->start_work = ipp_create_cmd_work(); 426 c_node->start_work = ipp_create_cmd_work();
427 if (IS_ERR(c_node->start_work)) { 427 if (IS_ERR(c_node->start_work)) {
428 DRM_ERROR("failed to create start work.\n"); 428 DRM_ERROR("failed to create start work.\n");
429 ret = PTR_ERR(c_node->start_work);
429 goto err_remove_id; 430 goto err_remove_id;
430 } 431 }
431 432
432 c_node->stop_work = ipp_create_cmd_work(); 433 c_node->stop_work = ipp_create_cmd_work();
433 if (IS_ERR(c_node->stop_work)) { 434 if (IS_ERR(c_node->stop_work)) {
434 DRM_ERROR("failed to create stop work.\n"); 435 DRM_ERROR("failed to create stop work.\n");
436 ret = PTR_ERR(c_node->stop_work);
435 goto err_free_start; 437 goto err_free_start;
436 } 438 }
437 439
438 c_node->event_work = ipp_create_event_work(); 440 c_node->event_work = ipp_create_event_work();
439 if (IS_ERR(c_node->event_work)) { 441 if (IS_ERR(c_node->event_work)) {
440 DRM_ERROR("failed to create event work.\n"); 442 DRM_ERROR("failed to create event work.\n");
443 ret = PTR_ERR(c_node->event_work);
441 goto err_free_stop; 444 goto err_free_stop;
442 } 445 }
443 446
diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
index 50faf913e574..45899fb63272 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
@@ -14,6 +14,7 @@
14 14
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/component.h>
17 18
18#include <drm/exynos_drm.h> 19#include <drm/exynos_drm.h>
19 20
@@ -28,7 +29,6 @@
28/* vidi has totally three virtual windows. */ 29/* vidi has totally three virtual windows. */
29#define WINDOWS_NR 3 30#define WINDOWS_NR 3
30 31
31#define get_vidi_mgr(dev) platform_get_drvdata(to_platform_device(dev))
32#define ctx_from_connector(c) container_of(c, struct vidi_context, \ 32#define ctx_from_connector(c) container_of(c, struct vidi_context, \
33 connector) 33 connector)
34 34
@@ -47,11 +47,13 @@ struct vidi_win_data {
47}; 47};
48 48
49struct vidi_context { 49struct vidi_context {
50 struct exynos_drm_manager manager;
51 struct exynos_drm_display display;
52 struct platform_device *pdev;
50 struct drm_device *drm_dev; 53 struct drm_device *drm_dev;
51 struct drm_crtc *crtc; 54 struct drm_crtc *crtc;
52 struct drm_encoder *encoder; 55 struct drm_encoder *encoder;
53 struct drm_connector connector; 56 struct drm_connector connector;
54 struct exynos_drm_subdrv subdrv;
55 struct vidi_win_data win_data[WINDOWS_NR]; 57 struct vidi_win_data win_data[WINDOWS_NR];
56 struct edid *raw_edid; 58 struct edid *raw_edid;
57 unsigned int clkdiv; 59 unsigned int clkdiv;
@@ -66,6 +68,16 @@ struct vidi_context {
66 int pipe; 68 int pipe;
67}; 69};
68 70
71static inline struct vidi_context *manager_to_vidi(struct exynos_drm_manager *m)
72{
73 return container_of(m, struct vidi_context, manager);
74}
75
76static inline struct vidi_context *display_to_vidi(struct exynos_drm_display *d)
77{
78 return container_of(d, struct vidi_context, display);
79}
80
69static const char fake_edid_info[] = { 81static const char fake_edid_info[] = {
70 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x4c, 0x2d, 0x05, 0x05, 82 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x4c, 0x2d, 0x05, 0x05,
71 0x00, 0x00, 0x00, 0x00, 0x30, 0x12, 0x01, 0x03, 0x80, 0x10, 0x09, 0x78, 83 0x00, 0x00, 0x00, 0x00, 0x30, 0x12, 0x01, 0x03, 0x80, 0x10, 0x09, 0x78,
@@ -93,7 +105,7 @@ static const char fake_edid_info[] = {
93 105
94static void vidi_apply(struct exynos_drm_manager *mgr) 106static void vidi_apply(struct exynos_drm_manager *mgr)
95{ 107{
96 struct vidi_context *ctx = mgr->ctx; 108 struct vidi_context *ctx = manager_to_vidi(mgr);
97 struct exynos_drm_manager_ops *mgr_ops = mgr->ops; 109 struct exynos_drm_manager_ops *mgr_ops = mgr->ops;
98 struct vidi_win_data *win_data; 110 struct vidi_win_data *win_data;
99 int i; 111 int i;
@@ -110,7 +122,7 @@ static void vidi_apply(struct exynos_drm_manager *mgr)
110 122
111static void vidi_commit(struct exynos_drm_manager *mgr) 123static void vidi_commit(struct exynos_drm_manager *mgr)
112{ 124{
113 struct vidi_context *ctx = mgr->ctx; 125 struct vidi_context *ctx = manager_to_vidi(mgr);
114 126
115 if (ctx->suspended) 127 if (ctx->suspended)
116 return; 128 return;
@@ -118,7 +130,7 @@ static void vidi_commit(struct exynos_drm_manager *mgr)
118 130
119static int vidi_enable_vblank(struct exynos_drm_manager *mgr) 131static int vidi_enable_vblank(struct exynos_drm_manager *mgr)
120{ 132{
121 struct vidi_context *ctx = mgr->ctx; 133 struct vidi_context *ctx = manager_to_vidi(mgr);
122 134
123 if (ctx->suspended) 135 if (ctx->suspended)
124 return -EPERM; 136 return -EPERM;
@@ -140,7 +152,7 @@ static int vidi_enable_vblank(struct exynos_drm_manager *mgr)
140 152
141static void vidi_disable_vblank(struct exynos_drm_manager *mgr) 153static void vidi_disable_vblank(struct exynos_drm_manager *mgr)
142{ 154{
143 struct vidi_context *ctx = mgr->ctx; 155 struct vidi_context *ctx = manager_to_vidi(mgr);
144 156
145 if (ctx->suspended) 157 if (ctx->suspended)
146 return; 158 return;
@@ -152,7 +164,7 @@ static void vidi_disable_vblank(struct exynos_drm_manager *mgr)
152static void vidi_win_mode_set(struct exynos_drm_manager *mgr, 164static void vidi_win_mode_set(struct exynos_drm_manager *mgr,
153 struct exynos_drm_overlay *overlay) 165 struct exynos_drm_overlay *overlay)
154{ 166{
155 struct vidi_context *ctx = mgr->ctx; 167 struct vidi_context *ctx = manager_to_vidi(mgr);
156 struct vidi_win_data *win_data; 168 struct vidi_win_data *win_data;
157 int win; 169 int win;
158 unsigned long offset; 170 unsigned long offset;
@@ -204,7 +216,7 @@ static void vidi_win_mode_set(struct exynos_drm_manager *mgr,
204 216
205static void vidi_win_commit(struct exynos_drm_manager *mgr, int zpos) 217static void vidi_win_commit(struct exynos_drm_manager *mgr, int zpos)
206{ 218{
207 struct vidi_context *ctx = mgr->ctx; 219 struct vidi_context *ctx = manager_to_vidi(mgr);
208 struct vidi_win_data *win_data; 220 struct vidi_win_data *win_data;
209 int win = zpos; 221 int win = zpos;
210 222
@@ -229,7 +241,7 @@ static void vidi_win_commit(struct exynos_drm_manager *mgr, int zpos)
229 241
230static void vidi_win_disable(struct exynos_drm_manager *mgr, int zpos) 242static void vidi_win_disable(struct exynos_drm_manager *mgr, int zpos)
231{ 243{
232 struct vidi_context *ctx = mgr->ctx; 244 struct vidi_context *ctx = manager_to_vidi(mgr);
233 struct vidi_win_data *win_data; 245 struct vidi_win_data *win_data;
234 int win = zpos; 246 int win = zpos;
235 247
@@ -247,7 +259,7 @@ static void vidi_win_disable(struct exynos_drm_manager *mgr, int zpos)
247 259
248static int vidi_power_on(struct exynos_drm_manager *mgr, bool enable) 260static int vidi_power_on(struct exynos_drm_manager *mgr, bool enable)
249{ 261{
250 struct vidi_context *ctx = mgr->ctx; 262 struct vidi_context *ctx = manager_to_vidi(mgr);
251 263
252 DRM_DEBUG_KMS("%s\n", __FILE__); 264 DRM_DEBUG_KMS("%s\n", __FILE__);
253 265
@@ -271,7 +283,7 @@ static int vidi_power_on(struct exynos_drm_manager *mgr, bool enable)
271 283
272static void vidi_dpms(struct exynos_drm_manager *mgr, int mode) 284static void vidi_dpms(struct exynos_drm_manager *mgr, int mode)
273{ 285{
274 struct vidi_context *ctx = mgr->ctx; 286 struct vidi_context *ctx = manager_to_vidi(mgr);
275 287
276 DRM_DEBUG_KMS("%d\n", mode); 288 DRM_DEBUG_KMS("%d\n", mode);
277 289
@@ -297,7 +309,7 @@ static void vidi_dpms(struct exynos_drm_manager *mgr, int mode)
297static int vidi_mgr_initialize(struct exynos_drm_manager *mgr, 309static int vidi_mgr_initialize(struct exynos_drm_manager *mgr,
298 struct drm_device *drm_dev) 310 struct drm_device *drm_dev)
299{ 311{
300 struct vidi_context *ctx = mgr->ctx; 312 struct vidi_context *ctx = manager_to_vidi(mgr);
301 struct exynos_drm_private *priv = drm_dev->dev_private; 313 struct exynos_drm_private *priv = drm_dev->dev_private;
302 314
303 mgr->drm_dev = ctx->drm_dev = drm_dev; 315 mgr->drm_dev = ctx->drm_dev = drm_dev;
@@ -316,11 +328,6 @@ static struct exynos_drm_manager_ops vidi_manager_ops = {
316 .win_disable = vidi_win_disable, 328 .win_disable = vidi_win_disable,
317}; 329};
318 330
319static struct exynos_drm_manager vidi_manager = {
320 .type = EXYNOS_DISPLAY_TYPE_VIDI,
321 .ops = &vidi_manager_ops,
322};
323
324static void vidi_fake_vblank_handler(struct work_struct *work) 331static void vidi_fake_vblank_handler(struct work_struct *work)
325{ 332{
326 struct vidi_context *ctx = container_of(work, struct vidi_context, 333 struct vidi_context *ctx = container_of(work, struct vidi_context,
@@ -349,9 +356,8 @@ static void vidi_fake_vblank_handler(struct work_struct *work)
349static int vidi_show_connection(struct device *dev, 356static int vidi_show_connection(struct device *dev,
350 struct device_attribute *attr, char *buf) 357 struct device_attribute *attr, char *buf)
351{ 358{
359 struct vidi_context *ctx = dev_get_drvdata(dev);
352 int rc; 360 int rc;
353 struct exynos_drm_manager *mgr = get_vidi_mgr(dev);
354 struct vidi_context *ctx = mgr->ctx;
355 361
356 mutex_lock(&ctx->lock); 362 mutex_lock(&ctx->lock);
357 363
@@ -366,8 +372,7 @@ static int vidi_store_connection(struct device *dev,
366 struct device_attribute *attr, 372 struct device_attribute *attr,
367 const char *buf, size_t len) 373 const char *buf, size_t len)
368{ 374{
369 struct exynos_drm_manager *mgr = get_vidi_mgr(dev); 375 struct vidi_context *ctx = dev_get_drvdata(dev);
370 struct vidi_context *ctx = mgr->ctx;
371 int ret; 376 int ret;
372 377
373 ret = kstrtoint(buf, 0, &ctx->connected); 378 ret = kstrtoint(buf, 0, &ctx->connected);
@@ -420,7 +425,7 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
420 display = exynos_drm_get_display(encoder); 425 display = exynos_drm_get_display(encoder);
421 426
422 if (display->type == EXYNOS_DISPLAY_TYPE_VIDI) { 427 if (display->type == EXYNOS_DISPLAY_TYPE_VIDI) {
423 ctx = display->ctx; 428 ctx = display_to_vidi(display);
424 break; 429 break;
425 } 430 }
426 } 431 }
@@ -530,7 +535,7 @@ static struct drm_connector_helper_funcs vidi_connector_helper_funcs = {
530static int vidi_create_connector(struct exynos_drm_display *display, 535static int vidi_create_connector(struct exynos_drm_display *display,
531 struct drm_encoder *encoder) 536 struct drm_encoder *encoder)
532{ 537{
533 struct vidi_context *ctx = display->ctx; 538 struct vidi_context *ctx = display_to_vidi(display);
534 struct drm_connector *connector = &ctx->connector; 539 struct drm_connector *connector = &ctx->connector;
535 int ret; 540 int ret;
536 541
@@ -556,27 +561,22 @@ static struct exynos_drm_display_ops vidi_display_ops = {
556 .create_connector = vidi_create_connector, 561 .create_connector = vidi_create_connector,
557}; 562};
558 563
559static struct exynos_drm_display vidi_display = { 564static int vidi_bind(struct device *dev, struct device *master, void *data)
560 .type = EXYNOS_DISPLAY_TYPE_VIDI,
561 .ops = &vidi_display_ops,
562};
563
564static int vidi_subdrv_probe(struct drm_device *drm_dev, struct device *dev)
565{ 565{
566 struct exynos_drm_manager *mgr = get_vidi_mgr(dev); 566 struct vidi_context *ctx = dev_get_drvdata(dev);
567 struct vidi_context *ctx = mgr->ctx; 567 struct drm_device *drm_dev = data;
568 struct drm_crtc *crtc = ctx->crtc; 568 struct drm_crtc *crtc = ctx->crtc;
569 int ret; 569 int ret;
570 570
571 vidi_mgr_initialize(mgr, drm_dev); 571 vidi_mgr_initialize(&ctx->manager, drm_dev);
572 572
573 ret = exynos_drm_crtc_create(&vidi_manager); 573 ret = exynos_drm_crtc_create(&ctx->manager);
574 if (ret) { 574 if (ret) {
575 DRM_ERROR("failed to create crtc.\n"); 575 DRM_ERROR("failed to create crtc.\n");
576 return ret; 576 return ret;
577 } 577 }
578 578
579 ret = exynos_drm_create_enc_conn(drm_dev, &vidi_display); 579 ret = exynos_drm_create_enc_conn(drm_dev, &ctx->display);
580 if (ret) { 580 if (ret) {
581 crtc->funcs->destroy(crtc); 581 crtc->funcs->destroy(crtc);
582 DRM_ERROR("failed to create encoder and connector.\n"); 582 DRM_ERROR("failed to create encoder and connector.\n");
@@ -586,9 +586,18 @@ static int vidi_subdrv_probe(struct drm_device *drm_dev, struct device *dev)
586 return 0; 586 return 0;
587} 587}
588 588
589
590static void vidi_unbind(struct device *dev, struct device *master, void *data)
591{
592}
593
594static const struct component_ops vidi_component_ops = {
595 .bind = vidi_bind,
596 .unbind = vidi_unbind,
597};
598
589static int vidi_probe(struct platform_device *pdev) 599static int vidi_probe(struct platform_device *pdev)
590{ 600{
591 struct exynos_drm_subdrv *subdrv;
592 struct vidi_context *ctx; 601 struct vidi_context *ctx;
593 int ret; 602 int ret;
594 603
@@ -596,40 +605,54 @@ static int vidi_probe(struct platform_device *pdev)
596 if (!ctx) 605 if (!ctx)
597 return -ENOMEM; 606 return -ENOMEM;
598 607
608 ctx->manager.type = EXYNOS_DISPLAY_TYPE_VIDI;
609 ctx->manager.ops = &vidi_manager_ops;
610 ctx->display.type = EXYNOS_DISPLAY_TYPE_VIDI;
611 ctx->display.ops = &vidi_display_ops;
599 ctx->default_win = 0; 612 ctx->default_win = 0;
613 ctx->pdev = pdev;
600 614
601 INIT_WORK(&ctx->work, vidi_fake_vblank_handler); 615 ret = exynos_drm_component_add(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC,
602 616 ctx->manager.type);
603 vidi_manager.ctx = ctx; 617 if (ret)
604 vidi_display.ctx = ctx; 618 return ret;
605 619
606 mutex_init(&ctx->lock); 620 ret = exynos_drm_component_add(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR,
621 ctx->display.type);
622 if (ret)
623 goto err_del_crtc_component;
607 624
608 platform_set_drvdata(pdev, &vidi_manager); 625 INIT_WORK(&ctx->work, vidi_fake_vblank_handler);
609 626
610 subdrv = &ctx->subdrv; 627 mutex_init(&ctx->lock);
611 subdrv->dev = &pdev->dev;
612 subdrv->probe = vidi_subdrv_probe;
613 628
614 ret = exynos_drm_subdrv_register(subdrv); 629 platform_set_drvdata(pdev, ctx);
615 if (ret < 0) {
616 dev_err(&pdev->dev, "failed to register drm vidi device\n");
617 return ret;
618 }
619 630
620 ret = device_create_file(&pdev->dev, &dev_attr_connection); 631 ret = device_create_file(&pdev->dev, &dev_attr_connection);
621 if (ret < 0) { 632 if (ret < 0) {
622 exynos_drm_subdrv_unregister(subdrv); 633 DRM_ERROR("failed to create connection sysfs.\n");
623 DRM_INFO("failed to create connection sysfs.\n"); 634 goto err_del_conn_component;
624 } 635 }
625 636
626 return 0; 637 ret = component_add(&pdev->dev, &vidi_component_ops);
638 if (ret)
639 goto err_remove_file;
640
641 return ret;
642
643err_remove_file:
644 device_remove_file(&pdev->dev, &dev_attr_connection);
645err_del_conn_component:
646 exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR);
647err_del_crtc_component:
648 exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC);
649
650 return ret;
627} 651}
628 652
629static int vidi_remove(struct platform_device *pdev) 653static int vidi_remove(struct platform_device *pdev)
630{ 654{
631 struct exynos_drm_manager *mgr = platform_get_drvdata(pdev); 655 struct vidi_context *ctx = platform_get_drvdata(pdev);
632 struct vidi_context *ctx = mgr->ctx;
633 656
634 if (ctx->raw_edid != (struct edid *)fake_edid_info) { 657 if (ctx->raw_edid != (struct edid *)fake_edid_info) {
635 kfree(ctx->raw_edid); 658 kfree(ctx->raw_edid);
@@ -638,6 +661,10 @@ static int vidi_remove(struct platform_device *pdev)
638 return -EINVAL; 661 return -EINVAL;
639 } 662 }
640 663
664 component_del(&pdev->dev, &vidi_component_ops);
665 exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR);
666 exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC);
667
641 return 0; 668 return 0;
642} 669}
643 670
@@ -668,12 +695,19 @@ int exynos_drm_probe_vidi(void)
668 return ret; 695 return ret;
669} 696}
670 697
698static int exynos_drm_remove_vidi_device(struct device *dev, void *data)
699{
700 platform_device_unregister(to_platform_device(dev));
701
702 return 0;
703}
704
671void exynos_drm_remove_vidi(void) 705void exynos_drm_remove_vidi(void)
672{ 706{
673 struct vidi_context *ctx = vidi_manager.ctx; 707 int ret = driver_for_each_device(&vidi_driver.driver, NULL, NULL,
674 struct exynos_drm_subdrv *subdrv = &ctx->subdrv; 708 exynos_drm_remove_vidi_device);
675 struct platform_device *pdev = to_platform_device(subdrv->dev); 709 /* silence compiler warning */
710 (void)ret;
676 711
677 platform_driver_unregister(&vidi_driver); 712 platform_driver_unregister(&vidi_driver);
678 platform_device_unregister(pdev);
679} 713}
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 563a19e62eb2..5765a161abdd 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -49,7 +49,6 @@
49#include <linux/gpio.h> 49#include <linux/gpio.h>
50#include <media/s5p_hdmi.h> 50#include <media/s5p_hdmi.h>
51 51
52#define get_hdmi_display(dev) platform_get_drvdata(to_platform_device(dev))
53#define ctx_from_connector(c) container_of(c, struct hdmi_context, connector) 52#define ctx_from_connector(c) container_of(c, struct hdmi_context, connector)
54 53
55#define HOTPLUG_DEBOUNCE_MS 1100 54#define HOTPLUG_DEBOUNCE_MS 1100
@@ -182,6 +181,7 @@ struct hdmi_conf_regs {
182}; 181};
183 182
184struct hdmi_context { 183struct hdmi_context {
184 struct exynos_drm_display display;
185 struct device *dev; 185 struct device *dev;
186 struct drm_device *drm_dev; 186 struct drm_device *drm_dev;
187 struct drm_connector connector; 187 struct drm_connector connector;
@@ -213,6 +213,11 @@ struct hdmi_context {
213 enum hdmi_type type; 213 enum hdmi_type type;
214}; 214};
215 215
216static inline struct hdmi_context *display_to_hdmi(struct exynos_drm_display *d)
217{
218 return container_of(d, struct hdmi_context, display);
219}
220
216struct hdmiphy_config { 221struct hdmiphy_config {
217 int pixel_clock; 222 int pixel_clock;
218 u8 conf[32]; 223 u8 conf[32];
@@ -1123,7 +1128,7 @@ static struct drm_connector_helper_funcs hdmi_connector_helper_funcs = {
1123static int hdmi_create_connector(struct exynos_drm_display *display, 1128static int hdmi_create_connector(struct exynos_drm_display *display,
1124 struct drm_encoder *encoder) 1129 struct drm_encoder *encoder)
1125{ 1130{
1126 struct hdmi_context *hdata = display->ctx; 1131 struct hdmi_context *hdata = display_to_hdmi(display);
1127 struct drm_connector *connector = &hdata->connector; 1132 struct drm_connector *connector = &hdata->connector;
1128 int ret; 1133 int ret;
1129 1134
@@ -2000,7 +2005,7 @@ static void hdmi_v14_mode_set(struct hdmi_context *hdata,
2000static void hdmi_mode_set(struct exynos_drm_display *display, 2005static void hdmi_mode_set(struct exynos_drm_display *display,
2001 struct drm_display_mode *mode) 2006 struct drm_display_mode *mode)
2002{ 2007{
2003 struct hdmi_context *hdata = display->ctx; 2008 struct hdmi_context *hdata = display_to_hdmi(display);
2004 struct drm_display_mode *m = mode; 2009 struct drm_display_mode *m = mode;
2005 2010
2006 DRM_DEBUG_KMS("xres=%d, yres=%d, refresh=%d, intl=%s\n", 2011 DRM_DEBUG_KMS("xres=%d, yres=%d, refresh=%d, intl=%s\n",
@@ -2019,7 +2024,7 @@ static void hdmi_mode_set(struct exynos_drm_display *display,
2019 2024
2020static void hdmi_commit(struct exynos_drm_display *display) 2025static void hdmi_commit(struct exynos_drm_display *display)
2021{ 2026{
2022 struct hdmi_context *hdata = display->ctx; 2027 struct hdmi_context *hdata = display_to_hdmi(display);
2023 2028
2024 mutex_lock(&hdata->hdmi_mutex); 2029 mutex_lock(&hdata->hdmi_mutex);
2025 if (!hdata->powered) { 2030 if (!hdata->powered) {
@@ -2033,7 +2038,7 @@ static void hdmi_commit(struct exynos_drm_display *display)
2033 2038
2034static void hdmi_poweron(struct exynos_drm_display *display) 2039static void hdmi_poweron(struct exynos_drm_display *display)
2035{ 2040{
2036 struct hdmi_context *hdata = display->ctx; 2041 struct hdmi_context *hdata = display_to_hdmi(display);
2037 struct hdmi_resources *res = &hdata->res; 2042 struct hdmi_resources *res = &hdata->res;
2038 2043
2039 mutex_lock(&hdata->hdmi_mutex); 2044 mutex_lock(&hdata->hdmi_mutex);
@@ -2064,7 +2069,7 @@ static void hdmi_poweron(struct exynos_drm_display *display)
2064 2069
2065static void hdmi_poweroff(struct exynos_drm_display *display) 2070static void hdmi_poweroff(struct exynos_drm_display *display)
2066{ 2071{
2067 struct hdmi_context *hdata = display->ctx; 2072 struct hdmi_context *hdata = display_to_hdmi(display);
2068 struct hdmi_resources *res = &hdata->res; 2073 struct hdmi_resources *res = &hdata->res;
2069 2074
2070 mutex_lock(&hdata->hdmi_mutex); 2075 mutex_lock(&hdata->hdmi_mutex);
@@ -2099,7 +2104,7 @@ out:
2099 2104
2100static void hdmi_dpms(struct exynos_drm_display *display, int mode) 2105static void hdmi_dpms(struct exynos_drm_display *display, int mode)
2101{ 2106{
2102 struct hdmi_context *hdata = display->ctx; 2107 struct hdmi_context *hdata = display_to_hdmi(display);
2103 struct drm_encoder *encoder = hdata->encoder; 2108 struct drm_encoder *encoder = hdata->encoder;
2104 struct drm_crtc *crtc = encoder->crtc; 2109 struct drm_crtc *crtc = encoder->crtc;
2105 struct drm_crtc_helper_funcs *funcs = NULL; 2110 struct drm_crtc_helper_funcs *funcs = NULL;
@@ -2143,11 +2148,6 @@ static struct exynos_drm_display_ops hdmi_display_ops = {
2143 .commit = hdmi_commit, 2148 .commit = hdmi_commit,
2144}; 2149};
2145 2150
2146static struct exynos_drm_display hdmi_display = {
2147 .type = EXYNOS_DISPLAY_TYPE_HDMI,
2148 .ops = &hdmi_display_ops,
2149};
2150
2151static void hdmi_hotplug_work_func(struct work_struct *work) 2151static void hdmi_hotplug_work_func(struct work_struct *work)
2152{ 2152{
2153 struct hdmi_context *hdata; 2153 struct hdmi_context *hdata;
@@ -2302,12 +2302,11 @@ MODULE_DEVICE_TABLE (of, hdmi_match_types);
2302static int hdmi_bind(struct device *dev, struct device *master, void *data) 2302static int hdmi_bind(struct device *dev, struct device *master, void *data)
2303{ 2303{
2304 struct drm_device *drm_dev = data; 2304 struct drm_device *drm_dev = data;
2305 struct hdmi_context *hdata; 2305 struct hdmi_context *hdata = dev_get_drvdata(dev);
2306 2306
2307 hdata = hdmi_display.ctx;
2308 hdata->drm_dev = drm_dev; 2307 hdata->drm_dev = drm_dev;
2309 2308
2310 return exynos_drm_create_enc_conn(drm_dev, &hdmi_display); 2309 return exynos_drm_create_enc_conn(drm_dev, &hdata->display);
2311} 2310}
2312 2311
2313static void hdmi_unbind(struct device *dev, struct device *master, void *data) 2312static void hdmi_unbind(struct device *dev, struct device *master, void *data)
@@ -2349,31 +2348,28 @@ static int hdmi_probe(struct platform_device *pdev)
2349 struct resource *res; 2348 struct resource *res;
2350 int ret; 2349 int ret;
2351 2350
2352 ret = exynos_drm_component_add(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR, 2351 if (!dev->of_node)
2353 hdmi_display.type); 2352 return -ENODEV;
2354 if (ret)
2355 return ret;
2356
2357 if (!dev->of_node) {
2358 ret = -ENODEV;
2359 goto err_del_component;
2360 }
2361 2353
2362 pdata = drm_hdmi_dt_parse_pdata(dev); 2354 pdata = drm_hdmi_dt_parse_pdata(dev);
2363 if (!pdata) { 2355 if (!pdata)
2364 ret = -EINVAL; 2356 return -EINVAL;
2365 goto err_del_component;
2366 }
2367 2357
2368 hdata = devm_kzalloc(dev, sizeof(struct hdmi_context), GFP_KERNEL); 2358 hdata = devm_kzalloc(dev, sizeof(struct hdmi_context), GFP_KERNEL);
2369 if (!hdata) { 2359 if (!hdata)
2370 ret = -ENOMEM; 2360 return -ENOMEM;
2371 goto err_del_component; 2361
2372 } 2362 hdata->display.type = EXYNOS_DISPLAY_TYPE_HDMI;
2363 hdata->display.ops = &hdmi_display_ops;
2364
2365 ret = exynos_drm_component_add(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR,
2366 hdata->display.type);
2367 if (ret)
2368 return ret;
2373 2369
2374 mutex_init(&hdata->hdmi_mutex); 2370 mutex_init(&hdata->hdmi_mutex);
2375 2371
2376 platform_set_drvdata(pdev, &hdmi_display); 2372 platform_set_drvdata(pdev, hdata);
2377 2373
2378 match = of_match_node(hdmi_match_types, dev->of_node); 2374 match = of_match_node(hdmi_match_types, dev->of_node);
2379 if (!match) { 2375 if (!match) {
@@ -2485,7 +2481,6 @@ out_get_phy_port:
2485 } 2481 }
2486 2482
2487 pm_runtime_enable(dev); 2483 pm_runtime_enable(dev);
2488 hdmi_display.ctx = hdata;
2489 2484
2490 ret = component_add(&pdev->dev, &hdmi_component_ops); 2485 ret = component_add(&pdev->dev, &hdmi_component_ops);
2491 if (ret) 2486 if (ret)
@@ -2510,7 +2505,7 @@ err_del_component:
2510 2505
2511static int hdmi_remove(struct platform_device *pdev) 2506static int hdmi_remove(struct platform_device *pdev)
2512{ 2507{
2513 struct hdmi_context *hdata = hdmi_display.ctx; 2508 struct hdmi_context *hdata = platform_get_drvdata(pdev);
2514 2509
2515 cancel_delayed_work_sync(&hdata->hotplug_work); 2510 cancel_delayed_work_sync(&hdata->hotplug_work);
2516 2511
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index a41c84ee3a2d..820b76234ef4 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -40,8 +40,6 @@
40#include "exynos_drm_iommu.h" 40#include "exynos_drm_iommu.h"
41#include "exynos_mixer.h" 41#include "exynos_mixer.h"
42 42
43#define get_mixer_manager(dev) platform_get_drvdata(to_platform_device(dev))
44
45#define MIXER_WIN_NR 3 43#define MIXER_WIN_NR 3
46#define MIXER_DEFAULT_WIN 0 44#define MIXER_DEFAULT_WIN 0
47 45
@@ -86,6 +84,7 @@ enum mixer_version_id {
86}; 84};
87 85
88struct mixer_context { 86struct mixer_context {
87 struct exynos_drm_manager manager;
89 struct platform_device *pdev; 88 struct platform_device *pdev;
90 struct device *dev; 89 struct device *dev;
91 struct drm_device *drm_dev; 90 struct drm_device *drm_dev;
@@ -104,6 +103,11 @@ struct mixer_context {
104 atomic_t wait_vsync_event; 103 atomic_t wait_vsync_event;
105}; 104};
106 105
106static inline struct mixer_context *mgr_to_mixer(struct exynos_drm_manager *mgr)
107{
108 return container_of(mgr, struct mixer_context, manager);
109}
110
107struct mixer_drv_data { 111struct mixer_drv_data {
108 enum mixer_version_id version; 112 enum mixer_version_id version;
109 bool is_vp_enabled; 113 bool is_vp_enabled;
@@ -854,7 +858,7 @@ static int mixer_initialize(struct exynos_drm_manager *mgr,
854 struct drm_device *drm_dev) 858 struct drm_device *drm_dev)
855{ 859{
856 int ret; 860 int ret;
857 struct mixer_context *mixer_ctx = mgr->ctx; 861 struct mixer_context *mixer_ctx = mgr_to_mixer(mgr);
858 struct exynos_drm_private *priv; 862 struct exynos_drm_private *priv;
859 priv = drm_dev->dev_private; 863 priv = drm_dev->dev_private;
860 864
@@ -885,7 +889,7 @@ static int mixer_initialize(struct exynos_drm_manager *mgr,
885 889
886static void mixer_mgr_remove(struct exynos_drm_manager *mgr) 890static void mixer_mgr_remove(struct exynos_drm_manager *mgr)
887{ 891{
888 struct mixer_context *mixer_ctx = mgr->ctx; 892 struct mixer_context *mixer_ctx = mgr_to_mixer(mgr);
889 893
890 if (is_drm_iommu_supported(mixer_ctx->drm_dev)) 894 if (is_drm_iommu_supported(mixer_ctx->drm_dev))
891 drm_iommu_detach_device(mixer_ctx->drm_dev, mixer_ctx->dev); 895 drm_iommu_detach_device(mixer_ctx->drm_dev, mixer_ctx->dev);
@@ -893,7 +897,7 @@ static void mixer_mgr_remove(struct exynos_drm_manager *mgr)
893 897
894static int mixer_enable_vblank(struct exynos_drm_manager *mgr) 898static int mixer_enable_vblank(struct exynos_drm_manager *mgr)
895{ 899{
896 struct mixer_context *mixer_ctx = mgr->ctx; 900 struct mixer_context *mixer_ctx = mgr_to_mixer(mgr);
897 struct mixer_resources *res = &mixer_ctx->mixer_res; 901 struct mixer_resources *res = &mixer_ctx->mixer_res;
898 902
899 if (!mixer_ctx->powered) { 903 if (!mixer_ctx->powered) {
@@ -910,7 +914,7 @@ static int mixer_enable_vblank(struct exynos_drm_manager *mgr)
910 914
911static void mixer_disable_vblank(struct exynos_drm_manager *mgr) 915static void mixer_disable_vblank(struct exynos_drm_manager *mgr)
912{ 916{
913 struct mixer_context *mixer_ctx = mgr->ctx; 917 struct mixer_context *mixer_ctx = mgr_to_mixer(mgr);
914 struct mixer_resources *res = &mixer_ctx->mixer_res; 918 struct mixer_resources *res = &mixer_ctx->mixer_res;
915 919
916 /* disable vsync interrupt */ 920 /* disable vsync interrupt */
@@ -920,7 +924,7 @@ static void mixer_disable_vblank(struct exynos_drm_manager *mgr)
920static void mixer_win_mode_set(struct exynos_drm_manager *mgr, 924static void mixer_win_mode_set(struct exynos_drm_manager *mgr,
921 struct exynos_drm_overlay *overlay) 925 struct exynos_drm_overlay *overlay)
922{ 926{
923 struct mixer_context *mixer_ctx = mgr->ctx; 927 struct mixer_context *mixer_ctx = mgr_to_mixer(mgr);
924 struct hdmi_win_data *win_data; 928 struct hdmi_win_data *win_data;
925 int win; 929 int win;
926 930
@@ -971,7 +975,7 @@ static void mixer_win_mode_set(struct exynos_drm_manager *mgr,
971 975
972static void mixer_win_commit(struct exynos_drm_manager *mgr, int zpos) 976static void mixer_win_commit(struct exynos_drm_manager *mgr, int zpos)
973{ 977{
974 struct mixer_context *mixer_ctx = mgr->ctx; 978 struct mixer_context *mixer_ctx = mgr_to_mixer(mgr);
975 int win = zpos == DEFAULT_ZPOS ? MIXER_DEFAULT_WIN : zpos; 979 int win = zpos == DEFAULT_ZPOS ? MIXER_DEFAULT_WIN : zpos;
976 980
977 DRM_DEBUG_KMS("win: %d\n", win); 981 DRM_DEBUG_KMS("win: %d\n", win);
@@ -993,7 +997,7 @@ static void mixer_win_commit(struct exynos_drm_manager *mgr, int zpos)
993 997
994static void mixer_win_disable(struct exynos_drm_manager *mgr, int zpos) 998static void mixer_win_disable(struct exynos_drm_manager *mgr, int zpos)
995{ 999{
996 struct mixer_context *mixer_ctx = mgr->ctx; 1000 struct mixer_context *mixer_ctx = mgr_to_mixer(mgr);
997 struct mixer_resources *res = &mixer_ctx->mixer_res; 1001 struct mixer_resources *res = &mixer_ctx->mixer_res;
998 int win = zpos == DEFAULT_ZPOS ? MIXER_DEFAULT_WIN : zpos; 1002 int win = zpos == DEFAULT_ZPOS ? MIXER_DEFAULT_WIN : zpos;
999 unsigned long flags; 1003 unsigned long flags;
@@ -1021,7 +1025,7 @@ static void mixer_win_disable(struct exynos_drm_manager *mgr, int zpos)
1021 1025
1022static void mixer_wait_for_vblank(struct exynos_drm_manager *mgr) 1026static void mixer_wait_for_vblank(struct exynos_drm_manager *mgr)
1023{ 1027{
1024 struct mixer_context *mixer_ctx = mgr->ctx; 1028 struct mixer_context *mixer_ctx = mgr_to_mixer(mgr);
1025 1029
1026 mutex_lock(&mixer_ctx->mixer_mutex); 1030 mutex_lock(&mixer_ctx->mixer_mutex);
1027 if (!mixer_ctx->powered) { 1031 if (!mixer_ctx->powered) {
@@ -1048,7 +1052,7 @@ static void mixer_wait_for_vblank(struct exynos_drm_manager *mgr)
1048 1052
1049static void mixer_window_suspend(struct exynos_drm_manager *mgr) 1053static void mixer_window_suspend(struct exynos_drm_manager *mgr)
1050{ 1054{
1051 struct mixer_context *ctx = mgr->ctx; 1055 struct mixer_context *ctx = mgr_to_mixer(mgr);
1052 struct hdmi_win_data *win_data; 1056 struct hdmi_win_data *win_data;
1053 int i; 1057 int i;
1054 1058
@@ -1062,7 +1066,7 @@ static void mixer_window_suspend(struct exynos_drm_manager *mgr)
1062 1066
1063static void mixer_window_resume(struct exynos_drm_manager *mgr) 1067static void mixer_window_resume(struct exynos_drm_manager *mgr)
1064{ 1068{
1065 struct mixer_context *ctx = mgr->ctx; 1069 struct mixer_context *ctx = mgr_to_mixer(mgr);
1066 struct hdmi_win_data *win_data; 1070 struct hdmi_win_data *win_data;
1067 int i; 1071 int i;
1068 1072
@@ -1077,7 +1081,7 @@ static void mixer_window_resume(struct exynos_drm_manager *mgr)
1077 1081
1078static void mixer_poweron(struct exynos_drm_manager *mgr) 1082static void mixer_poweron(struct exynos_drm_manager *mgr)
1079{ 1083{
1080 struct mixer_context *ctx = mgr->ctx; 1084 struct mixer_context *ctx = mgr_to_mixer(mgr);
1081 struct mixer_resources *res = &ctx->mixer_res; 1085 struct mixer_resources *res = &ctx->mixer_res;
1082 1086
1083 mutex_lock(&ctx->mixer_mutex); 1087 mutex_lock(&ctx->mixer_mutex);
@@ -1111,7 +1115,7 @@ static void mixer_poweron(struct exynos_drm_manager *mgr)
1111 1115
1112static void mixer_poweroff(struct exynos_drm_manager *mgr) 1116static void mixer_poweroff(struct exynos_drm_manager *mgr)
1113{ 1117{
1114 struct mixer_context *ctx = mgr->ctx; 1118 struct mixer_context *ctx = mgr_to_mixer(mgr);
1115 struct mixer_resources *res = &ctx->mixer_res; 1119 struct mixer_resources *res = &ctx->mixer_res;
1116 1120
1117 mutex_lock(&ctx->mixer_mutex); 1121 mutex_lock(&ctx->mixer_mutex);
@@ -1187,11 +1191,6 @@ static struct exynos_drm_manager_ops mixer_manager_ops = {
1187 .win_disable = mixer_win_disable, 1191 .win_disable = mixer_win_disable,
1188}; 1192};
1189 1193
1190static struct exynos_drm_manager mixer_manager = {
1191 .type = EXYNOS_DISPLAY_TYPE_HDMI,
1192 .ops = &mixer_manager_ops,
1193};
1194
1195static struct mixer_drv_data exynos5420_mxr_drv_data = { 1194static struct mixer_drv_data exynos5420_mxr_drv_data = {
1196 .version = MXR_VER_128_0_0_184, 1195 .version = MXR_VER_128_0_0_184,
1197 .is_vp_enabled = 0, 1196 .is_vp_enabled = 0,
@@ -1249,48 +1248,17 @@ MODULE_DEVICE_TABLE(of, mixer_match_types);
1249 1248
1250static int mixer_bind(struct device *dev, struct device *manager, void *data) 1249static int mixer_bind(struct device *dev, struct device *manager, void *data)
1251{ 1250{
1252 struct platform_device *pdev = to_platform_device(dev); 1251 struct mixer_context *ctx = dev_get_drvdata(dev);
1253 struct drm_device *drm_dev = data; 1252 struct drm_device *drm_dev = data;
1254 struct mixer_context *ctx;
1255 struct mixer_drv_data *drv;
1256 int ret; 1253 int ret;
1257 1254
1258 dev_info(dev, "probe start\n"); 1255 ret = mixer_initialize(&ctx->manager, drm_dev);
1259
1260 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
1261 if (!ctx) {
1262 DRM_ERROR("failed to alloc mixer context.\n");
1263 return -ENOMEM;
1264 }
1265
1266 mutex_init(&ctx->mixer_mutex);
1267
1268 if (dev->of_node) {
1269 const struct of_device_id *match;
1270 match = of_match_node(mixer_match_types, dev->of_node);
1271 drv = (struct mixer_drv_data *)match->data;
1272 } else {
1273 drv = (struct mixer_drv_data *)
1274 platform_get_device_id(pdev)->driver_data;
1275 }
1276
1277 ctx->pdev = pdev;
1278 ctx->dev = dev;
1279 ctx->vp_enabled = drv->is_vp_enabled;
1280 ctx->has_sclk = drv->has_sclk;
1281 ctx->mxr_ver = drv->version;
1282 init_waitqueue_head(&ctx->wait_vsync_queue);
1283 atomic_set(&ctx->wait_vsync_event, 0);
1284
1285 mixer_manager.ctx = ctx;
1286 ret = mixer_initialize(&mixer_manager, drm_dev);
1287 if (ret) 1256 if (ret)
1288 return ret; 1257 return ret;
1289 1258
1290 platform_set_drvdata(pdev, &mixer_manager); 1259 ret = exynos_drm_crtc_create(&ctx->manager);
1291 ret = exynos_drm_crtc_create(&mixer_manager);
1292 if (ret) { 1260 if (ret) {
1293 mixer_mgr_remove(&mixer_manager); 1261 mixer_mgr_remove(&ctx->manager);
1294 return ret; 1262 return ret;
1295 } 1263 }
1296 1264
@@ -1301,11 +1269,9 @@ static int mixer_bind(struct device *dev, struct device *manager, void *data)
1301 1269
1302static void mixer_unbind(struct device *dev, struct device *master, void *data) 1270static void mixer_unbind(struct device *dev, struct device *master, void *data)
1303{ 1271{
1304 struct exynos_drm_manager *mgr = dev_get_drvdata(dev); 1272 struct mixer_context *ctx = dev_get_drvdata(dev);
1305 1273
1306 dev_info(dev, "remove successful\n"); 1274 mixer_mgr_remove(&ctx->manager);
1307
1308 mixer_mgr_remove(mgr);
1309 1275
1310 pm_runtime_disable(dev); 1276 pm_runtime_disable(dev);
1311} 1277}
@@ -1317,22 +1283,62 @@ static const struct component_ops mixer_component_ops = {
1317 1283
1318static int mixer_probe(struct platform_device *pdev) 1284static int mixer_probe(struct platform_device *pdev)
1319{ 1285{
1286 struct device *dev = &pdev->dev;
1287 struct mixer_drv_data *drv;
1288 struct mixer_context *ctx;
1320 int ret; 1289 int ret;
1321 1290
1291 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
1292 if (!ctx) {
1293 DRM_ERROR("failed to alloc mixer context.\n");
1294 return -ENOMEM;
1295 }
1296
1297 mutex_init(&ctx->mixer_mutex);
1298
1299 ctx->manager.type = EXYNOS_DISPLAY_TYPE_HDMI;
1300 ctx->manager.ops = &mixer_manager_ops;
1301
1302 if (dev->of_node) {
1303 const struct of_device_id *match;
1304
1305 match = of_match_node(mixer_match_types, dev->of_node);
1306 drv = (struct mixer_drv_data *)match->data;
1307 } else {
1308 drv = (struct mixer_drv_data *)
1309 platform_get_device_id(pdev)->driver_data;
1310 }
1311
1312 ctx->pdev = pdev;
1313 ctx->dev = dev;
1314 ctx->vp_enabled = drv->is_vp_enabled;
1315 ctx->has_sclk = drv->has_sclk;
1316 ctx->mxr_ver = drv->version;
1317 init_waitqueue_head(&ctx->wait_vsync_queue);
1318 atomic_set(&ctx->wait_vsync_event, 0);
1319
1320 platform_set_drvdata(pdev, ctx);
1321
1322 ret = exynos_drm_component_add(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC, 1322 ret = exynos_drm_component_add(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC,
1323 mixer_manager.type); 1323 ctx->manager.type);
1324 if (ret) 1324 if (ret)
1325 return ret; 1325 return ret;
1326 1326
1327 ret = component_add(&pdev->dev, &mixer_component_ops); 1327 ret = component_add(&pdev->dev, &mixer_component_ops);
1328 if (ret) 1328 if (ret) {
1329 exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC); 1329 exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC);
1330 return ret;
1331 }
1332
1333 pm_runtime_enable(dev);
1330 1334
1331 return ret; 1335 return ret;
1332} 1336}
1333 1337
1334static int mixer_remove(struct platform_device *pdev) 1338static int mixer_remove(struct platform_device *pdev)
1335{ 1339{
1340 pm_runtime_disable(&pdev->dev);
1341
1336 component_del(&pdev->dev, &mixer_component_ops); 1342 component_del(&pdev->dev, &mixer_component_ops);
1337 exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC); 1343 exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC);
1338 1344