Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1553410ybz; Thu, 30 Apr 2020 01:11:07 -0700 (PDT) X-Google-Smtp-Source: APiQypLVPwE25E24JJZ/tStg90Kjtw9srAVz3BzeZVPTheiME6qvjgz3lB66YoDCBZG9+GG0G2Yt X-Received: by 2002:a50:e8c1:: with SMTP id l1mr1580621edn.81.1588234267202; Thu, 30 Apr 2020 01:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588234267; cv=none; d=google.com; s=arc-20160816; b=AXRNabpYT932QaEGQUvh/gF0M1kW23hKSnv1nuwgfJLcTR9aCHJU15+2AYnBUDjnTl lBjAgp6LgE6bVNNfs3DTCgyru74/lg61+6VNMqML6cO1ZXR6vAlSlZMJbKIzJALcm05K RfwFRoKESq4eo+cPIzRFOwssNqG3LuMMOi+TJekOXxq7D53hxHNJiiCk/PT/EVRKoYEG 8/pHRdif0UYnEiAPCRPtEJmHl51099CCjUnzh2NF7C8xSGNxFGujDwd8a2nVomX1V4vT l8PUMuUs29ocClHjhApxhJvODjTw7QACPnWZdAd7M1swbjptr354N3U6Hww7ggOWDEo5 /f5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=rqOYeWT+h/7+o8G19R8rphcsNjupExGTxIzkpepUzt4=; b=o42UBQAL0eL5mW2qygB7gXAIvas37fqhgLjLgcaxEt5TYHwdqYExcEn1mytneGQsF8 oBqlD8tUEiK/h/KssRFMsuiCl3KyRx9k0Xm0XyPpVcmdEncGXMd626BsIQdzLGcFa7oT z73IuL8lQaxyzXzNNgODw6lfG6N/Ko12EhT5a1oRCB2toKCYBrnXJbAhbYJr3F+WJsb/ 5Zv5TSGEiCp/vPIPGUnFwVTAyYmD8KpfKPD6cSekLo+rwpqSvjSjd6pm5OUpC6DsaCwd 1LJGN4VowamQFfLEzcX2v9IICVGDZditwxtnuKyyeMvA4ADoa6/gOvT/gXfp7hQHBuw2 tVXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gR4e+V+5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lc17si5293119ejb.413.2020.04.30.01.10.42; Thu, 30 Apr 2020 01:11:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gR4e+V+5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727792AbgD3IIK (ORCPT + 99 others); Thu, 30 Apr 2020 04:08:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726424AbgD3IIJ (ORCPT ); Thu, 30 Apr 2020 04:08:09 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75FF9C035494; Thu, 30 Apr 2020 01:08:08 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id a7so396718pju.2; Thu, 30 Apr 2020 01:08:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=rqOYeWT+h/7+o8G19R8rphcsNjupExGTxIzkpepUzt4=; b=gR4e+V+5EgJnMOnQ0hexP4GPEOj68hqlc5DMzW/mZrKoIO2y1wLzRNmj0b3IM6Sk5e zoVoYGhg5hMFskTex7j5Wg61YFqVLZ6taprwZK62JhjFFSbb34A9YdN7PNBDgy8IDwB/ 5KObEb9k6Y97u8IivxZwCpdKdQN/CnP0aNMbpHXN4xHEFs0Xoakd65UNohK5OTPak/Bt mgO0ny/GAn1OX8UO2t7IPAZvfcOU3FJKADgUFWksntHYlFm1FhpS5UInn6C8jit3E961 x4Va/f4X0gno98LQR7e9RvQ/SXVWhkvp/oJ+wiBxRpbBZc1tpstezia/EI35txo4tUNK LZVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=rqOYeWT+h/7+o8G19R8rphcsNjupExGTxIzkpepUzt4=; b=prFhlDdbxPLhwCG73LqgCi9Quvdc0xc+5A4Q52GZFW29tvcGYkI0aPppgZu1BBrenl PwH0ttgGn/nc/tuTdwq+nfC0+fN+giF+fOcx+R9eY/wfbkWkNVPqLBp/jUwUmceTHB0d lA1j4Hq0RVM52XfvGIzvS3laXE/bJ+ArfNqPo9OXlr6faO66stSlFCdfeT5yBW2l07d2 iyy5OnqzKs7uLzwxjBGclfevxyQfHHAAkIEJJBtsZXIO2xBDht55lqdDjHTztIHLpGAW TX5QJnZl+bsVidMemkA7sSMzVRtnTkqv7wN7d8kxftqt38Lu2BEu1dyf7099a7K0rstd 8vfg== X-Gm-Message-State: AGi0PuaUD8j43RfnLcKJ/5jsUWnNcciAopUwqN0WJWydtYSDsHHrwiGO qAXOJ3o0JGS5SFvgtBPA9Dc= X-Received: by 2002:a17:90a:1501:: with SMTP id l1mr1516408pja.82.1588234087741; Thu, 30 Apr 2020 01:08:07 -0700 (PDT) Received: from fmin-OptiPlex-7060.nreal.work ([137.59.101.138]) by smtp.gmail.com with ESMTPSA id u14sm2507675pgh.71.2020.04.30.01.08.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Apr 2020 01:08:06 -0700 (PDT) From: dillon.minfei@gmail.com To: mcoquelin.stm32@gmail.com Cc: sam@ravnborg.org, airlied@linux.ie, daniel@ffwll.ch, robh+dt@kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alexandre.torgue@st.com, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, mturquette@baylibre.com, sboyd@kernel.org, thierry.reding@gmail.com, broonie@kernel.org, p.zabel@pengutronix.de, dillon.min@gmail.com, dillonhua@gmail.com, dillon min Subject: [PATCH] add drm panel driver for stm32f429-dicovery board the change details: Date: Thu, 30 Apr 2020 16:07:59 +0800 Message-Id: <1588234079-4157-1-git-send-email-dillon.minfei@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: dillon min 1) add support drm ili9341 panel driver connect to ltdc 2) add i2c3/spi5 ltdc pins dts configuration for gyro/stmpe 3) add SPI_SIMPLEX_RX/SPI_3WIRE_RX in spi-stm32f4.c for SPI_SIMPLEX_RX , as we running kernel in sdram, so that the performance is not as good as internal flash, need add send dummy data out while in rx, otherwise will get many overrun errors. 4) fix hang bugs durning ltdc driver load , in clk-stm32f4.c store clk_hw to the wrong offset PLL_VCO_SAI, PLL_VCO_I2S 5) add CLK_IGNORE_UNUSED for ltdc, otherwise system will close ltdc clk ======================= Signed-off-by: dillon min --- .../bindings/display/panel/ilitek,ili9341.txt | 43 ++ arch/arm/boot/dts/stm32f4-pinctrl.dtsi | 79 +++ arch/arm/boot/dts/stm32f429-disco.dts | 88 ++++ arch/arm/boot/dts/stm32f429.dtsi | 12 + drivers/clk/clk-stm32f4.c | 7 +- drivers/gpu/drm/panel/Kconfig | 8 + drivers/gpu/drm/panel/Makefile | 1 + drivers/gpu/drm/panel/panel-ilitek-ili9341.c | 561 +++++++++++++++++++++ drivers/spi/spi-stm32.c | 26 +- 9 files changed, 818 insertions(+), 7 deletions(-) create mode 100644 Documentation/devicetree/bindings/display/panel/ilitek,ili9341.txt create mode 100644 drivers/gpu/drm/panel/panel-ilitek-ili9341.c diff --git a/Documentation/devicetree/bindings/display/panel/ilitek,ili9341.txt b/Documentation/devicetree/bindings/display/panel/ilitek,ili9341.txt new file mode 100644 index 0000000..a03825f --- /dev/null +++ b/Documentation/devicetree/bindings/display/panel/ilitek,ili9341.txt @@ -0,0 +1,43 @@ +Ilitek ILI9341 TFT panel driver with SPI control bus + +This is a driver for 320x240 TFT panels, accepting a rgb input +streams that get adapted and scaled to the panel. +VCOMH outputs. + +Required properties: + - compatible: "stm32f429-disco,ltdc-panel", "ilitek,ili9341" + (full system-specific compatible is always required to look up configuration) + - reg: address of the panel on the SPI bus + +Optional properties: + - reset-gpios: a GPIO spec for the reset pin, see gpio/gpio.txt + - dc-gpios: a GPIO spec for the dc pin, see gpio/gpio.txt + + The following optional properties only apply to RGB input mode: + + - pixelclk-active: see display/panel/display-timing.txt + - de-active: see display/panel/display-timing.txt + - hsync-active: see display/panel/display-timing.txt + - vsync-active: see display/panel/display-timing.txt + +The panel must obey the rules for a SPI slave device as specified in +spi/spi-bus.txt + +The device node can contain one 'port' child node with one child +'endpoint' node, according to the bindings defined in +media/video-interfaces.txt. This node should describe panel's video bus. + +Example: + +panel: display@0 { + compatible = "stm32f429-disco,ltdc-panel", "ilitek,ili9341"; + reg = <0>; + spi-3wire; + spi-max-frequency = <10000000>; + dc-gpios = <&gpiod 13 0>; + port { + panel_in: endpoint { + remote-endpoint = <&display_out>; + }; + }; +}; diff --git a/arch/arm/boot/dts/stm32f4-pinctrl.dtsi b/arch/arm/boot/dts/stm32f4-pinctrl.dtsi index 392fa14..45b68f4 100644 --- a/arch/arm/boot/dts/stm32f4-pinctrl.dtsi +++ b/arch/arm/boot/dts/stm32f4-pinctrl.dtsi @@ -316,6 +316,85 @@ }; }; + ltdc_pins_f429_disco: ltdc-1 { + pins { + pinmux = , + /* LCD_HSYNC */ + , + /* LCD_VSYNC */ + , + /* LCD_CLK */ + , + /* LCD_R2 */ + , + /* LCD_R3 */ + , + /* LCD_R4 */ + , + /* LCD_R5 */ + , + /* LCD_R6*/ + , + /* LCD_R7 */ + , + /* LCD_G2 */ + , + /* LCD_G3 */ + , + /* LCD_G4 */ + , + /* LCD_B2 */ + , + /* LCD_B3*/ + , + /* LCD_G5 */ + , + /* LCD_G6 */ + , + /* LCD_G7 */ + , + /* LCD_B4 */ + , + /* LCD_B5 */ + , + /* LCD_B6 */ + , + /* LCD_B7 */ + ; + /* LCD_DE */ + slew-rate = <2>; + }; + }; + + i2c3_pins: i2c3-0 { + pins { + pinmux = , + /* I2C3_SDA */ + ; + /* I2C3_SCL */ + bias-disable; + drive-open-drain; + slew-rate = <3>; + }; + }; + + spi5_pins: spi5-0 { + pins1 { + pinmux = , + /* SPI5_CLK */ + ; + /* SPI5_MOSI */ + bias-disable; + drive-push-pull; + slew-rate = <0>; + }; + pins2 { + pinmux = ; + /* SPI5_MISO */ + bias-disable; + }; + }; + dcmi_pins: dcmi-0 { pins { pinmux = , /* DCMI_HSYNC */ diff --git a/arch/arm/boot/dts/stm32f429-disco.dts b/arch/arm/boot/dts/stm32f429-disco.dts index 30c0f67..55eed05 100644 --- a/arch/arm/boot/dts/stm32f429-disco.dts +++ b/arch/arm/boot/dts/stm32f429-disco.dts @@ -49,6 +49,8 @@ #include "stm32f429.dtsi" #include "stm32f429-pinctrl.dtsi" #include +#include +#include / { model = "STMicroelectronics STM32F429i-DISCO board"; @@ -98,6 +100,14 @@ regulator-name = "vcc5_host1"; regulator-always-on; }; + + reg_3p3v: regulator-3p3v { + compatible = "regulator-fixed"; + regulator-name = "3P3V"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + }; }; &clk_hse { @@ -127,3 +137,81 @@ pinctrl-names = "default"; status = "okay"; }; + +<dc { + status = "okay"; + pinctrl-0 = <<dc_pins_f429_disco>; + pinctrl-names = "default"; + + port { + ltdc_out_rgb: endpoint { + remote-endpoint = <&panel_in_rgb>; + }; + }; +}; + +&spi5 { + status = "okay"; + pinctrl-0 = <&spi5_pins>; + pinctrl-names = "default"; + #address-cells = <1>; + #size-cells = <0>; + cs-gpios = <&gpioc 1 GPIO_ACTIVE_LOW>,<&gpioc 2 GPIO_ACTIVE_LOW>; + dmas = <&dma2 3 2 0x400 0x0>, + <&dma2 4 2 0x400 0x0>; + dma-names = "rx", "tx"; + l3gd20: l3gd20@0 { + compatible = "st,l3gd20-gyro"; + spi-max-frequency = <10000000>; + st,drdy-int-pin = <2>; + interrupt-parent = <&gpioa>; + interrupts = <1 IRQ_TYPE_EDGE_RISING>, + <2 IRQ_TYPE_EDGE_RISING>; + reg = <0>; + vddio = <®_3p3v>; + vdd = <®_3p3v>; + status = "okay"; + }; + display: display@1{ + /* Connect panel-ilitek-9341 to ltdc */ + compatible = "stm32f429-disco,ltdc-panel", "ilitek,ili9341"; + reg = <1>; + spi-3wire; + spi-max-frequency = <10000000>; + dc-gpios = <&gpiod 13 0>; + port { + panel_in_rgb: endpoint { + remote-endpoint = <<dc_out_rgb>; + }; + }; + }; +}; + +&i2c3 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c3_pins>; + status = "okay"; + + touch: stmpe811@41 { + compatible = "st,stmpe811"; + reg = <0x41>; + interrupts = <15 IRQ_TYPE_EDGE_FALLING>; + interrupt-parent = <&gpioa>; + vio = <®_3p3v>; + vcc = <®_3p3v>; + status = "okay"; + + stmpe_touchscreen { + compatible = "st,stmpe-ts"; + st,sample-time = <4>; + st,mod-12b = <1>; + st,ref-sel = <0>; + st,adc-freq = <1>; + st,ave-ctrl = <1>; + st,touch-det-delay = <2>; + st,settling = <2>; + st,fraction-z = <7>; + st,i-drive = <1>; + }; + }; +}; diff --git a/arch/arm/boot/dts/stm32f429.dtsi b/arch/arm/boot/dts/stm32f429.dtsi index d777069..257b843 100644 --- a/arch/arm/boot/dts/stm32f429.dtsi +++ b/arch/arm/boot/dts/stm32f429.dtsi @@ -402,6 +402,18 @@ status = "disabled"; }; + i2c3: i2c@40005c00 { + compatible = "st,stm32f4-i2c"; + reg = <0x40005c00 0x400>; + interrupts = <72>, + <73>; + resets = <&rcc STM32F4_APB1_RESET(I2C3)>; + clocks = <&rcc 0 STM32F4_APB1_CLOCK(I2C3)>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + dac: dac@40007400 { compatible = "st,stm32f4-dac-core"; reg = <0x40007400 0x400>; diff --git a/drivers/clk/clk-stm32f4.c b/drivers/clk/clk-stm32f4.c index 18117ce..bdebe05 100644 --- a/drivers/clk/clk-stm32f4.c +++ b/drivers/clk/clk-stm32f4.c @@ -129,7 +129,8 @@ static const struct stm32f4_gate_data stm32f429_gates[] __initconst = { { STM32F4_RCC_APB2ENR, 20, "spi5", "apb2_div" }, { STM32F4_RCC_APB2ENR, 21, "spi6", "apb2_div" }, { STM32F4_RCC_APB2ENR, 22, "sai1", "apb2_div" }, - { STM32F4_RCC_APB2ENR, 26, "ltdc", "apb2_div" }, + { STM32F4_RCC_APB2ENR, 26, "ltdc", "apb2_div", + CLK_IGNORE_UNUSED }, }; static const struct stm32f4_gate_data stm32f469_gates[] __initconst = { @@ -1754,10 +1755,10 @@ static void __init stm32f4_rcc_init(struct device_node *np) stm32f4_rcc_register_pll("vco_in", &data->pll_data[0], &stm32f4_clk_lock); - clks[PLL_VCO_I2S] = stm32f4_rcc_register_pll("vco_in", + clks[PLL_I2S] = stm32f4_rcc_register_pll("vco_in", &data->pll_data[1], &stm32f4_clk_lock); - clks[PLL_VCO_SAI] = stm32f4_rcc_register_pll("vco_in", + clks[PLL_SAI] = stm32f4_rcc_register_pll("vco_in", &data->pll_data[2], &stm32f4_clk_lock); for (n = 0; n < MAX_POST_DIV; n++) { diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig index a1723c1..e42692c 100644 --- a/drivers/gpu/drm/panel/Kconfig +++ b/drivers/gpu/drm/panel/Kconfig @@ -95,6 +95,14 @@ config DRM_PANEL_ILITEK_IL9322 Say Y here if you want to enable support for Ilitek IL9322 QVGA (320x240) RGB, YUV and ITU-T BT.656 panels. +config DRM_PANEL_ILITEK_IL9341 + tristate "Ilitek ILI9341 240x320 QVGA panels" + depends on OF && SPI + select REGMAP + help + Say Y here if you want to enable support for Ilitek IL9341 + QVGA (240x320) RGB panels. + config DRM_PANEL_ILITEK_ILI9881C tristate "Ilitek ILI9881C-based panels" depends on OF diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile index 96a883c..d123543 100644 --- a/drivers/gpu/drm/panel/Makefile +++ b/drivers/gpu/drm/panel/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_DRM_PANEL_ELIDA_KD35T133) += panel-elida-kd35t133.o obj-$(CONFIG_DRM_PANEL_FEIXIN_K101_IM2BA02) += panel-feixin-k101-im2ba02.o obj-$(CONFIG_DRM_PANEL_FEIYANG_FY07024DI26A30D) += panel-feiyang-fy07024di26a30d.o obj-$(CONFIG_DRM_PANEL_ILITEK_IL9322) += panel-ilitek-ili9322.o +obj-$(CONFIG_DRM_PANEL_ILITEK_IL9341) += panel-ilitek-ili9341.o obj-$(CONFIG_DRM_PANEL_ILITEK_ILI9881C) += panel-ilitek-ili9881c.o obj-$(CONFIG_DRM_PANEL_INNOLUX_P079ZCA) += panel-innolux-p079zca.o obj-$(CONFIG_DRM_PANEL_JDI_LT070ME05000) += panel-jdi-lt070me05000.o diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9341.c b/drivers/gpu/drm/panel/panel-ilitek-ili9341.c new file mode 100644 index 0000000..0b2b17f --- /dev/null +++ b/drivers/gpu/drm/panel/panel-ilitek-ili9341.c @@ -0,0 +1,561 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Ilitek ILI9341 TFT LCD drm_panel driver. + * + * This panel can be configured to support: + * - 16-bit parallel RGB interface + * + * Copyright (C) 2020 Dillon Min + * Derived from drivers/drm/gpu/panel/panel-ilitek-ili9322.c + */ + +#include +#include +#include +#include +#include +#include +#include + +#include