Linux Audio

Check our new training course

Loading...
Note: File does not exist in v3.1.
  1// SPDX-License-Identifier: GPL-2.0
  2/* Copyright (C) 2011-2013 Freescale Semiconductor, Inc.
  3 * Copyright (C) 2019, 2020 Paul Boddie <paul@boddie.org.uk>
  4 *
  5 * Derived from dw_hdmi-imx.c with i.MX portions removed.
  6 */
  7
  8#include <linux/module.h>
  9#include <linux/of_platform.h>
 10#include <linux/platform_device.h>
 11
 12#include <drm/bridge/dw_hdmi.h>
 13#include <drm/drm_of.h>
 14#include <drm/drm_print.h>
 15
 16static const struct dw_hdmi_mpll_config ingenic_mpll_cfg[] = {
 17	{ 45250000,  { { 0x01e0, 0x0000 }, { 0x21e1, 0x0000 }, { 0x41e2, 0x0000 } } },
 18	{ 92500000,  { { 0x0140, 0x0005 }, { 0x2141, 0x0005 }, { 0x4142, 0x0005 } } },
 19	{ 148500000, { { 0x00a0, 0x000a }, { 0x20a1, 0x000a }, { 0x40a2, 0x000a } } },
 20	{ 216000000, { { 0x00a0, 0x000a }, { 0x2001, 0x000f }, { 0x4002, 0x000f } } },
 21	{ ~0UL,      { { 0x0000, 0x0000 }, { 0x0000, 0x0000 }, { 0x0000, 0x0000 } } }
 22};
 23
 24static const struct dw_hdmi_curr_ctrl ingenic_cur_ctr[] = {
 25	/*pixelclk     bpp8    bpp10   bpp12 */
 26	{ 54000000,  { 0x091c, 0x091c, 0x06dc } },
 27	{ 58400000,  { 0x091c, 0x06dc, 0x06dc } },
 28	{ 72000000,  { 0x06dc, 0x06dc, 0x091c } },
 29	{ 74250000,  { 0x06dc, 0x0b5c, 0x091c } },
 30	{ 118800000, { 0x091c, 0x091c, 0x06dc } },
 31	{ 216000000, { 0x06dc, 0x0b5c, 0x091c } },
 32	{ ~0UL,      { 0x0000, 0x0000, 0x0000 } },
 33};
 34
 35/*
 36 * Resistance term 133Ohm Cfg
 37 * PREEMP config 0.00
 38 * TX/CK level 10
 39 */
 40static const struct dw_hdmi_phy_config ingenic_phy_config[] = {
 41	/*pixelclk   symbol   term   vlev */
 42	{ 216000000, 0x800d, 0x0005, 0x01ad},
 43	{ ~0UL,      0x0000, 0x0000, 0x0000}
 44};
 45
 46static enum drm_mode_status
 47ingenic_dw_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
 48			   const struct drm_display_info *info,
 49			   const struct drm_display_mode *mode)
 50{
 51	if (mode->clock < 13500)
 52		return MODE_CLOCK_LOW;
 53	/* FIXME: Hardware is capable of 270MHz, but setup data is missing. */
 54	if (mode->clock > 216000)
 55		return MODE_CLOCK_HIGH;
 56
 57	return MODE_OK;
 58}
 59
 60static struct dw_hdmi_plat_data ingenic_dw_hdmi_plat_data = {
 61	.mpll_cfg   = ingenic_mpll_cfg,
 62	.cur_ctr    = ingenic_cur_ctr,
 63	.phy_config = ingenic_phy_config,
 64	.mode_valid = ingenic_dw_hdmi_mode_valid,
 65	.output_port	= 1,
 66};
 67
 68static const struct of_device_id ingenic_dw_hdmi_dt_ids[] = {
 69	{ .compatible = "ingenic,jz4780-dw-hdmi" },
 70	{ /* Sentinel */ },
 71};
 72MODULE_DEVICE_TABLE(of, ingenic_dw_hdmi_dt_ids);
 73
 74static void ingenic_dw_hdmi_cleanup(void *data)
 75{
 76	struct dw_hdmi *hdmi = (struct dw_hdmi *)data;
 77
 78	dw_hdmi_remove(hdmi);
 79}
 80
 81static int ingenic_dw_hdmi_probe(struct platform_device *pdev)
 82{
 83	struct dw_hdmi *hdmi;
 84
 85	hdmi = dw_hdmi_probe(pdev, &ingenic_dw_hdmi_plat_data);
 86	if (IS_ERR(hdmi))
 87		return PTR_ERR(hdmi);
 88
 89	return devm_add_action_or_reset(&pdev->dev, ingenic_dw_hdmi_cleanup, hdmi);
 90}
 91
 92static struct platform_driver ingenic_dw_hdmi_driver = {
 93	.probe  = ingenic_dw_hdmi_probe,
 94	.driver = {
 95		.name = "dw-hdmi-ingenic",
 96		.of_match_table = ingenic_dw_hdmi_dt_ids,
 97	},
 98};
 99module_platform_driver(ingenic_dw_hdmi_driver);
100
101MODULE_DESCRIPTION("JZ4780 Specific DW-HDMI Driver Extension");
102MODULE_LICENSE("GPL v2");
103MODULE_ALIAS("platform:dw-hdmi-ingenic");