From patchwork Wed Apr 3 01:45:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 2383501 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id AE9FE3FDDA for ; Wed, 3 Apr 2013 01:45:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759066Ab3DCBp1 (ORCPT ); Tue, 2 Apr 2013 21:45:27 -0400 Received: from mail-ye0-f169.google.com ([209.85.213.169]:33846 "EHLO mail-ye0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753395Ab3DCBp0 (ORCPT ); Tue, 2 Apr 2013 21:45:26 -0400 Received: by mail-ye0-f169.google.com with SMTP id q14so173512yen.28 for ; Tue, 02 Apr 2013 18:45:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=qZRoMCwKHV2NGlcmBY0P2EvQzNc6qGlO/OViXxPkkbk=; b=tqPOdZd6p7Rp7JmAGLwSpnE2UI1SC4JHMtPqz3COQ6O8N0YiVYOvba2tio8M9Z51zh thLYO0R12TfOax5KKMnp0Tkz0K+LC1QPm0iqGRa0V++r0RKcIrd/ly/Xl3cljcHi+yOV 3D9cnYkoLlhqM3NEguKiLHeICDdHckPm+Sqw/VZCjCfOAgUuYqBTs0EDG3IhMNx/zPNo Bph/Ei+3eQJiTmxoo1jyAhGxYIVM0pdmT3nmc9UxFulf6AZQdIwCsqgIXHBeqazE5auK 5NasPCmTOzcX39Re758EEZ7P9SO8WeVhzr5NhL+ZK1JIG+8krm0rYLa6LglpwOSjHHYH fwWA== X-Received: by 10.236.21.168 with SMTP id r28mr17526931yhr.75.1364953526134; Tue, 02 Apr 2013 18:45:26 -0700 (PDT) Received: from localhost.localdomain ([187.64.220.204]) by mx.google.com with ESMTPS id b7sm7190504yhl.10.2013.04.02.18.45.23 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Apr 2013 18:45:25 -0700 (PDT) From: Fabio Estevam To: shawn.guo@linaro.org Cc: kernel@pengutronix.de, marex@denx.de, linux-fbdev@vger.kernel.org, FlorianSchandinat@gmx.de, Fabio Estevam Subject: [PATCH v2 1/2] video: Add a helper for enabling a panel via GPIO from dt Date: Tue, 2 Apr 2013 22:45:15 -0300 Message-Id: <1364953516-7664-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org From: Fabio Estevam Introduce a helper that can be used to retrieve the GPIO via devicetree that is used to turn on a display. Tested on a mx28evk board. Signed-off-by: Fabio Estevam Reviewed-by: Marek Vasut --- Changes since v1: - Fix return value drivers/video/Kconfig | 6 +++++ drivers/video/Makefile | 1 + drivers/video/of_display_enable_gpio.c | 43 ++++++++++++++++++++++++++++++++ include/video/of_display_gpio.h | 17 +++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 drivers/video/of_display_enable_gpio.c create mode 100644 include/video/of_display_gpio.h diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 0181a87..7607f42 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -52,6 +52,12 @@ config OF_VIDEOMODE help helper to get videomodes from the devicetree +config OF_DISPLAY_ENABLE_GPIO + bool "Support for enabling a panel via GPIO from the devicetree" + depends on OF + help + helper to turning on a panel via gpio from the devicetree + config HDMI bool diff --git a/drivers/video/Makefile b/drivers/video/Makefile index 97f7b6d..4d3ec70 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -176,3 +176,4 @@ obj-$(CONFIG_DISPLAY_TIMING) += display_timing.o obj-$(CONFIG_OF_DISPLAY_TIMING) += of_display_timing.o obj-$(CONFIG_VIDEOMODE) += videomode.o obj-$(CONFIG_OF_VIDEOMODE) += of_videomode.o +obj-$(CONFIG_OF_DISPLAY_ENABLE_GPIO) += of_display_enable_gpio.o diff --git a/drivers/video/of_display_enable_gpio.c b/drivers/video/of_display_enable_gpio.c new file mode 100644 index 0000000..d556854 --- /dev/null +++ b/drivers/video/of_display_enable_gpio.c @@ -0,0 +1,43 @@ +/* + * generic helper for enabling a panel via GPIO from the devicetree + * + * Copyright 2013 Freescale Semiconductor, Inc. + * + * The code contained herein is licensed under the GNU General Public + * License. You may obtain a copy of the GNU General Public License + * Version 2 or later at the following locations: + * + * http://www.opensource.org/licenses/gpl-license.html + * http://www.gnu.org/copyleft/gpl.html + */ + +#include +#include +#include +#include + +int of_get_display_gpio_enable(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + int panel_enable, ret; + enum of_gpio_flags flags; + + panel_enable = of_get_named_gpio_flags(np, "panel-enable-gpios", 0, + &flags); + + if (gpio_is_valid(panel_enable)) { + unsigned long f = GPIOF_OUT_INIT_HIGH; + if (flags == OF_GPIO_ACTIVE_LOW) + f = GPIOF_OUT_INIT_LOW; + ret = devm_gpio_request_one(&pdev->dev, panel_enable, f, + "panel-enable"); + if (ret) { + dev_err(&pdev->dev, "failed to request gpio %d: %d\n", + panel_enable, ret); + return ret; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(of_get_display_gpio_enable); diff --git a/include/video/of_display_gpio.h b/include/video/of_display_gpio.h new file mode 100644 index 0000000..a56b6a1 --- /dev/null +++ b/include/video/of_display_gpio.h @@ -0,0 +1,17 @@ +/* + * Copyright 2013 Freescale Semiconductor, Inc. + * + * The code contained herein is licensed under the GNU General Public + * License. You may obtain a copy of the GNU General Public License + * Version 2 or later at the following locations: + * + * http://www.opensource.org/licenses/gpl-license.html + * http://www.gnu.org/copyleft/gpl.html + */ + +#ifndef __LINUX_OF_DISPLAY_GPIO_H +#define __LINUX_OF_DISPLAY_GPIO_H + +int of_get_display_gpio_enable(struct platform_device *pdev); + +#endif