Debian Codegraph @

src/mainboard/google/geralt/mainboard.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <bootmode.h>
4 #include <device/device.h>
5 #include <fw_config.h>
6 #include <soc/bl31.h>
7 #include <soc/display.h>
8 #include <soc/i2c.h>
9 #include <soc/msdc.h>
10 #include <soc/mt6359p.h>
11 #include <soc/mtcmos.h>
12 #include <soc/usb.h>
13
14 #include "gpio.h"
15
16 #define AFE_SE_SECURE_CON (AUDIO_BASE + 0x17a8)
17
18 static void configure_i2s(void)
19 {
20 /* Audio PWR */
21 mtcmos_audio_power_on();
22 mtcmos_protect_audio_bus();
23
24 /* Switch to normal mode */
25 write32p(AFE_SE_SECURE_CON, 0x0);
26
27 /* SoC I2S */
28 gpio_set_mode(GPIO_I2SI1_LRCK, PAD_I2SO2_D2_FUNC_TDMIN_LRCK);
29 gpio_set_mode(GPIO_I2SI1_BCK, PAD_I2SIN_D3_FUNC_TDMIN_BCK);
30 gpio_set_mode(GPIO_I2SO1_D0, PAD_GPIO11_FUNC_I2SO1_D0);
31 }
32
33 static void configure_audio(void)
34 {
35 if (CONFIG(GERALT_USE_NAU8318))
36 return;
37
38 if (fw_config_probe(FW_CONFIG(AUDIO_AMP, AMP_MAX98390)) ||
39 fw_config_probe(FW_CONFIG(AUDIO_AMP, AMP_TAS2563))) {
40
41 mtk_i2c_bus_init(I2C0, I2C_SPEED_FAST);
42 configure_i2s();
43 }
44 }
45
46 static void mainboard_init(struct device *dev)
47 {
48 mt6359p_init_pmif_arb();
49
50 if (display_init_required()) {
51 if (mtk_display_init() < 0)
52 printk(BIOS_ERR, "%s: Failed to init display\n", __func__);
53 } else {
54 printk(BIOS_INFO, "%s: Skipped display initialization\n", __func__);
55 }
56
57 mtk_msdc_configure_emmc(true);
58
59 configure_audio();
60
61 if (CONFIG(GERALT_SDCARD_INIT))
62 mtk_msdc_configure_sdcard();
63
64 setup_usb_host();
65
66 if (CONFIG(ARM64_USE_ARM_TRUSTED_FIRMWARE))
67 register_reset_to_bl31(GPIO_AP_EC_WARM_RST_REQ.id, true);
68 }
69
70 static void mainboard_enable(struct device *dev)
71 {
72 dev->ops->init = &mainboard_init;
73 }
74
75 struct chip_operations mainboard_ops = {
76 .enable_dev = mainboard_enable,
77 };