From patchwork Fri Dec 26 10:23:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kumar, Shobhit" X-Patchwork-Id: 5542711 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E39BA9F2E2 for ; Fri, 26 Dec 2014 10:21:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 03F6E20155 for ; Fri, 26 Dec 2014 10:21:06 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id E831A201C7 for ; Fri, 26 Dec 2014 10:21:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8495A6E170; Fri, 26 Dec 2014 02:21:04 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id F202A6E18D for ; Fri, 26 Dec 2014 02:21:02 -0800 (PST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP; 26 Dec 2014 02:19:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,691,1406617200"; d="scan'208";a="504280411" Received: from shobhit-desk.iind.intel.com ([10.223.25.24]) by orsmga003.jf.intel.com with ESMTP; 26 Dec 2014 02:16:08 -0800 From: Shobhit Kumar To: intel-gfx Date: Fri, 26 Dec 2014 15:53:28 +0530 Message-Id: <1419589410-24365-3-git-send-email-shobhit.kumar@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1419589410-24365-1-git-send-email-shobhit.kumar@intel.com> References: <1419589410-24365-1-git-send-email-shobhit.kumar@intel.com> MIME-Version: 1.0 Cc: Jani Nikula , Daniel Vetter , Shobhit Kumar Subject: [Intel-gfx] [RFC 2/4] drm/i915: Add a drm_panel over INTEL_SOC_PMIC 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: , 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 This driver just add PANEL_ENABLE/DISABLE control using drm_panel framework. Signed-off-by: Shobhit Kumar --- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/intel_drv.h | 3 + drivers/gpu/drm/i915/intel_panel_pmic.c | 157 ++++++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+) create mode 100644 drivers/gpu/drm/i915/intel_panel_pmic.c diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 1849ffa..d282476 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -79,6 +79,7 @@ i915-y += dvo_ch7017.o \ intel_i2c.o \ intel_lvds.o \ intel_panel.o \ + intel_panel_pmic.o \ intel_sdvo.o \ intel_tv.o diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 0088f16..1dab753 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -1142,6 +1142,9 @@ extern struct drm_display_mode *intel_find_panel_downclock( void intel_backlight_register(struct drm_device *dev); void intel_backlight_unregister(struct drm_device *dev); +/* intel_panel_soc_pmic.c */ +struct drm_panel *intel_panel_pmic_init(struct device *dev, + struct panel_info *info); /* intel_psr.c */ void intel_psr_enable(struct intel_dp *intel_dp); diff --git a/drivers/gpu/drm/i915/intel_panel_pmic.c b/drivers/gpu/drm/i915/intel_panel_pmic.c new file mode 100644 index 0000000..28a9f00 --- /dev/null +++ b/drivers/gpu/drm/i915/intel_panel_pmic.c @@ -0,0 +1,157 @@ +/* + * Copyright © 2006-2014 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Shobhit Kumar + */ + +#include +#include +#include +#include +#include "intel_drv.h" + +#define PMIC_PANEL_EN 0x52 +struct panel_pmic { + struct drm_panel base; + bool prepared; + bool enabled; + + /* Panel enable/disable specififc delays */ + struct panel_info pinfo; +}; + +static inline struct panel_pmic *to_panel_pmic(struct drm_panel *panel) +{ + return container_of(panel, struct panel_pmic, base); +} + +static int panel_pmic_disable(struct drm_panel *panel) +{ + struct panel_pmic *p = to_panel_pmic(panel); + + if (!p->enabled) + return 0; + + DRM_DEBUG_KMS("\n"); + + /* invoke the pmic driver */ + intel_soc_pmic_writeb(PMIC_PANEL_EN, 0x00); + msleep(p->pinfo.panel_off_delay); + msleep(p->pinfo.panel_pwr_cycle_delay); + + p->enabled = false; + + return 0; +} + +static int panel_pmic_unprepare(struct drm_panel *panel) +{ + struct panel_pmic *p = to_panel_pmic(panel); + + if (!p->prepared) + return 0; + + /* Nothing needed */ + p->prepared = false; + + return 0; +} + +static int panel_pmic_prepare(struct drm_panel *panel) +{ + struct panel_pmic *p = to_panel_pmic(panel); + + if (p->prepared) + return 0; + + /* Nothing needed */ + p->prepared = true; + + return 0; +} + +static int panel_pmic_enable(struct drm_panel *panel) +{ + struct panel_pmic *p = to_panel_pmic(panel); + + if (p->enabled) + return 0; + + DRM_DEBUG_KMS("\n"); + + /* invoke the pmic driver */ + intel_soc_pmic_writeb(PMIC_PANEL_EN, 0x01); + msleep(p->pinfo.panel_on_delay); + + p->enabled = true; + + return 0; +} + +static const struct drm_panel_funcs panel_pmic_funcs = { + .disable = panel_pmic_disable, + .unprepare = panel_pmic_unprepare, + .prepare = panel_pmic_prepare, + .enable = panel_pmic_enable, +}; + +struct drm_panel *intel_panel_pmic_init(struct device *dev, + struct panel_info *info) +{ + struct panel_pmic *panel; + bool status = false; + + DRM_DEBUG_KMS("\n"); + + panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL); + if (!panel) + return NULL; + + status = intel_soc_pmic_readb(PMIC_PANEL_EN) ? true : false; + panel->enabled = panel->prepared = status; + + memcpy(&panel->pinfo, info, sizeof(struct panel_info)); + + drm_panel_init(&panel->base); + panel->base.dev = dev; + panel->base.funcs = &panel_pmic_funcs; + + drm_panel_add(&panel->base); + + return &panel->base; +} + +int intel_panel_pmic_remove(struct device *dev) +{ + struct panel_pmic *panel = dev_get_drvdata(dev); + + DRM_DEBUG_KMS("\n"); + + drm_panel_detach(&panel->base); + drm_panel_remove(&panel->base); + + panel_pmic_disable(&panel->base); + + kfree(panel); + return 0; +}