From patchwork Tue Jun 18 15:26:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13702519 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6B656200B7; Tue, 18 Jun 2024 15:26:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718724413; cv=none; b=D8CNhLpSGk14FCjxFQppdnArfbHNejFr2LYuvqYaPnH5VPFKRY683PzbFxpvsUio17xqIufzLGKMIBTB07hHEiSNlFUPUS0Y0+2KtsMnRy6SmB2wLVCbfpCDPWDKswM+315DPz8+bHhlGP6zmP+wgncAKr5Vhg1Az9h6yAN2mXs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718724413; c=relaxed/simple; bh=wC1F57KiEMRBwimtAXPqU6OCnb10sX4cGliwg7ktSpg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mk88twJVOg9p66EiQ2A47fFHQGCBFVK42IZ4wVZ2BXl0onlpSG8bJWpN6LhqqKE97htDcZUeZSYTB5SmL1ccj0ZRnv5nC4zur4ZOz4wI42kn74UX8c/EBdI0BTrK87t+PtJxmHIJdebqxPTwBuFvXeTh+W14mxI5NYe3464ASvQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com; spf=pass smtp.mailfrom=bp.renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bp.renesas.com X-IronPort-AV: E=Sophos;i="6.08,247,1712588400"; d="scan'208";a="208427472" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 19 Jun 2024 00:26:43 +0900 Received: from localhost.localdomain (unknown [10.226.93.44]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 004924006A90; Wed, 19 Jun 2024 00:26:40 +0900 (JST) From: Biju Das To: Alexandre Belloni Cc: Biju Das , linux-rtc@vger.kernel.org, Geert Uytterhoeven , Prabhakar Mahadev Lad , Biju Das , linux-renesas-soc@vger.kernel.org Subject: [PATCH 1/2] rtc: isl1208: Add a delay for clearing alarm Date: Tue, 18 Jun 2024 16:26:30 +0100 Message-ID: <20240618152635.48956-2-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240618152635.48956-1-biju.das.jz@bp.renesas.com> References: <20240618152635.48956-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 As per the latest HW manual[1], the INT# output is pulled low after the alarm is triggered. After the INT# output is pulled low, it is low for at least 250ms, even if the correct action is taken to clear it. It is impossible to clear ALM if it is still active. The host must wait for the RTC to progress past the alarm time plus the 250ms delay before clearing ALM. [1]https://www.renesas.com/us/en/document/dst/raa215300-datasheet?r=1506351 Signed-off-by: Biju Das --- drivers/rtc/rtc-isl1208.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c index e50c23ee1646..c58063d917d6 100644 --- a/drivers/rtc/rtc-isl1208.c +++ b/drivers/rtc/rtc-isl1208.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -628,6 +629,18 @@ isl1208_rtc_interrupt(int irq, void *data) struct isl1208_state *isl1208 = i2c_get_clientdata(client); int handled = 0, sr, err; + if (!isl1208->config->has_tamper) { + /* + * The INT# output is pulled low 250ms after the alarm is + * triggered. After the INT# output is pulled low, it is low for + * at least 250ms, even if the correct action is taken to clear + * it. It is impossible to clear ALM if it is still active. The + * host must wait for the RTC to progress past the alarm time + * plus the 250ms delay before clearing ALM. + */ + msleep(250); + } + /* * I2C reads get NAK'ed if we read straight away after an interrupt? * Using a mdelay/msleep didn't seem to help either, so we work around From patchwork Tue Jun 18 15:26:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13702520 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7CBCD1E895; Tue, 18 Jun 2024 15:26:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718724414; cv=none; b=ouHAmFwnqimqQA/URbO9wWnrnBX6H8tW39uSSyFz0MucUxPpE/V1T+SrJ1hmKhme8X+mUHExst7mW6Q6/iPFltm/wEFwqzTuCxn3zMkv41h+EsdFtp0yJuv/Hwgz4SdaBxw8UOt3tkRj8YuZxzPMq9+bkMuc8xDgCsGmC3LnhGk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718724414; c=relaxed/simple; bh=QFAInPUce4gQwzxkZrTMM7V/0YYUWyI2QbB1zcT0lNc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CLFYuE3j1+EGg2i9Dw7+92bI0ahdI+ltI2HKNY5v67eW+xm3gMt8eV2ukqfZX/SdJqzuhNZXCkGqzRcrlxJxVuHWIG67ZOjKHYnYz/Yq8/EpH7Bwwgq12116+7EenwP7rsQhW4lviT/5b4zVX3V7ljaaxSegRz7LYcA5JjSk6zM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com; spf=pass smtp.mailfrom=bp.renesas.com; arc=none smtp.client-ip=210.160.252.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bp.renesas.com X-IronPort-AV: E=Sophos;i="6.08,247,1712588400"; d="scan'208";a="212384989" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 19 Jun 2024 00:26:46 +0900 Received: from localhost.localdomain (unknown [10.226.93.44]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id CA6414006A90; Wed, 19 Jun 2024 00:26:43 +0900 (JST) From: Biju Das To: Alexandre Belloni Cc: Biju Das , linux-rtc@vger.kernel.org, Geert Uytterhoeven , Prabhakar Mahadev Lad , Biju Das , linux-renesas-soc@vger.kernel.org Subject: [PATCH 2/2] rtc: isl1208: Update correct procedure for clearing alarm Date: Tue, 18 Jun 2024 16:26:31 +0100 Message-ID: <20240618152635.48956-3-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240618152635.48956-1-biju.das.jz@bp.renesas.com> References: <20240618152635.48956-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 As per the latest HW manual[1], there is an internal delay(~250 microsec) from setting ALME = 0 to disabling the alarm function, so the user must add a short delay of greater than 250µs between setting ALME = 0 and clearing ALM. Currently setting of ALME = 0 is done after clearing the ALM, so just reverse the operation and add a delay of 275 microsec. [1]https://www.renesas.com/us/en/document/dst/raa215300-datasheet?r=1506351 Signed-off-by: Biju Das --- drivers/rtc/rtc-isl1208.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c index c58063d917d6..3df5605134fa 100644 --- a/drivers/rtc/rtc-isl1208.c +++ b/drivers/rtc/rtc-isl1208.c @@ -663,6 +663,13 @@ isl1208_rtc_interrupt(int irq, void *data) rtc_update_irq(isl1208->rtc, 1, RTC_IRQF | RTC_AF); + /* Disable the alarm */ + err = isl1208_rtc_toggle_alarm(client, 0); + if (err) + return err; + + fsleep(275); + /* Clear the alarm */ sr &= ~ISL1208_REG_SR_ALM; sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR, sr); @@ -671,11 +678,6 @@ isl1208_rtc_interrupt(int irq, void *data) __func__); else handled = 1; - - /* Disable the alarm */ - err = isl1208_rtc_toggle_alarm(client, 0); - if (err) - return err; } if (isl1208->config->has_tamper && (sr & ISL1208_REG_SR_EVT)) {