Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1985390rda; Tue, 24 Oct 2023 08:58:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEBG5A4I/pyAWnzlOkASBFjCXmGrrByKqw4VTwXSoiBmI6QomVm9f0RLwICdcQ7EXbyP1Zk X-Received: by 2002:a17:903:2310:b0:1c9:ece9:53d2 with SMTP id d16-20020a170903231000b001c9ece953d2mr11098043plh.61.1698163104888; Tue, 24 Oct 2023 08:58:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698163104; cv=none; d=google.com; s=arc-20160816; b=MPW9wBxcHUEHMXGPy5b02ffUoI4H/d/u4juzZh029GZSrso+EXTNBABWZxfxDyq1vc wn0hHGQOvVX2NIGk8B4pElNanhCBtgbChMEKPrXmF3BEabXBK2RHx5hIHyL6AkCrw9de j/DaJ9KNoHmyCx2adfSJLD0jGLUusAvinpTfchctUxhVtsfSdJw0nM5lLyYgozUHY5SF /jMWXzhR9PMmiLVuB/pW9NtsTuiasU38sZnE4lCAeLKfzKP7ywj4UsTGL3tmExLbHzMH XuFyOrbO6wIK9JrmPUNGiTh7BtX7oLAa5P7bIDswzhBBYeV1sgTKlSRZDZfOw1nU+mVq Plag== 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=bd4Wn5SAyGG8ON4xJ/nwNICVu3QF1cAFBQZwZsKoK8c=; fh=4fCGr/vcT8BP5WO1Zwkta5BK+bnwH5aUY2dV04P1PeQ=; b=pas4H+WUz4A4ZkYbj9m9kqpJdFn2IlxSFqaAVnj4Z0VDZIroHOdxSCXHir3d9TWJ9K qYCYrO7R0w/K84c4MlPU5ebJenvJGDi9+saLJ+Zm5Hm4MpTbPh79soIvlfcdpROOnze3 UUv3GSjgjJaDG8oNCZhb7hT7M9KjgbavWFQcvlmta78ZsWj4+q/I6+WWYeYF0Z+e/Uw8 P8wjbWP6kBrDM30c8jOQ34reEr5luqyqH2LxfGVsQEMvm0lf9E2d84E9zvdQVHIAZkhP M5wWvu3eU4kmL19vqjzYPAGE9ab0y3m5aaNm9N3EWkJq4uDGmJc4D9OpsNf1qQkkUgko IFsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EjXFNi1E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id p3-20020a170902a40300b001befd0512ecsi8170540plq.314.2023.10.24.08.58.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 08:58:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EjXFNi1E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 3EDF8802B110; Tue, 24 Oct 2023 08:58:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343978AbjJXP6B (ORCPT + 99 others); Tue, 24 Oct 2023 11:58:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343989AbjJXP5x (ORCPT ); Tue, 24 Oct 2023 11:57:53 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B85F610C9 for ; Tue, 24 Oct 2023 08:57:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698163070; x=1729699070; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dnQFwufB5Hr81HvGwsAEkxbIJnfWkJTFO23E+pdW1kc=; b=EjXFNi1EyrSOuIr2s6su7IylH5rb0Pyj2xEueIgE0uKwvpTTcYp+kYG0 jJcKraW9WPVL+0T9yV6c5u3dOfcIg09eTPInrrAJ4ZaKlvNOhUNXYNn7g eiZJMGZH/y3y74jI6rFKEotLq2LbRmuY2qI1v07z/2ZLTqwJ9HM8Tn1sA Dlae3PUwjoMxenOTqNZMyp363IxjI/pAqqPRX1kp1OTckWbq760xusyHx UNUkGMwlfUUuM4Wfq8vhLOTnp2rIZzz9jXvhVfNJkNvia4yISC7fqdcNI CKbuGPL83fbmlRR70xmZgrQs0C0YB/RylWCMtpoSIATypdynp0IHbMRfV Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="8649803" X-IronPort-AV: E=Sophos;i="6.03,248,1694761200"; d="scan'208";a="8649803" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2023 08:57:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="902233870" X-IronPort-AV: E=Sophos;i="6.03,248,1694761200"; d="scan'208";a="902233870" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 24 Oct 2023 08:55:26 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 67009BE1; Tue, 24 Oct 2023 18:57:42 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Jani Nikula , 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 v2 6/7] drm/i915/dsi: Replace poking of CHV GPIOs behind the driver's back Date: Tue, 24 Oct 2023 18:57:38 +0300 Message-Id: <20231024155739.3861342-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231024155739.3861342-1-andriy.shevchenko@linux.intel.com> References: <20231024155739.3861342-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 morse.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 (morse.vger.email [0.0.0.0]); Tue, 24 Oct 2023 08:58:22 -0700 (PDT) It's a dirty hack in the driver that pokes GPIO registers behind the driver's back. Moreoever it might be problematic as simultaneous I/O may hang the system, see the commit 0bd50d719b00 ("pinctrl: cherryview: prevent concurrent access to GPIO controllers") for the details. Taking all this into consideration replace the hack with proper GPIO APIs being used. Signed-off-by: Andy Shevchenko --- drivers/gpu/drm/i915/display/intel_dsi_vbt.c | 47 +++++--------------- 1 file changed, 10 insertions(+), 37 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_dsi_vbt.c b/drivers/gpu/drm/i915/display/intel_dsi_vbt.c index 8fc82aceae14..a393ddaff0dd 100644 --- a/drivers/gpu/drm/i915/display/intel_dsi_vbt.c +++ b/drivers/gpu/drm/i915/display/intel_dsi_vbt.c @@ -66,19 +66,6 @@ struct i2c_adapter_lookup { #define CHV_GPIO_IDX_START_SW 100 #define CHV_GPIO_IDX_START_SE 198 -#define CHV_VBT_MAX_PINS_PER_FMLY 15 - -#define CHV_GPIO_PAD_CFG0(f, i) (0x4400 + (f) * 0x400 + (i) * 8) -#define CHV_GPIO_GPIOEN (1 << 15) -#define CHV_GPIO_GPIOCFG_GPIO (0 << 8) -#define CHV_GPIO_GPIOCFG_GPO (1 << 8) -#define CHV_GPIO_GPIOCFG_GPI (2 << 8) -#define CHV_GPIO_GPIOCFG_HIZ (3 << 8) -#define CHV_GPIO_GPIOTXSTATE(state) ((!!(state)) << 1) - -#define CHV_GPIO_PAD_CFG1(f, i) (0x4400 + (f) * 0x400 + (i) * 8 + 4) -#define CHV_GPIO_CFGLOCK (1 << 31) - /* ICL DSI Display GPIO Pins */ #define ICL_GPIO_DDSP_HPD_A 0 #define ICL_GPIO_L_VDDEN_1 1 @@ -279,23 +266,21 @@ static void chv_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); - u16 cfg0, cfg1; - u16 family_num; - u8 port; if (connector->panel.vbt.dsi.seq_version >= 3) { if (gpio_index >= CHV_GPIO_IDX_START_SE) { /* XXX: it's unclear whether 255->57 is part of SE. */ - gpio_index -= CHV_GPIO_IDX_START_SE; - port = CHV_IOSF_PORT_GPIO_SE; + soc_exec_opaque_gpio(connector, "INT33FF:03", "Panel SE", + gpio_index - CHV_GPIO_IDX_START_SW, value); } else if (gpio_index >= CHV_GPIO_IDX_START_SW) { - gpio_index -= CHV_GPIO_IDX_START_SW; - port = CHV_IOSF_PORT_GPIO_SW; + soc_exec_opaque_gpio(connector, "INT33FF:00", "Panel SW", + gpio_index - CHV_GPIO_IDX_START_SW, value); } else if (gpio_index >= CHV_GPIO_IDX_START_E) { - gpio_index -= CHV_GPIO_IDX_START_E; - port = CHV_IOSF_PORT_GPIO_E; + soc_exec_opaque_gpio(connector, "INT33FF:02", "Panel E", + gpio_index - CHV_GPIO_IDX_START_E, value); } else { - port = CHV_IOSF_PORT_GPIO_N; + soc_exec_opaque_gpio(connector, "INT33FF:01", "Panel N", + gpio_index - CHV_GPIO_IDX_START_N, value); } } else { /* XXX: The spec is unclear about CHV GPIO on seq v2 */ @@ -312,21 +297,9 @@ static void chv_exec_gpio(struct intel_connector *connector, return; } - port = CHV_IOSF_PORT_GPIO_N; + soc_exec_opaque_gpio(connector, "INT33FF:01", "Panel N", + gpio_index - CHV_GPIO_IDX_START_N, value); } - - family_num = gpio_index / CHV_VBT_MAX_PINS_PER_FMLY; - gpio_index = gpio_index % CHV_VBT_MAX_PINS_PER_FMLY; - - cfg0 = CHV_GPIO_PAD_CFG0(family_num, gpio_index); - cfg1 = CHV_GPIO_PAD_CFG1(family_num, gpio_index); - - vlv_iosf_sb_get(dev_priv, BIT(VLV_IOSF_SB_GPIO)); - vlv_iosf_sb_write(dev_priv, port, cfg1, 0); - vlv_iosf_sb_write(dev_priv, port, cfg0, - CHV_GPIO_GPIOEN | CHV_GPIO_GPIOCFG_GPO | - CHV_GPIO_GPIOTXSTATE(value)); - vlv_iosf_sb_put(dev_priv, BIT(VLV_IOSF_SB_GPIO)); } static void bxt_exec_gpio(struct intel_connector *connector, -- 2.40.0.1.gaa8946217a0b