From 61598093bbdd283a7edc367d900f223070ead8d2 Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Fri, 10 May 2024 07:43:03 +0000 Subject: [PATCH] add ax88772C AX88772C_eeprom_tools --- kernel/drivers/rtc/rtc-imxdi.c | 58 ++++++++++++++++++++-------------------------------------- 1 files changed, 20 insertions(+), 38 deletions(-) diff --git a/kernel/drivers/rtc/rtc-imxdi.c b/kernel/drivers/rtc/rtc-imxdi.c index 8093111..8d141d8 100644 --- a/kernel/drivers/rtc/rtc-imxdi.c +++ b/kernel/drivers/rtc/rtc-imxdi.c @@ -1,18 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved. * Copyright 2010 Orex Computed Radiography */ - -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -/* based on rtc-mc13892.c */ /* * This driver uses the 47-bit 32 kHz counter in the Freescale DryIce block @@ -105,7 +95,7 @@ /** * struct imxdi_dev - private imxdi rtc data - * @pdev: pionter to platform dev + * @pdev: pointer to platform dev * @rtc: pointer to rtc struct * @ioaddr: IO registers pointer * @clk: input reference clock @@ -360,7 +350,7 @@ * the tamper register is locked. We cannot disable the * tamper detection. The TDCHL can only be reset by a * DRYICE POR, but we cannot force a DRYICE POR in - * softwere because we are still in "FAILURE STATE". + * software because we are still in "FAILURE STATE". * We need a DRYICE POR via battery power cycling.... */ /* @@ -552,7 +542,7 @@ unsigned long now; now = readl(imxdi->ioaddr + DTCMR); - rtc_time_to_tm(now, tm); + rtc_time64_to_tm(now, tm); return 0; } @@ -561,7 +551,7 @@ * set the seconds portion of dryice time counter and clear the * fractional part. */ -static int dryice_rtc_set_mmss(struct device *dev, unsigned long secs) +static int dryice_rtc_set_time(struct device *dev, struct rtc_time *tm) { struct imxdi_dev *imxdi = dev_get_drvdata(dev); u32 dcr, dsr; @@ -588,7 +578,7 @@ if (rc != 0) return rc; - rc = di_write_wait(imxdi, secs, DTCMR); + rc = di_write_wait(imxdi, rtc_tm_to_time64(tm), DTCMR); if (rc != 0) return rc; @@ -618,7 +608,7 @@ u32 dcamr; dcamr = readl(imxdi->ioaddr + DCAMR); - rtc_time_to_tm(dcamr, &alarm->time); + rtc_time64_to_tm(dcamr, &alarm->time); /* alarm is enabled if the interrupt is enabled */ alarm->enabled = (readl(imxdi->ioaddr + DIER) & DIER_CAIE) != 0; @@ -640,21 +630,10 @@ static int dryice_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) { struct imxdi_dev *imxdi = dev_get_drvdata(dev); - unsigned long now; - unsigned long alarm_time; int rc; - rc = rtc_tm_to_time(&alarm->time, &alarm_time); - if (rc) - return rc; - - /* don't allow setting alarm in the past */ - now = readl(imxdi->ioaddr + DTCMR); - if (alarm_time < now) - return -EINVAL; - /* write the new alarm time */ - rc = di_write_wait(imxdi, (u32)alarm_time, DCAMR); + rc = di_write_wait(imxdi, rtc_tm_to_time64(&alarm->time), DCAMR); if (rc) return rc; @@ -668,7 +647,7 @@ static const struct rtc_class_ops dryice_rtc_ops = { .read_time = dryice_rtc_read_time, - .set_mmss = dryice_rtc_set_mmss, + .set_time = dryice_rtc_set_time, .alarm_irq_enable = dryice_rtc_alarm_irq_enable, .read_alarm = dryice_rtc_read_alarm, .set_alarm = dryice_rtc_set_alarm, @@ -761,7 +740,6 @@ */ static int __init dryice_rtc_probe(struct platform_device *pdev) { - struct resource *res; struct imxdi_dev *imxdi; int norm_irq, sec_irq; int rc; @@ -772,8 +750,7 @@ imxdi->pdev = pdev; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - imxdi->ioaddr = devm_ioremap_resource(&pdev->dev, res); + imxdi->ioaddr = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(imxdi->ioaddr)) return PTR_ERR(imxdi->ioaddr); @@ -795,6 +772,10 @@ INIT_WORK(&imxdi->work, dryice_work); mutex_init(&imxdi->write_mutex); + + imxdi->rtc = devm_rtc_allocate_device(&pdev->dev); + if (IS_ERR(imxdi->rtc)) + return PTR_ERR(imxdi->rtc); imxdi->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(imxdi->clk)) @@ -829,12 +810,13 @@ } platform_set_drvdata(pdev, imxdi); - imxdi->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, - &dryice_rtc_ops, THIS_MODULE); - if (IS_ERR(imxdi->rtc)) { - rc = PTR_ERR(imxdi->rtc); + + imxdi->rtc->ops = &dryice_rtc_ops; + imxdi->rtc->range_max = U32_MAX; + + rc = rtc_register_device(imxdi->rtc); + if (rc) goto err; - } return 0; -- Gitblit v1.6.2