From patchwork Fri Jul 3 07:57:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 226442 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp2161636ilg; Fri, 3 Jul 2020 00:59:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywGriqb98xwwW3ZiG5LOH01YctrOqwkqXhcQSYt207yA3cHqoOs8u3B+L3kX6lovGZcwvh X-Received: by 2002:a17:902:121:: with SMTP id 30mr30088217plb.44.1593763154125; Fri, 03 Jul 2020 00:59:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593763154; cv=none; d=google.com; s=arc-20160816; b=GZEZe8bDoP1GBPpr3dNnE+oJBZLbxKEP3j1XdXQ28ZU8X9j3hQ1T9DWNWSJ2SGjh9X PS4E3iqR0ZGDuxTlZwATAEu5JEsc263iHdv7adVRpIPH5cbUtrlr9/15TJIz69D3hAFO gVHtAl0PHxcmOmA0ZrF5k/QfOB4m7iUmSgh0K91PNvudBNlbZ+26xSq1kL7leXVolCoR ADw9R4YDJh38k8d/kRqUZY8oDcfPlsXN8avJ02dfq6tnN2d7B9kPXuJBXALCz85UdoEJ iwuXmaazPEx9YjFNDn8bY8bnv/p8k5WXymZESP7abVa90pjkewe6NkxE97mpT2oXGJ26 tVjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:message-id:date:subject:to:from:dkim-signature :delivered-to; bh=7RaWVo17V99MPqkQsbPBePJGqBTHNpqxYLbFO85Kb6g=; b=musmVT2YazTQuPYl3JCic5KF6A7lIUbKUGz8wqZ7O3YjI3tJSUvJv6lSUz+3uMvnmR vFqh3JX7rjctqEVxT+oIZwIzl1NvRkN4g0roMFOPIldjVTdaK2wooZCll3oiuk/6CXwe Ss1WMGCKTE7JVyAyhhFwaW1B/iiS1cEtVISl+8oAPcABLYsA0QikjZAWVcW94jJPdd36 WXP5AV4n1V6AEdc1HuSRIQyByvoAtR+RDP3UNHOx1d4W5BTBqQKyeAG+ztXLEjxjLpVP pFWoyWpUZPHb+QtMSix0BavclF0a0Wj94rsuXbRah81zIsqdjEQhOoAonp+uJYm9bYRT +1TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=nWNZUtQN; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id w8si7618609pgm.22.2020.07.03.00.59.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jul 2020 00:59:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=nWNZUtQN; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3F0EE6E9A3; Fri, 3 Jul 2020 07:59:12 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by gabe.freedesktop.org (Postfix) with ESMTPS id 236BB6E9A3 for ; Fri, 3 Jul 2020 07:59:11 +0000 (UTC) Received: by mail-lf1-x142.google.com with SMTP id y13so17948724lfe.9 for ; Fri, 03 Jul 2020 00:59:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ySw6ja96kmzmy6ukg5tSpLgj5xcKDYU0d1iMpa3wbZU=; b=nWNZUtQNbxojdufqYcbUnyWEwxqB4h1CJlOhDgk0U8GutmTFtvSmk9xCB3oec8myhI XTxDzu3z8A4RSJXUkuzfcw7ms7OnBpPVYw6N99biXFZ9TK1JdU9x4RJrQkhyPLkNxSB6 oyV3cXz5T9p8WLpOOcy12FvZfiRp65flMsSXlCHaS3Js2ETpOAVUm4Qbl3xTuK+lnEv1 qsCmziRzOngmrcpmHWvQtQKTGCYLmdIZMon30eS3sVM8QnsfEuB4HXXn2o7HJegEy0Jq FzJi/7rGqej8hqqDAg2TSVnm6hEWyQVShMBn6upPwQLye11LqJ21uAI2EfuL/ygrILHa Dq8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ySw6ja96kmzmy6ukg5tSpLgj5xcKDYU0d1iMpa3wbZU=; b=HoNPTQzxnmwGIYdpjLFCAPOmmzJgSPH7fxnHbffvH//HahUVAbBOEgtIKAxoITZMu+ yr3BWLDWCWAGPXXvpJuhh1AY5zsDrtTdpOLqvhNVR5tBqH6Ac/CoOGkzQwtwhK9Qqr7K se2Y2Fnjg64p0Cq4YFBmOFjibkWXeDAzXaCUqefyds2JgIrxadSnx4m/5ZIMeAi7F+eN LWSFLxaUDXtNIN+eT+SggJMiQtWdAoueUwi1nBvPTlJR5FRev5DwVxPlzRzLqz3xqWVg t7qg6ScrGaEkc7GZlQLwZavgI6LWQVputtEvRC0YsdMsGQ+obJ3ei+0C7Upewq2FK4Lf a5GQ== X-Gm-Message-State: AOAM5307NZJRJMtYnJxk1mu1ngb22xxJP3rWqMjZonanYe2JMioBEcdN A2Jg1+NZSptVcdmGH8aokpfUaJoGjso7uw== X-Received: by 2002:a19:8253:: with SMTP id e80mr21710436lfd.199.1593763149127; Fri, 03 Jul 2020 00:59:09 -0700 (PDT) Received: from localhost.localdomain (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id i8sm4368336lja.18.2020.07.03.00.59.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jul 2020 00:59:08 -0700 (PDT) From: Linus Walleij To: dri-devel@lists.freedesktop.org, Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Subject: [PATCH v2] drm: gma500: Convert to GPIO descriptors Date: Fri, 3 Jul 2020 09:57:04 +0200 Message-Id: <20200703075704.505849-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Finalize he conversion of GMA500 to use only GPIO descriptors. The GPIO look-up-table is associated with the device directly in the GMA500 Medfield chip driver since no explicit platform type device (such as in x86/platform/intel-mid) exists: the GMA500 probes directly from the PCI device. Apparently GPIOs 128 and 34 are used on all of these so just go ahead and register those for resetting the DSI pipes. Acked-by: Patrik Jakobsson Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Fix comments --- drivers/gpu/drm/gma500/mdfld_device.c | 20 +++++++++ drivers/gpu/drm/gma500/mdfld_dsi_dpi.c | 2 +- drivers/gpu/drm/gma500/mdfld_dsi_output.c | 51 ++++++++++++----------- drivers/gpu/drm/gma500/mdfld_dsi_output.h | 2 +- drivers/gpu/drm/gma500/mdfld_output.h | 2 +- drivers/gpu/drm/gma500/psb_intel_drv.h | 1 - 6 files changed, 49 insertions(+), 29 deletions(-) -- 2.25.4 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel diff --git a/drivers/gpu/drm/gma500/mdfld_device.c b/drivers/gpu/drm/gma500/mdfld_device.c index b718efccdcf2..be9cf6b1e3b3 100644 --- a/drivers/gpu/drm/gma500/mdfld_device.c +++ b/drivers/gpu/drm/gma500/mdfld_device.c @@ -6,6 +6,7 @@ **************************************************************************/ #include +#include #include @@ -505,12 +506,31 @@ static const struct psb_offset mdfld_regmap[3] = { }, }; +/* + * The GPIO lines for resetting DSI pipe 0 and 2 are available in the + * PCI device 0000:00:0c.0 on the Medfield. + */ +static struct gpiod_lookup_table mdfld_dsi_pipe_gpio_table = { + .table = { + GPIO_LOOKUP("0000:00:0c.0", 128, "dsi-pipe0-reset", + GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("0000:00:0c.0", 34, "dsi-pipe2-reset", + GPIO_ACTIVE_HIGH), + { }, + }, +}; + static int mdfld_chip_setup(struct drm_device *dev) { struct drm_psb_private *dev_priv = dev->dev_private; if (pci_enable_msi(dev->pdev)) dev_warn(dev->dev, "Enabling MSI failed!\n"); dev_priv->regmap = mdfld_regmap; + + /* Associate the GPIO lines with the DRM device */ + mdfld_dsi_pipe_gpio_table.dev_id = dev_name(dev->dev); + gpiod_add_lookup_table(&mdfld_dsi_pipe_gpio_table); + return mid_chip_setup(dev); } diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c b/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c index c976a9dd9240..ae1223f631a7 100644 --- a/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c +++ b/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c @@ -955,7 +955,7 @@ struct mdfld_dsi_encoder *mdfld_dsi_dpi_init(struct drm_device *dev, /* panel hard-reset */ if (p_funcs->reset) { - ret = p_funcs->reset(pipe); + ret = p_funcs->reset(dev, pipe); if (ret) { DRM_ERROR("Panel %d hard-reset failed\n", pipe); return NULL; diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_output.c b/drivers/gpu/drm/gma500/mdfld_dsi_output.c index f350ac1ead18..c9478261964a 100644 --- a/drivers/gpu/drm/gma500/mdfld_dsi_output.c +++ b/drivers/gpu/drm/gma500/mdfld_dsi_output.c @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -432,42 +433,42 @@ static int mdfld_dsi_get_default_config(struct drm_device *dev, return 0; } -int mdfld_dsi_panel_reset(int pipe) +int mdfld_dsi_panel_reset(struct drm_device *ddev, int pipe) { - unsigned gpio; - int ret = 0; - + struct device *dev = ddev->dev; + struct gpio_desc *gpiod; + + /* + * Raise the GPIO reset line for the corresponding pipe to HIGH, + * this is probably because it is active low so this takes the + * respective pipe out of reset. (We have no code to put it back + * into reset in this driver.) + */ switch (pipe) { case 0: - gpio = 128; + gpiod = gpiod_get(dev, "dsi-pipe0-reset", GPIOD_OUT_HIGH); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); break; case 2: - gpio = 34; + gpiod = gpiod_get(dev, "dsi-pipe2-reset", GPIOD_OUT_HIGH); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); break; default: - DRM_ERROR("Invalid output\n"); + DRM_DEV_ERROR(dev, "Invalid output pipe\n"); return -EINVAL; } + gpiod_put(gpiod); - ret = gpio_request(gpio, "gfx"); - if (ret) { - DRM_ERROR("gpio_rqueset failed\n"); - return ret; - } - - ret = gpio_direction_output(gpio, 1); - if (ret) { - DRM_ERROR("gpio_direction_output failed\n"); - goto gpio_error; - } + /* Always read the pipe0 GPIO line, FIXME: explain why! */ + gpiod = gpiod_get(dev, "dsi-pipe0-reset", GPIOD_ASIS); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); + gpiod_get_value(gpiod); + gpiod_put(gpiod); - gpio_get_value(128); - -gpio_error: - if (gpio_is_valid(gpio)) - gpio_free(gpio); - - return ret; + return 0; } /* diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_output.h b/drivers/gpu/drm/gma500/mdfld_dsi_output.h index 0cccfe400a98..5c0db3c2903f 100644 --- a/drivers/gpu/drm/gma500/mdfld_dsi_output.h +++ b/drivers/gpu/drm/gma500/mdfld_dsi_output.h @@ -372,6 +372,6 @@ extern void mdfld_dsi_controller_init(struct mdfld_dsi_config *dsi_config, extern int mdfld_dsi_get_power_mode(struct mdfld_dsi_config *dsi_config, u32 *mode, bool hs); -extern int mdfld_dsi_panel_reset(int pipe); +extern int mdfld_dsi_panel_reset(struct drm_device *dev, int pipe); #endif /*__MDFLD_DSI_OUTPUT_H__*/ diff --git a/drivers/gpu/drm/gma500/mdfld_output.h b/drivers/gpu/drm/gma500/mdfld_output.h index 17a944d70add..37a516cc56be 100644 --- a/drivers/gpu/drm/gma500/mdfld_output.h +++ b/drivers/gpu/drm/gma500/mdfld_output.h @@ -54,7 +54,7 @@ struct panel_funcs { const struct drm_encoder_helper_funcs *encoder_helper_funcs; struct drm_display_mode * (*get_config_mode)(struct drm_device *); int (*get_panel_info)(struct drm_device *, int, struct panel_info *); - int (*reset)(int pipe); + int (*reset)(struct drm_device *, int); void (*drv_ic_init)(struct mdfld_dsi_config *dsi_config, int pipe); }; diff --git a/drivers/gpu/drm/gma500/psb_intel_drv.h b/drivers/gpu/drm/gma500/psb_intel_drv.h index fb601983cef0..9221d1f545b0 100644 --- a/drivers/gpu/drm/gma500/psb_intel_drv.h +++ b/drivers/gpu/drm/gma500/psb_intel_drv.h @@ -13,7 +13,6 @@ #include #include #include -#include #include "gma_display.h" /*