diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2011-09-11 12:27:50 -0400 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2012-03-12 17:40:45 -0400 |
commit | 732bbcc46c31dea5bb6dd27de331d8767e9e8530 (patch) | |
tree | 7ff04a0155925ade0331b0a4136bb5f5e32c5017 /drivers/video/sh_mipi_dsi.c | |
parent | 8511ea4ad39e351767167280b0b0ac716a8f2986 (diff) |
fbdev: sh_mipi_dsi: Implement sh_mobile_lcdc_entity interface
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'drivers/video/sh_mipi_dsi.c')
-rw-r--r-- | drivers/video/sh_mipi_dsi.c | 66 |
1 files changed, 51 insertions, 15 deletions
diff --git a/drivers/video/sh_mipi_dsi.c b/drivers/video/sh_mipi_dsi.c index 05151b82f40f..58744fee230e 100644 --- a/drivers/video/sh_mipi_dsi.c +++ b/drivers/video/sh_mipi_dsi.c | |||
@@ -24,6 +24,8 @@ | |||
24 | #include <video/sh_mipi_dsi.h> | 24 | #include <video/sh_mipi_dsi.h> |
25 | #include <video/sh_mobile_lcdc.h> | 25 | #include <video/sh_mobile_lcdc.h> |
26 | 26 | ||
27 | #include "sh_mobile_lcdcfb.h" | ||
28 | |||
27 | #define SYSCTRL 0x0000 | 29 | #define SYSCTRL 0x0000 |
28 | #define SYSCONF 0x0004 | 30 | #define SYSCONF 0x0004 |
29 | #define TIMSET 0x0008 | 31 | #define TIMSET 0x0008 |
@@ -50,6 +52,8 @@ | |||
50 | #define MAX_SH_MIPI_DSI 2 | 52 | #define MAX_SH_MIPI_DSI 2 |
51 | 53 | ||
52 | struct sh_mipi { | 54 | struct sh_mipi { |
55 | struct sh_mobile_lcdc_entity entity; | ||
56 | |||
53 | void __iomem *base; | 57 | void __iomem *base; |
54 | void __iomem *linkbase; | 58 | void __iomem *linkbase; |
55 | struct clk *dsit_clk; | 59 | struct clk *dsit_clk; |
@@ -60,6 +64,8 @@ struct sh_mipi { | |||
60 | void (*next_display_off)(void *board_data); | 64 | void (*next_display_off)(void *board_data); |
61 | }; | 65 | }; |
62 | 66 | ||
67 | #define to_sh_mipi(e) container_of(e, struct sh_mipi, entity) | ||
68 | |||
63 | static struct sh_mipi *mipi_dsi[MAX_SH_MIPI_DSI]; | 69 | static struct sh_mipi *mipi_dsi[MAX_SH_MIPI_DSI]; |
64 | 70 | ||
65 | /* Protect the above array */ | 71 | /* Protect the above array */ |
@@ -120,7 +126,7 @@ static void sh_mipi_dsi_enable(struct sh_mipi *mipi, bool enable) | |||
120 | 126 | ||
121 | static void sh_mipi_shutdown(struct platform_device *pdev) | 127 | static void sh_mipi_shutdown(struct platform_device *pdev) |
122 | { | 128 | { |
123 | struct sh_mipi *mipi = platform_get_drvdata(pdev); | 129 | struct sh_mipi *mipi = to_sh_mipi(platform_get_drvdata(pdev)); |
124 | 130 | ||
125 | sh_mipi_dsi_enable(mipi, false); | 131 | sh_mipi_dsi_enable(mipi, false); |
126 | } | 132 | } |
@@ -392,9 +398,10 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi, | |||
392 | return 0; | 398 | return 0; |
393 | } | 399 | } |
394 | 400 | ||
395 | static void mipi_display_on(void *arg, struct fb_info *info) | 401 | static int __mipi_display_on(struct sh_mobile_lcdc_entity *entity, |
402 | struct fb_info *info) | ||
396 | { | 403 | { |
397 | struct sh_mipi *mipi = arg; | 404 | struct sh_mipi *mipi = to_sh_mipi(entity); |
398 | struct sh_mipi_dsi_info *pdata = mipi->pdev->dev.platform_data; | 405 | struct sh_mipi_dsi_info *pdata = mipi->pdev->dev.platform_data; |
399 | int ret; | 406 | int ret; |
400 | 407 | ||
@@ -410,24 +417,34 @@ static void mipi_display_on(void *arg, struct fb_info *info) | |||
410 | 417 | ||
411 | sh_mipi_dsi_enable(mipi, true); | 418 | sh_mipi_dsi_enable(mipi, true); |
412 | 419 | ||
413 | if (mipi->next_display_on) | 420 | return 0; |
414 | mipi->next_display_on(mipi->next_board_data, info); | ||
415 | |||
416 | return; | ||
417 | 421 | ||
418 | mipi_display_on_fail1: | 422 | mipi_display_on_fail1: |
419 | pm_runtime_put_sync(&mipi->pdev->dev); | 423 | pm_runtime_put_sync(&mipi->pdev->dev); |
420 | mipi_display_on_fail2: | 424 | mipi_display_on_fail2: |
421 | pdata->set_dot_clock(mipi->pdev, mipi->base, 0); | 425 | pdata->set_dot_clock(mipi->pdev, mipi->base, 0); |
426 | |||
427 | return ret; | ||
422 | } | 428 | } |
423 | 429 | ||
424 | static void mipi_display_off(void *arg) | 430 | static void mipi_display_on(void *arg, struct fb_info *info) |
425 | { | 431 | { |
426 | struct sh_mipi *mipi = arg; | 432 | struct sh_mobile_lcdc_entity *entity = arg; |
427 | struct sh_mipi_dsi_info *pdata = mipi->pdev->dev.platform_data; | 433 | struct sh_mipi *mipi = to_sh_mipi(entity); |
434 | int ret; | ||
428 | 435 | ||
429 | if (mipi->next_display_off) | 436 | ret = __mipi_display_on(entity, info); |
430 | mipi->next_display_off(mipi->next_board_data); | 437 | if (ret < 0) |
438 | return; | ||
439 | |||
440 | if (mipi->next_display_on) | ||
441 | mipi->next_display_on(mipi->next_board_data, info); | ||
442 | } | ||
443 | |||
444 | static void __mipi_display_off(struct sh_mobile_lcdc_entity *entity) | ||
445 | { | ||
446 | struct sh_mipi *mipi = to_sh_mipi(entity); | ||
447 | struct sh_mipi_dsi_info *pdata = mipi->pdev->dev.platform_data; | ||
431 | 448 | ||
432 | sh_mipi_dsi_enable(mipi, false); | 449 | sh_mipi_dsi_enable(mipi, false); |
433 | 450 | ||
@@ -436,6 +453,22 @@ static void mipi_display_off(void *arg) | |||
436 | pm_runtime_put_sync(&mipi->pdev->dev); | 453 | pm_runtime_put_sync(&mipi->pdev->dev); |
437 | } | 454 | } |
438 | 455 | ||
456 | static void mipi_display_off(void *arg) | ||
457 | { | ||
458 | struct sh_mobile_lcdc_entity *entity = arg; | ||
459 | struct sh_mipi *mipi = to_sh_mipi(entity); | ||
460 | |||
461 | if (mipi->next_display_off) | ||
462 | mipi->next_display_off(mipi->next_board_data); | ||
463 | |||
464 | __mipi_display_off(entity); | ||
465 | } | ||
466 | |||
467 | static const struct sh_mobile_lcdc_entity_ops mipi_ops = { | ||
468 | .display_on = __mipi_display_on, | ||
469 | .display_off = __mipi_display_off, | ||
470 | }; | ||
471 | |||
439 | static int __init sh_mipi_probe(struct platform_device *pdev) | 472 | static int __init sh_mipi_probe(struct platform_device *pdev) |
440 | { | 473 | { |
441 | struct sh_mipi *mipi; | 474 | struct sh_mipi *mipi; |
@@ -467,6 +500,9 @@ static int __init sh_mipi_probe(struct platform_device *pdev) | |||
467 | goto ealloc; | 500 | goto ealloc; |
468 | } | 501 | } |
469 | 502 | ||
503 | mipi->entity.owner = THIS_MODULE; | ||
504 | mipi->entity.ops = &mipi_ops; | ||
505 | |||
470 | if (!request_mem_region(res->start, resource_size(res), pdev->name)) { | 506 | if (!request_mem_region(res->start, resource_size(res), pdev->name)) { |
471 | dev_err(&pdev->dev, "MIPI register region already claimed\n"); | 507 | dev_err(&pdev->dev, "MIPI register region already claimed\n"); |
472 | ret = -EBUSY; | 508 | ret = -EBUSY; |
@@ -521,7 +557,7 @@ static int __init sh_mipi_probe(struct platform_device *pdev) | |||
521 | pm_runtime_resume(&pdev->dev); | 557 | pm_runtime_resume(&pdev->dev); |
522 | 558 | ||
523 | mutex_unlock(&array_lock); | 559 | mutex_unlock(&array_lock); |
524 | platform_set_drvdata(pdev, mipi); | 560 | platform_set_drvdata(pdev, &mipi->entity); |
525 | 561 | ||
526 | /* Save original LCDC callbacks */ | 562 | /* Save original LCDC callbacks */ |
527 | mipi->next_board_data = pdata->lcd_chan->board_cfg.board_data; | 563 | mipi->next_board_data = pdata->lcd_chan->board_cfg.board_data; |
@@ -529,7 +565,7 @@ static int __init sh_mipi_probe(struct platform_device *pdev) | |||
529 | mipi->next_display_off = pdata->lcd_chan->board_cfg.display_off; | 565 | mipi->next_display_off = pdata->lcd_chan->board_cfg.display_off; |
530 | 566 | ||
531 | /* Set up LCDC callbacks */ | 567 | /* Set up LCDC callbacks */ |
532 | pdata->lcd_chan->board_cfg.board_data = mipi; | 568 | pdata->lcd_chan->board_cfg.board_data = &mipi->entity; |
533 | pdata->lcd_chan->board_cfg.display_on = mipi_display_on; | 569 | pdata->lcd_chan->board_cfg.display_on = mipi_display_on; |
534 | pdata->lcd_chan->board_cfg.display_off = mipi_display_off; | 570 | pdata->lcd_chan->board_cfg.display_off = mipi_display_off; |
535 | pdata->lcd_chan->board_cfg.owner = THIS_MODULE; | 571 | pdata->lcd_chan->board_cfg.owner = THIS_MODULE; |
@@ -561,7 +597,7 @@ static int __exit sh_mipi_remove(struct platform_device *pdev) | |||
561 | struct sh_mipi_dsi_info *pdata = pdev->dev.platform_data; | 597 | struct sh_mipi_dsi_info *pdata = pdev->dev.platform_data; |
562 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 598 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
563 | struct resource *res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 599 | struct resource *res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
564 | struct sh_mipi *mipi = platform_get_drvdata(pdev); | 600 | struct sh_mipi *mipi = to_sh_mipi(platform_get_drvdata(pdev)); |
565 | int i, ret; | 601 | int i, ret; |
566 | 602 | ||
567 | mutex_lock(&array_lock); | 603 | mutex_lock(&array_lock); |