From patchwork Tue Oct 24 15:57:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 157617 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp2049769vqx; Tue, 24 Oct 2023 09:09:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEHhJQiWRVZ3yjSw8wfkJ5hKiLKDRWAXvmsCd7+NtWRqiuX94W9jDz4NtYac69Os893IMqq X-Received: by 2002:a05:6358:c381:b0:168:e58d:8811 with SMTP id fl1-20020a056358c38100b00168e58d8811mr3633182rwb.5.1698163789873; Tue, 24 Oct 2023 09:09:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698163789; cv=none; d=google.com; s=arc-20160816; b=xZzccgw+tLv/4JEmGGIBymBhVrwQskDcjQMsvQpDS6Zr+eEMvZVbxrvul8xkbLG/xU E1bK5AFCZE4dtMjpNAkTitqJIUAwgWdQ8AhUvkp3HhTwUAaDkBHZnhUzepY6XGHPrsTZ M2cCRDMNWHfs11yqpb2M0eSPpNuJlzLxDseWIZ/kWmmpgjt9pdVY+/QrFk5aVaAKRwv4 nkRkGmPvAGh/F1SVdevyZJJrfh7qVsg/XuxSjbtJhSCHObBCQUkNisrcPArBQ3Dra1g3 VA6nGYQ1xGIwCEnqB54INj5f6hPNMP6+sRu8Aq3Dx6GhJQsWy3GaGfDYr16sNAEpo47T AsXA== 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=/f+ouqF5Tj3W/jYipcB/DANJ4TNhpbknJfVgo+8ukzU=; fh=4fCGr/vcT8BP5WO1Zwkta5BK+bnwH5aUY2dV04P1PeQ=; b=srLFXPhiYxG1zKWk7uwqyGoWPV5NNxQEOX0oHvRDnU3q4IXfWT5UuN3AvpiW90TMj3 eZ2YKoRQZ94SLiouNPm0avHSDfWxOVctMkoXCeBZFEKiBR+q1Oa+/HJg/PoPqll9/tky OSPl8kUOaN/+GnHD/CP4GYaoNdRDZEukRXB8V7H1RRv2A+TG0Bsk7H5dx5tk3z1nOg3G r9calwxXYuJLOJkjE4taYKotRjY+w2ZWvIOLYbe3+tiAwOrBBaMN4z7XpzExVp0XcQiv PI69Lhe/ymWq+z/7IV1iwVHBIDlaFZ++lREF/ZMGGkhFqHFFiE1r8V83pdtz11eGr12e KUOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=I44SO8wB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id g193-20020a636bca000000b00589876a1c18si8542442pgc.209.2023.10.24.09.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 09:09:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=I44SO8wB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 08DEC8027E2B; Tue, 24 Oct 2023 09:09:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344092AbjJXQJW (ORCPT + 27 others); Tue, 24 Oct 2023 12:09:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344083AbjJXQJQ (ORCPT ); Tue, 24 Oct 2023 12:09:16 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCDDD10CE for ; Tue, 24 Oct 2023 09:09:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698163752; x=1729699752; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2pV0njvceG1yP8TEVnAggZ39CaiG94yX2lM8ClTppZQ=; b=I44SO8wBH08cefKF6MbSxStTDWXF/0KJ7uNgUv2+whN3d/l0VtABUYGx +I6PnXKtpUBscfJJuqtUYmBt6YZKtGJO3dhIwHhxvOLbQTm0qwK48vaE9 KKu4NjG+l1c4btDhyqJVpxCJZJEV3dzPZW49pgb6U1unCSE5oXJCkfccP kppAEZBGg0PRmzV2vWboDcT8xm8Z24Z8ks4VHwtwb48OP7vIaZI/a88jz H196jEtzzNqUppxPbc/1C6mCh1ekothXXkhznSEk5sV/e+aaT0blJ00Y1 vLJlQZLBCTSF3K0KZFa3eSOenlcIrBxfDkUire+ItogpCSLCuuAussM4s Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="473328737" X-IronPort-AV: E=Sophos;i="6.03,248,1694761200"; d="scan'208";a="473328737" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2023 08:57:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="708354975" X-IronPort-AV: E=Sophos;i="6.03,248,1694761200"; d="scan'208";a="708354975" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 24 Oct 2023 08:57:47 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 57C4DBD4; 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 5/7] drm/i915/dsi: Replace poking of VLV GPIOs behind the driver's back Date: Tue, 24 Oct 2023 18:57:37 +0300 Message-Id: <20231024155739.3861342-6-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 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Tue, 24 Oct 2023 09:09:47 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780653794158697167 X-GMAIL-MSGID: 1780653794158697167 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 40ecab551232 ("pinctrl: baytrail: Really serialize all register accesses") 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 | 98 ++++++-------------- 1 file changed, 28 insertions(+), 70 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_dsi_vbt.c b/drivers/gpu/drm/i915/display/intel_dsi_vbt.c index 3fb85b6d320e..8fc82aceae14 100644 --- a/drivers/gpu/drm/i915/display/intel_dsi_vbt.c +++ b/drivers/gpu/drm/i915/display/intel_dsi_vbt.c @@ -55,43 +55,6 @@ #define MIPI_VIRTUAL_CHANNEL_SHIFT 1 #define MIPI_PORT_SHIFT 3 -/* base offsets for gpio pads */ -#define VLV_GPIO_NC_0_HV_DDI0_HPD 0x4130 -#define VLV_GPIO_NC_1_HV_DDI0_DDC_SDA 0x4120 -#define VLV_GPIO_NC_2_HV_DDI0_DDC_SCL 0x4110 -#define VLV_GPIO_NC_3_PANEL0_VDDEN 0x4140 -#define VLV_GPIO_NC_4_PANEL0_BKLTEN 0x4150 -#define VLV_GPIO_NC_5_PANEL0_BKLTCTL 0x4160 -#define VLV_GPIO_NC_6_HV_DDI1_HPD 0x4180 -#define VLV_GPIO_NC_7_HV_DDI1_DDC_SDA 0x4190 -#define VLV_GPIO_NC_8_HV_DDI1_DDC_SCL 0x4170 -#define VLV_GPIO_NC_9_PANEL1_VDDEN 0x4100 -#define VLV_GPIO_NC_10_PANEL1_BKLTEN 0x40E0 -#define VLV_GPIO_NC_11_PANEL1_BKLTCTL 0x40F0 - -#define VLV_GPIO_PCONF0(base_offset) (base_offset) -#define VLV_GPIO_PAD_VAL(base_offset) ((base_offset) + 8) - -struct gpio_map { - u16 base_offset; - bool init; -}; - -static struct gpio_map vlv_gpio_table[] = { - { VLV_GPIO_NC_0_HV_DDI0_HPD }, - { VLV_GPIO_NC_1_HV_DDI0_DDC_SDA }, - { VLV_GPIO_NC_2_HV_DDI0_DDC_SCL }, - { VLV_GPIO_NC_3_PANEL0_VDDEN }, - { VLV_GPIO_NC_4_PANEL0_BKLTEN }, - { VLV_GPIO_NC_5_PANEL0_BKLTCTL }, - { VLV_GPIO_NC_6_HV_DDI1_HPD }, - { VLV_GPIO_NC_7_HV_DDI1_DDC_SDA }, - { VLV_GPIO_NC_8_HV_DDI1_DDC_SCL }, - { VLV_GPIO_NC_9_PANEL1_VDDEN }, - { VLV_GPIO_NC_10_PANEL1_BKLTEN }, - { VLV_GPIO_NC_11_PANEL1_BKLTCTL }, -}; - struct i2c_adapter_lookup { u16 slave_addr; struct intel_dsi *intel_dsi; @@ -269,52 +232,47 @@ static void soc_exec_gpio(struct intel_connector *connector, const char *con_id, } } +static void soc_exec_opaque_gpio(struct intel_connector *connector, + const char *chip, const char *con_id, + u8 gpio_index, bool value) +{ + struct gpiod_lookup_table *lookup; + + lookup = kzalloc(struct_size(lookup, table, 2), GFP_KERNEL); + if (!lookup) + return; + + lookup->dev_id = "0000:00:02.0"; + lookup->table[0] = + GPIO_LOOKUP_IDX(chip, gpio_index, con_id, gpio_index, GPIO_ACTIVE_HIGH); + + gpiod_add_lookup_table(lookup); + + soc_exec_gpio(connector, con_id, gpio_index, value); + + gpiod_remove_lookup_table(lookup); + kfree(lookup); +} + static void vlv_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); - struct gpio_map *map; - u16 pconf0, padval; - u32 tmp; - u8 port; - if (gpio_index >= ARRAY_SIZE(vlv_gpio_table)) { - drm_dbg_kms(&dev_priv->drm, "unknown gpio index %u\n", - gpio_index); - return; - } - - map = &vlv_gpio_table[gpio_index]; - - if (connector->panel.vbt.dsi.seq_version >= 3) { - /* XXX: this assumes vlv_gpio_table only has NC GPIOs. */ - port = IOSF_PORT_GPIO_NC; - } else { - if (gpio_source == 0) { - port = IOSF_PORT_GPIO_NC; - } else if (gpio_source == 1) { + /* XXX: this assumes vlv_gpio_table only has NC GPIOs. */ + if (connector->panel.vbt.dsi.seq_version < 3) { + if (gpio_source == 1) { drm_dbg_kms(&dev_priv->drm, "SC gpio not supported\n"); return; - } else { + } + if (gpio_source > 1) { drm_dbg_kms(&dev_priv->drm, "unknown gpio source %u\n", gpio_source); return; } } - pconf0 = VLV_GPIO_PCONF0(map->base_offset); - padval = VLV_GPIO_PAD_VAL(map->base_offset); - - vlv_iosf_sb_get(dev_priv, BIT(VLV_IOSF_SB_GPIO)); - if (!map->init) { - /* FIXME: remove constant below */ - vlv_iosf_sb_write(dev_priv, port, pconf0, 0x2000CC00); - map->init = true; - } - - tmp = 0x4 | value; - vlv_iosf_sb_write(dev_priv, port, padval, tmp); - vlv_iosf_sb_put(dev_priv, BIT(VLV_IOSF_SB_GPIO)); + soc_exec_opaque_gpio(connector, "INT33FC:01", "Panel N", gpio_index, value); } static void chv_exec_gpio(struct intel_connector *connector,