Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
jornada720_lcd.c
Go to the documentation of this file.
1 /*
2  *
3  * LCD driver for HP Jornada 700 series (710/720/728)
4  * Copyright (C) 2006-2009 Kristoffer Ericson <[email protected]>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License version
8  * 2 or any later version as published by the Free Software Foundation.
9  *
10  */
11 
12 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13 
14 #include <linux/device.h>
15 #include <linux/fb.h>
16 #include <linux/kernel.h>
17 #include <linux/lcd.h>
18 #include <linux/module.h>
19 #include <linux/platform_device.h>
20 #include <linux/delay.h>
21 
22 #include <mach/jornada720.h>
23 #include <mach/hardware.h>
24 
25 #include <video/s1d13xxxfb.h>
26 
27 #define LCD_MAX_CONTRAST 0xff
28 #define LCD_DEF_CONTRAST 0x80
29 
30 static int jornada_lcd_get_power(struct lcd_device *dev)
31 {
32  /* LDD2 in PPC = LCD POWER */
33  if (PPSR & PPC_LDD2)
34  return FB_BLANK_UNBLANK; /* PW ON */
35  else
36  return FB_BLANK_POWERDOWN; /* PW OFF */
37 }
38 
39 static int jornada_lcd_get_contrast(struct lcd_device *dev)
40 {
41  int ret;
42 
43  if (jornada_lcd_get_power(dev) != FB_BLANK_UNBLANK)
44  return 0;
45 
47 
49  pr_err("get contrast failed\n");
51  return -ETIMEDOUT;
52  } else {
55  return ret;
56  }
57 }
58 
59 static int jornada_lcd_set_contrast(struct lcd_device *dev, int value)
60 {
61  int ret;
62 
64 
65  /* start by sending our set contrast cmd to mcu */
67 
68  /* push the new value */
69  if (jornada_ssp_byte(value) != TXDUMMY) {
70  pr_err("set contrast failed\n");
72  return -ETIMEDOUT;
73  }
74 
75  /* if we get here we can assume everything went well */
77 
78  return 0;
79 }
80 
81 static int jornada_lcd_set_power(struct lcd_device *dev, int power)
82 {
83  if (power != FB_BLANK_UNBLANK) {
84  PPSR &= ~PPC_LDD2;
85  PPDR |= PPC_LDD2;
86  } else
87  PPSR |= PPC_LDD2;
88 
89  return 0;
90 }
91 
92 static struct lcd_ops jornada_lcd_props = {
93  .get_contrast = jornada_lcd_get_contrast,
94  .set_contrast = jornada_lcd_set_contrast,
95  .get_power = jornada_lcd_get_power,
96  .set_power = jornada_lcd_set_power,
97 };
98 
99 static int jornada_lcd_probe(struct platform_device *pdev)
100 {
101  struct lcd_device *lcd_device;
102  int ret;
103 
104  lcd_device = lcd_device_register(S1D_DEVICENAME, &pdev->dev, NULL, &jornada_lcd_props);
105 
106  if (IS_ERR(lcd_device)) {
107  ret = PTR_ERR(lcd_device);
108  pr_err("failed to register device\n");
109  return ret;
110  }
111 
112  platform_set_drvdata(pdev, lcd_device);
113 
114  /* lets set our default values */
115  jornada_lcd_set_contrast(lcd_device, LCD_DEF_CONTRAST);
116  jornada_lcd_set_power(lcd_device, FB_BLANK_UNBLANK);
117  /* give it some time to startup */
118  msleep(100);
119 
120  return 0;
121 }
122 
123 static int jornada_lcd_remove(struct platform_device *pdev)
124 {
125  struct lcd_device *lcd_device = platform_get_drvdata(pdev);
126 
127  lcd_device_unregister(lcd_device);
128 
129  return 0;
130 }
131 
132 static struct platform_driver jornada_lcd_driver = {
133  .probe = jornada_lcd_probe,
134  .remove = jornada_lcd_remove,
135  .driver = {
136  .name = "jornada_lcd",
137  },
138 };
139 
140 module_platform_driver(jornada_lcd_driver);
141 
142 MODULE_AUTHOR("Kristoffer Ericson <[email protected]>");
143 MODULE_DESCRIPTION("HP Jornada 710/720/728 LCD driver");
144 MODULE_LICENSE("GPL");