diff options
| author | chunhui dai <chunhui.dai@mediatek.com> | 2018-10-02 23:41:42 -0400 |
|---|---|---|
| committer | CK Hu <ck.hu@mediatek.com> | 2018-10-02 23:56:31 -0400 |
| commit | 0ace4b993c7a524962c6c17f3956a2d3cf2454e1 (patch) | |
| tree | d0e221a02461e5e379cfc1d6ba924e82d73fe601 /drivers/gpu | |
| parent | 4e90a6eb769a2041a81efb3c288a087790ae885d (diff) | |
drm/mediatek: move hardware register to node data
The address of register DPI_H_FRE_CON is different in different IC.
Using of_node data to find this address.
Signed-off-by: chunhui dai <chunhui.dai@mediatek.com>
Signed-off-by: CK Hu <ck.hu@mediatek.com>
Diffstat (limited to 'drivers/gpu')
| -rw-r--r-- | drivers/gpu/drm/mediatek/mtk_dpi.c | 19 | ||||
| -rw-r--r-- | drivers/gpu/drm/mediatek/mtk_dpi_regs.h | 1 |
2 files changed, 16 insertions, 4 deletions
diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c index 5ede1ddbaa1a..72aa43187731 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #include <linux/component.h> | 18 | #include <linux/component.h> |
| 19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
| 20 | #include <linux/of.h> | 20 | #include <linux/of.h> |
| 21 | #include <linux/of_device.h> | ||
| 21 | #include <linux/of_graph.h> | 22 | #include <linux/of_graph.h> |
| 22 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
| 23 | #include <linux/types.h> | 24 | #include <linux/types.h> |
| @@ -72,6 +73,7 @@ struct mtk_dpi { | |||
| 72 | struct clk *tvd_clk; | 73 | struct clk *tvd_clk; |
| 73 | int irq; | 74 | int irq; |
| 74 | struct drm_display_mode mode; | 75 | struct drm_display_mode mode; |
| 76 | const struct mtk_dpi_conf *conf; | ||
| 75 | enum mtk_dpi_out_color_format color_format; | 77 | enum mtk_dpi_out_color_format color_format; |
| 76 | enum mtk_dpi_out_yc_map yc_map; | 78 | enum mtk_dpi_out_yc_map yc_map; |
| 77 | enum mtk_dpi_out_bit_num bit_num; | 79 | enum mtk_dpi_out_bit_num bit_num; |
| @@ -110,6 +112,10 @@ struct mtk_dpi_yc_limit { | |||
| 110 | u16 c_bottom; | 112 | u16 c_bottom; |
| 111 | }; | 113 | }; |
| 112 | 114 | ||
| 115 | struct mtk_dpi_conf { | ||
| 116 | u32 reg_h_fre_con; | ||
| 117 | }; | ||
| 118 | |||
| 113 | static void mtk_dpi_mask(struct mtk_dpi *dpi, u32 offset, u32 val, u32 mask) | 119 | static void mtk_dpi_mask(struct mtk_dpi *dpi, u32 offset, u32 val, u32 mask) |
| 114 | { | 120 | { |
| 115 | u32 tmp = readl(dpi->regs + offset) & ~mask; | 121 | u32 tmp = readl(dpi->regs + offset) & ~mask; |
| @@ -335,7 +341,7 @@ static void mtk_dpi_config_swap_input(struct mtk_dpi *dpi, bool enable) | |||
| 335 | 341 | ||
| 336 | static void mtk_dpi_config_2n_h_fre(struct mtk_dpi *dpi) | 342 | static void mtk_dpi_config_2n_h_fre(struct mtk_dpi *dpi) |
| 337 | { | 343 | { |
| 338 | mtk_dpi_mask(dpi, DPI_H_FRE_CON, H_FRE_2N, H_FRE_2N); | 344 | mtk_dpi_mask(dpi, dpi->conf->reg_h_fre_con, H_FRE_2N, H_FRE_2N); |
| 339 | } | 345 | } |
| 340 | 346 | ||
| 341 | static void mtk_dpi_config_color_format(struct mtk_dpi *dpi, | 347 | static void mtk_dpi_config_color_format(struct mtk_dpi *dpi, |
| @@ -639,6 +645,10 @@ static const struct component_ops mtk_dpi_component_ops = { | |||
| 639 | .unbind = mtk_dpi_unbind, | 645 | .unbind = mtk_dpi_unbind, |
| 640 | }; | 646 | }; |
| 641 | 647 | ||
| 648 | static const struct mtk_dpi_conf mt8173_conf = { | ||
| 649 | .reg_h_fre_con = 0xe0, | ||
| 650 | }; | ||
| 651 | |||
| 642 | static int mtk_dpi_probe(struct platform_device *pdev) | 652 | static int mtk_dpi_probe(struct platform_device *pdev) |
| 643 | { | 653 | { |
| 644 | struct device *dev = &pdev->dev; | 654 | struct device *dev = &pdev->dev; |
| @@ -653,6 +663,7 @@ static int mtk_dpi_probe(struct platform_device *pdev) | |||
| 653 | return -ENOMEM; | 663 | return -ENOMEM; |
| 654 | 664 | ||
| 655 | dpi->dev = dev; | 665 | dpi->dev = dev; |
| 666 | dpi->conf = (struct mtk_dpi_conf *)of_device_get_match_data(dev); | ||
| 656 | 667 | ||
| 657 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 668 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 658 | dpi->regs = devm_ioremap_resource(dev, mem); | 669 | dpi->regs = devm_ioremap_resource(dev, mem); |
| @@ -732,8 +743,10 @@ static int mtk_dpi_remove(struct platform_device *pdev) | |||
| 732 | } | 743 | } |
| 733 | 744 | ||
| 734 | static const struct of_device_id mtk_dpi_of_ids[] = { | 745 | static const struct of_device_id mtk_dpi_of_ids[] = { |
| 735 | { .compatible = "mediatek,mt8173-dpi", }, | 746 | { .compatible = "mediatek,mt8173-dpi", |
| 736 | {} | 747 | .data = &mt8173_conf, |
| 748 | }, | ||
| 749 | { }, | ||
| 737 | }; | 750 | }; |
| 738 | 751 | ||
| 739 | struct platform_driver mtk_dpi_driver = { | 752 | struct platform_driver mtk_dpi_driver = { |
diff --git a/drivers/gpu/drm/mediatek/mtk_dpi_regs.h b/drivers/gpu/drm/mediatek/mtk_dpi_regs.h index 4b6ad4751a31..040444d7718d 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi_regs.h +++ b/drivers/gpu/drm/mediatek/mtk_dpi_regs.h | |||
| @@ -223,6 +223,5 @@ | |||
| 223 | #define ESAV_CODE2 (0xFFF << 0) | 223 | #define ESAV_CODE2 (0xFFF << 0) |
| 224 | #define ESAV_CODE3_MSB BIT(16) | 224 | #define ESAV_CODE3_MSB BIT(16) |
| 225 | 225 | ||
| 226 | #define DPI_H_FRE_CON 0xE0 | ||
| 227 | #define H_FRE_2N BIT(25) | 226 | #define H_FRE_2N BIT(25) |
| 228 | #endif /* __MTK_DPI_REGS_H */ | 227 | #endif /* __MTK_DPI_REGS_H */ |
