drm/rockchip: hdmi support for rk3328
Subsystems (6)
Heiko Stuebner
maintainerv3 cover drm/rockchip: hdmi support for rk3328
The rk3228/rk3229 and rk3328 socs started using a new type of hdmi-phy from Innosilicon that resides completely separate from the dw-hdmi block and gets accessed via mmio.
Additionally the rk3328 dw-hdmi does not report the vendor-phy type but a different one instead, so add the possibility to override the phy type when the glue driver knows better than the ip block itself.
changes in v3:
- split off phy driver into a separate series
- only allow forcing vendor phy type
- wording fixes and other nits
changes in v2:
- phy: prevent overflow in tmdsclk calculation as reported by Martin Cerveny
- phy: use unsigned long for all tmdsclk rate uses
- phy: simplify tmds rate calculation
- dropped patch exporting some dw-hdmi phy functions as a similar patch entered drm-misc already
Heiko Stuebner (6):
drm/bridge: dw-hdmi: allow forcing vendor phy-type drm/rockchip: dw_hdmi: Allow outputs that don't need output switching
dt-bindings: allow optional phys in Rockchip dw_hdmi binding drm/rockchip: dw_hdmi: allow including external phys drm/rockchip: dw_hdmi: store rockchip_hdmi reference in phy_data
object
drm/rockchip: dw_hdmi: add dw-hdmi support for the rk3328
.../display/rockchip/dw_hdmi-rockchip.txt | 3 + drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 4 +- drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 130 +++++++++++++++++- include/drm/bridge/dw_hdmi.h | 1 + 4 files changed, 134 insertions(+), 4 deletions(-)
Signature · 1 line
2.17.0
Heiko Stuebner
maintainerPATCH v3 1/6 drm/bridge: dw-hdmi: allow forcing vendor phy-type
In some IP implementations the reading of the phy-type may be broken. One example are the Rockchip rk3228 and rk3328 socs that use a separate vendor-type phy from Innosilicon but still report the HDMI20_TX type.
So allow the glue driver to force the vendor-phy for these cases. In the future it may be necessary to allow forcing other types, but for now we'll keep it simply to the case actually seen in the wild.
---
changes in v3:
- only allow forcing vendor type, as suggested by Laurent
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 4 +++- include/drm/bridge/dw_hdmi.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +3 -1
@@ -2212,7 +2212,9 @@ static int dw_hdmi_detect_phy(struct dw_hdmi *hdmi)unsigned int i;u8 phy_type; - phy_type =hdmi_readb (hdmi,HDMI_CONFIG2_ID ); + phy_type = hdmi->plat_data->phy_force_vendor ? +DW_HDMI_PHY_VENDOR_PHY : +hdmi_readb (hdmi,HDMI_CONFIG2_ID );if (phy_type ==DW_HDMI_PHY_VENDOR_PHY ) {/* Vendor PHYs require support from the glue layer. */
include/drm/bridge/dw_hdmi.h +1 -0
@@ -133,6 +133,7 @@ struct dw_hdmi_plat_data {const struct dw_hdmi_phy_ops *phy_ops;const char *phy_name;void *phy_data; +bool phy_force_vendor;/* Synopsys PHY support */ const struct dw_hdmi_mpll_config *mpll_cfg;
Signature · 1 line
2.17.0
Heiko Stuebner
maintainerPATCH v3 2/6 drm/rockchip: dw_hdmi: Allow outputs that don't need output switching
In reply to Heiko StuebnerSo far we always encountered socs with 2 output crtcs needing the driver to tell the hdmi block which output to connect to. But there also exist socs with only one crtc like the rk3228, rk3328 and rk3368.
So adapt the register field to simply carry a negative value to signal that no output-switching is necessary.
---
changes in v3:
- fixed wording issue found by Robin Murphy
drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c +4 -1
@@ -36,7 +36,7 @@* @lcdsel_lit: reg value of selecting vop little for HDMI */ struct rockchip_hdmi_chip_data { -u32 lcdsel_grf_reg; +int lcdsel_grf_reg;u32 lcdsel_big;u32 lcdsel_lit; };
@@ -245,6 +245,9 @@ static void dw_hdmi_rockchip_encoder_enable(struct drm_encoder *encoder)u32 val;int ret; +if (hdmi->chip_data->lcdsel_grf_reg <0 ) +return ; + ret =drm_of_encoder_active_endpoint_id (hdmi->dev->of_node, encoder);if (ret) val = hdmi->chip_data->lcdsel_lit;
Signature · 1 line
2.17.0
Heiko Stuebner
maintainerPATCH v3 3/6 dt-bindings: allow optional phys in Rockchip dw_hdmi binding
In reply to Heiko StuebnerSome newer Rockchip SoCs use an Innosilicon hdmiphy accessed via general mmio, so allow these to be referenced via the regular phy interfaces and therefore add optional phy-related properties to the binding.
--- .../devicetree/bindings/display/rockchip/dw_hdmi-rockchip.txt | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/display/rockchip/dw_hdmi-rockchip.txt +2 -0
@@ -34,6 +34,8 @@ Optional properties - clock-names: May contain "cec" as defined in dw_hdmi.txt. - clock-names: May contain "grf", power for grf io. - clock-names: May contain "vpll", external clock for some hdmi phy. +- phys: from general PHY binding: the phandle for the PHY device. +- phy-names: Should be "hdmi" if phys references an external phy. Example:
Signature · 1 line
2.17.0
Heiko Stuebner
maintainerPATCH v3 4/6 drm/rockchip: dw_hdmi: allow including external phys
In reply to Heiko StuebnerSome variants of the dw-hdmi on Rockchip socs use a separate phy block accessed via the generic phy framework, so allow them to be included if such a phy reference is found.
--- drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c +10 -0
@@ -11,6 +11,7 @@#include <linux/mfd/syscon.h> #include <linux/module.h> #include <linux/platform_device.h> +#include <linux/phy/phy.h> #include <linux/regmap.h> #include <drm/drm_of.h>
@@ -49,6 +50,7 @@ struct rockchip_hdmi {struct clk *vpll_clk;struct clk *grf_clk;struct dw_hdmi *hdmi; +struct phy *phy; };#define to_rockchip_hdmi (x) container_of(x, struct rockchip_hdmi, x)
@@ -376,6 +378,14 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,return ret; } + hdmi->phy =devm_phy_optional_get (dev,"hdmi" ); +if (IS_ERR (hdmi->phy)) { + ret =PTR_ERR (hdmi->phy); +if (ret != -EPROBE_DEFER ) +DRM_DEV_ERROR (hdmi->dev,"failed to get phy\n" ); +return ret; + } +drm_encoder_helper_add (encoder, &dw_hdmi_rockchip_encoder_helper_funcs);drm_encoder_init (drm, encoder, &dw_hdmi_rockchip_encoder_funcs,DRM_MODE_ENCODER_TMDS ,NULL );
Signature · 1 line
2.17.0
Heiko Stuebner
maintainerPATCH v3 5/6 drm/rockchip: dw_hdmi: store rockchip_hdmi reference in phy_data object
In reply to Heiko StuebnerWhen using special phy handling operations we'll often need access to the rockchip_hdmi struct.
As the chip-data that occupies the phy_data pointer initially gets assigned to the rockchip_hdmi struct, we can now re-use this phy_data pointer to hold the reference to the rockchip_hdmi struct and use this reference later on.
Inspiration for this comes from meson and sunxi dw-hdmi, which are using the same method.
---
changes in v3:
- reword commit message
drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c +7 -2
@@ -335,7 +335,7 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master, void *data) {struct platform_device *pdev =to_platform_device (dev); -const struct dw_hdmi_plat_data *plat_data; +struct dw_hdmi_plat_data *plat_data;const struct of_device_id *match;struct drm_device *drm = data;struct drm_encoder *encoder;
@@ -350,9 +350,14 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,return -ENOMEM ; match =of_match_node (dw_hdmi_rockchip_dt_ids, pdev->dev.of_node); - plat_data = match->data; + plat_data =devm_kmemdup (&pdev->dev, match->data, +sizeof (*plat_data),GFP_KERNEL ); +if (!plat_data) +return -ENOMEM ; + hdmi->dev = &pdev->dev; hdmi->chip_data = plat_data->phy_data; + plat_data->phy_data = hdmi; encoder = &hdmi->encoder; encoder->possible_crtcs =drm_of_find_possible_crtcs (drm, dev->of_node);
Signature · 1 line
2.17.0
Heiko Stuebner
maintainerPATCH v3 6/6 drm/rockchip: dw_hdmi: add dw-hdmi support for the rk3328
In reply to Heiko StuebnerThe rk3328 uses a dw-hdmi controller with an external hdmi phy from Innosilicon which uses the generic phy framework for access. Add the necessary data and the compatible for the rk3328 to the rockchip dw-hdmi driver.
---
changes in v3:
- reword as suggested by Rob to show that it's a dw-hdmi + Inno phy
.../display/rockchip/dw_hdmi-rockchip.txt | 1 + drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 106 ++++++++++++++++++ 2 files changed, 107 insertions(+)
Documentation/devicetree/bindings/display/rockchip/dw_hdmi-rockchip.txt +1 -0
@@ -13,6 +13,7 @@ Required properties: - compatible: should be one of the following: "rockchip,rk3288-dw-hdmi" + "rockchip,rk3328-dw-hdmi" "rockchip,rk3399-dw-hdmi" - reg: See dw_hdmi.txt. - reg-io-width: See dw_hdmi.txt. Shall be 4.
drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c +106 -0
130 lines not on this page · raw message
Signature · 1 line
2.17.0
Re: [PATCH v3 6/6] drm/rockchip: dw_hdmi: add dw-hdmi support for the rk3328
Quoted 5 lines · Heiko Stuebner
The rk3328 uses a dw-hdmi controller with an external hdmi phy from Innosilicon which uses the generic phy framework for access. Add the necessary data and the compatible for the rk3328 to the rockchip dw-hdmi driver.
Quoted 7 lines
Signed-off-by Heiko Stuebner <[email protected]>Tested-by Robin Murphy <[email protected]>---
changes in v3:
- reword as suggested by Rob to show that it's a dw-hdmi + Inno phy.../display/rockchip/dw_hdmi-rockchip.txt | 1 +
Quoted 2 lines
drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 106 ++++++++++++++++++ 2 files changed, 107 insertions(+)