From patchwork Fri Oct 19 09:59:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammed Afzal X-Patchwork-Id: 192627 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-gg0-f184.google.com (mail-gg0-f184.google.com [209.85.161.184]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 1D23B2C0089 for ; Fri, 19 Oct 2012 20:59:39 +1100 (EST) Received: by mail-gg0-f184.google.com with SMTP id l2sf200602ggn.11 for ; Fri, 19 Oct 2012 02:59:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=x-beenthere:received-spf:from:to:cc:subject:date:message-id :x-mailer:in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type; bh=R//2NC9Vnr1TcC9dhM874gs/Xact9jIwzjp0qdmft4E=; b=G5i62azY8JcmgxLVbgH9QAscKWtC6cJsuKCGPBtHzouEhMQBQ7ZvAAB7M0Xke1yAoO kRO7XTrPktEu4/lJt8Tja0tIQBW4CSHiAI+3SzElsh24QJn4HQTNwfbfA4r/E+X7pIgZ 4OmABIWrWSp+48ioIcnXKMcOIpWjHl1vu8NIObEBxKQGIBs18bXAsG3lwG0uhLE8MaRr Ij52VN0/u8wk0o3RE4Tf9KKG3BsN/ORTXNSQ6cBDnsY389zq0Sd1jib4CwIhnQf2qa/n gTr/xHbZKe+DvjnY06OWLfKkscwyVgPcIWHWPic0pE6gJRn95c2URqwfslq8bGbX54qD dDKQ== Received: by 10.50.197.165 with SMTP id iv5mr4481979igc.4.1350640776825; Fri, 19 Oct 2012 02:59:36 -0700 (PDT) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.42.244.193 with SMTP id lr1ls3538530icb.1.gmail; Fri, 19 Oct 2012 02:59:36 -0700 (PDT) Received: by 10.42.175.70 with SMTP id az6mr362183icb.27.1350640776237; Fri, 19 Oct 2012 02:59:36 -0700 (PDT) Received: by 10.42.175.70 with SMTP id az6mr362182icb.27.1350640776220; Fri, 19 Oct 2012 02:59:36 -0700 (PDT) Received: from arroyo.ext.ti.com (arroyo.ext.ti.com. [192.94.94.40]) by gmr-mx.google.com with ESMTPS id ge7si165153igb.0.2012.10.19.02.59.36 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 19 Oct 2012 02:59:36 -0700 (PDT) Received-SPF: pass (google.com: domain of afzal@ti.com designates 192.94.94.40 as permitted sender) client-ip=192.94.94.40; Received: from dbdp20.itg.ti.com ([172.24.170.38]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id q9J9xSQr023488; Fri, 19 Oct 2012 04:59:29 -0500 Received: from DBDE71.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id q9J9xIsT027180; Fri, 19 Oct 2012 15:29:26 +0530 (IST) Received: from dbdp32.itg.ti.com (172.24.170.251) by DBDE71.ent.ti.com (172.24.170.149) with Microsoft SMTP Server id 14.1.323.3; Fri, 19 Oct 2012 15:29:25 +0530 Received: from psplinux063.india.ti.com (dbdp20.itg.ti.com [172.24.170.38]) by dbdp32.itg.ti.com (8.13.8/8.13.8) with ESMTP id q9J9xOu2020991; Fri, 19 Oct 2012 15:29:24 +0530 From: Afzal Mohammed To: Andrew Morton CC: Grant Likely , Rob Herring , Rob Landley , Sekhar Nori , Kevin Hilman , Russell King , Alessandro Zummo , , , , , , , Daniel Mack , Afzal Mohammed Subject: [rtc-linux] [PATCH v4 1/5] rtc: omap: kicker mechanism support Date: Fri, 19 Oct 2012 15:29:24 +0530 Message-ID: <2b03d31c625936283b51d504a27e0b8017d2b27d.1350633036.git.afzal@ti.com> X-Mailer: git-send-email 1.7.12 In-Reply-To: References: MIME-Version: 1.0 X-Original-Sender: afzal@ti.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of afzal@ti.com designates 192.94.94.40 as permitted sender) smtp.mail=afzal@ti.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , OMAP RTC IP can have kicker feature. This prevents spurious writes to register. To write to registers kicker lock has to be released. Procedure to do it as follows, 1. write to kick0 register, 0x83e70b13 2. write to kick1 register, 0x95a4f1e0 Writing value other than 0x83e70b13 to kick0 enables write locking, more details about kicker mechanism can be found in section 20.3.3.5.3 of AM335X TRM @www.ti.com/am335x Here id table information is added and is used to distinguish those that require kicker handling and the ones that doesn't need it. There are more features in the newer IP's compared to legacy ones other than kicker, which driver currently doesn't handle, supporting additional features would be easier with the addition of id table. Older IP (of OMAP1) doesn't have revision register as per TRM, so revision register can't be relied always to find features, hence id table is being used. While at it, replace __raw_writeb/__raw_readb with writeb/readb; this driver is used on ARMv7 (AM335X SoC) Signed-off-by: Afzal Mohammed Acked-by: Sekhar Nori --- v4: Resolve build error during module build v3: Use readb/writeb instead of __raw_* variants Remove unnecessary parens v2: Use device name da830-rtc instead of am1808-rtc Newly added register name made similar to that existing in the driver Better commit message description drivers/rtc/rtc-omap.c | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index 0b614e3..d948426 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c @@ -38,6 +38,8 @@ * the SoC). See the BOARD-SPECIFIC CUSTOMIZATION comment. */ +#define DRIVER_NAME "omap_rtc" + #define OMAP_RTC_BASE 0xfffb4800 /* RTC registers */ @@ -64,6 +66,9 @@ #define OMAP_RTC_COMP_MSB_REG 0x50 #define OMAP_RTC_OSC_REG 0x54 +#define OMAP_RTC_KICK0_REG 0x6c +#define OMAP_RTC_KICK1_REG 0x70 + /* OMAP_RTC_CTRL_REG bit fields: */ #define OMAP_RTC_CTRL_SPLIT (1<<7) #define OMAP_RTC_CTRL_DISABLE (1<<6) @@ -88,10 +93,18 @@ #define OMAP_RTC_INTERRUPTS_IT_ALARM (1<<3) #define OMAP_RTC_INTERRUPTS_IT_TIMER (1<<2) +/* OMAP_RTC_KICKER values */ +#define KICK0_VALUE 0x83e70b13 +#define KICK1_VALUE 0x95a4f1e0 + +#define OMAP_RTC_HAS_KICKER 0x1 + static void __iomem *rtc_base; -#define rtc_read(addr) __raw_readb(rtc_base + (addr)) -#define rtc_write(val, addr) __raw_writeb(val, rtc_base + (addr)) +#define rtc_read(addr) readb(rtc_base + (addr)) +#define rtc_write(val, addr) writeb(val, rtc_base + (addr)) + +#define rtc_writel(val, addr) writel(val, rtc_base + (addr)) /* we rely on the rtc framework to handle locking (rtc->ops_lock), @@ -285,11 +298,23 @@ static struct rtc_class_ops omap_rtc_ops = { static int omap_rtc_alarm; static int omap_rtc_timer; +static struct platform_device_id omap_rtc_devtype[] = { + { + .name = DRIVER_NAME, + }, { + .name = "da830-rtc", + .driver_data = OMAP_RTC_HAS_KICKER, + }, + {}, +}; +MODULE_DEVICE_TABLE(platform, omap_rtc_devtype); + static int __init omap_rtc_probe(struct platform_device *pdev) { struct resource *res, *mem; struct rtc_device *rtc; u8 reg, new_ctrl; + const struct platform_device_id *id_entry; omap_rtc_timer = platform_get_irq(pdev, 0); if (omap_rtc_timer <= 0) { @@ -322,6 +347,12 @@ static int __init omap_rtc_probe(struct platform_device *pdev) goto fail; } + id_entry = platform_get_device_id(pdev); + if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) { + rtc_writel(KICK0_VALUE, OMAP_RTC_KICK0_REG); + rtc_writel(KICK1_VALUE, OMAP_RTC_KICK1_REG); + } + rtc = rtc_device_register(pdev->name, &pdev->dev, &omap_rtc_ops, THIS_MODULE); if (IS_ERR(rtc)) { @@ -398,6 +429,8 @@ fail2: fail1: rtc_device_unregister(rtc); fail0: + if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) + rtc_writel(0, OMAP_RTC_KICK0_REG); iounmap(rtc_base); fail: release_mem_region(mem->start, resource_size(mem)); @@ -408,6 +441,8 @@ static int __exit omap_rtc_remove(struct platform_device *pdev) { struct rtc_device *rtc = platform_get_drvdata(pdev); struct resource *mem = dev_get_drvdata(&rtc->dev); + const struct platform_device_id *id_entry = + platform_get_device_id(pdev); device_init_wakeup(&pdev->dev, 0); @@ -420,6 +455,8 @@ static int __exit omap_rtc_remove(struct platform_device *pdev) free_irq(omap_rtc_alarm, rtc); rtc_device_unregister(rtc); + if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) + rtc_writel(0, OMAP_RTC_KICK0_REG); iounmap(rtc_base); release_mem_region(mem->start, resource_size(mem)); return 0; @@ -471,9 +508,10 @@ static struct platform_driver omap_rtc_driver = { .resume = omap_rtc_resume, .shutdown = omap_rtc_shutdown, .driver = { - .name = "omap_rtc", + .name = DRIVER_NAME, .owner = THIS_MODULE, }, + .id_table = omap_rtc_devtype, }; static int __init rtc_init(void)