From patchwork Mon Oct 21 18:05:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Hugo X-Patchwork-Id: 11203109 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3F7DF913 for ; Mon, 21 Oct 2019 22:21:46 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 23F202086D for ; Mon, 21 Oct 2019 22:21:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 23F202086D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3B58C6E29D; Mon, 21 Oct 2019 22:21:44 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id B8021895E7 for ; Mon, 21 Oct 2019 18:05:38 +0000 (UTC) Received: by mail-pf1-x442.google.com with SMTP id b128so8921346pfa.1 for ; Mon, 21 Oct 2019 11:05:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=tcCpwL0onfR06sWsqvX6mF6jQdr+eQVyW0yto6K7hG4=; b=RR4VMrEwjzHs++R8btw7WZW6eJ3aNnXLmuFV6HU7zazaJVIk8AEH9CDCz77kyN6ZrY eVFVa+lM8G2xr9WbZi9EfVpG8Xe7M7FoiRXWvzWtsmlajKB3A58ZQeZVMSKPVQCrnJSh 1cnPf9C8Mk5pUAcZboSowMCiY3fuTcwEujhu48PYO2+vHkOVQ9DUG6N0u55Z4/sg8OS/ 2PQ2A1lYidY35crRKXLRT3vrJJnfDE0sJXq40h6HNnflt4KAlPC+reqfOW6TL/9r6upn sMJnPSnl77AsPAuUZh6HnwDgMknzOVUm7ADQnSAL1uxeB7d5jbP+yKMa/9pnVf5JxEbD R7Eg== X-Gm-Message-State: APjAAAX5zi9nMam+Gpv2ENekoLycQuhQBwy7JWlrVRMrQuRmisMvD5hU aWrXKcfqn6ejomy8ZpEG78k= X-Google-Smtp-Source: APXvYqwShECGrMgtkCZNkbBpxSyUczjEot2rIP9v1Pq9qwXKdamaT6TFjN9i9tI8xzvwNdYjP+hFIA== X-Received: by 2002:a62:ae06:: with SMTP id q6mr24352444pff.96.1571681138284; Mon, 21 Oct 2019 11:05:38 -0700 (PDT) Received: from aw-bldr-10.qualcomm.com (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id b4sm13929276pju.16.2019.10.21.11.05.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 11:05:37 -0700 (PDT) From: Jeffrey Hugo To: a.hajda@samsung.com, narmstrong@baylibre.com, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@siol.net, airlied@linux.ie, daniel@ffwll.ch, bjorn.andersson@linaro.org Subject: [PATCH] drm/bridge: ti-sn65dsi86: Decouple DP output lanes from DSI input lanes Date: Mon, 21 Oct 2019 11:05:32 -0700 Message-Id: <20191021180532.31210-1-jeffrey.l.hugo@gmail.com> X-Mailer: git-send-email 2.17.1 X-Mailman-Approved-At: Mon, 21 Oct 2019 22:21:16 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=tcCpwL0onfR06sWsqvX6mF6jQdr+eQVyW0yto6K7hG4=; b=JYurzqC/VqEbhO/X3sS6Q14PnepMCPoiZ5ZXdzu6bk5bYu5tB0nwyEFf3Zya4K1jp5 RqpNk7QJQQvThq3Utlro5P6uUs2R2uWwYRFPDlFmtgqmboFh9oo1noVBDxfk0vAjNLNC HsIAaGynDWSXQWeBRwtBQQaIJGc8TdmbzmFxNO867q5hrGPNUB6Of6PqbX1etW1fzW3L qojXAc9r70oZX68lQsvFBoS03JHH6WQBaMEl1IoPX2BhpyEX2+Uayv0gUbJc0iwWZkr0 LZ4jDN6ChgAt29dhn7RVuetRAsNkEzSlYpgJfIrUpiCIee45Y4mvku80XdPSGOQKArr0 w4aA== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Jeffrey Hugo MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Based on work by Bjorn Andersson The bridge can be configured to use 1, 2, or 4 DP lanes. This configuration is independent of the input DSI lanes. Right now, the driver assumes that there is 1:1 mapping of input lanes to output lanes which is not correct and does not work for manu devices such as the Lenovo Miix 630 and Lenovo Yoga C630 laptops. Instead, configure the DP output lanes based on the connection information to the panel, if available. Signed-off-by: Jeffrey Hugo --- drivers/gpu/drm/bridge/ti-sn65dsi86.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c index 43abf01ebd4c..1afdc3d5d541 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c @@ -100,6 +100,7 @@ struct ti_sn_bridge { struct drm_panel *panel; struct gpio_desc *enable_gpio; struct regulator_bulk_data supplies[SN_REGULATOR_SUPPLY_NUM]; + int dp_lanes; }; static const struct regmap_range ti_sn_bridge_volatile_ranges[] = { @@ -444,7 +445,7 @@ static void ti_sn_bridge_set_dsi_dp_rate(struct ti_sn_bridge *pdata) regmap_write(pdata->regmap, SN_DSIA_CLK_FREQ_REG, val); /* set DP data rate */ - dp_rate_mhz = ((bit_rate_mhz / pdata->dsi->lanes) * DP_CLK_FUDGE_NUM) / + dp_rate_mhz = ((bit_rate_mhz / pdata->dp_lanes) * DP_CLK_FUDGE_NUM) / DP_CLK_FUDGE_DEN; for (i = 0; i < ARRAY_SIZE(ti_sn_bridge_dp_rate_lut) - 1; i++) if (ti_sn_bridge_dp_rate_lut[i] > dp_rate_mhz) @@ -504,8 +505,8 @@ static void ti_sn_bridge_enable(struct drm_bridge *bridge) regmap_update_bits(pdata->regmap, SN_DSI_LANES_REG, CHA_DSI_LANES_MASK, val); - /* DP lane config */ - val = DP_NUM_LANES(pdata->dsi->lanes - 1); + /* DP lane config - 4 lanes are encoded with the value "3" */ + val = DP_NUM_LANES(pdata->dp_lanes == 4 ? 3 : pdata->dp_lanes); regmap_update_bits(pdata->regmap, SN_SSC_CONFIG_REG, DP_NUM_LANES_MASK, val); @@ -699,7 +700,10 @@ static int ti_sn_bridge_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct ti_sn_bridge *pdata; - int ret; + int ret, len; + struct device_node *endpoint; + struct property *prop; + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { DRM_ERROR("device doesn't support I2C\n"); @@ -727,6 +731,21 @@ static int ti_sn_bridge_probe(struct i2c_client *client, return ret; } + endpoint = of_graph_get_endpoint_by_regs(pdata->dev->of_node, 1, -1); + prop = of_find_property(endpoint, "data-lanes", &len); + if (!prop) { + DRM_DEBUG("failed to find dp lane mapping, using default\n"); + pdata->dp_lanes = 1; + } else { + pdata->dp_lanes = len / sizeof(u32); + if (pdata->dp_lanes < 1 || pdata->dp_lanes > 4 || + pdata->dp_lanes == 3) { + DRM_ERROR("bad number of dp lanes: %d\n", + pdata->dp_lanes); + return -EINVAL; + } + } + dev_set_drvdata(&client->dev, pdata); pdata->enable_gpio = devm_gpiod_get(pdata->dev, "enable",