drivers/wifi: Remove unnecessary data structure copy
[coreboot2.git] / src / soc / mediatek / mt8195 / msdc.c
blob8036e976399c847d18ba0fcac44ec223689f075e
1 /* SPDX-License-Identifier: GPL-2.0-only OR MIT */
3 #include <device/mmio.h>
4 #include <gpio.h>
5 #include <soc/addressmap.h>
6 #include <soc/i2c.h>
7 #include <soc/regulator.h>
8 #include <soc/msdc.h>
9 #include <soc/mt6360.h>
11 DEFINE_BITFIELD(MSDC0_DRV, 29, 0)
12 DEFINE_BITFIELD(MSDC1_DRV, 17, 0)
13 DEFINE_BITFIELD(MSDC1_GPIO_MODE0_0, 26, 24)
14 DEFINE_BITFIELD(MSDC1_GPIO_MODE0_1, 30, 28)
15 DEFINE_BITFIELD(MSDC1_GPIO_MODE1_0, 2, 0)
16 DEFINE_BITFIELD(MSDC1_GPIO_MODE1_1, 6, 4)
17 DEFINE_BITFIELD(MSDC1_GPIO_MODE1_2, 10, 8)
18 DEFINE_BITFIELD(MSDC1_GPIO_MODE1_3, 14, 12)
20 #define MSDC0_BASE 0x11230000
21 #define MSDC0_TOP_BASE 0x11f50000
23 #define MSDC0_DRV_VALUE 0x1b6db6db
24 #define MSDC1_DRV_VALUE 0x1b6db
25 #define MSDC1_GPIO_MODE0_VALUE 0x1
26 #define MSDC1_GPIO_MODE1_VALUE 0x1
28 enum {
29 MSDC1_GPIO_MODE0_BASE = 0x100053d0,
30 MSDC1_GPIO_MODE1_BASE = 0x100053e0,
33 void mtk_msdc_configure_emmc(bool is_early_init)
35 void *gpio_base = (void *)IOCFG_TL_BASE;
36 int i;
38 const gpio_t emmc_pu_pin[] = {
39 GPIO(EMMC_DAT0), GPIO(EMMC_DAT1),
40 GPIO(EMMC_DAT2), GPIO(EMMC_DAT3),
41 GPIO(EMMC_DAT4), GPIO(EMMC_DAT5),
42 GPIO(EMMC_DAT6), GPIO(EMMC_DAT7),
43 GPIO(EMMC_CMD), GPIO(EMMC_RSTB),
46 const gpio_t emmc_pd_pin[] = {
47 GPIO(EMMC_DSL), GPIO(EMMC_CLK),
50 for (i = 0; i < ARRAY_SIZE(emmc_pu_pin); i++)
51 gpio_set_pull(emmc_pu_pin[i], GPIO_PULL_ENABLE, GPIO_PULL_UP);
53 for (i = 0; i < ARRAY_SIZE(emmc_pd_pin); i++)
54 gpio_set_pull(emmc_pd_pin[i], GPIO_PULL_ENABLE, GPIO_PULL_DOWN);
56 /* set eMMC cmd/dat/clk/ds/rstb pins driving to 8mA */
57 SET32_BITFIELDS(gpio_base, MSDC0_DRV, MSDC0_DRV_VALUE);
59 if (is_early_init)
60 mtk_emmc_early_init((void *)MSDC0_BASE, (void *)MSDC0_TOP_BASE);
63 void mtk_msdc_configure_sdcard(void)
65 void *gpio_base = (void *)IOCFG_RB_BASE;
66 void *gpio_mode0_base = (void *)MSDC1_GPIO_MODE0_BASE;
67 void *gpio_mode1_base = (void *)MSDC1_GPIO_MODE1_BASE;
68 int i;
70 const gpio_t sdcard_pu_pin[] = {
71 GPIO(MSDC1_DAT0), GPIO(MSDC1_DAT1),
72 GPIO(MSDC1_DAT2), GPIO(MSDC1_DAT3),
73 GPIO(MSDC1_CMD),
76 const gpio_t sdcard_pd_pin[] = {
77 GPIO(MSDC1_CLK),
80 for (i = 0; i < ARRAY_SIZE(sdcard_pu_pin); i++)
81 gpio_set_pull(sdcard_pu_pin[i], GPIO_PULL_ENABLE, GPIO_PULL_UP);
83 for (i = 0; i < ARRAY_SIZE(sdcard_pd_pin); i++)
84 gpio_set_pull(sdcard_pd_pin[i], GPIO_PULL_ENABLE, GPIO_PULL_DOWN);
86 /* set sdcard cmd/dat/clk pins driving to 8mA */
87 SET32_BITFIELDS(gpio_base, MSDC1_DRV, MSDC1_DRV_VALUE);
89 /* set sdcard dat2/dat0/dat3/cmd/clk pins to msdc1 mode */
90 SET32_BITFIELDS(gpio_mode0_base,
91 MSDC1_GPIO_MODE0_0, MSDC1_GPIO_MODE0_VALUE,
92 MSDC1_GPIO_MODE0_1, MSDC1_GPIO_MODE0_VALUE);
94 /* set sdcard dat1 pin to msdc1 mode */
95 SET32_BITFIELDS(gpio_mode1_base,
96 MSDC1_GPIO_MODE1_0, MSDC1_GPIO_MODE1_VALUE,
97 MSDC1_GPIO_MODE1_1, MSDC1_GPIO_MODE1_VALUE,
98 MSDC1_GPIO_MODE1_2, MSDC1_GPIO_MODE1_VALUE,
99 MSDC1_GPIO_MODE1_3, MSDC1_GPIO_MODE1_VALUE);
101 mtk_i2c_bus_init(I2C7, I2C_SPEED_FAST);
103 if (CONFIG(BOARD_GOOGLE_CHERRY))
104 mt6360_init(I2C7);
106 mainboard_enable_regulator(MTK_REGULATOR_VCCQ, true);
107 mainboard_enable_regulator(MTK_REGULATOR_VCC, true);