| 1 |
|
| 2 |
|
| 3 |
#include <boardid.h> |
| 4 |
#include <bootmode.h> |
| 5 |
#include <console/console.h> |
| 6 |
#include <device/device.h> |
| 7 |
#include <device/mmio.h> |
| 8 |
#include <ec/google/chromeec/ec.h> |
| 9 |
#include <gpio.h> |
| 10 |
#include <soc/bl31.h> |
| 11 |
#include <soc/display.h> |
| 12 |
#include <soc/dpm_v1.h> |
| 13 |
#include <soc/i2c.h> |
| 14 |
#include <soc/msdc.h> |
| 15 |
#include <soc/mtcmos.h> |
| 16 |
#include <soc/pcie.h> |
| 17 |
#include <soc/spm.h> |
| 18 |
#include <soc/usb.h> |
| 19 |
#include <types.h> |
| 20 |
|
| 21 |
#include "gpio.h" |
| 22 |
|
| 23 |
|
| 24 |
#define GPIO_AP_EDP_BKLTEN GPIO(DGI_D5) |
| 25 |
#define GPIO_BL_PWM_1V8 GPIO(DISP_PWM0) |
| 26 |
#define GPIO_EDP_HPD_1V8 GPIO(GPIO_07) |
| 27 |
#define GPIO_EN_PP3300_DISP_X GPIO(I2SO1_D2) |
| 28 |
|
| 29 |
bool mainboard_needs_pcie_init(void) |
| 30 |
{ |
| 31 |
uint32_t sku = sku_id(); |
| 32 |
|
| 33 |
if (sku == CROS_SKU_UNKNOWN) { |
| 34 |
printk(BIOS_WARNING, "Unknown SKU (%#x); assuming PCIe", sku); |
| 35 |
return true; |
| 36 |
} else if (sku == CROS_SKU_UNPROVISIONED) { |
| 37 |
printk(BIOS_WARNING, "Unprovisioned SKU (%#x); assuming PCIe", sku); |
| 38 |
return true; |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
if (sku & BIT(3)) |
| 48 |
return false; |
| 49 |
if (sku & BIT(1)) |
| 50 |
return true; |
| 51 |
|
| 52 |
|
| 53 |
return false; |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
static void configure_backlight(void) |
| 58 |
{ |
| 59 |
gpio_output(GPIO_AP_EDP_BKLTEN, 0); |
| 60 |
gpio_output(GPIO_BL_PWM_1V8, 0); |
| 61 |
} |
| 62 |
|
| 63 |
static void power_on_panel(void) |
| 64 |
{ |
| 65 |
|
| 66 |
gpio_set_pull(GPIO_EDP_HPD_1V8, GPIO_PULL_ENABLE, GPIO_PULL_UP); |
| 67 |
gpio_set_mode(GPIO_EDP_HPD_1V8, 2); |
| 68 |
gpio_output(GPIO_EN_PP3300_DISP_X, 1); |
| 69 |
} |
| 70 |
|
| 71 |
static struct panel_description panel = { |
| 72 |
.configure_backlight = configure_backlight, |
| 73 |
.power_on = power_on_panel, |
| 74 |
.disp_path = DISP_PATH_EDP, |
| 75 |
.orientation = LB_FB_ORIENTATION_NORMAL, |
| 76 |
}; |
| 77 |
|
| 78 |
struct panel_description *get_active_panel(void) |
| 79 |
{ |
| 80 |
return &panel; |
| 81 |
} |
| 82 |
|
| 83 |
static void configure_i2s(void) |
| 84 |
{ |
| 85 |
|
| 86 |
mtcmos_audio_power_on(); |
| 87 |
mtcmos_protect_audio_bus(); |
| 88 |
|
| 89 |
|
| 90 |
gpio_set_mode(GPIO(GPIO_02), PAD_GPIO_02_FUNC_TDMIN_LRCK); |
| 91 |
gpio_set_mode(GPIO(GPIO_03), PAD_GPIO_03_FUNC_TDMIN_BCK); |
| 92 |
gpio_set_mode(GPIO(I2SO2_D0), PAD_I2SO2_D0_FUNC_I2SO2_D0); |
| 93 |
} |
| 94 |
|
| 95 |
static void configure_audio(void) |
| 96 |
{ |
| 97 |
if (CONFIG(CHERRY_USE_RT1011) || CONFIG(CHERRY_USE_MAX98390)) |
| 98 |
mtk_i2c_bus_init(I2C2, I2C_SPEED_FAST); |
| 99 |
|
| 100 |
if (CONFIG(CHERRY_USE_MAX98390)) |
| 101 |
configure_i2s(); |
| 102 |
} |
| 103 |
|
| 104 |
static void mainboard_init(struct device *dev) |
| 105 |
{ |
| 106 |
if (display_init_required()) |
| 107 |
mtk_display_init(); |
| 108 |
else |
| 109 |
printk(BIOS_INFO, "%s: Skipped display initialization\n", __func__); |
| 110 |
|
| 111 |
mtk_msdc_configure_emmc(true); |
| 112 |
mtk_msdc_configure_sdcard(); |
| 113 |
setup_usb_host(); |
| 114 |
|
| 115 |
configure_audio(); |
| 116 |
|
| 117 |
if (dpm_init()) |
| 118 |
printk(BIOS_ERR, "dpm init failed, DVFS may not work\n"); |
| 119 |
|
| 120 |
if (spm_init()) |
| 121 |
printk(BIOS_ERR, "spm init failed, system suspend may not work\n"); |
| 122 |
|
| 123 |
if (CONFIG(ARM64_USE_ARM_TRUSTED_FIRMWARE)) |
| 124 |
register_reset_to_bl31(GPIO_RESET.id, true); |
| 125 |
} |
| 126 |
|
| 127 |
static void mainboard_enable(struct device *dev) |
| 128 |
{ |
| 129 |
dev->ops->init = &mainboard_init; |
| 130 |
} |
| 131 |
|
| 132 |
struct chip_operations mainboard_ops = { |
| 133 |
.enable_dev = mainboard_enable, |
| 134 |
}; |