diff options
author | Timur Tabi <timur@freescale.com> | 2011-10-04 20:36:51 -0400 |
---|---|---|
committer | Florian Tobias Schandinat <FlorianSchandinat@gmx.de> | 2011-10-04 21:10:12 -0400 |
commit | 3c755b7c09a5f83a96c26a2a784212791cc02bdc (patch) | |
tree | d6d9ad7adb0fe635f7e7e1c1f5b7ac787f0a9482 /drivers/video/fsl-diu-fb.c | |
parent | c4e5a0232763db22d6c60c391ed5816b2b2ac063 (diff) |
drivers/video: fsl-diu-fb: merge diu_hw into fsl_diu_data
The diu_hw structure contains two fields used to access the DIU registers,
but the only instance of this structure is a global variable, 'dr'.
Eliminate 'dr' by merging its fields into the fsl_diu_data structure,
which is instantiated on the heap for each DIU controller found.
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.c | 69 |
1 files changed, 31 insertions, 38 deletions
diff --git a/drivers/video/fsl-diu-fb.c b/drivers/video/fsl-diu-fb.c index 6539e70cb59a..f9a95ab28883 100644 --- a/drivers/video/fsl-diu-fb.c +++ b/drivers/video/fsl-diu-fb.c | |||
@@ -49,11 +49,6 @@ | |||
49 | #define INT_PARERR 0x08 /* Display parameters error interrupt */ | 49 | #define INT_PARERR 0x08 /* Display parameters error interrupt */ |
50 | #define INT_LS_BF_VS 0x10 /* Lines before vsync. interrupt */ | 50 | #define INT_LS_BF_VS 0x10 /* Lines before vsync. interrupt */ |
51 | 51 | ||
52 | struct diu_hw { | ||
53 | struct diu __iomem *diu_reg; | ||
54 | spinlock_t reg_lock; | ||
55 | }; | ||
56 | |||
57 | struct diu_addr { | 52 | struct diu_addr { |
58 | void *vaddr; /* Virtual address */ | 53 | void *vaddr; /* Virtual address */ |
59 | dma_addr_t paddr; /* Physical address */ | 54 | dma_addr_t paddr; /* Physical address */ |
@@ -351,6 +346,8 @@ struct fsl_diu_data { | |||
351 | unsigned int irq; | 346 | unsigned int irq; |
352 | int fb_enabled; | 347 | int fb_enabled; |
353 | enum fsl_diu_monitor_port monitor_port; | 348 | enum fsl_diu_monitor_port monitor_port; |
349 | struct diu __iomem *diu_reg; | ||
350 | spinlock_t reg_lock; | ||
354 | }; | 351 | }; |
355 | 352 | ||
356 | enum mfb_index { | 353 | enum mfb_index { |
@@ -424,10 +421,6 @@ static struct mfb_info mfb_template[] = { | |||
424 | }, | 421 | }, |
425 | }; | 422 | }; |
426 | 423 | ||
427 | static struct diu_hw dr = { | ||
428 | .reg_lock = __SPIN_LOCK_UNLOCKED(diu_hw.reg_lock), | ||
429 | }; | ||
430 | |||
431 | static struct diu_pool pool; | 424 | static struct diu_pool pool; |
432 | 425 | ||
433 | /** | 426 | /** |
@@ -506,9 +499,9 @@ void wr_reg_wa(u32 *reg, u32 val) | |||
506 | static void fsl_diu_enable_panel(struct fb_info *info) | 499 | static void fsl_diu_enable_panel(struct fb_info *info) |
507 | { | 500 | { |
508 | struct mfb_info *pmfbi, *cmfbi, *mfbi = info->par; | 501 | struct mfb_info *pmfbi, *cmfbi, *mfbi = info->par; |
509 | struct diu *hw = dr.diu_reg; | ||
510 | struct diu_ad *ad = mfbi->ad; | 502 | struct diu_ad *ad = mfbi->ad; |
511 | struct fsl_diu_data *machine_data = mfbi->parent; | 503 | struct fsl_diu_data *machine_data = mfbi->parent; |
504 | struct diu __iomem *hw = machine_data->diu_reg; | ||
512 | 505 | ||
513 | switch (mfbi->index) { | 506 | switch (mfbi->index) { |
514 | case PLANE0: | 507 | case PLANE0: |
@@ -559,9 +552,9 @@ static void fsl_diu_enable_panel(struct fb_info *info) | |||
559 | static void fsl_diu_disable_panel(struct fb_info *info) | 552 | static void fsl_diu_disable_panel(struct fb_info *info) |
560 | { | 553 | { |
561 | struct mfb_info *pmfbi, *cmfbi, *mfbi = info->par; | 554 | struct mfb_info *pmfbi, *cmfbi, *mfbi = info->par; |
562 | struct diu *hw = dr.diu_reg; | ||
563 | struct diu_ad *ad = mfbi->ad; | 555 | struct diu_ad *ad = mfbi->ad; |
564 | struct fsl_diu_data *machine_data = mfbi->parent; | 556 | struct fsl_diu_data *machine_data = mfbi->parent; |
557 | struct diu __iomem *hw = machine_data->diu_reg; | ||
565 | 558 | ||
566 | switch (mfbi->index) { | 559 | switch (mfbi->index) { |
567 | case PLANE0: | 560 | case PLANE0: |
@@ -613,9 +606,9 @@ static void fsl_diu_disable_panel(struct fb_info *info) | |||
613 | 606 | ||
614 | static void enable_lcdc(struct fb_info *info) | 607 | static void enable_lcdc(struct fb_info *info) |
615 | { | 608 | { |
616 | struct diu *hw = dr.diu_reg; | ||
617 | struct mfb_info *mfbi = info->par; | 609 | struct mfb_info *mfbi = info->par; |
618 | struct fsl_diu_data *machine_data = mfbi->parent; | 610 | struct fsl_diu_data *machine_data = mfbi->parent; |
611 | struct diu __iomem *hw = machine_data->diu_reg; | ||
619 | 612 | ||
620 | if (!machine_data->fb_enabled) { | 613 | if (!machine_data->fb_enabled) { |
621 | out_be32(&hw->diu_mode, MFB_MODE1); | 614 | out_be32(&hw->diu_mode, MFB_MODE1); |
@@ -625,9 +618,9 @@ static void enable_lcdc(struct fb_info *info) | |||
625 | 618 | ||
626 | static void disable_lcdc(struct fb_info *info) | 619 | static void disable_lcdc(struct fb_info *info) |
627 | { | 620 | { |
628 | struct diu *hw = dr.diu_reg; | ||
629 | struct mfb_info *mfbi = info->par; | 621 | struct mfb_info *mfbi = info->par; |
630 | struct fsl_diu_data *machine_data = mfbi->parent; | 622 | struct fsl_diu_data *machine_data = mfbi->parent; |
623 | struct diu __iomem *hw = machine_data->diu_reg; | ||
631 | 624 | ||
632 | if (machine_data->fb_enabled) { | 625 | if (machine_data->fb_enabled) { |
633 | out_be32(&hw->diu_mode, 0); | 626 | out_be32(&hw->diu_mode, 0); |
@@ -822,13 +815,13 @@ static void update_lcdc(struct fb_info *info) | |||
822 | struct fb_var_screeninfo *var = &info->var; | 815 | struct fb_var_screeninfo *var = &info->var; |
823 | struct mfb_info *mfbi = info->par; | 816 | struct mfb_info *mfbi = info->par; |
824 | struct fsl_diu_data *machine_data = mfbi->parent; | 817 | struct fsl_diu_data *machine_data = mfbi->parent; |
825 | struct diu *hw; | 818 | struct diu __iomem *hw; |
826 | int i, j; | 819 | int i, j; |
827 | char __iomem *cursor_base, *gamma_table_base; | 820 | char __iomem *cursor_base, *gamma_table_base; |
828 | 821 | ||
829 | u32 temp; | 822 | u32 temp; |
830 | 823 | ||
831 | hw = dr.diu_reg; | 824 | hw = machine_data->diu_reg; |
832 | 825 | ||
833 | diu_ops.set_monitor_port(machine_data->monitor_port); | 826 | diu_ops.set_monitor_port(machine_data->monitor_port); |
834 | gamma_table_base = pool.gamma.vaddr; | 827 | gamma_table_base = pool.gamma.vaddr; |
@@ -939,9 +932,9 @@ static int fsl_diu_set_par(struct fb_info *info) | |||
939 | struct mfb_info *mfbi = info->par; | 932 | struct mfb_info *mfbi = info->par; |
940 | struct fsl_diu_data *machine_data = mfbi->parent; | 933 | struct fsl_diu_data *machine_data = mfbi->parent; |
941 | struct diu_ad *ad = mfbi->ad; | 934 | struct diu_ad *ad = mfbi->ad; |
942 | struct diu *hw; | 935 | struct diu __iomem *hw; |
943 | 936 | ||
944 | hw = dr.diu_reg; | 937 | hw = machine_data->diu_reg; |
945 | 938 | ||
946 | set_fix(info); | 939 | set_fix(info); |
947 | mfbi->cursor_reset = 1; | 940 | mfbi->cursor_reset = 1; |
@@ -1344,7 +1337,7 @@ static void uninstall_fb(struct fb_info *info) | |||
1344 | 1337 | ||
1345 | static irqreturn_t fsl_diu_isr(int irq, void *dev_id) | 1338 | static irqreturn_t fsl_diu_isr(int irq, void *dev_id) |
1346 | { | 1339 | { |
1347 | struct diu *hw = dr.diu_reg; | 1340 | struct diu __iomem *hw = dev_id; |
1348 | unsigned int status = in_be32(&hw->int_status); | 1341 | unsigned int status = in_be32(&hw->int_status); |
1349 | 1342 | ||
1350 | if (status) { | 1343 | if (status) { |
@@ -1370,18 +1363,16 @@ static irqreturn_t fsl_diu_isr(int irq, void *dev_id) | |||
1370 | return IRQ_NONE; | 1363 | return IRQ_NONE; |
1371 | } | 1364 | } |
1372 | 1365 | ||
1373 | static int request_irq_local(int irq) | 1366 | static int request_irq_local(struct fsl_diu_data *machine_data) |
1374 | { | 1367 | { |
1368 | struct diu __iomem *hw = machine_data->diu_reg; | ||
1375 | u32 ints; | 1369 | u32 ints; |
1376 | struct diu *hw; | ||
1377 | int ret; | 1370 | int ret; |
1378 | 1371 | ||
1379 | hw = dr.diu_reg; | ||
1380 | |||
1381 | /* Read to clear the status */ | 1372 | /* Read to clear the status */ |
1382 | in_be32(&hw->int_status); | 1373 | in_be32(&hw->int_status); |
1383 | 1374 | ||
1384 | ret = request_irq(irq, fsl_diu_isr, 0, "fsl-diu-fb", NULL); | 1375 | ret = request_irq(machine_data->irq, fsl_diu_isr, 0, "fsl-diu-fb", hw); |
1385 | if (!ret) { | 1376 | if (!ret) { |
1386 | ints = INT_PARERR | INT_LS_BF_VS; | 1377 | ints = INT_PARERR | INT_LS_BF_VS; |
1387 | #if !defined(CONFIG_NOT_COHERENT_CACHE) | 1378 | #if !defined(CONFIG_NOT_COHERENT_CACHE) |
@@ -1396,14 +1387,14 @@ static int request_irq_local(int irq) | |||
1396 | return ret; | 1387 | return ret; |
1397 | } | 1388 | } |
1398 | 1389 | ||
1399 | static void free_irq_local(int irq) | 1390 | static void free_irq_local(struct fsl_diu_data *machine_data) |
1400 | { | 1391 | { |
1401 | struct diu *hw = dr.diu_reg; | 1392 | struct diu __iomem *hw = machine_data->diu_reg; |
1402 | 1393 | ||
1403 | /* Disable all LCDC interrupt */ | 1394 | /* Disable all LCDC interrupt */ |
1404 | out_be32(&hw->int_mask, 0x1f); | 1395 | out_be32(&hw->int_mask, 0x1f); |
1405 | 1396 | ||
1406 | free_irq(irq, NULL); | 1397 | free_irq(machine_data->irq, NULL); |
1407 | } | 1398 | } |
1408 | 1399 | ||
1409 | #ifdef CONFIG_PM | 1400 | #ifdef CONFIG_PM |
@@ -1521,6 +1512,8 @@ static int __devinit fsl_diu_probe(struct platform_device *pdev) | |||
1521 | if (!machine_data) | 1512 | if (!machine_data) |
1522 | return -ENOMEM; | 1513 | return -ENOMEM; |
1523 | 1514 | ||
1515 | spin_lock_init(&machine_data->reg_lock); | ||
1516 | |||
1524 | for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++) { | 1517 | for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++) { |
1525 | machine_data->fsl_diu_info[i] = | 1518 | machine_data->fsl_diu_info[i] = |
1526 | framebuffer_alloc(sizeof(struct mfb_info), &pdev->dev); | 1519 | framebuffer_alloc(sizeof(struct mfb_info), &pdev->dev); |
@@ -1545,16 +1538,16 @@ static int __devinit fsl_diu_probe(struct platform_device *pdev) | |||
1545 | } | 1538 | } |
1546 | } | 1539 | } |
1547 | 1540 | ||
1548 | dr.diu_reg = of_iomap(np, 0); | 1541 | machine_data->diu_reg = of_iomap(np, 0); |
1549 | if (!dr.diu_reg) { | 1542 | if (!machine_data->diu_reg) { |
1550 | dev_err(&pdev->dev, "cannot map DIU registers\n"); | 1543 | dev_err(&pdev->dev, "cannot map DIU registers\n"); |
1551 | ret = -EFAULT; | 1544 | ret = -EFAULT; |
1552 | goto error2; | 1545 | goto error2; |
1553 | } | 1546 | } |
1554 | 1547 | ||
1555 | diu_mode = in_be32(&dr.diu_reg->diu_mode); | 1548 | diu_mode = in_be32(&machine_data->diu_reg->diu_mode); |
1556 | if (diu_mode == MFB_MODE0) | 1549 | if (diu_mode == MFB_MODE0) |
1557 | out_be32(&dr.diu_reg->diu_mode, 0); /* disable DIU */ | 1550 | out_be32(&machine_data->diu_reg->diu_mode, 0); /* disable DIU */ |
1558 | 1551 | ||
1559 | /* Get the IRQ of the DIU */ | 1552 | /* Get the IRQ of the DIU */ |
1560 | machine_data->irq = irq_of_parse_and_map(np, 0); | 1553 | machine_data->irq = irq_of_parse_and_map(np, 0); |
@@ -1607,10 +1600,11 @@ static int __devinit fsl_diu_probe(struct platform_device *pdev) | |||
1607 | * by the bootloader, set dummy area descriptor otherwise. | 1600 | * by the bootloader, set dummy area descriptor otherwise. |
1608 | */ | 1601 | */ |
1609 | if (diu_mode == MFB_MODE0) | 1602 | if (diu_mode == MFB_MODE0) |
1610 | out_be32(&dr.diu_reg->desc[0], machine_data->dummy_ad->paddr); | 1603 | out_be32(&machine_data->diu_reg->desc[0], |
1604 | machine_data->dummy_ad->paddr); | ||
1611 | 1605 | ||
1612 | out_be32(&dr.diu_reg->desc[1], machine_data->dummy_ad->paddr); | 1606 | out_be32(&machine_data->diu_reg->desc[1], machine_data->dummy_ad->paddr); |
1613 | out_be32(&dr.diu_reg->desc[2], machine_data->dummy_ad->paddr); | 1607 | out_be32(&machine_data->diu_reg->desc[2], machine_data->dummy_ad->paddr); |
1614 | 1608 | ||
1615 | for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++) { | 1609 | for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++) { |
1616 | machine_data->fsl_diu_info[i]->fix.smem_start = 0; | 1610 | machine_data->fsl_diu_info[i]->fix.smem_start = 0; |
@@ -1625,7 +1619,7 @@ static int __devinit fsl_diu_probe(struct platform_device *pdev) | |||
1625 | } | 1619 | } |
1626 | } | 1620 | } |
1627 | 1621 | ||
1628 | if (request_irq_local(machine_data->irq)) { | 1622 | if (request_irq_local(machine_data)) { |
1629 | dev_err(&pdev->dev, "could not claim irq\n"); | 1623 | dev_err(&pdev->dev, "could not claim irq\n"); |
1630 | goto error; | 1624 | goto error; |
1631 | } | 1625 | } |
@@ -1659,7 +1653,7 @@ error: | |||
1659 | 32); | 1653 | 32); |
1660 | if (machine_data->dummy_aoi_virt) | 1654 | if (machine_data->dummy_aoi_virt) |
1661 | fsl_diu_free(machine_data->dummy_aoi_virt, 64); | 1655 | fsl_diu_free(machine_data->dummy_aoi_virt, 64); |
1662 | iounmap(dr.diu_reg); | 1656 | iounmap(machine_data->diu_reg); |
1663 | 1657 | ||
1664 | error2: | 1658 | error2: |
1665 | for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++) | 1659 | for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++) |
@@ -1677,7 +1671,7 @@ static int fsl_diu_remove(struct platform_device *pdev) | |||
1677 | 1671 | ||
1678 | machine_data = dev_get_drvdata(&pdev->dev); | 1672 | machine_data = dev_get_drvdata(&pdev->dev); |
1679 | disable_lcdc(machine_data->fsl_diu_info[0]); | 1673 | disable_lcdc(machine_data->fsl_diu_info[0]); |
1680 | free_irq_local(machine_data->irq); | 1674 | free_irq_local(machine_data); |
1681 | for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++) | 1675 | for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++) |
1682 | uninstall_fb(machine_data->fsl_diu_info[i]); | 1676 | uninstall_fb(machine_data->fsl_diu_info[i]); |
1683 | if (pool.ad.vaddr) | 1677 | if (pool.ad.vaddr) |
@@ -1689,7 +1683,7 @@ static int fsl_diu_remove(struct platform_device *pdev) | |||
1689 | free_buf(&pdev->dev, &pool.cursor, MAX_CURS * MAX_CURS * 2, 32); | 1683 | free_buf(&pdev->dev, &pool.cursor, MAX_CURS * MAX_CURS * 2, 32); |
1690 | if (machine_data->dummy_aoi_virt) | 1684 | if (machine_data->dummy_aoi_virt) |
1691 | fsl_diu_free(machine_data->dummy_aoi_virt, 64); | 1685 | fsl_diu_free(machine_data->dummy_aoi_virt, 64); |
1692 | iounmap(dr.diu_reg); | 1686 | iounmap(machine_data->diu_reg); |
1693 | for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++) | 1687 | for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++) |
1694 | if (machine_data->fsl_diu_info[i]) | 1688 | if (machine_data->fsl_diu_info[i]) |
1695 | framebuffer_release(machine_data->fsl_diu_info[i]); | 1689 | framebuffer_release(machine_data->fsl_diu_info[i]); |
@@ -1812,7 +1806,6 @@ static int __init fsl_diu_init(void) | |||
1812 | #if defined(CONFIG_NOT_COHERENT_CACHE) | 1806 | #if defined(CONFIG_NOT_COHERENT_CACHE) |
1813 | vfree(coherence_data); | 1807 | vfree(coherence_data); |
1814 | #endif | 1808 | #endif |
1815 | iounmap(dr.diu_reg); | ||
1816 | } | 1809 | } |
1817 | return ret; | 1810 | return ret; |
1818 | } | 1811 | } |