Googler | 40bc9d0 | 2023-12-15 16:42:49 +0800 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */ |
| 2 | /* |
| 3 | * board/amlogic/gxl_p212_v1/lcd.c |
| 4 | * |
| 5 | * Copyright (C) 2020 Amlogic, Inc. All rights reserved. |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <amlogic/aml_lcd.h> |
| 11 | #include <asm/arch/gpio.h> |
| 12 | |
| 13 | //Rsv_val = 0xffffffff |
| 14 | |
| 15 | static char lcd_cpu_gpio[LCD_CPU_GPIO_NUM_MAX][LCD_CPU_GPIO_NAME_MAX] = { |
| 16 | "invalid", /* ending flag */ |
| 17 | }; |
| 18 | |
| 19 | static struct lcd_power_step_s lcd_power_on_step[] = { |
| 20 | {LCD_POWER_TYPE_SIGNAL,0,0,0,}, /* signal */ |
| 21 | {LCD_POWER_TYPE_MAX, 0,0,0,}, /* ending flag */ |
| 22 | }; |
| 23 | static struct lcd_power_step_s lcd_power_off_step[] = { |
| 24 | {LCD_POWER_TYPE_SIGNAL,0,0,50,}, /* signal */ |
| 25 | {LCD_POWER_TYPE_MAX, 0,0,0,}, /* ending flag */ |
| 26 | }; |
| 27 | |
| 28 | static char lcd_bl_gpio[BL_GPIO_NUM_MAX][LCD_CPU_GPIO_NAME_MAX] = { |
| 29 | "invalid", /* ending flag */ |
| 30 | }; |
| 31 | |
| 32 | struct ext_lcd_config_s ext_lcd_config[LCD_NUM_MAX] = { |
| 33 | { |
| 34 | "lcd_0",LCD_TTL,6, |
| 35 | /* basic timing */ |
| 36 | 1280,720,1650,750,40,220,1,5,20,1, |
| 37 | /* clk_attr */ |
| 38 | 0,0,1,74250000,Rsv_val,Rsv_val,Rsv_val,Rsv_val,Rsv_val,Rsv_val, |
| 39 | /* ttl_attr */ |
| 40 | 0,1,1,0,0,Rsv_val,Rsv_val,Rsv_val,Rsv_val,Rsv_val, |
| 41 | /* power step */ |
| 42 | lcd_power_on_step, lcd_power_off_step, |
| 43 | /* backlight */ |
| 44 | 60,255,10,128,128, |
| 45 | 0xff,0,1,0,200,200, |
| 46 | BL_PWM_POSITIVE,BL_PWM_B,180,100,25,1,0, |
| 47 | Rsv_val,Rsv_val,Rsv_val,Rsv_val,Rsv_val,Rsv_val,Rsv_val, |
| 48 | Rsv_val,Rsv_val,Rsv_val,Rsv_val, |
| 49 | 10,10,Rsv_val}, |
| 50 | }; |
| 51 | |
| 52 | //**** Special parameters just for ttl ***// |
| 53 | static struct ttl_config_s lcd_ttl_config = { |
| 54 | .clk_pol = 0, |
| 55 | .sync_valid = (1 << 1) | (1 << 0), /* [1]DE, [0]hvsync */ |
| 56 | .swap_ctrl = (0 << 1) | (0 << 0), /* [1]rb swap, [0]bit swap */ |
| 57 | }; |
| 58 | |
| 59 | //**** Special parameters just for lvds ***// |
| 60 | static struct lvds_config_s lcd_lvds_config = { |
| 61 | .lvds_repack = 1, //0=JEDIA mode, 1=VESA mode |
| 62 | .dual_port = 1, //0=single port, 1=double port |
| 63 | .pn_swap = 0, //0=normal, 1=swap |
| 64 | .port_swap = 0, //0=normal, 1=swap |
| 65 | .lane_reverse = 0, //0=normal, 1=swap |
| 66 | }; |
| 67 | |
| 68 | static struct lcd_power_ctrl_s lcd_power_ctrl = { |
| 69 | .power_on_step = { |
| 70 | { |
| 71 | .type = LCD_POWER_TYPE_SIGNAL, |
| 72 | .delay = 0, /* unit: ms */ |
| 73 | }, |
| 74 | { |
| 75 | .type = LCD_POWER_TYPE_MAX, /* ending flag */ |
| 76 | }, |
| 77 | }, |
| 78 | .power_off_step = { |
| 79 | { |
| 80 | .type = LCD_POWER_TYPE_SIGNAL, |
| 81 | .delay = 50, /* unit: ms */ |
| 82 | }, |
| 83 | { |
| 84 | .type = LCD_POWER_TYPE_MAX, /* ending flag */ |
| 85 | }, |
| 86 | }, |
| 87 | }; |
| 88 | |
| 89 | struct lcd_config_s lcd_config_dft = { |
| 90 | .lcd_mode = LCD_MODE_TABLET, |
| 91 | .lcd_key_valid = 0, |
| 92 | .lcd_basic = { |
| 93 | .model_name = "default", |
| 94 | .lcd_type = LCD_TYPE_MAX, //LCD_TTL /LCD_LVDS/LCD_VBYONE |
| 95 | .lcd_bits = 8, |
| 96 | .h_active = 1920, |
| 97 | .v_active = 1080, |
| 98 | .h_period = 2200, |
| 99 | .v_period = 1125, |
| 100 | |
| 101 | .screen_width = 16, |
| 102 | .screen_height = 9, |
| 103 | }, |
| 104 | |
| 105 | .lcd_timing = { |
| 106 | .clk_auto = 1, |
| 107 | .lcd_clk = 60, |
| 108 | .ss_level = 0, |
| 109 | .fr_adjust_type = 0, |
| 110 | |
| 111 | .hsync_width = 44, |
| 112 | .hsync_bp = 148, |
| 113 | .hsync_pol = 0, |
| 114 | .vsync_width = 5, |
| 115 | .vsync_bp = 36, |
| 116 | .vsync_pol = 0, |
| 117 | }, |
| 118 | |
| 119 | .lcd_control = { |
| 120 | .ttl_config = &lcd_ttl_config, |
| 121 | .lvds_config = &lcd_lvds_config, |
| 122 | }, |
| 123 | .lcd_power = &lcd_power_ctrl, |
| 124 | |
| 125 | .pinctrl_ver = 0, |
| 126 | .pinmux_set = {{3, 0x000002a0}, {LCD_PINMUX_END, 0x0}}, |
| 127 | .pinmux_clr = {{1, 0xfa030000}, {2, 0xf9fe0409}, {3, 0x00000001}, {LCD_PINMUX_END, 0x0}}, |
| 128 | }; |
| 129 | |
| 130 | #ifdef CONFIG_AML_LCD_EXTERN |
| 131 | static char lcd_ext_gpio[LCD_EXTERN_GPIO_NUM_MAX][LCD_EXTERN_GPIO_LEN_MAX] = { |
| 132 | "invalid", /* ending flag */ |
| 133 | }; |
| 134 | |
| 135 | static unsigned char init_on_table[LCD_EXTERN_INIT_ON_MAX] = { |
| 136 | 0xff, 0, //ending flag |
| 137 | }; |
| 138 | |
| 139 | static unsigned char init_off_table[LCD_EXTERN_INIT_OFF_MAX] = { |
| 140 | 0xff, 0, //ending flag |
| 141 | }; |
| 142 | |
| 143 | struct lcd_extern_common_s ext_common_dft = { |
| 144 | .lcd_ext_key_valid = 0, |
| 145 | .lcd_ext_num = 1, |
| 146 | .i2c_bus = LCD_EXTERN_I2C_BUS_D, /* LCD_EXTERN_I2C_BUS_A/B/C/D/AO */ |
| 147 | .pinmux_set = {{LCD_PINMUX_END, 0x0}}, |
| 148 | .pinmux_clr = {{LCD_PINMUX_END, 0x0}}, |
| 149 | }; |
| 150 | |
| 151 | struct lcd_extern_config_s ext_config_dtf[LCD_EXTERN_NUM_MAX] = { |
| 152 | { |
| 153 | .index = 0, |
| 154 | .name = "ext_default", |
| 155 | .type = LCD_EXTERN_I2C, /* LCD_EXTERN_I2C, LCD_EXTERN_SPI, LCD_EXTERN_MAX */ |
| 156 | .status = 1, /* 0=disable, 1=enable */ |
| 157 | .i2c_addr = 0x1c, /* 7bit i2c address */ |
| 158 | .i2c_addr2 = 0xff, /* 7bit i2c address, 0xff for none */ |
| 159 | .spi_gpio_cs = 0, |
| 160 | .spi_gpio_clk = 1, |
| 161 | .spi_gpio_data = 2, |
| 162 | .spi_clk_freq = 0, /* hz */ |
| 163 | .spi_clk_pol = 0, |
| 164 | .cmd_size = LCD_EXT_CMD_SIZE_DYNAMIC, |
| 165 | .table_init_on = init_on_table, |
| 166 | .table_init_on_cnt = sizeof(init_on_table), |
| 167 | .table_init_off = init_off_table, |
| 168 | .table_init_off_cnt = sizeof(init_off_table), |
| 169 | }, |
| 170 | { |
| 171 | .index = LCD_EXTERN_INDEX_INVALID, |
| 172 | }, |
| 173 | }; |
| 174 | #endif |
| 175 | |
| 176 | struct bl_config_s bl_config_dft = { |
| 177 | .name = "default", |
| 178 | .bl_key_valid = 0, |
| 179 | |
| 180 | .level_default = 100, |
| 181 | .level_min = 10, |
| 182 | .level_max = 255, |
| 183 | .level_mid = 128, |
| 184 | .level_mid_mapping = 128, |
| 185 | .level = 0, |
| 186 | |
| 187 | .method = BL_CTRL_MAX, |
| 188 | .power_on_delay = 200, |
| 189 | .power_off_delay = 200, |
| 190 | |
| 191 | .en_gpio = 0xff, |
| 192 | .en_gpio_on = 1, |
| 193 | .en_gpio_off = 0, |
| 194 | |
| 195 | .bl_pwm = NULL, |
| 196 | .bl_pwm_combo0 = NULL, |
| 197 | .bl_pwm_combo1 = NULL, |
| 198 | .pwm_on_delay = 10, |
| 199 | .pwm_off_delay = 10, |
| 200 | |
| 201 | .pinctrl_ver = 0, |
| 202 | .pinmux_set = {{2, 0x00000800}, {LCD_PINMUX_END, 0x0}}, |
| 203 | .pinmux_clr = {{1, 0x00000400}, {2, 0x00000020}, {LCD_PINMUX_END, 0x0}}, |
| 204 | }; |
| 205 | |
| 206 | void lcd_config_bsp_init(void) |
| 207 | { |
| 208 | int i, j; |
| 209 | |
| 210 | for (i = 0; i < LCD_CPU_GPIO_NUM_MAX; i++) { |
| 211 | if (strcmp(lcd_cpu_gpio[i], "invalid") == 0) |
| 212 | break; |
| 213 | strcpy(lcd_power_ctrl.cpu_gpio[i], lcd_cpu_gpio[i]); |
| 214 | } |
| 215 | for (j = i; j < LCD_CPU_GPIO_NUM_MAX; j++) |
| 216 | strcpy(lcd_power_ctrl.cpu_gpio[j], "invalid"); |
| 217 | for (i = 0; i < BL_GPIO_NUM_MAX; i++) { |
| 218 | if (strcmp(lcd_bl_gpio[i], "invalid") == 0) |
| 219 | break; |
| 220 | strcpy(bl_config_dft.gpio_name[i], lcd_bl_gpio[i]); |
| 221 | } |
| 222 | for (j = i; j < BL_GPIO_NUM_MAX; j++) |
| 223 | strcpy(bl_config_dft.gpio_name[j], "invalid"); |
| 224 | |
| 225 | #ifdef CONFIG_AML_LCD_EXTERN |
| 226 | for (i = 0; i < LCD_EXTERN_NUM_MAX; i++) { |
| 227 | if (ext_config_dtf[i].index == LCD_EXTERN_INDEX_INVALID) |
| 228 | break; |
| 229 | } |
| 230 | ext_common_dft.lcd_ext_num = i; |
| 231 | |
| 232 | for (i = 0; i < LCD_EXTERN_GPIO_NUM_MAX; i++) { |
| 233 | if (strcmp(lcd_ext_gpio[i], "invalid") == 0) |
| 234 | break; |
| 235 | strcpy(ext_common_dft.gpio_name[i], lcd_ext_gpio[i]); |
| 236 | } |
| 237 | for (j = i; j < LCD_EXTERN_GPIO_NUM_MAX; j++) |
| 238 | strcpy(ext_common_dft.gpio_name[j], "invalid"); |
| 239 | |
| 240 | #endif |
| 241 | } |