linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2.6.12-rc2 2/2] ppc32: add rtc hooks in PPC7D platform file
@ 2005-04-08  8:17 Chris Elston
  2005-04-08  8:28 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Elston @ 2005-04-08  8:17 UTC (permalink / raw)
  To: akpm; +Cc: linuxppc-embedded

[-- Attachment #1: Type: text/plain, Size: 571 bytes --]

This patch adds the hooks into the PPC7D platforms file to
support the DS1337 RTC device as the clock device for the 
PPC7D board.

Signed-off-by: Chris Elston <chris.elston@radstone.co.uk>


________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

[-- Attachment #2: ppc7d_rtc_hooks.patch --]
[-- Type: application/octet-stream, Size: 2008 bytes --]

--- linux-2.6.12-rc2/arch/ppc/platforms/radstone_ppc7d.c	2005-04-07 12:31:43.000000000 +0100
+++ linux-2.6.12-rc2-cde/arch/ppc/platforms/radstone_ppc7d.c	2005-04-07 12:28:51.000000000 +0100
@@ -68,6 +68,7 @@
 #define PPC7D_RST_PIN			17 	/* GPP17 */
 
 extern u32 mv64360_irq_base;
+extern spinlock_t rtc_lock;
 
 static struct mv64x60_handle bh;
 static int ppc7d_has_alma;
@@ -75,6 +76,11 @@
 extern void gen550_progress(char *, unsigned short);
 extern void gen550_init(int, struct uart_port *);
 
+/* FIXME - move to h file */
+extern int ds1337_do_command(int id, int cmd, void *arg);
+#define DS1337_GET_DATE         0
+#define DS1337_SET_DATE         1
+
 /* residual data */
 unsigned char __res[sizeof(bd_t)];
 
@@ -1236,6 +1248,38 @@
 	printk(KERN_INFO "Radstone Technology PPC7D\n");
 	if (ppc_md.progress)
 		ppc_md.progress("ppc7d_setup_arch: exit", 0);
+
+}
+
+/* Real Time Clock support.
+ * PPC7D has a DS1337 accessed by I2C.
+ */
+static ulong ppc7d_get_rtc_time(void)
+{
+        struct rtc_time tm;
+        int result;
+
+        spin_lock(&rtc_lock);
+        result = ds1337_do_command(0, DS1337_GET_DATE, &tm);
+        spin_unlock(&rtc_lock);
+
+        if (result == 0)
+                result = mktime(tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
+
+        return result;
+}
+
+static int ppc7d_set_rtc_time(unsigned long nowtime)
+{
+        struct rtc_time tm;
+        int result;
+
+        spin_lock(&rtc_lock);
+        to_tm(nowtime, &tm);
+        result = ds1337_do_command(0, DS1337_SET_DATE, &tm);
+        spin_unlock(&rtc_lock);
+
+        return result;
 }
 
 /* This kernel command line parameter can be used to have the target
@@ -1293,6 +1337,10 @@
 	data8 |= 0x07;
 	outb(data8, PPC7D_CPLD_LEDS);
 
+        /* Hook up RTC. We couldn't do this earlier because we need the I2C subsystem */
+        ppc_md.set_rtc_time = ppc7d_set_rtc_time;
+        ppc_md.get_rtc_time = ppc7d_get_rtc_time;
+
 	pr_debug("%s: exit\n", __FUNCTION__);
 }
 

^ permalink raw reply	[flat|nested] 4+ messages in thread
* [PATCH 2.6.12-rc2 2/2] ppc32: add rtc hooks in PPC7D platform file
@ 2005-04-08  8:43 Chris Elston
  0 siblings, 0 replies; 4+ messages in thread
From: Chris Elston @ 2005-04-08  8:43 UTC (permalink / raw)
  To: akpm; +Cc: linuxppc-embedded

This=20patch=20adds=20the=20hooks=20into=20the=20PPC7D=20platforms=20file=20=
to
support=20the=20DS1337=20RTC=20device=20as=20the=20clock=20device=20for=20=
the=20
PPC7D=20board.

Signed-off-by:=20Chris=20Elston=20<chris.elston@radstone.co.uk>

---=20linux-2.6.12-rc2/arch/ppc/platforms/radstone_ppc7d.c
2005-04-07=2012:31:43.000000000=20+0100
+++=20linux-2.6.12-rc2-cde/arch/ppc/platforms/radstone_ppc7d.c
2005-04-07=2012:28:51.000000000=20+0100
@@=20-68,6=20+68,7=20@@
=20#define=20PPC7D_RST_PIN=09=09=0917=20=09/*=20GPP17=20*/
=20
=20extern=20u32=20mv64360_irq_base;
+extern=20spinlock_t=20rtc_lock;
=20
=20static=20struct=20mv64x60_handle=20bh;
=20static=20int=20ppc7d_has_alma;
@@=20-75,6=20+76,11=20@@
=20extern=20void=20gen550_progress(char=20*,=20unsigned=20short);
=20extern=20void=20gen550_init(int,=20struct=20uart_port=20*);
=20
+/*=20FIXME=20-=20move=20to=20h=20file=20*/
+extern=20int=20ds1337_do_command(int=20id,=20int=20cmd,=20void=20*arg);
+#define=20DS1337_GET_DATE=20=20=20=20=20=20=20=20=200
+#define=20DS1337_SET_DATE=20=20=20=20=20=20=20=20=201
+
=20/*=20residual=20data=20*/
=20unsigned=20char=20__res[sizeof(bd_t)];
=20
@@=20-1236,6=20+1248,38=20@@
=20=09printk(KERN_INFO=20"Radstone=20Technology=20PPC7D\n");
=20=09if=20(ppc_md.progress)
=20=09=09ppc_md.progress("ppc7d_setup_arch:=20exit",=200);
+
+}
+
+/*=20Real=20Time=20Clock=20support.
+=20*=20PPC7D=20has=20a=20DS1337=20accessed=20by=20I2C.
+=20*/
+static=20ulong=20ppc7d_get_rtc_time(void)
+{
+=20=20=20=20=20=20=20=20struct=20rtc_time=20tm;
+=20=20=20=20=20=20=20=20int=20result;
+
+=20=20=20=20=20=20=20=20spin_lock(&rtc_lock);
+=20=20=20=20=20=20=20=20result=20=3D=20ds1337_do_command(0,=20DS1337_GET_=
DATE,=20&tm);
+=20=20=20=20=20=20=20=20spin_unlock(&rtc_lock);
+
+=20=20=20=20=20=20=20=20if=20(result=20=3D=3D=200)
+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20result=20=3D=20mktime(tm.=
tm_year,=20tm.tm_mon,=20tm.tm_mday,
tm.tm_hour,=20tm.tm_min,=20tm.tm_sec);
+
+=20=20=20=20=20=20=20=20return=20result;
+}
+
+static=20int=20ppc7d_set_rtc_time(unsigned=20long=20nowtime)
+{
+=20=20=20=20=20=20=20=20struct=20rtc_time=20tm;
+=20=20=20=20=20=20=20=20int=20result;
+
+=20=20=20=20=20=20=20=20spin_lock(&rtc_lock);
+=20=20=20=20=20=20=20=20to_tm(nowtime,=20&tm);
+=20=20=20=20=20=20=20=20result=20=3D=20ds1337_do_command(0,=20DS1337_SET_=
DATE,=20&tm);
+=20=20=20=20=20=20=20=20spin_unlock(&rtc_lock);
+
+=20=20=20=20=20=20=20=20return=20result;
=20}
=20
=20/*=20This=20kernel=20command=20line=20parameter=20can=20be=20used=20to=20=
have=20the=20target
@@=20-1293,6=20+1337,10=20@@
=20=09data8=20|=3D=200x07;
=20=09outb(data8,=20PPC7D_CPLD_LEDS);
=20
+=20=20=20=20=20=20=20=20/*=20Hook=20up=20RTC.=20We=20couldn't=20do=20this=
=20earlier=20because=20we=20need=20the
I2C=20subsystem=20*/
+=20=20=20=20=20=20=20=20ppc_md.set_rtc_time=20=3D=20ppc7d_set_rtc_time;
+=20=20=20=20=20=20=20=20ppc_md.get_rtc_time=20=3D=20ppc7d_get_rtc_time;
+
=20=09pr_debug("%s:=20exit\n",=20__FUNCTION__);
=20}


