All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vinod Koul <vkoul@kernel.org>
To: Nelson Costa <Nelson.Costa@synopsys.com>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Rob Herring <robh+dt@kernel.org>,
	Jose Abreu <Jose.Abreu@synopsys.com>
Subject: Re: [PATCH 5/9] phy: dwc: Add Synopsys DesignWare HDMI RX PHYs e405 and e406 Driver
Date: Mon, 21 Jun 2021 11:23:29 +0530	[thread overview]
Message-ID: <YNApWS7tNGdWbyCm@vkoul-mobl> (raw)
In-Reply-To: <ac32f8d433860c5be612b393023329f967e2c058.1622631488.git.nelson.costa@synopsys.com>

On 02-06-21, 13:24, Nelson Costa wrote:

> +# Makefile for the PHY drivers.
> +#
> +
> +phy-dw-hdmi-e40x-y			:= phy-dw-hdmi-e40x-core.o
> +phy-dw-hdmi-e40x-y			+= phy-dw-hdmi-e405.o
> +phy-dw-hdmi-e40x-y			+= phy-dw-hdmi-e406.o

why not:
phy-dw-hdmi-e40x-y                   :=  phy-dw-hdmi-e40x-core.o phy-dw-hdmi-e405.o phy-dw-hdmi-e406.o ?

> +obj-$(CONFIG_VIDEO_DWC_HDMI_PHY_E40X)	+= phy-dw-hdmi-e40x.o
> diff --git a/drivers/phy/dwc/phy-dw-hdmi-e405.c b/drivers/phy/dwc/phy-dw-hdmi-e405.c
> new file mode 100644
> index 0000000..5078a86
> --- /dev/null
> +++ b/drivers/phy/dwc/phy-dw-hdmi-e405.c
> @@ -0,0 +1,497 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2018 - present Synopsys, Inc. and/or its affiliates.
> + * Synopsys DesignWare HDMI PHY e405

2018 - 2021 ?

> +/* PHY e405 mpll configuration */
> +static const struct dw_phy_mpll_config dw_phy_e405_mpll_cfg[] = {
> +	{ 0x27, 0x1B94 },

Lowercase please

> +	{ 0x28, 0x16D2 },
> +	{ 0x29, 0x12D9 },
> +	{ 0x2A, 0x3249 },
> +	{ 0x2B, 0x3653 },
> +	{ 0x2C, 0x3436 },
> +	{ 0x2D, 0x124D },
> +	{ 0x2E, 0x0001 },
> +	{ 0xCE, 0x0505 },
> +	{ 0xCF, 0x0505 },
> +	{ 0xD0, 0x0000 },
> +	{ 0x00, 0x0000 },
> +};
> +
> +/* PHY e405 equalization functions */
> +static int dw_phy_eq_test(struct dw_phy_dev *dw_dev,
> +			  u16 *fat_bit_mask, int *min_max_length)

Please align this to preceding line open brace (checkpatch with --strict would warn you about this)

