* [PATCH v2] IP27: Switch over to RTC class driver
@ 2008-08-04 17:00 Thomas Bogendoerfer
2008-08-05 0:33 ` Atsushi Nemoto
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Bogendoerfer @ 2008-08-04 17:00 UTC (permalink / raw)
To: linux-mips; +Cc: ralf
This patchset removes some dead code and creates a platform device
for the RTC class driver.
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
---
Changes in v2:
- use physical address for resource setup
- use late_initcall until ioc3 resource conflict is resolved
arch/mips/sgi-ip27/ip27-timer.c | 99 +++++++++------------------------------
1 files changed, 22 insertions(+), 77 deletions(-)
diff --git a/arch/mips/sgi-ip27/ip27-timer.c b/arch/mips/sgi-ip27/ip27-timer.c
index 8b4e854..a5f0eec 100644
--- a/arch/mips/sgi-ip27/ip27-timer.c
+++ b/arch/mips/sgi-ip27/ip27-timer.c
@@ -13,12 +13,12 @@
#include <linux/time.h>
#include <linux/timex.h>
#include <linux/mm.h>
+#include <linux/platform_device.h>
#include <asm/time.h>
#include <asm/pgtable.h>
#include <asm/sgialib.h>
#include <asm/sn/ioc3.h>
-#include <asm/m48t35.h>
#include <asm/sn/klconfig.h>
#include <asm/sn/arch.h>
#include <asm/sn/addrs.h>
@@ -28,51 +28,6 @@
#define TICK_SIZE (tick_nsec / 1000)
-#if 0
-static int set_rtc_mmss(unsigned long nowtime)
-{
- int retval = 0;
- int real_seconds, real_minutes, cmos_minutes;
- struct m48t35_rtc *rtc;
- nasid_t nid;
-
- nid = get_nasid();
- rtc = (struct m48t35_rtc *)(KL_CONFIG_CH_CONS_INFO(nid)->memory_base +
- IOC3_BYTEBUS_DEV0);
-
- rtc->control |= M48T35_RTC_READ;
- cmos_minutes = BCD2BIN(rtc->min);
- rtc->control &= ~M48T35_RTC_READ;
-
- /*
- * Since we're only adjusting minutes and seconds, don't interfere with
- * hour overflow. This avoids messing with unknown time zones but
- * requires your RTC not to be off by more than 15 minutes
- */
- real_seconds = nowtime % 60;
- real_minutes = nowtime / 60;
- if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1)
- real_minutes += 30; /* correct for half hour time zone */
- real_minutes %= 60;
-
- if (abs(real_minutes - cmos_minutes) < 30) {
- real_seconds = BIN2BCD(real_seconds);
- real_minutes = BIN2BCD(real_minutes);
- rtc->control |= M48T35_RTC_SET;
- rtc->sec = real_seconds;
- rtc->min = real_minutes;
- rtc->control &= ~M48T35_RTC_SET;
- } else {
- printk(KERN_WARNING
- "set_rtc_mmss: can't update from %d to %d\n",
- cmos_minutes, real_minutes);
- retval = -1;
- }
-
- return retval;
-}
-#endif
-
/* Includes for ioc3_init(). */
#include <asm/sn/types.h>
#include <asm/sn/sn0/addrs.h>
@@ -80,37 +35,6 @@ static int set_rtc_mmss(unsigned long nowtime)
#include <asm/sn/sn0/hubio.h>
#include <asm/pci/bridge.h>
-unsigned long read_persistent_clock(void)
-{
- unsigned int year, month, date, hour, min, sec;
- struct m48t35_rtc *rtc;
- nasid_t nid;
-
- nid = get_nasid();
- rtc = (struct m48t35_rtc *)(KL_CONFIG_CH_CONS_INFO(nid)->memory_base +
- IOC3_BYTEBUS_DEV0);
-
- rtc->control |= M48T35_RTC_READ;
- sec = rtc->sec;
- min = rtc->min;
- hour = rtc->hour;
- date = rtc->date;
- month = rtc->month;
- year = rtc->year;
- rtc->control &= ~M48T35_RTC_READ;
-
- sec = BCD2BIN(sec);
- min = BCD2BIN(min);
- hour = BCD2BIN(hour);
- date = BCD2BIN(date);
- month = BCD2BIN(month);
- year = BCD2BIN(year);
-
- year += 1970;
-
- return mktime(year, month, date, hour, min, sec);
-}
-
static void enable_rt_irq(unsigned int irq)
{
}
@@ -286,6 +210,7 @@ void __cpuinit cpu_time_init(void)
void __cpuinit hub_rtc_init(cnodeid_t cnode)
{
+
/*
* We only need to initialize the current node.
* If this is not the current node then it is a cpuless
@@ -301,3 +226,23 @@ void __cpuinit hub_rtc_init(cnodeid_t cnode)
LOCAL_HUB_S(PI_RT_PEND_B, 0);
}
}
+
+static int __init sgi_ip27_rtc_devinit(void)
+{
+ struct resource res;
+
+ memset(&res, 0, sizeof(res));
+ res.start = XPHYSADDR(KL_CONFIG_CH_CONS_INFO(master_nasid)->memory_base +
+ IOC3_BYTEBUS_DEV0);
+ res.end = res.start + 32768;
+ res.flags = IORESOURCE_MEM;
+
+ return IS_ERR(platform_device_register_simple("rtc-m48t35", -1,
+ &res, 1));
+}
+
+/*
+ * kludge make this a device_initcall after ioc3 resource conflicts
+ * are resolved
+ */
+late_initcall(sgi_ip27_rtc_devinit);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] IP27: Switch over to RTC class driver
2008-08-04 17:00 [PATCH v2] IP27: Switch over to RTC class driver Thomas Bogendoerfer
@ 2008-08-05 0:33 ` Atsushi Nemoto
2008-08-05 8:52 ` Thomas Bogendoerfer
0 siblings, 1 reply; 3+ messages in thread
From: Atsushi Nemoto @ 2008-08-05 0:33 UTC (permalink / raw)
To: tsbogend; +Cc: linux-mips, ralf
On Mon, 4 Aug 2008 19:00:21 +0200 (CEST), Thomas Bogendoerfer <tsbogend@alpha.franken.de> wrote:
> + res.start = XPHYSADDR(KL_CONFIG_CH_CONS_INFO(master_nasid)->memory_base +
> + IOC3_BYTEBUS_DEV0);
> + res.end = res.start + 32768;
res.end should be res.start + 32767 ?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] IP27: Switch over to RTC class driver
2008-08-05 0:33 ` Atsushi Nemoto
@ 2008-08-05 8:52 ` Thomas Bogendoerfer
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Bogendoerfer @ 2008-08-05 8:52 UTC (permalink / raw)
To: Atsushi Nemoto; +Cc: linux-mips, ralf
On Tue, Aug 05, 2008 at 09:33:05AM +0900, Atsushi Nemoto wrote:
> On Mon, 4 Aug 2008 19:00:21 +0200 (CEST), Thomas Bogendoerfer <tsbogend@alpha.franken.de> wrote:
> > + res.start = XPHYSADDR(KL_CONFIG_CH_CONS_INFO(master_nasid)->memory_base +
> > + IOC3_BYTEBUS_DEV0);
> > + res.end = res.start + 32768;
>
> res.end should be res.start + 32767 ?
correct, I'll fix that.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-08-05 8:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-04 17:00 [PATCH v2] IP27: Switch over to RTC class driver Thomas Bogendoerfer
2008-08-05 0:33 ` Atsushi Nemoto
2008-08-05 8:52 ` Thomas Bogendoerfer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox