From patchwork Tue Mar 7 13:01:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 65477 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2426352wrd; Tue, 7 Mar 2023 05:23:53 -0800 (PST) X-Google-Smtp-Source: AK7set8/Nm5yYUXr/JuPy4jaX1mqfQ5N4LDG1gKhLLO9Ryg0jJbTU64hI7eCc0+bREfdK5wOXA5D X-Received: by 2002:aa7:95a8:0:b0:5a8:5e6d:28d7 with SMTP id a8-20020aa795a8000000b005a85e6d28d7mr11803348pfk.0.1678195432869; Tue, 07 Mar 2023 05:23:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678195432; cv=none; d=google.com; s=arc-20160816; b=q8esDMVYCurb8BxLdRryRe5vFmLr/3F/b/O0UmxJ5Jei3KuwzVCWC7iJU9mF8696Br f96t1mCByld4HRh6FDpgu3/fDWN4knycRN4YTecm7BKSx1j3Jht0LSkrxlTxS8KTt3nf dthEOHckx+qwyggT71er217xT+4/HueZ1dr1hZz1JM9/oxGh89eB0Z8wXhDkyR40t9jd l12c/K3nFPAzZJxLG6+jPzg4QDcNbca1i+whBxVmwxAeRNI9z9+8UsFAjsOZfpZ1mENp uKPQetmDMWCJX4jKcw6NBUoXKFaxG/h0oopsV80sQpynSupL/bW5tk/ULU6B0PPZVG/P oGIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=tKiXCG4bbxlqg4TZuhn1lShaquHQ+BPuyW0xhFs0ICg=; b=1GhrH3hEHNz0nUEpqIRdfiRg9T6o1iIabPMm3Hko5yWP9mcQ6NA/7sl3aGmkjeHivM y6pelqcVb46yMGbV/n6hWfPLz80+6G9dtTOeLYae0YZuSHU9wGQMiSeAm57tkXI05Yif 7xGAUX/B9pkJvbj8WOJgKoHAJ9jL//IhgjIG6Jw9PubysJvC0PXFSnTcubLF1+sZbWeL TrtGA1/biKbKnQivWfwWh/nYwvzLhjocQEpdqU2R7bldfQb2qsX16m1MZwV0PDejMaWl tphoZppnyfUVDlXM/thUSOXALIvwaQcxquhjdCvUN559vKKN3jtDMUdAe5SAfX3W3sUV 9PUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tZaZP0Fy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x38-20020a634a26000000b004c76dcc99c2si12176217pga.334.2023.03.07.05.23.39; Tue, 07 Mar 2023 05:23:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tZaZP0Fy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230030AbjCGNCC (ORCPT + 99 others); Tue, 7 Mar 2023 08:02:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229897AbjCGNBu (ORCPT ); Tue, 7 Mar 2023 08:01:50 -0500 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34314C15F for ; Tue, 7 Mar 2023 05:01:48 -0800 (PST) Received: by mail-lf1-x12e.google.com with SMTP id d36so13799055lfv.8 for ; Tue, 07 Mar 2023 05:01:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678194106; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=tKiXCG4bbxlqg4TZuhn1lShaquHQ+BPuyW0xhFs0ICg=; b=tZaZP0FyqV0gNReyC679bi8CT0Th0omgS+EoRTEnAD3riOmZsa+mcSjJyqcfkWH4Ao IvJ9m82jdcjokfNRv3cT+rqdJ1o/OZlV7d669NyXq8esHk+jllnLcGB4khEBa00+gMda +t8fPDutFT07fVECMCXLY48Rzqg/1ut1axARViYSSCqAn+cDA7uhmo1mKuT3WGhlMHIk bAu5VC8ChDxF2CdoshgXTrGAxGDLm/HZ7R+9+RWPRRZfVAkuTPo4fUFdLpnVkpFHqYYH B8gUOLGDThhN/UzwJyYf3TIukCW1XxPeqaMai/ZeYJk9K1OLINUAW5Zpu/wTj6hh+j+t uV7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678194106; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tKiXCG4bbxlqg4TZuhn1lShaquHQ+BPuyW0xhFs0ICg=; b=sQBMRTNk0xIJuuc3MNiWQUW+EFM35smpmsBlu3hkwnWKmkO9stfRsXc72AhhGO3ROc sKGjKaATcsmGUGIbHYiiqeAseRxm4EuIKA/7if4aWQ5M2hGOVKDkv5mAymFrdhpsSSD5 9jnwXpTvRlTDOrdj1Ie6bPZ6uic1v0ZDj0fNa2bue2DwT1nYy5duMJg2uKKsvMImE/bW YJLebJ19+FWgAl4QAW6gndevnhslFkqDRpqP19lE5CO9w+UZ+wFM3tIqdgwEbBlWH8N3 WMotj406VIS4ZAx9wAFKFVWnHe/rDwFYMxw4JIvxhSNvnAei3CGMm4CVgG8edGpsxV// RncQ== X-Gm-Message-State: AO0yUKXjCnf4jTeoTGFou90jXVNc5N7UWX7nYQ/Jv3AQHbNrcDSpNB7w S5XyylJZH0YwphW3FU7E4T7tuQ== X-Received: by 2002:a19:5212:0:b0:4d5:a0d2:f542 with SMTP id m18-20020a195212000000b004d5a0d2f542mr4223293lfb.18.1678194106320; Tue, 07 Mar 2023 05:01:46 -0800 (PST) Received: from [192.168.1.101] (abyj16.neoplus.adsl.tpnet.pl. [83.9.29.16]) by smtp.gmail.com with ESMTPSA id u2-20020ac248a2000000b004cc5e97d356sm2048265lfg.148.2023.03.07.05.01.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 05:01:46 -0800 (PST) From: Konrad Dybcio Date: Tue, 07 Mar 2023 14:01:41 +0100 Subject: [PATCH v3 03/10] drm/msm/dsi: Fix DSI index detection when version clash occurs MIME-Version: 1.0 Message-Id: <20230307-topic-dsi_qcm-v3-3-8bd7e1add38a@linaro.org> References: <20230307-topic-dsi_qcm-v3-0-8bd7e1add38a@linaro.org> In-Reply-To: <20230307-topic-dsi_qcm-v3-0-8bd7e1add38a@linaro.org> To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Krishna Manikandan , Bryan O'Donoghue , Andy Gross , Bjorn Andersson Cc: Rob Herring , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Dybcio X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1678194100; l=8155; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=CgPPBWXxtg/cf0U+pXW2+cQoa7CuqDjjXQcr9orrQS4=; b=qXiUBICAvOwDvzHakzzS9oTY5TbLxWE4fBJrqxuJMvESTctvtTtRBrZD/bUOi1pHRYNJd0udFTwB iSLiiAU/B0xoMvN7kRKd+BKOoP3lsU6zQk4WmZx2hTiUiKxm+WWr X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_HTTP,RCVD_IN_SORBS_SOCKS,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759715453803603147?= X-GMAIL-MSGID: =?utf-8?q?1759715453803603147?= Currently, we allow for MAX_DSI entries in io_start to facilitate for MAX_DSI number of DSI hosts at different addresses. The configuration is matched against the DSI CTRL hardware revision read back from the component. We need a way to resolve situations where multiple SoCs with different register maps may use the same version of DSI CTRL. In preparation to do so, make msm_dsi_config a 2d array where each entry represents a set of configurations adequate for a given SoC. This is totally fine to do, as the only differentiating factors between same-version-different-SoCs configurations are the number of DSI hosts (1 or 2, at least as of today) and the set of base registers. The regulator setup is the same, because the DSI hardware is the same, regardless of the SoC it was implemented in. In addition to that, update the matching logic such that it will loop over VARIANTS_MAX variants, making sure they are all taken into account. Reviewed-by: Dmitry Baryshkov Signed-off-by: Konrad Dybcio Reviewed-by: Marijn Suijten --- drivers/gpu/drm/msm/dsi/dsi_cfg.c | 52 ++++++++++++++++++++++++++++---------- drivers/gpu/drm/msm/dsi/dsi_cfg.h | 5 +++- drivers/gpu/drm/msm/dsi/dsi_host.c | 10 ++++---- 3 files changed, 48 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.c b/drivers/gpu/drm/msm/dsi/dsi_cfg.c index 4515f52b407a..6c192963c100 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_cfg.c +++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.c @@ -21,7 +21,9 @@ static const struct msm_dsi_config apq8064_dsi_cfg = { .num_regulators = ARRAY_SIZE(apq8064_dsi_regulators), .bus_clk_names = dsi_v2_bus_clk_names, .num_bus_clks = ARRAY_SIZE(dsi_v2_bus_clk_names), - .io_start = { 0x4700000, 0x5800000 }, + .io_start = { + { 0x4700000, 0x5800000 }, + }, }; static const char * const dsi_6g_bus_clk_names[] = { @@ -40,7 +42,9 @@ static const struct msm_dsi_config msm8974_apq8084_dsi_cfg = { .num_regulators = ARRAY_SIZE(msm8974_apq8084_regulators), .bus_clk_names = dsi_6g_bus_clk_names, .num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names), - .io_start = { 0xfd922800, 0xfd922b00 }, + .io_start = { + { 0xfd922800, 0xfd922b00 }, + }, }; static const char * const dsi_8916_bus_clk_names[] = { @@ -58,7 +62,9 @@ static const struct msm_dsi_config msm8916_dsi_cfg = { .num_regulators = ARRAY_SIZE(msm8916_dsi_regulators), .bus_clk_names = dsi_8916_bus_clk_names, .num_bus_clks = ARRAY_SIZE(dsi_8916_bus_clk_names), - .io_start = { 0x1a98000 }, + .io_start = { + { 0x1a98000 }, + }, }; static const char * const dsi_8976_bus_clk_names[] = { @@ -76,7 +82,9 @@ static const struct msm_dsi_config msm8976_dsi_cfg = { .num_regulators = ARRAY_SIZE(msm8976_dsi_regulators), .bus_clk_names = dsi_8976_bus_clk_names, .num_bus_clks = ARRAY_SIZE(dsi_8976_bus_clk_names), - .io_start = { 0x1a94000, 0x1a96000 }, + .io_start = { + { 0x1a94000, 0x1a96000 }, + }, }; static const struct regulator_bulk_data msm8994_dsi_regulators[] = { @@ -94,7 +102,9 @@ static const struct msm_dsi_config msm8994_dsi_cfg = { .num_regulators = ARRAY_SIZE(msm8994_dsi_regulators), .bus_clk_names = dsi_6g_bus_clk_names, .num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names), - .io_start = { 0xfd998000, 0xfd9a0000 }, + .io_start = { + { 0xfd998000, 0xfd9a0000 }, + }, }; static const char * const dsi_8996_bus_clk_names[] = { @@ -113,7 +123,9 @@ static const struct msm_dsi_config msm8996_dsi_cfg = { .num_regulators = ARRAY_SIZE(msm8996_dsi_regulators), .bus_clk_names = dsi_8996_bus_clk_names, .num_bus_clks = ARRAY_SIZE(dsi_8996_bus_clk_names), - .io_start = { 0x994000, 0x996000 }, + .io_start = { + { 0x994000, 0x996000 }, + }, }; static const char * const dsi_msm8998_bus_clk_names[] = { @@ -131,7 +143,9 @@ static const struct msm_dsi_config msm8998_dsi_cfg = { .num_regulators = ARRAY_SIZE(msm8998_dsi_regulators), .bus_clk_names = dsi_msm8998_bus_clk_names, .num_bus_clks = ARRAY_SIZE(dsi_msm8998_bus_clk_names), - .io_start = { 0xc994000, 0xc996000 }, + .io_start = { + { 0xc994000, 0xc996000 }, + }, }; static const char * const dsi_sdm660_bus_clk_names[] = { @@ -148,7 +162,9 @@ static const struct msm_dsi_config sdm660_dsi_cfg = { .num_regulators = ARRAY_SIZE(sdm660_dsi_regulators), .bus_clk_names = dsi_sdm660_bus_clk_names, .num_bus_clks = ARRAY_SIZE(dsi_sdm660_bus_clk_names), - .io_start = { 0xc994000, 0xc996000 }, + .io_start = { + { 0xc994000, 0xc996000 }, + }, }; static const char * const dsi_sdm845_bus_clk_names[] = { @@ -169,7 +185,9 @@ static const struct msm_dsi_config sdm845_dsi_cfg = { .num_regulators = ARRAY_SIZE(sdm845_dsi_regulators), .bus_clk_names = dsi_sdm845_bus_clk_names, .num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names), - .io_start = { 0xae94000, 0xae96000 }, + .io_start = { + { 0xae94000, 0xae96000 }, + }, }; static const struct regulator_bulk_data sm8550_dsi_regulators[] = { @@ -182,7 +200,9 @@ static const struct msm_dsi_config sm8550_dsi_cfg = { .num_regulators = ARRAY_SIZE(sm8550_dsi_regulators), .bus_clk_names = dsi_sdm845_bus_clk_names, .num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names), - .io_start = { 0xae94000, 0xae96000 }, + .io_start = { + { 0xae94000, 0xae96000 }, + }, }; static const struct regulator_bulk_data sc7180_dsi_regulators[] = { @@ -195,7 +215,9 @@ static const struct msm_dsi_config sc7180_dsi_cfg = { .num_regulators = ARRAY_SIZE(sc7180_dsi_regulators), .bus_clk_names = dsi_sc7180_bus_clk_names, .num_bus_clks = ARRAY_SIZE(dsi_sc7180_bus_clk_names), - .io_start = { 0xae94000 }, + .io_start = { + { 0xae94000 }, + }, }; static const char * const dsi_sc7280_bus_clk_names[] = { @@ -212,7 +234,9 @@ static const struct msm_dsi_config sc7280_dsi_cfg = { .num_regulators = ARRAY_SIZE(sc7280_dsi_regulators), .bus_clk_names = dsi_sc7280_bus_clk_names, .num_bus_clks = ARRAY_SIZE(dsi_sc7280_bus_clk_names), - .io_start = { 0xae94000, 0xae96000 }, + .io_start = { + { 0xae94000, 0xae96000 }, + }, }; static const char * const dsi_qcm2290_bus_clk_names[] = { @@ -229,7 +253,9 @@ static const struct msm_dsi_config qcm2290_dsi_cfg = { .num_regulators = ARRAY_SIZE(qcm2290_dsi_cfg_regulators), .bus_clk_names = dsi_qcm2290_bus_clk_names, .num_bus_clks = ARRAY_SIZE(dsi_qcm2290_bus_clk_names), - .io_start = { 0x5e94000 }, + .io_start = { + { 0x5e94000 }, + }, }; static const struct msm_dsi_host_cfg_ops msm_dsi_v2_host_ops = { diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.h b/drivers/gpu/drm/msm/dsi/dsi_cfg.h index 6b6b16c5fd25..8772a3631ac1 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_cfg.h +++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.h @@ -32,13 +32,16 @@ #define DSI_6G_REG_SHIFT 4 +/* Maximum number of configurations matched against the same hw revision */ +#define VARIANTS_MAX 2 + struct msm_dsi_config { u32 io_offset; const struct regulator_bulk_data *regulator_data; int num_regulators; const char * const *bus_clk_names; const int num_bus_clks; - const resource_size_t io_start[DSI_MAX]; + const resource_size_t io_start[VARIANTS_MAX][DSI_MAX]; }; struct msm_dsi_host_cfg_ops { diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c index 9021f0d65515..9cfb9e91bfea 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_host.c +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c @@ -1862,16 +1862,16 @@ static int dsi_host_get_id(struct msm_dsi_host *msm_host) struct platform_device *pdev = msm_host->pdev; const struct msm_dsi_config *cfg = msm_host->cfg_hnd->cfg; struct resource *res; - int i; + int i, j; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dsi_ctrl"); if (!res) return -EINVAL; - for (i = 0; i < DSI_MAX; i++) { - if (cfg->io_start[i] == res->start) - return i; - } + for (i = 0; i < VARIANTS_MAX; i++) + for (j = 0; j < DSI_MAX; j++) + if (cfg->io_start[i][j] == res->start) + return j; return -EINVAL; }