Lines Matching +full:lcd +full:- +full:olinuxino
1 // SPDX-License-Identifier: GPL-2.0+
3 * LCD-OLinuXino support for panel driver
83 struct lcd_olinuxino *lcd = to_lcd_olinuxino(panel); in lcd_olinuxino_disable() local
85 if (!lcd->enabled) in lcd_olinuxino_disable()
88 lcd->enabled = false; in lcd_olinuxino_disable()
95 struct lcd_olinuxino *lcd = to_lcd_olinuxino(panel); in lcd_olinuxino_unprepare() local
97 if (!lcd->prepared) in lcd_olinuxino_unprepare()
100 gpiod_set_value_cansleep(lcd->enable_gpio, 0); in lcd_olinuxino_unprepare()
101 regulator_disable(lcd->supply); in lcd_olinuxino_unprepare()
103 lcd->prepared = false; in lcd_olinuxino_unprepare()
110 struct lcd_olinuxino *lcd = to_lcd_olinuxino(panel); in lcd_olinuxino_prepare() local
113 if (lcd->prepared) in lcd_olinuxino_prepare()
116 ret = regulator_enable(lcd->supply); in lcd_olinuxino_prepare()
120 gpiod_set_value_cansleep(lcd->enable_gpio, 1); in lcd_olinuxino_prepare()
121 lcd->prepared = true; in lcd_olinuxino_prepare()
128 struct lcd_olinuxino *lcd = to_lcd_olinuxino(panel); in lcd_olinuxino_enable() local
130 if (lcd->enabled) in lcd_olinuxino_enable()
133 lcd->enabled = true; in lcd_olinuxino_enable()
141 struct lcd_olinuxino *lcd = to_lcd_olinuxino(panel); in lcd_olinuxino_get_modes() local
142 struct lcd_olinuxino_info *lcd_info = &lcd->eeprom.info; in lcd_olinuxino_get_modes()
147 for (i = 0; i < lcd->eeprom.num_modes; i++) { in lcd_olinuxino_get_modes()
149 &lcd->eeprom.reserved[i * sizeof(*lcd_mode)]; in lcd_olinuxino_get_modes()
151 mode = drm_mode_create(connector->dev); in lcd_olinuxino_get_modes()
153 dev_err(panel->dev, "failed to add mode %ux%u@%u\n", in lcd_olinuxino_get_modes()
154 lcd_mode->hactive, in lcd_olinuxino_get_modes()
155 lcd_mode->vactive, in lcd_olinuxino_get_modes()
156 lcd_mode->refresh); in lcd_olinuxino_get_modes()
160 mode->clock = lcd_mode->pixelclock; in lcd_olinuxino_get_modes()
161 mode->hdisplay = lcd_mode->hactive; in lcd_olinuxino_get_modes()
162 mode->hsync_start = lcd_mode->hactive + lcd_mode->hfp; in lcd_olinuxino_get_modes()
163 mode->hsync_end = lcd_mode->hactive + lcd_mode->hfp + in lcd_olinuxino_get_modes()
164 lcd_mode->hpw; in lcd_olinuxino_get_modes()
165 mode->htotal = lcd_mode->hactive + lcd_mode->hfp + in lcd_olinuxino_get_modes()
166 lcd_mode->hpw + lcd_mode->hbp; in lcd_olinuxino_get_modes()
167 mode->vdisplay = lcd_mode->vactive; in lcd_olinuxino_get_modes()
168 mode->vsync_start = lcd_mode->vactive + lcd_mode->vfp; in lcd_olinuxino_get_modes()
169 mode->vsync_end = lcd_mode->vactive + lcd_mode->vfp + in lcd_olinuxino_get_modes()
170 lcd_mode->vpw; in lcd_olinuxino_get_modes()
171 mode->vtotal = lcd_mode->vactive + lcd_mode->vfp + in lcd_olinuxino_get_modes()
172 lcd_mode->vpw + lcd_mode->vbp; in lcd_olinuxino_get_modes()
176 mode->type |= DRM_MODE_TYPE_PREFERRED; in lcd_olinuxino_get_modes()
177 mode->type |= DRM_MODE_TYPE_DRIVER; in lcd_olinuxino_get_modes()
185 connector->display_info.width_mm = lcd_info->width_mm; in lcd_olinuxino_get_modes()
186 connector->display_info.height_mm = lcd_info->height_mm; in lcd_olinuxino_get_modes()
187 connector->display_info.bpc = lcd_info->bpc; in lcd_olinuxino_get_modes()
189 if (lcd_info->bus_format) in lcd_olinuxino_get_modes()
190 drm_display_info_set_bus_formats(&connector->display_info, in lcd_olinuxino_get_modes()
191 &lcd_info->bus_format, 1); in lcd_olinuxino_get_modes()
192 connector->display_info.bus_flags = lcd_info->bus_flag; in lcd_olinuxino_get_modes()
208 struct device *dev = &client->dev; in lcd_olinuxino_probe()
209 struct lcd_olinuxino *lcd; in lcd_olinuxino_probe() local
213 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C | in lcd_olinuxino_probe()
215 return -ENODEV; in lcd_olinuxino_probe()
217 lcd = devm_kzalloc(dev, sizeof(*lcd), GFP_KERNEL); in lcd_olinuxino_probe()
218 if (!lcd) in lcd_olinuxino_probe()
219 return -ENOMEM; in lcd_olinuxino_probe()
221 i2c_set_clientdata(client, lcd); in lcd_olinuxino_probe()
222 lcd->dev = dev; in lcd_olinuxino_probe()
223 lcd->client = client; in lcd_olinuxino_probe()
225 mutex_init(&lcd->mutex); in lcd_olinuxino_probe()
229 mutex_lock(&lcd->mutex); in lcd_olinuxino_probe()
233 (u8 *)&lcd->eeprom + i); in lcd_olinuxino_probe()
234 mutex_unlock(&lcd->mutex); in lcd_olinuxino_probe()
242 checksum = ~crc32(~0, (u8 *)&lcd->eeprom, 252); in lcd_olinuxino_probe()
243 if (checksum != lcd->eeprom.checksum) { in lcd_olinuxino_probe()
245 return -EINVAL; in lcd_olinuxino_probe()
249 if (lcd->eeprom.header != LCD_OLINUXINO_HEADER_MAGIC) { in lcd_olinuxino_probe()
251 return -EINVAL; in lcd_olinuxino_probe()
255 lcd->eeprom.info.name, in lcd_olinuxino_probe()
256 lcd->eeprom.revision, in lcd_olinuxino_probe()
257 lcd->eeprom.serial); in lcd_olinuxino_probe()
263 if (lcd->eeprom.num_modes > 4) { in lcd_olinuxino_probe()
265 lcd->eeprom.num_modes = 4; in lcd_olinuxino_probe()
268 lcd->enabled = false; in lcd_olinuxino_probe()
269 lcd->prepared = false; in lcd_olinuxino_probe()
271 lcd->supply = devm_regulator_get(dev, "power"); in lcd_olinuxino_probe()
272 if (IS_ERR(lcd->supply)) in lcd_olinuxino_probe()
273 return PTR_ERR(lcd->supply); in lcd_olinuxino_probe()
275 lcd->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW); in lcd_olinuxino_probe()
276 if (IS_ERR(lcd->enable_gpio)) in lcd_olinuxino_probe()
277 return PTR_ERR(lcd->enable_gpio); in lcd_olinuxino_probe()
279 drm_panel_init(&lcd->panel, dev, &lcd_olinuxino_funcs, in lcd_olinuxino_probe()
282 ret = drm_panel_of_backlight(&lcd->panel); in lcd_olinuxino_probe()
286 drm_panel_add(&lcd->panel); in lcd_olinuxino_probe()
295 drm_panel_remove(&panel->panel); in lcd_olinuxino_remove()
297 drm_panel_disable(&panel->panel); in lcd_olinuxino_remove()
298 drm_panel_unprepare(&panel->panel); in lcd_olinuxino_remove()
304 { .compatible = "olimex,lcd-olinuxino" },
321 MODULE_DESCRIPTION("LCD-OLinuXino driver");