From nobody Wed Nov 27 07:43:56 2024 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (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 070E43EA71 for ; Sun, 13 Oct 2024 05:22:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728796961; cv=none; b=dlYfsFcpxALJnxCWN19wUhpxkCuBbYis68TfC5Ub+flwWQsnAkwKow06Owr79t+Ry1iyeEleCBn7/mSJVTmJn4GivBlEYvDk1dojEW5SP1J0y//EjVaRjZ8ZKV01AuIeVeGYhxf/xQqOrI8HHhMt2J+ePXbU3ywjSF3c9Dtjlvc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728796961; c=relaxed/simple; bh=4MZOvQKHClittUmpnQnoq/i+2Op7x5TOc+aMOdSKGRQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KGmO52d48Us7kTc6BiQAYeaUfwoDZ7XJ2Votbrkx8CxZMD/4DL7DAqHgwqXZxXf8KRWOtzmp2b+r26qNGMJsx4AXuuCnNWl1oxdX7XwDyLNYyQGP1Plb2B4QbIhgfW2pdmCQelKGSWnHYSOXFJIGTuMQFShp98LQGuMhM/4i0vE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=marek.ca; spf=pass smtp.mailfrom=marek.ca; dkim=pass (2048-bit key) header.d=marek.ca header.i=@marek.ca header.b=cvx74f9L; arc=none smtp.client-ip=209.85.219.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=marek.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marek.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marek.ca header.i=@marek.ca header.b="cvx74f9L" Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-6cbe68f787dso20991326d6.2 for ; Sat, 12 Oct 2024 22:22:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marek.ca; s=google; t=1728796959; x=1729401759; 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=B6xxZ43bcNrMRSyYePE5aWtWwfMTqg7K7KAOvUgotws=; b=cvx74f9LirfQIpvi8uN+yNHViK0Vu5/j8Nqhu8mJsOjnvlJnZjFHvLWxq9p5J56oS3 ESmsViBMhZ3sZH9LDwsD0zVlm2Y+XChD2MBvTNfBem/Nx8ToFBOofCXy4vuSKOHmW7ya OVp/94rTQ6sGxK7OMI3HsyFTqenU57uuO5HOWQlxfbMDfeqkgxkq33ko5S+2w0oW+JIT R7giN2IZfnR1rlVFfOX3uqwpWX00GmrKU7x7RSZR19LBKIOlZyk+4p1RLgU2WOkvMeG9 dmQhnSiFJAD9OftS4iO3wwSlsm0yKGRxs+RTJ4VKBkLmrT4ktctz0jZTdNh0gcYJgmiX QY0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728796959; x=1729401759; 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=B6xxZ43bcNrMRSyYePE5aWtWwfMTqg7K7KAOvUgotws=; b=dmtcdjsePUvBMH6lUdgkLrUW3XzKczNVZnasW9iGcMHl5Hs0x9TFgGCQnxDCYyS61z GHKoMTI4qw5E8AFG2jHX/ZKvdh/qyvQIVOebJskjMbOond2w272HJkN8fEnKRXCyMtlr Cf1yx6/BUV3ZRLLrIr7kHoCAoNKj5fKS9XKU/3KsvBirIZYsWX14zyM3QvtytKUjID8M mCyCltpN5lQQF0TUZKs0sdkvov5wwI9MK2YIeM9iRKgnLUM5ps2Qp66RQFVws628dnx1 5GVGWdQk9AJ8jMZ9KBrLncSndGWkGjNJUueemsP1GofqUMcYIdaRGFxE4EJ5yzqqqthv MBMg== X-Forwarded-Encrypted: i=1; AJvYcCU5VzrrxAldSyxXVItGtLXIiSE4FX3zOInQ75i5UkOKxuJ6CjRfSX5s3twuo+TtpEhTvFuUADbfGX4S95E=@vger.kernel.org X-Gm-Message-State: AOJu0YwWoE8ns76aGTJJcSxB1gJdEQZa54T/vmV6NZMXYM+X00dH1QLX EE7+TIFgOqE4N6xDM3uDPSgU1oYqHZkGXI82xpl8wF6+mx995VCPet6EYhjWTgA= X-Google-Smtp-Source: AGHT+IHsbqqTS9ovb3ovjSqTfhAbFTCjDmWZz0KsigO/gs/tDfosJX8dkKPETxwqd4+611XM0iYC4A== X-Received: by 2002:a05:6214:5d0c:b0:6cb:f991:ec51 with SMTP id 6a1803df08f44-6cbf991ec9bmr71722876d6.45.1728796958920; Sat, 12 Oct 2024 22:22:38 -0700 (PDT) Received: from localhost.localdomain (modemcable125.110-19-135.mc.videotron.ca. [135.19.110.125]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cbe8608e2csm31821496d6.102.2024.10.12.22.22.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Oct 2024 22:22:38 -0700 (PDT) From: Jonathan Marek To: linux-arm-msm@vger.kernel.org Cc: Alexandre Belloni , linux-rtc@vger.kernel.org (open list:REAL TIME CLOCK (RTC) SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 1/5] rtc: pm8xxx: implement no-alarm flag for non-HLOS owned alarm Date: Sun, 13 Oct 2024 01:15:26 -0400 Message-ID: <20241013051859.22800-2-jonathan@marek.ca> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20241013051859.22800-1-jonathan@marek.ca> References: <20241013051859.22800-1-jonathan@marek.ca> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Qualcomm x1e80100 firmware sets the ownership of the RTC alarm to ADSP. Thus writing to RTC alarm registers and receiving alarm interrupts is not possible. Add a no-alarm flag to support RTC on this platform. Signed-off-by: Jonathan Marek --- drivers/rtc/rtc-pm8xxx.c | 43 +++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index c32fba550c8e0..0de55779b04f7 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -61,6 +61,7 @@ struct pm8xxx_rtc { struct rtc_device *rtc; struct regmap *regmap; bool allow_set_time; + bool no_alarm; int alarm_irq; const struct pm8xxx_rtc_regs *regs; struct device *dev; @@ -473,9 +474,13 @@ static int pm8xxx_rtc_probe(struct platform_device *pd= ev) if (!rtc_dd->regmap) return -ENXIO; =20 - rtc_dd->alarm_irq =3D platform_get_irq(pdev, 0); - if (rtc_dd->alarm_irq < 0) - return -ENXIO; + rtc_dd->no_alarm =3D of_property_read_bool(pdev->dev.of_node, "no-alarm"); + + if (!rtc_dd->no_alarm) { + rtc_dd->alarm_irq =3D platform_get_irq(pdev, 0); + if (rtc_dd->alarm_irq < 0) + return -ENXIO; + } =20 rtc_dd->allow_set_time =3D of_property_read_bool(pdev->dev.of_node, "allow-set-time"); @@ -503,7 +508,8 @@ static int pm8xxx_rtc_probe(struct platform_device *pde= v) =20 platform_set_drvdata(pdev, rtc_dd); =20 - device_init_wakeup(&pdev->dev, 1); + if (!rtc_dd->no_alarm) + device_init_wakeup(&pdev->dev, 1); =20 rtc_dd->rtc =3D devm_rtc_allocate_device(&pdev->dev); if (IS_ERR(rtc_dd->rtc)) @@ -512,27 +518,36 @@ static int pm8xxx_rtc_probe(struct platform_device *p= dev) rtc_dd->rtc->ops =3D &pm8xxx_rtc_ops; rtc_dd->rtc->range_max =3D U32_MAX; =20 - rc =3D devm_request_any_context_irq(&pdev->dev, rtc_dd->alarm_irq, - pm8xxx_alarm_trigger, - IRQF_TRIGGER_RISING, - "pm8xxx_rtc_alarm", rtc_dd); - if (rc < 0) - return rc; + if (!rtc_dd->no_alarm) { + rc =3D devm_request_any_context_irq(&pdev->dev, rtc_dd->alarm_irq, + pm8xxx_alarm_trigger, + IRQF_TRIGGER_RISING, + "pm8xxx_rtc_alarm", rtc_dd); + if (rc < 0) + return rc; + } =20 rc =3D devm_rtc_register_device(rtc_dd->rtc); if (rc) return rc; =20 - rc =3D dev_pm_set_wake_irq(&pdev->dev, rtc_dd->alarm_irq); - if (rc) - return rc; + if (!rtc_dd->no_alarm) { + rc =3D dev_pm_set_wake_irq(&pdev->dev, rtc_dd->alarm_irq); + if (rc) + return rc; + } else { + clear_bit(RTC_FEATURE_ALARM, rtc_dd->rtc->features); + } =20 return 0; } =20 static void pm8xxx_remove(struct platform_device *pdev) { - dev_pm_clear_wake_irq(&pdev->dev); + struct pm8xxx_rtc *rtc_dd =3D platform_get_drvdata(pdev); + + if (!rtc_dd->no_alarm) + dev_pm_clear_wake_irq(&pdev->dev); } =20 static struct platform_driver pm8xxx_rtc_driver =3D { --=20 2.45.1