| 1 |
|
| 2 |
|
| 3 |
#include <device/mmio.h> |
| 4 |
#include <device/resource.h> |
| 5 |
#include <gpio.h> |
| 6 |
#include <soc/addressmap.h> |
| 7 |
#include <soc/early_init.h> |
| 8 |
#include <soc/pcie.h> |
| 9 |
#include <soc/pcie_common.h> |
| 10 |
|
| 11 |
#define PCIE_REG_BASE_PORT0 0x112f0000 |
| 12 |
|
| 13 |
static const struct pad_func pcie_pins[2][3] = { |
| 14 |
{ |
| 15 |
PAD_FUNC_UP(PCIE_WAKE_N, WAKEN), |
| 16 |
PAD_FUNC_UP(PCIE_PERESET_N, PERSTN), |
| 17 |
PAD_FUNC_UP(PCIE_CLKREQ_N, CLKREQN), |
| 18 |
}, |
| 19 |
{ |
| 20 |
PAD_FUNC_UP(CMMCLK0, PERSTN_1), |
| 21 |
PAD_FUNC_UP(CMMCLK1, CLKREQN_1), |
| 22 |
PAD_FUNC_UP(CMMCLK2, WAKEN_1), |
| 23 |
}, |
| 24 |
}; |
| 25 |
|
| 26 |
static void mtk_pcie_set_pinmux(uint8_t port) |
| 27 |
{ |
| 28 |
const struct pad_func *pins = pcie_pins[port]; |
| 29 |
size_t i; |
| 30 |
|
| 31 |
for (i = 0; i < ARRAY_SIZE(pcie_pins[port]); i++) { |
| 32 |
gpio_set_mode(pins[i].gpio, pins[i].func); |
| 33 |
gpio_set_pull(pins[i].gpio, GPIO_PULL_ENABLE, pins[i].select); |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
void mtk_pcie_pre_init(void) |
| 38 |
{ |
| 39 |
mtk_pcie_set_pinmux(0); |
| 40 |
|
| 41 |
|
| 42 |
mtk_pcie_reset(PCIE_REG_BASE_PORT0, true); |
| 43 |
|
| 44 |
early_init_save_time(EARLY_INIT_PCIE); |
| 45 |
} |