4 * Copyright (C) 2016 Renesas Electronics Corporation
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
14 #include <linux/module.h>
15 #include <linux/platform_device.h>
17 #include <drm/bridge/dw_hdmi.h>
19 #define RCAR_HDMI_PHY_OPMODE_PLLCFG 0x06 /* Mode of operation and PLL dividers */
20 #define RCAR_HDMI_PHY_PLLCURRGMPCTRL 0x10 /* PLL current and Gmp (conductance) */
21 #define RCAR_HDMI_PHY_PLLDIVCTRL 0x11 /* PLL dividers */
23 struct rcar_hdmi_phy_params
{
24 unsigned long mpixelclock
;
25 u16 opmode_div
; /* Mode of operation and PLL dividers */
26 u16 curr_gmp
; /* PLL current and Gmp (conductance) */
27 u16 div
; /* PLL dividers */
30 static const struct rcar_hdmi_phy_params rcar_hdmi_phy_params
[] = {
31 { 35500000, 0x0003, 0x0344, 0x0328 },
32 { 44900000, 0x0003, 0x0285, 0x0128 },
33 { 71000000, 0x0002, 0x1184, 0x0314 },
34 { 90000000, 0x0002, 0x1144, 0x0114 },
35 { 140250000, 0x0001, 0x20c4, 0x030a },
36 { 182750000, 0x0001, 0x2084, 0x010a },
37 { 281250000, 0x0000, 0x0084, 0x0305 },
38 { 297000000, 0x0000, 0x0084, 0x0105 },
39 { ~0UL, 0x0000, 0x0000, 0x0000 },
42 static int rcar_hdmi_phy_configure(struct dw_hdmi
*hdmi
,
43 const struct dw_hdmi_plat_data
*pdata
,
44 unsigned long mpixelclock
)
46 const struct rcar_hdmi_phy_params
*params
= rcar_hdmi_phy_params
;
48 for (; params
->mpixelclock
!= ~0UL; ++params
) {
49 if (mpixelclock
<= params
->mpixelclock
)
53 if (params
->mpixelclock
== ~0UL)
56 dw_hdmi_phy_i2c_write(hdmi
, params
->opmode_div
,
57 RCAR_HDMI_PHY_OPMODE_PLLCFG
);
58 dw_hdmi_phy_i2c_write(hdmi
, params
->curr_gmp
,
59 RCAR_HDMI_PHY_PLLCURRGMPCTRL
);
60 dw_hdmi_phy_i2c_write(hdmi
, params
->div
, RCAR_HDMI_PHY_PLLDIVCTRL
);
65 static const struct dw_hdmi_plat_data rcar_dw_hdmi_plat_data
= {
66 .configure_phy
= rcar_hdmi_phy_configure
,
69 static int rcar_dw_hdmi_probe(struct platform_device
*pdev
)
73 hdmi
= dw_hdmi_probe(pdev
, &rcar_dw_hdmi_plat_data
);
77 platform_set_drvdata(pdev
, hdmi
);
82 static int rcar_dw_hdmi_remove(struct platform_device
*pdev
)
84 struct dw_hdmi
*hdmi
= platform_get_drvdata(pdev
);
91 static const struct of_device_id rcar_dw_hdmi_of_table
[] = {
92 { .compatible
= "renesas,rcar-gen3-hdmi" },
95 MODULE_DEVICE_TABLE(of
, rcar_dw_hdmi_of_table
);
97 static struct platform_driver rcar_dw_hdmi_platform_driver
= {
98 .probe
= rcar_dw_hdmi_probe
,
99 .remove
= rcar_dw_hdmi_remove
,
101 .name
= "rcar-dw-hdmi",
102 .of_match_table
= rcar_dw_hdmi_of_table
,
106 module_platform_driver(rcar_dw_hdmi_platform_driver
);
108 MODULE_AUTHOR("Laurent Pinchart <laurent.pinchart@ideasonboard.com>");
109 MODULE_DESCRIPTION("Renesas R-Car Gen3 HDMI Encoder Driver");
110 MODULE_LICENSE("GPL");