From patchwork Mon Jun 24 10:23:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emanuele Ghidoli X-Patchwork-Id: 13709294 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3054013B2B8; Mon, 24 Jun 2024 10:24:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719224669; cv=none; b=MdfAH0CrfClXPaL/YKu5cNSysRp9gql2QxY0BN5d4jw/Gr/fmTlWnQA8vXKXyQ1IHZhj037W0nX1bW63g3totQGBdqjb8Xqc75Bm5zdVmnBItF/mglKlW6W4sic+EhcB2GEh+QHcuct5NuaBHGca86OK36MGoCONiGr4UTZBLgY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719224669; c=relaxed/simple; bh=KdIGeyWdRKZzO8NP9ZkQ5U+ppGVbhZBCX2qqL5ZjDNo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BYQfg6fntKQ8skOY07nIjaNzq8siD6MptglkJo65+HYS7TCRtTk823yBbNBPSJ4DROwF8H19blK7aj8w4TJiQTUGbkNQ7nh15d8bjm6vsLw2N5PoQzRp939DzBsUYSEvl2Uk38SiGuigpAROQ9ZFaUZH5WpJMh1HYcyh/Pd19S0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nqL08QmP; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nqL08QmP" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-42278f3aea4so34482975e9.1; Mon, 24 Jun 2024 03:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719224666; x=1719829466; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FFxwAQjS1MtSOpGwk1XEKmlAhT8y2ybUUwre8SCcIKY=; b=nqL08QmPZ2Z8LdNDDoP0yDgcvB8A/L4b8T7B15393xlXaqC/aKjx8+9dhbFFx/LEo8 8+s3f7+YWeP8uCaTgjWG7AEKptDy2QG6w4q7iiua3uQwiw2iVSv+Cm8EcBmM7YWw8NQC LcdLPPy41tZvQheADrnb7wS5In4cB4ObTz6Th45Rkq64aW9gpKNBOfCHhuOGA6KF/Vtz kl44FlQhsN/h4AzUwJySlfvy5BJW8ivZ55MmG7k2y8Klsl/rqhUR86Ym5ZMR3IByYkqd /8zTusnKgJivyu7zwzDXq8it6vZX62tErGjKXT4tHTEbhiYjDr+m8289OsYx17rME893 Qz9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719224666; x=1719829466; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FFxwAQjS1MtSOpGwk1XEKmlAhT8y2ybUUwre8SCcIKY=; b=srznzUg+J1QKMlgT50lb9ZzErEDyR+b2qXt0f6yy9DQIPXu5tGWdgMvm625K/oXRqM vztApnZRU7TvZeC8Sgwd22lSHnkut937V13Ej/ommnDEtskHYaSqohrUDr29uWB7jdj1 SZbcJldW6XCgokg5LuBXw8oK0Qi56bKhShQLWqZ7TT0hUYQKC00AyfwLlSNIeRisvfvz tkQzuqiIr8dQ/agQZVebcZE6BWPeQAfFwkKTwZ1ICgc2AQbzUJrEK2HfPEKa8wfh08nF u32n2gRJx+ahjEZFYC5ZsUS7AmfMVs3/1slSuPMtUyhlOD1yHY9VeHBl6KvLpXv1RQps MEww== X-Forwarded-Encrypted: i=1; AJvYcCXRdKILDhxcX3k6iPMrgkcmNMb1CqwxLmKPXWIYqRtqCBkQXQUyb23jh9jPcwKd1SeVZdyxVsbr4ZJmYOR18P05cTtAy7BJ4ycmLrNx64r1Yq95dgoXRY4etQYPfTJ4UYdG/21SYtAAn0lxxpZ0LweVI0EQyO8Bk3yKmLV0odNP9PlkODyFwaBs X-Gm-Message-State: AOJu0Yw/fZrDrqaNM7W4r7K+jb5O6X7eRn5iu0M/VVRKLEa7ap9Q8y08 NQ6JoOQP2eMTR+4+/GKB8ILwuwQvRCAMdxvELi32UuY/Er28Jui6ZxlWdxl/ X-Google-Smtp-Source: AGHT+IFjukPDfaUNJnc18ZZK0odySizFOwxw8N5zekxjkntxnPupdFk0N892gbNLhvE1f5YZP4hZYw== X-Received: by 2002:a5d:59a4:0:b0:366:f6bd:a544 with SMTP id ffacd0b85a97d-366f6bda67cmr1334669f8f.71.1719224666236; Mon, 24 Jun 2024 03:24:26 -0700 (PDT) Received: from localhost.localdomain ([2001:b07:aac:705d:6ec5:53d3:2412:2d96]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3663a2f6af9sm9685315f8f.73.2024.06.24.03.24.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 03:24:25 -0700 (PDT) From: Emanuele Ghidoli To: alexandre.belloni@bootlin.com, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, linux-kselftest@vger.kernel.org, shuah@kernel.org Cc: Emanuele Ghidoli , jjang@nvidia.com, kobak@nvidia.com, mochs@nvidia.com Subject: [PATCH v1 1/2] rtc: ds1307: set one-minute alarm resolution for rx_8130 Date: Mon, 24 Jun 2024 12:23:53 +0200 Message-Id: <20240624102354.894871-2-ghidoliemanuele@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240624102354.894871-1-ghidoliemanuele@gmail.com> References: <20240624102354.894871-1-ghidoliemanuele@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Emanuele Ghidoli Set one-minute alarm resolution for the rx_8130 by setting the RTC_FEATURE_ALARM_RES_MINUTE flag according to the hw capabilities. Additionally, set the no_upd_irq flag to disable update interrupts, as it is not possible to generate update IRQs. hwclock fails reading the date and time if the no update irq flag is not set and IRQs is defined in DT. Signed-off-by: Emanuele Ghidoli --- drivers/rtc/rtc-ds1307.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 506b7d1c2397..96e4d82ad915 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -181,6 +181,8 @@ struct ds1307 { struct chip_desc { unsigned alarm:1; + unsigned alarm_res_min:1; + unsigned no_upd_irq:1; u16 nvram_offset; u16 nvram_size; u8 offset; /* register's offset */ @@ -1015,6 +1017,8 @@ static const struct chip_desc chips[last_ds_type] = { }, [rx_8130] = { .alarm = 1, + .alarm_res_min = 1, + .no_upd_irq = 1, /* this is battery backed SRAM */ .nvram_offset = 0x20, .nvram_size = 4, /* 32bit (4 word x 8 bit) */ @@ -1946,10 +1950,16 @@ static int ds1307_probe(struct i2c_client *client) if (IS_ERR(ds1307->rtc)) return PTR_ERR(ds1307->rtc); - if (want_irq || ds1307_can_wakeup_device) + if (want_irq || ds1307_can_wakeup_device) { device_set_wakeup_capable(ds1307->dev, true); - else + if (chip->alarm_res_min) + set_bit(RTC_FEATURE_ALARM_RES_MINUTE, ds1307->rtc->features); + } else { clear_bit(RTC_FEATURE_ALARM, ds1307->rtc->features); + } + + if (chip->no_upd_irq) + clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, ds1307->rtc->features); if (ds1307_can_wakeup_device && !want_irq) { dev_info(ds1307->dev, From patchwork Mon Jun 24 10:23:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emanuele Ghidoli X-Patchwork-Id: 13709295 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 351E513BAC3; Mon, 24 Jun 2024 10:24:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719224671; cv=none; b=r0MhsXi/BMusNKspCF2ckMkTHi7OgQIJ+Q5sSulrUSvUh/li9fkflia3wGPl9xJ9Jzlb9HU8umT0vY62qaQfB+zR4/WcNuyAHsdsD0+XSleFh++ZLbQ50dnKesX/yqaKAoSV7A3yJEd1uWpa1FiCLXqHOKFLkERjcWHWXeCIZDc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719224671; c=relaxed/simple; bh=FxNKrE8jcwE4rIT+PnGILKZCGFn+N9HPzKAqEQC1pzo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oXPnOoqJmO/6P0hxTR6Dd0hANSSHmllLRQOL7lae53c4bQAxuFk+RtkJ4bppCZuslF3GB4rUQBfE60j8eRCxdI+I7YbsyAVV3CM9j+/PazSYFUJ/7Ci1lr+Yrtp3FeJPE9lHG1nLo5a7DgFWbHqtvnlIwhDteUK+ZopKq3luKIY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PyZ9islg; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PyZ9islg" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-3651ee582cfso2250496f8f.2; Mon, 24 Jun 2024 03:24:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719224668; x=1719829468; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lHdI+h5DqWakYO4MXCjstj5TeeRaVKzxo+aLIe7ivLw=; b=PyZ9islgn97IM6kIJZUzouncSHS3ZYsptPvO+sWYoRpgLBmJ9hMB30V+UkBbXsDkGG UH9V/AXIycZu98PI+d1HnN8GJm4NS1vg40UwhI8V6TNECShIRPEX15MVzsJCbnSWL9Ws 4QK0ALcIQ58ehOWDFIgdoJMOcVRJfTWLTsV7GAHoVn83F0PC0hnxELZdCmn5LY6f6Dk2 5RHkxylHZ/PhXkg4E62VMmKgD6Pa0bEiTMEZK7Ew2gKDoumRK0puizbKHgmW+bMTBLVi wX2rYxre9lamdIrNbbu2e+pDJh1GVTT6Nsb+boiQzzK3Fpi4X0jEUW6xkrGz99PqleHe 71sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719224668; x=1719829468; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lHdI+h5DqWakYO4MXCjstj5TeeRaVKzxo+aLIe7ivLw=; b=WKLrjbLU0GgkBP5PD1FyGdCX2QSwdaIGRBWEIChN8e7YgqHlrkA40xo9kt1batROf4 rSLQdliQmwpWVnUPskzv4V6GLe1Ur1zXqS3/KPgFXkRePgQX2PPHLy4/78B4zNpc5DhQ 45uqkdAnwuAUE2o+RMRxYNZVosp9qNGrQ0WIlrQ3e1CSrEMoFNF/N9PixAx1kFEBr/lp ANOs1JP9UB4fYPxmjOseu4RmmlJg1Wud4d0sfT5dN5SQbXR7UCovUWNJmAIEmH4rWatV eoAZRaRbgAipKf8vUYw2TDLqaz4aDqChdhC3IlnkgKBrTitNDdcj99iH5Ot4aLsiHJDo 7snQ== X-Forwarded-Encrypted: i=1; AJvYcCVbbqlmYuutcWPDwyKCcRU6eaIn/WrNguKokZy5TFee/zYGF3XY9lHFVsLDt4XvxgFeKix1W9NUZ3HUe5b29ZuyUAxV98E9UnM179UH0nDTNhbiRmfudBxS/ZApMiudAgaMt14dJfjMU28uJxTEK2ZmyFfiQmHAzBCo7PEj8Qwvxcttt9NB6hok X-Gm-Message-State: AOJu0YzJCzCQK3djhpZRuLH5syaAHBiTqzo3zJo8bnEcmQ7+fFQ8stAm /c+8y7M1tPISu52+5zVizfcW5V7JfczTJvnuI/mdwX7tmEdYV2GC X-Google-Smtp-Source: AGHT+IHIv6eTVUjcCSv5PALPamjZJ2P7b67H8kH7mtEoHBRhV3vZ5HrlkaE6y1SHgknz6Et0SHWPCA== X-Received: by 2002:a5d:448c:0:b0:364:aafb:5fd7 with SMTP id ffacd0b85a97d-366e95d2968mr2825122f8f.45.1719224668366; Mon, 24 Jun 2024 03:24:28 -0700 (PDT) Received: from localhost.localdomain ([2001:b07:aac:705d:6ec5:53d3:2412:2d96]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3663a2f6af9sm9685315f8f.73.2024.06.24.03.24.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 03:24:27 -0700 (PDT) From: Emanuele Ghidoli To: alexandre.belloni@bootlin.com, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, linux-kselftest@vger.kernel.org, shuah@kernel.org Cc: Emanuele Ghidoli , jjang@nvidia.com, kobak@nvidia.com, mochs@nvidia.com Subject: [PATCH v1 2/2] selftests: rtc: rtctest: skip alarm test if alarm resolution is one minute Date: Mon, 24 Jun 2024 12:23:54 +0200 Message-Id: <20240624102354.894871-3-ghidoliemanuele@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240624102354.894871-1-ghidoliemanuele@gmail.com> References: <20240624102354.894871-1-ghidoliemanuele@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Emanuele Ghidoli There are two types of alarm tests: one that tests alarms on minute boundaries and another that tests alarms on second boundaries. For RTCs with one-minute resolution, only the minute boundary test should be run. Skip the second boundary alarm test for these RTCs. Signed-off-by: Emanuele Ghidoli --- tools/testing/selftests/rtc/rtctest.c | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/testing/selftests/rtc/rtctest.c b/tools/testing/selftests/rtc/rtctest.c index 63ce02d1d5cc..d741a548ef76 100644 --- a/tools/testing/selftests/rtc/rtctest.c +++ b/tools/testing/selftests/rtc/rtctest.c @@ -82,6 +82,22 @@ static void nanosleep_with_retries(long ns) } } +static int rtc_get_features(int fd, uint64_t *features) +{ + struct rtc_param param = { 0 }; + int rc; + + param.param = RTC_PARAM_FEATURES; + param.index = 0; + rc = ioctl(fd, RTC_PARAM_GET, ¶m); + if (rc < 0) + return rc; + + *features = param.uvalue; + + return 0; +} + TEST_F_TIMEOUT(rtc, date_read_loop, READ_LOOP_DURATION_SEC + 2) { int rc; long iter_count = 0; @@ -197,6 +213,13 @@ TEST_F(rtc, alarm_alm_set) { fd_set readfds; time_t secs, new; int rc; + int rc_feat; + uint64_t rtc_feat; + + rc_feat = rtc_get_features(self->fd, &rtc_feat); + + if (!rc_feat && (rtc_feat & _BITUL(RTC_FEATURE_ALARM_RES_MINUTE))) + SKIP(return, "Skipping test since only one minute resolution alarms are supported."); if (self->fd == -1 && errno == ENOENT) SKIP(return, "Skipping test since %s does not exist", rtc_file); @@ -255,6 +278,13 @@ TEST_F(rtc, alarm_wkalm_set) { fd_set readfds; time_t secs, new; int rc; + int rc_feat; + uint64_t rtc_feat; + + rc_feat = rtc_get_features(self->fd, &rtc_feat); + + if (!rc_feat && (rtc_feat & _BITUL(RTC_FEATURE_ALARM_RES_MINUTE))) + SKIP(return, "Skipping test since only one minute resolution alarms are supported."); if (self->fd == -1 && errno == ENOENT) SKIP(return, "Skipping test since %s does not exist", rtc_file);