Tristan Shieh | bb684e0 | 2018-06-19 16:07:54 +0800 | [diff] [blame] | 1 | /* |
| 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 Shieh | 8db79c1 | 2018-09-07 17:26:21 +0800 | [diff] [blame] | 17 | #include <soc/gpio.h> |
Tristan Shieh | bb684e0 | 2018-06-19 16:07:54 +0800 | [diff] [blame] | 18 | #include <soc/mmu_operations.h> |
Jiaxin Yu | 30bc9f4 | 2019-04-23 20:45:50 +0800 | [diff] [blame^] | 19 | #include <soc/mtcmos.h> |
Tristan Shieh | 71ae582 | 2018-09-26 14:33:54 +0800 | [diff] [blame] | 20 | #include <soc/usb.h> |
Tristan Shieh | bb684e0 | 2018-06-19 16:07:54 +0800 | [diff] [blame] | 21 | |
Tristan Shieh | 8db79c1 | 2018-09-07 17:26:21 +0800 | [diff] [blame] | 22 | static 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 Shieh | 71ae582 | 2018-09-26 14:33:54 +0800 | [diff] [blame] | 36 | static void configure_usb(void) |
| 37 | { |
| 38 | setup_usb_host(); |
| 39 | } |
| 40 | |
Jiaxin Yu | 30bc9f4 | 2019-04-23 20:45:50 +0800 | [diff] [blame^] | 41 | static 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 Shieh | bb684e0 | 2018-06-19 16:07:54 +0800 | [diff] [blame] | 52 | static void mainboard_init(struct device *dev) |
| 53 | { |
Tristan Shieh | 8db79c1 | 2018-09-07 17:26:21 +0800 | [diff] [blame] | 54 | configure_emmc(); |
Tristan Shieh | 71ae582 | 2018-09-26 14:33:54 +0800 | [diff] [blame] | 55 | configure_usb(); |
Jiaxin Yu | 30bc9f4 | 2019-04-23 20:45:50 +0800 | [diff] [blame^] | 56 | configure_audio(); |
Tristan Shieh | bb684e0 | 2018-06-19 16:07:54 +0800 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | static void mainboard_enable(struct device *dev) |
| 60 | { |
| 61 | dev->ops->init = &mainboard_init; |
| 62 | } |
| 63 | |
| 64 | struct chip_operations mainboard_ops = { |
| 65 | .name = CONFIG_MAINBOARD_PART_NUMBER, |
| 66 | .enable_dev = mainboard_enable, |
| 67 | }; |