Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /* Copyright (C) 2011-2013 Freescale Semiconductor, Inc.
0003  * Copyright (C) 2019, 2020 Paul Boddie <paul@boddie.org.uk>
0004  *
0005  * Derived from dw_hdmi-imx.c with i.MX portions removed.
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     /*pixelclk     bpp8    bpp10   bpp12 */
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  * Resistance term 133Ohm Cfg
0037  * PREEMP config 0.00
0038  * TX/CK level 10
0039  */
0040 static const struct dw_hdmi_phy_config ingenic_phy_config[] = {
0041     /*pixelclk   symbol   term   vlev */
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     /* FIXME: Hardware is capable of 270MHz, but setup data is missing. */
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     { /* Sentinel */ },
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");