{"id":814761,"url":"http://patchwork.ozlabs.org/api/1.2/patches/814761/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20170918032145.25349-5-anarsoul@gmail.com/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.2/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170918032145.25349-5-anarsoul@gmail.com>","list_archive_url":null,"date":"2017-09-18T03:21:45","name":"[U-Boot,5/5] sunxi: video: add LCD support to DE2 driver","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"ea533162141cf16647b76b8c2db82c1fcf6135be","submitter":{"id":6930,"url":"http://patchwork.ozlabs.org/api/1.2/people/6930/?format=json","name":"Vasily Khoruzhick","email":"anarsoul@gmail.com"},"delegate":{"id":1700,"url":"http://patchwork.ozlabs.org/api/1.2/users/1700/?format=json","username":"ag","first_name":"Anatolij","last_name":"Gustschin","email":"agust@denx.de"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170918032145.25349-5-anarsoul@gmail.com/mbox/","series":[{"id":3555,"url":"http://patchwork.ozlabs.org/api/1.2/series/3555/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=3555","date":"2017-09-18T03:21:41","name":"[U-Boot,1/5] dm: video: bridge: add operation to read EDID","version":1,"mbox":"http://patchwork.ozlabs.org/series/3555/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/814761/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/814761/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"ifRlT8rH\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xwWb416k3z9ryr\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 18 Sep 2017 13:24:48 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid E7EAAC21ED8; Mon, 18 Sep 2017 03:23:35 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 640AFC21F03;\n\tMon, 18 Sep 2017 03:22:11 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 5061CC21EF7; Mon, 18 Sep 2017 03:22:05 +0000 (UTC)","from mail-pg0-f65.google.com (mail-pg0-f65.google.com\n\t[74.125.83.65])\n\tby lists.denx.de (Postfix) with ESMTPS id D23CCC21DE4\n\tfor <u-boot@lists.denx.de>; Mon, 18 Sep 2017 03:21:59 +0000 (UTC)","by mail-pg0-f65.google.com with SMTP id v82so4585832pgb.1\n\tfor <u-boot@lists.denx.de>; Sun, 17 Sep 2017 20:21:59 -0700 (PDT)","from anarsoul-thinkpad.lan (216-71-193-140.dyn.novuscom.net.\n\t[216.71.193.140]) by smtp.gmail.com with ESMTPSA id\n\t5sm11500606pfr.151.2017.09.17.20.21.57\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tSun, 17 Sep 2017 20:21:57 -0700 (PDT)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-0.0 required=5.0 tests=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID\n\tautolearn=unavailable autolearn_force=no version=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=SCXf1WleS9jSZ8TAgh98vTEnRQoHhnwZtukQd4s2XXI=;\n\tb=ifRlT8rHXLtyggxhxFsfgzaWxDb/YdNqJjjZ7I39QuKwdIK1yEIeaPbFTYpdlr+oIS\n\tzVvLTgUB+du+nFzQ8vANxkErr/Y7Kh5SmROue7dMGWDs5j/coRPnMV2a7LDrj9edWtQ+\n\tZLSHHwUYH2Tzb/2Sy7WURj7F5KiqPW94HSuTeMBo1n+FX3kQvwYUtQuzv2RkcobVKm7s\n\tThSUCDHD0OO7U5mZF+Do71xNAw5r2zc3x7MfAg3XnGBaEdPfQHV6oM871jqRq8tmREnQ\n\tNYGJnRh40963F6tdN3DtO1GMDCTu44PVkg+t3L4y02jZdUnAym3IGGzLfDr9q9wdAxGC\n\tt31A==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=SCXf1WleS9jSZ8TAgh98vTEnRQoHhnwZtukQd4s2XXI=;\n\tb=pJnnhYCmUjNCCCTL7lXVEM+W7zmqVg2LK66AxKTKVUBZL73mpvPgwC75NgH4PWDkQg\n\t3d+IHJ75ACgMB8VtHCxYR9U610CydH33Zr+YO/7z4OqoYPwXfi4iLHyztkDmG8E+TiEa\n\tnpHXWZMSRFKHN89LeH9tx7vAtrszUCd8IEExZIIJGYEs91X0lY3IbG0n7+9D8uBvqyvo\n\tfuaAoJhcaST4uut2IWWcFszObxzj9rt20x5DZ5/QdvREIgEmJ2Bcdc3BQlcCi61Sn1y/\n\tMBkDxEOKTgMjoHBPfCEWFSxaWoG2uXhGzBJzy9wa0Ab4jgsjIohwCFMfMUhmVm6Pq6Es\n\tpSMQ==","X-Gm-Message-State":"AHPjjUieXHYtN0d8ihcoBHbZ+xhl4YqIA1vy74uUI5Qin256z2k1xpX6\n\t1txArpIQW9r137hwaf0=","X-Google-Smtp-Source":"ADKCNb5+5xeZhm1CtD+efXLo7TlIrCKJ9N0v3yqTfkvf/H1U/9y1IDoRrDZcISLfJdsEleY2DVB4OA==","X-Received":"by 10.99.95.131 with SMTP id t125mr30985851pgb.172.1505704918329;\n\tSun, 17 Sep 2017 20:21:58 -0700 (PDT)","From":"Vasily Khoruzhick <anarsoul@gmail.com>","To":"u-boot@lists.denx.de,\n\tjernej.skrabec@siol.net,\n\ticenowy@aosc.io","Date":"Sun, 17 Sep 2017 20:21:45 -0700","Message-Id":"<20170918032145.25349-5-anarsoul@gmail.com>","X-Mailer":"git-send-email 2.14.1","In-Reply-To":"<20170918032145.25349-1-anarsoul@gmail.com>","References":"<20170918032145.25349-1-anarsoul@gmail.com>","Subject":"[U-Boot] [PATCH 5/5] sunxi: video: add LCD support to DE2 driver","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"Extend DE2 driver with LCD support\n\nSigned-off-by: Vasily Khoruzhick <anarsoul@gmail.com>\n---\n arch/arm/mach-sunxi/Kconfig     |   2 +-\n drivers/video/sunxi/Makefile    |   2 +-\n drivers/video/sunxi/sunxi_de2.c |  17 +++++\n drivers/video/sunxi/sunxi_lcd.c | 142 ++++++++++++++++++++++++++++++++++++++++\n 4 files changed, 161 insertions(+), 2 deletions(-)\n create mode 100644 drivers/video/sunxi/sunxi_lcd.c","diff":"diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig\nindex 2309f59999..06d697e3a7 100644\n--- a/arch/arm/mach-sunxi/Kconfig\n+++ b/arch/arm/mach-sunxi/Kconfig\n@@ -680,7 +680,7 @@ config VIDEO_LCD_MODE\n \n config VIDEO_LCD_DCLK_PHASE\n \tint \"LCD panel display clock phase\"\n-\tdepends on VIDEO\n+\tdepends on VIDEO || DM_VIDEO\n \tdefault 1\n \t---help---\n \tSelect LCD panel display clock phase shift, range 0-3.\ndiff --git a/drivers/video/sunxi/Makefile b/drivers/video/sunxi/Makefile\nindex 0d64c2021f..8c91766c24 100644\n--- a/drivers/video/sunxi/Makefile\n+++ b/drivers/video/sunxi/Makefile\n@@ -6,4 +6,4 @@\n #\n \n obj-$(CONFIG_VIDEO_SUNXI) += sunxi_display.o lcdc.o tve_common.o ../videomodes.o\n-obj-$(CONFIG_VIDEO_DE2) += sunxi_de2.o sunxi_dw_hdmi.o lcdc.o ../dw_hdmi.o\n+obj-$(CONFIG_VIDEO_DE2) += sunxi_de2.o sunxi_dw_hdmi.o lcdc.o ../dw_hdmi.o sunxi_lcd.o\ndiff --git a/drivers/video/sunxi/sunxi_de2.c b/drivers/video/sunxi/sunxi_de2.c\nindex ee67764ac5..a838bbacd1 100644\n--- a/drivers/video/sunxi/sunxi_de2.c\n+++ b/drivers/video/sunxi/sunxi_de2.c\n@@ -232,6 +232,23 @@ static int sunxi_de2_probe(struct udevice *dev)\n \tif (!(gd->flags & GD_FLG_RELOC))\n \t\treturn 0;\n \n+\tret = uclass_find_device_by_name(UCLASS_DISPLAY,\n+\t\t\t\t\t \"sunxi_lcd\", &disp);\n+\tif (!ret) {\n+\t\tint mux;\n+\n+\t\tmux = 0;\n+\n+\t\tret = sunxi_de2_init(dev, plat->base, VIDEO_BPP32, disp, mux,\n+\t\t                     false);\n+\t\tif (!ret) {\n+\t\t\tvideo_set_flush_dcache(dev, 1);\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n+\n+\tdebug(\"%s: lcd display not found (ret=%d)\\n\", __func__, ret);\n+\n \tret = uclass_find_device_by_name(UCLASS_DISPLAY,\n \t\t\t\t\t \"sunxi_dw_hdmi\", &disp);\n \tif (!ret) {\ndiff --git a/drivers/video/sunxi/sunxi_lcd.c b/drivers/video/sunxi/sunxi_lcd.c\nnew file mode 100644\nindex 0000000000..154eb5835e\n--- /dev/null\n+++ b/drivers/video/sunxi/sunxi_lcd.c\n@@ -0,0 +1,142 @@\n+/*\n+ * Allwinner LCD driver\n+ *\n+ * (C) Copyright 2017 Vasily Khoruzhick <anarsoul@gmail.com>\n+ *\n+ * SPDX-License-Identifier:\tGPL-2.0+\n+ */\n+\n+#include <common.h>\n+#include <display.h>\n+#include <video_bridge.h>\n+#include <backlight.h>\n+#include <dm.h>\n+#include <edid.h>\n+#include <asm/io.h>\n+#include <asm/arch/clock.h>\n+#include <asm/arch/lcdc.h>\n+#include <asm/arch/gpio.h>\n+#include <asm/gpio.h>\n+\n+struct sunxi_lcd_priv {\n+\tstruct display_timing timing;\n+\tint panel_bpp;\n+};\n+\n+static void sunxi_lcdc_config_pinmux(void)\n+{\n+\tint pin;\n+\tfor (pin = SUNXI_GPD(0); pin <= SUNXI_GPD(21); pin++) {\n+\t\tsunxi_gpio_set_cfgpin(pin, SUNXI_GPD_LCD0);\n+\t\tsunxi_gpio_set_drv(pin, 3);\n+\t}\n+}\n+\n+static int sunxi_lcd_enable(struct udevice *dev, int bpp,\n+                           const struct display_timing *edid)\n+{\n+\tstruct sunxi_ccm_reg * const ccm =\n+\t       (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;\n+\tstruct sunxi_lcdc_reg * const lcdc =\n+\t       (struct sunxi_lcdc_reg *)SUNXI_LCD0_BASE;\n+\tstruct sunxi_lcd_priv *priv = dev_get_priv(dev);\n+\tstruct udevice *backlight;\n+\tint clk_div, clk_double, ret;\n+\n+\t/* Reset off */\n+\tsetbits_le32(&ccm->ahb_reset1_cfg, 1 << AHB_RESET_OFFSET_LCD0);\n+\n+\t/* Clock on */\n+\tsetbits_le32(&ccm->ahb_gate1, 1 << AHB_GATE_OFFSET_LCD0);\n+\n+\tlcdc_init(lcdc);\n+\tsunxi_lcdc_config_pinmux();\n+\tlcdc_pll_set(ccm, 0, edid->pixelclock.typ / 1000,\n+\t             &clk_div, &clk_double);\n+\tlcdc_tcon0_mode_set(lcdc, edid, clk_div, false,\n+\t                    priv->panel_bpp, CONFIG_VIDEO_LCD_DCLK_PHASE);\n+\tlcdc_enable(lcdc, priv->panel_bpp);\n+\n+\tret = uclass_get_device(UCLASS_PANEL_BACKLIGHT, 0, &backlight);\n+\tif (!ret)\n+\t\tbacklight_enable(backlight);\n+\n+\treturn 0;\n+}\n+\n+static int sunxi_lcd_read_timing(struct udevice *dev,\n+                                struct display_timing *timing)\n+{\n+\tstruct sunxi_lcd_priv *priv = dev_get_priv(dev);\n+\tmemcpy(timing, &priv->timing, sizeof(struct display_timing));\n+\n+\treturn 0;\n+}\n+\n+static int sunxi_lcd_probe(struct udevice *dev)\n+{\n+\tstruct udevice *cdev;\n+\tstruct sunxi_lcd_priv *priv = dev_get_priv(dev);\n+\tint ret;\n+\n+\t/* make sure that clock is active */\n+\tclock_set_pll10(432000000);\n+\n+#ifdef CONFIG_VIDEO_BRIDGE\n+\t/* Try to get timings from bridge first */\n+\tret = uclass_get_device(UCLASS_VIDEO_BRIDGE, 0, &cdev);\n+\tif (!ret) {\n+\t\tu8 edid[EDID_SIZE];\n+\t\tint channel_bpp;\n+\n+\t\tret = video_bridge_attach(cdev);\n+\t\tif (ret) {\n+\t\t\tdebug(\"video bridge attach failed: %d\\n\", ret);\n+\t\t\treturn ret;\n+\t\t}\n+\t\tret = video_bridge_read_edid(cdev, edid, EDID_SIZE);\n+\t\tif (ret <= 0) {\n+\t\t\tdebug(\"video bridge failed to read edid: %d\\n\", ret);\n+\t\t\treturn ret ? ret : -EIO;\n+\t\t}\n+\t\tret = edid_get_timing(edid, ret, &priv->timing, &channel_bpp);\n+\t\tpriv->panel_bpp = channel_bpp * 3;\n+\t\treturn ret;\n+\t}\n+\tdebug(\"video bridge not found: %d\\n\", ret);\n+#endif\n+\t/* Fallback to timings from DT if there's no bridge */\n+\tret = uclass_get_device(UCLASS_PANEL, 0, &cdev);\n+\tif (ret) {\n+\t\tdebug(\"video panel not found: %d\\n\", ret);\n+\t\treturn ret;\n+\t}\n+\n+\tif (fdtdec_decode_display_timing(gd->fdt_blob, dev_of_offset(cdev),\n+\t\t\t\t\t 0, &priv->timing)) {\n+\t\tdebug(\"%s: Failed to decode display timing\\n\", __func__);\n+\t\treturn -EINVAL;\n+\t}\n+\tpriv->panel_bpp = 16;\n+\n+\treturn 0;\n+}\n+\n+static const struct dm_display_ops sunxi_lcd_ops = {\n+       .read_timing = sunxi_lcd_read_timing,\n+       .enable = sunxi_lcd_enable,\n+};\n+\n+U_BOOT_DRIVER(sunxi_lcd) = {\n+\t.name   = \"sunxi_lcd\",\n+\t.id     = UCLASS_DISPLAY,\n+\t.ops    = &sunxi_lcd_ops,\n+\t.probe  = sunxi_lcd_probe,\n+\t.priv_auto_alloc_size = sizeof(struct sunxi_lcd_priv),\n+};\n+\n+#ifdef CONFIG_MACH_SUN50I\n+U_BOOT_DEVICE(sunxi_lcd) = {\n+\t.name = \"sunxi_lcd\"\n+};\n+#endif\n","prefixes":["U-Boot","5/5"]}