coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
pcie.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <commonlib/stdlib.h>
4 #include <console/console.h>
5 #include <device/mmio.h>
6 #include <device/resource.h>
7 #include <delay.h>
8 #include <soc/addressmap.h>
9 #include <soc/early_init.h>
10 #include <soc/gpio.h>
11 #include <soc/pcie.h>
12 #include <soc/pcie_common.h>
13 #include <stdlib.h>
14 #include <string.h>
15 
16 #define PCIE_REG_BASE_PORT0 0x112f0000
17 #define PCIE_RST_CTRL_REG (PCIE_REG_BASE_PORT0 + 0x148)
18 #define PCIE_MAC_RSTB BIT(0)
19 #define PCIE_PHY_RSTB BIT(1)
20 #define PCIE_BRG_RSTB BIT(2)
21 #define PCIE_PE_RSTB BIT(3)
22 
23 struct pad_func {
24  gpio_t gpio;
25  u8 func;
26 };
27 
28 #define PAD_FUNC(name, func) {GPIO(name), PAD_##name##_FUNC_##func}
29 
30 static const struct pad_func pcie_pins[2][3] = {
31  {
32  PAD_FUNC(PCIE_WAKE_N, WAKEN),
33  PAD_FUNC(PCIE_PERESET_N, PERSTN),
34  PAD_FUNC(PCIE_CLKREQ_N, CLKREQN),
35  },
36  {
37  PAD_FUNC(CMMCLK0, PERSTN_1),
38  PAD_FUNC(CMMCLK1, CLKREQN_1),
39  PAD_FUNC(CMMCLK2, WAKEN_1),
40  },
41 };
42 
44 {
45  const struct pad_func *pins = pcie_pins[port];
46  size_t i;
47 
48  for (i = 0; i < ARRAY_SIZE(pcie_pins[port]); i++) {
51  }
52 }
53 
54 void mtk_pcie_reset(uintptr_t reg, bool enable)
55 {
56  uint32_t val;
57 
58  val = read32p(reg);
59 
60  if (enable)
63  else
65  PCIE_PE_RSTB);
66 
67  write32p(reg, val);
68 }
69 
71 {
73 
74  /* Assert all reset signals at early stage */
76 
78 }
#define ARRAY_SIZE(a)
Definition: helpers.h:12
port
Definition: i915.h:29
static __always_inline uint32_t read32p(const uintptr_t addr)
Definition: mmio.h:220
static __always_inline void write32p(const uintptr_t addr, const uint32_t value)
Definition: mmio.h:240
@ GPIO_PULL_ENABLE
Definition: gpio_common.h:13
void gpio_set_pull(gpio_t gpio, enum pull_enable enable, enum pull_select select)
Definition: gpio.c:17
void early_init_save_time(enum early_init_type init_type)
Definition: early_init.c:24
void gpio_set_mode(gpio_t gpio, int mode)
Definition: gpio.c:45
@ EARLY_INIT_PCIE
Definition: early_init.h:14
#define PCIE_PHY_RSTB
Definition: pcie.c:19
#define PAD_FUNC(name, func)
Definition: pcie.c:28
#define PCIE_BRG_RSTB
Definition: pcie.c:20
static void mtk_pcie_set_pinmux(uint8_t port)
Definition: pcie.c:43
void mtk_pcie_pre_init(void)
Definition: pcie.c:70
#define PCIE_MAC_RSTB
Definition: pcie.c:18
#define PCIE_RST_CTRL_REG
Definition: pcie.c:17
void mtk_pcie_reset(uintptr_t reg, bool enable)
Definition: pcie.c:54
static const struct pad_func pcie_pins[2][3]
Definition: pcie.c:30
#define PCIE_PE_RSTB
Definition: pcie.c:21
static struct @1213 pins[]
#define GPIO_PULL_UP
Definition: gpio.h:24
unsigned int uint32_t
Definition: stdint.h:14
unsigned long uintptr_t
Definition: stdint.h:21
uint8_t u8
Definition: stdint.h:45
unsigned char uint8_t
Definition: stdint.h:8
Definition: pinmux.c:36
gpio_t gpio
Definition: i2c.c:57
u8 func
Definition: bootblock.c:15
u8 val
Definition: sys.c:300