coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
msdc.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <device/mmio.h>
4 #include <soc/addressmap.h>
5 #include <soc/gpio.h>
6 #include <soc/regulator.h>
7 #include <soc/msdc.h>
8 
9 #define MSDC0_BASE 0x11f60000
10 #define MSDC0_TOP_BASE 0x11f50000
11 
12 #define MSDC0_DRV_MASK 0x3fffffff
13 #define MSDC1_DRV_MASK 0x3ffff000
14 #define MSDC0_DRV_VALUE 0x24924924
15 #define MSDC1_DRV_VALUE 0x1b6db000
16 
17 #define MSDC1_GPIO_MODE0_BASE 0x10005360
18 #define MSDC1_GPIO_MODE0_MASK 0x77777000
19 #define MSDC1_GPIO_MODE0_VALUE 0x11111000
20 
21 #define MSDC1_GPIO_MODE1_BASE 0x10005370
22 #define MSDC1_GPIO_MODE1_MASK 0x7
23 #define MSDC1_GPIO_MODE1_VALUE 0x1
24 
25 void mtk_msdc_configure_emmc(bool is_early_init)
26 {
27  void *gpio_base = (void *)IOCFG_TL_BASE;
28  int i;
29 
30  const gpio_t emmc_pu_pin[] = {
31  GPIO(MSDC0_DAT0), GPIO(MSDC0_DAT1),
32  GPIO(MSDC0_DAT2), GPIO(MSDC0_DAT3),
33  GPIO(MSDC0_DAT4), GPIO(MSDC0_DAT5),
34  GPIO(MSDC0_DAT6), GPIO(MSDC0_DAT7),
35  GPIO(MSDC0_CMD), GPIO(MSDC0_RSTB),
36  };
37 
38  const gpio_t emmc_pd_pin[] = {
39  GPIO(MSDC0_DSL), GPIO(MSDC0_CLK),
40  };
41 
42  for (i = 0; i < ARRAY_SIZE(emmc_pu_pin); i++)
44 
45  for (i = 0; i < ARRAY_SIZE(emmc_pd_pin); i++)
47 
48  /* set eMMC cmd/dat/clk/ds/rstb pins driving to 10mA */
50 
51  if (is_early_init)
53 }
54 
56 {
57  void *gpio_base = (void *)IOCFG_RM_BASE;
58  void *gpio_mode0_base = (void *)MSDC1_GPIO_MODE0_BASE;
59  void *gpio_mode1_base = (void *)MSDC1_GPIO_MODE1_BASE;
60  uint8_t enable = 1;
61  int i;
62 
63  const gpio_t sdcard_pu_pin[] = {
64  GPIO(MSDC1_DAT0), GPIO(MSDC1_DAT1),
65  GPIO(MSDC1_DAT2), GPIO(MSDC1_DAT3),
66  GPIO(MSDC1_CMD),
67  };
68 
69  const gpio_t sdcard_pd_pin[] = {
70  GPIO(MSDC1_CLK),
71  };
72 
73  for (i = 0; i < ARRAY_SIZE(sdcard_pu_pin); i++)
74  gpio_set_pull(sdcard_pu_pin[i], GPIO_PULL_ENABLE, GPIO_PULL_UP);
75 
76  for (i = 0; i < ARRAY_SIZE(sdcard_pd_pin); i++)
77  gpio_set_pull(sdcard_pd_pin[i], GPIO_PULL_ENABLE, GPIO_PULL_DOWN);
78 
79  /* set sdcard cmd/dat/clk pins driving to 8mA */
81 
82  /* set sdcard dat2/dat0/dat3/cmd/clk pins to msdc1 mode */
84 
85  /* set sdcard dat1 pin to msdc1 mode */
87 
90 }
int mainboard_enable_regulator(enum mtk_regulator regulator, uint8_t enable)
Definition: regulator.c:98
#define ARRAY_SIZE(a)
Definition: helpers.h:12
int mtk_emmc_early_init(void *base, void *top_base)
Definition: msdc.c:457
@ GPIO
Definition: chip.h:84
#define clrsetbits32(addr, clear, set)
Definition: mmio.h:16
@ 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 mtk_msdc_configure_sdcard(void)
Definition: msdc.c:66
void mtk_msdc_configure_emmc(bool is_early_init)
Definition: msdc.c:36
#define MSDC0_DRV_MASK
Definition: msdc.c:12
#define MSDC1_GPIO_MODE1_BASE
Definition: msdc.c:21
#define MSDC1_DRV_MASK
Definition: msdc.c:13
#define MSDC1_GPIO_MODE0_BASE
Definition: msdc.c:17
#define MSDC0_TOP_BASE
Definition: msdc.c:10
#define MSDC1_GPIO_MODE1_MASK
Definition: msdc.c:22
#define MSDC0_DRV_VALUE
Definition: msdc.c:14
#define MSDC1_GPIO_MODE0_MASK
Definition: msdc.c:18
#define MSDC1_GPIO_MODE1_VALUE
Definition: msdc.c:23
#define MSDC0_BASE
Definition: msdc.c:9
#define MSDC1_GPIO_MODE0_VALUE
Definition: msdc.c:19
#define MSDC1_DRV_VALUE
Definition: msdc.c:15
@ MTK_REGULATOR_VCCQ
Definition: regulator.h:15
@ MTK_REGULATOR_VCC
Definition: regulator.h:14
@ IOCFG_TL_BASE
Definition: addressmap.h:47
@ IOCFG_RM_BASE
Definition: addressmap.h:39
#define GPIO_PULL_UP
Definition: gpio.h:24
#define GPIO_PULL_DOWN
Definition: gpio.h:23
unsigned char uint8_t
Definition: stdint.h:8