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> |
Tristan Shieh | 71ae582 | 2018-09-26 14:33:54 +0800 | [diff] [blame^] | 19 | #include <soc/usb.h> |
Tristan Shieh | bb684e0 | 2018-06-19 16:07:54 +0800 | [diff] [blame] | 20 | |
Tristan Shieh | 8db79c1 | 2018-09-07 17:26:21 +0800 | [diff] [blame] | 21 | static void configure_emmc(void) |
| 22 | { |
| 23 | const gpio_t emmc_pin[] = { |
| 24 | GPIO(MSDC0_DAT0), GPIO(MSDC0_DAT1), |
| 25 | GPIO(MSDC0_DAT2), GPIO(MSDC0_DAT3), |
| 26 | GPIO(MSDC0_DAT4), GPIO(MSDC0_DAT5), |
| 27 | GPIO(MSDC0_DAT6), GPIO(MSDC0_DAT7), |
| 28 | GPIO(MSDC0_CMD), GPIO(MSDC0_RSTB), |
| 29 | }; |
| 30 | |
| 31 | for (size_t i = 0; i < ARRAY_SIZE(emmc_pin); i++) |
| 32 | gpio_set_pull(emmc_pin[i], GPIO_PULL_ENABLE, GPIO_PULL_UP); |
| 33 | } |
| 34 | |
Tristan Shieh | 71ae582 | 2018-09-26 14:33:54 +0800 | [diff] [blame^] | 35 | static void configure_usb(void) |
| 36 | { |
| 37 | setup_usb_host(); |
| 38 | } |
| 39 | |
Tristan Shieh | bb684e0 | 2018-06-19 16:07:54 +0800 | [diff] [blame] | 40 | static void mainboard_init(struct device *dev) |
| 41 | { |
Tristan Shieh | 8db79c1 | 2018-09-07 17:26:21 +0800 | [diff] [blame] | 42 | configure_emmc(); |
Tristan Shieh | 71ae582 | 2018-09-26 14:33:54 +0800 | [diff] [blame^] | 43 | configure_usb(); |
Tristan Shieh | bb684e0 | 2018-06-19 16:07:54 +0800 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | static void mainboard_enable(struct device *dev) |
| 47 | { |
| 48 | dev->ops->init = &mainboard_init; |
| 49 | } |
| 50 | |
| 51 | struct chip_operations mainboard_ops = { |
| 52 | .name = CONFIG_MAINBOARD_PART_NUMBER, |
| 53 | .enable_dev = mainboard_enable, |
| 54 | }; |