| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <delay.h> |
| 5 |
#include <device/i2c_simple.h> |
| 6 |
|
| 7 |
#include <gpio.h> |
| 8 |
#include <soc/display.h> |
| 9 |
#include <soc/regulator.h> |
| 10 |
|
| 11 |
#include "gpio.h" |
| 12 |
#include "panel.h" |
| 13 |
|
| 14 |
static void aw37503_init(unsigned int bus) |
| 15 |
{ |
| 16 |
i2c_write_field(bus, PMIC_AW37503_SLAVE, 0x00, 0x13, 0x1F, 0); |
| 17 |
i2c_write_field(bus, PMIC_AW37503_SLAVE, 0x01, 0x13, 0x1F, 0); |
| 18 |
i2c_write_field(bus, PMIC_AW37503_SLAVE, 0x21, 0x4C, 0xFF, 0); |
| 19 |
i2c_write_field(bus, PMIC_AW37503_SLAVE, 0x03, 0x43, 0xFF, 0); |
| 20 |
i2c_write_field(bus, PMIC_AW37503_SLAVE, 0x21, 0x00, 0xFF, 0); |
| 21 |
} |
| 22 |
|
| 23 |
static bool is_pmic_aw37503(unsigned int bus) |
| 24 |
{ |
| 25 |
u8 vendor_id; |
| 26 |
return (!i2c_read_field(bus, PMIC_AW37503_SLAVE, |
| 27 |
0x04, &vendor_id, 0x0F, 0) && vendor_id == 0x01); |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
void panel_configure_backlight(void) |
| 32 |
{ |
| 33 |
gpio_output(GPIO_EDP_BL_EN_1V8, 0); |
| 34 |
gpio_output(GPIO_BL_PWM_1V8, 0); |
| 35 |
} |
| 36 |
|
| 37 |
static void power_on_panel(void) |
| 38 |
{ |
| 39 |
gpio_output(GPIO_EN_PP3300_EDP_X, 1); |
| 40 |
gpio_set_mode(GPIO_EDP_HPD_1V8, GPIO_FUNC(EDP_TX_HPD, EDP_TX_HPD)); |
| 41 |
gpio_set_pull(GPIO_EDP_HPD_1V8, GPIO_PULL_DISABLE, GPIO_PULL_UP); |
| 42 |
} |
| 43 |
|
| 44 |
void mipi_panel_power_on(void) |
| 45 |
{ |
| 46 |
struct aw37503_config config = { |
| 47 |
.i2c_bus = PMIC_I2C_BUS, |
| 48 |
.en = GPIO_TCHSCR_REPORT_DISABLE, |
| 49 |
}; |
| 50 |
gpio_output(config.en, 0); |
| 51 |
mdelay(1); |
| 52 |
|
| 53 |
mainboard_set_regulator_voltage(MTK_REGULATOR_VCN18, 1800000); |
| 54 |
mtk_i2c_bus_init(config.i2c_bus, I2C_SPEED_FAST); |
| 55 |
|
| 56 |
mainboard_enable_regulator(MTK_REGULATOR_VCN18, true); |
| 57 |
mdelay(5); |
| 58 |
|
| 59 |
if (is_pmic_aw37503(config.i2c_bus)) { |
| 60 |
printk(BIOS_DEBUG, "Initialize and power on PMIC AW37503\n"); |
| 61 |
aw37503_init(config.i2c_bus); |
| 62 |
gpio_output(config.en, 1); |
| 63 |
mdelay(10); |
| 64 |
} |
| 65 |
gpio_output(GPIO_EN_PP3300_EDP_X, 0); |
| 66 |
mdelay(1); |
| 67 |
gpio_output(GPIO_EN_PP3300_EDP_X, 1); |
| 68 |
mdelay(1); |
| 69 |
gpio_output(GPIO_TCHSCR_RST_1V8_L, 0); |
| 70 |
mdelay(1); |
| 71 |
gpio_output(GPIO_TCHSCR_RST_1V8_L, 1); |
| 72 |
mdelay(6); |
| 73 |
} |
| 74 |
|
| 75 |
static struct panel_description panel = { |
| 76 |
.configure_backlight = panel_configure_backlight, |
| 77 |
.power_on = power_on_panel, |
| 78 |
.disp_path = DISP_PATH_EDP, |
| 79 |
.orientation = LB_FB_ORIENTATION_NORMAL, |
| 80 |
}; |
| 81 |
|
| 82 |
struct panel_description *get_active_panel(void) |
| 83 |
{ |
| 84 |
if (CONFIG(BOARD_GOOGLE_PADME)) |
| 85 |
return get_panel_description(); |
| 86 |
|
| 87 |
return &panel; |
| 88 |
} |