2 * linux/drivers/video/mmp/panel/tpo_tj032md01bw.c
3 * active panel using spi interface to do init
5 * Copyright (C) 2012 Marvell Technology Group Ltd.
6 * Authors: Guoqing Li <ligq@marvell.com>
7 * Lisa Du <cldu@marvell.com>
8 * Zhou Zhu <zzhu3@marvell.com>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
20 * You should have received a copy of the GNU General Public License along with
21 * this program. If not, see <http://www.gnu.org/licenses/>.
25 #include <linux/module.h>
26 #include <linux/moduleparam.h>
27 #include <linux/kernel.h>
28 #include <linux/errno.h>
29 #include <linux/string.h>
30 #include <linux/delay.h>
31 #include <linux/platform_device.h>
32 #include <linux/err.h>
33 #include <linux/spi/spi.h>
34 #include <video/mmp_disp.h>
79 static u16 poweroff
[] = {
83 struct tpohvga_plat_data
{
84 void (*plat_onoff
)(int status
);
85 struct spi_device
*spi
;
88 static void tpohvga_onoff(struct mmp_panel
*panel
, int status
)
90 struct tpohvga_plat_data
*plat
= panel
->plat_data
;
96 ret
= spi_write(plat
->spi
, init
, sizeof(init
));
98 dev_warn(panel
->dev
, "init cmd failed(%d)\n", ret
);
100 ret
= spi_write(plat
->spi
, poweroff
, sizeof(poweroff
));
102 dev_warn(panel
->dev
, "poweroff cmd failed(%d)\n", ret
);
108 static struct mmp_mode mmp_modes_tpohvga
[] = {
110 .pixclock_freq
= 10394400,
120 .invert_pixclock
= 1,
121 .pix_fmt_out
= PIXFMT_RGB565
,
125 static int tpohvga_get_modelist(struct mmp_panel
*panel
,
126 struct mmp_mode
**modelist
)
128 *modelist
= mmp_modes_tpohvga
;
132 static struct mmp_panel panel_tpohvga
= {
134 .panel_type
= PANELTYPE_ACTIVE
,
135 .get_modelist
= tpohvga_get_modelist
,
136 .set_onoff
= tpohvga_onoff
,
139 static int tpohvga_probe(struct spi_device
*spi
)
141 struct mmp_mach_panel_info
*mi
;
143 struct tpohvga_plat_data
*plat_data
;
145 /* get configs from platform data */
146 mi
= spi
->dev
.platform_data
;
148 dev_err(&spi
->dev
, "%s: no platform data defined\n", __func__
);
152 /* setup spi related info */
153 spi
->bits_per_word
= 16;
154 ret
= spi_setup(spi
);
156 dev_err(&spi
->dev
, "spi setup failed %d", ret
);
160 plat_data
= kzalloc(sizeof(*plat_data
), GFP_KERNEL
);
161 if (plat_data
== NULL
)
164 plat_data
->spi
= spi
;
165 plat_data
->plat_onoff
= mi
->plat_set_onoff
;
166 panel_tpohvga
.plat_data
= plat_data
;
167 panel_tpohvga
.plat_path_name
= mi
->plat_path_name
;
168 panel_tpohvga
.dev
= &spi
->dev
;
170 mmp_register_panel(&panel_tpohvga
);
175 static struct spi_driver panel_tpohvga_driver
= {
179 .probe
= tpohvga_probe
,
181 module_spi_driver(panel_tpohvga_driver
);
183 MODULE_AUTHOR("Lisa Du<cldu@marvell.com>");
184 MODULE_DESCRIPTION("Panel driver for tpohvga");
185 MODULE_LICENSE("GPL");