From patchwork Mon Nov 17 04:43:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lokesh Vutla X-Patchwork-Id: 5315501 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 38E72C11AC for ; Mon, 17 Nov 2014 04:47:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5BA20201BC for ; Mon, 17 Nov 2014 04:47:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 66FCE20148 for ; Mon, 17 Nov 2014 04:47:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XqEBO-0006f8-T4; Mon, 17 Nov 2014 04:44:58 +0000 Received: from comal.ext.ti.com ([198.47.26.152]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XqEBL-0006dn-Fo for linux-arm-kernel@lists.infradead.org; Mon, 17 Nov 2014 04:44:56 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id sAH4iaJ4004010; Sun, 16 Nov 2014 22:44:36 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id sAH4ia8i014021; Sun, 16 Nov 2014 22:44:36 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Sun, 16 Nov 2014 22:44:35 -0600 Received: from a0131933.apr.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id sAH4iWCP002663; Sun, 16 Nov 2014 22:44:33 -0600 From: Lokesh Vutla To: Subject: [RFC PATCH] ARM: DRA: hwmod: RTC: Add reset function for RTC Date: Mon, 17 Nov 2014 10:13:22 +0530 Message-ID: <1416199402-3865-1-git-send-email-lokeshvutla@ti.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141116_204455_621427_5C2F36CE X-CRM114-Status: GOOD ( 11.70 ) X-Spam-Score: -5.0 (-----) Cc: devicetree@vger.kernel.org, paul@pwsan.com, tony@atomide.com, nsekhar@ti.com, t-kristo@ti.com, Lokesh Vutla , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP RTC IP have kicker feature which prevents spurious writes to its registers. In order to write into any of the RTC registers, KICK values has te be written to KICK registers. Currently hwmod is updating the IDLEMODE in rtc sysconfig register without writing into any kick register which is a noop. When autoidle is allowed for rtc, interruts are not received until IDLEMODE is set to SIDLE_SMART_WKUP. Adding a reset function to unlock RTC registers so that IDLEMODE is updated. Signed-off-by: Lokesh Vutla --- arch/arm/mach-omap2/omap_hwmod.h | 1 + arch/arm/mach-omap2/omap_hwmod_7xx_data.c | 1 + arch/arm/mach-omap2/omap_hwmod_reset.c | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/arch/arm/mach-omap2/omap_hwmod.h b/arch/arm/mach-omap2/omap_hwmod.h index 512f809..3703f99 100644 --- a/arch/arm/mach-omap2/omap_hwmod.h +++ b/arch/arm/mach-omap2/omap_hwmod.h @@ -744,6 +744,7 @@ const char *omap_hwmod_get_main_clk(struct omap_hwmod *oh); */ extern int omap_hwmod_aess_preprogram(struct omap_hwmod *oh); +int omap_hwmod_rtc_unlock(struct omap_hwmod *oh); /* * Chip variant-specific hwmod init routines - XXX should be converted diff --git a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c index 5684f11..90e1df4 100644 --- a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c @@ -1584,6 +1584,7 @@ static struct omap_hwmod_class_sysconfig dra7xx_rtcss_sysc = { static struct omap_hwmod_class dra7xx_rtcss_hwmod_class = { .name = "rtcss", .sysc = &dra7xx_rtcss_sysc, + .reset = &omap_hwmod_rtc_unlock, }; /* rtcss */ diff --git a/arch/arm/mach-omap2/omap_hwmod_reset.c b/arch/arm/mach-omap2/omap_hwmod_reset.c index 65e186c..b825a28 100644 --- a/arch/arm/mach-omap2/omap_hwmod_reset.c +++ b/arch/arm/mach-omap2/omap_hwmod_reset.c @@ -30,6 +30,12 @@ #include "omap_hwmod.h" +#define RTC_KICK0_REG_OFFSET 0x6c +#define RTC_KICK1_REG_OFFSET 0x70 + +#define RTC_KICK0_VALUE 0x83E70B13 +#define RTC_KICK1_VALUE 0x95A4F1E0 + /** * omap_hwmod_aess_preprogram - enable AESS internal autogating * @oh: struct omap_hwmod * @@ -51,3 +57,20 @@ int omap_hwmod_aess_preprogram(struct omap_hwmod *oh) return 0; } + +/** + * omap_hwmod_rtc_unlock - Reset and unlock the Kicker mechanism. + * @oh: struct omap_hwmod * + * + * RTC IP have kicker feature. This prevents spurious writes to its registers. + * In order to write into any of the RTC registers, KICK values has te be + * written in respective KICK registers. This is needed for hwmod to write into + * sysconfig register. + */ +int omap_hwmod_rtc_unlock(struct omap_hwmod *oh) +{ + omap_hwmod_write(RTC_KICK0_VALUE, oh, RTC_KICK0_REG_OFFSET); + omap_hwmod_write(RTC_KICK1_VALUE, oh, RTC_KICK1_REG_OFFSET); + + return 0; +}