From patchwork Thu Aug 16 01:49:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 144299 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1495108ljj; Wed, 15 Aug 2018 18:49:37 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxff97H9PMfhGiQdUleJ4/SxgLSdUgb+GpVxBYXrg0xzk40JgnUZr9bVo/1K1JTyEL2l/8s X-Received: by 2002:a62:1089:: with SMTP id 9-v6mr29442975pfq.30.1534384176911; Wed, 15 Aug 2018 18:49:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534384176; cv=none; d=google.com; s=arc-20160816; b=ghjhktuUWwgEFUxyafgoI4lZsUQpRROmm7CWhF9HViX+PUExHq6Z0M1ghOBg8wZl2c ruze3lejNNSihEqcwzoa7u65ReelXbLo3hzkh0U4dZE3QN+7Vq3ITS49RANjgOE7Ec7c lA2rrobtI64KDff6DoBMlyB/Py4zsJWzfLe56fPYpjQIiNPPmlJC8pp3t7yR4wwnEqmU GeW3i4winoTgAeHiIuMGnCwPd+zF0wr9gSqRnDR0XNEdD2NELQKAanEc/8d9TQqpGuYq AiojwqqY5HeTa5bv6fJBLtQ58hor7tDgZt4jucXRncaHuywWMgWFVLnSiJmj3a5qzQfW NI3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=0Fk69iwMqXXa/MFhRDadQ8MEvPK4PqRi+gItG3vwVDM=; b=tc1RCfZAaHQKsPeeJDmV7nltbB0zxj3zfhDJYuF+eK/Ljj5OC1dk6j3S/t0t0SrIeV eUmPNvhr40D6ljW+/R/cIGIoewPQwYL0gOrwnA669JDp19AP01IYyR30zJT8iOXD0Z7k ePqkJLyvy4SPEOSzx0xrJinn2fMQAiPbNSUCtsJ/q0qntIH//fLHKKvAOtLOd6iU7B5p +EWpPEQeKIhes730r/uYtCLS0cPYxrtRN3jpo0YZNuHvD7bpVhg+OZVoQ8eOUIoY/D2g zPAZZqXuIowpw5Pnv6etYKDyln8W6R0T/xL31U81xTNfeZQyZRen2PRY71YzkpTR/SKe vDRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=bHZ7ayBE; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id z18-v6si24123520pgg.332.2018.08.15.18.49.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Aug 2018 18:49:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=bHZ7ayBE; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 84B55210F2D0D; Wed, 15 Aug 2018 18:49:36 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::444; helo=mail-pf1-x444.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 77FA521962301 for ; Wed, 15 Aug 2018 18:49:35 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id y10-v6so1260536pfn.8 for ; Wed, 15 Aug 2018 18:49:35 -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:in-reply-to:references; bh=uPHPCgp67DQlhtcAI70IgA5R0w58/Kde4mcGknxhhMU=; b=bHZ7ayBEXbDS23y53Utp30odue/Z6MubZwtH9+lflWxaGBnf8oZMM+a3QmnS88Wgtz r9HJNZg5bcdJ01Bh85JDYe+/TvKSwJvbiGSC1roBpGujn0lDixUzwJf00eKzuGlsfin/ ayxKSjX1+bSVQVAr80dcYR2JNft1/AxhP9jyI= 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:in-reply-to :references; bh=uPHPCgp67DQlhtcAI70IgA5R0w58/Kde4mcGknxhhMU=; b=soVX/hWdvur0FmiNZ0jgH/BWVwyBWuqN9btLwXFYpnz3SYrMNGI+0DksnUJUObKVp9 Y8nYVMolj5ntExZVv4wY9nBh5DF28C6u4lsz1BceTzDyXc2kWec3mnMLaHuJIfx21wLb 9mYL2jARTLdHznzb+L/6G+VAcbQfUgszHH/U+Isc9gPpZ0g4ry6+KbhsvHbFTiD1NW2E 2aoi2DYUpkYv6QRd9IpVVXspQzsvZ6KHh//j+pn+wZsuPxwlGIxkuf0CdTidcel4CPiX 6Re2NvvSp7Ve09Fpb/nX8c72Y0xxTvl6uPaG3DbL7EjZCXnToZ68wjkA9B9dt2e3cyK0 BWXg== X-Gm-Message-State: AOUpUlFkPL4QetzLliRZy5JCNHeJayDlvTO8przBbxn+1EwmbwUGk6we dYNi5eIqQ9dcN7GY5DV44rjlbbTW/RZdGg== X-Received: by 2002:a62:e0d5:: with SMTP id d82-v6mr30057984pfm.59.1534384174905; Wed, 15 Aug 2018 18:49:34 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.56]) by smtp.gmail.com with ESMTPSA id c1-v6sm45536108pfg.25.2018.08.15.18.49.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Aug 2018 18:49:33 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Thu, 16 Aug 2018 09:49:24 +0800 Message-Id: <1534384166-15673-2-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534384166-15673-1-git-send-email-haojian.zhuang@linaro.org> References: <1534384166-15673-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH v2 edk-platforms 1/3] Silicon/Hi3660: fix LDO9_VSET register definition X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Fix the LDO9_VSET register definition in PMIC. LDO9 is used by Designware SD controller. Without this fix, SD controller fails to operate SD card since lack of right voltage setting. Cc: Leif Lindholm Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Haojian Zhuang --- Silicon/Hisilicon/Hi3660/Include/Hi3660.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Leif Lindholm diff --git a/Silicon/Hisilicon/Hi3660/Include/Hi3660.h b/Silicon/Hisilicon/Hi3660/Include/Hi3660.h index 5fbf32267657..6e0587f7783a 100644 --- a/Silicon/Hisilicon/Hi3660/Include/Hi3660.h +++ b/Silicon/Hisilicon/Hi3660/Include/Hi3660.h @@ -58,7 +58,7 @@ #define USB3OTG_PHY_CR_CAP_ADDR (1 << 0) #define PMU_REG_BASE 0xFFF34000 -#define PMIC_LDO9_VSET_REG (PMU_REG_BASE + (0x068 << 2)) +#define PMIC_LDO9_VSET_REG (PMU_REG_BASE + (0x06b << 2)) #define LDO9_VSET_MASK (7 << 0) #define PMIC_LDO16_ONOFF_ECO_REG (PMU_REG_BASE + (0x078 << 2)) From patchwork Thu Aug 16 01:49:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 144300 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1495140ljj; Wed, 15 Aug 2018 18:49:40 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxjgRnpJwSq7TTYJQ1pZitAAOqShJoCcilEKGh5UNPzD0cRfiZQL7EGL2Dbf3oMmyNKHS4U X-Received: by 2002:a17:902:6946:: with SMTP id k6-v6mr26943841plt.268.1534384180113; Wed, 15 Aug 2018 18:49:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534384180; cv=none; d=google.com; s=arc-20160816; b=F7h6e3bSZlVv7yqo1bkfdeEBDHDIY8jdA3PkSZaeAICFVuVx7BBrYlIHbyLFRVXBWH uAmfRazsoNreTOqzHMtQnMlBy+TFi/WYIlQxt+cihvy2lHPy/Ntooa+IyBQmoy+y3qbp TqaKbkRcBdv0iN17DBcOKbZUQqGs2o+WFT31UAjnKCo2gEUN/6pzB4o1wmbbAnZnRHh4 ZKbAeNrT+QgCTj9SZ5JKKUZAJicy0U0e5bdiOL/oHImnyqnDZxXJuBm2EqCuKTNt2f1o pdA0wUrWrD5vx86FkyHKuc9N3aJSSCs6Tkl/BWBNtfFrUJ5175MzQjC1wdNbyGPJcyaQ kAtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=roBXXDC0PYi1AgQUaFWTdl1trv8pHcpn24ZDdCUOXN8=; b=xfmqUW/lwmzfd093duXZHcVsE/87zbt5ouTM0+h+MT6FCcYifMNbht7Rb9NQlccuwM tT5x4z9cPlUk/AqQCPwsKqZBNXvUnf1ItR3ls63H+RukSXhEB1Zm8YSn/SjvCVDdFewX wIddmzCWKjqrEolbROPG++6e+a+MbHm8zTPjhTZv3tACNcCEurfsEYodWz+N3h8TOwST dbHuq4PtKZy0OwddqLlWAMXRRKKPtXjxifbUamxbK72MHyDdg8eYv5Pg+cFsRfJ+Bwkh 1l+fBuHxuCakSuLK8H9M6ccArToWut0n7ZJvrsrhyuEmMCb7au0zwU5H9L4ykR5zB0S9 jhuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fGQqsRUr; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id g3-v6si26623688pfa.104.2018.08.15.18.49.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Aug 2018 18:49:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fGQqsRUr; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B90AA210F2D15; Wed, 15 Aug 2018 18:49:39 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c01::241; helo=mail-pl0-x241.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl0-x241.google.com (mail-pl0-x241.google.com [IPv6:2607:f8b0:400e:c01::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 57D72210F2D12 for ; Wed, 15 Aug 2018 18:49:38 -0700 (PDT) Received: by mail-pl0-x241.google.com with SMTP id b90-v6so1276742plb.0 for ; Wed, 15 Aug 2018 18:49:38 -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:in-reply-to:references; bh=KlhCeodt1xfKUoPcsSqSK6p69G62B9kqO+HK9WcNEgw=; b=fGQqsRUrH24NIR5GBcwHClhVNiin7mRAixfURfvIc0+hPYHO3uPZAKBBU9fjSUZHH+ JfHzV/ki4xq9gHnOcQIbY2Ih3jYEyv499XgLmN2iHQuU7yX2tf6HGao9UuM9JtWyS5fm luPbAY/aLT+GfUhy+DQY+nKUGCWv1F6vhPQHw= 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:in-reply-to :references; bh=KlhCeodt1xfKUoPcsSqSK6p69G62B9kqO+HK9WcNEgw=; b=J3xT0V52XqXSsiO+HacJKqjtwfuBNtmk7Wh+2vUbMRDeSBYrnJWl63HVlDOu4I3Hsn 6WhiJfgOZo2upBMV8uoF0WDQA2ZmDtTQpKLYgO5DrnhbA0G+RHC9XafEMqkm23GIFOko qwa5dgSTzM3d+4EfCDjbIEbTjxiEllufzSenlIka5zPBZnVyOOKlsygi7hwUsGHEHWcY lr0ZJ/nkSts3ck8vlzjLqIR8sTZbVIIAemF6dmlCYMTq+1fPX7N2XRBaXSruUQL2j1+q YGbcNVWu5Eh/whUCdk2UJTxIS5oqplWPqAjgIQNTDWilP0JrFlwH78eB19S4o3Gzy4IA gQCQ== X-Gm-Message-State: AOUpUlG9rcFmt7sCtVDHXuLTkSW6d4zuKvTm4xlYXymB9Hymlqrm2wK6 mie5gPkh4ekP72ji5GT6B5B1l+IU5h5ZPg== X-Received: by 2002:a17:902:bb97:: with SMTP id m23-v6mr20447717pls.215.1534384177662; Wed, 15 Aug 2018 18:49:37 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.56]) by smtp.gmail.com with ESMTPSA id c1-v6sm45536108pfg.25.2018.08.15.18.49.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Aug 2018 18:49:36 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Thu, 16 Aug 2018 09:49:25 +0800 Message-Id: <1534384166-15673-3-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534384166-15673-1-git-send-email-haojian.zhuang@linaro.org> References: <1534384166-15673-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH v2 edk-platforms 2/3] Platform/HiKey960: enable SD controller X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Enable DwMmcHcDxe driver on HiKey960 platform. Cc: Leif Lindholm Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Haojian Zhuang --- Platform/Hisilicon/HiKey960/HiKey960.dsc | 8 ++ Platform/Hisilicon/HiKey960/HiKey960.fdf | 8 ++ Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf | 1 + Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.inf | 46 +++++++ Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c | 15 +++ Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.c | 125 ++++++++++++++++++++ 6 files changed, 203 insertions(+) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dsc b/Platform/Hisilicon/HiKey960/HiKey960.dsc index be13714b9c19..1ce306da5b50 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960.dsc +++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc @@ -193,6 +193,14 @@ [Components.common] # EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf + # + # MMC/SD + # + Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.inf + EmbeddedPkg/Universal/NonDiscoverableDeviceDxe/NonDiscoverableDeviceDxe.inf + EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.inf + MdeModulePkg/Bus/Sd/SdDxe/SdDxe.inf + Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf # diff --git a/Platform/Hisilicon/HiKey960/HiKey960.fdf b/Platform/Hisilicon/HiKey960/HiKey960.fdf index d65f77878575..d4fe4c46b818 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960.fdf +++ b/Platform/Hisilicon/HiKey960/HiKey960.fdf @@ -128,6 +128,14 @@ [FV.FvMain] # INF EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf + # + # MMC/SD + # + INF Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.inf + INF EmbeddedPkg/Universal/NonDiscoverableDeviceDxe/NonDiscoverableDeviceDxe.inf + INF EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.inf + INF MdeModulePkg/Bus/Sd/SdDxe/SdDxe.inf + INF Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf # diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf index 54105bdb3c94..9d66c028832e 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf +++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf @@ -33,6 +33,7 @@ [LibraryClasses] CacheMaintenanceLib DxeServicesTableLib IoLib + NonDiscoverableDeviceRegistrationLib PcdLib TimerLib UefiBootManagerLib diff --git a/Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.inf b/Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.inf new file mode 100644 index 000000000000..3e4bc807956e --- /dev/null +++ b/Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.inf @@ -0,0 +1,46 @@ +#/** @file +# +# Copyright (c) 2018, Linaro. All rights reserved. +# +# This program and the accompanying materials are licensed and made available +# under the terms and conditions of the BSD License which accompanies this +# distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# +#**/ + +[Defines] + INF_VERSION = 0x00010019 + BASE_NAME = HiKey960MmcDxe + FILE_GUID = e10d1dea-2f00-4eea-ac5d-9d6cfa7831a0 + MODULE_TYPE = UEFI_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = HiKey960MmcEntryPoint + +[Sources.common] + HiKey960MmcDxe.c + +[LibraryClasses] + DebugLib + IoLib + TimerLib + UefiBootServicesTableLib + UefiDriverEntryPoint + +[Protocols] + gEfiDriverBindingProtocolGuid + gEmbeddedGpioProtocolGuid + gPlatformDwMmcProtocolGuid + +[Packages] + EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.dec + EmbeddedPkg/EmbeddedPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + Silicon/Hisilicon/Hi3660/Hi3660.dec + +[Depex] + TRUE diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c index 47ec879861bd..75627d5d6665 100644 --- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c +++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +34,7 @@ #include #include #include +#include #include #include @@ -447,6 +449,19 @@ HiKey960EntryPoint ( return Status; } + Status = RegisterNonDiscoverableMmioDevice ( + NonDiscoverableDeviceTypeSdhci, + NonDiscoverableDeviceDmaTypeNonCoherent, + NULL, + NULL, + 1, + 0xFF37F000, // SD + SIZE_4KB + ); + if (EFI_ERROR (Status)) { + return Status; + } + Status = gBS->InstallProtocolInterface ( &ImageHandle, &gPlatformVirtualKeyboardProtocolGuid, diff --git a/Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.c b/Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.c new file mode 100644 index 000000000000..0a2b60edf352 --- /dev/null +++ b/Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.c @@ -0,0 +1,125 @@ +/** @file +* +* Copyright (c) 2018, Linaro. All rights reserved. +* +* This program and the accompanying materials are licensed and made available +* under the terms and conditions of the BSD License which accompanies this +* distribution. The full text of the license may be found at +* http://opensource.org/licenses/bsd-license.php +* +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +* +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#define DETECT_SD_CARD 203 // GPIO 25_3 + +DW_MMC_HC_SLOT_CAP +DwMmcCapability[] = { + { + .HighSpeed = 1, + .BusWidth = 4, + .SlotType = RemovableSlot, + .CardType = SdCardType, + .Voltage30 = 1, + .BaseClkFreq = 3200 + } +}; + +EFI_STATUS +EFIAPI +HiKey960GetCapability ( + IN EFI_HANDLE Controller, + IN UINT8 Slot, + OUT DW_MMC_HC_SLOT_CAP *Capability + ) +{ + if (Capability == NULL) { + return EFI_INVALID_PARAMETER; + } + if (DwMmcCapability[0].Controller == 0) { + DwMmcCapability[0].Controller = Controller; + CopyMem (Capability, &DwMmcCapability[0], sizeof (DW_MMC_HC_SLOT_CAP)); + } else if (DwMmcCapability[0].Controller == Controller) { + CopyMem (Capability, &DwMmcCapability[0], sizeof (DW_MMC_HC_SLOT_CAP)); + } else { + return EFI_INVALID_PARAMETER; + } + return EFI_SUCCESS; +} + +BOOLEAN +EFIAPI +HiKey960CardDetect ( + IN EFI_HANDLE Controller, + IN UINT8 Slot + ) +{ + EFI_STATUS Status; + EMBEDDED_GPIO *Gpio; + UINTN Value; + + if (Slot == 0) { + Status = gBS->LocateProtocol (&gEmbeddedGpioProtocolGuid, NULL, (VOID **)&Gpio); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to get GPIO protocol: %r\n", Status)); + goto Exit; + } + Status = Gpio->Set (Gpio, DETECT_SD_CARD, GPIO_MODE_INPUT); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to sed GPIO as input mode: %r\n", Status)); + goto Exit; + } + Status = Gpio->Get (Gpio, DETECT_SD_CARD, &Value); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to get GPIO value: %r\n", Status)); + goto Exit; + } + if (Value == 0) { + return TRUE; + } + } +Exit: + return FALSE; +} + +PLATFORM_DW_MMC_PROTOCOL mDwMmcDevice = { + HiKey960GetCapability, + HiKey960CardDetect +}; + +EFI_STATUS +EFIAPI +HiKey960MmcEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status = gBS->InstallProtocolInterface ( + &ImageHandle, + &gPlatformDwMmcProtocolGuid, + EFI_NATIVE_INTERFACE, + &mDwMmcDevice + ); + if (EFI_ERROR (Status)) { + return Status; + } + return Status; +} From patchwork Thu Aug 16 01:49:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 144301 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1495186ljj; Wed, 15 Aug 2018 18:49:43 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwhcFtZcYTNz1QLS4gobnQZ3aVBHKAIOc3vQtc9BXCa70xbucHmgiyzURkJpKnhUHvXOJ4J X-Received: by 2002:a62:7e94:: with SMTP id z142-v6mr29628776pfc.234.1534384183284; Wed, 15 Aug 2018 18:49:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534384183; cv=none; d=google.com; s=arc-20160816; b=kE0hnBAdLG5BYW7El1w6H83pAeVxpFQ6wx9B6u1rgC2DREt8bgJLC9SMpmr/pzoq7P 6K7kc7WFwx4MOklvnslnds8DzkpgwqZpxPjFK8ge4Cic7iMc7et8kUQdG5Czgyxt92Z3 qnEZ1BmfMlq6m1rDFmzaKwW3Pq3r8tPOacFP9GDREjzpy78gXQFYnv5gKFBB7GU8FwR8 6NXK9nkigvMK2CSOuSxH9FLA59kgvDckJTpaMbvvB2jb+ML049/b4NW0kdatuqIIxHFE 1cQAIroFVUacdvLQV0FoLw4FkBJ+Za744W52k6VVf3esxSV7f0uR0csOy36bIIfjtqST KGFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=7nUkswPjHRy+jl3k4XPHaSgn+n+2BahN3e2CWF1omnY=; b=RCghEZlUb8H7pvoey8f2Ce9dcNgLI49RmK7kg1loQWv0NCnusWqoLIjVoQJplDT/+e J7ntBU+COvxSQrU64IhrDa/g+fPeMOhLTEZoHMZN02vSSDZJbhSsoa9VN6+2k7yDdbfa XCzXEv5KZ4anx41ubucMy9NdJHUhOK3vAnUbDNwTgr/nPXIc6wIIl6miJybEDToGZ8BW gkht6NRnh6Pf4GGC0a+Ge8LBZzeJqLe6AxpZ/gvHk5+y9eUKkA0UPjOM+ea/LaGKdJwy 0S/Q5uKhv2Z1gDdRt2dycpl4GtWKOU8Psj+eZ+bW/91O5un4JfjLTzGqJSiSCOwr35ov QkaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="O/X2L0Tl"; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id 1-v6si11208594plh.339.2018.08.15.18.49.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Aug 2018 18:49:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="O/X2L0Tl"; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E3B11210F2D1C; Wed, 15 Aug 2018 18:49:42 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::430; helo=mail-pf1-x430.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4E6F6210F2D19 for ; Wed, 15 Aug 2018 18:49:41 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id k19-v6so1276444pfi.1 for ; Wed, 15 Aug 2018 18:49:41 -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:in-reply-to:references; bh=yqwdknotehCqdYjTGbFqLDNl7PkIJ9C2R3/lO5U1fD8=; b=O/X2L0TlBCZpI6C6YqthBO2g88ptudPpNv0UPAidIrdfkfPcJV3seNt422bSKbF2Dq QO1fd+uwLwsQnZvCVdP1egGX5irI+Naa+14Ip7+MVfh+K4XQrAiH0p8GWOYudTUv/T/C xiBzeTE3lFlRJ/eZl+DOphRe7Gx7ueRoUZcJM= 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:in-reply-to :references; bh=yqwdknotehCqdYjTGbFqLDNl7PkIJ9C2R3/lO5U1fD8=; b=B3VRHHGrNGVsBxeyUA1Sk+gR+uTp1Aq/oe75dfHr5LmZnzBMvOV+dZK9y+Ko67HeIu UN+e8kAQzHkjXeXbZb08f5byCCLapL/ig2SP88IQvVJUwC/mc7wsYeAYBhIHy3H8a2Qy x2pQgx6b1HKCCG4NomUrDcVdZlb9tMMeajswnvyu+2uLF/J+M9VLIO2jX2LAhRrTXHnC b7ftDVdRXy/FKKVvCzhgY/hesgCl8tvxQnUl2jXp6v65hjDiL83f7orRccZ+vw0D6Mbu 6A3bsl1i6IrkgtxDntqLZ8ClKDEDvhy8Emu5yrubRljdKNvjGuco0SkM9B5b54MfsAHO d1dA== X-Gm-Message-State: AOUpUlEzMzqShESBfkLgOYVJshrR0fomkNSIBXv9F1zdz3DfWroFtYrL kpZ/z9Kobe6dsiH5EKLQSUEta39bp70XRg== X-Received: by 2002:a63:9e0a:: with SMTP id s10-v6mr26974820pgd.326.1534384180503; Wed, 15 Aug 2018 18:49:40 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.56]) by smtp.gmail.com with ESMTPSA id c1-v6sm45536108pfg.25.2018.08.15.18.49.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Aug 2018 18:49:39 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Thu, 16 Aug 2018 09:49:26 +0800 Message-Id: <1534384166-15673-4-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534384166-15673-1-git-send-email-haojian.zhuang@linaro.org> References: <1534384166-15673-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH v2 edk-platforms 3/3] Platform/HiKey: enable SD/MMC controller on HiKey X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Replace DwEmmcDxe driver by DwMmcHcDxe driver on HiKey platform. Since the new driver could work on both eMMC and SD controller. Cc: Leif Lindholm Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Haojian Zhuang --- Platform/Hisilicon/HiKey/HiKey.dsc | 17 +-- Platform/Hisilicon/HiKey/HiKey.fdf | 15 ++- Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf | 1 + Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.inf | 45 +++++++ Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c | 26 ++++ Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.c | 139 ++++++++++++++++++++ 6 files changed, 227 insertions(+), 16 deletions(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Platform/Hisilicon/HiKey/HiKey.dsc b/Platform/Hisilicon/HiKey/HiKey.dsc index 9c1fc2e1b40d..4b5b73c15afe 100644 --- a/Platform/Hisilicon/HiKey/HiKey.dsc +++ b/Platform/Hisilicon/HiKey/HiKey.dsc @@ -126,12 +126,6 @@ [PcdsFixedAtBuild.common] gEmbeddedTokenSpaceGuid.PcdMetronomeTickPeriod|1000 # - # DW MMC/SD card controller - # - gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeBaseAddress|0xF723D000 - gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeClockFrequencyInHz|100000000 - - # # # Fastboot # @@ -204,13 +198,16 @@ [Components.common] # EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf - Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf - # # MMC/SD # - EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf - EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf + Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.inf + EmbeddedPkg/Universal/NonDiscoverableDeviceDxe/NonDiscoverableDeviceDxe.inf + EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.inf + MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.inf + MdeModulePkg/Bus/Sd/SdDxe/SdDxe.inf + + Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf # # USB Host Support diff --git a/Platform/Hisilicon/HiKey/HiKey.fdf b/Platform/Hisilicon/HiKey/HiKey.fdf index 2bca7232b6e5..89d3e9280ff6 100644 --- a/Platform/Hisilicon/HiKey/HiKey.fdf +++ b/Platform/Hisilicon/HiKey/HiKey.fdf @@ -128,15 +128,18 @@ [FV.FvMain] # INF EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf + # + # MMC/SD + # + INF Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.inf + INF EmbeddedPkg/Universal/NonDiscoverableDeviceDxe/NonDiscoverableDeviceDxe.inf + INF EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.inf + INF MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.inf + INF MdeModulePkg/Bus/Sd/SdDxe/SdDxe.inf + INF Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf # - # Multimedia Card Interface - # - INF EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf - INF EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf - - # # USB Host Support # INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf index 4c4644a0fe51..3d2843fbc9f6 100644 --- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf +++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf @@ -32,6 +32,7 @@ [LibraryClasses] CacheMaintenanceLib DebugLib IoLib + NonDiscoverableDeviceRegistrationLib UefiBootManagerLib UefiLib UefiDriverEntryPoint diff --git a/Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.inf b/Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.inf new file mode 100644 index 000000000000..1b78d3228ccf --- /dev/null +++ b/Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.inf @@ -0,0 +1,45 @@ +#/** @file +# +# Copyright (c) 2017, Linaro. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# +#**/ + +[Defines] + INF_VERSION = 0x00010019 + BASE_NAME = HiKeyMmcDxe + FILE_GUID = a4f9bfb1-b3f8-4d4d-8c04-9539173fc1f2 + MODULE_TYPE = UEFI_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = HiKeyMmcEntryPoint + +[Sources.common] + HiKeyMmcDxe.c + +[LibraryClasses] + DebugLib + IoLib + TimerLib + UefiBootServicesTableLib + UefiDriverEntryPoint + +[Protocols] + gEfiDriverBindingProtocolGuid + gEmbeddedGpioProtocolGuid + gPlatformDwMmcProtocolGuid + +[Packages] + EmbeddedPkg/EmbeddedPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + OpenPlatformPkg/Drivers/SdMmc/DwMmcHcDxe/DwMmcHcDxe.dec + +[Depex] + TRUE diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c index 2162b68529bd..cdec3f1dd0b0 100644 --- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c +++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -351,6 +352,31 @@ HiKeyEntryPoint ( return Status; } + Status = RegisterNonDiscoverableMmioDevice ( + NonDiscoverableDeviceTypeSdhci, + NonDiscoverableDeviceDmaTypeNonCoherent, + NULL, + NULL, + 1, + 0xF723D000, // eMMC + SIZE_4KB + ); + if (EFI_ERROR (Status)) { + return Status; + } + Status = RegisterNonDiscoverableMmioDevice ( + NonDiscoverableDeviceTypeSdhci, + NonDiscoverableDeviceDmaTypeNonCoherent, + NULL, + NULL, + 1, + 0xF723E000, // SD + SIZE_4KB + ); + if (EFI_ERROR (Status)) { + return Status; + } + Status = gBS->InstallProtocolInterface ( &ImageHandle, &gPlatformVirtualKeyboardProtocolGuid, diff --git a/Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.c b/Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.c new file mode 100644 index 000000000000..390c23018bc6 --- /dev/null +++ b/Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.c @@ -0,0 +1,139 @@ +/** @file +* +* Copyright (c) 2017, Linaro. All rights reserved. +* +* This program and the accompanying materials +* are licensed and made available under the terms and conditions of the BSD License +* which accompanies this distribution. The full text of the license may be found at +* http://opensource.org/licenses/bsd-license.php +* +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +* +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#define DETECT_SD_CARD 8 // GPIO 1_0 + +DW_MMC_HC_SLOT_CAP +DwMmcCapability[2] = { + { + .Ddr50 = 1, + .HighSpeed = 1, + .BusWidth = 8, + .SlotType = EmbeddedSlot, + .CardType = EmmcCardType, + .BaseClkFreq = 100000 + }, { + .HighSpeed = 1, + .BusWidth = 4, + .SlotType = RemovableSlot, + .CardType = SdCardType, + .Voltage30 = 1, + .BaseClkFreq = 100000 + } +}; + +EFI_STATUS +EFIAPI +HiKeyGetCapability ( + IN EFI_HANDLE Controller, + IN UINT8 Slot, + OUT DW_MMC_HC_SLOT_CAP *Capability + ) +{ + if (Capability == NULL) { + return EFI_INVALID_PARAMETER; + } + if (DwMmcCapability[0].Controller == 0) { + DwMmcCapability[0].Controller = Controller; + CopyMem (Capability, &DwMmcCapability[0], sizeof (DW_MMC_HC_SLOT_CAP)); + } else if (DwMmcCapability[0].Controller == Controller) { + CopyMem (Capability, &DwMmcCapability[0], sizeof (DW_MMC_HC_SLOT_CAP)); + } else if (DwMmcCapability[1].Controller == 0) { + DwMmcCapability[1].Controller = Controller; + CopyMem (Capability, &DwMmcCapability[1], sizeof (DW_MMC_HC_SLOT_CAP)); + } else if (DwMmcCapability[1].Controller == Controller) { + CopyMem (Capability, &DwMmcCapability[1], sizeof (DW_MMC_HC_SLOT_CAP)); + } else { + return EFI_INVALID_PARAMETER; + } + return EFI_SUCCESS; +} + +BOOLEAN +EFIAPI +HiKeyCardDetect ( + IN EFI_HANDLE Controller, + IN UINT8 Slot + ) +{ + EFI_STATUS Status; + EMBEDDED_GPIO *Gpio; + UINTN Value; + + if (DwMmcCapability[0].Controller == Controller) { + return TRUE; + } else if (DwMmcCapability[1].Controller == Controller) { + Status = gBS->LocateProtocol (&gEmbeddedGpioProtocolGuid, NULL, (VOID **)&Gpio); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to get GPIO protocol: %r\n", Status)); + return FALSE; + } + Status = Gpio->Set (Gpio, DETECT_SD_CARD, GPIO_MODE_INPUT); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to sed GPIO as input mode: %r\n", Status)); + return FALSE; + } + Status = Gpio->Get (Gpio, DETECT_SD_CARD, &Value); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to get GPIO value: %r\n", Status)); + return FALSE; + } + if (Value == 0) { + return TRUE; + } + return FALSE; + } + return FALSE; +} + +PLATFORM_DW_MMC_PROTOCOL mDwMmcDevice = { + HiKeyGetCapability, + HiKeyCardDetect +}; + +EFI_STATUS +EFIAPI +HiKeyMmcEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status = gBS->InstallProtocolInterface ( + &ImageHandle, + &gPlatformDwMmcProtocolGuid, + EFI_NATIVE_INTERFACE, + &mDwMmcDevice + ); + if (EFI_ERROR (Status)) { + return Status; + } + return Status; +}