From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by mx.groups.io with SMTP id smtpd.web10.7773.1585657862273000062 for ; Tue, 31 Mar 2020 05:31:02 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=SsjMoxe/; spf=pass (domain: nuviainc.com, ip: 209.85.128.65, mailfrom: leif@nuviainc.com) Received: by mail-wm1-f65.google.com with SMTP id b12so2248176wmj.3 for ; Tue, 31 Mar 2020 05:31:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=W9dt8V+gM2JRU6cwI/g+gRu9odaEo4GZ7v7LWp0Q3so=; b=SsjMoxe/L9536vdUq+4UAm7ojv1+yw3XD2ATHx+tqnTkTw/I27w4T7k+elFw9Alv+A uX5/QZE8uEpSOB361SBtadcE2s33Puahw662a80df45gZVyaeqaiqixo4QVnVvphXPc+ 11a1WZZoR6cSqo1Rvly5Oz0XYUDF+tDQlzxl2ZVD5W5iEyWtIv5pWCA8jGr0NxuZ3oGx NMYT12eKgaufWfJEXIk7BH03NtA34XjnhMQiq4kKhSZjZuRvQD0b7IbZ+fMshcSz/J79 LdnMldlf00FrkHm+FuUwE9+2wEjtZQCkrOjvkzHzqL4yY/BLo7I//c4bZkuv4dq9dr6H AzjQ== 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=W9dt8V+gM2JRU6cwI/g+gRu9odaEo4GZ7v7LWp0Q3so=; b=CGTMejn4XCGpCNHbELaC4SD7DQDjsLdM1e3dl7NWvQkWTpJYM4ZQ6iiiaO3Em2giPa GeVqdEHacQ/UFPLWaacOP5Gt62XrrTh8SkGOmxvh5GUaQQ9dvhF46TdjxF+mZa0/wSQ4 x7DXVGleDYSExB5dh66BHowmKjJbThoXM9ER6+gKn6D6tMfPDpLlOKo19SpOzMOmrGao SmW5aH24/yVXEz2TY06mLXiHAfk+wb9jBIsjs00GRYyGH1sILwADc6LfOaxiEzO++Q1r GA/2HhU5mdn+mV/ycjmVb0Bz8uKq2HAEFAjgA2iTRDQZpSIjQfrj5daboHl+bFS2DIs/ uwxg== X-Gm-Message-State: ANhLgQ2egzvcYDiAj917BNBKsPf7csQtdtWOTLpfXnlBhlqKnmHPme8D L7mf2NegjA1YEPTaIbdqiw9VeA== X-Google-Smtp-Source: ADFU+vuJ8GSUzNS1h7/cE+E1o/pvbEuPB6zuBBwGAQBxO24k7pzlSQN7j41iKnmTavh5iBihyJv/fw== X-Received: by 2002:a1c:7216:: with SMTP id n22mr3153866wmc.41.1585657860603; Tue, 31 Mar 2020 05:31:00 -0700 (PDT) Return-Path: Received: from vanye ([2001:470:1f09:12f0:b26e:bfff:fea9:f1b8]) by smtp.gmail.com with ESMTPSA id u5sm26758325wrq.85.2020.03.31.05.30.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2020 05:31:00 -0700 (PDT) Date: Tue, 31 Mar 2020 13:30:58 +0100 From: "Leif Lindholm" To: Pankaj Bansal Cc: Meenakshi Aggarwal , Michael D Kinney , devel@edk2.groups.io, Varun Sethi , Samer El-Haj-Mahmoud , Jon Nettleton Subject: Re: [PATCH v2 04/28] Silicon/Maxim: Fix bug in RtcWrite in Ds1307RtcLib Message-ID: <20200331123058.GF7468@vanye> References: <20200320143543.18615-1-pankaj.bansal@oss.nxp.com> <20200320143543.18615-5-pankaj.bansal@oss.nxp.com> MIME-Version: 1.0 In-Reply-To: <20200320143543.18615-5-pankaj.bansal@oss.nxp.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Mar 20, 2020 at 20:05:19 +0530, Pankaj Bansal wrote: > From: Pankaj Bansal > > There was a bug in I2C DXE implementation, which caused the Ds1307 RTC > device to issue two operation for register write, while this is a single > operation task. refer page 12 (Slave Receiver Mode (Write Mode)) on > > https://datasheets.maximintegrated.com/en/ds/DS1307.pdf > > Modify ds1307 RtcWrite code accordingly. > > Signed-off-by: Pankaj Bansal So, I'm OK with this patch, but I'll mention that I prefer the design in Silicon/NXP/Library/Pcf8563RealTimeClockLib which I think could also be applied here. I think that might have avoided the confusion that caused the bug. Reviewed-by: Leif Lindholm > --- > Silicon/Maxim/Library/Ds1307RtcLib/Ds1307RtcLib.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/Silicon/Maxim/Library/Ds1307RtcLib/Ds1307RtcLib.c b/Silicon/Maxim/Library/Ds1307RtcLib/Ds1307RtcLib.c > index 88dc198ffec8..fd7a8696e405 100644 > --- a/Silicon/Maxim/Library/Ds1307RtcLib/Ds1307RtcLib.c > +++ b/Silicon/Maxim/Library/Ds1307RtcLib/Ds1307RtcLib.c > @@ -5,7 +5,7 @@ > EmbeddedPkg/Library/TemplateRealTimeClockLib/RealTimeClockLib.c > > Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> - Copyright 2017 NXP > + Copyright 2017, 2020 NXP > > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -84,16 +84,15 @@ RtcWrite ( > { > RTC_I2C_REQUEST Req; > EFI_STATUS Status; > + UINT8 Buffer[2]; > > - Req.OperationCount = 2; > + Req.OperationCount = 1; > + Buffer[0] = RtcRegAddr; > + Buffer[1] = Val; > > Req.SetAddressOp.Flags = 0; > - Req.SetAddressOp.LengthInBytes = sizeof (RtcRegAddr); > - Req.SetAddressOp.Buffer = &RtcRegAddr; > - > - Req.GetSetDateTimeOp.Flags = 0; > - Req.GetSetDateTimeOp.LengthInBytes = sizeof (Val); > - Req.GetSetDateTimeOp.Buffer = &Val; > + Req.SetAddressOp.LengthInBytes = sizeof (Buffer); > + Req.SetAddressOp.Buffer = Buffer; > > Status = mI2cMaster->StartRequest (mI2cMaster, FixedPcdGet8 (PcdI2cSlaveAddress), > (VOID *)&Req, > -- > 2.17.1 >