> +{
> +	u16 main_fsm_status, val;
> +	unsigned int i;
> +
> +	for (i = 0; i < DW_PHY_EQ_WAIT_TIME_START; i++) {
> +		main_fsm_status = dw_phy_read(dw_dev, DW_PHY_MAINFSM_STATUS1);
> +		if (main_fsm_status & DW_PHY_CLOCK_STABLE)
> +			break;
> +		mdelay(DW_PHY_EQ_SLEEP_TIME_CDR);
> +	}
> +
> +	if (i == DW_PHY_EQ_WAIT_TIME_START) {
> +		dev_dbg(dw_dev->dev, "PHY start conditions not achieved\n");

not error?

> +		return -ETIMEDOUT;
> +	}
> +
> +	if (main_fsm_status & DW_PHY_PLL_RATE_BIT1) {
> +		dev_dbg(dw_dev->dev, "invalid pll rate\n");

error?

> +		return -EINVAL;
> +	}
> +
> +	val = dw_phy_read(dw_dev, DW_PHY_CDR_CTRL_CNT) &
> +		DW_PHY_HDMI_MHL_MODE_MASK;

can be single line

> +static void dw_phy_eq_init_vars(struct dw_phy_eq_ch *ch)
> +{
> +	ch->acc = 0;
> +	ch->acq = 0;
> +	ch->last_acq = 0;
> +	ch->valid_long_setting = 0;
> +	ch->valid_short_setting = 0;

memset() ?

> +static bool dw_phy_eq_acquire_early_cnt(struct dw_phy_dev *dw_dev,
> +					u16 setting, u16 acq,
> +					struct dw_phy_eq_ch *ch0,
> +					struct dw_phy_eq_ch *ch1,
> +					struct dw_phy_eq_ch *ch2)
> +{
> +	u16 lock_vector = 0x1 << setting;
> +	unsigned int i;
> +
> +	ch0->out_bound_acq = 0;
> +	ch1->out_bound_acq = 0;
> +	ch2->out_bound_acq = 0;
> +	ch0->acq = 0;
> +	ch1->acq = 0;
> +	ch2->acq = 0;
> +
> +	dw_phy_eq_equal_setting(dw_dev, lock_vector);
> +	dw_phy_eq_auto_calib(dw_dev);
> +
> +	mdelay(DW_PHY_EQ_SLEEP_TIME_CDR);
> +	if (!dw_phy_tmds_valid(dw_dev))
> +		dev_dbg(dw_dev->dev, "TMDS is NOT valid\n");
> +
> +	ch0->read_acq = dw_phy_read(dw_dev, DW_PHY_CH0_EQ_STATUS3);
> +	ch1->read_acq = dw_phy_read(dw_dev, DW_PHY_CH1_EQ_STATUS3);
> +	ch2->read_acq = dw_phy_read(dw_dev, DW_PHY_CH2_EQ_STATUS3);
> +
> +	ch0->acq += ch0->read_acq;
> +	ch1->acq += ch1->read_acq;
> +	ch2->acq += ch2->read_acq;
> +
> +	ch0->upper_bound_acq = ch0->read_acq + DW_PHY_EQ_BOUNDSPREAD;
> +	ch0->lower_bound_acq = ch0->read_acq - DW_PHY_EQ_BOUNDSPREAD;
> +	ch1->upper_bound_acq = ch1->read_acq + DW_PHY_EQ_BOUNDSPREAD;
> +	ch1->lower_bound_acq = ch1->read_acq - DW_PHY_EQ_BOUNDSPREAD;
> +	ch2->upper_bound_acq = ch2->read_acq + DW_PHY_EQ_BOUNDSPREAD;
> +	ch2->lower_bound_acq = ch2->read_acq - DW_PHY_EQ_BOUNDSPREAD;
> +
> +	for (i = 1; i < acq; i++) {

why do we start from 1 here..?

> +static const struct dw_phy_mpll_config dw_phy_e406_mpll_cfg[] = {
> +	{ 0x27, 0x1C94 },
> +	{ 0x28, 0x3713 },
> +	{ 0x29, 0x24DA },
> +	{ 0x2A, 0x5492 },
> +	{ 0x2B, 0x4B0D },
> +	{ 0x2C, 0x4760 },
> +	{ 0x2D, 0x008C },
> +	{ 0x2E, 0x0010 },
> +	{ 0x00, 0x0000 },

lower case here too please

> +static void dw_phy_eq_init_vars(struct dw_phy_eq_ch *ch)
> +{
> +	ch->acc = 0;
> +	ch->acq = 0;
> +	ch->last_acq = 0;
> +	ch->valid_long_setting = 0;
> +	ch->valid_short_setting = 0;
> +	ch->best_setting = DW_PHY_EQ_SHORT_CABLE_SETTING;
> +}

duplicate, it would make sense to create a common lib of such functions
and use them across these files

> +static int dw_phy_set_data(struct dw_phy_dev *dw_dev)
> +{
> +	const struct dw_hdmi_phy_data *of_data;
> +
> +	of_data = of_device_get_match_data(dw_dev->dev);
> +
> +	if (of_data) {
> +		dw_dev->phy_data = (struct dw_hdmi_phy_data *)of_data;
> +	} else if (dw_dev->config->version == dw_phy_e405_data.version) {
> +		dw_dev->phy_data = &dw_phy_e405_data;
> +	} else if (dw_dev->config->version == dw_phy_e406_data.version) {
> +		dw_dev->phy_data = &dw_phy_e406_data;

Driver supports only of, where will these else cases get triggered?

-- 
~Vinod

  reply	other threads:[~2021-06-21  5:53 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02 11:24 [PATCH 0/9] Add Synopsys DesignWare HDMI RX Controller and PHY drivers Nelson Costa
2021-06-02 11:24 ` [PATCH 1/9] dt-bindings: phy: Document Synopsys DesignWare HDMI RX PHYs e405 and e406 Nelson Costa
2021-06-15 23:36   ` Rob Herring
2021-06-02 11:24 ` [PATCH 2/9] dt-bindings: media: Document Synopsys DesignWare HDMI RX Nelson Costa
2021-06-15 23:40   ` Rob Herring
2021-06-16 18:21     ` Nelson Costa
2021-06-02 11:24 ` [PATCH 3/9] MAINTAINERS: Add entry for Synopsys DesignWare HDMI drivers Nelson Costa
2021-06-02 11:24 ` [PATCH 4/9] phy: Add PHY standard HDMI opts to the PHY API Nelson Costa
2021-06-02 11:24 ` [PATCH 5/9] phy: dwc: Add Synopsys DesignWare HDMI RX PHYs e405 and e406 Driver Nelson Costa
2021-06-21  5:53   ` Vinod Koul [this message]
2021-06-23 16:02     ` Nelson Costa
2021-06-02 11:24 ` [PATCH 6/9] media: platform: Add Synopsys DesignWare HDMI RX Controller Driver Nelson Costa
2021-06-02 11:54   ` Hans Verkuil
2021-06-02 15:44     ` Nelson Costa
2021-06-02 17:04       ` Hans Verkuil
2021-06-14 17:03         ` Nelson Costa
2021-06-02 11:24 ` [PATCH 7/9] media: v4l2-dv-timings: Add more CEA/CTA-861 video format timings Nelson Costa
2021-06-02 12:26   ` Hans Verkuil
2021-06-02 17:15     ` Nelson Costa
2021-06-02 18:19       ` Hans Verkuil
2021-06-14 17:04         ` Nelson Costa
2021-06-15  8:39           ` Hans Verkuil
2021-06-15  9:25             ` Nelson Costa
2021-06-02 11:24 ` [PATCH 8/9] media: dwc: dw-hdmi-rx: Add support for Aspect Ratio Nelson Costa
2021-06-02 12:34   ` Hans Verkuil
2021-06-02 17:35     ` Nelson Costa
2021-06-02 11:24 ` [PATCH 9/9] media: dwc: dw-hdmi-rx: Add support for CEC Nelson Costa
2021-06-02 12:45   ` Hans Verkuil
2021-06-02 18:20     ` Nelson Costa
2021-06-02 18:27       ` Hans Verkuil
2021-06-14 17:05         ` Nelson Costa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YNApWS7tNGdWbyCm@vkoul-mobl \
    --to=vkoul@kernel.org \
    --cc=Jose.Abreu@synopsys.com \
    --cc=Nelson.Costa@synopsys.com \
    --cc=devicetree@vger.kernel.org \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=kishon@ti.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.