summaryrefslogtreecommitdiff
path: root/src/mainboard/google/geralt/mainboard.c
blob: 4042dcefef589984d3ca5ed6c729acc021a374d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* SPDX-License-Identifier: GPL-2.0-only */

#include <bootmode.h>
#include <device/device.h>
#include <soc/bl31.h>
#include <soc/i2c.h>
#include <soc/msdc.h>
#include <soc/mt6359p.h>
#include <soc/mtcmos.h>
#include <soc/usb.h>

#include "display.h"
#include "gpio.h"

#define AFE_SE_SECURE_CON	(AUDIO_BASE + 0x17a8)

static void configure_i2s(void)
{
	/* Audio PWR */
	mtcmos_audio_power_on();
	mtcmos_protect_audio_bus();

	/* Switch to normal mode */
	write32p(AFE_SE_SECURE_CON, 0x0);

	/* SoC I2S */
	gpio_set_mode(GPIO_I2SI1_LRCK, PAD_I2SO2_D2_FUNC_TDMIN_LRCK);
	gpio_set_mode(GPIO_I2SI1_BCK, PAD_I2SIN_D3_FUNC_TDMIN_BCK);
	gpio_set_mode(GPIO_I2SO1_D0, PAD_GPIO11_FUNC_I2SO1_D0);
}

static void configure_audio(void)
{
	if (CONFIG(USE_MAX98390)) {
		printk(BIOS_DEBUG, "Configure MAX98390 audio\n");

		mtk_i2c_bus_init(I2C0, I2C_SPEED_FAST);
		configure_i2s();
	}
}

static void mainboard_init(struct device *dev)
{
	mt6359p_init_pmif_arb();

	if (display_init_required()) {
		if (configure_display() < 0)
			printk(BIOS_ERR, "%s: Failed to init display\n", __func__);
	} else {
		printk(BIOS_INFO, "%s: Skipped display initialization\n", __func__);
	}

	mtk_msdc_configure_emmc(true);

	configure_audio();

	if (CONFIG(SDCARD_INIT))
		mtk_msdc_configure_sdcard();

	setup_usb_host();

	if (CONFIG(ARM64_USE_ARM_TRUSTED_FIRMWARE))
		register_reset_to_bl31(GPIO_AP_EC_WARM_RST_REQ.id, true);
}

static void mainboard_enable(struct device *dev)
{
	dev->ops->init = &mainboard_init;
}

struct chip_operations mainboard_ops = {
	.enable_dev = mainboard_enable,
};