blob: 044e5beecc3393ed61e5ad59697806b94a0e6b01
1 | /* |
2 | * include/amlogic/aml_bl_ldim.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_BL_LDIM_H |
17 | #define INC_AML_BL_LDIM_H |
18 | |
19 | #include <common.h> |
20 | #include <linux/list.h> |
21 | #include <amlogic/aml_lcd.h> |
22 | #include <spi.h> |
23 | |
24 | enum ldim_dev_type_e { |
25 | LDIM_DEV_TYPE_NORMAL = 0, |
26 | LDIM_DEV_TYPE_SPI, |
27 | LDIM_DEV_TYPE_I2C, |
28 | LDIM_DEV_TYPE_MAX, |
29 | }; |
30 | |
31 | #define LDIM_INIT_ON_MAX 300 |
32 | #define LDIM_INIT_OFF_MAX 20 |
33 | |
34 | struct ldim_pinmux_ctrl_s { |
35 | char *name; |
36 | unsigned int pinmux_set[LCD_PINMUX_NUM][2]; |
37 | unsigned int pinmux_clr[LCD_PINMUX_NUM][2]; |
38 | }; |
39 | |
40 | struct ldim_config_s { |
41 | unsigned char row; |
42 | unsigned char col; |
43 | }; |
44 | |
45 | struct ldim_dev_config_s { |
46 | char name[20]; |
47 | char pinmux_name[20]; |
48 | unsigned char type; |
49 | int cs_hold_delay; |
50 | int cs_clk_delay; |
51 | int en_gpio; |
52 | int en_gpio_on; |
53 | int en_gpio_off; |
54 | int lamp_err_gpio; |
55 | unsigned char fault_check; |
56 | unsigned char write_check; |
57 | |
58 | unsigned int dim_min; |
59 | unsigned int dim_max; |
60 | |
61 | unsigned char init_loaded; |
62 | unsigned char cmd_size; |
63 | unsigned char *init_on; |
64 | unsigned char *init_off; |
65 | unsigned int init_on_cnt; |
66 | unsigned int init_off_cnt; |
67 | |
68 | unsigned char pinctrl_ver; |
69 | struct ldim_pinmux_ctrl_s *ldim_pinmux; |
70 | struct bl_pwm_config_s pwm_config; |
71 | char gpio_name[BL_GPIO_NUM_MAX][LCD_CPU_GPIO_NAME_MAX]; |
72 | |
73 | unsigned short bl_regnum; |
74 | }; |
75 | |
76 | #define LDIM_SPI_NAME_MAX 30 |
77 | struct ldim_spi_dev_info_s { |
78 | char modalias[20]; |
79 | char spi_name[LDIM_SPI_NAME_MAX]; |
80 | int mode; |
81 | int max_speed_hz; |
82 | int bus_num; |
83 | int chip_select; |
84 | int wordlen; |
85 | |
86 | struct spi_slave *spi; |
87 | }; |
88 | |
89 | /*******global API******/ |
90 | struct aml_ldim_driver_s { |
91 | int valid_flag; |
92 | int dev_index; |
93 | struct ldim_config_s *ldim_conf; |
94 | struct ldim_dev_config_s *ldev_conf; |
95 | unsigned short *ldim_matrix_buf; |
96 | int (*power_on)(void); |
97 | int (*power_off)(void); |
98 | int (*set_level)(unsigned int level); |
99 | void (*config_print)(void); |
100 | int (*pinmux_ctrl)(int status); |
101 | void (*device_config_print)(void); |
102 | int (*device_power_on)(void); |
103 | int (*device_power_off)(void); |
104 | int (*device_bri_update)(unsigned short *buf, unsigned char len); |
105 | struct ldim_spi_dev_info_s *spi_info; |
106 | }; |
107 | |
108 | extern struct ldim_dev_config_s ldim_config_dft; |
109 | |
110 | extern struct aml_ldim_driver_s *aml_ldim_get_driver(void); |
111 | extern int aml_ldim_probe(char *dt_addr, int flag); /* flag: 0=dts, 1=bsp, 2=unifykey */ |
112 | |
113 | #endif /* INC_AML_BL_LDIM_H */ |
114 |