Skip to content

Commit 435e06c

Browse files
author
Linus Walleij
committed
drm/panel: s6e63m0: Add DSI transport
This makes it possible to use the s6e63m0 panel with a DSI host, such as in the Samsung GT-I8190 (Golden) mobile phone. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Tested-by: Stephan Gerhold <stephan@gerhold.net> Cc: Stephan Gerhold <stephan@gerhold.net> Cc: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com> Acked-by: Paul Cercueil <paul@crapouillou.net> Link: https://patchwork.freedesktop.org/patch/msgid/20200809215104.1830206-3-linus.walleij@linaro.org
1 parent b7b23e4 commit 435e06c

6 files changed

Lines changed: 144 additions & 3 deletions

File tree

‎drivers/gpu/drm/panel/Kconfig‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,14 @@ config DRM_PANEL_SAMSUNG_S6E63M0_SPI
341341
Say Y here if you want to be able to access the Samsung
342342
S6E63M0 panel using SPI.
343343

344+
config DRM_PANEL_SAMSUNG_S6E63M0_DSI
345+
tristate "Samsung S6E63M0 RGB DSI interface"
346+
depends on DRM_MIPI_DSI
347+
depends on DRM_PANEL_SAMSUNG_S6E63M0
348+
help
349+
Say Y here if you want to be able to access the Samsung
350+
S6E63M0 panel using DSI.
351+
344352
config DRM_PANEL_SAMSUNG_S6E88A0_AMS452EF01
345353
tristate "Samsung AMS452EF01 panel with S6E88A0 DSI video mode controller"
346354
depends on OF

‎drivers/gpu/drm/panel/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HA2) += panel-samsung-s6e3ha2.o
3535
obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63J0X03) += panel-samsung-s6e63j0x03.o
3636
obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0) += panel-samsung-s6e63m0.o
3737
obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0_SPI) += panel-samsung-s6e63m0-spi.o
38+
obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0_DSI) += panel-samsung-s6e63m0-dsi.o
3839
obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E88A0_AMS452EF01) += panel-samsung-s6e88a0-ams452ef01.o
3940
obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E8AA0) += panel-samsung-s6e8aa0.o
4041
obj-$(CONFIG_DRM_PANEL_SEIKO_43WVF1G) += panel-seiko-43wvf1g.o
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* DSI interface to the Samsung S6E63M0 panel.
4+
* (C) 2019 Linus Walleij
5+
*/
6+
7+
#include <linux/module.h>
8+
#include <linux/delay.h>
9+
#include <linux/of_device.h>
10+
11+
#include <drm/drm_mipi_dsi.h>
12+
#include <drm/drm_print.h>
13+
14+
#include "panel-samsung-s6e63m0.h"
15+
16+
#define MCS_GLOBAL_PARAM 0xb0
17+
#define S6E63M0_DSI_MAX_CHUNK 15 /* CMD + 15 bytes max */
18+
19+
static int s6e63m0_dsi_dcs_write(struct device *dev, const u8 *data, size_t len)
20+
{
21+
struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
22+
const u8 *seqp = data;
23+
u8 cmd;
24+
u8 cmdwritten;
25+
int remain;
26+
int chunk;
27+
int ret;
28+
29+
DRM_DEV_INFO(dev, "DSI writing dcs seq: %*ph\n", (int)len, data);
30+
31+
/* Pick out and skip past the DCS command */
32+
cmd = *seqp;
33+
seqp++;
34+
cmdwritten = 0;
35+
remain = len - 1;
36+
chunk = remain;
37+
38+
/* Send max S6E63M0_DSI_MAX_CHUNK bytes at a time */
39+
if (chunk > S6E63M0_DSI_MAX_CHUNK)
40+
chunk = S6E63M0_DSI_MAX_CHUNK;
41+
ret = mipi_dsi_dcs_write(dsi, cmd, seqp, chunk);
42+
if (ret < 0) {
43+
DRM_DEV_ERROR(dev,
44+
"error sending DCS command seq cmd %02x\n",
45+
cmd);
46+
return ret;
47+
}
48+
cmdwritten += chunk;
49+
seqp += chunk;
50+
51+
while (cmdwritten < remain) {
52+
chunk = remain - cmdwritten;
53+
if (chunk > S6E63M0_DSI_MAX_CHUNK)
54+
chunk = S6E63M0_DSI_MAX_CHUNK;
55+
ret = mipi_dsi_dcs_write(dsi, MCS_GLOBAL_PARAM, &cmdwritten, 1);
56+
if (ret < 0) {
57+
DRM_DEV_ERROR(dev,
58+
"error sending CMD %02x global param %02x\n",
59+
cmd, cmdwritten);
60+
return ret;
61+
}
62+
ret = mipi_dsi_dcs_write(dsi, cmd, seqp, chunk);
63+
if (ret < 0) {
64+
DRM_DEV_ERROR(dev,
65+
"error sending CMD %02x chunk\n",
66+
cmd);
67+
return ret;
68+
}
69+
cmdwritten += chunk;
70+
seqp += chunk;
71+
}
72+
DRM_DEV_INFO(dev, "sent command %02x %02x bytes\n",
73+
cmd, cmdwritten);
74+
75+
usleep_range(8000, 9000);
76+
77+
return 0;
78+
}
79+
80+
static int s6e63m0_dsi_probe(struct mipi_dsi_device *dsi)
81+
{
82+
struct device *dev = &dsi->dev;
83+
int ret;
84+
85+
dsi->lanes = 2;
86+
dsi->format = MIPI_DSI_FMT_RGB888;
87+
dsi->hs_rate = 349440000;
88+
dsi->lp_rate = 9600000;
89+
dsi->mode_flags = MIPI_DSI_MODE_VIDEO |
90+
MIPI_DSI_MODE_EOT_PACKET |
91+
MIPI_DSI_MODE_VIDEO_BURST;
92+
93+
ret = s6e63m0_probe(dev, s6e63m0_dsi_dcs_write, true);
94+
if (ret)
95+
return ret;
96+
97+
ret = mipi_dsi_attach(dsi);
98+
if (ret < 0)
99+
s6e63m0_remove(dev);
100+
101+
return ret;
102+
}
103+
104+
static int s6e63m0_dsi_remove(struct mipi_dsi_device *dsi)
105+
{
106+
mipi_dsi_detach(dsi);
107+
return s6e63m0_remove(&dsi->dev);
108+
}
109+
110+
static const struct of_device_id s6e63m0_dsi_of_match[] = {
111+
{ .compatible = "samsung,s6e63m0" },
112+
{ /* sentinel */ }
113+
};
114+
MODULE_DEVICE_TABLE(of, s6e63m0_dsi_of_match);
115+
116+
static struct mipi_dsi_driver s6e63m0_dsi_driver = {
117+
.probe = s6e63m0_dsi_probe,
118+
.remove = s6e63m0_dsi_remove,
119+
.driver = {
120+
.name = "panel-samsung-s6e63m0",
121+
.of_match_table = s6e63m0_dsi_of_match,
122+
},
123+
};
124+
module_mipi_dsi_driver(s6e63m0_dsi_driver);
125+
126+
MODULE_AUTHOR("Linus Walleij <linusw@kernel.org>");
127+
MODULE_DESCRIPTION("s6e63m0 LCD DSI Driver");
128+
MODULE_LICENSE("GPL v2");

