From patchwork Thu Mar 12 16:31:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kumar, Shobhit" X-Patchwork-Id: 5997231 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 2A1EABF90F for ; Thu, 12 Mar 2015 16:32:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4EC622035B for ; Thu, 12 Mar 2015 16:32:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0A5B420377 for ; Thu, 12 Mar 2015 16:32:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 85DF972048; Thu, 12 Mar 2015 09:32:05 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id CA7A172048 for ; Thu, 12 Mar 2015 09:32:04 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 12 Mar 2015 09:29:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,389,1422950400"; d="scan'208";a="664379204" Received: from skumar40-ivm.iind.intel.com ([10.223.179.147]) by orsmga001.jf.intel.com with ESMTP; 12 Mar 2015 09:32:00 -0700 From: Shobhit Kumar To: intel-gfx Date: Thu, 12 Mar 2015 22:01:33 +0530 Message-Id: <1426177893-17945-10-git-send-email-shobhit.kumar@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1426177893-17945-1-git-send-email-shobhit.kumar@intel.com> References: <1426177893-17945-1-git-send-email-shobhit.kumar@intel.com> Cc: Alexandre Courbot , Samuel Ortiz , Jani Nikula , Shobhit Kumar , Linus Walleij , Thierry Reding , Daniel Vetter Subject: [Intel-gfx] [RFC v5 9/9] drm/i915: Backlight control using CRC PMIC based PWM driver 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, T_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 CC: Samuel Ortiz Cc: Linus Walleij Cc: Alexandre Courbot Cc: Thierry Reding Signed-off-by: Shobhit Kumar --- drivers/gpu/drm/i915/intel_dsi.c | 25 +++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_dsi.h | 3 +++ 2 files changed, 28 insertions(+) diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c index 219421c..511446f 100644 --- a/drivers/gpu/drm/i915/intel_dsi.c +++ b/drivers/gpu/drm/i915/intel_dsi.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "i915_drv.h" #include "intel_drv.h" #include "intel_dsi.h" @@ -402,6 +403,10 @@ static void intel_dsi_enable(struct intel_encoder *encoder) intel_dsi_port_enable(encoder); } + + /* Enable the backlight with default PWM as programmed by BIOS */ + pwm_enable(intel_dsi->pwm); + pwm_config_alternate(intel_dsi->pwm, 0x7F, 100); } static void intel_dsi_pre_enable(struct intel_encoder *encoder) @@ -467,6 +472,11 @@ static void intel_dsi_pre_disable(struct intel_encoder *encoder) DRM_DEBUG_KMS("\n"); + /* Disable the backlight */ + pwm_config_alternate(intel_dsi->pwm, 0x7F, 0); + usleep_range(2000, 3000); + pwm_disable(intel_dsi->pwm); + if (is_vid_mode(intel_dsi)) { /* Send Shutdown command to the panel in LP mode */ for_each_dsi_port(port, intel_dsi->ports) @@ -971,6 +981,10 @@ static void intel_dsi_encoder_destroy(struct drm_encoder *encoder) if (intel_dsi->gpio_panel) gpiod_put(intel_dsi->gpio_panel); + /* dispose of the pwm */ + if (intel_dsi->pwm) + pwm_put(intel_dsi->pwm); + intel_encoder_destroy(encoder); } @@ -1098,6 +1112,17 @@ void intel_dsi_init(struct drm_device *dev) DRM_ERROR("Failed to own gpio for panel control\n"); intel_dsi->gpio_panel = NULL; } + + /* Get the PWM chip for backlight control */ + intel_dsi->pwm = pwm_get(dev->dev, "pwm_backlight"); + if (IS_ERR(intel_dsi->pwm)) { + DRM_ERROR("Faild to own the pwm chip\n"); + intel_dsi->pwm = NULL; + } else if (pwm_config_alternate(intel_dsi->pwm, 0x7F, 100) < 0) { + DRM_ERROR("Failed to configure the pwm chip\n"); + pwm_put(intel_dsi->pwm); + intel_dsi->pwm = NULL; + } } intel_encoder->type = INTEL_OUTPUT_DSI; diff --git a/drivers/gpu/drm/i915/intel_dsi.h b/drivers/gpu/drm/i915/intel_dsi.h index 8be75a7..d8ec9c1 100644 --- a/drivers/gpu/drm/i915/intel_dsi.h +++ b/drivers/gpu/drm/i915/intel_dsi.h @@ -52,6 +52,9 @@ struct intel_dsi { /* GPIO Desc for CRC based Panel control */ struct gpio_desc *gpio_panel; + /* PWM chip */ + struct pwm_device *pwm; + struct intel_connector *attached_connector; /* bit mask of ports being driven */