[PATCH v12 05/10] drm/mediatek: Add MT8195 Embedded DisplayPort driver
CK Hu
ck.hu at mediatek.com
Wed Jun 29 19:29:27 PDT 2022
Hi, Bo-Chen:
On Mon, 2022-06-27 at 16:03 +0800, Bo-Chen Chen wrote:
> From: Markus Schneider-Pargmann <msp at baylibre.com>
>
> This patch adds a embedded displayport driver for the MediaTek mt8195
> SoC.
>
> It supports the MT8195, the embedded DisplayPort units. It offers
> DisplayPort 1.4 with up to 4 lanes.
>
> The driver creates a child device for the phy. The child device will
> never exist without the parent being active. As they are sharing a
> register range, the parent passes a regmap pointer to the child so
> that
> both can work with the same register range. The phy driver sets
> device
> data that is read by the parent to get the phy device that can be
> used
> to control the phy properties.
>
> This driver is based on an initial version by
> Jitao shi <jitao.shi at mediatek.com>
>
> Signed-off-by: Markus Schneider-Pargmann <msp at baylibre.com>
> Signed-off-by: Guillaume Ranquet <granquet at baylibre.com>
> [Bo-Chen: Cleanup the drivers and modify comments from reviewers]
> Signed-off-by: Bo-Chen Chen <rex-bc.chen at mediatek.com>
> ---
[snip]
> +
> +static int mtk_dp_dt_parse(struct mtk_dp *mtk_dp,
> + struct platform_device *pdev)
> +{
> + struct device_node *of_node = pdev->dev.of_node;
> + struct device *dev = &pdev->dev;
> + int ret = 0;
> + void __iomem *base;
> + u32 linkrate;
> + int len;
> +
> + base = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(base))
> + return PTR_ERR(base);
> +
> + mtk_dp->regs = devm_regmap_init_mmio(dev, base,
> &mtk_dp_regmap_config);
> + if (IS_ERR(mtk_dp->regs))
> + return PTR_ERR(mtk_dp->regs);
> +
> + len = of_property_count_elems_of_size(of_node,
> + "data-lanes",
> sizeof(u32));
> + if (len < 0 || len > 4 || len == 3) {
> + dev_err(dev, "invalid data lane size: %d\n", len);
> + return -EINVAL;
> + }
> +
> + mtk_dp->max_lanes = len;
> +
> + ret = device_property_read_u32(dev, "max-linkrate-mhz",
> &linkrate);
> + if (ret) {
> + dev_err(dev, "failed to read max linkrate: %d\n", ret);
> + return ret;
> + }
> +
> + switch (linkrate) {
> + case 8100: /* 8.1G */
> + mtk_dp->max_linkrate = DP_LINK_BW_8_1;
> + break;
> + case 5400: /* 5.4G */
> + mtk_dp->max_linkrate = DP_LINK_BW_5_4;
> + break;
> + case 2700: /* 2.7G */
> + mtk_dp->max_linkrate = DP_LINK_BW_2_7;
> + break;
> + case 1620: /* 1.62G */
> + mtk_dp->max_linkrate = DP_LINK_BW_1_62;
> + break;
> + default:
> + dev_err(dev, "invalid linkrate: %d\n", linkrate);
> + return -EINVAL;
> + }
Use drm_dp_link_rate_to_bw_code() instead of self-implementation.
Regards,
CK
> +
> + return 0;
> +}
> +
More information about the Linux-mediatek
mailing list