aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c')
-rw-r--r--drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c126
1 files changed, 51 insertions, 75 deletions
diff --git a/drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c b/drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c
index cada8c621e01..74cb0eb45311 100644
--- a/drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c
+++ b/drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c
@@ -20,16 +20,13 @@
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/device.h> 22#include <linux/device.h>
23#include <linux/backlight.h>
24#include <linux/fb.h> 23#include <linux/fb.h>
25#include <linux/err.h> 24#include <linux/err.h>
26#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/gpio.h>
27 27
28#include <video/omapdss.h> 28#include <video/omapdss.h>
29 29#include <video/omap-panel-data.h>
30struct sharp_data {
31 struct backlight_device *bl;
32};
33 30
34static struct omap_video_timings sharp_ls_timings = { 31static struct omap_video_timings sharp_ls_timings = {
35 .x_res = 480, 32 .x_res = 480,
@@ -52,91 +49,67 @@ static struct omap_video_timings sharp_ls_timings = {
52 .sync_pclk_edge = OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES, 49 .sync_pclk_edge = OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES,
53}; 50};
54 51
55static int sharp_ls_bl_update_status(struct backlight_device *bl) 52static inline struct panel_sharp_ls037v7dw01_data
53*get_panel_data(const struct omap_dss_device *dssdev)
56{ 54{
57 struct omap_dss_device *dssdev = dev_get_drvdata(&bl->dev); 55 return (struct panel_sharp_ls037v7dw01_data *) dssdev->data;
58 int level;
59
60 if (!dssdev->set_backlight)
61 return -EINVAL;
62
63 if (bl->props.fb_blank == FB_BLANK_UNBLANK &&
64 bl->props.power == FB_BLANK_UNBLANK)
65 level = bl->props.brightness;
66 else
67 level = 0;
68
69 return dssdev->set_backlight(dssdev, level);
70} 56}
71 57
72static int sharp_ls_bl_get_brightness(struct backlight_device *bl)
73{
74 if (bl->props.fb_blank == FB_BLANK_UNBLANK &&
75 bl->props.power == FB_BLANK_UNBLANK)
76 return bl->props.brightness;
77
78 return 0;
79}
80
81static const struct backlight_ops sharp_ls_bl_ops = {
82 .get_brightness = sharp_ls_bl_get_brightness,
83 .update_status = sharp_ls_bl_update_status,
84};
85
86
87
88static int sharp_ls_panel_probe(struct omap_dss_device *dssdev) 58static int sharp_ls_panel_probe(struct omap_dss_device *dssdev)
89{ 59{
90 struct backlight_properties props; 60 struct panel_sharp_ls037v7dw01_data *pd = get_panel_data(dssdev);
91 struct backlight_device *bl;
92 struct sharp_data *sd;
93 int r; 61 int r;
94 62
63 if (!pd)
64 return -EINVAL;
65
95 dssdev->panel.timings = sharp_ls_timings; 66 dssdev->panel.timings = sharp_ls_timings;
96 67
97 sd = kzalloc(sizeof(*sd), GFP_KERNEL); 68 if (gpio_is_valid(pd->mo_gpio)) {
98 if (!sd) 69 r = devm_gpio_request_one(&dssdev->dev, pd->mo_gpio,
99 return -ENOMEM; 70 GPIOF_OUT_INIT_LOW, "lcd MO");
71 if (r)
72 return r;
73 }
100 74
101 dev_set_drvdata(&dssdev->dev, sd); 75 if (gpio_is_valid(pd->lr_gpio)) {
76 r = devm_gpio_request_one(&dssdev->dev, pd->lr_gpio,
77 GPIOF_OUT_INIT_HIGH, "lcd LR");
78 if (r)
79 return r;
80 }
102 81
103 memset(&props, 0, sizeof(struct backlight_properties)); 82 if (gpio_is_valid(pd->ud_gpio)) {
104 props.max_brightness = dssdev->max_backlight_level; 83 r = devm_gpio_request_one(&dssdev->dev, pd->ud_gpio,
105 props.type = BACKLIGHT_RAW; 84 GPIOF_OUT_INIT_HIGH, "lcd UD");
85 if (r)
86 return r;
87 }
106 88
107 bl = backlight_device_register("sharp-ls", &dssdev->dev, dssdev, 89 if (gpio_is_valid(pd->resb_gpio)) {
108 &sharp_ls_bl_ops, &props); 90 r = devm_gpio_request_one(&dssdev->dev, pd->resb_gpio,
109 if (IS_ERR(bl)) { 91 GPIOF_OUT_INIT_LOW, "lcd RESB");
110 r = PTR_ERR(bl); 92 if (r)
111 kfree(sd); 93 return r;
112 return r;
113 } 94 }
114 sd->bl = bl;
115 95
116 bl->props.fb_blank = FB_BLANK_UNBLANK; 96 if (gpio_is_valid(pd->ini_gpio)) {
117 bl->props.power = FB_BLANK_UNBLANK; 97 r = devm_gpio_request_one(&dssdev->dev, pd->ini_gpio,
118 bl->props.brightness = dssdev->max_backlight_level; 98 GPIOF_OUT_INIT_LOW, "lcd INI");
119 r = sharp_ls_bl_update_status(bl); 99 if (r)
120 if (r < 0) 100 return r;
121 dev_err(&dssdev->dev, "failed to set lcd brightness\n"); 101 }
122 102
123 return 0; 103 return 0;
124} 104}
125 105
126static void __exit sharp_ls_panel_remove(struct omap_dss_device *dssdev) 106static void __exit sharp_ls_panel_remove(struct omap_dss_device *dssdev)
127{ 107{
128 struct sharp_data *sd = dev_get_drvdata(&dssdev->dev);
129 struct backlight_device *bl = sd->bl;
130
131 bl->props.power = FB_BLANK_POWERDOWN;
132 sharp_ls_bl_update_status(bl);
133 backlight_device_unregister(bl);
134
135 kfree(sd);
136} 108}
137 109
138static int sharp_ls_power_on(struct omap_dss_device *dssdev) 110static int sharp_ls_power_on(struct omap_dss_device *dssdev)
139{ 111{
112 struct panel_sharp_ls037v7dw01_data *pd = get_panel_data(dssdev);
140 int r = 0; 113 int r = 0;
141 114
142 if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE) 115 if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
@@ -152,26 +125,29 @@ static int sharp_ls_power_on(struct omap_dss_device *dssdev)
152 /* wait couple of vsyncs until enabling the LCD */ 125 /* wait couple of vsyncs until enabling the LCD */
153 msleep(50); 126 msleep(50);
154 127
155 if (dssdev->platform_enable) { 128 if (gpio_is_valid(pd->resb_gpio))
156 r = dssdev->platform_enable(dssdev); 129 gpio_set_value_cansleep(pd->resb_gpio, 1);
157 if (r) 130
158 goto err1; 131 if (gpio_is_valid(pd->ini_gpio))
159 } 132 gpio_set_value_cansleep(pd->ini_gpio, 1);
160 133
161 return 0; 134 return 0;
162err1:
163 omapdss_dpi_display_disable(dssdev);
164err0: 135err0:
165 return r; 136 return r;
166} 137}
167 138
168static void sharp_ls_power_off(struct omap_dss_device *dssdev) 139static void sharp_ls_power_off(struct omap_dss_device *dssdev)
169{ 140{
141 struct panel_sharp_ls037v7dw01_data *pd = get_panel_data(dssdev);
142
170 if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE) 143 if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
171 return; 144 return;
172 145
173 if (dssdev->platform_disable) 146 if (gpio_is_valid(pd->ini_gpio))
174 dssdev->platform_disable(dssdev); 147 gpio_set_value_cansleep(pd->ini_gpio, 0);
148
149 if (gpio_is_valid(pd->resb_gpio))
150 gpio_set_value_cansleep(pd->resb_gpio, 0);
175 151
176 /* wait at least 5 vsyncs after disabling the LCD */ 152 /* wait at least 5 vsyncs after disabling the LCD */
177 153