Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp333332ybj; Mon, 4 May 2020 22:46:41 -0700 (PDT) X-Google-Smtp-Source: APiQypITp0FGg9fCR6OzRfZr5keSzHLqWpn8UKoJwu2LjOqGQidEd2CqBhuea4qVePNSEp+RKQsV X-Received: by 2002:a17:906:7717:: with SMTP id q23mr1217552ejm.38.1588657601617; Mon, 04 May 2020 22:46:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588657601; cv=none; d=google.com; s=arc-20160816; b=Mi9HGLJAaiQL6/uD9f4eqbnzfCcAdDLDo24zLiTf8R/KhgLdtMns8gsVnooN992FDb GJG0lR15bjOzClfKTzrVG3AZn7R3TThVRY1t6s58ziIPY0ohkOSGHYfMOFmPG75OJbib rMW0uFkWWFIcJKV/So+6mNSEEJ4B3UbJdct4u3N9uK25YNxGkdIs83TnOMQqkfsKsKFo dmdUDUmqsoFNWXRhw5/QYKKPUqkUlSwXjBMaRaRbDAv9LHtIc8flN0ogXufBSt9Fvxt2 w7NunkIdDXhHHm3c2BN973zlxeJBngzpGG4+xjI7oSUzvNh/bmhbTnYuNw3cd/uk9+ut LN0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:date:to:cc:from :subject:references:in-reply-to:content-transfer-encoding :mime-version:dkim-signature; bh=OFyVgPW92xjeHjZOe3d3BTj75xEysQbpF9I3kxPup5I=; b=leLt1QDoM5RogdMqC4usIIftIqMQUM7+Mqtcb99AKde4AZSmiw/Nw89Y/uki0P+vod WU21+QwN4T/fBzFsKvsLnGmhDJyU75E+fQpNnnvH4zIpKr7hyjC0837XqCy7anCaDsr2 SezhU+ce0pj0zjQGSmWlgI0GAvDrLGSjlQf7W7P5IZJ1SkhXYMJj71g10tXCE4O4oXJ9 nThCCIEQJvv6grH65Sy/ZiQKXuf9t0KAO9acJ5lhEFSjBpea3rap/wY6f3qiAQK5IkGt bVUqEfhLB1vU9Y4U5+CfZf9GyI28s45mDI2wRVawdmZvJIuHNm7WcoPpYR2ojMFhj8Rk Uvsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=fqcQe4nT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id f6si611651edw.325.2020.05.04.22.46.16; Mon, 04 May 2020 22:46:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=fqcQe4nT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726065AbgEEFoV (ORCPT + 99 others); Tue, 5 May 2020 01:44:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725320AbgEEFoV (ORCPT ); Tue, 5 May 2020 01:44:21 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10555C061A0F for ; Mon, 4 May 2020 22:44:20 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id z6so370386plk.10 for ; Mon, 04 May 2020 22:44:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:content-transfer-encoding:in-reply-to:references :subject:from:cc:to:date:message-id:user-agent; bh=OFyVgPW92xjeHjZOe3d3BTj75xEysQbpF9I3kxPup5I=; b=fqcQe4nTEPPqqUKFm8/irKkoCtCZhv5uz7tbiq6X/lrL0rbErtDlV6Z9fIJnnyHTbb WXKN028/CTSLOnK0pv+DU+ZH1xDdlXzRTO0xHKOYyaPVcyLAmhwH7TLcqE+vzRbU65K9 /vOyhR7ZIDYOv8AzmWW2hfJjjb5ukdnp6PLbA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:content-transfer-encoding :in-reply-to:references:subject:from:cc:to:date:message-id :user-agent; bh=OFyVgPW92xjeHjZOe3d3BTj75xEysQbpF9I3kxPup5I=; b=MCDtx8GnLUwD0wd2mTRzb0avkqMrnAP9wIhRZ4EqkQRiEShEtVkL7zzWmNEZhuoq6V l81VPVdczogAZdXnG6BfmPBD8VyrAkqpbzxp+0UGb9LANIogFg0rprWlzefagz51Whts A2FwkmcW7jC+QkDWKTr1+sJYu8D8oelmTaux/ZCFh97m9Cid6bksx2qA2RmvMUYcJFLL ZmLtzY679xQHbTTaR35V1dQbHJ0pBSS4aSp6rhnF6V3/spGuo9SXl1mwT62+SsBqKtr/ vdiy8NGj2yEHfVEH/O3SPBsU79RaI0k1RVWrdtuTxNwnJIVZXv/WwkEseNoAlkgB+sNd 9fLQ== X-Gm-Message-State: AGi0PuawJjUIAzyjSiAUyAWVOWVvvy08PMaq2f2JJ+OQGLGkx0RJHZK6 ukC2KBw17+Bpisi6jNzB6Pm6Pg== X-Received: by 2002:a17:902:8641:: with SMTP id y1mr1649408plt.14.1588657459376; Mon, 04 May 2020 22:44:19 -0700 (PDT) Received: from chromium.org ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id b29sm862082pfp.68.2020.05.04.22.44.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2020 22:44:18 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20200504213624.1.Ibc8eeddcee94984a608d6900b46f9ffde4045da4@changeid> References: <20200504213624.1.Ibc8eeddcee94984a608d6900b46f9ffde4045da4@changeid> Subject: Re: [PATCH] drm/bridge: ti-sn65dsi86: Implement lane reordering + polarity From: Stephen Boyd Cc: robdclark@chromium.org, seanpaul@chromium.org, linux-arm-msm@vger.kernel.org, Douglas Anderson , Daniel Vetter , David Airlie , Jernej Skrabec , Jonas Karlman , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org To: Andrzej Hajda , Douglas Anderson , Laurent Pinchart , Neil Armstrong Date: Mon, 04 May 2020 22:44:17 -0700 Message-ID: <158865745768.11125.12003632060774071567@swboyd.mtv.corp.google.com> User-Agent: alot/0.9 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Douglas Anderson (2020-05-04 21:36:31) > The ti-sn65dsi86 MIPI DSI to eDP bridge chip supports arbitrary > remapping of eDP lanes and also polarity inversion. Both of these > features have been described in the device tree bindings for the > device since the beginning but were never implemented in the driver. > Implement both of them. >=20 > Part of this change also allows you to (via the same device tree > bindings) specify to use fewer than the max number of DP lanes that > the panel reports. This could be useful if your display supports more > lanes but only a few are hooked up on your board. >=20 > Signed-off-by: Douglas Anderson > --- Except for one thing below: Reviewed-by: Stephen Boyd > diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/brid= ge/ti-sn65dsi86.c > index 1a125423eb07..52cca54b525f 100644 > --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c > +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c > @@ -707,26 +716,20 @@ static void ti_sn_bridge_enable(struct drm_bridge *= bridge) > int dp_rate_idx; > unsigned int val; > int ret =3D -EINVAL; > + int max_dp_lanes; > =20 > - /* > - * Run with the maximum number of lanes that the DP sink supports. > - * > - * Depending use cases, we might want to revisit this later becau= se: > - * - It's plausible that someone may have run fewer lines to the > - * sink than the sink actually supports, assuming that the lines > - * will just be driven at a higher rate. > - * - The DP spec seems to indicate that it's more important to mi= nimize > - * the number of lanes than the link rate. > - * > - * If we do revisit, it would be important to measure the power i= mpact. > - */ > - pdata->dp_lanes =3D ti_sn_get_max_lanes(pdata); > + max_dp_lanes =3D ti_sn_get_max_lanes(pdata); > + pdata->dp_lanes =3D min(pdata->dp_lanes, max_dp_lanes); > =20 > /* DSI_A lane config */ > val =3D CHA_DSI_LANES(4 - pdata->dsi->lanes); Not a problem in this patch, but maybe this can be SN_MAX_DP_LANES - pdata->dsi->lanes now. > regmap_update_bits(pdata->regmap, SN_DSI_LANES_REG, > CHA_DSI_LANES_MASK, val); > =20 > + regmap_write(pdata->regmap, SN_LN_ASSIGN_REG, pdata->ln_assign); > + regmap_update_bits(pdata->regmap, SN_ENH_FRAME_REG, LN_POLRS_MASK, > + pdata->ln_polrs << LN_POLRS_OFFSET); > + > /* set dsi clk frequency value */ > ti_sn_bridge_set_dsi_rate(pdata); > =20 > @@ -1063,6 +1066,50 @@ static int ti_sn_setup_gpio_controller(struct ti_s= n_bridge *pdata) > return ret; > } > =20 > +static void ti_sn_bridge_parse_lanes(struct ti_sn_bridge *pdata, > + struct device_node *np) > +{ > + u32 lane_assignments[SN_MAX_DP_LANES] =3D { 0, 1, 2, 3 }; > + u32 lane_polarities[SN_MAX_DP_LANES] =3D { }; > + struct device_node *endpoint; > + u8 ln_assign =3D 0; > + u8 ln_polrs =3D 0; Do we need to assign to 0 to start? Seems like no? > + int dp_lanes; > + int i; > + > + /* > + * Read config from the device tree about lane remapping and lane > + * polarities. These are optional and we assume identity map and > + * normal polarity if nothing is specified. It's OK to specify j= ust > + * data-lanes but not lane-polarities but not vice versa. > + */ > + endpoint =3D of_graph_get_endpoint_by_regs(np, 1, -1); > + dp_lanes =3D of_property_count_u32_elems(endpoint, "data-lanes"); > + if (dp_lanes > 0) { > + of_property_read_u32_array(endpoint, "data-lanes", > + lane_assignments, dp_lanes); > + of_property_read_u32_array(endpoint, "lane-polarities", > + lane_polarities, dp_lanes); > + } else { > + dp_lanes =3D SN_MAX_DP_LANES; > + } Needs an of_node_put(endpoint) here for the of_graph_get_endpoint_by_regs() above. > + > + /* > + * Convert into register format. Loop over all lanes even if > + * data-lanes had fewer elements so that we nicely initialize > + * the LN_ASSIGN register. > + */ > + for (i =3D SN_MAX_DP_LANES - 1; i >=3D 0; i--) { > + ln_assign =3D ln_assign << LN_ASSIGN_WIDTH | lane_assignm= ents[i]; > + ln_polrs =3D ln_polrs << 1 | lane_polarities[i]; > + } > + > + /* Stash in our struct for when we power on */ > + pdata->dp_lanes =3D dp_lanes; > + pdata->ln_assign =3D ln_assign; > + pdata->ln_polrs =3D ln_polrs; > +}