| 1 |
|
| 2 |
|
| 3 |
#include <bootmode.h> |
| 4 |
#include <console/console.h> |
| 5 |
#include <device/device.h> |
| 6 |
#include <fw_config.h> |
| 7 |
#include <gpio.h> |
| 8 |
#include <soc/bl31.h> |
| 9 |
#include <soc/display.h> |
| 10 |
#include <soc/i2c.h> |
| 11 |
#include <soc/msdc.h> |
| 12 |
#include <soc/spm.h> |
| 13 |
#include <soc/usb.h> |
| 14 |
|
| 15 |
#include "gpio.h" |
| 16 |
#include "panel.h" |
| 17 |
|
| 18 |
static void configure_alc1019(void) |
| 19 |
{ |
| 20 |
mtcmos_audio_power_on(); |
| 21 |
|
| 22 |
|
| 23 |
gpio_set_mode(GPIO(I2S2_MCK), PAD_I2S2_MCK_FUNC_I2S2_MCK); |
| 24 |
gpio_set_mode(GPIO(I2S2_BCK), PAD_I2S2_BCK_FUNC_I2S2_BCK); |
| 25 |
gpio_set_mode(GPIO(I2S2_LRCK), PAD_I2S2_LRCK_FUNC_I2S2_LRCK); |
| 26 |
gpio_set_mode(GPIO(EINT4), PAD_EINT4_FUNC_I2S3_DO); |
| 27 |
} |
| 28 |
|
| 29 |
static void configure_alc5645(void) |
| 30 |
{ |
| 31 |
mtcmos_audio_power_on(); |
| 32 |
|
| 33 |
|
| 34 |
gpio_set_mode(GPIO(I2S1_MCK), PAD_I2S1_MCK_FUNC_I2S1_MCK); |
| 35 |
gpio_set_mode(GPIO(I2S1_BCK), PAD_I2S1_BCK_FUNC_I2S1_BCK); |
| 36 |
gpio_set_mode(GPIO(I2S1_LRCK), PAD_I2S1_LRCK_FUNC_I2S1_LRCK); |
| 37 |
gpio_set_mode(GPIO(I2S1_DO), PAD_I2S1_DO_FUNC_I2S1_DO); |
| 38 |
|
| 39 |
|
| 40 |
mtk_i2c_bus_init(I2C5, I2C_SPEED_STANDARD); |
| 41 |
} |
| 42 |
|
| 43 |
static void mainboard_init(struct device *dev) |
| 44 |
{ |
| 45 |
mtk_msdc_configure_emmc(true); |
| 46 |
|
| 47 |
if (CONFIG(CORSOLA_SDCARD_INIT)) { |
| 48 |
printk(BIOS_INFO, "SD card init\n"); |
| 49 |
|
| 50 |
|
| 51 |
gpio_output(GPIO_EN_PP3300_SDBRDG_X, 1); |
| 52 |
} |
| 53 |
|
| 54 |
setup_usb_host(); |
| 55 |
|
| 56 |
if (fw_config_probe(FW_CONFIG(SECONDARY_USB, ENABLED))) { |
| 57 |
|
| 58 |
setup_usb_secondary_host(); |
| 59 |
} |
| 60 |
|
| 61 |
if (!fw_config_is_provisioned() || |
| 62 |
fw_config_probe(FW_CONFIG(AUDIO_AMP, AMP_ALC1019))) |
| 63 |
configure_alc1019(); |
| 64 |
else if (fw_config_probe(FW_CONFIG(AUDIO_AMP, AMP_ALC5645))) |
| 65 |
configure_alc5645(); |
| 66 |
|
| 67 |
if (spm_init()) |
| 68 |
printk(BIOS_ERR, "spm init failed, system suspend may not work\n"); |
| 69 |
|
| 70 |
if (CONFIG(ARM64_USE_ARM_TRUSTED_FIRMWARE)) |
| 71 |
register_reset_to_bl31(GPIO_RESET.id, true); |
| 72 |
|
| 73 |
if (display_init_required()) { |
| 74 |
if (mtk_display_init() < 0) |
| 75 |
printk(BIOS_ERR, "%s: Failed to init display\n", __func__); |
| 76 |
} else { |
| 77 |
if (CONFIG(BOARD_GOOGLE_STARYU_COMMON)) { |
| 78 |
mtk_i2c_bus_init(PMIC_I2C_BUS, I2C_SPEED_FAST); |
| 79 |
if (is_pmic_aw37503(PMIC_I2C_BUS)) { |
| 80 |
printk(BIOS_DEBUG, "Initialize PMIC AW37503\n"); |
| 81 |
aw37503_init(PMIC_I2C_BUS); |
| 82 |
} |
| 83 |
} |
| 84 |
printk(BIOS_INFO, "%s: Skipped display init\n", __func__); |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
static void mainboard_enable(struct device *dev) |
| 89 |
{ |
| 90 |
dev->ops->init = &mainboard_init; |
| 91 |
} |
| 92 |
|
| 93 |
struct chip_operations mainboard_ops = { |
| 94 |
.enable_dev = mainboard_enable, |
| 95 |
}; |