huang lin | a6dbfb5 | 2016-03-02 18:38:40 +0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2016 Rockchip 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 | |
Vadim Bendebury | 8e8a00c | 2016-04-22 12:25:07 -0700 | [diff] [blame^] | 17 | #include <boardid.h> |
huang lin | a6dbfb5 | 2016-03-02 18:38:40 +0800 | [diff] [blame] | 18 | #include <device/device.h> |
Vadim Bendebury | 1e80ab3 | 2016-03-28 00:44:54 -0700 | [diff] [blame] | 19 | #include <gpio.h> |
| 20 | #include <soc/clock.h> |
| 21 | #include <soc/grf.h> |
| 22 | |
| 23 | static void configure_sdmmc(void) |
| 24 | { |
| 25 | gpio_output(GPIO(4, D, 5), 1); /* SDMMC_PWR_EN */ |
| 26 | gpio_output(GPIO(2, A, 2), 1); /* SDMMC_SDIO_PWR_EN */ |
Vadim Bendebury | 8e8a00c | 2016-04-22 12:25:07 -0700 | [diff] [blame^] | 27 | /* |
| 28 | * SDMMC_DET_L is different on different board revisions. |
| 29 | * Ideally this and other deviations should come from a table |
| 30 | * which could be looked up by board revision. |
| 31 | */ |
| 32 | switch (board_id()) { |
| 33 | case 0: /* This is for Kevin proto 1. */ |
| 34 | gpio_input(GPIO(4, D, 2)); |
| 35 | break; |
| 36 | default: |
| 37 | gpio_input(GPIO(4, D, 0)); |
| 38 | break; |
| 39 | } |
Vadim Bendebury | 1e80ab3 | 2016-03-28 00:44:54 -0700 | [diff] [blame] | 40 | gpio_output(GPIO(2, D, 4), 0); /* Keep the max voltage */ |
Vadim Bendebury | 8e8a00c | 2016-04-22 12:25:07 -0700 | [diff] [blame^] | 41 | |
Vadim Bendebury | 1e80ab3 | 2016-03-28 00:44:54 -0700 | [diff] [blame] | 42 | write32(&rk3399_grf->iomux_sdmmc, IOMUX_SDMMC); |
| 43 | } |
huang lin | a6dbfb5 | 2016-03-02 18:38:40 +0800 | [diff] [blame] | 44 | |
| 45 | static void mainboard_init(device_t dev) |
| 46 | { |
Vadim Bendebury | 1e80ab3 | 2016-03-28 00:44:54 -0700 | [diff] [blame] | 47 | configure_sdmmc(); |
huang lin | a6dbfb5 | 2016-03-02 18:38:40 +0800 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | static void mainboard_enable(device_t dev) |
| 51 | { |
| 52 | dev->ops->init = &mainboard_init; |
| 53 | } |
| 54 | |
| 55 | struct chip_operations mainboard_ops = { |
| 56 | .name = CONFIG_MAINBOARD_PART_NUMBER, |
| 57 | .enable_dev = mainboard_enable, |
| 58 | }; |