aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/fsl-diu-fb.c
diff options
context:
space:
mode:
authorTimur Tabi <timur@freescale.com>2011-12-08 18:27:31 -0500
committerFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>2011-12-19 15:06:41 -0500
commitb779505282590289546aab9ffead4490fe195d40 (patch)
treed8cf8c21715ddceef957afb8a78cd30f4a772fb6 /drivers/video/fsl-diu-fb.c
parentff8c91072389491375f6d1ea86ce55942c460a04 (diff)
drivers/video: fsl-diu-fb: rename "machine_data" to "data"
"machine_data" is too long and clunky, and the "machine" part doesn't make much sense, anyway. Signed-off-by: Timur Tabi <timur@freescale.com> Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Diffstat (limited to 'drivers/video/fsl-diu-fb.c')
-rw-r--r--drivers/video/fsl-diu-fb.c236
1 files changed, 116 insertions, 120 deletions
diff --git a/drivers/video/fsl-diu-fb.c b/drivers/video/fsl-diu-fb.c
index 4d54188daa24..408272c7fb52 100644
--- a/drivers/video/fsl-diu-fb.c
+++ b/drivers/video/fsl-diu-fb.c
@@ -509,8 +509,8 @@ static void fsl_diu_enable_panel(struct fb_info *info)
509{ 509{
510 struct mfb_info *pmfbi, *cmfbi, *mfbi = info->par; 510 struct mfb_info *pmfbi, *cmfbi, *mfbi = info->par;
511 struct diu_ad *ad = mfbi->ad; 511 struct diu_ad *ad = mfbi->ad;
512 struct fsl_diu_data *machine_data = mfbi->parent; 512 struct fsl_diu_data *data = mfbi->parent;
513 struct diu __iomem *hw = machine_data->diu_reg; 513 struct diu __iomem *hw = data->diu_reg;
514 514
515 switch (mfbi->index) { 515 switch (mfbi->index) {
516 case PLANE0: 516 case PLANE0:
@@ -518,7 +518,7 @@ static void fsl_diu_enable_panel(struct fb_info *info)
518 wr_reg_wa(&hw->desc[0], ad->paddr); 518 wr_reg_wa(&hw->desc[0], ad->paddr);
519 break; 519 break;
520 case PLANE1_AOI0: 520 case PLANE1_AOI0:
521 cmfbi = &machine_data->mfb[2]; 521 cmfbi = &data->mfb[2];
522 if (hw->desc[1] != ad->paddr) { /* AOI0 closed */ 522 if (hw->desc[1] != ad->paddr) { /* AOI0 closed */
523 if (cmfbi->count > 0) /* AOI1 open */ 523 if (cmfbi->count > 0) /* AOI1 open */
524 ad->next_ad = 524 ad->next_ad =
@@ -529,7 +529,7 @@ static void fsl_diu_enable_panel(struct fb_info *info)
529 } 529 }
530 break; 530 break;
531 case PLANE2_AOI0: 531 case PLANE2_AOI0:
532 cmfbi = &machine_data->mfb[4]; 532 cmfbi = &data->mfb[4];
533 if (hw->desc[2] != ad->paddr) { /* AOI0 closed */ 533 if (hw->desc[2] != ad->paddr) { /* AOI0 closed */
534 if (cmfbi->count > 0) /* AOI1 open */ 534 if (cmfbi->count > 0) /* AOI1 open */
535 ad->next_ad = 535 ad->next_ad =
@@ -540,17 +540,17 @@ static void fsl_diu_enable_panel(struct fb_info *info)
540 } 540 }
541 break; 541 break;
542 case PLANE1_AOI1: 542 case PLANE1_AOI1:
543 pmfbi = &machine_data->mfb[1]; 543 pmfbi = &data->mfb[1];
544 ad->next_ad = 0; 544 ad->next_ad = 0;
545 if (hw->desc[1] == machine_data->dummy_ad.paddr) 545 if (hw->desc[1] == data->dummy_ad.paddr)
546 wr_reg_wa(&hw->desc[1], ad->paddr); 546 wr_reg_wa(&hw->desc[1], ad->paddr);
547 else /* AOI0 open */ 547 else /* AOI0 open */
548 pmfbi->ad->next_ad = cpu_to_le32(ad->paddr); 548 pmfbi->ad->next_ad = cpu_to_le32(ad->paddr);
549 break; 549 break;
550 case PLANE2_AOI1: 550 case PLANE2_AOI1:
551 pmfbi = &machine_data->mfb[3]; 551 pmfbi = &data->mfb[3];
552 ad->next_ad = 0; 552 ad->next_ad = 0;
553 if (hw->desc[2] == machine_data->dummy_ad.paddr) 553 if (hw->desc[2] == data->dummy_ad.paddr)
554 wr_reg_wa(&hw->desc[2], ad->paddr); 554 wr_reg_wa(&hw->desc[2], ad->paddr);
555 else /* AOI0 was open */ 555 else /* AOI0 was open */
556 pmfbi->ad->next_ad = cpu_to_le32(ad->paddr); 556 pmfbi->ad->next_ad = cpu_to_le32(ad->paddr);
@@ -562,52 +562,52 @@ static void fsl_diu_disable_panel(struct fb_info *info)
562{ 562{
563 struct mfb_info *pmfbi, *cmfbi, *mfbi = info->par; 563 struct mfb_info *pmfbi, *cmfbi, *mfbi = info->par;
564 struct diu_ad *ad = mfbi->ad; 564 struct diu_ad *ad = mfbi->ad;
565 struct fsl_diu_data *machine_data = mfbi->parent; 565 struct fsl_diu_data *data = mfbi->parent;
566 struct diu __iomem *hw = machine_data->diu_reg; 566 struct diu __iomem *hw = data->diu_reg;
567 567
568 switch (mfbi->index) { 568 switch (mfbi->index) {
569 case PLANE0: 569 case PLANE0:
570 if (hw->desc[0] != machine_data->dummy_ad.paddr) 570 if (hw->desc[0] != data->dummy_ad.paddr)
571 wr_reg_wa(&hw->desc[0], machine_data->dummy_ad.paddr); 571 wr_reg_wa(&hw->desc[0], data->dummy_ad.paddr);
572 break; 572 break;
573 case PLANE1_AOI0: 573 case PLANE1_AOI0:
574 cmfbi = &machine_data->mfb[2]; 574 cmfbi = &data->mfb[2];
575 if (cmfbi->count > 0) /* AOI1 is open */ 575 if (cmfbi->count > 0) /* AOI1 is open */
576 wr_reg_wa(&hw->desc[1], cmfbi->ad->paddr); 576 wr_reg_wa(&hw->desc[1], cmfbi->ad->paddr);
577 /* move AOI1 to the first */ 577 /* move AOI1 to the first */
578 else /* AOI1 was closed */ 578 else /* AOI1 was closed */
579 wr_reg_wa(&hw->desc[1], machine_data->dummy_ad.paddr); 579 wr_reg_wa(&hw->desc[1], data->dummy_ad.paddr);
580 /* close AOI 0 */ 580 /* close AOI 0 */
581 break; 581 break;
582 case PLANE2_AOI0: 582 case PLANE2_AOI0:
583 cmfbi = &machine_data->mfb[4]; 583 cmfbi = &data->mfb[4];
584 if (cmfbi->count > 0) /* AOI1 is open */ 584 if (cmfbi->count > 0) /* AOI1 is open */
585 wr_reg_wa(&hw->desc[2], cmfbi->ad->paddr); 585 wr_reg_wa(&hw->desc[2], cmfbi->ad->paddr);
586 /* move AOI1 to the first */ 586 /* move AOI1 to the first */
587 else /* AOI1 was closed */ 587 else /* AOI1 was closed */
588 wr_reg_wa(&hw->desc[2], machine_data->dummy_ad.paddr); 588 wr_reg_wa(&hw->desc[2], data->dummy_ad.paddr);
589 /* close AOI 0 */ 589 /* close AOI 0 */
590 break; 590 break;
591 case PLANE1_AOI1: 591 case PLANE1_AOI1:
592 pmfbi = &machine_data->mfb[1]; 592 pmfbi = &data->mfb[1];
593 if (hw->desc[1] != ad->paddr) { 593 if (hw->desc[1] != ad->paddr) {
594 /* AOI1 is not the first in the chain */ 594 /* AOI1 is not the first in the chain */
595 if (pmfbi->count > 0) 595 if (pmfbi->count > 0)
596 /* AOI0 is open, must be the first */ 596 /* AOI0 is open, must be the first */
597 pmfbi->ad->next_ad = 0; 597 pmfbi->ad->next_ad = 0;
598 } else /* AOI1 is the first in the chain */ 598 } else /* AOI1 is the first in the chain */
599 wr_reg_wa(&hw->desc[1], machine_data->dummy_ad.paddr); 599 wr_reg_wa(&hw->desc[1], data->dummy_ad.paddr);
600 /* close AOI 1 */ 600 /* close AOI 1 */
601 break; 601 break;
602 case PLANE2_AOI1: 602 case PLANE2_AOI1:
603 pmfbi = &machine_data->mfb[3]; 603 pmfbi = &data->mfb[3];
604 if (hw->desc[2] != ad->paddr) { 604 if (hw->desc[2] != ad->paddr) {
605 /* AOI1 is not the first in the chain */ 605 /* AOI1 is not the first in the chain */
606 if (pmfbi->count > 0) 606 if (pmfbi->count > 0)
607 /* AOI0 is open, must be the first */ 607 /* AOI0 is open, must be the first */
608 pmfbi->ad->next_ad = 0; 608 pmfbi->ad->next_ad = 0;
609 } else /* AOI1 is the first in the chain */ 609 } else /* AOI1 is the first in the chain */
610 wr_reg_wa(&hw->desc[2], machine_data->dummy_ad.paddr); 610 wr_reg_wa(&hw->desc[2], data->dummy_ad.paddr);
611 /* close AOI 1 */ 611 /* close AOI 1 */
612 break; 612 break;
613 } 613 }
@@ -616,24 +616,24 @@ static void fsl_diu_disable_panel(struct fb_info *info)
616static void enable_lcdc(struct fb_info *info) 616static void enable_lcdc(struct fb_info *info)
617{ 617{
618 struct mfb_info *mfbi = info->par; 618 struct mfb_info *mfbi = info->par;
619 struct fsl_diu_data *machine_data = mfbi->parent; 619 struct fsl_diu_data *data = mfbi->parent;
620 struct diu __iomem *hw = machine_data->diu_reg; 620 struct diu __iomem *hw = data->diu_reg;
621 621
622 if (!machine_data->fb_enabled) { 622 if (!data->fb_enabled) {
623 out_be32(&hw->diu_mode, MFB_MODE1); 623 out_be32(&hw->diu_mode, MFB_MODE1);
624 machine_data->fb_enabled++; 624 data->fb_enabled++;
625 } 625 }
626} 626}
627 627
628static void disable_lcdc(struct fb_info *info) 628static void disable_lcdc(struct fb_info *info)
629{ 629{
630 struct mfb_info *mfbi = info->par; 630 struct mfb_info *mfbi = info->par;
631 struct fsl_diu_data *machine_data = mfbi->parent; 631 struct fsl_diu_data *data = mfbi->parent;
632 struct diu __iomem *hw = machine_data->diu_reg; 632 struct diu __iomem *hw = data->diu_reg;
633 633
634 if (machine_data->fb_enabled) { 634 if (data->fb_enabled) {
635 out_be32(&hw->diu_mode, 0); 635 out_be32(&hw->diu_mode, 0);
636 machine_data->fb_enabled = 0; 636 data->fb_enabled = 0;
637 } 637 }
638} 638}
639 639
@@ -641,14 +641,14 @@ static void adjust_aoi_size_position(struct fb_var_screeninfo *var,
641 struct fb_info *info) 641 struct fb_info *info)
642{ 642{
643 struct mfb_info *lower_aoi_mfbi, *upper_aoi_mfbi, *mfbi = info->par; 643 struct mfb_info *lower_aoi_mfbi, *upper_aoi_mfbi, *mfbi = info->par;
644 struct fsl_diu_data *machine_data = mfbi->parent; 644 struct fsl_diu_data *data = mfbi->parent;
645 int available_height, upper_aoi_bottom; 645 int available_height, upper_aoi_bottom;
646 enum mfb_index index = mfbi->index; 646 enum mfb_index index = mfbi->index;
647 int lower_aoi_is_open, upper_aoi_is_open; 647 int lower_aoi_is_open, upper_aoi_is_open;
648 __u32 base_plane_width, base_plane_height, upper_aoi_height; 648 __u32 base_plane_width, base_plane_height, upper_aoi_height;
649 649
650 base_plane_width = machine_data->fsl_diu_info[0].var.xres; 650 base_plane_width = data->fsl_diu_info[0].var.xres;
651 base_plane_height = machine_data->fsl_diu_info[0].var.yres; 651 base_plane_height = data->fsl_diu_info[0].var.yres;
652 652
653 if (mfbi->x_aoi_d < 0) 653 if (mfbi->x_aoi_d < 0)
654 mfbi->x_aoi_d = 0; 654 mfbi->x_aoi_d = 0;
@@ -663,7 +663,7 @@ static void adjust_aoi_size_position(struct fb_var_screeninfo *var,
663 break; 663 break;
664 case PLANE1_AOI0: 664 case PLANE1_AOI0:
665 case PLANE2_AOI0: 665 case PLANE2_AOI0:
666 lower_aoi_mfbi = machine_data->fsl_diu_info[index+1].par; 666 lower_aoi_mfbi = data->fsl_diu_info[index+1].par;
667 lower_aoi_is_open = lower_aoi_mfbi->count > 0 ? 1 : 0; 667 lower_aoi_is_open = lower_aoi_mfbi->count > 0 ? 1 : 0;
668 if (var->xres > base_plane_width) 668 if (var->xres > base_plane_width)
669 var->xres = base_plane_width; 669 var->xres = base_plane_width;
@@ -681,9 +681,8 @@ static void adjust_aoi_size_position(struct fb_var_screeninfo *var,
681 break; 681 break;
682 case PLANE1_AOI1: 682 case PLANE1_AOI1:
683 case PLANE2_AOI1: 683 case PLANE2_AOI1:
684 upper_aoi_mfbi = machine_data->fsl_diu_info[index-1].par; 684 upper_aoi_mfbi = data->fsl_diu_info[index-1].par;
685 upper_aoi_height = 685 upper_aoi_height = data->fsl_diu_info[index-1].var.yres;
686 machine_data->fsl_diu_info[index-1].var.yres;
687 upper_aoi_bottom = upper_aoi_mfbi->y_aoi_d + upper_aoi_height; 686 upper_aoi_bottom = upper_aoi_mfbi->y_aoi_d + upper_aoi_height;
688 upper_aoi_is_open = upper_aoi_mfbi->count > 0 ? 1 : 0; 687 upper_aoi_is_open = upper_aoi_mfbi->count > 0 ? 1 : 0;
689 if (var->xres > base_plane_width) 688 if (var->xres > base_plane_width)
@@ -823,17 +822,17 @@ static void update_lcdc(struct fb_info *info)
823{ 822{
824 struct fb_var_screeninfo *var = &info->var; 823 struct fb_var_screeninfo *var = &info->var;
825 struct mfb_info *mfbi = info->par; 824 struct mfb_info *mfbi = info->par;
826 struct fsl_diu_data *machine_data = mfbi->parent; 825 struct fsl_diu_data *data = mfbi->parent;
827 struct diu __iomem *hw; 826 struct diu __iomem *hw;
828 int i, j; 827 int i, j;
829 u8 *gamma_table_base; 828 u8 *gamma_table_base;
830 829
831 u32 temp; 830 u32 temp;
832 831
833 hw = machine_data->diu_reg; 832 hw = data->diu_reg;
834 833
835 diu_ops.set_monitor_port(machine_data->monitor_port); 834 diu_ops.set_monitor_port(data->monitor_port);
836 gamma_table_base = machine_data->gamma; 835 gamma_table_base = data->gamma;
837 836
838 /* Prep for DIU init - gamma table, cursor table */ 837 /* Prep for DIU init - gamma table, cursor table */
839 838
@@ -841,15 +840,14 @@ static void update_lcdc(struct fb_info *info)
841 for (j = 0; j <= 255; j++) 840 for (j = 0; j <= 255; j++)
842 *gamma_table_base++ = j; 841 *gamma_table_base++ = j;
843 842
844 diu_ops.set_gamma_table(machine_data->monitor_port, 843 diu_ops.set_gamma_table(data->monitor_port, data->gamma);
845 machine_data->gamma);
846 844
847 disable_lcdc(info); 845 disable_lcdc(info);
848 846
849 /* Program DIU registers */ 847 /* Program DIU registers */
850 848
851 out_be32(&hw->gamma, DMA_ADDR(machine_data, gamma)); 849 out_be32(&hw->gamma, DMA_ADDR(data, gamma));
852 out_be32(&hw->cursor, DMA_ADDR(machine_data, cursor)); 850 out_be32(&hw->cursor, DMA_ADDR(data, cursor));
853 851
854 out_be32(&hw->bgnd, 0x007F7F7F); /* BGND */ 852 out_be32(&hw->bgnd, 0x007F7F7F); /* BGND */
855 out_be32(&hw->bgnd_wb, 0); /* BGND_WB */ 853 out_be32(&hw->bgnd_wb, 0); /* BGND_WB */
@@ -940,11 +938,11 @@ static int fsl_diu_set_par(struct fb_info *info)
940 unsigned long len; 938 unsigned long len;
941 struct fb_var_screeninfo *var = &info->var; 939 struct fb_var_screeninfo *var = &info->var;
942 struct mfb_info *mfbi = info->par; 940 struct mfb_info *mfbi = info->par;
943 struct fsl_diu_data *machine_data = mfbi->parent; 941 struct fsl_diu_data *data = mfbi->parent;
944 struct diu_ad *ad = mfbi->ad; 942 struct diu_ad *ad = mfbi->ad;
945 struct diu __iomem *hw; 943 struct diu __iomem *hw;
946 944
947 hw = machine_data->diu_reg; 945 hw = data->diu_reg;
948 946
949 set_fix(info); 947 set_fix(info);
950 mfbi->cursor_reset = 1; 948 mfbi->cursor_reset = 1;
@@ -962,7 +960,7 @@ static int fsl_diu_set_par(struct fb_info *info)
962 } 960 }
963 } 961 }
964 962
965 ad->pix_fmt = diu_ops.get_pixel_format(machine_data->monitor_port, 963 ad->pix_fmt = diu_ops.get_pixel_format(data->monitor_port,
966 var->bits_per_pixel); 964 var->bits_per_pixel);
967 ad->addr = cpu_to_le32(info->fix.smem_start); 965 ad->addr = cpu_to_le32(info->fix.smem_start);
968 ad->src_size_g_alpha = cpu_to_le32((var->yres_virtual << 12) | 966 ad->src_size_g_alpha = cpu_to_le32((var->yres_virtual << 12) |
@@ -1373,16 +1371,16 @@ static irqreturn_t fsl_diu_isr(int irq, void *dev_id)
1373 return IRQ_NONE; 1371 return IRQ_NONE;
1374} 1372}
1375 1373
1376static int request_irq_local(struct fsl_diu_data *machine_data) 1374static int request_irq_local(struct fsl_diu_data *data)
1377{ 1375{
1378 struct diu __iomem *hw = machine_data->diu_reg; 1376 struct diu __iomem *hw = data->diu_reg;
1379 u32 ints; 1377 u32 ints;
1380 int ret; 1378 int ret;
1381 1379
1382 /* Read to clear the status */ 1380 /* Read to clear the status */
1383 in_be32(&hw->int_status); 1381 in_be32(&hw->int_status);
1384 1382
1385 ret = request_irq(machine_data->irq, fsl_diu_isr, 0, "fsl-diu-fb", hw); 1383 ret = request_irq(data->irq, fsl_diu_isr, 0, "fsl-diu-fb", hw);
1386 if (!ret) { 1384 if (!ret) {
1387 ints = INT_PARERR | INT_LS_BF_VS; 1385 ints = INT_PARERR | INT_LS_BF_VS;
1388#if !defined(CONFIG_NOT_COHERENT_CACHE) 1386#if !defined(CONFIG_NOT_COHERENT_CACHE)
@@ -1397,14 +1395,14 @@ static int request_irq_local(struct fsl_diu_data *machine_data)
1397 return ret; 1395 return ret;
1398} 1396}
1399 1397
1400static void free_irq_local(struct fsl_diu_data *machine_data) 1398static void free_irq_local(struct fsl_diu_data *data)
1401{ 1399{
1402 struct diu __iomem *hw = machine_data->diu_reg; 1400 struct diu __iomem *hw = data->diu_reg;
1403 1401
1404 /* Disable all LCDC interrupt */ 1402 /* Disable all LCDC interrupt */
1405 out_be32(&hw->int_mask, 0x1f); 1403 out_be32(&hw->int_mask, 0x1f);
1406 1404
1407 free_irq(machine_data->irq, NULL); 1405 free_irq(data->irq, NULL);
1408} 1406}
1409 1407
1410#ifdef CONFIG_PM 1408#ifdef CONFIG_PM
@@ -1414,20 +1412,20 @@ static void free_irq_local(struct fsl_diu_data *machine_data)
1414 */ 1412 */
1415static int fsl_diu_suspend(struct platform_device *ofdev, pm_message_t state) 1413static int fsl_diu_suspend(struct platform_device *ofdev, pm_message_t state)
1416{ 1414{
1417 struct fsl_diu_data *machine_data; 1415 struct fsl_diu_data *data;
1418 1416
1419 machine_data = dev_get_drvdata(&ofdev->dev); 1417 data = dev_get_drvdata(&ofdev->dev);
1420 disable_lcdc(machine_data->fsl_diu_info[0]); 1418 disable_lcdc(data->fsl_diu_info[0]);
1421 1419
1422 return 0; 1420 return 0;
1423} 1421}
1424 1422
1425static int fsl_diu_resume(struct platform_device *ofdev) 1423static int fsl_diu_resume(struct platform_device *ofdev)
1426{ 1424{
1427 struct fsl_diu_data *machine_data; 1425 struct fsl_diu_data *data;
1428 1426
1429 machine_data = dev_get_drvdata(&ofdev->dev); 1427 data = dev_get_drvdata(&ofdev->dev);
1430 enable_lcdc(machine_data->fsl_diu_info[0]); 1428 enable_lcdc(data->fsl_diu_info[0]);
1431 1429
1432 return 0; 1430 return 0;
1433} 1431}
@@ -1441,20 +1439,20 @@ static ssize_t store_monitor(struct device *device,
1441 struct device_attribute *attr, const char *buf, size_t count) 1439 struct device_attribute *attr, const char *buf, size_t count)
1442{ 1440{
1443 enum fsl_diu_monitor_port old_monitor_port; 1441 enum fsl_diu_monitor_port old_monitor_port;
1444 struct fsl_diu_data *machine_data = 1442 struct fsl_diu_data *data =
1445 container_of(attr, struct fsl_diu_data, dev_attr); 1443 container_of(attr, struct fsl_diu_data, dev_attr);
1446 1444
1447 old_monitor_port = machine_data->monitor_port; 1445 old_monitor_port = data->monitor_port;
1448 machine_data->monitor_port = fsl_diu_name_to_port(buf); 1446 data->monitor_port = fsl_diu_name_to_port(buf);
1449 1447
1450 if (old_monitor_port != machine_data->monitor_port) { 1448 if (old_monitor_port != data->monitor_port) {
1451 /* All AOIs need adjust pixel format 1449 /* All AOIs need adjust pixel format
1452 * fsl_diu_set_par only change the pixsel format here 1450 * fsl_diu_set_par only change the pixsel format here
1453 * unlikely to fail. */ 1451 * unlikely to fail. */
1454 unsigned int i; 1452 unsigned int i;
1455 1453
1456 for (i=0; i < NUM_AOIS; i++) 1454 for (i=0; i < NUM_AOIS; i++)
1457 fsl_diu_set_par(&machine_data->fsl_diu_info[i]); 1455 fsl_diu_set_par(&data->fsl_diu_info[i]);
1458 } 1456 }
1459 return count; 1457 return count;
1460} 1458}
@@ -1462,10 +1460,10 @@ static ssize_t store_monitor(struct device *device,
1462static ssize_t show_monitor(struct device *device, 1460static ssize_t show_monitor(struct device *device,
1463 struct device_attribute *attr, char *buf) 1461 struct device_attribute *attr, char *buf)
1464{ 1462{
1465 struct fsl_diu_data *machine_data = 1463 struct fsl_diu_data *data =
1466 container_of(attr, struct fsl_diu_data, dev_attr); 1464 container_of(attr, struct fsl_diu_data, dev_attr);
1467 1465
1468 switch (machine_data->monitor_port) { 1466 switch (data->monitor_port) {
1469 case FSL_DIU_PORT_DVI: 1467 case FSL_DIU_PORT_DVI:
1470 return sprintf(buf, "DVI\n"); 1468 return sprintf(buf, "DVI\n");
1471 case FSL_DIU_PORT_LVDS: 1469 case FSL_DIU_PORT_LVDS:
@@ -1481,17 +1479,17 @@ static int __devinit fsl_diu_probe(struct platform_device *pdev)
1481{ 1479{
1482 struct device_node *np = pdev->dev.of_node; 1480 struct device_node *np = pdev->dev.of_node;
1483 struct mfb_info *mfbi; 1481 struct mfb_info *mfbi;
1484 struct fsl_diu_data *machine_data; 1482 struct fsl_diu_data *data;
1485 int diu_mode; 1483 int diu_mode;
1486 dma_addr_t dma_addr; /* DMA addr of machine_data struct */ 1484 dma_addr_t dma_addr; /* DMA addr of fsl_diu_data struct */
1487 unsigned int i; 1485 unsigned int i;
1488 int ret; 1486 int ret;
1489 1487
1490 machine_data = dma_alloc_coherent(&pdev->dev, 1488 data = dma_alloc_coherent(&pdev->dev, sizeof(struct fsl_diu_data),
1491 sizeof(struct fsl_diu_data), &dma_addr, GFP_DMA | __GFP_ZERO); 1489 &dma_addr, GFP_DMA | __GFP_ZERO);
1492 if (!machine_data) 1490 if (!data)
1493 return -ENOMEM; 1491 return -ENOMEM;
1494 machine_data->dma_addr = dma_addr; 1492 data->dma_addr = dma_addr;
1495 1493
1496 /* 1494 /*
1497 * dma_alloc_coherent() uses a page allocator, so the address is 1495 * dma_alloc_coherent() uses a page allocator, so the address is
@@ -1500,33 +1498,33 @@ static int __devinit fsl_diu_probe(struct platform_device *pdev)
1500 * need to catch that. It's not worth the effort to handle unaligned 1498 * need to catch that. It's not worth the effort to handle unaligned
1501 * alloctions now because it's highly unlikely to ever be a problem. 1499 * alloctions now because it's highly unlikely to ever be a problem.
1502 */ 1500 */
1503 if ((unsigned long)machine_data & 31) { 1501 if ((unsigned long)data & 31) {
1504 dev_err(&pdev->dev, "misaligned allocation"); 1502 dev_err(&pdev->dev, "misaligned allocation");
1505 ret = -ENOMEM; 1503 ret = -ENOMEM;
1506 goto error; 1504 goto error;
1507 } 1505 }
1508 1506
1509 spin_lock_init(&machine_data->reg_lock); 1507 spin_lock_init(&data->reg_lock);
1510 1508
1511 for (i = 0; i < NUM_AOIS; i++) { 1509 for (i = 0; i < NUM_AOIS; i++) {
1512 struct fb_info *info = &machine_data->fsl_diu_info[i]; 1510 struct fb_info *info = &data->fsl_diu_info[i];
1513 1511
1514 info->device = &pdev->dev; 1512 info->device = &pdev->dev;
1515 info->par = &machine_data->mfb[i]; 1513 info->par = &data->mfb[i];
1516 1514
1517 /* 1515 /*
1518 * We store the physical address of the AD in the reserved 1516 * We store the physical address of the AD in the reserved
1519 * 'paddr' field of the AD itself. 1517 * 'paddr' field of the AD itself.
1520 */ 1518 */
1521 machine_data->ad[i].paddr = DMA_ADDR(machine_data, ad[i]); 1519 data->ad[i].paddr = DMA_ADDR(data, ad[i]);
1522 1520
1523 info->fix.smem_start = 0; 1521 info->fix.smem_start = 0;
1524 1522
1525 /* Initialize the AOI data structure */ 1523 /* Initialize the AOI data structure */
1526 mfbi = info->par; 1524 mfbi = info->par;
1527 memcpy(mfbi, &mfb_template[i], sizeof(struct mfb_info)); 1525 memcpy(mfbi, &mfb_template[i], sizeof(struct mfb_info));
1528 mfbi->parent = machine_data; 1526 mfbi->parent = data;
1529 mfbi->ad = &machine_data->ad[i]; 1527 mfbi->ad = &data->ad[i];
1530 1528
1531 if (mfbi->index == PLANE0) { 1529 if (mfbi->index == PLANE0) {
1532 const u8 *prop; 1530 const u8 *prop;
@@ -1540,104 +1538,102 @@ static int __devinit fsl_diu_probe(struct platform_device *pdev)
1540 } 1538 }
1541 } 1539 }
1542 1540
1543 machine_data->diu_reg = of_iomap(np, 0); 1541 data->diu_reg = of_iomap(np, 0);
1544 if (!machine_data->diu_reg) { 1542 if (!data->diu_reg) {
1545 dev_err(&pdev->dev, "cannot map DIU registers\n"); 1543 dev_err(&pdev->dev, "cannot map DIU registers\n");
1546 ret = -EFAULT; 1544 ret = -EFAULT;
1547 goto error; 1545 goto error;
1548 } 1546 }
1549 1547
1550 diu_mode = in_be32(&machine_data->diu_reg->diu_mode); 1548 diu_mode = in_be32(&data->diu_reg->diu_mode);
1551 if (diu_mode == MFB_MODE0) 1549 if (diu_mode == MFB_MODE0)
1552 out_be32(&machine_data->diu_reg->diu_mode, 0); /* disable DIU */ 1550 out_be32(&data->diu_reg->diu_mode, 0); /* disable DIU */
1553 1551
1554 /* Get the IRQ of the DIU */ 1552 /* Get the IRQ of the DIU */
1555 machine_data->irq = irq_of_parse_and_map(np, 0); 1553 data->irq = irq_of_parse_and_map(np, 0);
1556 1554
1557 if (!machine_data->irq) { 1555 if (!data->irq) {
1558 dev_err(&pdev->dev, "could not get DIU IRQ\n"); 1556 dev_err(&pdev->dev, "could not get DIU IRQ\n");
1559 ret = -EINVAL; 1557 ret = -EINVAL;
1560 goto error; 1558 goto error;
1561 } 1559 }
1562 machine_data->monitor_port = monitor_port; 1560 data->monitor_port = monitor_port;
1563 1561
1564 /* Initialize the dummy Area Descriptor */ 1562 /* Initialize the dummy Area Descriptor */
1565 machine_data->dummy_ad.addr = 1563 data->dummy_ad.addr = cpu_to_le32(DMA_ADDR(data, dummy_aoi));
1566 cpu_to_le32(DMA_ADDR(machine_data, dummy_aoi)); 1564 data->dummy_ad.pix_fmt = 0x88882317;
1567 machine_data->dummy_ad.pix_fmt = 0x88882317; 1565 data->dummy_ad.src_size_g_alpha = cpu_to_le32((4 << 12) | 4);
1568 machine_data->dummy_ad.src_size_g_alpha = cpu_to_le32((4 << 12) | 4); 1566 data->dummy_ad.aoi_size = cpu_to_le32((4 << 16) | 2);
1569 machine_data->dummy_ad.aoi_size = cpu_to_le32((4 << 16) | 2); 1567 data->dummy_ad.offset_xyi = 0;
1570 machine_data->dummy_ad.offset_xyi = 0; 1568 data->dummy_ad.offset_xyd = 0;
1571 machine_data->dummy_ad.offset_xyd = 0; 1569 data->dummy_ad.next_ad = 0;
1572 machine_data->dummy_ad.next_ad = 0; 1570 data->dummy_ad.paddr = DMA_ADDR(data, dummy_ad);
1573 machine_data->dummy_ad.paddr = DMA_ADDR(machine_data, dummy_ad);
1574 1571
1575 /* 1572 /*
1576 * Let DIU display splash screen if it was pre-initialized 1573 * Let DIU display splash screen if it was pre-initialized
1577 * by the bootloader, set dummy area descriptor otherwise. 1574 * by the bootloader, set dummy area descriptor otherwise.
1578 */ 1575 */
1579 if (diu_mode == MFB_MODE0) 1576 if (diu_mode == MFB_MODE0)
1580 out_be32(&machine_data->diu_reg->desc[0], 1577 out_be32(&data->diu_reg->desc[0], data->dummy_ad.paddr);
1581 machine_data->dummy_ad.paddr);
1582 1578
1583 out_be32(&machine_data->diu_reg->desc[1], machine_data->dummy_ad.paddr); 1579 out_be32(&data->diu_reg->desc[1], data->dummy_ad.paddr);
1584 out_be32(&machine_data->diu_reg->desc[2], machine_data->dummy_ad.paddr); 1580 out_be32(&data->diu_reg->desc[2], data->dummy_ad.paddr);
1585 1581
1586 for (i = 0; i < NUM_AOIS; i++) { 1582 for (i = 0; i < NUM_AOIS; i++) {
1587 ret = install_fb(&machine_data->fsl_diu_info[i]); 1583 ret = install_fb(&data->fsl_diu_info[i]);
1588 if (ret) { 1584 if (ret) {
1589 dev_err(&pdev->dev, "could not register fb %d\n", i); 1585 dev_err(&pdev->dev, "could not register fb %d\n", i);
1590 goto error; 1586 goto error;
1591 } 1587 }
1592 } 1588 }
1593 1589
1594 if (request_irq_local(machine_data)) { 1590 if (request_irq_local(data)) {
1595 dev_err(&pdev->dev, "could not claim irq\n"); 1591 dev_err(&pdev->dev, "could not claim irq\n");
1596 goto error; 1592 goto error;
1597 } 1593 }
1598 1594
1599 sysfs_attr_init(&machine_data->dev_attr.attr); 1595 sysfs_attr_init(&data->dev_attr.attr);
1600 machine_data->dev_attr.attr.name = "monitor"; 1596 data->dev_attr.attr.name = "monitor";
1601 machine_data->dev_attr.attr.mode = S_IRUGO|S_IWUSR; 1597 data->dev_attr.attr.mode = S_IRUGO|S_IWUSR;
1602 machine_data->dev_attr.show = show_monitor; 1598 data->dev_attr.show = show_monitor;
1603 machine_data->dev_attr.store = store_monitor; 1599 data->dev_attr.store = store_monitor;
1604 ret = device_create_file(&pdev->dev, &machine_data->dev_attr); 1600 ret = device_create_file(&pdev->dev, &data->dev_attr);
1605 if (ret) { 1601 if (ret) {
1606 dev_err(&pdev->dev, "could not create sysfs file %s\n", 1602 dev_err(&pdev->dev, "could not create sysfs file %s\n",
1607 machine_data->dev_attr.attr.name); 1603 data->dev_attr.attr.name);
1608 } 1604 }
1609 1605
1610 dev_set_drvdata(&pdev->dev, machine_data); 1606 dev_set_drvdata(&pdev->dev, data);
1611 return 0; 1607 return 0;
1612 1608
1613error: 1609error:
1614 for (i = 0; i < NUM_AOIS; i++) 1610 for (i = 0; i < NUM_AOIS; i++)
1615 uninstall_fb(&machine_data->fsl_diu_info[i]); 1611 uninstall_fb(&data->fsl_diu_info[i]);
1616 1612
1617 iounmap(machine_data->diu_reg); 1613 iounmap(data->diu_reg);
1618 1614
1619 dma_free_coherent(&pdev->dev, sizeof(struct fsl_diu_data), 1615 dma_free_coherent(&pdev->dev, sizeof(struct fsl_diu_data), data,
1620 machine_data, machine_data->dma_addr); 1616 data->dma_addr);
1621 1617
1622 return ret; 1618 return ret;
1623} 1619}
1624 1620
1625static int fsl_diu_remove(struct platform_device *pdev) 1621static int fsl_diu_remove(struct platform_device *pdev)
1626{ 1622{
1627 struct fsl_diu_data *machine_data; 1623 struct fsl_diu_data *data;
1628 int i; 1624 int i;
1629 1625
1630 machine_data = dev_get_drvdata(&pdev->dev); 1626 data = dev_get_drvdata(&pdev->dev);
1631 disable_lcdc(&machine_data->fsl_diu_info[0]); 1627 disable_lcdc(&data->fsl_diu_info[0]);
1632 free_irq_local(machine_data); 1628 free_irq_local(data);
1633 1629
1634 for (i = 0; i < NUM_AOIS; i++) 1630 for (i = 0; i < NUM_AOIS; i++)
1635 uninstall_fb(&machine_data->fsl_diu_info[i]); 1631 uninstall_fb(&data->fsl_diu_info[i]);
1636 1632
1637 iounmap(machine_data->diu_reg); 1633 iounmap(data->diu_reg);
1638 1634
1639 dma_free_coherent(&pdev->dev, sizeof(struct fsl_diu_data), 1635 dma_free_coherent(&pdev->dev, sizeof(struct fsl_diu_data), data,
1640 machine_data, machine_data->dma_addr); 1636 data->dma_addr);
1641 1637
1642 return 0; 1638 return 0;
1643} 1639}