From: "Heiko Stübner" <heiko@sntech.de>
To: Kukjin Kim <kgene.kim@samsung.com>,
ben-linux@fluff.org, a.zummo@towertech.it
Cc: linux-samsung-soc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, rtc-linux@googlegroups.com
Subject: [PATCH 3/4] rtc-s3c: add variants for S3C2443 and S3C2416
Date: Wed, 21 Dec 2011 10:17:26 +0100 [thread overview]
Message-ID: <201112211017.27245.heiko@sntech.de> (raw)
In-Reply-To: <201112211014.30695.heiko@sntech.de>
Especially the TICNT registers are different from the two rtc types
that currently exists.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
arch/arm/plat-samsung/include/plat/regs-rtc.h | 17 ++++++++++
drivers/rtc/rtc-s3c.c | 43 ++++++++++++++++++++++--
2 files changed, 56 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 a7d944f..0f8263e 100644
--- a/arch/arm/plat-samsung/include/plat/regs-rtc.h
+++ b/arch/arm/plat-samsung/include/plat/regs-rtc.h
@@ -22,11 +22,28 @@
#define S3C2410_RTCCON_RTCEN (1 << 0)
#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 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)
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,
},
--
1.7.5.4
WARNING: multiple messages have this Message-ID (diff)
From: heiko@sntech.de (Heiko Stübner)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/4] rtc-s3c: add variants for S3C2443 and S3C2416
Date: Wed, 21 Dec 2011 10:17:26 +0100 [thread overview]
Message-ID: <201112211017.27245.heiko@sntech.de> (raw)
In-Reply-To: <201112211014.30695.heiko@sntech.de>
Especially the TICNT registers are different from the two rtc types
that currently exists.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
arch/arm/plat-samsung/include/plat/regs-rtc.h | 17 ++++++++++
drivers/rtc/rtc-s3c.c | 43 ++++++++++++++++++++++--
2 files changed, 56 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 a7d944f..0f8263e 100644
--- a/arch/arm/plat-samsung/include/plat/regs-rtc.h
+++ b/arch/arm/plat-samsung/include/plat/regs-rtc.h
@@ -22,11 +22,28 @@
#define S3C2410_RTCCON_RTCEN (1 << 0)
#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 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)
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,
},
--
1.7.5.4
next prev parent reply other threads:[~2011-12-21 9:17 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-21 9:14 [PATCH v3 0/4] Implement RTC support for S3C2443/S3C2416/S3C2450 Heiko Stübner
2011-12-21 9:14 ` Heiko Stübner
2011-12-21 9:16 ` [PATCH 1/4] ARM: SAMSUNG: cleanup of rtc register definitions Heiko Stübner
2011-12-21 9:16 ` Heiko Stübner
2011-12-21 9:16 ` [PATCH 2/4] rtc-s3c: make room for more variants in devicetree block Heiko Stübner
2011-12-21 9:16 ` Heiko Stübner
2012-01-04 10:43 ` Sylwester Nawrocki
2012-01-04 10:43 ` Sylwester Nawrocki
2012-01-04 11:51 ` Heiko Stübner
2012-01-04 11:51 ` Heiko Stübner
2012-01-04 14:12 ` Heiko Stübner
2012-01-04 14:12 ` Heiko Stübner
2012-01-04 14:14 ` [PATCH] rtc-s3c: Fix breakage introduced by S3C2443/S3C2416 support Heiko Stübner
2012-01-04 14:14 ` Heiko Stübner
2012-01-05 2:32 ` Kukjin Kim
2012-01-05 2:32 ` Kukjin Kim
2012-01-04 14:14 ` [PATCH v4 0/4] Implement RTC support for S3C2443/S3C2416/S3C2450 Heiko Stübner
2012-01-04 14:14 ` Heiko Stübner
2012-01-04 14:15 ` [PATCH 1/4] ARM: SAMSUNG: cleanup of rtc register definitions Heiko Stübner
2012-01-04 14:15 ` Heiko Stübner
2012-01-04 22:14 ` Russell King - ARM Linux
2012-01-04 22:14 ` Russell King - ARM Linux
2012-01-04 14:16 ` [PATCH 2/4] rtc-s3c: make room for more variants in devicetree block Heiko Stübner
2012-01-04 14:16 ` Heiko Stübner
2012-01-04 14:16 ` [PATCH 3/4] rtc-s3c: add variants for S3C2443 and S3C2416 Heiko Stübner
2012-01-04 14:16 ` Heiko Stübner
2012-01-04 14:17 ` [PATCH 4/4] ARM: S3C2443/S3C2416: add s3c_rtc_setname and rename rtc devices Heiko Stübner
2012-01-04 14:17 ` Heiko Stübner
2012-01-05 2:32 ` [PATCH 2/4] rtc-s3c: make room for more variants in devicetree block Kukjin Kim
2012-01-05 2:32 ` Kukjin Kim
2011-12-21 9:17 ` Heiko Stübner [this message]
2011-12-21 9:17 ` [PATCH 3/4] rtc-s3c: add variants for S3C2443 and S3C2416 Heiko Stübner
2011-12-21 9:18 ` [PATCH 4/4] ARM: S3C2443/S3C2416: add s3c_rtc_setname and rename rtc devices Heiko Stübner
2011-12-21 9:18 ` Heiko Stübner
-- strict thread matches above, loose matches on Subject: below --
2011-12-12 14:43 [PATCH v2 0/4] Implement RTC support for S3C2443/S3C2416/S3C2450 Heiko Stübner
2011-12-12 14:48 ` [PATCH 3/4] rtc-s3c: add variants for S3C2443 and S3C2416 Heiko Stübner
2011-12-12 14:48 ` Heiko Stübner
2011-12-09 9:46 [PATCH 0/4] Implement RTC support for S3C2443/S3C2416/S3C2450 Heiko Stübner
2011-12-09 9:50 ` [PATCH 3/4] rtc-s3c: add variants for S3C2443 and S3C2416 Heiko Stübner
2011-12-09 9:50 ` Heiko Stübner
2011-12-11 5:54 ` Thomas Abraham
2011-12-11 5:54 ` Thomas Abraham
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201112211017.27245.heiko@sntech.de \
--to=heiko@sntech.de \
--cc=a.zummo@towertech.it \
--cc=ben-linux@fluff.org \
--cc=kgene.kim@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=rtc-linux@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.