From nobody Sat Apr 18 07:44:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC856C43334 for ; Fri, 15 Jul 2022 13:53:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233010AbiGONxn (ORCPT ); Fri, 15 Jul 2022 09:53:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232699AbiGONxk (ORCPT ); Fri, 15 Jul 2022 09:53:40 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EA9ED83; Fri, 15 Jul 2022 06:53:38 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id C569A34720; Fri, 15 Jul 2022 13:53:36 +0000 (UTC) Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id ACB502C141; Fri, 15 Jul 2022 13:53:36 +0000 (UTC) From: Thomas Bogendoerfer To: Alessandro Zummo , Alexandre Belloni , linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org Subject: [PATCH] rtc: remove VR41XX rtc driver Date: Fri, 15 Jul 2022 15:53:30 +0200 Message-Id: <20220715135330.134684-1-tsbogend@alpha.franken.de> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Commit d3164e2f3b0a ("MIPS: Remove VR41xx support") removed support for MIPS VR41xx platform, so remove exclusive drivers for this platform, too. Signed-off-by: Thomas Bogendoerfer --- drivers/rtc/Kconfig | 10 -- drivers/rtc/Makefile | 1 - drivers/rtc/rtc-vr41xx.c | 363 --------------------------------------- 3 files changed, 374 deletions(-) delete mode 100644 drivers/rtc/rtc-vr41xx.c diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index a00f901b5c1d..70fb26f99147 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -1478,16 +1478,6 @@ config RTC_DRV_SUNPLUS This driver can also be built as a module. If so, the module will be called rtc-sunplus. =20 -config RTC_DRV_VR41XX - tristate "NEC VR41XX" - depends on CPU_VR41XX || COMPILE_TEST - help - If you say Y here you will get access to the real time clock - built into your NEC VR41XX CPU. - - To compile this driver as a module, choose M here: the - module will be called rtc-vr41xx. - config RTC_DRV_PL030 tristate "ARM AMBA PL030 RTC" depends on ARM_AMBA diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index fb04467b652d..514e415208a3 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile @@ -176,7 +176,6 @@ obj-$(CONFIG_RTC_DRV_TPS6586X) +=3D rtc-tps6586x.o obj-$(CONFIG_RTC_DRV_TPS65910) +=3D rtc-tps65910.o obj-$(CONFIG_RTC_DRV_TWL4030) +=3D rtc-twl.o obj-$(CONFIG_RTC_DRV_V3020) +=3D rtc-v3020.o -obj-$(CONFIG_RTC_DRV_VR41XX) +=3D rtc-vr41xx.o obj-$(CONFIG_RTC_DRV_VT8500) +=3D rtc-vt8500.o obj-$(CONFIG_RTC_DRV_WILCO_EC) +=3D rtc-wilco-ec.o obj-$(CONFIG_RTC_DRV_WM831X) +=3D rtc-wm831x.o diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c deleted file mode 100644 index 5a9f9ad86d32..000000000000 --- a/drivers/rtc/rtc-vr41xx.c +++ /dev/null @@ -1,363 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * Driver for NEC VR4100 series Real Time Clock unit. - * - * Copyright (C) 2003-2008 Yoichi Yuasa - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -MODULE_AUTHOR("Yoichi Yuasa "); -MODULE_DESCRIPTION("NEC VR4100 series RTC driver"); -MODULE_LICENSE("GPL v2"); - -/* RTC 1 registers */ -#define ETIMELREG 0x00 -#define ETIMEMREG 0x02 -#define ETIMEHREG 0x04 -/* RFU */ -#define ECMPLREG 0x08 -#define ECMPMREG 0x0a -#define ECMPHREG 0x0c -/* RFU */ -#define RTCL1LREG 0x10 -#define RTCL1HREG 0x12 -#define RTCL1CNTLREG 0x14 -#define RTCL1CNTHREG 0x16 -#define RTCL2LREG 0x18 -#define RTCL2HREG 0x1a -#define RTCL2CNTLREG 0x1c -#define RTCL2CNTHREG 0x1e - -/* RTC 2 registers */ -#define TCLKLREG 0x00 -#define TCLKHREG 0x02 -#define TCLKCNTLREG 0x04 -#define TCLKCNTHREG 0x06 -/* RFU */ -#define RTCINTREG 0x1e - #define TCLOCK_INT 0x08 - #define RTCLONG2_INT 0x04 - #define RTCLONG1_INT 0x02 - #define ELAPSEDTIME_INT 0x01 - -#define RTC_FREQUENCY 32768 -#define MAX_PERIODIC_RATE 6553 - -static void __iomem *rtc1_base; -static void __iomem *rtc2_base; - -#define rtc1_read(offset) readw(rtc1_base + (offset)) -#define rtc1_write(offset, value) writew((value), rtc1_base + (offset)) - -#define rtc2_read(offset) readw(rtc2_base + (offset)) -#define rtc2_write(offset, value) writew((value), rtc2_base + (offset)) - -/* 32-bit compat for ioctls that nobody else uses */ -#define RTC_EPOCH_READ32 _IOR('p', 0x0d, __u32) - -static unsigned long epoch =3D 1970; /* Jan 1 1970 00:00:00 */ - -static DEFINE_SPINLOCK(rtc_lock); -static char rtc_name[] =3D "RTC"; -static unsigned long periodic_count; -static unsigned int alarm_enabled; -static int aie_irq; -static int pie_irq; - -static inline time64_t read_elapsed_second(void) -{ - - unsigned long first_low, first_mid, first_high; - - unsigned long second_low, second_mid, second_high; - - do { - first_low =3D rtc1_read(ETIMELREG); - first_mid =3D rtc1_read(ETIMEMREG); - first_high =3D rtc1_read(ETIMEHREG); - second_low =3D rtc1_read(ETIMELREG); - second_mid =3D rtc1_read(ETIMEMREG); - second_high =3D rtc1_read(ETIMEHREG); - } while (first_low !=3D second_low || first_mid !=3D second_mid || - first_high !=3D second_high); - - return ((u64)first_high << 17) | (first_mid << 1) | (first_low >> 15); -} - -static inline void write_elapsed_second(time64_t sec) -{ - spin_lock_irq(&rtc_lock); - - rtc1_write(ETIMELREG, (uint16_t)(sec << 15)); - rtc1_write(ETIMEMREG, (uint16_t)(sec >> 1)); - rtc1_write(ETIMEHREG, (uint16_t)(sec >> 17)); - - spin_unlock_irq(&rtc_lock); -} - -static int vr41xx_rtc_read_time(struct device *dev, struct rtc_time *time) -{ - time64_t epoch_sec, elapsed_sec; - - epoch_sec =3D mktime64(epoch, 1, 1, 0, 0, 0); - elapsed_sec =3D read_elapsed_second(); - - rtc_time64_to_tm(epoch_sec + elapsed_sec, time); - - return 0; -} - -static int vr41xx_rtc_set_time(struct device *dev, struct rtc_time *time) -{ - time64_t epoch_sec, current_sec; - - epoch_sec =3D mktime64(epoch, 1, 1, 0, 0, 0); - current_sec =3D rtc_tm_to_time64(time); - - write_elapsed_second(current_sec - epoch_sec); - - return 0; -} - -static int vr41xx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *wk= alrm) -{ - unsigned long low, mid, high; - struct rtc_time *time =3D &wkalrm->time; - - spin_lock_irq(&rtc_lock); - - low =3D rtc1_read(ECMPLREG); - mid =3D rtc1_read(ECMPMREG); - high =3D rtc1_read(ECMPHREG); - wkalrm->enabled =3D alarm_enabled; - - spin_unlock_irq(&rtc_lock); - - rtc_time64_to_tm((high << 17) | (mid << 1) | (low >> 15), time); - - return 0; -} - -static int vr41xx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wka= lrm) -{ - time64_t alarm_sec; - - alarm_sec =3D rtc_tm_to_time64(&wkalrm->time); - - spin_lock_irq(&rtc_lock); - - if (alarm_enabled) - disable_irq(aie_irq); - - rtc1_write(ECMPLREG, (uint16_t)(alarm_sec << 15)); - rtc1_write(ECMPMREG, (uint16_t)(alarm_sec >> 1)); - rtc1_write(ECMPHREG, (uint16_t)(alarm_sec >> 17)); - - if (wkalrm->enabled) - enable_irq(aie_irq); - - alarm_enabled =3D wkalrm->enabled; - - spin_unlock_irq(&rtc_lock); - - return 0; -} - -static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned= long arg) -{ - switch (cmd) { - case RTC_EPOCH_READ: - return put_user(epoch, (unsigned long __user *)arg); -#ifdef CONFIG_64BIT - case RTC_EPOCH_READ32: - return put_user(epoch, (unsigned int __user *)arg); -#endif - case RTC_EPOCH_SET: - /* Doesn't support before 1900 */ - if (arg < 1900) - return -EINVAL; - epoch =3D arg; - break; - default: - return -ENOIOCTLCMD; - } - - return 0; -} - -static int vr41xx_rtc_alarm_irq_enable(struct device *dev, unsigned int en= abled) -{ - spin_lock_irq(&rtc_lock); - if (enabled) { - if (!alarm_enabled) { - enable_irq(aie_irq); - alarm_enabled =3D 1; - } - } else { - if (alarm_enabled) { - disable_irq(aie_irq); - alarm_enabled =3D 0; - } - } - spin_unlock_irq(&rtc_lock); - return 0; -} - -static irqreturn_t elapsedtime_interrupt(int irq, void *dev_id) -{ - struct platform_device *pdev =3D (struct platform_device *)dev_id; - struct rtc_device *rtc =3D platform_get_drvdata(pdev); - - rtc2_write(RTCINTREG, ELAPSEDTIME_INT); - - rtc_update_irq(rtc, 1, RTC_AF); - - return IRQ_HANDLED; -} - -static irqreturn_t rtclong1_interrupt(int irq, void *dev_id) -{ - struct platform_device *pdev =3D (struct platform_device *)dev_id; - struct rtc_device *rtc =3D platform_get_drvdata(pdev); - unsigned long count =3D periodic_count; - - rtc2_write(RTCINTREG, RTCLONG1_INT); - - rtc1_write(RTCL1LREG, count); - rtc1_write(RTCL1HREG, count >> 16); - - rtc_update_irq(rtc, 1, RTC_PF); - - return IRQ_HANDLED; -} - -static const struct rtc_class_ops vr41xx_rtc_ops =3D { - .ioctl =3D vr41xx_rtc_ioctl, - .read_time =3D vr41xx_rtc_read_time, - .set_time =3D vr41xx_rtc_set_time, - .read_alarm =3D vr41xx_rtc_read_alarm, - .set_alarm =3D vr41xx_rtc_set_alarm, - .alarm_irq_enable =3D vr41xx_rtc_alarm_irq_enable, -}; - -static int rtc_probe(struct platform_device *pdev) -{ - struct resource *res; - struct rtc_device *rtc; - int retval; - - if (pdev->num_resources !=3D 4) - return -EBUSY; - - res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) - return -EBUSY; - - rtc1_base =3D devm_ioremap(&pdev->dev, res->start, resource_size(res)); - if (!rtc1_base) - return -EBUSY; - - res =3D platform_get_resource(pdev, IORESOURCE_MEM, 1); - if (!res) { - retval =3D -EBUSY; - goto err_rtc1_iounmap; - } - - rtc2_base =3D devm_ioremap(&pdev->dev, res->start, resource_size(res)); - if (!rtc2_base) { - retval =3D -EBUSY; - goto err_rtc1_iounmap; - } - - rtc =3D devm_rtc_allocate_device(&pdev->dev); - if (IS_ERR(rtc)) { - retval =3D PTR_ERR(rtc); - goto err_iounmap_all; - } - - rtc->ops =3D &vr41xx_rtc_ops; - - /* 48-bit counter at 32.768 kHz */ - rtc->range_max =3D (1ULL << 33) - 1; - rtc->max_user_freq =3D MAX_PERIODIC_RATE; - - spin_lock_irq(&rtc_lock); - - rtc1_write(ECMPLREG, 0); - rtc1_write(ECMPMREG, 0); - rtc1_write(ECMPHREG, 0); - rtc1_write(RTCL1LREG, 0); - rtc1_write(RTCL1HREG, 0); - - spin_unlock_irq(&rtc_lock); - - aie_irq =3D platform_get_irq(pdev, 0); - if (aie_irq <=3D 0) { - retval =3D -EBUSY; - goto err_iounmap_all; - } - - retval =3D devm_request_irq(&pdev->dev, aie_irq, elapsedtime_interrupt, 0, - "elapsed_time", pdev); - if (retval < 0) - goto err_iounmap_all; - - pie_irq =3D platform_get_irq(pdev, 1); - if (pie_irq <=3D 0) { - retval =3D -EBUSY; - goto err_iounmap_all; - } - - retval =3D devm_request_irq(&pdev->dev, pie_irq, rtclong1_interrupt, 0, - "rtclong1", pdev); - if (retval < 0) - goto err_iounmap_all; - - platform_set_drvdata(pdev, rtc); - - disable_irq(aie_irq); - disable_irq(pie_irq); - - dev_info(&pdev->dev, "Real Time Clock of NEC VR4100 series\n"); - - retval =3D devm_rtc_register_device(rtc); - if (retval) - goto err_iounmap_all; - - return 0; - -err_iounmap_all: - rtc2_base =3D NULL; - -err_rtc1_iounmap: - rtc1_base =3D NULL; - - return retval; -} - -/* work with hotplug and coldplug */ -MODULE_ALIAS("platform:RTC"); - -static struct platform_driver rtc_platform_driver =3D { - .probe =3D rtc_probe, - .driver =3D { - .name =3D rtc_name, - }, -}; - -module_platform_driver(rtc_platform_driver); --=20 2.29.2