________________________________________________________________________
This=20e-mail=20has=20been=20scanned=20for=20all=20viruses=20by=20Star.=20=
The
service=20is=20powered=20by=20MessageLabs.=20For=20more=20information=20on=
=20a=20proactive
anti-virus=20service=20working=20around=20the=20clock,=20around=20the=20gl=
obe,=20visit:
http://www.star.net.uk
________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread
* [PATCH 2.6.12-rc2 2/2] ppc32: add rtc hooks in PPC7D platform file
@ 2005-04-08  9:31 Chris Elston
  0 siblings, 0 replies; 4+ messages in thread
From: Chris Elston @ 2005-04-08  9:31 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, linuxppc-embedded

[-- Attachment #1: Type: text/plain, Size: 569 bytes --]

This patch adds the hooks into the PPC7D platforms file to
support the DS1337 RTC device as the clock device for the 
PPC7D board.

Signed-off-by: Chris Elston <chris.elston@radstone.co.uk>

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

[-- Attachment #2: ppc7d_rtc_hooks.patch --]
[-- Type: application/octet-stream, Size: 2008 bytes --]

--- linux-2.6.12-rc2/arch/ppc/platforms/radstone_ppc7d.c	2005-04-07 12:31:43.000000000 +0100
+++ linux-2.6.12-rc2-cde/arch/ppc/platforms/radstone_ppc7d.c	2005-04-07 12:28:51.000000000 +0100
@@ -68,6 +68,7 @@
 #define PPC7D_RST_PIN			17 	/* GPP17 */
 
 extern u32 mv64360_irq_base;
+extern spinlock_t rtc_lock;
 
 static struct mv64x60_handle bh;
 static int ppc7d_has_alma;
@@ -75,6 +76,11 @@
 extern void gen550_progress(char *, unsigned short);
 extern void gen550_init(int, struct uart_port *);
 
+/* FIXME - move to h file */
+extern int ds1337_do_command(int id, int cmd, void *arg);
+#define DS1337_GET_DATE         0
+#define DS1337_SET_DATE         1
+
 /* residual data */
 unsigned char __res[sizeof(bd_t)];
 
@@ -1236,6 +1248,38 @@
 	printk(KERN_INFO "Radstone Technology PPC7D\n");
 	if (ppc_md.progress)
 		ppc_md.progress("ppc7d_setup_arch: exit", 0);
+
+}
+
+/* Real Time Clock support.
+ * PPC7D has a DS1337 accessed by I2C.
+ */
+static ulong ppc7d_get_rtc_time(void)
+{
+        struct rtc_time tm;
+        int result;
+
+        spin_lock(&rtc_lock);
+        result = ds1337_do_command(0, DS1337_GET_DATE, &tm);
+        spin_unlock(&rtc_lock);
+
+        if (result == 0)
+                result = mktime(tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
+
+        return result;
+}
+
+static int ppc7d_set_rtc_time(unsigned long nowtime)
+{
+        struct rtc_time tm;
+        int result;
+
+        spin_lock(&rtc_lock);
+        to_tm(nowtime, &tm);
+        result = ds1337_do_command(0, DS1337_SET_DATE, &tm);
+        spin_unlock(&rtc_lock);
+
+        return result;
 }
 
 /* This kernel command line parameter can be used to have the target
@@ -1293,6 +1337,10 @@
 	data8 |= 0x07;
 	outb(data8, PPC7D_CPLD_LEDS);
 
+        /* Hook up RTC. We couldn't do this earlier because we need the I2C subsystem */
+        ppc_md.set_rtc_time = ppc7d_set_rtc_time;
+        ppc_md.get_rtc_time = ppc7d_get_rtc_time;
+
 	pr_debug("%s: exit\n", __FUNCTION__);
 }
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-04-08  9:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-08  8:17 [PATCH 2.6.12-rc2 2/2] ppc32: add rtc hooks in PPC7D platform file Chris Elston
2005-04-08  8:28 ` Andrew Morton
  -- strict thread matches above, loose matches on Subject: below --
2005-04-08  8:43 Chris Elston
2005-04-08  9:31 Chris Elston

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).