mainboard/intel/avenuecity_crb: Update full IIO configuration
[coreboot2.git] / src / mainboard / google / cherry / mainboard.c
blob19638c97f69d7b33c9a3d4014e59daa591fccf53
1 /* SPDX-License-Identifier: GPL-2.0-only */
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.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>
21 #include "gpio.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);
35 return true;
36 } else if (sku == CROS_SKU_UNPROVISIONED) {
37 printk(BIOS_WARNING, "Unprovisioned SKU (%#x); assuming PCIe", sku);
38 return true;
42 * All cherry boards share the same SKU encoding. Therefore there is no need to check
43 * the board here.
44 * - BIT(1): NVMe (PCIe)
45 * - BIT(3): UFS (which takes precedence over BIT(1))
47 if (sku & BIT(3))
48 return false;
49 if (sku & BIT(1))
50 return true;
52 /* Otherwise, eMMC */
53 return false;
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)
80 return &panel;
83 static void configure_i2s(void)
85 /* Audio PWR */
86 mtcmos_audio_power_on();
87 mtcmos_protect_audio_bus();
89 /* SoC I2S */
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))
101 configure_i2s();
104 static void mainboard_init(struct device *dev)
106 if (display_init_required())
107 mtk_display_init();
108 else
109 printk(BIOS_INFO, "%s: Skipped display initialization\n", __func__);
111 mtk_msdc_configure_emmc(true);
112 mtk_msdc_configure_sdcard();
113 setup_usb_host();
115 configure_audio();
117 if (dpm_init())
118 printk(BIOS_ERR, "dpm init failed, DVFS may not work\n");
120 if (spm_init())
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,