uboot-d1: add bootloader for upcoming d1 target
[openwrt/staging/mans0n.git] / package / boot / uboot-d1 / patches / 0016-sunxi-mmc-ignore-card-detect-in-SPL.patch
1 From 2cde6c8a7c41c13137298c19b4e104e4f5d6851c Mon Sep 17 00:00:00 2001
2 From: Andre Przywara <andre.przywara@arm.com>
3 Date: Wed, 13 Jul 2022 17:21:43 +0100
4 Subject: [PATCH 16/90] sunxi: mmc: ignore card detect in SPL
5
6 The sunxi MMC code does not use the DM in the SPL, as we don't have a
7 device tree available that early, also no space for it.
8 This also means we cannot access the card-detect GPIO information from
9 there, so we have Kconfig symbols called CONFIG_MMCx_CD_PIN, which each
10 board has to define. This is a burden, also requires extra GPIO code in
11 the SPL.
12 As the SPL is the natural successor of the BootROM (from which we are
13 loaded), we can actually ignore the CD pin completely, as this is what
14 the BootROM does as well: CD GPIOs are board specific, but the BootROM
15 is not, so accesses the MMC devices anyway.
16
17 Remove the card detect code from the non-DM implementation of the sunxi
18 MMC driver, to get rid of this unneeded code.
19
20 Signed-off-by: Andre Przywara <andre.przywara@arm.com>
21 ---
22 drivers/mmc/sunxi_mmc.c | 37 ++-----------------------------------
23 1 file changed, 2 insertions(+), 35 deletions(-)
24
25 --- a/drivers/mmc/sunxi_mmc.c
26 +++ b/drivers/mmc/sunxi_mmc.c
27 @@ -44,22 +44,10 @@ struct sunxi_mmc_priv {
28 /* support 4 mmc hosts */
29 struct sunxi_mmc_priv mmc_host[4];
30
31 -static int sunxi_mmc_getcd_gpio(int sdc_no)
32 -{
33 - switch (sdc_no) {
34 - case 0: return sunxi_name_to_gpio(CONFIG_MMC0_CD_PIN);
35 - case 1: return sunxi_name_to_gpio(CONFIG_MMC1_CD_PIN);
36 - case 2: return sunxi_name_to_gpio(CONFIG_MMC2_CD_PIN);
37 - case 3: return sunxi_name_to_gpio(CONFIG_MMC3_CD_PIN);
38 - }
39 - return -EINVAL;
40 -}
41 -
42 static int mmc_resource_init(int sdc_no)
43 {
44 struct sunxi_mmc_priv *priv = &mmc_host[sdc_no];
45 struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
46 - int cd_pin, ret = 0;
47
48 debug("init mmc %d resource\n", sdc_no);
49
50 @@ -90,16 +78,7 @@ static int mmc_resource_init(int sdc_no)
51 }
52 priv->mmc_no = sdc_no;
53
54 - cd_pin = sunxi_mmc_getcd_gpio(sdc_no);
55 - if (cd_pin >= 0) {
56 - ret = gpio_request(cd_pin, "mmc_cd");
57 - if (!ret) {
58 - sunxi_gpio_set_pull(cd_pin, SUNXI_GPIO_PULL_UP);
59 - ret = gpio_direction_input(cd_pin);
60 - }
61 - }
62 -
63 - return ret;
64 + return 0;
65 }
66 #endif
67
68 @@ -523,23 +502,11 @@ static int sunxi_mmc_send_cmd_legacy(str
69 return sunxi_mmc_send_cmd_common(priv, mmc, cmd, data);
70 }
71
72 -static int sunxi_mmc_getcd_legacy(struct mmc *mmc)
73 -{
74 - struct sunxi_mmc_priv *priv = mmc->priv;
75 - int cd_pin;
76 -
77 - cd_pin = sunxi_mmc_getcd_gpio(priv->mmc_no);
78 - if (cd_pin < 0)
79 - return 1;
80 -
81 - return !gpio_get_value(cd_pin);
82 -}
83 -
84 +/* .get_cd is not needed by the SPL */
85 static const struct mmc_ops sunxi_mmc_ops = {
86 .send_cmd = sunxi_mmc_send_cmd_legacy,
87 .set_ios = sunxi_mmc_set_ios_legacy,
88 .init = sunxi_mmc_core_init,
89 - .getcd = sunxi_mmc_getcd_legacy,
90 };
91
92 struct mmc *sunxi_mmc_init(int sdc_no)