1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * linux/drivers/video/mmp/panel/tpo_tj032md01bw.c
4 * active panel using spi interface to do init
6 * Copyright (C) 2012 Marvell Technology Group Ltd.
7 * Authors: Guoqing Li <ligq@marvell.com>
8 * Lisa Du <cldu@marvell.com>
9 * Zhou Zhu <zzhu3@marvell.com>
12 #include <linux/module.h>
13 #include <linux/moduleparam.h>
14 #include <linux/kernel.h>
15 #include <linux/errno.h>
16 #include <linux/string.h>
17 #include <linux/delay.h>
18 #include <linux/platform_device.h>
19 #include <linux/err.h>
20 #include <linux/spi/spi.h>
21 #include <video/mmp_disp.h>
66 static u16 poweroff
[] = {
70 struct tpohvga_plat_data
{
71 void (*plat_onoff
)(int status
);
72 struct spi_device
*spi
;
75 static void tpohvga_onoff(struct mmp_panel
*panel
, int status
)
77 struct tpohvga_plat_data
*plat
= panel
->plat_data
;
83 ret
= spi_write(plat
->spi
, init
, sizeof(init
));
85 dev_warn(panel
->dev
, "init cmd failed(%d)\n", ret
);
87 ret
= spi_write(plat
->spi
, poweroff
, sizeof(poweroff
));
89 dev_warn(panel
->dev
, "poweroff cmd failed(%d)\n", ret
);
95 static struct mmp_mode mmp_modes_tpohvga
[] = {
97 .pixclock_freq
= 10394400,
107 .invert_pixclock
= 1,
108 .pix_fmt_out
= PIXFMT_RGB565
,
112 static int tpohvga_get_modelist(struct mmp_panel
*panel
,
113 struct mmp_mode
**modelist
)
115 *modelist
= mmp_modes_tpohvga
;
119 static struct mmp_panel panel_tpohvga
= {
121 .panel_type
= PANELTYPE_ACTIVE
,
122 .get_modelist
= tpohvga_get_modelist
,
123 .set_onoff
= tpohvga_onoff
,
126 static int tpohvga_probe(struct spi_device
*spi
)
128 struct mmp_mach_panel_info
*mi
;
130 struct tpohvga_plat_data
*plat_data
;
132 /* get configs from platform data */
133 mi
= spi
->dev
.platform_data
;
135 dev_err(&spi
->dev
, "%s: no platform data defined\n", __func__
);
139 /* setup spi related info */
140 spi
->bits_per_word
= 16;
141 ret
= spi_setup(spi
);
143 dev_err(&spi
->dev
, "spi setup failed %d", ret
);
147 plat_data
= kzalloc(sizeof(*plat_data
), GFP_KERNEL
);
148 if (plat_data
== NULL
)
151 plat_data
->spi
= spi
;
152 plat_data
->plat_onoff
= mi
->plat_set_onoff
;
153 panel_tpohvga
.plat_data
= plat_data
;
154 panel_tpohvga
.plat_path_name
= mi
->plat_path_name
;
155 panel_tpohvga
.dev
= &spi
->dev
;
157 mmp_register_panel(&panel_tpohvga
);
162 static struct spi_driver panel_tpohvga_driver
= {
166 .probe
= tpohvga_probe
,
168 module_spi_driver(panel_tpohvga_driver
);
170 MODULE_AUTHOR("Lisa Du<cldu@marvell.com>");
171 MODULE_DESCRIPTION("Panel driver for tpohvga");
172 MODULE_LICENSE("GPL");