aboutsummaryrefslogtreecommitdiffstats
path: root/patches.at91/0128-video-atmelfb-refactor-start-stop.patch
blob: 5f2899a93bc7607ac6b50ffb196136e7916b5994 (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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
From 77d8d936f1c593a6e273e93585514f7d8428c68a Mon Sep 17 00:00:00 2001
From: Wolfram Sang <w.sang@pengutronix.de>
Date: Thu, 19 May 2011 15:12:30 +0200
Subject: video: atmelfb: refactor start/stop
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/video/atmel_lcdfb.c      | 30 +++++++++++++++++++++++-
 drivers/video/atmel_lcdfb_core.c | 50 ++++++++++------------------------------
 include/video/atmel_lcdc.h       |  9 +++++---
 3 files changed, 47 insertions(+), 42 deletions(-)

diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
index 85063d6..422be1a 100644
--- a/drivers/video/atmel_lcdfb.c
+++ b/drivers/video/atmel_lcdfb.c
@@ -25,6 +25,32 @@
 #define ATMEL_LCDC_DMA_BURST_LEN	8	/* words */
 #define ATMEL_LCDC_FIFO_SIZE		512	/* words */
 
+void atmel_lcdfb_start(struct atmel_lcdfb_info *sinfo)
+{
+	lcdc_writel(sinfo, ATMEL_LCDC_DMACON, sinfo->default_dmacon);
+	lcdc_writel(sinfo, ATMEL_LCDC_PWRCON,
+		(sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET)
+		| ATMEL_LCDC_PWR);
+}
+
+static void atmel_lcdfb_stop(struct atmel_lcdfb_info *sinfo, u32 flags)
+{
+	/* Turn off the LCD controller and the DMA controller */
+	lcdc_writel(sinfo, ATMEL_LCDC_PWRCON,
+			sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET);
+
+	/* Wait for the LCDC core to become idle */
+	while (lcdc_readl(sinfo, ATMEL_LCDC_PWRCON) & ATMEL_LCDC_BUSY)
+		msleep(10);
+
+	lcdc_writel(sinfo, ATMEL_LCDC_DMACON, 0);
+
+	if (!(flags & ATMEL_LCDC_STOP_NOWAIT))
+		/* Wait for DMA engine to become idle... */
+		while (lcdc_readl(sinfo, ATMEL_LCDC_DMACON) & ATMEL_LCDC_DMABUSY)
+			msleep(10);
+}
+
 static unsigned long compute_hozval(unsigned long xres, unsigned long lcdcon2)
 {
 	unsigned long value;
@@ -186,7 +212,7 @@ static int atmel_lcdfb_suspend(struct platform_device *pdev, pm_message_t mesg)
 	if (sinfo->atmel_lcdfb_power_control)
 		sinfo->atmel_lcdfb_power_control(0);
 
-	atmel_lcdfb_stop(sinfo);
+	atmel_lcdfb_stop(sinfo, 0);
 	atmel_lcdfb_stop_clock(sinfo);
 
 	return 0;
@@ -218,6 +244,8 @@ static int atmel_lcdfb_resume(struct platform_device *pdev)
 
 static struct atmel_lcdfb_devdata dev_data = {
 	.setup_core = atmel_lcdfb_setup_core,
+	.start = atmel_lcdfb_start,
+	.stop = atmel_lcdfb_stop,
 };
 
 static int __init atmel_lcdfb_probe(struct platform_device *pdev)
diff --git a/drivers/video/atmel_lcdfb_core.c b/drivers/video/atmel_lcdfb_core.c
index 9a7c5eb..8413b76 100644
--- a/drivers/video/atmel_lcdfb_core.c
+++ b/drivers/video/atmel_lcdfb_core.c
@@ -181,38 +181,6 @@ static struct fb_fix_screeninfo atmel_lcdfb_fix = {
 	.accel		= FB_ACCEL_NONE,
 };
 
-static void atmel_lcdfb_stop_nowait(struct atmel_lcdfb_info *sinfo)
-{
-	/* Turn off the LCD controller and the DMA controller */
-	lcdc_writel(sinfo, ATMEL_LCDC_PWRCON,
-			sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET);
-
-	/* Wait for the LCDC core to become idle */
-	while (lcdc_readl(sinfo, ATMEL_LCDC_PWRCON) & ATMEL_LCDC_BUSY)
-		msleep(10);
-
-	lcdc_writel(sinfo, ATMEL_LCDC_DMACON, 0);
-}
-
-void atmel_lcdfb_stop(struct atmel_lcdfb_info *sinfo)
-{
-	atmel_lcdfb_stop_nowait(sinfo);
-
-	/* Wait for DMA engine to become idle... */
-	while (lcdc_readl(sinfo, ATMEL_LCDC_DMACON) & ATMEL_LCDC_DMABUSY)
-		msleep(10);
-}
-EXPORT_SYMBOL_GPL(atmel_lcdfb_stop);
-
-void atmel_lcdfb_start(struct atmel_lcdfb_info *sinfo)
-{
-	lcdc_writel(sinfo, ATMEL_LCDC_DMACON, sinfo->default_dmacon);
-	lcdc_writel(sinfo, ATMEL_LCDC_PWRCON,
-		(sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET)
-		| ATMEL_LCDC_PWR);
-}
-EXPORT_SYMBOL_GPL(atmel_lcdfb_start);
-
 static void atmel_lcdfb_update_dma(struct fb_info *info,
 			       struct fb_var_screeninfo *var)
 {
@@ -439,8 +407,10 @@ static void atmel_lcdfb_reset(struct atmel_lcdfb_info *sinfo)
 {
 	might_sleep();
 
-	atmel_lcdfb_stop(sinfo);
-	atmel_lcdfb_start(sinfo);
+	if (sinfo->dev_data->stop)
+		sinfo->dev_data->stop(sinfo, 0);
+	if (sinfo->dev_data->start)
+		sinfo->dev_data->start(sinfo);
 }
 
 /**
@@ -469,7 +439,8 @@ static int atmel_lcdfb_set_par(struct fb_info *info)
 		 info->var.xres, info->var.yres,
 		 info->var.xres_virtual, info->var.yres_virtual);
 
-	atmel_lcdfb_stop_nowait(sinfo);
+	if (sinfo->dev_data->stop)
+		sinfo->dev_data->stop(sinfo, ATMEL_LCDC_STOP_NOWAIT);
 
 	if (info->var.bits_per_pixel == 1)
 		info->fix.visual = FB_VISUAL_MONO01;
@@ -488,7 +459,8 @@ static int atmel_lcdfb_set_par(struct fb_info *info)
 	/* Now, the LCDC core... */
 	sinfo->dev_data->setup_core(info);
 
-	atmel_lcdfb_start(sinfo);
+	if (sinfo->dev_data->start)
+		sinfo->dev_data->start(sinfo);
 
 	dev_dbg(info->device, "  * DONE\n");
 
@@ -600,13 +572,15 @@ static int atmel_lcdfb_blank(int blank_mode, struct fb_info *info)
 	switch (blank_mode) {
 	case FB_BLANK_UNBLANK:
 	case FB_BLANK_NORMAL:
-		atmel_lcdfb_start(sinfo);
+		if (sinfo->dev_data->start)
+			sinfo->dev_data->start(sinfo);
 		break;
 	case FB_BLANK_VSYNC_SUSPEND:
 	case FB_BLANK_HSYNC_SUSPEND:
 		break;
 	case FB_BLANK_POWERDOWN:
-		atmel_lcdfb_stop(sinfo);
+		if (sinfo->dev_data->stop)
+			sinfo->dev_data->stop(sinfo, 0);
 		break;
 	default:
 		return -EINVAL;
diff --git a/include/video/atmel_lcdc.h b/include/video/atmel_lcdc.h
index b1a5fad1..ea7ce31 100644
--- a/include/video/atmel_lcdc.h
+++ b/include/video/atmel_lcdc.h
@@ -32,17 +32,20 @@
 #define ATMEL_LCDC_WIRING_RGB	1
 #define ATMEL_LCDC_WIRING_RGB555	2
 
-extern void atmel_lcdfb_start(struct atmel_lcdfb_info *sinfo);
-extern void atmel_lcdfb_stop(struct atmel_lcdfb_info *sinfo);
+#define ATMEL_LCDC_STOP_NOWAIT (1 << 0)
+
 extern void atmel_lcdfb_start_clock(struct atmel_lcdfb_info *sinfo);
 extern void atmel_lcdfb_stop_clock(struct atmel_lcdfb_info *sinfo);
-
 extern int __atmel_lcdfb_probe(struct platform_device *pdev,
 				struct atmel_lcdfb_devdata *devdata);
 extern int __atmel_lcdfb_remove(struct platform_device *pdev);
 
+struct atmel_lcdfb_info;
+
 struct atmel_lcdfb_devdata {
 	int (*setup_core)(struct fb_info *info);
+	void (*start)(struct atmel_lcdfb_info *sinfo);
+	void (*stop)(struct atmel_lcdfb_info *sinfo, u32 flags);
 };
 
  /* LCD Controller info data structure, stored in device platform_data */
-- 
1.8.0.197.g5a90748