This source file includes following definitions.
- rcar_hdmi_mode_valid
- rcar_hdmi_phy_configure
- rcar_dw_hdmi_probe
- rcar_dw_hdmi_remove
1
2
3
4
5
6
7
8
9
10 #include <linux/mod_devicetable.h>
11 #include <linux/module.h>
12 #include <linux/platform_device.h>
13
14 #include <drm/bridge/dw_hdmi.h>
15 #include <drm/drm_modes.h>
16
17 #define RCAR_HDMI_PHY_OPMODE_PLLCFG 0x06
18 #define RCAR_HDMI_PHY_PLLCURRGMPCTRL 0x10
19 #define RCAR_HDMI_PHY_PLLDIVCTRL 0x11
20
21 struct rcar_hdmi_phy_params {
22 unsigned long mpixelclock;
23 u16 opmode_div;
24 u16 curr_gmp;
25 u16 div;
26 };
27
28 static const struct rcar_hdmi_phy_params rcar_hdmi_phy_params[] = {
29 { 35500000, 0x0003, 0x0344, 0x0328 },
30 { 44900000, 0x0003, 0x0285, 0x0128 },
31 { 71000000, 0x0002, 0x1184, 0x0314 },
32 { 90000000, 0x0002, 0x1144, 0x0114 },
33 { 140250000, 0x0001, 0x20c4, 0x030a },
34 { 182750000, 0x0001, 0x2084, 0x010a },
35 { 281250000, 0x0000, 0x0084, 0x0305 },
36 { 297000000, 0x0000, 0x0084, 0x0105 },
37 { ~0UL, 0x0000, 0x0000, 0x0000 },
38 };
39
40 static enum drm_mode_status
41 rcar_hdmi_mode_valid(struct drm_connector *connector,
42 const struct drm_display_mode *mode)
43 {
44
45
46
47
48 if (mode->clock > 297000)
49 return MODE_CLOCK_HIGH;
50
51 return MODE_OK;
52 }
53
54 static int rcar_hdmi_phy_configure(struct dw_hdmi *hdmi,
55 const struct dw_hdmi_plat_data *pdata,
56 unsigned long mpixelclock)
57 {
58 const struct rcar_hdmi_phy_params *params = rcar_hdmi_phy_params;
59
60 for (; params->mpixelclock != ~0UL; ++params) {
61 if (mpixelclock <= params->mpixelclock)
62 break;
63 }
64
65 if (params->mpixelclock == ~0UL)
66 return -EINVAL;
67
68 dw_hdmi_phy_i2c_write(hdmi, params->opmode_div,
69 RCAR_HDMI_PHY_OPMODE_PLLCFG);
70 dw_hdmi_phy_i2c_write(hdmi, params->curr_gmp,
71 RCAR_HDMI_PHY_PLLCURRGMPCTRL);
72 dw_hdmi_phy_i2c_write(hdmi, params->div, RCAR_HDMI_PHY_PLLDIVCTRL);
73
74 return 0;
75 }
76
77 static const struct dw_hdmi_plat_data rcar_dw_hdmi_plat_data = {
78 .mode_valid = rcar_hdmi_mode_valid,
79 .configure_phy = rcar_hdmi_phy_configure,
80 };
81
82 static int rcar_dw_hdmi_probe(struct platform_device *pdev)
83 {
84 struct dw_hdmi *hdmi;
85
86 hdmi = dw_hdmi_probe(pdev, &rcar_dw_hdmi_plat_data);
87 if (IS_ERR(hdmi))
88 return PTR_ERR(hdmi);
89
90 platform_set_drvdata(pdev, hdmi);
91
92 return 0;
93 }
94
95 static int rcar_dw_hdmi_remove(struct platform_device *pdev)
96 {
97 struct dw_hdmi *hdmi = platform_get_drvdata(pdev);
98
99 dw_hdmi_remove(hdmi);
100
101 return 0;
102 }
103
104 static const struct of_device_id rcar_dw_hdmi_of_table[] = {
105 { .compatible = "renesas,rcar-gen3-hdmi" },
106 { },
107 };
108 MODULE_DEVICE_TABLE(of, rcar_dw_hdmi_of_table);
109
110 static struct platform_driver rcar_dw_hdmi_platform_driver = {
111 .probe = rcar_dw_hdmi_probe,
112 .remove = rcar_dw_hdmi_remove,
113 .driver = {
114 .name = "rcar-dw-hdmi",
115 .of_match_table = rcar_dw_hdmi_of_table,
116 },
117 };
118
119 module_platform_driver(rcar_dw_hdmi_platform_driver);
120
121 MODULE_AUTHOR("Laurent Pinchart <laurent.pinchart@ideasonboard.com>");
122 MODULE_DESCRIPTION("Renesas R-Car Gen3 HDMI Encoder Driver");
123 MODULE_LICENSE("GPL");