Received: by 2002:a05:6a10:c7d3:0:0:0:0 with SMTP id h19csp559497pxy; Sat, 14 Aug 2021 15:55:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyk4+hn+CTxJNbp8eqHGIA94eWujxu432XmSARPUhYR/XJe2Bur/f1NtV3hAPuPCPYRU/e X-Received: by 2002:a17:906:491a:: with SMTP id b26mr9202786ejq.25.1628981746280; Sat, 14 Aug 2021 15:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628981746; cv=none; d=google.com; s=arc-20160816; b=s0ZF7FbQfjLOMOdGSmomquO9RhA2X6zoPPxcbgz9e2j76B7KgSpH49tjbhcw8/bv5W WFkubyBJN8sjOKGnA+9n/PkHHTM7T+HIre9n/JQ4V1M3XWbZIL2L0LKn7Lde+hyrENi4 pw5OdTwqzIy/O56lhmOS0C2tvJTMLpz6jFWWuERxugf1Qw3M4bVN/1ajH1Z9lowXpugu osLzC15PVtW2fE/4xdR0/RXKKDfOiU0Pxyq1LALzbQzufpevr1fcH1avhZzq2ktgmxB6 yCImmoYhV2sNkUY94zbuVXZpxxqCqk0r4MTbjzNW/a228W45rViZVXcPUUXLnNcx90eN NSDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=gkJO73YRk3QGSnXa3a/jzv/FQTbPeEQgelsyLZQoqKU=; b=mWotzpu7F+F6MXOF9yzZG5Vg02a68tAU0CrSTS7RbIB2JOS2gUOisqAEbeFhQsjGd8 EwD/PBFzsENju8jHPGygca1zMxT2+1M1sGEqpVLGtJSi0yHzn4uhZYF089uV8JR2wX6Z tQSWkMiiq+ptDuq05DcgBebmh9LMCMyi60oLCXB/cXtTTHCntbP9K0Jbm14UofRSKDPA eqIGwGfbQ88ItpGKyV5+EuZ+08OOuWTN7RyK/sY1p2zXVmXQGObS2lRfD0PanvlG/giA ZZx6rvqmUw9zfytTIvo8yZSPCWebDkQBCk6v/VtVSmJI9wbs178RqKgj5ci52SDzmEYJ kUOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=r82EXC6m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f5si5515006edt.448.2021.08.14.15.55.22; Sat, 14 Aug 2021 15:55:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=r82EXC6m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233613AbhHNWxR (ORCPT + 99 others); Sat, 14 Aug 2021 18:53:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233223AbhHNWxQ (ORCPT ); Sat, 14 Aug 2021 18:53:16 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A13BEC061764 for ; Sat, 14 Aug 2021 15:52:47 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id c12so8265404ljr.5 for ; Sat, 14 Aug 2021 15:52:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=gkJO73YRk3QGSnXa3a/jzv/FQTbPeEQgelsyLZQoqKU=; b=r82EXC6mAkPDrvFMZW4X8doFflMMnxOdP8em34Yi13pMRUhr3qtpGvibRm6l25ch4Y Gh1r3xhgfphKRiIWrg+NZiWHpfKHDDPCrr4LT1d842XokIlbTGGJ/iUM1bBGvKIzrzKK VL/jEsDymKxkS8ntVfNfmFNiSnYtAhT0IRPuSCqyTHYmtsTtFx1IUO9JwBYe31PSgtN4 lJL2pjHRUT8EbCnhfh8Px8KX7Gg3fifHVSKMYYWobB+Ae/XApS7IU40UhC1Go206g25G yg91wBgwB1L9cDSJG+T1R2ZadavjrMSGOTp5VtJfNnEiYubBpyP8MFA/UTwSTZc2beak LAJA== 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:content-transfer-encoding :in-reply-to:user-agent; bh=gkJO73YRk3QGSnXa3a/jzv/FQTbPeEQgelsyLZQoqKU=; b=c4eX3LNA8tXolbLEDbnau2cmKEsu1tdqIKrNyYMvpiBaUgWNh97Gu4RWKjN7l1Z8NR BQSFjwWPbNWiKqCKV4jbznpY8l+jNxJ+8AOuSia7wIsLGKsyDoROduhyuW/tNkB+D6ni VCeaqWSt3fgBgZHP8l0okP84kCcsGdpJ0HyHMLdSu8Sd9Ib1Vb2pxYgpmB1KeCNE7v7q CQNvbnv7SFTlBd/vTFKUnBxyxHO5/+iEZ3Sc4OUQZYXtkGoI/qRNexoktC9zHF0Uc9gg 62ZL00Kh8F3mNqlpTEp0le8dQQVizZENc5HSXOuHBVBx9Un6vKI4xf2u96jtQWQKsNVk eEsg== X-Gm-Message-State: AOAM5311xKGqehEJHw7lpFpTtgZVviOohEqAxbNjyR3J5NsVfne3sY1/ SFZz7gbVOXNQ1atoGlRhenDCH7MTcuk= X-Received: by 2002:a2e:a784:: with SMTP id c4mr6968438ljf.479.1628981565946; Sat, 14 Aug 2021 15:52:45 -0700 (PDT) Received: from home.paul.comp (paulfertser.info. [2001:470:26:54b:226:9eff:fe70:80c2]) by smtp.gmail.com with ESMTPSA id y6sm516221lfa.122.2021.08.14.15.52.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Aug 2021 15:52:45 -0700 (PDT) Received: from home.paul.comp (home.paul.comp [IPv6:0:0:0:0:0:0:0:1]) by home.paul.comp (8.15.2/8.15.2/Debian-14~deb10u1) with ESMTP id 17EMqhbc008737; Sun, 15 Aug 2021 01:52:44 +0300 Received: (from paul@localhost) by home.paul.comp (8.15.2/8.15.2/Submit) id 17EMqgX4008736; Sun, 15 Aug 2021 01:52:42 +0300 Date: Sun, 15 Aug 2021 01:52:42 +0300 From: Paul Fertser To: Ivan Mikhaylov Cc: Alessandro Zummo , Alexandre Belloni , openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] rtc: pch-rtc: add RTC driver for Intel Series PCH Message-ID: <20210814225242.GY15173@home.paul.comp> References: <20210810154436.125678-1-i.mikhaylov@yadro.com> <20210810154436.125678-2-i.mikhaylov@yadro.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210810154436.125678-2-i.mikhaylov@yadro.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 10, 2021 at 06:44:35PM +0300, Ivan Mikhaylov wrote: > +config RTC_DRV_PCH > + tristate "PCH RTC driver" > + help > + If you say yes here you get support for the Intel Series PCH I'm afraid this is really lacking some specification of devices that are supported. Is it really everything that Intel currently calls PCH? > +static int pch_rtc_read_time(struct device *dev, struct rtc_time *tm) > +{ > + struct i2c_client *client = to_i2c_client(dev); > + struct pch *pch = i2c_get_clientdata(client); > + unsigned char rtc_data[NUM_TIME_REGS] = {0}; > + int rc; > + > + rc = regmap_bulk_read(pch->regmap, PCH_REG_SC, rtc_data, NUM_TIME_REGS); > + if (rc < 0) { > + dev_err(dev, "fail to read time reg(%d)\n", rc); > + return rc; > + } Citing 26.7.2.3 from C620 (Lewisburg/Purley) datasheet: "The PCH SMBus slave interface only supports Byte Read operation. The external SMBus master will read the RTC time bytes one after another. It is software’s responsibility to check and manage the possible time rollover when subsequent time bytes are read. For example, assuming the RTC time is 11 hours: 59 minutes: 59 seconds. When the external SMBus master reads the hour as 11, then proceeds to read the minute, it is possible that the rollover happens between the reads and the minute is read as 0. This results in 11 hours: 0 minutes instead of the correct time of 12 hours: 0 minutes. Unless it is certain that rollover will not occur, software is required to detect the possible time rollover by reading multiple times such that the read time bytes can be adjusted accordingly if needed." Should this be taken additional care of somehow? > +static ssize_t force_off_store(struct device *dev, > + struct device_attribute *attr, > + const char *buf, size_t count) > +{ > + struct i2c_client *client = to_i2c_client(dev); > + struct pch *pch = i2c_get_clientdata(client); > + unsigned long val; > + int rc; > + > + if (kstrtoul(buf, 10, &val)) > + return -EINVAL; > + > + if (val) { > + /* 0x02 host force off */ I wonder why you write "host force off" while the C620 datasheet calls it "Unconditional Power Down", does your PCH manual use different naming? In any case this doesn't belong to an RTC driver, as previously noted. -- Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software! mailto:fercerpav@gmail.com