0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/module.h>
0009 #include <linux/of_platform.h>
0010 #include <linux/platform_device.h>
0011
0012 #include <drm/bridge/dw_hdmi.h>
0013 #include <drm/drm_of.h>
0014 #include <drm/drm_print.h>
0015
0016 static const struct dw_hdmi_mpll_config ingenic_mpll_cfg[] = {
0017 { 45250000, { { 0x01e0, 0x0000 }, { 0x21e1, 0x0000 }, { 0x41e2, 0x0000 } } },
0018 { 92500000, { { 0x0140, 0x0005 }, { 0x2141, 0x0005 }, { 0x4142, 0x0005 } } },
0019 { 148500000, { { 0x00a0, 0x000a }, { 0x20a1, 0x000a }, { 0x40a2, 0x000a } } },
0020 { 216000000, { { 0x00a0, 0x000a }, { 0x2001, 0x000f }, { 0x4002, 0x000f } } },
0021 { ~0UL, { { 0x0000, 0x0000 }, { 0x0000, 0x0000 }, { 0x0000, 0x0000 } } }
0022 };
0023
0024 static const struct dw_hdmi_curr_ctrl ingenic_cur_ctr[] = {
0025
0026 { 54000000, { 0x091c, 0x091c, 0x06dc } },
0027 { 58400000, { 0x091c, 0x06dc, 0x06dc } },
0028 { 72000000, { 0x06dc, 0x06dc, 0x091c } },
0029 { 74250000, { 0x06dc, 0x0b5c, 0x091c } },
0030 { 118800000, { 0x091c, 0x091c, 0x06dc } },
0031 { 216000000, { 0x06dc, 0x0b5c, 0x091c } },
0032 { ~0UL, { 0x0000, 0x0000, 0x0000 } },
0033 };
0034
0035
0036
0037
0038
0039
0040 static const struct dw_hdmi_phy_config ingenic_phy_config[] = {
0041
0042 { 216000000, 0x800d, 0x0005, 0x01ad},
0043 { ~0UL, 0x0000, 0x0000, 0x0000}
0044 };
0045
0046 static enum drm_mode_status
0047 ingenic_dw_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
0048 const struct drm_display_info *info,
0049 const struct drm_display_mode *mode)
0050 {
0051 if (mode->clock < 13500)
0052 return MODE_CLOCK_LOW;
0053
0054 if (mode->clock > 216000)
0055 return MODE_CLOCK_HIGH;
0056
0057 return MODE_OK;
0058 }
0059
0060 static struct dw_hdmi_plat_data ingenic_dw_hdmi_plat_data = {
0061 .mpll_cfg = ingenic_mpll_cfg,
0062 .cur_ctr = ingenic_cur_ctr,
0063 .phy_config = ingenic_phy_config,
0064 .mode_valid = ingenic_dw_hdmi_mode_valid,
0065 .output_port = 1,
0066 };
0067
0068 static const struct of_device_id ingenic_dw_hdmi_dt_ids[] = {
0069 { .compatible = "ingenic,jz4780-dw-hdmi" },
0070 { },
0071 };
0072 MODULE_DEVICE_TABLE(of, ingenic_dw_hdmi_dt_ids);
0073
0074 static void ingenic_dw_hdmi_cleanup(void *data)
0075 {
0076 struct dw_hdmi *hdmi = (struct dw_hdmi *)data;
0077
0078 dw_hdmi_remove(hdmi);
0079 }
0080
0081 static int ingenic_dw_hdmi_probe(struct platform_device *pdev)
0082 {
0083 struct dw_hdmi *hdmi;
0084
0085 hdmi = dw_hdmi_probe(pdev, &ingenic_dw_hdmi_plat_data);
0086 if (IS_ERR(hdmi))
0087 return PTR_ERR(hdmi);
0088
0089 return devm_add_action_or_reset(&pdev->dev, ingenic_dw_hdmi_cleanup, hdmi);
0090 }
0091
0092 static struct platform_driver ingenic_dw_hdmi_driver = {
0093 .probe = ingenic_dw_hdmi_probe,
0094 .driver = {
0095 .name = "dw-hdmi-ingenic",
0096 .of_match_table = ingenic_dw_hdmi_dt_ids,
0097 },
0098 };
0099 module_platform_driver(ingenic_dw_hdmi_driver);
0100
0101 MODULE_DESCRIPTION("JZ4780 Specific DW-HDMI Driver Extension");
0102 MODULE_LICENSE("GPL v2");
0103 MODULE_ALIAS("platform:dw-hdmi-ingenic");