From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::442; helo=mail-wr1-x442.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) (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 9B171210F624A for ; Tue, 21 Aug 2018 15:57:05 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id w11-v6so18475wrc.5 for ; Tue, 21 Aug 2018 15:57:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=XFfom2tTVpnLrPSlODhjis8sYXTHmiDO+gMMSiFp1VA=; b=af4c1wE0VgvRbFLhpPcI2yO1dlqKNhuUpdjMEOP8uUQIeY7HhneOpEK5QbRmTJbErc D7QlffhJQriOe6rjDAcMSf+syXXOxiak2lwVZ15iae5IN3p4FhYMAFhifEZ9g8sagiXw Kw99DcIbPqfodQLJqWdpJUVHprbbllnQ8eBu8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=XFfom2tTVpnLrPSlODhjis8sYXTHmiDO+gMMSiFp1VA=; b=j19IvOsazkG0m0MjW9VzaqmKQyJROHdltxKvFZ07UDMXaLM8sBs8mUQ1xkyLsVB3dk OXBGmQMk3AmQQf3w2E5zqGVq93ToCC+u+7+Y2Mh464QUxYEFxMvEep4VHvus1U12dOnv oYIyMcnvvBxxKpSHNF4p6kWTZ/6wvh/yxpXBaqnJBmMg3vPPJ2Dvi6Q0kaDnJlQ9oABs 4qBvGyxSACiL4TqxutJvpjd4u/FP/pK5DyX3mMxIUJvmN83aYa3PthbW93jzck0Xa6uL Srb04uF/vAAx+cvqKszkkl3xx5tEnnZHKUThD3g9SI79T6lgQCXD+T+bjEAk1eit2QCb N0JA== X-Gm-Message-State: AOUpUlFUi6CZKTOD/dhhHmEq5WLhNSGN7HdP1Okv+J8ZcBVYMIWreFIE I9bU3IJjCnPXam7n8DwospQh3g== X-Google-Smtp-Source: AA+uWPzaLblQ8NWUqYeOd9EyQ2xBSl+ZudYqKnWrBWI/xUAQWuFrZM9oMAZKFUWG26JjE8BPUkBX6g== X-Received: by 2002:adf:8466:: with SMTP id 93-v6mr32887356wrf.274.1534892223693; Tue, 21 Aug 2018 15:57:03 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id j6-v6sm36931wrq.25.2018.08.21.15.57.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Aug 2018 15:57:02 -0700 (PDT) Date: Tue, 21 Aug 2018 23:57:01 +0100 From: Leif Lindholm To: Ming Huang Cc: linaro-uefi@lists.linaro.org, edk2-devel@lists.01.org, graeme.gregory@linaro.org, ard.biesheuvel@linaro.org, michael.d.kinney@intel.com, lersek@redhat.com, guoheyi@huawei.com, wanghuiqiang@huawei.com, huangming23@huawei.com, zhangjinsong2@huawei.com, huangdaode@hisilicon.com, john.garry@huawei.com, xinliang.liu@linaro.org Message-ID: <20180821225701.ukblpupod3uqhdb6@bivouac.eciton.net> References: <20180814080903.50466-1-ming.huang@linaro.org> <20180814080903.50466-12-ming.huang@linaro.org> MIME-Version: 1.0 In-Reply-To: <20180814080903.50466-12-ming.huang@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH edk2-platforms v2 11/43] Platform/Hisilicon/D06: Add M41T83RealTimeClockLib X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Aug 2018 22:57:06 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Aug 14, 2018 at 04:08:31PM +0800, Ming Huang wrote: > Add M41T83RealTimeClockLib for RTC. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ming Huang > --- > Platform/Hisilicon/D06/D06.dsc | 1 + > Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.inf | 46 ++ > Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClock.h | 158 ++++++ > Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.c | 564 ++++++++++++++++++++ > 4 files changed, 769 insertions(+) > > diff --git a/Platform/Hisilicon/D06/D06.dsc b/Platform/Hisilicon/D06/D06.dsc > index d14fce1159..27358f8c78 100644 > --- a/Platform/Hisilicon/D06/D06.dsc > +++ b/Platform/Hisilicon/D06/D06.dsc > @@ -65,6 +65,7 @@ > CpldIoLib|Silicon/Hisilicon/Library/CpldIoLib/CpldIoLib.inf > > TimeBaseLib|EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.inf > + RealTimeClockLib|Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.inf > > CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf > GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf > diff --git a/Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.inf b/Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.inf > new file mode 100644 > index 0000000000..e0bf6b3f24 > --- /dev/null > +++ b/Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.inf > @@ -0,0 +1,46 @@ > +#/** @file > +# > +# Copyright (c) 2018, Hisilicon Limited. All rights reserved.
> +# Copyright (c) 2018, Linaro Limited. 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 = 0x0001001A > + BASE_NAME = M41T83RealTimeClockLib > + FILE_GUID = 470DFB96-E205-4515-A75E-2E60F853E79D > + MODULE_TYPE = BASE > + VERSION_STRING = 1.0 > + LIBRARY_CLASS = RealTimeClockLib > + > +[Sources.common] > + M41T83RealTimeClockLib.c > + > +[Packages] > + EmbeddedPkg/EmbeddedPkg.dec > + MdePkg/MdePkg.dec > + Platform/Hisilicon/D06/D06.dec > + Silicon/Hisilicon/HisiPkg.dec > + > +[LibraryClasses] > + BaseMemoryLib > + CpldIoLib > + DebugLib > + I2CLib > + IoLib > + PcdLib > + TimeBaseLib > + TimerLib > + UefiLib > + UefiRuntimeLib # Use EFiAtRuntime to check stage > + > +[Depex] > + gEfiCpuArchProtocolGuid > diff --git a/Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClock.h b/Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClock.h > new file mode 100644 > index 0000000000..ed10099bf3 > --- /dev/null > +++ b/Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClock.h > @@ -0,0 +1,158 @@ > +/** @file > + > + Copyright (c) 2018, Hisilicon Limited. All rights reserved.
> + Copyright (c) 2018, Linaro Limited. 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. > + > +**/ > + > +#ifndef __M41T83_REAL_TIME_CLOCK_H__ > +#define __M41T83_REAL_TIME_CLOCK_H__ > + > +// The delay is need for cpld and I2C. This is a empirical value. MemoryFance is no need. > +#define RTC_DELAY_30_MS 30000 > +// The delay is need for cpld and I2C. This is a empirical value. MemoryFance is no need. > +#define RTC_DELAY_1000_MACROSECOND 1000 > +// The delay is need for cpld and I2C. This is a empirical value. MemoryFance is no need. > +#define RTC_DELAY_2_MACROSECOND 2 > + > +#define M41T83_REGADDR_DOTSECONDS 0x00 > +#define M41T83_REGADDR_SECONDS 0x01 > +#define M41T83_REGADDR_MINUTES 0x02 > +#define M41T83_REGADDR_HOURS 0x03 > +#define M41T83_REGADDR_WEEK_DAY 0x04 > +#define M41T83_REGADDR_DAY 0x05 > +#define M41T83_REGADDR_MONTH 0x06 > +#define M41T83_REGADDR_YEAR 0x07 > +#define M41T83_REGADDR_ALARM1SEC 0x0E > +#define M41T83_REGADDR_ALARM1MIN 0x0D > +#define M41T83_REGADDR_ALARM1HOUR 0x0C > +#define M41T83_REGADDR_ALARM1DATE 0x0B > +#define M41T83_REGADDR_ALARM1MONTH 0x0A > + > +#define M41T83_REGADDR_TIMERCONTROL 0x11 > + > +#define M41T83_REGADDR_ALARM2SEC 0x18 > +#define M41T83_REGADDR_ALARM2MIN 0x17 > +#define M41T83_REGADDR_ALARM2HOUR 0x16 > +#define M41T83_REGADDR_ALARM2DATE 0x15 > +#define M41T83_REGADDR_ALARM2MONTH 0x14 > + > +typedef union { > + struct { > + UINT8 TD0:1; > + UINT8 TD1:1; > + UINT8 RSV:3; > + UINT8 TIE:1; > + UINT8 TITP:1; > + UINT8 TE:1; > + } Bits; > + UINT8 Uint8; > +} RTC_M41T83_TIMERCONTROL; > + > +typedef union { > + struct { > + UINT8 MicroSeconds; > + } Bits; > + UINT8 Uint8; > +} RTC_M41T83_DOTSECOND; > + > +typedef union { > + struct{ > + UINT8 Seconds:7; > + UINT8 ST:1; > + } Bits; > + UINT8 Uint8; > +} RTC_M41T83_SECOND; > + > +typedef union { > + struct { > + UINT8 Minutes:7; > + UINT8 Rsv:1; > + } Bits; > + UINT8 Uint8; > +} RTC_M41T83_MINUTE; > + > +typedef union { > + struct { > + UINT8 Hours:6; > + UINT8 CB:2; > + } Bits; > + UINT8 Uint8; > +} RTC_M41T83_HOUR; > + > +typedef union { > + struct{ > + UINT8 Days:3; > + UINT8 Rsv:5; > + } Bits; > + UINT8 Uint8; > +} RTC_M41T83_WEEK_DAY; > + > +typedef union { > + struct{ > + UINT8 Days:6; > + UINT8 Rsv:2; > + } Bits; > + UINT8 Uint8; > +} RTC_M41T83_MONTH_DAY; > + > +typedef union { > + struct { > + UINT8 Months:5; > + UINT8 Rsv:3; > + } Bits; > + UINT8 Uint8; > +} RTC_M41T83_MONTH; > + > +typedef union { > + struct { > + UINT8 Years:8; > + } Bits; > + UINT8 Uint8; > +} RTC_M41T83_YEAR; > + > +typedef union { > + struct { > + UINT8 Second:7; > + UINT8 RPT11:1; > + } Bits; > + UINT8 Uint8; > +} RTC_M41T83_ALARM1SEC; > + > +typedef union { > + struct { > + UINT8 Minute:7; > + UINT8 RPT12:1; > + } Bits; > + UINT8 Uint8; > +} RTC_M41T83_ALARM1MIN; > + > +typedef union { > + struct { > + UINT8 Hour:6; > + UINT8 HT:1; > + UINT8 RPT13:1; > + } Bits; > + UINT8 Uint8; > +} RTC_M41T83_ALARM1HOUR; > + > +typedef struct { > + RTC_M41T83_DOTSECOND DotSecond; > + RTC_M41T83_SECOND Second; > + RTC_M41T83_MINUTE Minute; > + RTC_M41T83_HOUR Hour; > + RTC_M41T83_WEEK_DAY WeekDay; > + RTC_M41T83_MONTH_DAY Day; > + RTC_M41T83_MONTH Month; > + RTC_M41T83_YEAR Year; > +} RTC_M41T83_TIME; > + > +#endif > diff --git a/Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.c b/Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.c > new file mode 100644 > index 0000000000..eabe8dc0f3 > --- /dev/null > +++ b/Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.c > @@ -0,0 +1,564 @@ > +/** @file > + > + Copyright (c) 2018, Hisilicon Limited. All rights reserved.
> + Copyright (c) 2018, Linaro Limited. 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. > + > +**/ > + The highlightes include appear unused. > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include * > +#include * > +#include * > +#include > +#include > +#include > +#include * > +#include > +#include > +#include * > +#include If really unused, please delete. / Leif