blob: 0e296613cb3d2d0bcbe608131b0ef610b3912d1a
1 | /* |
2 | * include/amlogic/aml_lcd_extern.h |
3 | * |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by |
6 | * the Free Software Foundation; either version 2 of the named License, |
7 | * or any later version. |
8 | * |
9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. |
13 | * |
14 | */ |
15 | |
16 | #ifndef _INC_AML_LCD_EXTERN_H_ |
17 | #define _INC_AML_LCD_EXTERN_H_ |
18 | |
19 | #include <amlogic/aml_lcd_vout.h> |
20 | |
21 | enum lcd_extern_type_e { |
22 | LCD_EXTERN_I2C = 0, |
23 | LCD_EXTERN_SPI, |
24 | LCD_EXTERN_MIPI, |
25 | LCD_EXTERN_MAX, |
26 | }; |
27 | |
28 | #define LCD_EXTERN_I2C_BUS_A 0 |
29 | #define LCD_EXTERN_I2C_BUS_B 1 |
30 | #define LCD_EXTERN_I2C_BUS_C 2 |
31 | #define LCD_EXTERN_I2C_BUS_D 3 |
32 | #define LCD_EXTERN_I2C_BUS_AO 4 |
33 | |
34 | #define LCD_EXTERN_I2C_BUS_0 LCD_EXTERN_I2C_BUS_A |
35 | #define LCD_EXTERN_I2C_BUS_1 LCD_EXTERN_I2C_BUS_B |
36 | #define LCD_EXTERN_I2C_BUS_2 LCD_EXTERN_I2C_BUS_C |
37 | #define LCD_EXTERN_I2C_BUS_3 LCD_EXTERN_I2C_BUS_D |
38 | #define LCD_EXTERN_I2C_BUS_4 LCD_EXTERN_I2C_BUS_AO |
39 | #define LCD_EXTERN_I2C_BUS_MAX 5 |
40 | |
41 | |
42 | #define LCD_EXTERN_INIT_ON_MAX 3000 |
43 | #define LCD_EXTERN_INIT_OFF_MAX 100 |
44 | |
45 | #define LCD_EXTERN_GPIO_NUM_MAX 6 |
46 | #define LCD_EXTERN_GPIO_LEN_MAX 10 |
47 | #define LCD_EXTERN_INDEX_INVALID 0xff |
48 | #define LCD_EXTERN_NAME_LEN_MAX 30 |
49 | |
50 | #define LCD_EXTERN_NUM_MAX 20 |
51 | |
52 | struct lcd_extern_config_s { |
53 | unsigned char index; |
54 | char name[LCD_EXTERN_NAME_LEN_MAX]; |
55 | enum lcd_extern_type_e type; |
56 | unsigned char status; |
57 | unsigned char pinmux_valid; |
58 | unsigned char pinmux_gpio_off; |
59 | |
60 | unsigned char i2c_addr; |
61 | unsigned char i2c_addr2; |
62 | unsigned char i2c_bus; |
63 | unsigned char i2c_sck_gpio; |
64 | unsigned char i2c_sda_gpio; |
65 | |
66 | unsigned char spi_gpio_cs; |
67 | unsigned char spi_gpio_clk; |
68 | unsigned char spi_gpio_data; |
69 | unsigned char spi_clk_pol; |
70 | unsigned short spi_clk_freq; /*KHz */ |
71 | unsigned short spi_delay_us; |
72 | |
73 | unsigned char cmd_size; |
74 | unsigned char table_init_loaded; /* internal use */ |
75 | unsigned int table_init_on_cnt; |
76 | unsigned int table_init_off_cnt; |
77 | unsigned char *table_init_on; |
78 | unsigned char *table_init_off; |
79 | }; |
80 | |
81 | struct lcd_extern_common_s { |
82 | unsigned char lcd_ext_key_valid; |
83 | char gpio_name[LCD_EXTERN_GPIO_NUM_MAX][LCD_EXTERN_GPIO_LEN_MAX]; |
84 | unsigned int lcd_ext_num; |
85 | |
86 | unsigned char i2c_bus; |
87 | unsigned char i2c_sck_gpio; |
88 | unsigned char i2c_sck_gpio_off; |
89 | unsigned char i2c_sda_gpio; |
90 | unsigned char i2c_sda_gpio_off; |
91 | unsigned int pinmux_set[LCD_PINMUX_NUM][2]; |
92 | unsigned int pinmux_clr[LCD_PINMUX_NUM][2]; |
93 | }; |
94 | |
95 | //global API |
96 | struct aml_lcd_extern_driver_s { |
97 | struct lcd_extern_config_s *config; |
98 | struct lcd_extern_common_s *common; |
99 | int (*reg_read) (unsigned char reg, unsigned char *buf); |
100 | int (*reg_write) (unsigned char reg, unsigned char value); |
101 | int (*power_on)(void); |
102 | int (*power_off)(void); |
103 | void (*info_print)(void); |
104 | }; |
105 | |
106 | extern struct aml_lcd_extern_driver_s *aml_lcd_extern_get_driver(void); |
107 | extern int aml_lcd_extern_probe(char *dtaddr, int index); |
108 | extern int aml_lcd_extern_remove(void); |
109 | |
110 | extern struct lcd_extern_config_s ext_config_dtf[LCD_EXTERN_NUM_MAX]; |
111 | extern struct lcd_extern_common_s ext_common_dft; |
112 | |
113 | #endif |
114 | |
115 |