# Use a 7 inch TFT display with RoadRunner SOM 

<abstract>
This article explain how to manage a 7 inch TFT display using the DPI port of RoarRunner SOM
</abstract>

## Wirings

Data lines:

<img src="./rgb.jpg" width="620px">

Example of wiring in 666 mode with a TFT display:

| LCD 7 inch  |       |
|-------------|-------|	
|	 1 VLED-  |       |
|	 2 VLED+  |       |
|	 3 GND    |	GND   |
|	 4 3V3    | 3V3   |
|	 5 R0     |	GND   |
|	 6 R1     |	GND   |
|	 7 R2     |	PC22  |
|	 8 R3     |	PC23  |
|	 9 R4     |	PC24  |
|	10 R5     |	PC25  |
|	11 R6     |	PC26  |
|	12 R7     |	PC27  |
|	13 G0     |	GND   |
|	14 G1     |	GND   |
|	15 G2     |	PC16  |
|	16 G3 	  |	PC17  |
|	17 G4	  |	PC18  |
|	18 G5	  |	PC19  |
|	19 G6	  |	PC20  |
|	20 G7	  |	PC21  |
|	21 B0	  |	GND   |
|	22 B1	  |	GND   |
|	23 B2	  |	PC10  |
|	24 B3	  |	PC11  |
|	25 B4	  |	PC12  |
|	26 B5	  |	PC13  |
|	27 B6	  |	PC14  |
|	28 B7	  |	PC15  |
|	29 GND    |       |
|	30 PCLK	  |	PD0   |
|	31 DISP	  |	3V3   |
|	32 HSYNC  |	PC31  |
|	33 VSYNC  |	PC30  |
|	34 DE	  |	PD1   |
|	35 NC     |       |
|	36 GND	  |	GND   |
|	37 NC     |       |
|	38 NC     |       |
|	39 NC     |       |
|	40 NC     |       |

## Device tree apb section

	hlcdc: hlcdc@f0000000 {
		status = "okay";

		hlcdc-display-controller {

			pinctrl-names = "default";
			pinctrl-0 = <&pinctrl_lcd_base &pinctrl_lcd_rgb666>;

			port@0 {
				#address-cells = <1>;
				#size-cells = <0>;
				hlcdc_panel_output: endpoint@0 {
					reg = <0>;
					remote-endpoint = <&panel_input>;
				};
			};
		};
		
		hlcdc_pwm: hlcdc-pwm {
			pinctrl-names = "default";
			pinctrl-0 = <&pinctrl_lcd_pwm>;
		};
		
	};	

	backlight: backlight {
		compatible = "pwm-backlight";
		pwms = <&hlcdc_pwm 0 50000 0>;
		brightness-levels = <0 4 8 16 32 64 128 255>;
		default-brightness-level = <7>;
		power-supply = <&bl_reg>;
		status = "okay";
	};

	bl_reg: backlight_regulator {
		compatible = "regulator-fixed";
		regulator-name = "backlight-power-supply";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		status = "okay";
	};

	panel: panel {
		/* compatible = "pda,91-00156-a0", "simple-panel"; */
		compatible = "innolux,g070y2-l01", "simple-panel";
		backlight = <&backlight>;
		power-supply = <&panel_reg>;
		#address-cells = <1>;
		#size-cells = <0>;
		status = "okay";

		port@0 {
			reg = <0>;
			#address-cells = <1>;
			#size-cells = <0>;

			panel_input: endpoint@0 {
				reg = <0>;
				remote-endpoint = <&hlcdc_panel_output>;
			};
		};
	};

	panel_reg: panel_regulator {
		compatible = "regulator-fixed";
		regulator-name = "panel-power-supply";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		status = "okay";
	};

	i2c0: i2c@f8028000 {
		dmas = <0>, <0>;
		pinctrl-names = "default","gpio";
		pinctrl-0 = <&pinctrl_i2c0_default>;
		pinctrl-1 = <&pinctrl_i2c0_gpio>;
		i2c-analog-filter;
		i2c-digital-filter;
		i2c-digital-filter-width-ns = <35>;
		sda-gpios = <&pioA PIN_PD21 GPIO_ACTIVE_HIGH>;
		scl-gpios = <&pioA PIN_PD22 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
		status = "disabled";
		
		gt9271: gt9271@5d {
				compatible = "goodix,gt9271";
				reg = <0x5D>;
				interrupt-parent = <&pioA>;
				interrupts = <PIN_PC7 IRQ_TYPE_LEVEL_LOW>;
		};
		
	};


## Device tree - pinctrl@fc038000 section

	pinctrl_lcd_base: pinctrl_lcd_base {
		pinmux = <PIN_PC30__LCDVSYNC>,
			 <PIN_PC31__LCDHSYNC>,
			 <PIN_PD1__LCDDEN>,
			 <PIN_PD0__LCDPCK>;
		bias-disable;
		/* atmel,drive-strength = <ATMEL_PIO_DRVSTR_ME>; */
	};


	pinctrl_lcd_rgb666: pinctrl_lcd_rgb666 {
		pinmux = <PIN_PC10__LCDDAT2>,
			 <PIN_PC11__LCDDAT3>,
			 <PIN_PC12__LCDDAT4>,
			 <PIN_PC13__LCDDAT5>,
			 <PIN_PC14__LCDDAT6>,
			 <PIN_PC15__LCDDAT7>,
			 <PIN_PC16__LCDDAT10>,
			 <PIN_PC17__LCDDAT11>,
			 <PIN_PC18__LCDDAT12>,
			 <PIN_PC19__LCDDAT13>,
			 <PIN_PC20__LCDDAT14>,
			 <PIN_PC21__LCDDAT15>,
			 <PIN_PC22__LCDDAT18>,
			 <PIN_PC23__LCDDAT19>,
			 <PIN_PC24__LCDDAT20>,
			 <PIN_PC25__LCDDAT21>,
			 <PIN_PC26__LCDDAT22>,
			 <PIN_PC27__LCDDAT23>;
		bias-disable;
	};

	pinctrl_lcd_pwm: pinctrl_lcd_pwm {
		pinmux = <PIN_PC28__LCDPWM>;
		bias-disable;
	};
## Datasheet 

* [Toutch interface Godix GT9271](https://www.distec.de/fileadmin/pdf/produkte/Touchcontroller/DDGroup/GT9271_Datasheet.pdf)

## Device tree

Working example of dts

* [acme-roadrunner-panel.dts](./acme-roadrunner-panel.dts)


## Links

* [How to install Microchip Ensemble Graphics Toolkit](https://github.com/linux4sam/egt)
* [egt repository](https://github.com/linux4sam/egt)
* [egt-samples repository](https://github.com/linux4sam/egt-samples)
 
@include='adv_roadrunner'


