11 #include <linux/bitmap.h>
18 #include <linux/slab.h>
19 #include <linux/string.h>
20 #include <linux/types.h>
21 #include <linux/module.h>
29 #define SYSCTRL 0x0000
30 #define SYSCONF 0x0004
32 #define RESREQSET0 0x0018
33 #define RESREQSET1 0x001c
34 #define HSTTOVSET 0x0020
35 #define LPRTOVSET 0x0024
36 #define TATOVSET 0x0028
37 #define PRTOVSET 0x002c
38 #define DSICTRL 0x0030
39 #define DSIINTE 0x0060
40 #define PHYCTRL 0x0070
48 #define CMTSRTREQ 0x0070
49 #define CMTSRTCTR 0x00d0
52 #define MAX_SH_MIPI_DSI 2
63 #define to_sh_mipi(e) container_of(e, struct sh_mipi, entity)
72 if (handle >=
ARRAY_SIZE(mipi_dsi) || handle < 0)
78 static int sh_mipi_send_short(
struct sh_mipi *mipi,
u8 dsi_cmd,
81 u32 data = (dsi_cmd << 24) | (cmd << 16) | (param << 8);
94 #define LCD_CHAN2MIPI(c) ((c) < LCDC_CHAN_MAINLCD || (c) > LCDC_CHAN_SUBLCD ? \
97 static int sh_mipi_dcs(
int handle,
u8 cmd)
105 static int sh_mipi_dcs_param(
int handle,
u8 cmd,
u8 param)
114 static void sh_mipi_dsi_enable(
struct sh_mipi *mipi,
bool enable)
127 sh_mipi_dsi_enable(mipi,
false);
170 linelength = (ch->
lcd_modes[0].xres * 18 + 7) / 8;
198 linelength = (ch->
lcd_modes[0].xres * 18 + 7) / 8;
219 linelength = (ch->
lcd_modes[0].xres * 12 + 7) / 8;
227 linelength = (ch->
lcd_modes[0].xres + 1) / 2;
284 bitmap_fill((
unsigned long *)&tmp, pdata->
lane);
297 (pdata->
clksrc << 16) | (pctype << 12) | datatype,
327 top = linelength << 16;
351 top = ((pdata->
lane * top /
div) - 10) << 16;
355 bottom = (pdata->
lane * bottom /
div) - 12;
358 bpp = linelength / ch->
lcd_modes[0].xres;
359 if ((pdata->
lane / div) >
bpp) {
402 pm_runtime_get_sync(&mipi->
pdev->dev);
406 goto mipi_display_on_fail1;
408 ret = sh_mipi_setup(mipi, pdata);
410 goto mipi_display_on_fail2;
412 sh_mipi_dsi_enable(mipi,
true);
416 mipi_display_on_fail1:
417 pm_runtime_put_sync(&mipi->
pdev->dev);
418 mipi_display_on_fail2:
429 sh_mipi_dsi_enable(mipi,
false);
433 pm_runtime_put_sync(&mipi->
pdev->dev);
437 .display_on = mipi_display_on,
438 .display_off = mipi_display_off,
447 unsigned long rate, f_current;
450 if (!res || !res2 || idx >=
ARRAY_SIZE(mipi_dsi) || !pdata)
458 for (idx = 0; idx <
ARRAY_SIZE(mipi_dsi) && mipi_dsi[
idx]; idx++)
473 mipi->
entity.ops = &mipi_ops;
476 dev_err(&pdev->
dev,
"MIPI register region already claimed\n");
488 dev_err(&pdev->
dev,
"MIPI register region 2 already claimed\n");
510 if (rate > 0 && rate != f_current)
517 dev_dbg(&pdev->
dev,
"DSI-T clk %lu -> %lu\n", f_current, rate);
523 mipi_dsi[
idx] = mipi;
526 pm_runtime_resume(&pdev->
dev);
529 platform_set_drvdata(pdev, &mipi->
entity);
562 for (i = 0; i <
ARRAY_SIZE(mipi_dsi) && mipi_dsi[
i] != mipi; i++)
577 pm_runtime_disable(&pdev->
dev);
587 platform_set_drvdata(pdev,
NULL);
595 .shutdown = sh_mipi_shutdown,
597 .name =
"sh-mipi-dsi",
601 static int __init sh_mipi_init(
void)
607 static void __exit sh_mipi_exit(
void)