From patchwork Tue Aug 15 16:18:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Griffin X-Patchwork-Id: 110184 Delivered-To: patches@linaro.org Received: by 10.140.95.78 with SMTP id h72csp5874544qge; Tue, 15 Aug 2017 09:20:19 -0700 (PDT) X-Received: by 10.80.169.100 with SMTP id m33mr27356527edc.31.1502814019647; Tue, 15 Aug 2017 09:20:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502814019; cv=none; d=google.com; s=arc-20160816; b=gPDfPhL+tx25jFJhk5QxHoL3Vai5CrStdxvGv6U682lESD4B0Lb1VNMAayfXnYC9I5 SjpjyPA6p8ldC47/KFJS0Sr+WA9JloMuivfauIxOUL7yXNbPWyieAUXqFdAr+72wREZY 7Ag/QLatS3EjU9S7wQ5SUiS0wumxShJLT4zwkuOYdS0pHAmoFgFaN+wq0dHqxh/hIAdI Mmol1s3TpNaNPSZGImcUtBeToDojS7stJ2WTyyRjntwb9vEfvv30gnds8wwpheP+ktgF km1DTQPs0Xyy7dKLJlr+XIJdwNCucW2k8T8/c+LnHliuJhcKpqlBBQYSCYGdAXPnNzb3 Eygg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=xEP6Jq6OiD4ryVzVr1dAlQincsG1KDuSEtzAIho54Fw=; b=feh5W5YITjeK4DMPbi0T5CIiknT87xox7udDHGovRhiu2H8PSA81/aZxQz/ECIPXhl iVQAvTHpc+Yj6Wl7bVNRR86smCT42UsqtgW+Fs9lGaJ49ZigKpwOYOOrcjlO21hoayTw 6IL5WuDe5rup7CC0kGknzioM8bf7A32l9Rzv+PnMWL9JX8OZywxaTPt7xpMH8L9N6Jem ogD9Par80ib4xmEdWmoAjCsKRG+YU69DEden9Sf5NGHw9rweB7rj8DOjIHm46atJJ++X VY4gJx2WEnEyBPrbvRUWpeDmIplYJ6jPoEF0yF50cz7f/1iUcsgfZ0u1Zkl0B2DBd4Ch ZiKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dsSVJtyv; spf=pass (google.com: domain of peter.griffin@linaro.org designates 2a00:1450:400c:c0c::234 as permitted sender) smtp.mailfrom=peter.griffin@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-wr0-x234.google.com (mail-wr0-x234.google.com. [2a00:1450:400c:c0c::234]) by mx.google.com with ESMTPS id s15si8109181edj.328.2017.08.15.09.20.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Aug 2017 09:20:19 -0700 (PDT) Received-SPF: pass (google.com: domain of peter.griffin@linaro.org designates 2a00:1450:400c:c0c::234 as permitted sender) client-ip=2a00:1450:400c:c0c::234; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dsSVJtyv; spf=pass (google.com: domain of peter.griffin@linaro.org designates 2a00:1450:400c:c0c::234 as permitted sender) smtp.mailfrom=peter.griffin@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-wr0-x234.google.com with SMTP id m57so4625929wrm.5 for ; Tue, 15 Aug 2017 09:20:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=xEP6Jq6OiD4ryVzVr1dAlQincsG1KDuSEtzAIho54Fw=; b=dsSVJtyv0yLV4VDjFIrKCvpzV1a4UMxmzUrPU3EAuviLez9IbzHD1GETg+9OgLZp2Z cMYVotCl36tiXfXRBIMn4EYwzR2ta6hpp8UL4hlZZmxvC8CSElamDTv7r+NGZHy+czTU S28gKM2Ib7tOMtJkiv/aRC+wF8IRVs3U5Y4BY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xEP6Jq6OiD4ryVzVr1dAlQincsG1KDuSEtzAIho54Fw=; b=mCMH+iakBU7589qqf9NlQP02TASOGx2Yq/sXkoDyWlAPJSlnShtXOnb+IGNwKiElMF 1OTmAptZX1sJit5xKfL6gUjEAt8eqXCjFXHOq7ZCKGyX6XmM4C70s9g42ZmocKBJG1Ht AENWv+k1ljTpi4wDjQXmAfUI8YogYtMN0o9BeN2FcIMrmCitPKsi/WoxHcT9qJsknHu+ eWm8KSi+NWlENCZ7RuL+/TzzC0wBWJLuYCBYmUVwh13Dd46TRYDe3lrr5+EOQdG9/K6r bjols3Tut7zUdJuJ2+ePNm4gvdgAxDkjgVS+XJsMzzsQWI5Q3qiLllBhsIhb0N0sjpn9 4faw== X-Gm-Message-State: AHYfb5hi7M27jZDi2DQMS5+Kvm2AC0Mb5XkkjwVXmBI1llsmQi4cpMJy CwYAD4Vmk+UmT/agEB6rOP6c X-Received: by 10.223.143.6 with SMTP id p6mr6893825wrb.20.1502814019225; Tue, 15 Aug 2017 09:20:19 -0700 (PDT) Return-Path: Received: from localhost.localdomain (cpc89244-aztw30-2-0-cust4998.18-1.cable.virginm.net. [86.31.179.135]) by smtp.gmail.com with ESMTPSA id b25sm11357238wrb.79.2017.08.15.09.20.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Aug 2017 09:20:18 -0700 (PDT) From: Peter Griffin To: u-boot@lists.denx.de, trini@konsulko.com Cc: Peter Griffin Subject: [PATCH] ARM: hisilicon: hikey: Fix eMMC with latest ATF & U-Boot Date: Tue, 15 Aug 2017 17:18:16 +0100 Message-Id: <1502813896-25560-1-git-send-email-peter.griffin@linaro.org> X-Mailer: git-send-email 2.7.4 ATF can leave the MMC IP in a state where U-Boot mmc driver can't enumerate the eMMC. This patch provides a mmc0_reset_clk() function like we already so do sd card controller which resets the IP when entering U-Boot. With this patch applied eMMC partitions are successfully enumerated again. => mmc dev 0 switch to partitions #0, OK mmc0(part 0) is current device => mmc part Partition Map for MMC device 0 -- Partition Type: EFI Part Start LBA End LBA Name Attributes Type GUID Partition GUID 1 0x00000800 0x00000fff "vrl" attrs: 0x0000000000000000 type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 guid: 496847ab-56a1-4cd5-a1ad-47f4acf055c9 2 0x00001000 0x000017ff "vrl_backup" attrs: 0x0000000000000000 type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 guid: 61a36fc1-8efb-4899-84d8-b61642efa723 3 0x00001800 0x00001fff "mcuimage" Signed-off-by: Peter Griffin --- board/hisilicon/hikey/hikey.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/board/hisilicon/hikey/hikey.c b/board/hisilicon/hikey/hikey.c index 47bce4d..8405467 100644 --- a/board/hisilicon/hikey/hikey.c +++ b/board/hisilicon/hikey/hikey.c @@ -295,13 +295,47 @@ static void mmc1_reset_clk(void) data = readl(&peri_sc->rst0_stat); } while (!(data & PERI_RST0_MMC1)); - /* unreset mmc0 clock domain */ + /* unreset mmc1 clock domain */ writel(PERI_RST0_MMC1, &peri_sc->rst0_dis); do { data = readl(&peri_sc->rst0_stat); } while (data & PERI_RST0_MMC1); } +static void mmc0_reset_clk(void) +{ + unsigned int data; + + /* disable mmc0 bus clock */ + hi6220_clk_disable(PERI_CLK0_MMC0, &peri_sc->clk0_dis); + + /* enable mmc0 bus clock */ + hi6220_clk_enable(PERI_CLK0_MMC0, &peri_sc->clk0_en); + + /* reset mmc0 clock domain */ + writel(PERI_RST0_MMC0, &peri_sc->rst0_en); + + /* bypass mmc0 clock phase */ + data = readl(&peri_sc->ctrl2); + data |= 3; + writel(data, &peri_sc->ctrl2); + + /* disable low power */ + data = readl(&peri_sc->ctrl13); + data |= 1 << 3; + writel(data, &peri_sc->ctrl13); + do { + data = readl(&peri_sc->rst0_stat); + } while (!(data & PERI_RST0_MMC0)); + + /* unreset mmc0 clock domain */ + writel(PERI_RST0_MMC0, &peri_sc->rst0_dis); + do { + data = readl(&peri_sc->rst0_stat); + } while (data & PERI_RST0_MMC0); +} + + /* PMU SSI is the IP that maps the external PMU hi6553 registers as IO */ static void hi6220_pmussi_init(void) { @@ -349,7 +383,8 @@ static int init_dwmmc(void) #ifdef CONFIG_MMC_DW - /* mmc0 clocks are already configured by ATF */ + /* mmc0 pll is already configured by ATF */ + mmc0_reset_clk(); ret = hi6220_pinmux_config(PERIPH_ID_SDMMC0); if (ret) printf("%s: Error configuring pinmux for eMMC (%d)\n"