From patchwork Fri Mar 18 11:11:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 8618321 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 36366C0553 for ; Fri, 18 Mar 2016 11:11:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5528120377 for ; Fri, 18 Mar 2016 11:11:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 62719201F2 for ; Fri, 18 Mar 2016 11:11:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 00E746EBBE; Fri, 18 Mar 2016 11:11:42 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id B3FEE6EBBE for ; Fri, 18 Mar 2016 11:11:33 +0000 (UTC) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 18 Mar 2016 04:11:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,354,1455004800"; d="scan'208";a="940094494" Received: from jnikula-mobl.fi.intel.com (HELO localhost) ([10.237.72.67]) by fmsmga002.fm.intel.com with ESMTP; 18 Mar 2016 04:11:31 -0700 From: Jani Nikula To: intel-gfx@lists.freedesktop.org Date: Fri, 18 Mar 2016 13:11:12 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Cc: Deepak M , jani.nikula@intel.com Subject: [Intel-gfx] [PATCH v2 4/9] drm/i915/dsi: add gpio indexes to the gpio table X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This lets us specify the exact gpios we want to let through, without leaving holes in the array. Signed-off-by: Jani Nikula --- drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 54 ++++++++++++++++++------------ 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c b/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c index b04d88e6127b..744368d01ee6 100644 --- a/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +++ b/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c @@ -75,24 +75,25 @@ static inline struct vbt_panel *to_vbt_panel(struct drm_panel *panel) #define VLV_GPIO_PCONF0(base_offset) (base_offset) #define VLV_GPIO_PAD_VAL(base_offset) ((base_offset) + 8) -struct gpio_table { +struct vlv_gpio_map { + u8 gpio_index; u16 base_offset; bool init; }; -static struct gpio_table 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_BLKEN }, - { VLV_GPIO_NC_5_PANEL0_BLKCTL }, - { VLV_GPIO_NC_6_PCONF0 }, - { VLV_GPIO_NC_7_PCONF0 }, - { VLV_GPIO_NC_8_PCONF0 }, - { VLV_GPIO_NC_9_PCONF0 }, - { VLV_GPIO_NC_10_PCONF0 }, - { VLV_GPIO_NC_11_PCONF0 }, +static struct vlv_gpio_map vlv_gpio_table[] = { + { 0, VLV_GPIO_NC_0_HV_DDI0_HPD }, + { 1, VLV_GPIO_NC_1_HV_DDI0_DDC_SDA }, + { 2, VLV_GPIO_NC_2_HV_DDI0_DDC_SCL }, + { 3, VLV_GPIO_NC_3_PANEL0_VDDEN }, + { 4, VLV_GPIO_NC_4_PANEL0_BLKEN }, + { 5, VLV_GPIO_NC_5_PANEL0_BLKCTL }, + { 6, VLV_GPIO_NC_6_PCONF0 }, + { 7, VLV_GPIO_NC_7_PCONF0 }, + { 8, VLV_GPIO_NC_8_PCONF0 }, + { 9, VLV_GPIO_NC_9_PCONF0 }, + { 10, VLV_GPIO_NC_10_PCONF0 }, + { 11, VLV_GPIO_NC_11_PCONF0 }, }; static inline enum port intel_dsi_seq_port_to_port(u8 port) @@ -194,6 +195,8 @@ static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data) u32 val; struct drm_device *dev = intel_dsi->base.base.dev; struct drm_i915_private *dev_priv = dev->dev_private; + struct vlv_gpio_map *map = NULL; + int i; if (dev_priv->vbt.dsi.seq_version >= 3) data++; @@ -209,13 +212,20 @@ static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data) /* pull up/down */ action = *data++ & 1; - if (gpio_index >= ARRAY_SIZE(vlv_gpio_table)) { - DRM_DEBUG_KMS("unknown gpio index %u\n", gpio_index); + if (!IS_VALLEYVIEW(dev_priv)) { + DRM_DEBUG_KMS("GPIO element not supported on this platform\n"); goto out; } - if (!IS_VALLEYVIEW(dev_priv)) { - DRM_DEBUG_KMS("GPIO element not supported on this platform\n"); + for (i = 0; i < ARRAY_SIZE(vlv_gpio_table); i++) { + if (gpio_index == vlv_gpio_table[i].gpio_index) { + map = &vlv_gpio_table[i]; + break; + } + } + + if (!map) { + DRM_DEBUG_KMS("invalid gpio index %u\n", gpio_index); goto out; } @@ -233,15 +243,15 @@ static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data) } } - pconf0 = VLV_GPIO_PCONF0(vlv_gpio_table[gpio_index].base_offset); - padval = VLV_GPIO_PAD_VAL(vlv_gpio_table[gpio_index].base_offset); + pconf0 = VLV_GPIO_PCONF0(map->base_offset); + padval = VLV_GPIO_PAD_VAL(map->base_offset); mutex_lock(&dev_priv->sb_lock); - if (!vlv_gpio_table[gpio_index].init) { + if (!map->init) { /* program the function */ /* FIXME: remove constant below */ vlv_iosf_sb_write(dev_priv, port, pconf0, 0x2000CC00); - vlv_gpio_table[gpio_index].init = true; + map->init = true; } val = 0x4 | action;