1 /*
2  * Copyright (c) 2006-2023, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2021-01-11     Lyons        first version
9  * 2021-06-24     RiceChen     refactor
10  */
11 
12 #ifndef __DRV_LCD_H__
13 #define __DRV_LCD_H__
14 
15 #include <board.h>
16 #include "drv_pin.h"
17 #include "drv_common.h"
18 
19 #include "fsl_iomuxc.h"
20 #include "fsl_clock.h"
21 #include "fsl_elcdif.h"
22 
23 #define LCD_GPIO_MAX               29
24 #define LCD_MUX_BASE                0x020E0104U
25 #define LCD_CONFIG_BASE             0x020E0390U
26 
27 #define LCD_WIDTH                   BSP_LCD_WIDTH
28 #define LCD_HEIGHT                  BSP_LCD_HEIGHT
29 #define LCD_VSW                     BSP_LCD_VSW
30 #define LCD_VBP                     BSP_LCD_VBP
31 #define LCD_VFP                     BSP_LCD_VFP
32 #define LCD_HSW                     BSP_LCD_HSW
33 #define LCD_HBP                     BSP_LCD_HBP
34 #define LCD_HFP                     BSP_LCD_HFP
35 #define LCD_PLL_DIV                 BSP_LCD_PLL_DIV
36 
37 #define LCD_BITS_PER_PIXEL          32
38 #define LCD_BUF_SIZE                (LCD_WIDTH * LCD_HEIGHT * LCD_BITS_PER_PIXEL / 8)
39 
40 #define IMX6ULL_LCD_BL_PIN          GET_PIN(1, 8)
41 
42 struct fb_fix_screen_info
43 {
44     rt_uint32_t shamem_start;
45     rt_uint32_t shamem_len;
46 };
47 
48 struct lcd_info
49 {
50     struct rt_device_graphic_info graphic;
51     struct fb_fix_screen_info screen;
52 };
53 
54 struct imx6ull_lcd_config
55 {
56     LCDIF_Type *ELCDIF;
57     char *name;
58 
59     rt_uint32_t apd_clk_name;
60     rt_uint32_t pix_clk_name;
61 
62     rt_uint32_t lcd_mux_base;
63     rt_uint32_t lcd_cfg_base;
64 };
65 
66 struct imx6ull_lcd_bus
67 {
68     struct rt_device parent;
69     struct rt_device_graphic_info info;
70 
71     struct imx6ull_lcd_config *config;
72 
73     rt_uint8_t *fb_phy;
74     rt_uint8_t *fb_virt;
75 };
76 
77 #ifdef BSP_USING_LCD
78 #define LCD_BUS_CONFIG                             \
79     {                                               \
80         .ELCDIF        = LCDIF,                     \
81         .name         = "lcd",                     \
82         .apd_clk_name = kCLOCK_Lcd,                 \
83         .pix_clk_name = kCLOCK_Lcdif1,              \
84         .lcd_mux_base = LCD_MUX_BASE,               \
85         .lcd_cfg_base = LCD_CONFIG_BASE,            \
86     }
87 #endif /* BSP_USING_LCD */
88 
89 
90 #endif
91