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