Lines Matching +full:spi +full:- +full:gpio

1 // SPDX-License-Identifier: GPL-2.0-only
12 #include <linux/spi/spi.h>
14 #include <linux/gpio/consumer.h>
43 struct spi_device *spi; member
54 static int lb035q02_write_reg(struct spi_device *spi, u8 reg, u16 val) in lb035q02_write_reg() argument
82 return spi_sync(spi, &msg); in lb035q02_write_reg()
85 static void init_lb035q02_panel(struct spi_device *spi) in init_lb035q02_panel() argument
88 lb035q02_write_reg(spi, 0x01, 0x6300); in init_lb035q02_panel()
89 lb035q02_write_reg(spi, 0x02, 0x0200); in init_lb035q02_panel()
90 lb035q02_write_reg(spi, 0x03, 0x0177); in init_lb035q02_panel()
91 lb035q02_write_reg(spi, 0x04, 0x04c7); in init_lb035q02_panel()
92 lb035q02_write_reg(spi, 0x05, 0xffc0); in init_lb035q02_panel()
93 lb035q02_write_reg(spi, 0x06, 0xe806); in init_lb035q02_panel()
94 lb035q02_write_reg(spi, 0x0a, 0x4008); in init_lb035q02_panel()
95 lb035q02_write_reg(spi, 0x0b, 0x0000); in init_lb035q02_panel()
96 lb035q02_write_reg(spi, 0x0d, 0x0030); in init_lb035q02_panel()
97 lb035q02_write_reg(spi, 0x0e, 0x2800); in init_lb035q02_panel()
98 lb035q02_write_reg(spi, 0x0f, 0x0000); in init_lb035q02_panel()
99 lb035q02_write_reg(spi, 0x16, 0x9f80); in init_lb035q02_panel()
100 lb035q02_write_reg(spi, 0x17, 0x0a0f); in init_lb035q02_panel()
101 lb035q02_write_reg(spi, 0x1e, 0x00c1); in init_lb035q02_panel()
102 lb035q02_write_reg(spi, 0x30, 0x0300); in init_lb035q02_panel()
103 lb035q02_write_reg(spi, 0x31, 0x0007); in init_lb035q02_panel()
104 lb035q02_write_reg(spi, 0x32, 0x0000); in init_lb035q02_panel()
105 lb035q02_write_reg(spi, 0x33, 0x0000); in init_lb035q02_panel()
106 lb035q02_write_reg(spi, 0x34, 0x0707); in init_lb035q02_panel()
107 lb035q02_write_reg(spi, 0x35, 0x0004); in init_lb035q02_panel()
108 lb035q02_write_reg(spi, 0x36, 0x0302); in init_lb035q02_panel()
109 lb035q02_write_reg(spi, 0x37, 0x0202); in init_lb035q02_panel()
110 lb035q02_write_reg(spi, 0x3a, 0x0a0d); in init_lb035q02_panel()
111 lb035q02_write_reg(spi, 0x3b, 0x0806); in init_lb035q02_panel()
117 struct omap_dss_device *in = ddata->in; in lb035q02_connect()
123 r = in->ops.dpi->connect(in, dssdev); in lb035q02_connect()
127 init_lb035q02_panel(ddata->spi); in lb035q02_connect()
135 struct omap_dss_device *in = ddata->in; in lb035q02_disconnect()
140 in->ops.dpi->disconnect(in, dssdev); in lb035q02_disconnect()
146 struct omap_dss_device *in = ddata->in; in lb035q02_enable()
150 return -ENODEV; in lb035q02_enable()
155 if (ddata->data_lines) in lb035q02_enable()
156 in->ops.dpi->set_data_lines(in, ddata->data_lines); in lb035q02_enable()
157 in->ops.dpi->set_timings(in, &ddata->videomode); in lb035q02_enable()
159 r = in->ops.dpi->enable(in); in lb035q02_enable()
163 if (ddata->enable_gpio) in lb035q02_enable()
164 gpiod_set_value_cansleep(ddata->enable_gpio, 1); in lb035q02_enable()
166 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; in lb035q02_enable()
174 struct omap_dss_device *in = ddata->in; in lb035q02_disable()
179 if (ddata->enable_gpio) in lb035q02_disable()
180 gpiod_set_value_cansleep(ddata->enable_gpio, 0); in lb035q02_disable()
182 in->ops.dpi->disable(in); in lb035q02_disable()
184 dssdev->state = OMAP_DSS_DISPLAY_DISABLED; in lb035q02_disable()
191 struct omap_dss_device *in = ddata->in; in lb035q02_set_timings()
193 ddata->videomode = *timings; in lb035q02_set_timings()
194 dssdev->panel.timings = *timings; in lb035q02_set_timings()
196 in->ops.dpi->set_timings(in, timings); in lb035q02_set_timings()
204 *timings = ddata->videomode; in lb035q02_get_timings()
211 struct omap_dss_device *in = ddata->in; in lb035q02_check_timings()
213 return in->ops.dpi->check_timings(in, timings); in lb035q02_check_timings()
230 static int lb035q02_probe_of(struct spi_device *spi) in lb035q02_probe_of() argument
232 struct device_node *node = spi->dev.of_node; in lb035q02_probe_of()
233 struct panel_drv_data *ddata = spi_get_drvdata(spi); in lb035q02_probe_of()
235 struct gpio_desc *gpio; in lb035q02_probe_of() local
237 gpio = devm_gpiod_get(&spi->dev, "enable", GPIOD_OUT_LOW); in lb035q02_probe_of()
238 if (IS_ERR(gpio)) in lb035q02_probe_of()
239 return dev_err_probe(&spi->dev, PTR_ERR(gpio), in lb035q02_probe_of()
240 "failed to parse enable gpio\n"); in lb035q02_probe_of()
242 ddata->enable_gpio = gpio; in lb035q02_probe_of()
246 dev_err(&spi->dev, "failed to find video source\n"); in lb035q02_probe_of()
250 ddata->in = in; in lb035q02_probe_of()
255 static int lb035q02_panel_spi_probe(struct spi_device *spi) in lb035q02_panel_spi_probe() argument
261 if (!spi->dev.of_node) in lb035q02_panel_spi_probe()
262 return -ENODEV; in lb035q02_panel_spi_probe()
264 ddata = devm_kzalloc(&spi->dev, sizeof(*ddata), GFP_KERNEL); in lb035q02_panel_spi_probe()
266 return -ENOMEM; in lb035q02_panel_spi_probe()
268 spi_set_drvdata(spi, ddata); in lb035q02_panel_spi_probe()
270 ddata->spi = spi; in lb035q02_panel_spi_probe()
272 r = lb035q02_probe_of(spi); in lb035q02_panel_spi_probe()
276 ddata->videomode = lb035q02_timings; in lb035q02_panel_spi_probe()
278 dssdev = &ddata->dssdev; in lb035q02_panel_spi_probe()
279 dssdev->dev = &spi->dev; in lb035q02_panel_spi_probe()
280 dssdev->driver = &lb035q02_ops; in lb035q02_panel_spi_probe()
281 dssdev->type = OMAP_DISPLAY_TYPE_DPI; in lb035q02_panel_spi_probe()
282 dssdev->owner = THIS_MODULE; in lb035q02_panel_spi_probe()
283 dssdev->panel.timings = ddata->videomode; in lb035q02_panel_spi_probe()
284 dssdev->phy.dpi.data_lines = ddata->data_lines; in lb035q02_panel_spi_probe()
288 dev_err(&spi->dev, "Failed to register panel\n"); in lb035q02_panel_spi_probe()
295 omap_dss_put_device(ddata->in); in lb035q02_panel_spi_probe()
299 static void lb035q02_panel_spi_remove(struct spi_device *spi) in lb035q02_panel_spi_remove() argument
301 struct panel_drv_data *ddata = spi_get_drvdata(spi); in lb035q02_panel_spi_remove()
302 struct omap_dss_device *dssdev = &ddata->dssdev; in lb035q02_panel_spi_remove()
303 struct omap_dss_device *in = ddata->in; in lb035q02_panel_spi_remove()
332 MODULE_ALIAS("spi:lgphilips,lb035q02");