aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/clps711xfb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/clps711xfb.c')
-rw-r--r--drivers/video/clps711xfb.c156
1 files changed, 19 insertions, 137 deletions
diff --git a/drivers/video/clps711xfb.c b/drivers/video/clps711xfb.c
index f994c8b8f10a..63ecdf8f7baf 100644
--- a/drivers/video/clps711xfb.c
+++ b/drivers/video/clps711xfb.c
@@ -22,19 +22,15 @@
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/seq_file.h>
26#include <linux/slab.h> 25#include <linux/slab.h>
27#include <linux/fb.h> 26#include <linux/fb.h>
28#include <linux/init.h> 27#include <linux/init.h>
29#include <linux/proc_fs.h>
30#include <linux/delay.h> 28#include <linux/delay.h>
31 29
32#include <mach/hardware.h> 30#include <mach/hardware.h>
33#include <asm/mach-types.h> 31#include <asm/mach-types.h>
34#include <linux/uaccess.h> 32#include <linux/uaccess.h>
35 33
36#include <mach/syspld.h>
37
38struct fb_info *cfb; 34struct fb_info *cfb;
39 35
40#define CMAP_MAX_SIZE 16 36#define CMAP_MAX_SIZE 16
@@ -162,44 +158,12 @@ clps7111fb_set_par(struct fb_info *info)
162 158
163static int clps7111fb_blank(int blank, struct fb_info *info) 159static int clps7111fb_blank(int blank, struct fb_info *info)
164{ 160{
165 if (blank) { 161 /* Enable/Disable LCD controller. */
166 if (machine_is_edb7211()) { 162 if (blank)
167 /* Turn off the LCD backlight. */ 163 clps_writel(clps_readl(SYSCON1) & ~SYSCON1_LCDEN, SYSCON1);
168 clps_writeb(clps_readb(PDDR) & ~EDB_PD3_LCDBL, PDDR); 164 else
169 165 clps_writel(clps_readl(SYSCON1) | SYSCON1_LCDEN, SYSCON1);
170 /* Power off the LCD DC-DC converter. */
171 clps_writeb(clps_readb(PDDR) & ~EDB_PD1_LCD_DC_DC_EN, PDDR);
172
173 /* Delay for a little while (half a second). */
174 udelay(100);
175
176 /* Power off the LCD panel. */
177 clps_writeb(clps_readb(PDDR) & ~EDB_PD2_LCDEN, PDDR);
178
179 /* Power off the LCD controller. */
180 clps_writel(clps_readl(SYSCON1) & ~SYSCON1_LCDEN,
181 SYSCON1);
182 }
183 } else {
184 if (machine_is_edb7211()) {
185 /* Power up the LCD controller. */
186 clps_writel(clps_readl(SYSCON1) | SYSCON1_LCDEN,
187 SYSCON1);
188
189 /* Power up the LCD panel. */
190 clps_writeb(clps_readb(PDDR) | EDB_PD2_LCDEN, PDDR);
191
192 /* Delay for a little while. */
193 udelay(100);
194 166
195 /* Power up the LCD DC-DC converter. */
196 clps_writeb(clps_readb(PDDR) | EDB_PD1_LCD_DC_DC_EN,
197 PDDR);
198
199 /* Turn on the LCD backlight. */
200 clps_writeb(clps_readb(PDDR) | EDB_PD3_LCDBL, PDDR);
201 }
202 }
203 return 0; 167 return 0;
204} 168}
205 169
@@ -214,63 +178,7 @@ static struct fb_ops clps7111fb_ops = {
214 .fb_imageblit = cfb_imageblit, 178 .fb_imageblit = cfb_imageblit,
215}; 179};
216 180
217static int backlight_proc_show(struct seq_file *m, void *v) 181static void __devinit clps711x_guess_lcd_params(struct fb_info *info)
218{
219 if (machine_is_edb7211()) {
220 seq_printf(m, "%d\n",
221 (clps_readb(PDDR) & EDB_PD3_LCDBL) ? 1 : 0);
222 }
223
224 return 0;
225}
226
227static int backlight_proc_open(struct inode *inode, struct file *file)
228{
229 return single_open(file, backlight_proc_show, NULL);
230}
231
232static ssize_t backlight_proc_write(struct file *file, const char *buffer,
233 size_t count, loff_t *pos)
234{
235 unsigned char char_value;
236 int value;
237
238 if (count < 1) {
239 return -EINVAL;
240 }
241
242 if (copy_from_user(&char_value, buffer, 1))
243 return -EFAULT;
244
245 value = char_value - '0';
246
247 if (machine_is_edb7211()) {
248 unsigned char port_d;
249
250 port_d = clps_readb(PDDR);
251
252 if (value) {
253 port_d |= EDB_PD3_LCDBL;
254 } else {
255 port_d &= ~EDB_PD3_LCDBL;
256 }
257
258 clps_writeb(port_d, PDDR);
259 }
260
261 return count;
262}
263
264static const struct file_operations backlight_proc_fops = {
265 .owner = THIS_MODULE,
266 .open = backlight_proc_open,
267 .read = seq_read,
268 .llseek = seq_lseek,
269 .release = single_release,
270 .write = backlight_proc_write,
271};
272
273static void __init clps711x_guess_lcd_params(struct fb_info *info)
274{ 182{
275 unsigned int lcdcon, syscon, size; 183 unsigned int lcdcon, syscon, size;
276 unsigned long phys_base = PAGE_OFFSET; 184 unsigned long phys_base = PAGE_OFFSET;
@@ -358,7 +266,7 @@ static void __init clps711x_guess_lcd_params(struct fb_info *info)
358 info->fix.type = FB_TYPE_PACKED_PIXELS; 266 info->fix.type = FB_TYPE_PACKED_PIXELS;
359} 267}
360 268
361int __init clps711xfb_init(void) 269static int __devinit clps711x_fb_probe(struct platform_device *pdev)
362{ 270{
363 int err = -ENOMEM; 271 int err = -ENOMEM;
364 272
@@ -378,55 +286,29 @@ int __init clps711xfb_init(void)
378 286
379 fb_alloc_cmap(&cfb->cmap, CMAP_MAX_SIZE, 0); 287 fb_alloc_cmap(&cfb->cmap, CMAP_MAX_SIZE, 0);
380 288
381 if (!proc_create("backlight", 0444, NULL, &backlight_proc_fops)) {
382 printk("Couldn't create the /proc entry for the backlight.\n");
383 return -EINVAL;
384 }
385
386 /*
387 * Power up the LCD
388 */
389 if (machine_is_p720t()) {
390 PLD_LCDEN = PLD_LCDEN_EN;
391 PLD_PWR |= (PLD_S4_ON|PLD_S3_ON|PLD_S2_ON|PLD_S1_ON);
392 }
393
394 if (machine_is_edb7211()) {
395 /* Power up the LCD panel. */
396 clps_writeb(clps_readb(PDDR) | EDB_PD2_LCDEN, PDDR);
397
398 /* Delay for a little while. */
399 udelay(100);
400
401 /* Power up the LCD DC-DC converter. */
402 clps_writeb(clps_readb(PDDR) | EDB_PD1_LCD_DC_DC_EN, PDDR);
403
404 /* Turn on the LCD backlight. */
405 clps_writeb(clps_readb(PDDR) | EDB_PD3_LCDBL, PDDR);
406 }
407
408 err = register_framebuffer(cfb); 289 err = register_framebuffer(cfb);
409 290
410out: return err; 291out: return err;
411} 292}
412 293
413static void __exit clps711xfb_exit(void) 294static int __devexit clps711x_fb_remove(struct platform_device *pdev)
414{ 295{
415 unregister_framebuffer(cfb); 296 unregister_framebuffer(cfb);
416 kfree(cfb); 297 kfree(cfb);
417 298
418 /* 299 return 0;
419 * Power down the LCD
420 */
421 if (machine_is_p720t()) {
422 PLD_LCDEN = 0;
423 PLD_PWR &= ~(PLD_S4_ON|PLD_S3_ON|PLD_S2_ON|PLD_S1_ON);
424 }
425} 300}
426 301
427module_init(clps711xfb_init); 302static struct platform_driver clps711x_fb_driver = {
428module_exit(clps711xfb_exit); 303 .driver = {
304 .name = "video-clps711x",
305 .owner = THIS_MODULE,
306 },
307 .probe = clps711x_fb_probe,
308 .remove = __devexit_p(clps711x_fb_remove),
309};
310module_platform_driver(clps711x_fb_driver);
429 311
430MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>"); 312MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>");
431MODULE_DESCRIPTION("CLPS711x framebuffer driver"); 313MODULE_DESCRIPTION("CLPS711X framebuffer driver");
432MODULE_LICENSE("GPL"); 314MODULE_LICENSE("GPL");