Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp843042lqb; Wed, 17 Apr 2024 12:20:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVy5XIvvtw0d56k9brq4r06glK3VwguqcIys9PUpHrsuMq8Bq4hYkEZdzpvhtOICSFm8jpCiAUpoUct9oU4kEIR69tC5T1Zc0CUVGLA1Q== X-Google-Smtp-Source: AGHT+IH46fYve41UrWbeVCOdyzW80vOtvbljbCUO22bDZy5QdBKj0eJbJWJBsSIKSdGGWNYmU12I X-Received: by 2002:a05:622a:3:b0:436:64e5:42c3 with SMTP id x3-20020a05622a000300b0043664e542c3mr442735qtw.51.1713381611722; Wed, 17 Apr 2024 12:20:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713381611; cv=pass; d=google.com; s=arc-20160816; b=FE/XTxkW5Kyh6SEsxxjUbDNNOz7BLzgn2xZuCgfbqg7sQufsQcNUYtIjuzRx/mjJun giMzlVxUu2OLf68Rn4ZyhqAqBURf7PaxMk06cHpkO86vv3Y7qmysiAAJZPFo2Gs785le 4FCpj4frdXAYe1Cq5CEf8ctK3Sn0BSeyXikVNOQHWVbaFO2xgwBMQddxtzCvdmVkf1cE ixvtGLcO9/iijrG1YhmH8YefgMwGJyi0he0xnXMP0yvlz69C7Z6hiJYaaRvCImkdWpwv aS25hWwMU1oW+ykVx81611Y7/b0CoQM4N/8GUZ3bPZVXFP1y0o9Ly6ibNRu43YVcXV8D Zq3A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=jQo9vcuwNFak9EahRUpeiFOj0bXZpNg5mHU6fet7Il4=; fh=WU17kdw4RXVKHtu1k8RSL1WNEyq/FnTUIEZGTHaYM9M=; b=sMvQazy804+LhRhK0uo0qDA88LccpydNRxqXbjZY8vvgFwI1RqIAFdK77D5JRS5JRr HjxxfnSyi9eT+aPC+QVMotK2o+mQ2cIpn2F1VMk1nO/qH6lsSkN/vdGG+G0NwDQbBQIr ohJtHQfOzHGYJDRLexuYoNMvt0QsOVvI1i0uE7KKyoVLVHSKSs16nfBE9koPNbQI7DTQ CDIU2pVKKtOKBQTX0I4FGbuExjOeVpuDtmwBClsJXCKRdjiHB0gl1gGlPXZBrKF382nE BxTR0BmepMxQJ3PknxLwI4zfNsU/OYun4buwh2qkCd1OyqLa6Kg4FDU8/lrCLgjX1UOd MiJg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=oIgRsW3U; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-149115-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149115-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 20-20020ac85754000000b004365142e0f7si16294740qtx.385.2024.04.17.12.20.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 12:20:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-149115-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=oIgRsW3U; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-149115-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149115-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7332E1C21A80 for ; Wed, 17 Apr 2024 19:20:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 41D4E2C68A; Wed, 17 Apr 2024 19:20:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="oIgRsW3U" Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25B1A2BB16; Wed, 17 Apr 2024 19:19:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713381599; cv=none; b=F78zuYr/oLOAD2ONQRVPCKIR3iS17hXQXLSgNBc9Y+8CDEmZQKHBcm3krwTThHBZXR9RtZNxFHSs/QFoHW/CkM1DWVa5vonrYicO4XborJbAUlE9tzF1sVV3X4OzJSFdS5MDSsVZ4xqgtAVfNkBERGNJHnGJjYem91Uy59VWNpA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713381599; c=relaxed/simple; bh=1WkTOQjl0bt6iavNqrnDeQegNFNYwXSEDpYVQxuGjJ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LbLZ/9SzyGRYbUJMrMMi3l1M0aUWOrPw+Z/tXqEtjg9/SFR616gXotypVzXSS5ydZ5xMK1MGnR3M6wN+8RrC0+Q82UwOjANyxlHgIUwMl/xOM+kYJ+EVlFWNkr37ZLV4FBUW/2d69iZhtJClFXXvKCU8FXEX4y9scHd8oJEO6MA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=oIgRsW3U; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 4FB9460002; Wed, 17 Apr 2024 19:19:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1713381595; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jQo9vcuwNFak9EahRUpeiFOj0bXZpNg5mHU6fet7Il4=; b=oIgRsW3UbIUkZDmclmiZaDkSJLJ7avJgIK/ktpfLzl05AZRllOBSQFqJaaYSZwKWFpTGMH tnW98VdSuTYN2q0RO298pBc9j+23NzAzm6xeovJUTiy9DcRFfNQcHCcWj78Dzzs517bocA hQLFlp0KV67qLvRR5rpxytjQ/icmuvGVAyW+rkgZaEJkR9+lcp4lVoLn98DZDFVBgyMWPB X1sz8emUKahIZ++XYFsnuWwW0YHrX2wFVoLsrIx7OoWJgaHZ5Vvu5nbShRrAfb+9L9S7eq I4n0qazoUj3C8A7sdxjmk1ayRgJHZGi8dciuNpowoay0e4+kPExrpesO/cvbuA== From: alexandre.belloni@bootlin.com To: Alexandre Belloni Cc: Waqar Hameed , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] rtc: rx8111: handle VLOW flag Date: Wed, 17 Apr 2024 21:19:36 +0200 Message-ID: <20240417191937.33790-2-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240417191937.33790-1-alexandre.belloni@bootlin.com> References: <20240417191937.33790-1-alexandre.belloni@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: alexandre.belloni@bootlin.com From: Alexandre Belloni Allow userspace to get battery status information and be able to warn when battery is low and has to be replaced. Signed-off-by: Alexandre Belloni --- drivers/rtc/rtc-rx8111.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/rtc/rtc-rx8111.c b/drivers/rtc/rtc-rx8111.c index 4a35bd921b33..8450d9f0b566 100644 --- a/drivers/rtc/rtc-rx8111.c +++ b/drivers/rtc/rtc-rx8111.c @@ -95,6 +95,9 @@ enum rx8111_regfield { RX8111_REGF_INIEN, RX8111_REGF_CHGEN, + /* RX8111_REG_STATUS_MON. */ + RX8111_REGF_VLOW, + /* Sentinel value. */ RX8111_REGF_MAX }; @@ -129,6 +132,8 @@ static const struct reg_field rx8111_regfields[] = { [RX8111_REGF_SWSEL1] = REG_FIELD(RX8111_REG_PWR_SWITCH_CTRL, 3, 3), [RX8111_REGF_INIEN] = REG_FIELD(RX8111_REG_PWR_SWITCH_CTRL, 6, 6), [RX8111_REGF_CHGEN] = REG_FIELD(RX8111_REG_PWR_SWITCH_CTRL, 7, 7), + + [RX8111_REGF_VLOW] = REG_FIELD(RX8111_REG_STATUS_MON, 1, 1), }; static const struct regmap_config rx8111_regmap_config = { @@ -276,6 +281,13 @@ static int rx8111_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) vlval = regval ? RTC_VL_DATA_INVALID : 0; + ret = regmap_field_read(data->regfields[RX8111_REGF_VLOW], + ®val); + if (ret) + return ret; + + vlval |= regval ? RTC_VL_BACKUP_LOW : 0; + return put_user(vlval, (typeof(vlval) __user *)arg); default: return -ENOIOCTLCMD; -- 2.44.0