diff options
author | Marek Belisko <marek@goldelico.com> | 2014-12-03 16:33:20 -0500 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2015-01-13 05:53:15 -0500 |
commit | 0e8787313a00d4202aad249d0734a30bbde1485b (patch) | |
tree | 8482319c3d3e8b5f3b4fc6b43158be3d065cc7e6 /drivers/video | |
parent | eaa27f34e91a14cdceed26ed6c6793ec1d186115 (diff) |
video: omapdss: Add opa362 driver
opa362 is amplifier for video and can be connected to the tvout pads
of the OMAP3. It has one gpio control for enable/disable of the output
(high impedance).
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: Marek Belisko <marek@goldelico.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/fbdev/omap2/displays-new/Kconfig | 6 | ||||
-rw-r--r-- | drivers/video/fbdev/omap2/displays-new/Makefile | 1 | ||||
-rw-r--r-- | drivers/video/fbdev/omap2/displays-new/encoder-opa362.c | 285 |
3 files changed, 292 insertions, 0 deletions
diff --git a/drivers/video/fbdev/omap2/displays-new/Kconfig b/drivers/video/fbdev/omap2/displays-new/Kconfig index e6cfc38160d3..574710141a61 100644 --- a/drivers/video/fbdev/omap2/displays-new/Kconfig +++ b/drivers/video/fbdev/omap2/displays-new/Kconfig | |||
@@ -1,6 +1,12 @@ | |||
1 | menu "OMAP Display Device Drivers (new device model)" | 1 | menu "OMAP Display Device Drivers (new device model)" |
2 | depends on OMAP2_DSS | 2 | depends on OMAP2_DSS |
3 | 3 | ||
4 | config DISPLAY_ENCODER_OPA362 | ||
5 | tristate "OPA362 external analog amplifier" | ||
6 | help | ||
7 | Driver for OPA362 external analog TV amplifier controlled | ||
8 | through a GPIO. | ||
9 | |||
4 | config DISPLAY_ENCODER_TFP410 | 10 | config DISPLAY_ENCODER_TFP410 |
5 | tristate "TFP410 DPI to DVI Encoder" | 11 | tristate "TFP410 DPI to DVI Encoder" |
6 | help | 12 | help |
diff --git a/drivers/video/fbdev/omap2/displays-new/Makefile b/drivers/video/fbdev/omap2/displays-new/Makefile index 0323a8a1c682..9aa176bfbf2e 100644 --- a/drivers/video/fbdev/omap2/displays-new/Makefile +++ b/drivers/video/fbdev/omap2/displays-new/Makefile | |||
@@ -1,3 +1,4 @@ | |||
1 | obj-$(CONFIG_DISPLAY_ENCODER_OPA362) += encoder-opa362.o | ||
1 | obj-$(CONFIG_DISPLAY_ENCODER_TFP410) += encoder-tfp410.o | 2 | obj-$(CONFIG_DISPLAY_ENCODER_TFP410) += encoder-tfp410.o |
2 | obj-$(CONFIG_DISPLAY_ENCODER_TPD12S015) += encoder-tpd12s015.o | 3 | obj-$(CONFIG_DISPLAY_ENCODER_TPD12S015) += encoder-tpd12s015.o |
3 | obj-$(CONFIG_DISPLAY_CONNECTOR_DVI) += connector-dvi.o | 4 | obj-$(CONFIG_DISPLAY_CONNECTOR_DVI) += connector-dvi.o |
diff --git a/drivers/video/fbdev/omap2/displays-new/encoder-opa362.c b/drivers/video/fbdev/omap2/displays-new/encoder-opa362.c new file mode 100644 index 000000000000..84a6b3367124 --- /dev/null +++ b/drivers/video/fbdev/omap2/displays-new/encoder-opa362.c | |||
@@ -0,0 +1,285 @@ | |||
1 | /* | ||
2 | * OPA362 analog video amplifier with output/power control | ||
3 | * | ||
4 | * Copyright (C) 2014 Golden Delicious Computers | ||
5 | * Author: H. Nikolaus Schaller <hns@goldelico.com> | ||
6 | * | ||
7 | * based on encoder-tfp410 | ||
8 | * | ||
9 | * Copyright (C) 2013 Texas Instruments | ||
10 | * Author: Tomi Valkeinen <tomi.valkeinen@ti.com> | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify it | ||
13 | * under the terms of the GNU General Public License version 2 as published by | ||
14 | * the Free Software Foundation. | ||
15 | */ | ||
16 | |||
17 | #include <linux/gpio.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/platform_device.h> | ||
20 | #include <linux/slab.h> | ||
21 | #include <linux/of_gpio.h> | ||
22 | |||
23 | #include <video/omapdss.h> | ||
24 | |||
25 | struct panel_drv_data { | ||
26 | struct omap_dss_device dssdev; | ||
27 | struct omap_dss_device *in; | ||
28 | |||
29 | struct gpio_desc *enable_gpio; | ||
30 | |||
31 | struct omap_video_timings timings; | ||
32 | }; | ||
33 | |||
34 | #define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev) | ||
35 | |||
36 | static int opa362_connect(struct omap_dss_device *dssdev, | ||
37 | struct omap_dss_device *dst) | ||
38 | { | ||
39 | struct panel_drv_data *ddata = to_panel_data(dssdev); | ||
40 | struct omap_dss_device *in = ddata->in; | ||
41 | int r; | ||
42 | |||
43 | dev_dbg(dssdev->dev, "connect\n"); | ||
44 | |||
45 | if (omapdss_device_is_connected(dssdev)) | ||
46 | return -EBUSY; | ||
47 | |||
48 | r = in->ops.atv->connect(in, dssdev); | ||
49 | if (r) | ||
50 | return r; | ||
51 | |||
52 | dst->src = dssdev; | ||
53 | dssdev->dst = dst; | ||
54 | |||
55 | return 0; | ||
56 | } | ||
57 | |||
58 | static void opa362_disconnect(struct omap_dss_device *dssdev, | ||
59 | struct omap_dss_device *dst) | ||
60 | { | ||
61 | struct panel_drv_data *ddata = to_panel_data(dssdev); | ||
62 | struct omap_dss_device *in = ddata->in; | ||
63 | |||
64 | dev_dbg(dssdev->dev, "disconnect\n"); | ||
65 | |||
66 | WARN_ON(!omapdss_device_is_connected(dssdev)); | ||
67 | if (!omapdss_device_is_connected(dssdev)) | ||
68 | return; | ||
69 | |||
70 | WARN_ON(dst != dssdev->dst); | ||
71 | if (dst != dssdev->dst) | ||
72 | return; | ||
73 | |||
74 | dst->src = NULL; | ||
75 | dssdev->dst = NULL; | ||
76 | |||
77 | in->ops.atv->disconnect(in, &ddata->dssdev); | ||
78 | } | ||
79 | |||
80 | static int opa362_enable(struct omap_dss_device *dssdev) | ||
81 | { | ||
82 | struct panel_drv_data *ddata = to_panel_data(dssdev); | ||
83 | struct omap_dss_device *in = ddata->in; | ||
84 | int r; | ||
85 | |||
86 | dev_dbg(dssdev->dev, "enable\n"); | ||
87 | |||
88 | if (!omapdss_device_is_connected(dssdev)) | ||
89 | return -ENODEV; | ||
90 | |||
91 | if (omapdss_device_is_enabled(dssdev)) | ||
92 | return 0; | ||
93 | |||
94 | in->ops.atv->set_timings(in, &ddata->timings); | ||
95 | |||
96 | r = in->ops.atv->enable(in); | ||
97 | if (r) | ||
98 | return r; | ||
99 | |||
100 | if (ddata->enable_gpio) | ||
101 | gpiod_set_value_cansleep(ddata->enable_gpio, 1); | ||
102 | |||
103 | dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; | ||
104 | |||
105 | return 0; | ||
106 | } | ||
107 | |||
108 | static void opa362_disable(struct omap_dss_device *dssdev) | ||
109 | { | ||
110 | struct panel_drv_data *ddata = to_panel_data(dssdev); | ||
111 | struct omap_dss_device *in = ddata->in; | ||
112 | |||
113 | dev_dbg(dssdev->dev, "disable\n"); | ||
114 | |||
115 | if (!omapdss_device_is_enabled(dssdev)) | ||
116 | return; | ||
117 | |||
118 | if (ddata->enable_gpio) | ||
119 | gpiod_set_value_cansleep(ddata->enable_gpio, 0); | ||
120 | |||
121 | in->ops.atv->disable(in); | ||
122 | |||
123 | dssdev->state = OMAP_DSS_DISPLAY_DISABLED; | ||
124 | } | ||
125 | |||
126 | static void opa362_set_timings(struct omap_dss_device *dssdev, | ||
127 | struct omap_video_timings *timings) | ||
128 | { | ||
129 | struct panel_drv_data *ddata = to_panel_data(dssdev); | ||
130 | struct omap_dss_device *in = ddata->in; | ||
131 | |||
132 | dev_dbg(dssdev->dev, "set_timings\n"); | ||
133 | |||
134 | ddata->timings = *timings; | ||
135 | dssdev->panel.timings = *timings; | ||
136 | |||
137 | in->ops.atv->set_timings(in, timings); | ||
138 | } | ||
139 | |||
140 | static void opa362_get_timings(struct omap_dss_device *dssdev, | ||
141 | struct omap_video_timings *timings) | ||
142 | { | ||
143 | struct panel_drv_data *ddata = to_panel_data(dssdev); | ||
144 | |||
145 | dev_dbg(dssdev->dev, "get_timings\n"); | ||
146 | |||
147 | *timings = ddata->timings; | ||
148 | } | ||
149 | |||
150 | static int opa362_check_timings(struct omap_dss_device *dssdev, | ||
151 | struct omap_video_timings *timings) | ||
152 | { | ||
153 | struct panel_drv_data *ddata = to_panel_data(dssdev); | ||
154 | struct omap_dss_device *in = ddata->in; | ||
155 | |||
156 | dev_dbg(dssdev->dev, "check_timings\n"); | ||
157 | |||
158 | return in->ops.atv->check_timings(in, timings); | ||
159 | } | ||
160 | |||
161 | static void opa362_set_type(struct omap_dss_device *dssdev, | ||
162 | enum omap_dss_venc_type type) | ||
163 | { | ||
164 | /* we can only drive a COMPOSITE output */ | ||
165 | WARN_ON(type != OMAP_DSS_VENC_TYPE_COMPOSITE); | ||
166 | |||
167 | } | ||
168 | |||
169 | static const struct omapdss_atv_ops opa362_atv_ops = { | ||
170 | .connect = opa362_connect, | ||
171 | .disconnect = opa362_disconnect, | ||
172 | |||
173 | .enable = opa362_enable, | ||
174 | .disable = opa362_disable, | ||
175 | |||
176 | .check_timings = opa362_check_timings, | ||
177 | .set_timings = opa362_set_timings, | ||
178 | .get_timings = opa362_get_timings, | ||
179 | |||
180 | .set_type = opa362_set_type, | ||
181 | }; | ||
182 | |||
183 | static int opa362_probe(struct platform_device *pdev) | ||
184 | { | ||
185 | struct device_node *node = pdev->dev.of_node; | ||
186 | struct panel_drv_data *ddata; | ||
187 | struct omap_dss_device *dssdev, *in; | ||
188 | struct gpio_desc *gpio; | ||
189 | int r; | ||
190 | |||
191 | dev_dbg(&pdev->dev, "probe\n"); | ||
192 | |||
193 | if (node == NULL) { | ||
194 | dev_err(&pdev->dev, "Unable to find device tree\n"); | ||
195 | return -EINVAL; | ||
196 | } | ||
197 | |||
198 | ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL); | ||
199 | if (!ddata) | ||
200 | return -ENOMEM; | ||
201 | |||
202 | platform_set_drvdata(pdev, ddata); | ||
203 | |||
204 | gpio = devm_gpiod_get(&pdev->dev, "enable"); | ||
205 | if (IS_ERR(gpio)) { | ||
206 | if (PTR_ERR(gpio) != -ENOENT) | ||
207 | return PTR_ERR(gpio); | ||
208 | |||
209 | gpio = NULL; | ||
210 | } else { | ||
211 | gpiod_direction_output(gpio, 0); | ||
212 | } | ||
213 | |||
214 | ddata->enable_gpio = gpio; | ||
215 | |||
216 | in = omapdss_of_find_source_for_first_ep(node); | ||
217 | if (IS_ERR(in)) { | ||
218 | dev_err(&pdev->dev, "failed to find video source\n"); | ||
219 | return PTR_ERR(in); | ||
220 | } | ||
221 | |||
222 | ddata->in = in; | ||
223 | |||
224 | dssdev = &ddata->dssdev; | ||
225 | dssdev->ops.atv = &opa362_atv_ops; | ||
226 | dssdev->dev = &pdev->dev; | ||
227 | dssdev->type = OMAP_DISPLAY_TYPE_VENC; | ||
228 | dssdev->output_type = OMAP_DISPLAY_TYPE_VENC; | ||
229 | dssdev->owner = THIS_MODULE; | ||
230 | |||
231 | r = omapdss_register_output(dssdev); | ||
232 | if (r) { | ||
233 | dev_err(&pdev->dev, "Failed to register output\n"); | ||
234 | goto err_reg; | ||
235 | } | ||
236 | |||
237 | return 0; | ||
238 | err_reg: | ||
239 | omap_dss_put_device(ddata->in); | ||
240 | return r; | ||
241 | } | ||
242 | |||
243 | static int __exit opa362_remove(struct platform_device *pdev) | ||
244 | { | ||
245 | struct panel_drv_data *ddata = platform_get_drvdata(pdev); | ||
246 | struct omap_dss_device *dssdev = &ddata->dssdev; | ||
247 | struct omap_dss_device *in = ddata->in; | ||
248 | |||
249 | omapdss_unregister_output(&ddata->dssdev); | ||
250 | |||
251 | WARN_ON(omapdss_device_is_enabled(dssdev)); | ||
252 | if (omapdss_device_is_enabled(dssdev)) | ||
253 | opa362_disable(dssdev); | ||
254 | |||
255 | WARN_ON(omapdss_device_is_connected(dssdev)); | ||
256 | if (omapdss_device_is_connected(dssdev)) | ||
257 | opa362_disconnect(dssdev, dssdev->dst); | ||
258 | |||
259 | omap_dss_put_device(in); | ||
260 | |||
261 | return 0; | ||
262 | } | ||
263 | |||
264 | static const struct of_device_id opa362_of_match[] = { | ||
265 | { .compatible = "omapdss,ti,opa362", }, | ||
266 | {}, | ||
267 | }; | ||
268 | MODULE_DEVICE_TABLE(of, opa362_of_match); | ||
269 | |||
270 | static struct platform_driver opa362_driver = { | ||
271 | .probe = opa362_probe, | ||
272 | .remove = __exit_p(opa362_remove), | ||
273 | .driver = { | ||
274 | .name = "amplifier-opa362", | ||
275 | .owner = THIS_MODULE, | ||
276 | .of_match_table = opa362_of_match, | ||
277 | .suppress_bind_attrs = true, | ||
278 | }, | ||
279 | }; | ||
280 | |||
281 | module_platform_driver(opa362_driver); | ||
282 | |||
283 | MODULE_AUTHOR("H. Nikolaus Schaller <hns@goldelico.com>"); | ||
284 | MODULE_DESCRIPTION("OPA362 analog video amplifier with output/power control"); | ||
285 | MODULE_LICENSE("GPL v2"); | ||