From patchwork Sat Jul 29 19:17:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 9870093 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 328B5603FA for ; Sat, 29 Jul 2017 19:20:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20E972880B for ; Sat, 29 Jul 2017 19:20:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F7CC2880D; Sat, 29 Jul 2017 19:20:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 889AA287FF for ; Sat, 29 Jul 2017 19:20:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752164AbdG2TTe (ORCPT ); Sat, 29 Jul 2017 15:19:34 -0400 Received: from vern.gendns.com ([206.190.152.46]:51012 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751614AbdG2TSM (ORCPT ); Sat, 29 Jul 2017 15:18:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject :Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=NcPWUievBzHMAFdf57DkgSnURooenw+VRvyCqZpbG8Y=; b=Te4aN6/v3Rx14/T5CUi38jF7B C4X76HUD2N7J1o7rr2Ag3KFORE5DCDKoXzoxEq3Sf90zAe4iRs7iNGXlI85QTdpWTdC33WR/PxTJX /FvJ/8tnJ7TNXvR2mKcLVT2+xBVcOm5y0IAaJDERtcQHI7ge2qyyfFFWNjgfZUgKNqaH4YLsBMX9H 7FEHqb3wkM/gXKHCjlQiu+8u2EcMfnl/CmnX8tuMCpeQJ2beYMYh0xKIoRDrxVQY8qMbRnILrf8jf 2BzI29I0QRBHtM2+BIXJ0oBhqgQSuRI1pVEo5tPP+3wEkWXbMd/O70FLO6EdMicB6/f+DdDWd941g M2hykvzGg==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:58148 helo=freyr.lechnology.com) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-SHA256:128) (Exim 4.89) (envelope-from ) id 1dbXCz-000DrP-S3; Sat, 29 Jul 2017 15:15:30 -0400 From: David Lechner To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org Cc: David Lechner , =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= , David Airlie , Rob Herring , Mark Rutland , Sekhar Nori , Kevin Hilman , linux-fbdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] drm/tinydrm: add support for LEGO MINDSTORMS EV3 LCD Date: Sat, 29 Jul 2017 14:17:49 -0500 Message-Id: <1501355870-13960-6-git-send-email-david@lechnology.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501355870-13960-1-git-send-email-david@lechnology.com> References: <1501355870-13960-1-git-send-email-david@lechnology.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP LEGO MINDSTORMS EV3 has an LCD with a ST7586 controller. This adds a new module for the ST7586 controller with parameters for the EV3 LCD dispay. Signed-off-by: David Lechner --- .../devicetree/bindings/display/mipi-panel.txt | 2 +- drivers/gpu/drm/tinydrm/Kconfig | 1 + drivers/gpu/drm/tinydrm/mipi-panel.c | 87 ++++++++++++++++++++++ include/drm/tinydrm/st7586.h | 34 +++++++++ 4 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 include/drm/tinydrm/st7586.h diff --git a/Documentation/devicetree/bindings/display/mipi-panel.txt b/Documentation/devicetree/bindings/display/mipi-panel.txt index 01d6ea9..ba8c8ab 100644 --- a/Documentation/devicetree/bindings/display/mipi-panel.txt +++ b/Documentation/devicetree/bindings/display/mipi-panel.txt @@ -1,7 +1,7 @@ MIPI DBI compatible display panel Required properties: -- compatible: "multi-inno,mi0283qt". +- compatible: one of "lego,ev3-lcd", "multi-inno,mi0283qt". The node for this driver must be a child node of a SPI controller, hence all mandatory properties described in ../spi/spi-bus.txt must be specified. diff --git a/drivers/gpu/drm/tinydrm/Kconfig b/drivers/gpu/drm/tinydrm/Kconfig index 394519b..6e90bb5 100644 --- a/drivers/gpu/drm/tinydrm/Kconfig +++ b/drivers/gpu/drm/tinydrm/Kconfig @@ -20,6 +20,7 @@ config TINYDRM_MIPI_PANEL DRM driver for the MIPI DBI compatible display panels. Supported panels include: + * LEGO MINDSTORMS EV3 * Multi-Inno MI0283QT If M is selected the module will be called mipi-panel. diff --git a/drivers/gpu/drm/tinydrm/mipi-panel.c b/drivers/gpu/drm/tinydrm/mipi-panel.c index 8aa1d8e..e3d5678 100644 --- a/drivers/gpu/drm/tinydrm/mipi-panel.c +++ b/drivers/gpu/drm/tinydrm/mipi-panel.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -23,6 +24,7 @@ enum mipi_panel_type { MIPI_PANEL_TYPE_UNKNOWN, + MIPI_PANEL_TYPE_LEGO_EV3_LCD, MIPI_PANEL_TYPE_MULTI_INNO_MI0283QT, }; @@ -125,6 +127,84 @@ static int mipi_panel_init_ili9341(struct mipi_dbi *mipi) return 0; } +static int mipi_panel_init_st7586(struct mipi_dbi *mipi) +{ + struct tinydrm_device *tdev = &mipi->tinydrm; + struct device *dev = tdev->drm->dev; + u8 addr_mode; + int ret; + + DRM_DEBUG_KMS("\n"); + + ret = regulator_enable(mipi->regulator); + if (ret) { + dev_err(dev, "Failed to enable regulator %d\n", ret); + return ret; + } + + /* Avoid flicker by skipping setup if the bootloader has done it */ + if (mipi_dbi_display_is_on(mipi)) + return 0; + + mipi_dbi_hw_reset(mipi); + ret = mipi_dbi_command(mipi, ST7586_AUTO_READ_CTRL, 0x9f); + if (ret) { + dev_err(dev, "Error sending command %d\n", ret); + regulator_disable(mipi->regulator); + return ret; + } + + mipi_dbi_command(mipi, ST7586_OTP_RW_CTRL, 0x00); + + msleep(10); + + mipi_dbi_command(mipi, ST7586_OTP_READ); + + msleep(20); + + mipi_dbi_command(mipi, ST7586_OTP_CTRL_OUT); + mipi_dbi_command(mipi, MIPI_DCS_EXIT_SLEEP_MODE); + mipi_dbi_command(mipi, MIPI_DCS_SET_DISPLAY_OFF); + + msleep(50); + + mipi_dbi_command(mipi, ST7586_SET_VOP_OFFSET, 0x00); + mipi_dbi_command(mipi, ST7586_SET_VOP, 0xe3, 0x00); + mipi_dbi_command(mipi, ST7586_SET_BIAS_SYSTEM, 0x02); + mipi_dbi_command(mipi, ST7586_SET_BOOST_LEVEL, 0x04); + mipi_dbi_command(mipi, ST7586_ENABLE_ANALOG, 0x1d); + mipi_dbi_command(mipi, ST7586_SET_NLINE_INV, 0x00); + mipi_dbi_command(mipi, ST7586_DISP_MODE_GRAY); + mipi_dbi_command(mipi, ST7586_ENABLE_DDRAM, 0x02); + + switch (mipi->rotation) { + default: + addr_mode = 0x00; + break; + case 90: + addr_mode = ST7586_DISP_CTRL_MY; + break; + case 180: + addr_mode = ST7586_DISP_CTRL_MX | ST7586_DISP_CTRL_MY; + break; + case 270: + addr_mode = ST7586_DISP_CTRL_MX; + break; + } + mipi_dbi_command(mipi, MIPI_DCS_SET_ADDRESS_MODE, addr_mode); + + mipi_dbi_command(mipi, ST7586_SET_DISP_DUTY, 0x7f); + mipi_dbi_command(mipi, ST7586_SET_PART_DISP, 0xa0); + mipi_dbi_command(mipi, MIPI_DCS_SET_PARTIAL_AREA, 0x00, 0x00, 0x00, 0x77); + mipi_dbi_command(mipi, MIPI_DCS_EXIT_INVERT_MODE); + + msleep(100); + + mipi_dbi_command(mipi, MIPI_DCS_SET_DISPLAY_ON); + + return 0; +} + static void mipi_panel_fini(void *data) { struct mipi_dbi *mipi = data; @@ -141,6 +221,11 @@ static const struct drm_simple_display_pipe_funcs mipi_panel_pipe_funcs = { }; static const struct mipi_panel_info mipi_panel_infos[] = { + [MIPI_PANEL_TYPE_LEGO_EV3_LCD] = { + .init = mipi_panel_init_st7586, + .mode = { TINYDRM_MODE(178, 128, 37, 27) }, + .pixel_fmt = MIPI_DCS_PIXEL_FMT_ST7586_332, + }, [MIPI_PANEL_TYPE_MULTI_INNO_MI0283QT] = { .init = mipi_panel_init_ili9341, .mode = { TINYDRM_MODE(320, 240, 58, 43) }, @@ -165,12 +250,14 @@ static struct drm_driver mipi_panel_driver = { }; static const struct of_device_id mipi_panel_of_match[] = { + { .compatible = "lego,ev3-lcd" }, { .compatible = "multi-inno,mi0283qt" }, {}, }; MODULE_DEVICE_TABLE(of, mipi_panel_of_match); static const struct spi_device_id mipi_panel_id[] = { + { "ev3-lcd", MIPI_PANEL_TYPE_LEGO_EV3_LCD }, { "mi0283qt", MIPI_PANEL_TYPE_MULTI_INNO_MI0283QT }, { }, }; diff --git a/include/drm/tinydrm/st7586.h b/include/drm/tinydrm/st7586.h new file mode 100644 index 0000000..18fb56b --- /dev/null +++ b/include/drm/tinydrm/st7586.h @@ -0,0 +1,34 @@ +/* + * ST7586 LCD controller + * + * Copyright (C) 2017 David Lechner + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#ifndef __LINUX_ST7856_H +#define __LINUX_ST7856_H + +#define ST7586_DISP_MODE_GRAY 0x38 +#define ST7586_DISP_MODE_MONO 0x39 +#define ST7586_ENABLE_DDRAM 0x3a +#define ST7586_SET_DISP_DUTY 0xb0 +#define ST7586_SET_PART_DISP 0xb4 +#define ST7586_SET_NLINE_INV 0xb5 +#define ST7586_SET_VOP 0xc0 +#define ST7586_SET_BIAS_SYSTEM 0xc3 +#define ST7586_SET_BOOST_LEVEL 0xc4 +#define ST7586_SET_VOP_OFFSET 0xc7 +#define ST7586_ENABLE_ANALOG 0xd0 +#define ST7586_AUTO_READ_CTRL 0xd7 +#define ST7586_OTP_RW_CTRL 0xe0 +#define ST7586_OTP_CTRL_OUT 0xe1 +#define ST7586_OTP_READ 0xe3 + +#define ST7586_DISP_CTRL_MX BIT(6) +#define ST7586_DISP_CTRL_MY BIT(7) + +#endif /* __LINUX_ST7856_H */