Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Texas Instruments |
| 3 | * Author: Rob Clark <robdclark@gmail.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 as published by |
| 7 | * the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | * more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License along with |
| 15 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | #include <linux/pinctrl/pinmux.h> |
| 19 | #include <linux/pinctrl/consumer.h> |
| 20 | #include <linux/backlight.h> |
Ezequiel Garcia | d898ce0 | 2014-09-02 09:51:22 -0300 | [diff] [blame] | 21 | #include <linux/gpio/consumer.h> |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 22 | #include <video/display_timing.h> |
| 23 | #include <video/of_display_timing.h> |
| 24 | #include <video/videomode.h> |
| 25 | |
| 26 | #include "tilcdc_drv.h" |
| 27 | |
| 28 | struct panel_module { |
| 29 | struct tilcdc_module base; |
| 30 | struct tilcdc_panel_info *info; |
| 31 | struct display_timings *timings; |
| 32 | struct backlight_device *backlight; |
Ezequiel Garcia | d898ce0 | 2014-09-02 09:51:22 -0300 | [diff] [blame] | 33 | struct gpio_desc *enable_gpio; |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 34 | }; |
| 35 | #define to_panel_module(x) container_of(x, struct panel_module, base) |
| 36 | |
| 37 | |
| 38 | /* |
| 39 | * Encoder: |
| 40 | */ |
| 41 | |
| 42 | struct panel_encoder { |
| 43 | struct drm_encoder base; |
| 44 | struct panel_module *mod; |
| 45 | }; |
| 46 | #define to_panel_encoder(x) container_of(x, struct panel_encoder, base) |
| 47 | |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 48 | static void panel_encoder_dpms(struct drm_encoder *encoder, int mode) |
| 49 | { |
| 50 | struct panel_encoder *panel_encoder = to_panel_encoder(encoder); |
| 51 | struct backlight_device *backlight = panel_encoder->mod->backlight; |
Ezequiel Garcia | d898ce0 | 2014-09-02 09:51:22 -0300 | [diff] [blame] | 52 | struct gpio_desc *gpio = panel_encoder->mod->enable_gpio; |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 53 | |
Ezequiel Garcia | d898ce0 | 2014-09-02 09:51:22 -0300 | [diff] [blame] | 54 | if (backlight) { |
| 55 | backlight->props.power = mode == DRM_MODE_DPMS_ON ? |
| 56 | FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; |
| 57 | backlight_update_status(backlight); |
| 58 | } |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 59 | |
Ezequiel Garcia | d898ce0 | 2014-09-02 09:51:22 -0300 | [diff] [blame] | 60 | if (gpio) |
| 61 | gpiod_set_value_cansleep(gpio, |
| 62 | mode == DRM_MODE_DPMS_ON ? 1 : 0); |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 63 | } |
| 64 | |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 65 | static void panel_encoder_prepare(struct drm_encoder *encoder) |
| 66 | { |
| 67 | struct panel_encoder *panel_encoder = to_panel_encoder(encoder); |
| 68 | panel_encoder_dpms(encoder, DRM_MODE_DPMS_OFF); |
| 69 | tilcdc_crtc_set_panel_info(encoder->crtc, panel_encoder->mod->info); |
| 70 | } |
| 71 | |
| 72 | static void panel_encoder_commit(struct drm_encoder *encoder) |
| 73 | { |
| 74 | panel_encoder_dpms(encoder, DRM_MODE_DPMS_ON); |
| 75 | } |
| 76 | |
| 77 | static void panel_encoder_mode_set(struct drm_encoder *encoder, |
| 78 | struct drm_display_mode *mode, |
| 79 | struct drm_display_mode *adjusted_mode) |
| 80 | { |
| 81 | /* nothing needed */ |
| 82 | } |
| 83 | |
| 84 | static const struct drm_encoder_funcs panel_encoder_funcs = { |
Jyri Sarha | d0ec32c | 2016-02-23 12:44:27 +0200 | [diff] [blame] | 85 | .destroy = drm_encoder_cleanup, |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | static const struct drm_encoder_helper_funcs panel_encoder_helper_funcs = { |
| 89 | .dpms = panel_encoder_dpms, |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 90 | .prepare = panel_encoder_prepare, |
| 91 | .commit = panel_encoder_commit, |
| 92 | .mode_set = panel_encoder_mode_set, |
| 93 | }; |
| 94 | |
| 95 | static struct drm_encoder *panel_encoder_create(struct drm_device *dev, |
| 96 | struct panel_module *mod) |
| 97 | { |
| 98 | struct panel_encoder *panel_encoder; |
| 99 | struct drm_encoder *encoder; |
| 100 | int ret; |
| 101 | |
Jyri Sarha | d0ec32c | 2016-02-23 12:44:27 +0200 | [diff] [blame] | 102 | panel_encoder = devm_kzalloc(dev->dev, sizeof(*panel_encoder), |
| 103 | GFP_KERNEL); |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 104 | if (!panel_encoder) { |
| 105 | dev_err(dev->dev, "allocation failed\n"); |
| 106 | return NULL; |
| 107 | } |
| 108 | |
| 109 | panel_encoder->mod = mod; |
| 110 | |
| 111 | encoder = &panel_encoder->base; |
| 112 | encoder->possible_crtcs = 1; |
| 113 | |
| 114 | ret = drm_encoder_init(dev, encoder, &panel_encoder_funcs, |
Ville Syrjälä | 13a3d91 | 2015-12-09 16:20:18 +0200 | [diff] [blame] | 115 | DRM_MODE_ENCODER_LVDS, NULL); |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 116 | if (ret < 0) |
| 117 | goto fail; |
| 118 | |
| 119 | drm_encoder_helper_add(encoder, &panel_encoder_helper_funcs); |
| 120 | |
| 121 | return encoder; |
| 122 | |
| 123 | fail: |
Jyri Sarha | d0ec32c | 2016-02-23 12:44:27 +0200 | [diff] [blame] | 124 | drm_encoder_cleanup(encoder); |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 125 | return NULL; |
| 126 | } |
| 127 | |
| 128 | /* |
| 129 | * Connector: |
| 130 | */ |
| 131 | |
| 132 | struct panel_connector { |
| 133 | struct drm_connector base; |
| 134 | |
| 135 | struct drm_encoder *encoder; /* our connected encoder */ |
| 136 | struct panel_module *mod; |
| 137 | }; |
| 138 | #define to_panel_connector(x) container_of(x, struct panel_connector, base) |
| 139 | |
| 140 | |
| 141 | static void panel_connector_destroy(struct drm_connector *connector) |
| 142 | { |
Sachin Kamat | 62eb3e2 | 2014-07-09 17:12:57 +0530 | [diff] [blame] | 143 | drm_connector_unregister(connector); |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 144 | drm_connector_cleanup(connector); |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | static enum drm_connector_status panel_connector_detect( |
| 148 | struct drm_connector *connector, |
| 149 | bool force) |
| 150 | { |
| 151 | return connector_status_connected; |
| 152 | } |
| 153 | |
| 154 | static int panel_connector_get_modes(struct drm_connector *connector) |
| 155 | { |
| 156 | struct drm_device *dev = connector->dev; |
| 157 | struct panel_connector *panel_connector = to_panel_connector(connector); |
| 158 | struct display_timings *timings = panel_connector->mod->timings; |
| 159 | int i; |
| 160 | |
| 161 | for (i = 0; i < timings->num_timings; i++) { |
| 162 | struct drm_display_mode *mode = drm_mode_create(dev); |
| 163 | struct videomode vm; |
| 164 | |
Tomi Valkeinen | 6cd2c7d | 2013-03-21 14:20:12 +0200 | [diff] [blame] | 165 | if (videomode_from_timings(timings, &vm, i)) |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 166 | break; |
| 167 | |
| 168 | drm_display_mode_from_videomode(&vm, mode); |
| 169 | |
| 170 | mode->type = DRM_MODE_TYPE_DRIVER; |
| 171 | |
| 172 | if (timings->native_mode == i) |
| 173 | mode->type |= DRM_MODE_TYPE_PREFERRED; |
| 174 | |
| 175 | drm_mode_set_name(mode); |
| 176 | drm_mode_probed_add(connector, mode); |
| 177 | } |
| 178 | |
| 179 | return i; |
| 180 | } |
| 181 | |
| 182 | static int panel_connector_mode_valid(struct drm_connector *connector, |
| 183 | struct drm_display_mode *mode) |
| 184 | { |
| 185 | struct tilcdc_drm_private *priv = connector->dev->dev_private; |
| 186 | /* our only constraints are what the crtc can generate: */ |
| 187 | return tilcdc_crtc_mode_valid(priv->crtc, mode); |
| 188 | } |
| 189 | |
| 190 | static struct drm_encoder *panel_connector_best_encoder( |
| 191 | struct drm_connector *connector) |
| 192 | { |
| 193 | struct panel_connector *panel_connector = to_panel_connector(connector); |
| 194 | return panel_connector->encoder; |
| 195 | } |
| 196 | |
| 197 | static const struct drm_connector_funcs panel_connector_funcs = { |
| 198 | .destroy = panel_connector_destroy, |
| 199 | .dpms = drm_helper_connector_dpms, |
| 200 | .detect = panel_connector_detect, |
| 201 | .fill_modes = drm_helper_probe_single_connector_modes, |
| 202 | }; |
| 203 | |
| 204 | static const struct drm_connector_helper_funcs panel_connector_helper_funcs = { |
| 205 | .get_modes = panel_connector_get_modes, |
| 206 | .mode_valid = panel_connector_mode_valid, |
| 207 | .best_encoder = panel_connector_best_encoder, |
| 208 | }; |
| 209 | |
| 210 | static struct drm_connector *panel_connector_create(struct drm_device *dev, |
| 211 | struct panel_module *mod, struct drm_encoder *encoder) |
| 212 | { |
| 213 | struct panel_connector *panel_connector; |
| 214 | struct drm_connector *connector; |
| 215 | int ret; |
| 216 | |
Jyri Sarha | d0ec32c | 2016-02-23 12:44:27 +0200 | [diff] [blame] | 217 | panel_connector = devm_kzalloc(dev->dev, sizeof(*panel_connector), |
| 218 | GFP_KERNEL); |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 219 | if (!panel_connector) { |
| 220 | dev_err(dev->dev, "allocation failed\n"); |
| 221 | return NULL; |
| 222 | } |
| 223 | |
| 224 | panel_connector->encoder = encoder; |
| 225 | panel_connector->mod = mod; |
| 226 | |
| 227 | connector = &panel_connector->base; |
| 228 | |
| 229 | drm_connector_init(dev, connector, &panel_connector_funcs, |
| 230 | DRM_MODE_CONNECTOR_LVDS); |
| 231 | drm_connector_helper_add(connector, &panel_connector_helper_funcs); |
| 232 | |
| 233 | connector->interlace_allowed = 0; |
| 234 | connector->doublescan_allowed = 0; |
| 235 | |
| 236 | ret = drm_mode_connector_attach_encoder(connector, encoder); |
| 237 | if (ret) |
| 238 | goto fail; |
| 239 | |
Thomas Wood | 34ea3d3 | 2014-05-29 16:57:41 +0100 | [diff] [blame] | 240 | drm_connector_register(connector); |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 241 | |
| 242 | return connector; |
| 243 | |
| 244 | fail: |
| 245 | panel_connector_destroy(connector); |
| 246 | return NULL; |
| 247 | } |
| 248 | |
| 249 | /* |
| 250 | * Module: |
| 251 | */ |
| 252 | |
| 253 | static int panel_modeset_init(struct tilcdc_module *mod, struct drm_device *dev) |
| 254 | { |
| 255 | struct panel_module *panel_mod = to_panel_module(mod); |
| 256 | struct tilcdc_drm_private *priv = dev->dev_private; |
| 257 | struct drm_encoder *encoder; |
| 258 | struct drm_connector *connector; |
| 259 | |
| 260 | encoder = panel_encoder_create(dev, panel_mod); |
| 261 | if (!encoder) |
| 262 | return -ENOMEM; |
| 263 | |
| 264 | connector = panel_connector_create(dev, panel_mod, encoder); |
| 265 | if (!connector) |
| 266 | return -ENOMEM; |
| 267 | |
| 268 | priv->encoders[priv->num_encoders++] = encoder; |
| 269 | priv->connectors[priv->num_connectors++] = connector; |
| 270 | |
| 271 | return 0; |
| 272 | } |
| 273 | |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 274 | static const struct tilcdc_module_ops panel_module_ops = { |
| 275 | .modeset_init = panel_modeset_init, |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 276 | }; |
| 277 | |
| 278 | /* |
| 279 | * Device: |
| 280 | */ |
| 281 | |
| 282 | /* maybe move this somewhere common if it is needed by other outputs? */ |
Sachin Kamat | 1733d01 | 2013-03-02 15:53:09 +0530 | [diff] [blame] | 283 | static struct tilcdc_panel_info *of_get_panel_info(struct device_node *np) |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 284 | { |
| 285 | struct device_node *info_np; |
| 286 | struct tilcdc_panel_info *info; |
| 287 | int ret = 0; |
| 288 | |
| 289 | if (!np) { |
| 290 | pr_err("%s: no devicenode given\n", __func__); |
| 291 | return NULL; |
| 292 | } |
| 293 | |
| 294 | info_np = of_get_child_by_name(np, "panel-info"); |
| 295 | if (!info_np) { |
| 296 | pr_err("%s: could not find panel-info node\n", __func__); |
| 297 | return NULL; |
| 298 | } |
| 299 | |
| 300 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
| 301 | if (!info) { |
| 302 | pr_err("%s: allocation failed\n", __func__); |
Ezequiel Garcia | 9430dfa | 2014-09-02 09:51:16 -0300 | [diff] [blame] | 303 | of_node_put(info_np); |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 304 | return NULL; |
| 305 | } |
| 306 | |
| 307 | ret |= of_property_read_u32(info_np, "ac-bias", &info->ac_bias); |
| 308 | ret |= of_property_read_u32(info_np, "ac-bias-intrpt", &info->ac_bias_intrpt); |
| 309 | ret |= of_property_read_u32(info_np, "dma-burst-sz", &info->dma_burst_sz); |
| 310 | ret |= of_property_read_u32(info_np, "bpp", &info->bpp); |
| 311 | ret |= of_property_read_u32(info_np, "fdd", &info->fdd); |
| 312 | ret |= of_property_read_u32(info_np, "sync-edge", &info->sync_edge); |
| 313 | ret |= of_property_read_u32(info_np, "sync-ctrl", &info->sync_ctrl); |
| 314 | ret |= of_property_read_u32(info_np, "raster-order", &info->raster_order); |
| 315 | ret |= of_property_read_u32(info_np, "fifo-th", &info->fifo_th); |
| 316 | |
| 317 | /* optional: */ |
| 318 | info->tft_alt_mode = of_property_read_bool(info_np, "tft-alt-mode"); |
| 319 | info->invert_pxl_clk = of_property_read_bool(info_np, "invert-pxl-clk"); |
| 320 | |
| 321 | if (ret) { |
| 322 | pr_err("%s: error reading panel-info properties\n", __func__); |
| 323 | kfree(info); |
Ezequiel Garcia | 9430dfa | 2014-09-02 09:51:16 -0300 | [diff] [blame] | 324 | of_node_put(info_np); |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 325 | return NULL; |
| 326 | } |
Ezequiel Garcia | 9430dfa | 2014-09-02 09:51:16 -0300 | [diff] [blame] | 327 | of_node_put(info_np); |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 328 | |
| 329 | return info; |
| 330 | } |
| 331 | |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 332 | static int panel_probe(struct platform_device *pdev) |
| 333 | { |
Ezequiel Garcia | 18c44db | 2014-09-02 09:51:20 -0300 | [diff] [blame] | 334 | struct device_node *bl_node, *node = pdev->dev.of_node; |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 335 | struct panel_module *panel_mod; |
| 336 | struct tilcdc_module *mod; |
| 337 | struct pinctrl *pinctrl; |
Ezequiel Garcia | 12778fc | 2014-09-02 09:51:21 -0300 | [diff] [blame] | 338 | int ret; |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 339 | |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 340 | /* bail out early if no DT data: */ |
| 341 | if (!node) { |
| 342 | dev_err(&pdev->dev, "device-tree data is missing\n"); |
| 343 | return -ENXIO; |
| 344 | } |
| 345 | |
Ezequiel Garcia | 971645d | 2014-09-02 09:51:19 -0300 | [diff] [blame] | 346 | panel_mod = devm_kzalloc(&pdev->dev, sizeof(*panel_mod), GFP_KERNEL); |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 347 | if (!panel_mod) |
| 348 | return -ENOMEM; |
| 349 | |
Ezequiel Garcia | 18c44db | 2014-09-02 09:51:20 -0300 | [diff] [blame] | 350 | bl_node = of_parse_phandle(node, "backlight", 0); |
| 351 | if (bl_node) { |
| 352 | panel_mod->backlight = of_find_backlight_by_node(bl_node); |
| 353 | of_node_put(bl_node); |
| 354 | |
| 355 | if (!panel_mod->backlight) |
| 356 | return -EPROBE_DEFER; |
| 357 | |
| 358 | dev_info(&pdev->dev, "found backlight\n"); |
| 359 | } |
| 360 | |
Uwe Kleine-König | 26a5bd2 | 2015-02-11 17:32:53 +0100 | [diff] [blame] | 361 | panel_mod->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable", |
| 362 | GPIOD_OUT_LOW); |
Ezequiel Garcia | d898ce0 | 2014-09-02 09:51:22 -0300 | [diff] [blame] | 363 | if (IS_ERR(panel_mod->enable_gpio)) { |
| 364 | ret = PTR_ERR(panel_mod->enable_gpio); |
Uwe Kleine-König | 26a5bd2 | 2015-02-11 17:32:53 +0100 | [diff] [blame] | 365 | dev_err(&pdev->dev, "failed to request enable GPIO\n"); |
| 366 | goto fail_backlight; |
Ezequiel Garcia | d898ce0 | 2014-09-02 09:51:22 -0300 | [diff] [blame] | 367 | } |
| 368 | |
Uwe Kleine-König | 26a5bd2 | 2015-02-11 17:32:53 +0100 | [diff] [blame] | 369 | if (panel_mod->enable_gpio) |
| 370 | dev_info(&pdev->dev, "found enable GPIO\n"); |
| 371 | |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 372 | mod = &panel_mod->base; |
Guido Martínez | 7cdcce9 | 2014-06-17 11:17:10 -0300 | [diff] [blame] | 373 | pdev->dev.platform_data = mod; |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 374 | |
| 375 | tilcdc_module_init(mod, "panel", &panel_module_ops); |
| 376 | |
| 377 | pinctrl = devm_pinctrl_get_select_default(&pdev->dev); |
| 378 | if (IS_ERR(pinctrl)) |
| 379 | dev_warn(&pdev->dev, "pins are not configured\n"); |
| 380 | |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 381 | panel_mod->timings = of_get_display_timings(node); |
| 382 | if (!panel_mod->timings) { |
| 383 | dev_err(&pdev->dev, "could not get panel timings\n"); |
Ezequiel Garcia | 12778fc | 2014-09-02 09:51:21 -0300 | [diff] [blame] | 384 | ret = -EINVAL; |
Guido Martínez | 7cdcce9 | 2014-06-17 11:17:10 -0300 | [diff] [blame] | 385 | goto fail_free; |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | panel_mod->info = of_get_panel_info(node); |
| 389 | if (!panel_mod->info) { |
| 390 | dev_err(&pdev->dev, "could not get panel info\n"); |
Ezequiel Garcia | 12778fc | 2014-09-02 09:51:21 -0300 | [diff] [blame] | 391 | ret = -EINVAL; |
Guido Martínez | 7cdcce9 | 2014-06-17 11:17:10 -0300 | [diff] [blame] | 392 | goto fail_timings; |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 393 | } |
| 394 | |
Benoit Parrot | dc28aa0 | 2013-06-18 17:18:31 -0500 | [diff] [blame] | 395 | mod->preferred_bpp = panel_mod->info->bpp; |
| 396 | |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 397 | return 0; |
| 398 | |
Guido Martínez | 7cdcce9 | 2014-06-17 11:17:10 -0300 | [diff] [blame] | 399 | fail_timings: |
| 400 | display_timings_release(panel_mod->timings); |
| 401 | |
| 402 | fail_free: |
Guido Martínez | 7cdcce9 | 2014-06-17 11:17:10 -0300 | [diff] [blame] | 403 | tilcdc_module_cleanup(mod); |
Ezequiel Garcia | d898ce0 | 2014-09-02 09:51:22 -0300 | [diff] [blame] | 404 | |
| 405 | fail_backlight: |
Ezequiel Garcia | 18c44db | 2014-09-02 09:51:20 -0300 | [diff] [blame] | 406 | if (panel_mod->backlight) |
| 407 | put_device(&panel_mod->backlight->dev); |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 408 | return ret; |
| 409 | } |
| 410 | |
| 411 | static int panel_remove(struct platform_device *pdev) |
| 412 | { |
Guido Martínez | 7cdcce9 | 2014-06-17 11:17:10 -0300 | [diff] [blame] | 413 | struct tilcdc_module *mod = dev_get_platdata(&pdev->dev); |
| 414 | struct panel_module *panel_mod = to_panel_module(mod); |
Ezequiel Garcia | 18c44db | 2014-09-02 09:51:20 -0300 | [diff] [blame] | 415 | struct backlight_device *backlight = panel_mod->backlight; |
| 416 | |
| 417 | if (backlight) |
| 418 | put_device(&backlight->dev); |
Guido Martínez | 7cdcce9 | 2014-06-17 11:17:10 -0300 | [diff] [blame] | 419 | |
| 420 | display_timings_release(panel_mod->timings); |
| 421 | |
| 422 | tilcdc_module_cleanup(mod); |
| 423 | kfree(panel_mod->info); |
Guido Martínez | 7cdcce9 | 2014-06-17 11:17:10 -0300 | [diff] [blame] | 424 | |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 425 | return 0; |
| 426 | } |
| 427 | |
| 428 | static struct of_device_id panel_of_match[] = { |
| 429 | { .compatible = "ti,tilcdc,panel", }, |
| 430 | { }, |
| 431 | }; |
Rob Clark | 0d4bbaf | 2012-12-18 17:34:16 -0600 | [diff] [blame] | 432 | |
| 433 | struct platform_driver panel_driver = { |
| 434 | .probe = panel_probe, |
| 435 | .remove = panel_remove, |
| 436 | .driver = { |
| 437 | .owner = THIS_MODULE, |
| 438 | .name = "panel", |
| 439 | .of_match_table = panel_of_match, |
| 440 | }, |
| 441 | }; |
| 442 | |
| 443 | int __init tilcdc_panel_init(void) |
| 444 | { |
| 445 | return platform_driver_register(&panel_driver); |
| 446 | } |
| 447 | |
| 448 | void __exit tilcdc_panel_fini(void) |
| 449 | { |
| 450 | platform_driver_unregister(&panel_driver); |
| 451 | } |