diff options
| author | Noralf Trønnes <noralf@tronnes.org> | 2018-01-10 13:59:38 -0500 |
|---|---|---|
| committer | Noralf Trønnes <noralf@tronnes.org> | 2018-01-15 09:16:06 -0500 |
| commit | f730eceb42fa0bf60006d45e93c52207cb8a65be (patch) | |
| tree | 297ff7f949b72ee0d01b7b87034f683326eb012e /drivers/gpu/drm/tinydrm | |
| parent | 070ab1283a57d7bfff5cce9ce58be64b90173a8f (diff) | |
drm/tinydrm/mi0283qt: Let the display pipe handle power
It's better to leave power handling and controller init to the
modesetting machinery using the simple pipe .enable and .disable
callbacks. Remove unused mipi_dbi_pipe_enable().
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: David Lechner <david@lechnology.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180110185940.53841-6-noralf@tronnes.org
Diffstat (limited to 'drivers/gpu/drm/tinydrm')
| -rw-r--r-- | drivers/gpu/drm/tinydrm/mi0283qt.c | 47 | ||||
| -rw-r--r-- | drivers/gpu/drm/tinydrm/mipi-dbi.c | 32 |
2 files changed, 15 insertions, 64 deletions
diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c b/drivers/gpu/drm/tinydrm/mi0283qt.c index 1617405faed4..79cb5af5abac 100644 --- a/drivers/gpu/drm/tinydrm/mi0283qt.c +++ b/drivers/gpu/drm/tinydrm/mi0283qt.c | |||
| @@ -47,8 +47,11 @@ | |||
| 47 | #define ILI9341_MADCTL_MX BIT(6) | 47 | #define ILI9341_MADCTL_MX BIT(6) |
| 48 | #define ILI9341_MADCTL_MY BIT(7) | 48 | #define ILI9341_MADCTL_MY BIT(7) |
| 49 | 49 | ||
| 50 | static int mi0283qt_init(struct mipi_dbi *mipi) | 50 | static void mi0283qt_enable(struct drm_simple_display_pipe *pipe, |
| 51 | struct drm_crtc_state *crtc_state) | ||
| 51 | { | 52 | { |
| 53 | struct tinydrm_device *tdev = pipe_to_tinydrm(pipe); | ||
| 54 | struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev); | ||
| 52 | u8 addr_mode; | 55 | u8 addr_mode; |
| 53 | int ret; | 56 | int ret; |
| 54 | 57 | ||
| @@ -56,9 +59,9 @@ static int mi0283qt_init(struct mipi_dbi *mipi) | |||
| 56 | 59 | ||
| 57 | ret = mipi_dbi_poweron_conditional_reset(mipi); | 60 | ret = mipi_dbi_poweron_conditional_reset(mipi); |
| 58 | if (ret < 0) | 61 | if (ret < 0) |
| 59 | return ret; | 62 | return; |
| 60 | if (ret == 1) | 63 | if (ret == 1) |
| 61 | return 0; | 64 | goto out_enable; |
| 62 | 65 | ||
| 63 | mipi_dbi_command(mipi, MIPI_DCS_SET_DISPLAY_OFF); | 66 | mipi_dbi_command(mipi, MIPI_DCS_SET_DISPLAY_OFF); |
| 64 | 67 | ||
| @@ -121,19 +124,12 @@ static int mi0283qt_init(struct mipi_dbi *mipi) | |||
| 121 | mipi_dbi_command(mipi, MIPI_DCS_SET_DISPLAY_ON); | 124 | mipi_dbi_command(mipi, MIPI_DCS_SET_DISPLAY_ON); |
| 122 | msleep(100); | 125 | msleep(100); |
| 123 | 126 | ||
| 124 | return 0; | 127 | out_enable: |
| 125 | } | 128 | mipi_dbi_enable_flush(mipi); |
| 126 | |||
| 127 | static void mi0283qt_fini(void *data) | ||
| 128 | { | ||
| 129 | struct mipi_dbi *mipi = data; | ||
| 130 | |||
| 131 | DRM_DEBUG_KMS("\n"); | ||
| 132 | regulator_disable(mipi->regulator); | ||
| 133 | } | 129 | } |
| 134 | 130 | ||
| 135 | static const struct drm_simple_display_pipe_funcs mi0283qt_pipe_funcs = { | 131 | static const struct drm_simple_display_pipe_funcs mi0283qt_pipe_funcs = { |
| 136 | .enable = mipi_dbi_pipe_enable, | 132 | .enable = mi0283qt_enable, |
| 137 | .disable = mipi_dbi_pipe_disable, | 133 | .disable = mipi_dbi_pipe_disable, |
| 138 | .update = tinydrm_display_pipe_update, | 134 | .update = tinydrm_display_pipe_update, |
| 139 | .prepare_fb = tinydrm_display_pipe_prepare_fb, | 135 | .prepare_fb = tinydrm_display_pipe_prepare_fb, |
| @@ -214,17 +210,6 @@ static int mi0283qt_probe(struct spi_device *spi) | |||
| 214 | if (ret) | 210 | if (ret) |
| 215 | return ret; | 211 | return ret; |
| 216 | 212 | ||
| 217 | ret = mi0283qt_init(mipi); | ||
| 218 | if (ret) | ||
| 219 | return ret; | ||
| 220 | |||
| 221 | /* use devres to fini after drm unregister (drv->remove is before) */ | ||
| 222 | ret = devm_add_action(dev, mi0283qt_fini, mipi); | ||
| 223 | if (ret) { | ||
| 224 | mi0283qt_fini(mipi); | ||
| 225 | return ret; | ||
| 226 | } | ||
| 227 | |||
| 228 | spi_set_drvdata(spi, mipi); | 213 | spi_set_drvdata(spi, mipi); |
| 229 | 214 | ||
| 230 | return devm_tinydrm_register(&mipi->tinydrm); | 215 | return devm_tinydrm_register(&mipi->tinydrm); |
| @@ -240,25 +225,13 @@ static void mi0283qt_shutdown(struct spi_device *spi) | |||
| 240 | static int __maybe_unused mi0283qt_pm_suspend(struct device *dev) | 225 | static int __maybe_unused mi0283qt_pm_suspend(struct device *dev) |
| 241 | { | 226 | { |
| 242 | struct mipi_dbi *mipi = dev_get_drvdata(dev); | 227 | struct mipi_dbi *mipi = dev_get_drvdata(dev); |
| 243 | int ret; | ||
| 244 | |||
| 245 | ret = drm_mode_config_helper_suspend(mipi->tinydrm.drm); | ||
| 246 | if (ret) | ||
| 247 | return ret; | ||
| 248 | |||
| 249 | mi0283qt_fini(mipi); | ||
| 250 | 228 | ||
| 251 | return 0; | 229 | return drm_mode_config_helper_suspend(mipi->tinydrm.drm); |
| 252 | } | 230 | } |
| 253 | 231 | ||
| 254 | static int __maybe_unused mi0283qt_pm_resume(struct device *dev) | 232 | static int __maybe_unused mi0283qt_pm_resume(struct device *dev) |
| 255 | { | 233 | { |
| 256 | struct mipi_dbi *mipi = dev_get_drvdata(dev); | 234 | struct mipi_dbi *mipi = dev_get_drvdata(dev); |
| 257 | int ret; | ||
| 258 | |||
| 259 | ret = mi0283qt_init(mipi); | ||
| 260 | if (ret) | ||
| 261 | return ret; | ||
| 262 | 235 | ||
| 263 | drm_mode_config_helper_resume(mipi->tinydrm.drm); | 236 | drm_mode_config_helper_resume(mipi->tinydrm.drm); |
| 264 | 237 | ||
diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c b/drivers/gpu/drm/tinydrm/mipi-dbi.c index 3e879d605ed3..6798b4837441 100644 --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c | |||
| @@ -290,31 +290,6 @@ void mipi_dbi_enable_flush(struct mipi_dbi *mipi) | |||
| 290 | } | 290 | } |
| 291 | EXPORT_SYMBOL(mipi_dbi_enable_flush); | 291 | EXPORT_SYMBOL(mipi_dbi_enable_flush); |
| 292 | 292 | ||
| 293 | /** | ||
| 294 | * mipi_dbi_pipe_enable - MIPI DBI pipe enable helper | ||
| 295 | * @pipe: Display pipe | ||
| 296 | * @crtc_state: CRTC state | ||
| 297 | * | ||
| 298 | * This function enables backlight. Drivers can use this as their | ||
| 299 | * &drm_simple_display_pipe_funcs->enable callback. | ||
| 300 | */ | ||
| 301 | void mipi_dbi_pipe_enable(struct drm_simple_display_pipe *pipe, | ||
| 302 | struct drm_crtc_state *crtc_state) | ||
| 303 | { | ||
| 304 | struct tinydrm_device *tdev = pipe_to_tinydrm(pipe); | ||
| 305 | struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev); | ||
| 306 | struct drm_framebuffer *fb = pipe->plane.fb; | ||
| 307 | |||
| 308 | DRM_DEBUG_KMS("\n"); | ||
| 309 | |||
| 310 | mipi->enabled = true; | ||
| 311 | if (fb) | ||
| 312 | fb->funcs->dirty(fb, NULL, 0, 0, NULL, 0); | ||
| 313 | |||
| 314 | tinydrm_enable_backlight(mipi->backlight); | ||
| 315 | } | ||
| 316 | EXPORT_SYMBOL(mipi_dbi_pipe_enable); | ||
| 317 | |||
| 318 | static void mipi_dbi_blank(struct mipi_dbi *mipi) | 293 | static void mipi_dbi_blank(struct mipi_dbi *mipi) |
| 319 | { | 294 | { |
| 320 | struct drm_device *drm = mipi->tinydrm.drm; | 295 | struct drm_device *drm = mipi->tinydrm.drm; |
| @@ -336,8 +311,8 @@ static void mipi_dbi_blank(struct mipi_dbi *mipi) | |||
| 336 | * mipi_dbi_pipe_disable - MIPI DBI pipe disable helper | 311 | * mipi_dbi_pipe_disable - MIPI DBI pipe disable helper |
| 337 | * @pipe: Display pipe | 312 | * @pipe: Display pipe |
| 338 | * | 313 | * |
| 339 | * This function disables backlight if present or if not the | 314 | * This function disables backlight if present, if not the display memory is |
| 340 | * display memory is blanked. Drivers can use this as their | 315 | * blanked. The regulator is disabled if in use. Drivers can use this as their |
| 341 | * &drm_simple_display_pipe_funcs->disable callback. | 316 | * &drm_simple_display_pipe_funcs->disable callback. |
| 342 | */ | 317 | */ |
| 343 | void mipi_dbi_pipe_disable(struct drm_simple_display_pipe *pipe) | 318 | void mipi_dbi_pipe_disable(struct drm_simple_display_pipe *pipe) |
| @@ -353,6 +328,9 @@ void mipi_dbi_pipe_disable(struct drm_simple_display_pipe *pipe) | |||
| 353 | tinydrm_disable_backlight(mipi->backlight); | 328 | tinydrm_disable_backlight(mipi->backlight); |
| 354 | else | 329 | else |
| 355 | mipi_dbi_blank(mipi); | 330 | mipi_dbi_blank(mipi); |
| 331 | |||
| 332 | if (mipi->regulator) | ||
| 333 | regulator_disable(mipi->regulator); | ||
| 356 | } | 334 | } |
| 357 | EXPORT_SYMBOL(mipi_dbi_pipe_disable); | 335 | EXPORT_SYMBOL(mipi_dbi_pipe_disable); |
| 358 | 336 | ||
