blob: 40b8a49c61ae8e362fb11d715e9defcbda024a55 [file] [log] [blame]
Tristan Shiehbb684e02018-06-19 16:07:54 +08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright 2018 MediaTek Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <device/device.h>
Tristan Shieh8db79c12018-09-07 17:26:21 +080017#include <soc/gpio.h>
Tristan Shiehbb684e02018-06-19 16:07:54 +080018#include <soc/mmu_operations.h>
Jiaxin Yu30bc9f42019-04-23 20:45:50 +080019#include <soc/mtcmos.h>
Tristan Shieh71ae5822018-09-26 14:33:54 +080020#include <soc/usb.h>
Tristan Shiehbb684e02018-06-19 16:07:54 +080021
Tristan Shieh8db79c12018-09-07 17:26:21 +080022static void configure_emmc(void)
23{
24 const gpio_t emmc_pin[] = {
25 GPIO(MSDC0_DAT0), GPIO(MSDC0_DAT1),
26 GPIO(MSDC0_DAT2), GPIO(MSDC0_DAT3),
27 GPIO(MSDC0_DAT4), GPIO(MSDC0_DAT5),
28 GPIO(MSDC0_DAT6), GPIO(MSDC0_DAT7),
29 GPIO(MSDC0_CMD), GPIO(MSDC0_RSTB),
30 };
31
32 for (size_t i = 0; i < ARRAY_SIZE(emmc_pin); i++)
33 gpio_set_pull(emmc_pin[i], GPIO_PULL_ENABLE, GPIO_PULL_UP);
34}
35
Tristan Shieh71ae5822018-09-26 14:33:54 +080036static void configure_usb(void)
37{
38 setup_usb_host();
39}
40
Jiaxin Yu30bc9f42019-04-23 20:45:50 +080041static void configure_audio(void)
42{
43 /* Audio PWR*/
44 mtcmos_audio_power_on();
45
46 /* SoC I2S */
47 gpio_set_mode(GPIO(CAM_RST0), PAD_CAM_RST0_FUNC_I2S2_LRCK);
48 gpio_set_mode(GPIO(CAM_PDN1), PAD_CAM_PDN1_FUNC_I2S2_BCK);
49 gpio_set_mode(GPIO(CAM_PDN0), PAD_CAM_PDN0_FUNC_I2S2_MCK);
50 gpio_set_mode(GPIO(EINT3), PAD_EINT3_FUNC_I2S3_DO);
51}
Tristan Shiehbb684e02018-06-19 16:07:54 +080052static void mainboard_init(struct device *dev)
53{
Tristan Shieh8db79c12018-09-07 17:26:21 +080054 configure_emmc();
Tristan Shieh71ae5822018-09-26 14:33:54 +080055 configure_usb();
Jiaxin Yu30bc9f42019-04-23 20:45:50 +080056 configure_audio();
Tristan Shiehbb684e02018-06-19 16:07:54 +080057}
58
59static void mainboard_enable(struct device *dev)
60{
61 dev->ops->init = &mainboard_init;
62}
63
64struct chip_operations mainboard_ops = {
65 .name = CONFIG_MAINBOARD_PART_NUMBER,
66 .enable_dev = mainboard_enable,
67};