]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - arch/ppc/platforms/radstone_ppc7d.c
Merge in v2.6.14 by hand
[karo-tx-linux.git] / arch / ppc / platforms / radstone_ppc7d.c
index df2ea051380a67dd6d1425808fb8e78e4527627c..6f97911c330d4e5d02ff71f12ab2fd1262528b7f 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/delay.h>
-#include <linux/irq.h>
 #include <linux/ide.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
@@ -59,7 +58,6 @@
 #include <asm/mpc10x.h>
 #include <asm/pci-bridge.h>
 #include <asm/mv64x60.h>
-#include <asm/i8259.h>
 
 #include "radstone_ppc7d.h"
 
@@ -68,6 +66,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 +74,11 @@ static int ppc7d_has_alma;
 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)];
 
@@ -510,13 +514,9 @@ static void __init ppc7d_init_irq(void)
        int irq;
 
        pr_debug("%s\n", __FUNCTION__);
-       i8259_init(0);
+       i8259_init(0, 0);
        mv64360_init_irq();
 
-       /* IRQ 0..15 are handled by the cascaded 8259's of the Ali1535 */
-       for (irq = 0; irq < 16; irq++) {
-               irq_desc[irq].handler = &i8259_pic;
-       }
        /* IRQs 5,6,9,10,11,14,15 are level sensitive */
        irq_desc[5].status |= IRQ_LEVEL;
        irq_desc[6].status |= IRQ_LEVEL;
@@ -1179,18 +1179,18 @@ static void __init ppc7d_setup_arch(void)
                ROOT_DEV = Root_HDA1;
 #endif
 
-       if ((cur_cpu_spec[0]->cpu_features & CPU_FTR_SPEC7450) ||
-           (cur_cpu_spec[0]->cpu_features & CPU_FTR_L3CR))
+       if ((cur_cpu_spec->cpu_features & CPU_FTR_SPEC7450) ||
+           (cur_cpu_spec->cpu_features & CPU_FTR_L3CR))
                /* 745x is different.  We only want to pass along enable. */
                _set_L2CR(L2CR_L2E);
-       else if (cur_cpu_spec[0]->cpu_features & CPU_FTR_L2CR)
+       else if (cur_cpu_spec->cpu_features & CPU_FTR_L2CR)
                /* All modules have 1MB of L2.  We also assume that an
                 * L2 divisor of 3 will work.
                 */
                _set_L2CR(L2CR_L2E | L2CR_L2SIZ_1MB | L2CR_L2CLK_DIV3
                          | L2CR_L2RAM_PIPE | L2CR_L2OH_1_0 | L2CR_L2DF);
 
-       if (cur_cpu_spec[0]->cpu_features & CPU_FTR_L3CR)
+       if (cur_cpu_spec->cpu_features & CPU_FTR_L3CR)
                /* No L3 cache */
                _set_L3CR(0);
 
@@ -1242,6 +1242,38 @@ static void __init ppc7d_setup_arch(void)
        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
@@ -1299,6 +1331,10 @@ static void ppc7d_init2(void)
        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__);
 }
 
@@ -1384,6 +1420,7 @@ void __init platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
        ppc_md.setup_arch = ppc7d_setup_arch;
        ppc_md.init = ppc7d_init2;
        ppc_md.show_cpuinfo = ppc7d_show_cpuinfo;
+       /* XXX this is broken... */
        ppc_md.irq_canonicalize = ppc7d_irq_canonicalize;
        ppc_md.init_IRQ = ppc7d_init_irq;
        ppc_md.get_irq = ppc7d_get_irq;