linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <swboyd@chromium.org>
To: Andy Gross <agross@kernel.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Doug Anderson <dianders@chromium.org>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Matthias Kaehlcke <mka@chromium.org>,
	Rob Herring <robh+dt@kernel.org>,
	Sandeep Maheswaram <sanm@codeaurora.org>
Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org,
	Sandeep Maheswaram <sanm@codeaurora.org>
Subject: Re: [PATCH v4 5/8] phy: qcom-qusb2: Add support for overriding tuning parameters in QUSB2 V2 PHY
Date: Mon, 03 Feb 2020 16:52:05 -0800	[thread overview]
Message-ID: <5e38c036.1c69fb81.3da87.c53d@mx.google.com> (raw)
In-Reply-To: <1580305919-30946-6-git-send-email-sanm@codeaurora.org>

Quoting Sandeep Maheswaram (2020-01-29 05:51:56)
> @@ -277,6 +289,34 @@ static const char * const qusb2_phy_vreg_names[] = {
>  
>  #define QUSB2_NUM_VREGS                ARRAY_SIZE(qusb2_phy_vreg_names)
>  
> +/* struct override_param - structure holding qusb2 v2 phy overriding param
> + * set override true if the  device tree property exists and read and assign
> + * to value
> + */
> +struct override_param {
> +       bool override;
> +       u8 value;
> +};
> +
> +/*struct override_params - structure holding qusb2 v2 phy overriding params
> + * @imp_res_offset: rescode offset to be updated in IMP_CTRL1 register
> + * @hstx_trim: HSTX_TRIM to be updated in TUNE1 register
> + * @preemphasis: Amplitude Pre-Emphasis to be updated in TUNE1 register
> + * @preemphasis_width: half/full-width Pre-Emphasis updated via TUNE1
> + * @bias_ctrl: bias ctrl to be updated in BIAS_CONTROL_2 register
> + * @charge_ctrl: charge ctrl to be updated in CHG_CTRL2 register
> + * @hsdisc_trim: disconnect threshold to be updated in TUNE2 register
> + */
> +struct override_params {
> +       struct override_param imp_res_offset;
> +       struct override_param hstx_trim;
> +       struct override_param preemphasis;
> +       struct override_param preemphasis_width;
> +       struct override_param bias_ctrl;
> +       struct override_param charge_ctrl;
> +       struct override_param hsdisc_trim;
> +};
> +
>  /**
>   * struct qusb2_phy - structure holding qusb2 phy attributes
>   *
> @@ -395,23 +423,33 @@ static void qusb2_phy_override_phy_params(struct qusb2_phy *qphy)
> @@ -421,6 +459,11 @@ static void qusb2_phy_override_phy_params(struct qusb2_phy *qphy)
>                                       cfg->regs[QUSB2PHY_PORT_TUNE1],
>                                       PREEMPH_WIDTH_HALF_BIT);
>         }
> +
> +       if (qphy->overrides.hsdisc_trim.override)
> +               qusb2_write_mask(qphy->base, cfg->regs[QUSB2PHY_PORT_TUNE2],
> +               qphy->overrides.hsdisc_trim.value << HSDISC_TRIM_SHIFT,
> +                                HSDISC_TRIM_MASK);
>  }
>  
>  /*
> @@ -864,26 +907,44 @@ static int qusb2_phy_probe(struct platform_device *pdev)
>  
[...]
>         if (!of_property_read_u32(dev->of_node, "qcom,preemphasis-width",
>                                      &value)) {
> -               qphy->preemphasis_width = (u8)value;
> -               qphy->override_preemphasis_width = true;
> +               qphy->overrides.preemphasis_width.value = (u8)value;
> +               qphy->overrides.preemphasis_width.override = true;
> +       }
> +
> +       if (!of_property_read_u32(dev->of_node, "qcom,hsdisc-trim-value",
> +                                 &value)) {
> +               qphy->overrides.hsdisc_trim.value = (u8)value;
> +               qphy->overrides.hsdisc_trim.override = true;
>         }
>  

Is it possible to make a local array that we can crank through the
overrides with? If they're all u8 values maybe we can have an array like

	const char * const char override_names[] = {
		[HSDISC_TRIM_VALUE] = "qcom,hsdisc-trim-value",
		[PREEMP_WIDTH] = ...
	};

that we then link to another array inside qphy named overrides:
	
	struct override_param overrides[NUM_OVERRIDES];

and then we can bounce from overrides to override_names to parse out the
random u8 values from the DT node. The idea is to avoid "wasting"
pointers to the name when we don't care after parsing it. It may not be
any different vs. just having a const char *name in the override_paramt
struct though, so please measure it.

Also, why not  use of_property_read_u8() and make DT writers have

	/bits/ 8 <0xf0>

properties so that we can keep things smaller. I don't understand why
they're u32 in DT besides to make it simpler to specify a u32.


  parent reply	other threads:[~2020-02-04  0:52 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-29 13:51 [PATCH v4 0/8] Add QUSB2 PHY support for SC7180 Sandeep Maheswaram
2020-01-29 13:51 ` [PATCH v4 1/8] dt-bindings: phy: qcom,qusb2: Convert QUSB2 phy bindings to yaml Sandeep Maheswaram
2020-01-29 20:08   ` Matthias Kaehlcke
2020-01-29 20:28   ` Matthias Kaehlcke
2020-01-29 20:57     ` Matthias Kaehlcke
2020-02-04  0:39   ` Stephen Boyd
2020-02-06 17:28   ` Rob Herring
2020-01-29 13:51 ` [PATCH v4 2/8] dt-bindings: phy: qcom,qusb2: Add compatibles for QUSB2 V2 phy and SC7180 Sandeep Maheswaram
2020-01-29 20:58   ` Matthias Kaehlcke
2020-02-04  0:39   ` Stephen Boyd
2020-02-06 17:34   ` Rob Herring
2020-01-29 13:51 ` [PATCH v4 3/8] phy: qcom-qusb2: Add generic QUSB2 V2 PHY support Sandeep Maheswaram
2020-01-29 20:31   ` Matthias Kaehlcke
2020-02-04  0:39   ` Stephen Boyd
2020-01-29 13:51 ` [PATCH v4 4/8] dt-bindings: phy: qcom-qusb2: Add support for overriding Phy tuning parameters Sandeep Maheswaram
2020-01-29 20:38   ` Matthias Kaehlcke
2020-02-04  0:41     ` Stephen Boyd
2020-01-29 13:51 ` [PATCH v4 5/8] phy: qcom-qusb2: Add support for overriding tuning parameters in QUSB2 V2 PHY Sandeep Maheswaram
2020-01-29 20:54   ` Matthias Kaehlcke
2020-02-04  0:52   ` Stephen Boyd [this message]
2020-02-04 17:24     ` Doug Anderson
2020-01-29 13:51 ` [PATCH v4 6/8] arm64: dts: qcom: sc7180: Add generic QUSB2 V2 Phy compatible Sandeep Maheswaram
2020-01-29 21:34   ` Matthias Kaehlcke
2020-02-04  0:52   ` Stephen Boyd
2020-01-29 13:51 ` [PATCH v4 7/8] arm64: dts: qcom: sdm845: " Sandeep Maheswaram
2020-01-29 21:35   ` Matthias Kaehlcke
2020-02-04  0:52   ` Stephen Boyd
2020-01-29 13:51 ` [PATCH v4 8/8] arm64: dts: qcom: sc7180: Update QUSB2 V2 Phy params for SC7180 IDP device Sandeep Maheswaram
2020-02-04  0:52   ` Stephen Boyd
2020-02-04  0:53   ` Stephen Boyd
2020-02-04 17:02     ` Doug Anderson
2020-02-03 18:56 ` [PATCH v4 0/8] Add QUSB2 PHY support for SC7180 Bjorn Andersson
2020-03-05 18:51   ` Matthias Kaehlcke
2020-03-06 11:21     ` Sandeep Maheswaram (Temp)

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=5e38c036.1c69fb81.3da87.c53d@mx.google.com \
    --to=swboyd@chromium.org \
    --cc=agross@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dianders@chromium.org \
    --cc=kishon@ti.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mka@chromium.org \
    --cc=robh+dt@kernel.org \
    --cc=sanm@codeaurora.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).