summaryrefslogtreecommitdiff
path: root/drivers/video/mvf/mvffb_nec_wqvga.c
blob: 82d8ff371aa5b35df60e197dd14da7b1404413c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
 * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
 */

/*
 * The code contained herein is licensed under the GNU General Public
 * License. You may obtain a copy of the GNU General Public License
 * Version 2 or later at the following locations:
 *
 * http://www.opensource.org/licenses/gpl-license.html
 * http://www.gnu.org/copyleft/gpl.html
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/mvffb.h>
#include <linux/fsl_devices.h>
#include "mvf_dispdrv.h"

struct mvf_lcdif_data {
	struct platform_device *pdev;
	struct mvf_dispdrv_handle *disp_lcdif;
};

#define DISPDRV_LCD	"lcd"

static struct fb_videomode lcdif_modedb[] = {
	{
	 /* 480x272 @ 75 Hz pixel clock - typical - 10.87Mhz*/
	 "NEC-WQVGA", 75, 480, 272, KHZ2PICOS(10870), 2, 2, 1, 1, 41, 2,
	/*Active low HSYC/VSYNC, Sample on falling edge of pxl clk, output not negated*/
	 0,
	 FB_VMODE_NONINTERLACED,
	 0,},
};

static int lcdif_modedb_sz = ARRAY_SIZE(lcdif_modedb);

static int lcdif_init(struct mvf_dispdrv_handle *disp,
	struct mvf_dispdrv_setting *setting)
{
	int ret, i;
	struct mvf_lcdif_data *lcdif = mvf_dispdrv_getdata(disp);
	struct fsl_mvf_lcd_platform_data *plat_data
			= lcdif->pdev->dev.platform_data;
	struct fb_videomode *modedb = lcdif_modedb;
	int modedb_sz = lcdif_modedb_sz;

	printk("lcd-if: init called with dcu = %d!!\n", plat_data->dcu_id);
	printk("The pixel clock in modedb, picosecs = %ld, HZ = %ld\n", KHZ2PICOS(10870), ((PICOS2KHZ(91996)) * 1000UL));

	/* use platform defined dcu */
	setting->dev_id = plat_data->dcu_id;

	ret = fb_find_mode(&setting->fbi->var, setting->fbi, setting->dft_mode_str,
				modedb, modedb_sz, NULL, setting->default_bpp);
	if (!ret) {
		fb_videomode_to_var(&setting->fbi->var, &modedb[0]);
		setting->if_fmt = plat_data->default_ifmt;
	}

	INIT_LIST_HEAD(&setting->fbi->modelist);
	for (i = 0; i < modedb_sz; i++) {
		struct fb_videomode m;
		fb_var_to_videomode(&m, &setting->fbi->var);
		if (fb_mode_is_equal(&m, &modedb[i])) {
			fb_add_videomode(&modedb[i],
					&setting->fbi->modelist);
			break;
		}
	}

	return ret;
}

void lcdif_deinit(struct mvf_dispdrv_handle *disp)
{
	/*TODO*/
}

static struct mvf_dispdrv_driver lcdif_drv = {
	.name 	= DISPDRV_LCD,
	.init 	= lcdif_init,
	.deinit	= lcdif_deinit,
};

static int mvf_lcdif_probe(struct platform_device *pdev)
{
	int ret = 0;
	struct mvf_lcdif_data *lcdif;
	printk("lcdif: probe called!!!\n");

	lcdif = kzalloc(sizeof(struct mvf_lcdif_data), GFP_KERNEL);
	if (!lcdif) {
		ret = -ENOMEM;
		goto alloc_failed;
	}

	lcdif->pdev = pdev;
	lcdif->disp_lcdif = mvf_dispdrv_register(&lcdif_drv);
	mvf_dispdrv_setdata(lcdif->disp_lcdif, lcdif);

	dev_set_drvdata(&pdev->dev, lcdif);

	printk("lcdif: registeration and setdata complete\n");
alloc_failed:
	return ret;
}

static int mvf_lcdif_remove(struct platform_device *pdev)
{
	struct mvf_lcdif_data *lcdif = dev_get_drvdata(&pdev->dev);

	mvf_dispdrv_puthandle(lcdif->disp_lcdif);
	mvf_dispdrv_unregister(lcdif->disp_lcdif);
	kfree(lcdif);
	return 0;
}

static struct platform_driver mvf_lcdif_driver = {
	.driver = {
		   .name = "mvf_lcdif",
		   },
	.probe = mvf_lcdif_probe,
	.remove = mvf_lcdif_remove,
};

static int __init mvf_lcdif_init(void)
{
	return platform_driver_register(&mvf_lcdif_driver);
}

static void __exit mvf_lcdif_exit(void)
{
	platform_driver_unregister(&mvf_lcdif_driver);
}

module_init(mvf_lcdif_init);
module_exit(mvf_lcdif_exit);

MODULE_AUTHOR("Freescale Semiconductor, Inc.");
MODULE_DESCRIPTION("MVF DCUV4 LCD driver");
MODULE_LICENSE("GPL");