Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3577861rdg; Tue, 17 Oct 2023 22:11:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH3w3zu9f4u9EVFK+JyqiCVdwAvQf5KlXy+CVDTA2aLhTg2XitkV62WQx+VxTHUT7R1SSvk X-Received: by 2002:a05:6a20:8f12:b0:125:517c:4f18 with SMTP id b18-20020a056a208f1200b00125517c4f18mr4512260pzk.8.1697605884475; Tue, 17 Oct 2023 22:11:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697605884; cv=none; d=google.com; s=arc-20160816; b=xOQr6KBD2DGV2128VZ5UBIJqgLpMjTQL1f6oUl6AaoztW0ZfbdlkVahV24gUlsQw1c Foz0qs8hjQQwc1KmhcqjwUEjHAY7NIJlDAysE8eMtcGsfKoOqxp/GwCfDdLkdviifFho 2NmTw1Je9RLrlzRUUi0Ck1RfRSun5t/Po1dp2zO5N+/sHx7U/qC3WkbFX50I1Mv2LxrQ pTXrbMlHWVWUxqyjdNul75FKjZ1XCwvBMGNKW3yJ25K8Sdhbzq3m3p4E00C6JYuT7Ih8 kkmQ7LHVNaPsZrvR8GhpAyp8qnFfTWNuLvCvBbEONZyOncOLXs7rlIhcx15BR+HLKGhn BlAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KpCoJ4MXJtG6KPjX6IjHVY0OQ6ICgqe3d87Vg8phYkU=; fh=W9Apx1mxfI4Sn4Tfu/ApINr5FKslMaF8Hy7vCgvNWsQ=; b=e2I0wzLxKUOVy1D8/P+UDpVtfVHjYwt0apP5Ar9PzA18wyn39boQOCRGjkMFWgTyck c+CiK9isNsuOYuPYfhxUcn4E9+uSsSReVWOc5wZWplxoOU40PaZXd03o8O1I6w5RXv5G NvbCS6Umqus+D10CRO31AnF2hc5tBowT/6bda2MC6aubwiVfUc0znbZXxBm9+4WhM5w5 XDG2JK0HEP7cbrmZbRnzhrYfS7JFzeoyZN1/a/6bJxW+PVfNUxbnZskVdoDJGVJo7yYL Ll9Fw2JplFbD3LR3nhYwG97wWD006rQCpk9Jpwcn0KycDUci1dqOwreo6DEaT7pMvbhB DG8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lTGrtu5l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id r4-20020a632b04000000b005a9c401068bsi1337038pgr.484.2023.10.17.22.11.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 22:11:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lTGrtu5l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 336308026C0E; Tue, 17 Oct 2023 22:11:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229594AbjJRFLN (ORCPT + 99 others); Wed, 18 Oct 2023 01:11:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229582AbjJRFLJ (ORCPT ); Wed, 18 Oct 2023 01:11:09 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1511010B for ; Tue, 17 Oct 2023 22:11:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697605864; x=1729141864; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YvDBqhfDgnDd5m69diSkC/yOJ2Ix4OIlArCI45h7ELg=; b=lTGrtu5l8pbx4Le7e4f1/81QB/SaUugv8R55hypZoua+3EZtvbgQtOgC 979NraneN8R+qPQbQcZwq6CWnfp+gKM/0aiPJnarjadJSXqs06n0AtGAZ gxmZOkYVc/KuRais7m++CmZ29H84rajOyo+Bg1Nlyz6bgaVN3yEOyLSRl 2rvBWFnMSrKalkkIXZTO2Nix03rYrAYET4gPuLSo8hCbt1QjqcifakOMp isDczgtydJ57U3Cjkpjf2HVpGOe6KMC8FQ99VFfLhMGpQFg9GoIctjaU3 FK9ofk6tH9xq5t/eXSlWYhQJmCXprRR6H/Vb6nvaZjFd8lH3H7xZTxpks Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="388803240" X-IronPort-AV: E=Sophos;i="6.03,234,1694761200"; d="scan'208";a="388803240" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2023 22:11:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="785736947" X-IronPort-AV: E=Sophos;i="6.03,234,1694761200"; d="scan'208";a="785736947" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 17 Oct 2023 22:10:59 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8BE61BF; Wed, 18 Oct 2023 08:10:58 +0300 (EEST) From: Andy Shevchenko To: Jani Nikula , Andy Shevchenko , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , Hans de Goede Subject: [PATCH v1 1/2] drm/i915/dsi: Extract common soc_gpio_exec() helper Date: Wed, 18 Oct 2023 08:10:51 +0300 Message-Id: <20231018051052.1328852-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231018051052.1328852-1-andriy.shevchenko@linux.intel.com> References: <20231018051052.1328852-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 17 Oct 2023 22:11:22 -0700 (PDT) Extract a common soc_gpio_exec() helper that may be used by a few SoCs. Signed-off-by: Andy Shevchenko --- drivers/gpu/drm/i915/display/intel_dsi_vbt.c | 49 +++++++++++--------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_dsi_vbt.c b/drivers/gpu/drm/i915/display/intel_dsi_vbt.c index 24b2cbcfc1ef..c3c3f4df9ac4 100644 --- a/drivers/gpu/drm/i915/display/intel_dsi_vbt.c +++ b/drivers/gpu/drm/i915/display/intel_dsi_vbt.c @@ -243,6 +243,32 @@ static const u8 *mipi_exec_delay(struct intel_dsi *intel_dsi, const u8 *data) return data; } +static void soc_exec_gpio(struct intel_connector *connector, const char *con_id, + u8 gpio_index, bool value) +{ + struct drm_i915_private *dev_priv = to_i915(connector->base.dev); + /* XXX: this table is a quick ugly hack. */ + static struct gpio_desc *soc_gpio_table[U8_MAX + 1]; + struct gpio_desc *gpio_desc = soc_gpio_table[gpio_index]; + + if (gpio_desc) { + gpiod_set_value(gpio_desc, value); + } else { + gpio_desc = devm_gpiod_get_index(dev_priv->drm.dev, + con_id, gpio_index, + value ? GPIOD_OUT_LOW : + GPIOD_OUT_HIGH); + if (IS_ERR(gpio_desc)) { + drm_err(&dev_priv->drm, + "GPIO index %u request failed (%pe)\n", + gpio_index, gpio_desc); + return; + } + + soc_gpio_table[gpio_index] = gpio_desc; + } +} + static void vlv_exec_gpio(struct intel_connector *connector, u8 gpio_source, u8 gpio_index, bool value) { @@ -348,28 +374,7 @@ static void chv_exec_gpio(struct intel_connector *connector, static void bxt_exec_gpio(struct intel_connector *connector, u8 gpio_source, u8 gpio_index, bool value) { - struct drm_i915_private *dev_priv = to_i915(connector->base.dev); - /* XXX: this table is a quick ugly hack. */ - static struct gpio_desc *bxt_gpio_table[U8_MAX + 1]; - struct gpio_desc *gpio_desc = bxt_gpio_table[gpio_index]; - - if (!gpio_desc) { - gpio_desc = devm_gpiod_get_index(dev_priv->drm.dev, - NULL, gpio_index, - value ? GPIOD_OUT_LOW : - GPIOD_OUT_HIGH); - - if (IS_ERR_OR_NULL(gpio_desc)) { - drm_err(&dev_priv->drm, - "GPIO index %u request failed (%ld)\n", - gpio_index, PTR_ERR(gpio_desc)); - return; - } - - bxt_gpio_table[gpio_index] = gpio_desc; - } - - gpiod_set_value(gpio_desc, value); + soc_exec_gpio(connector, NULL, gpio_index, value); } static void icl_exec_gpio(struct intel_connector *connector, -- 2.40.0.1.gaa8946217a0b