1 /* SPDX-License-Identifier: GPL-2.0-only */
5 #include <console/console.h>
6 #include <device/device.h>
7 #include <device/mmio.h>
8 #include <ec/google/chromeec/ec.h>
11 #include <soc/display.h>
15 #include <soc/mtcmos.h>
23 /* GPIO to schematics names */
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)
29 bool mainboard_needs_pcie_init(void)
31 uint32_t sku
= sku_id();
33 if (sku
== CROS_SKU_UNKNOWN
) {
34 printk(BIOS_WARNING
, "Unknown SKU (%#x); assuming PCIe", sku
);
36 } else if (sku
== CROS_SKU_UNPROVISIONED
) {
37 printk(BIOS_WARNING
, "Unprovisioned SKU (%#x); assuming PCIe", sku
);
42 * All cherry boards share the same SKU encoding. Therefore there is no need to check
44 * - BIT(1): NVMe (PCIe)
45 * - BIT(3): UFS (which takes precedence over BIT(1))
56 /* Set up backlight control pins as output pin and power-off by default */
57 static void configure_backlight(void)
59 gpio_output(GPIO_AP_EDP_BKLTEN
, 0);
60 gpio_output(GPIO_BL_PWM_1V8
, 0);
63 static void power_on_panel(void)
65 /* Default power sequence for most panels. */
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);
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
,
78 struct panel_description
*get_active_panel(void)
83 static void configure_i2s(void)
86 mtcmos_audio_power_on();
87 mtcmos_protect_audio_bus();
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
);
95 static void configure_audio(void)
97 if (CONFIG(CHERRY_USE_RT1011
) || CONFIG(CHERRY_USE_MAX98390
))
98 mtk_i2c_bus_init(I2C2
, I2C_SPEED_FAST
);
100 if (CONFIG(CHERRY_USE_MAX98390
))
104 static void mainboard_init(struct device
*dev
)
106 if (display_init_required())
109 printk(BIOS_INFO
, "%s: Skipped display initialization\n", __func__
);
111 mtk_msdc_configure_emmc(true);
112 mtk_msdc_configure_sdcard();
118 printk(BIOS_ERR
, "dpm init failed, DVFS may not work\n");
121 printk(BIOS_ERR
, "spm init failed, system suspend may not work\n");
123 if (CONFIG(ARM64_USE_ARM_TRUSTED_FIRMWARE
))
124 register_reset_to_bl31(GPIO_RESET
.id
, true);
127 static void mainboard_enable(struct device
*dev
)
129 dev
->ops
->init
= &mainboard_init
;
132 struct chip_operations mainboard_ops
= {
133 .enable_dev
= mainboard_enable
,