From 7cac5dd637b6d1fe994ed363673ba399154f3085 Mon Sep 17 00:00:00 2001 From: Peter Robinson Date: Tue, 20 Mar 2018 01:25:33 +0000 Subject: [PATCH] Fix issue with certain MMC cards on Raspberry Pi --- ...re-clock-frequency-in-bcm2835-sdhost.patch | 115 ++++++++++++++++++ uboot-tools.spec | 6 +- 2 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 mmc-use-core-clock-frequency-in-bcm2835-sdhost.patch diff --git a/mmc-use-core-clock-frequency-in-bcm2835-sdhost.patch b/mmc-use-core-clock-frequency-in-bcm2835-sdhost.patch new file mode 100644 index 0000000..115bc14 --- /dev/null +++ b/mmc-use-core-clock-frequency-in-bcm2835-sdhost.patch @@ -0,0 +1,115 @@ +From patchwork Sat Mar 17 05:15:48 2018 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Subject: [U-Boot] mmc: use core clock frequency in bcm2835 sdhost +X-Patchwork-Submitter: Jonathan Gray +X-Patchwork-Id: 887255 +Message-Id: <20180317051548.42856-1-jsg@jsg.id.au> +To: u-boot@lists.denx.de +Cc: Alexander Graf +Date: Sat, 17 Mar 2018 16:15:48 +1100 +From: Jonathan Gray +List-Id: U-Boot discussion + +In raspberrypi-firmware 7fdcd00e00a42a1c91e8bd6f5eb8352fe9358557 and +later start.elf now sets the EMMC clock to 200 MHz. + +According to Phil Elwell in +https://github.com/raspberrypi/firmware/issues/953 +the SDHost controller shares the core/VPU clock and doesn't use +the EMMC clock. + +Use the core clock id when determining the frequency to allow +U-Boot to work with recent versions of raspberrypi-firmware. +Otherwise U-Boot hangs at: + +U-Boot 2018.03 (Mar 14 2018 - 20:36:00 +1100) + +DRAM: 948 MiB +RPI 3 Model B (0xa02082) +MMC: mmc@7e202000: 0, sdhci@7e300000: 1 +Loading Environment from FAT... + +Signed-off-by: Jonathan Gray +Cc: Alexander Graf +Cc: Peter Robinson +--- + arch/arm/mach-bcm283x/include/mach/msg.h | 3 ++- + arch/arm/mach-bcm283x/msg.c | 4 ++-- + drivers/mmc/bcm2835_sdhci.c | 2 +- + drivers/mmc/bcm2835_sdhost.c | 3 ++- + 4 files changed, 7 insertions(+), 5 deletions(-) + +diff --git a/arch/arm/mach-bcm283x/include/mach/msg.h b/arch/arm/mach-bcm283x/include/mach/msg.h +index 478b1f1c50..d055480ba1 100644 +--- a/arch/arm/mach-bcm283x/include/mach/msg.h ++++ b/arch/arm/mach-bcm283x/include/mach/msg.h +@@ -18,9 +18,10 @@ int bcm2835_power_on_module(u32 module); + /** + * bcm2835_get_mmc_clock() - get the frequency of the MMC clock + * ++ * @clock_id: ID of clock to get frequency for + * @return clock frequency, or -ve on error + */ +-int bcm2835_get_mmc_clock(void); ++int bcm2835_get_mmc_clock(u32 clock_id); + + /** + * bcm2835_get_video_size() - get the current display size +diff --git a/arch/arm/mach-bcm283x/msg.c b/arch/arm/mach-bcm283x/msg.c +index 92e93ad9e5..ad29f3be09 100644 +--- a/arch/arm/mach-bcm283x/msg.c ++++ b/arch/arm/mach-bcm283x/msg.c +@@ -65,7 +65,7 @@ int bcm2835_power_on_module(u32 module) + return 0; + } + +-int bcm2835_get_mmc_clock(void) ++int bcm2835_get_mmc_clock(u32 clock_id) + { + ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_clock_rate, msg_clk, 1); + int ret; +@@ -76,7 +76,7 @@ int bcm2835_get_mmc_clock(void) + + BCM2835_MBOX_INIT_HDR(msg_clk); + BCM2835_MBOX_INIT_TAG(&msg_clk->get_clock_rate, GET_CLOCK_RATE); +- msg_clk->get_clock_rate.body.req.clock_id = BCM2835_MBOX_CLOCK_ID_EMMC; ++ msg_clk->get_clock_rate.body.req.clock_id = clock_id; + + ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg_clk->hdr); + if (ret) { +diff --git a/drivers/mmc/bcm2835_sdhci.c b/drivers/mmc/bcm2835_sdhci.c +index 3157354d2a..08bddd410e 100644 +--- a/drivers/mmc/bcm2835_sdhci.c ++++ b/drivers/mmc/bcm2835_sdhci.c +@@ -183,7 +183,7 @@ static int bcm2835_sdhci_probe(struct udevice *dev) + if (base == FDT_ADDR_T_NONE) + return -EINVAL; + +- ret = bcm2835_get_mmc_clock(); ++ ret = bcm2835_get_mmc_clock(BCM2835_MBOX_CLOCK_ID_EMMC); + if (ret < 0) { + debug("%s: Failed to set MMC clock (err=%d)\n", __func__, ret); + return ret; +diff --git a/drivers/mmc/bcm2835_sdhost.c b/drivers/mmc/bcm2835_sdhost.c +index 1bf52a3019..bccd182e50 100644 +--- a/drivers/mmc/bcm2835_sdhost.c ++++ b/drivers/mmc/bcm2835_sdhost.c +@@ -35,6 +35,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -941,7 +942,7 @@ static int bcm2835_probe(struct udevice *dev) + if (!host->ioaddr) + return -ENOMEM; + +- host->max_clk = bcm2835_get_mmc_clock(); ++ host->max_clk = bcm2835_get_mmc_clock(BCM2835_MBOX_CLOCK_ID_CORE); + + bcm2835_add_host(host); + diff --git a/uboot-tools.spec b/uboot-tools.spec index d4e1b16..c2750d9 100644 --- a/uboot-tools.spec +++ b/uboot-tools.spec @@ -2,7 +2,7 @@ Name: uboot-tools Version: 2018.03 -Release: 2%{?candidate:.%{candidate}}%{?dist} +Release: 3%{?candidate:.%{candidate}}%{?dist} Summary: U-Boot utilities License: GPLv2+ BSD LGPL-2.1+ LGPL-2.0+ URL: http://www.denx.de/wiki/U-Boot @@ -30,6 +30,7 @@ Patch10: dragonboard-fixes.patch Patch11: BeagleBoard.org-PocketBeagle.patch Patch12: mx6cuboxi-add-support-for-detecting-Revision-1.5-SoM.patch Patch13: rpi-3-plus-support.patch +Patch14: mmc-use-core-clock-frequency-in-bcm2835-sdhost.patch # Patch19: mvebu-enable-generic-distro-boot-config.patch BuildRequires: bc @@ -289,6 +290,9 @@ cp -p board/warp7/README builds/docs/README.warp7 %endif %changelog +* Tue Mar 20 2018 Peter Robinson 2018.03-3 +- Fix issue with certain MMC cards on Raspberry Pi + * Fri Mar 16 2018 Peter Robinson 2018.03-2 - Add support for Raspberry Pi 3+