Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4325256ybl; Mon, 3 Feb 2020 16:53:17 -0800 (PST) X-Google-Smtp-Source: APXvYqx92oWXir66fZvgHvRAUPb1P1fN6nTigxkeBb4NJZlONs3oTWri/oVHiPaNBOy2wcLVQZNM X-Received: by 2002:aca:be57:: with SMTP id o84mr1466612oif.138.1580777597136; Mon, 03 Feb 2020 16:53:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580777597; cv=none; d=google.com; s=arc-20160816; b=v+m7uZGJ84soKfI4zxhd/9oL78hOHqittQ/Vagetk4ikJQx+6O02SVhK1zE6HniN/7 0tewYlIbptN1n09CGhPy9TSiYnX5nZWNgppnRSUtGi4iuhCEO8vkMDrjHCv4vTRK2YM5 g2cZGhYU4Klw8NkI9P4jQ2sK/jUVn6+8iQYFn3Ouut9Bo4CXkN5eGELKfAJt1VXOodLk fycoSYk/0r7dzCpWTkIkFHIiYU/dyzC0KCn6Y8MuUmbuRM0UxzsiJeFFB9gT+od/yuAb boL86xVFHR/Jv83DGxJmxLNRjPJ+20nQGtt6OKqL6Hzv3pCRrvdUV0rDpPEh9eTy3TB0 vM9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:user-agent:cc:subject:to:from :references:in-reply-to:content-transfer-encoding:mime-version :message-id:dkim-signature; bh=hcIePRtjEpO0TZ9jpC5LlD4R/lpZZZ3BibuM5fjf+D8=; b=kiMghbAWkJsW8QqI+X8JaCflhaJxtGRtNLNaM8PRxJ/K0K5O6J8uTK25ciuy21dUQz b9uFrnrkzOIJHSAZ6YbZ5JWrOElQ+WH1QF5vxtmopJ7jkdxkmCGAwF9XDeGv0ScxcLSy kQOjeoiDPFmxJVKKVKVVsHNb6YIRPTBCM2JamqUZLhLmX7qM4z6EmXTLsXLZBo/5Kjmn VFj0V8gc5k6lljo9pH6RBoMyTHuMzwVmVqH8DRThfvRnUrl+X4rueYyhhl0uHckZM+mi gBxUX/OGBPTiOyYtFbj088rT36Vndw+/fkNF9GFzZxEOWGjcuAH5vkfOmoKNZyrvSpXd 8EKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Wd7mzS76; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l15si8525508oic.220.2020.02.03.16.53.03; Mon, 03 Feb 2020 16:53:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Wd7mzS76; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726992AbgBDAwJ (ORCPT + 99 others); Mon, 3 Feb 2020 19:52:09 -0500 Received: from mail-pl1-f171.google.com ([209.85.214.171]:46948 "EHLO mail-pl1-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726369AbgBDAwI (ORCPT ); Mon, 3 Feb 2020 19:52:08 -0500 Received: by mail-pl1-f171.google.com with SMTP id y8so6513965pll.13 for ; Mon, 03 Feb 2020 16:52:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=message-id:mime-version:content-transfer-encoding:in-reply-to :references:from:to:subject:cc:user-agent:date; bh=hcIePRtjEpO0TZ9jpC5LlD4R/lpZZZ3BibuM5fjf+D8=; b=Wd7mzS76ljQ/4qpb1siNkBg4U0iNC8Flv4k2iIn7K7CX6OYPrVh+iypR8nVmEpBhCV 2fa2RhLn4FsSP7mNmro9wArlkyph4AMAVVjj5S3RZgsK1ZsQFdONdfCDj+qsOUesrGxu 94HRhQlbXJBpAwNFkv65dUXbSIG69xmiBmVXs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:mime-version :content-transfer-encoding:in-reply-to:references:from:to:subject:cc :user-agent:date; bh=hcIePRtjEpO0TZ9jpC5LlD4R/lpZZZ3BibuM5fjf+D8=; b=aV7jU9niLfx4hYbfOTGfXOM1BAUIH5bvvSl9Opx7QdEnCwxGZTU3LkupzHamsChJLv soET4Q2Mfu/dAl2BUsToofa3tI2xKoGo7G+aVnF5yllLSKX7enteAE/72xqNle2M7TRN RaTiQLDfQZx1NEIoh1c4gP8oQokclgHPsC+9qBErxEC7jdj3bgJek8y9lfJqDiTtqLrK mUMkFhs/Hw5Quwjw3xXT7uJ2Q/shlGgMkIinZsCUDtGS2caA2wNHXa5HnuBmGRgRl3j+ /GRjiUtmVc/zsELEvK/5CuDkgwhcBxV9KOhQiCA+eWsoyr70ci3dZrOpEIsunUkyX+vl IbUw== X-Gm-Message-State: APjAAAV06N2MQURPz/tIISuvp0Mp4DGd6kYHNsAKT4v3oEbjZmchXGrX 48mhNmVekaRHgjma/hgU//xaHA== X-Received: by 2002:a17:90a:d986:: with SMTP id d6mr2438594pjv.78.1580777527487; Mon, 03 Feb 2020 16:52:07 -0800 (PST) Received: from chromium.org ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id y23sm21626086pfn.101.2020.02.03.16.52.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 16:52:06 -0800 (PST) Message-ID: <5e38c036.1c69fb81.3da87.c53d@mx.google.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <1580305919-30946-6-git-send-email-sanm@codeaurora.org> References: <1580305919-30946-1-git-send-email-sanm@codeaurora.org> <1580305919-30946-6-git-send-email-sanm@codeaurora.org> From: Stephen Boyd To: Andy Gross , Bjorn Andersson , Doug Anderson , Kishon Vijay Abraham I , Mark Rutland , Matthias Kaehlcke , Rob Herring , Sandeep Maheswaram Subject: Re: [PATCH v4 5/8] phy: qcom-qusb2: Add support for overriding tuning parameters in QUSB2 V2 PHY Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Sandeep Maheswaram User-Agent: alot/0.8.1 Date: Mon, 03 Feb 2020 16:52:05 -0800 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Sandeep Maheswaram (2020-01-29 05:51:56) > @@ -277,6 +289,34 @@ static const char * const qusb2_phy_vreg_names[] =3D= { > =20 > #define QUSB2_NUM_VREGS ARRAY_SIZE(qusb2_phy_vreg_names) > =20 > +/* struct override_param - structure holding qusb2 v2 phy overriding par= am > + * set override true if the device tree property exists and read and as= sign > + * to value > + */ > +struct override_param { > + bool override; > + u8 value; > +}; > + > +/*struct override_params - structure holding qusb2 v2 phy overriding par= ams > + * @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 qu= sb2_phy *qphy) > @@ -421,6 +459,11 @@ static void qusb2_phy_override_phy_params(struct qus= b2_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_TUNE= 2], > + qphy->overrides.hsdisc_trim.value << HSDISC_TRIM_SHIFT, > + HSDISC_TRIM_MASK); > } > =20 > /* > @@ -864,26 +907,44 @@ static int qusb2_phy_probe(struct platform_device *= pdev) > =20 [...] > if (!of_property_read_u32(dev->of_node, "qcom,preemphasis-width", > &value)) { > - qphy->preemphasis_width =3D (u8)value; > - qphy->override_preemphasis_width =3D true; > + qphy->overrides.preemphasis_width.value =3D (u8)value; > + qphy->overrides.preemphasis_width.override =3D true; > + } > + > + if (!of_property_read_u32(dev->of_node, "qcom,hsdisc-trim-value", > + &value)) { > + qphy->overrides.hsdisc_trim.value =3D (u8)value; > + qphy->overrides.hsdisc_trim.override =3D true; > } > =20 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[] =3D { [HSDISC_TRIM_VALUE] =3D "qcom,hsdisc-trim-value", [PREEMP_WIDTH] =3D ... }; that we then link to another array inside qphy named overrides: =09 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.