From patchwork Mon Dec 12 14:48:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Heiko_St=C3=BCbner?= X-Patchwork-Id: 130758 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-pz0-f56.google.com (mail-pz0-f56.google.com [209.85.210.56]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 2A1841007D1 for ; Tue, 13 Dec 2011 01:48:32 +1100 (EST) Received: by dafa1 with SMTP id a1sf6086552daf.11 for ; Mon, 12 Dec 2011 06:48:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:from:to:subject:date:user-agent:cc :references:in-reply-to:mime-version:message-id: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=pb1I9ji8H1ml5FPfYC9762AYOkD5WpbmJEez689hLEs=; b=4BO81u6guxQjzVsGM8PEv671H1wJShl6fSyT5MMgFomlyuYbmkSM+sO33/ESBtcUPY OSSaBlup+ezIIQd2+6l4UC3Qa3YbNH7cAnLxCtafAyH/Qcc4mhYYk7beoqH8kIbb0R4T kebPZ1EPO9c1sC0YymPuUW6w7mWY4ydoQ6oW8= Received: by 10.68.73.8 with SMTP id h8mr1155299pbv.7.1323701310027; Mon, 12 Dec 2011 06:48:30 -0800 (PST) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.68.156.102 with SMTP id wd6ls13457558pbb.2.gmail; Mon, 12 Dec 2011 06:48:29 -0800 (PST) Received: by 10.68.189.233 with SMTP id gl9mr9349733pbc.8.1323701309777; Mon, 12 Dec 2011 06:48:29 -0800 (PST) Received: by 10.68.189.233 with SMTP id gl9mr9349732pbc.8.1323701309768; Mon, 12 Dec 2011 06:48:29 -0800 (PST) Received: from h1778886.stratoserver.net (h1778886.stratoserver.net. [85.214.133.74]) by gmr-mx.google.com with ESMTPS id j5si25862915pbi.0.2011.12.12.06.48.29 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 12 Dec 2011 06:48:29 -0800 (PST) Received-SPF: neutral (google.com: 85.214.133.74 is neither permitted nor denied by best guess record for domain of heiko@sntech.de) client-ip=85.214.133.74; Received: from p509909d9.dip0.t-ipconnect.de ([80.153.9.217] helo=nx4-rtr-0001.kes) by h1778886.stratoserver.net with esmtpa (Exim 4.69) (envelope-from ) id 1Ra7Aw-00041k-C5; Mon, 12 Dec 2011 15:48:18 +0100 Received: from [192.168.30.196] (helo=nx4-deb-0000.localnet) by nx4-rtr-0001.kes with esmtp (Exim 4.69) (envelope-from ) id 1Ra7Ai-0008RA-3v; Mon, 12 Dec 2011 15:48:09 +0100 From: Heiko =?iso-8859-1?q?St=FCbner?= To: Kukjin Kim , ben-linux@fluff.org, a.zummo@towertech.it Subject: [rtc-linux] [PATCH 3/4] rtc-s3c: add variants for S3C2443 and S3C2416 Date: Mon, 12 Dec 2011 15:48:01 +0100 User-Agent: KMail/1.13.7 (Linux/2.6.39-2-amd64; KDE/4.6.4; x86_64; ; ) Cc: rtc-linux@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Thomas Abraham References: <201112121543.42299.heiko@sntech.de> In-Reply-To: <201112121543.42299.heiko@sntech.de> MIME-Version: 1.0 Message-Id: <201112121548.02180.heiko@sntech.de> X-Original-Sender: heiko@sntech.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 85.214.133.74 is neither permitted nor denied by best guess record for domain of heiko@sntech.de) smtp.mail=heiko@sntech.de 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: , Especially the TICNT registers are different from the two rtc types that currently exists. Signed-off-by: Heiko Stuebner --- arch/arm/plat-samsung/include/plat/regs-rtc.h | 24 ++++++++++++++ drivers/rtc/rtc-s3c.c | 43 ++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/arch/arm/plat-samsung/include/plat/regs-rtc.h b/arch/arm/plat-samsung/include/plat/regs-rtc.h index d9d9bdc..fa6066a 100644 --- a/arch/arm/plat-samsung/include/plat/regs-rtc.h +++ b/arch/arm/plat-samsung/include/plat/regs-rtc.h @@ -23,14 +23,33 @@ #define S3C2410_RTCCON_CLKSEL (1 << 1) #define S3C2410_RTCCON_CNTSEL (1 << 2) #define S3C2410_RTCCON_CLKRST (1 << 3) +#define S3C2443_RTCCON_TICSEL (1 << 4) #define S3C64XX_RTCCON_TICEN (1 << 8) #define S3C64XX_RTCCON_TICMSK (0xF << 7) #define S3C64XX_RTCCON_TICSHT (7) +#define S3C2416_RTCCON_TICMSK (0x1F << 7) + #define S3C2410_TICNT S3C2410_RTCREG(0x44) #define S3C2410_TICNT_ENABLE (1 << 7) +/* S3C2443: tick count is 15 bit wide + * TICNT[6:0] contains upper 7 bits + * TICNT1[7:0] contains lower 8 bits + */ +#define S3C2443_TICNT_PART(x) ((x & 0x7f00) >> 8) +#define S3C2443_TICNT1 S3C2410_RTCREG(0x4C) +#define S3C2443_TICNT1_PART(x) (x & 0xff) + +/* S3C2416: tick count is 32 bit wide + * TICNT[6:0] contains bits [14:8] + * TICNT1[7:0] contains lower 8 bits + * TICNT2[16:0] contains upper 17 bits + */ +#define S3C2416_TICNT2 S3C2410_RTCREG(0x48) +#define S3C2416_TICNT2_PART(x) ((x & 0xffff8000) >> 15) + #define S3C2410_RTCALM S3C2410_RTCREG(0x50) #define S3C2410_RTCALM_ALMEN (1 << 6) #define S3C2410_RTCALM_YEAREN (1 << 5) @@ -63,4 +82,9 @@ #define S3C2410_RTCMON S3C2410_RTCREG(0x84) #define S3C2410_RTCYEAR S3C2410_RTCREG(0x88) +#define S3C2443_TICKCNT S3C2410_RTCREG(0x90) + +#define S3C2443_RTCLBAT S3C2410_RTCREG(0x94) +#define S3C2443_RTCLBAT_CLEAR (1 << 0) + #endif /* __ASM_ARCH_REGS_RTC_H */ diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index 2885b25..4498053 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c @@ -35,6 +35,8 @@ enum s3c_cpu_type { TYPE_S3C2410, + TYPE_S3C2443, + TYPE_S3C2416, TYPE_S3C64XX, }; @@ -132,6 +134,7 @@ static int s3c_rtc_setfreq(struct device *dev, int freq) struct platform_device *pdev = to_platform_device(dev); struct rtc_device *rtc_dev = platform_get_drvdata(pdev); unsigned int tmp = 0; + int val; if (!is_power_of_2(freq)) return -EINVAL; @@ -139,12 +142,24 @@ static int s3c_rtc_setfreq(struct device *dev, int freq) clk_enable(rtc_clk); spin_lock_irq(&s3c_rtc_pie_lock); - if (s3c_rtc_cpu_type == TYPE_S3C2410) { + if (s3c_rtc_cpu_type != TYPE_S3C64XX) { tmp = readb(s3c_rtc_base + S3C2410_TICNT); tmp &= S3C2410_TICNT_ENABLE; } - tmp |= (rtc_dev->max_user_freq / freq)-1; + val = (rtc_dev->max_user_freq / freq) - 1; + + if (s3c_rtc_cpu_type == TYPE_S3C2443 || + s3c_rtc_cpu_type == TYPE_S3C2416) { + tmp |= S3C2443_TICNT_PART(val); + writel(S3C2443_TICNT1_PART(val), + s3c_rtc_base + S3C2443_TICNT1); + if (s3c_rtc_cpu_type == TYPE_S3C2416) + writel(S3C2416_TICNT2_PART(val), + s3c_rtc_base + S3C2416_TICNT2); + } else { + tmp |= val; + } writel(tmp, s3c_rtc_base + S3C2410_TICNT); spin_unlock_irq(&s3c_rtc_pie_lock); @@ -371,7 +386,7 @@ static void s3c_rtc_enable(struct platform_device *pdev, int en) tmp &= ~S3C2410_RTCCON_RTCEN; writew(tmp, base + S3C2410_RTCCON); - if (s3c_rtc_cpu_type == TYPE_S3C2410) { + if (s3c_rtc_cpu_type != TYPE_S3C64XX) { tmp = readb(base + S3C2410_TICNT); tmp &= ~S3C2410_TICNT_ENABLE; writeb(tmp, base + S3C2410_TICNT); @@ -448,6 +463,7 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) struct rtc_time rtc_tm; struct resource *res; int ret; + int tmp; pr_debug("%s: probe=%p\n", __func__, pdev); @@ -541,11 +557,18 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) dev_warn(&pdev->dev, "warning: invalid RTC value so initializing it\n"); } - if (s3c_rtc_cpu_type == TYPE_S3C64XX) + if (s3c_rtc_cpu_type != TYPE_S3C2410) rtc->max_user_freq = 32768; else rtc->max_user_freq = 128; + if (s3c_rtc_cpu_type == TYPE_S3C2443 || + s3c_rtc_cpu_type == TYPE_S3C2416) { + tmp = readw(s3c_rtc_base + S3C2410_RTCCON); + tmp |= S3C2443_RTCCON_TICSEL; + writew(tmp, s3c_rtc_base + S3C2410_RTCCON); + } + platform_set_drvdata(pdev, rtc); s3c_rtc_setfreq(&pdev->dev, 1); @@ -650,6 +673,12 @@ static const struct of_device_id s3c_rtc_dt_match[] = { .compatible = "samsung,s3c2410-rtc" .data = TYPE_S3C2410, }, { + .compatible = "samsung,s3c2443-rtc" + .data = TYPE_S3C2443, + }, { + .compatible = "samsung,s3c2416-rtc" + .data = TYPE_S3C2416, + }, { .compatible = "samsung,s3c6410-rtc" .data = TYPE_S3C64XX, }, @@ -665,6 +694,12 @@ static struct platform_device_id s3c_rtc_driver_ids[] = { .name = "s3c2410-rtc", .driver_data = TYPE_S3C2410, }, { + .name = "s3c2443-rtc", + .driver_data = TYPE_S3C2443, + }, { + .name = "s3c2416-rtc", + .driver_data = TYPE_S3C2416, + }, { .name = "s3c64xx-rtc", .driver_data = TYPE_S3C64XX, },