‎drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static int s6e63m0_spi_probe(struct spi_device *spi)
6060
DRM_DEV_ERROR(dev, "spi setup failed.\n");
6161
return ret;
6262
}
63-
return s6e63m0_probe(dev, s6e63m0_spi_dcs_write);
63+
return s6e63m0_probe(dev, s6e63m0_spi_dcs_write, false);
6464
}
6565

6666
static int s6e63m0_spi_remove(struct spi_device *spi)

‎drivers/gpu/drm/panel/panel-samsung-s6e63m0.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ static int s6e63m0_backlight_register(struct s6e63m0 *ctx)
400400
}
401401

402402
int s6e63m0_probe(struct device *dev,
403-
int (*dcs_write)(struct device *dev, const u8 *data, size_t len))
403+
int (*dcs_write)(struct device *dev, const u8 *data, size_t len),
404+
bool dsi_mode)
404405
{
405406
struct s6e63m0 *ctx;
406407
int ret;
@@ -432,6 +433,7 @@ int s6e63m0_probe(struct device *dev,
432433
}
433434

434435
drm_panel_init(&ctx->panel, dev, &s6e63m0_drm_funcs,
436+
dsi_mode ? DRM_MODE_CONNECTOR_DSI :
435437
DRM_MODE_CONNECTOR_DPI);
436438

437439
ret = s6e63m0_backlight_register(ctx);

‎drivers/gpu/drm/panel/panel-samsung-s6e63m0.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
#define _PANEL_SAMSUNG_S6E63M0_H
55

66
int s6e63m0_probe(struct device *dev,
7-
int (*dcs_write)(struct device *dev, const u8 *data, size_t len));
7+
int (*dcs_write)(struct device *dev, const u8 *data,
8+
size_t len),
9+
bool dsi_mode);
810
int s6e63m0_remove(struct device *dev);
911

1012
#endif /* _PANEL_SAMSUNG_S6E63M0_H */

0 commit comments

Comments
 (0)