From patchwork Fri Aug 10 08:49:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 143895 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3088356ljj; Fri, 10 Aug 2018 01:49:45 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzKlbzCJtCbzfT0rAPOYIZxZf8fYF+Ty5tSms/Ccy9HHhDOR8Hz+2PMcPkEQacDdkUP8BUL X-Received: by 2002:a63:6188:: with SMTP id v130-v6mr5565219pgb.100.1533890985041; Fri, 10 Aug 2018 01:49:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533890985; cv=none; d=google.com; s=arc-20160816; b=pmxxUACubuUcUxvjnp0dH5r8+kiYgo+Y+EgiN7O1R5eLYppuKo7mPSu1pGc+9C9Ofa P0GEGqUkT3joyGYHS9JDAEQynU0VmQelnwcVQLQmLN3wJtZscAXVaCl93gvYRDm291WE z1/Ag7YBhz/gxSe4mkbhxujHA2Gx7nf4hnmilucaG3RmgbDOpSee7OPuGwsfMcVDuy1k PcqIxD7Jv9wQG6xp4TTJ+QLi6/CxxntEu4oHNp/lsdvIF95s+1QEcvO1r+mtRPrrPvOS xbcVlvQIb2jQPKQfkyDB/0naEj3fORHvvswes1VH13UUBuuDdwmEyBiTDNFbTXBVqxij 6/BQ== 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=ZNn9/K0SSY7o7gzApjrhKSJ01cSn0WZh1W8B/IOnOMA=; b=xRsVuuYh4dNmm3vrvVdDgKZqN4YQXodLEBKWFKpjS5X6dmmUjGcW8VbaxfLhM/XyC4 BNsXe17jpnqN6BHSWoKjoT/hPxQgs9AUwokvaGUzsS4ZUbDtMA3ThFg7rShsosbpNvVh ES4R3fSXO+RKss4+izNqsroqNMdOs+NJehFTf9XLUFi0wgoOxxMhXC2m1SJ+iIfvKrVv 6Wskn03HbTw54V6sYjcFStfFqlQyagLaCG+dQ8tLcHHst70HC34LZad2cOzuHB8Df0hF UsK7kA2MQjoAUZvTcTov9XoVZWd9uFTlCnFwA4lVfr99UUw6JPqTXkD+lY2S87bm3B4P vy5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FrW46OJO; 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 w14-v6si7599960pgv.462.2018.08.10.01.49.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Aug 2018 01:49:45 -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=FrW46OJO; 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 9EBF6210EB13B; Fri, 10 Aug 2018 01:49:44 -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::441; helo=mail-pf1-x441.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) (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 6A2CB210EB122 for ; Fri, 10 Aug 2018 01:49:43 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id j8-v6so4214184pff.6 for ; Fri, 10 Aug 2018 01:49:43 -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=UMprczNoF6cUTlMZbhoIUw89F24nh0QN7EzKtKJg1ks=; b=FrW46OJOSmqUkQcOtee1ptI8MG9CzL5CgiPEHFg/rBP9fUb7ietpjH2mE0Y0NmLnPE pUH4xl9u4h47PDy8ESDhcMwzb/5KMq5TAHZwx1ROmp9PcwxXIw3CepMlbOKGUMNGI7hf ZWfBnCANN/pm07Nug6jw8wGeDhTsAbffZWlXo= 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=UMprczNoF6cUTlMZbhoIUw89F24nh0QN7EzKtKJg1ks=; b=Vw7OK/wPCQlrwlnekW8x9KrXXhq2I2T19WtyQhBolLvNr7UfcSDcawkXHqCpHGk89T bKV5AqksE04/arrg0HbVxRIUZSvnJuXAkW/QiLiWwlP8Zd9W31Gk4VrFyMzdUju3FcZN iUyANPFSWIpuyknhSmoo5pbwM+c7VT1ip6wIlyMdiVZDDn3Vzkbu+Vpdd9XnJCuiLUuu qbdFb/urCo2/NCojp/RzQtenFXtrU/B7WxF6BIBSlfrkvAFI/KDRrJ2wYgQ0ris3esoO 9fTl/XNXAEYTr4i3TigQyALFVnIiLwwgpEMRisW7JDCOZpespzjE4KodFeGcEvJ0tjSw wx9w== X-Gm-Message-State: AOUpUlFkOfypLjMp99EGvZAV+x/VxnII35wBaVtAEYlYNjLzH/WQmubR XsB3V0KU7Yhxw0HiTtFwfG+dFFsSXZI= X-Received: by 2002:a63:e914:: with SMTP id i20-v6mr5567438pgh.10.1533890982803; Fri, 10 Aug 2018 01:49:42 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.24]) by smtp.gmail.com with ESMTPSA id h9-v6sm9805783pfe.187.2018.08.10.01.49.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Aug 2018 01:49:41 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Fri, 10 Aug 2018 16:49:33 +0800 Message-Id: <1533890975-13055-2-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533890975-13055-1-git-send-email-haojian.zhuang@linaro.org> References: <1533890975-13055-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH v1 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. 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 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 Fri Aug 10 08:49:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 143896 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3088450ljj; Fri, 10 Aug 2018 01:49:52 -0700 (PDT) X-Google-Smtp-Source: AA+uWPw1yafEp7oD3lnaPJkX96TlK8uHKp73sh9kd/rNmcufjkXPqAfxSdq2nyYUqIuf/zZaEaCM X-Received: by 2002:a62:198e:: with SMTP id 136-v6mr6180676pfz.103.1533890992302; Fri, 10 Aug 2018 01:49:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533890992; cv=none; d=google.com; s=arc-20160816; b=H5D1fhAwGczcDRDCMbz2agqD6vmOdT8uWDsrZ5m5oIQ6mT0G40nmagSEsHpPTwy/So +dTCv7bfpOwNv9yjr9qGsvoW593+TtexzVV6B5Ae3ahJ1ilnS4e+8xEAxxFfJboGNL/X nGQC9xyCU/97pDAfiL9vxiAKfLch675EZDaaAOnit/fSM3nKDvpPUd19Wiyvn4+DLsUB y70ngxF1hkJ0ZxsAoMnwjxKiWZyi3mYmJW6d/MmbH92vFIeUFiOEwPRbT9+YVC1LiDfk r9JRdEKSZmmgKxOje2s7aBf6qWZhqe1KgBQJ1m8Fmns4f2Gbg9QB8rJ+7JuEa2Czbo5a xhuw== 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=QeKzosN0xXjc/zpH36DFr1krBWOBF7Wfq166Gq/H92k+Svwpx6f+OTGJtzaMZhiqZS 0gpz09W/dee1p4UwXiVhuLl9DGNO05uwBxAi4YtAduhK/1kBXOWdFvGV/0IQLWWttYRS 3b6aPaoi6n3sM77LSVS7LypL3jixgNHEwKpIV+VIIdK7iCFx/EvB/JbmivhPdhkwFHD5 h/0f9BNFzC/ThwrMmC3PkmH6o9yZQNRZqlMgHAtdUTakQpCmv3w1BnEE1eUaFXxNq+6P i494WTUSHD1wUqLIFxSr/m+5a9pk8YFUoeLqLV8WPLnQ9xRA9WTyMasv+ozC/cc+9Xu9 166A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ZT0DcnyH; 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 t62-v6si9064743pgd.485.2018.08.10.01.49.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Aug 2018 01:49:52 -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=ZT0DcnyH; 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 0B420210EB4C5; Fri, 10 Aug 2018 01:49:49 -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 A4D54210EB4C3 for ; Fri, 10 Aug 2018 01:49:47 -0700 (PDT) Received: by mail-pl0-x241.google.com with SMTP id e11-v6so3776189plb.3 for ; Fri, 10 Aug 2018 01:49:47 -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=ZT0DcnyHhJ11a/jQQsaR8ir6SAkrFOkLdkPV93gYXea677KpkyLWRbYuksj226qqGY E0/oAwUNUNDit++jPwSB7isjThypybb06qqe1iiziDuxCjYoiykxlrRhZ0IpVm2PRvnV u7V3GouWDoIFEuqrJ7uVfnTVcepSQ5+nR/C00= 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=WJ0K6jkM7xryWpqv8EDhH+9ZTzb+yH9ToK7N1Ynjjpd3zz4DjJsIB2lwrrvvZfM6Av jN1KtRmdsQLOtosNfJeKMVL+ih7S77rphfsSOHIt1RWcFU3IvnC+ImLPxOns51kVEHeF bO8itWokTtz0GsEayVzgrdXYZ5l2VTObdEmFpKG1Assm/c15NyDek/jnUhQFHPM+2eOT 59TKgPegLGhMagKINFcnQQRM0s1A6ss9VnZJqSf1EtbMcXsIB/pyASIr46a88Alo5s4V mBgUgkhNog+dnQuBpicgSOCRT1WrdogNj6vgXE+gu0rU7175Y4OV2vtPyvygDYcV0hc/ 3zxA== X-Gm-Message-State: AOUpUlEKMPWzJaau0he2Sw++7i7T7iigWI1rdXSMU1UHezqsfLfgGFNh SdKV9fwMNd5eab3OBtcodWKJsJ5weVw= X-Received: by 2002:a17:902:8a4:: with SMTP id 33-v6mr5435457pll.82.1533890985647; Fri, 10 Aug 2018 01:49:45 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.24]) by smtp.gmail.com with ESMTPSA id h9-v6sm9805783pfe.187.2018.08.10.01.49.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Aug 2018 01:49:44 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Fri, 10 Aug 2018 16:49:34 +0800 Message-Id: <1533890975-13055-3-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533890975-13055-1-git-send-email-haojian.zhuang@linaro.org> References: <1533890975-13055-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH v1 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 Fri Aug 10 08:49:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 143897 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3088497ljj; Fri, 10 Aug 2018 01:49:55 -0700 (PDT) X-Google-Smtp-Source: AA+uWPz56TAOR6u14TGvSu5CE28YpASB+tf/Cu2/7nz8bbxkjOh5VpiAZmlJJ6b/gXQ6qx4Amkb8 X-Received: by 2002:a63:f54c:: with SMTP id e12-v6mr5489069pgk.286.1533890995763; Fri, 10 Aug 2018 01:49:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533890995; cv=none; d=google.com; s=arc-20160816; b=aBA4aZttggXZTczc6Pb4ng/NtT2+8SUw/inMqW/kQOwyPqBRxUm2VCOrCCccHu3wFs AVWwxmNyBtRVUCNEdk7c8UXiwJw23XgRelvavInqCp1t4ZPy6F9lrRlG1TJ48X9OhICV MCoriR/QkNNetTFYjhd7gmI2VK6tsdUXEKEnBDrq4nOO4qJfyd/pukTJWpPQhd/Oq9WJ p2fwnzSBV6p1WGncXDlNN9/vKm+08FoGtO2amkcssUbu1Vq/l4tFjbEoj19pugkcpJEE Ka7Juw75+zGFn3nWz0MMVEa7uqMupyiOUsa/FBODaenh+drDBPL7iJKyVpjSwxoj4bEh +56Q== 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=IgAyVI3iy1hIo2LbyUEQJJU1KJeaL25s7wtVtIvRwBWwavYfQYaM+9qbX5VPekDtNG xxFLgNvSNnQUn8HeFPLhNDcP/VbuUTHGOdxu6iEtonOJNTpHYDJ+pJIjD9IBHkcyaggX K68jQJSSNV0cWtUmfOgnfNpEM996LXxPuG9Ny08mlLOFvd1MoBcO8DiWIGcw3Va+krSB kiiWK+Q1Yebxf0/Y7uFGj+f+yd33vV4itQ/Z8+GLZ7G2DmVEJbNmoM5mjIjn7RXqNEB+ 8s1aDsf4qyZYLHKbTlT4sjQNUXWKp04TZLj8OAKoT6UiPVIKAqZ8oSWwK2ylZpRf3nX0 w/eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="XBq8/XGO"; 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-v6si9518124pgg.332.2018.08.10.01.49.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Aug 2018 01:49:55 -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="XBq8/XGO"; 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 3588E210EB4C9; Fri, 10 Aug 2018 01:49:51 -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::433; helo=mail-pf1-x433.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) (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 56AC1210EB13C for ; Fri, 10 Aug 2018 01:49:49 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id k19-v6so4228548pfi.1 for ; Fri, 10 Aug 2018 01:49:49 -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=XBq8/XGO/Zs4c+eCN2N6wp6d/Sh/YxIlaEQchkD505BAHu2I307qkNO58R+pdcUHCt svsVFPjE4ZMgOijegUzlG+qeTbGnOVKyshzerQLH0nizyAOdZaAxLeCUnX7giIcZDYMp YrQRn8abli9EnDpcyDcmj3d67ydDXy7GRQXAA= 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=VbvRmjLK55yZHIzC53VLmjFTf3emH6duGALamNhPuu+jcoZyCGBQxGj+ff/Ow0IgT1 JhUGS2bUb3KqSJNpF2KNTgELHyHkutDCTOrLtlDWT/UnPsDF6NA+EKRscHQIt+Cr8abM dD+LcYdCwbRKFFbixwApWNfan05u5zqLvH2oebTpkSuMRNCIoFR4nqEDez5AoaaxVnFX mdCXvkmjwLhcB2Cw8YQtj8qGqoOLmMQLTkr/5886cPaUGNJ7wieseqkV3JLvtQarzOWT NQbIljyJ/urfyJr24fiIjr/+MlNqPmnduovy0qiW7NLi5UZPNOjSDaxt1Ofnpgwxf32s W+ig== X-Gm-Message-State: AOUpUlEiajDyUix996xG5cnQIXqEnGYsgtS2C3Aq46iCgB/kr1X91iVP M81E5pX685AhGHMiM5kG7lazG2rWjJE= X-Received: by 2002:a62:aa02:: with SMTP id e2-v6mr6059669pff.211.1533890988512; Fri, 10 Aug 2018 01:49:48 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.24]) by smtp.gmail.com with ESMTPSA id h9-v6sm9805783pfe.187.2018.08.10.01.49.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Aug 2018 01:49:47 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Date: Fri, 10 Aug 2018 16:49:35 +0800 Message-Id: <1533890975-13055-4-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533890975-13055-1-git-send-email-haojian.zhuang@linaro.org> References: <1533890975-13055-1-git-send-email-haojian.zhuang@linaro.org> Subject: [edk2] [PATCH v1 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; +}