atheros: fix setting the gpio interrupt level when registering a gpio interrupt
[openwrt/svn-archive/archive.git] / target / linux / atheros / files / arch / mips / atheros / board.c
index ebb4a5afef716102eacc2cf325fcd4ab404beac3..ba427883a7d8601d6df129b15a2f95d03f914013 100644 (file)
@@ -25,7 +25,7 @@
 #include <asm/bootinfo.h>
 #include <asm/irq_cpu.h>
 #include <asm/io.h>
-#include "ar531x.h"
+#include <ar531x.h>
 
 char *board_config, *radio_config;
 
@@ -51,7 +51,7 @@ static u8 *find_board_config(char *flash_limit)
                printk("WARNING: No board configuration data found!\n");
                addr = NULL;
        }
-       
+
        return addr;
 }
 
@@ -59,8 +59,8 @@ static u8 *find_radio_config(char *flash_limit, char *board_config)
 {
        int dataFound;
        u32 radio_config;
-       
-       /* 
+
+       /*
         * Now find the start of Radio Configuration data, using heuristics:
         * Search forward from Board Configuration data by 0x1000 bytes
         * at a time until we find non-0xffffffff.
@@ -121,16 +121,16 @@ int __init ar531x_find_config(char *flash_limit)
 
        radio_config = board_config + 0x100 + ((rcfg - bcfg) & 0xfff);
        printk("Radio config found at offset 0x%x(0x%x)\n", rcfg - bcfg, radio_config - board_config);
-       rcfg_size = BOARD_CONFIG_BUFSZ - ((rcfg - bcfg) & (BOARD_CONFIG_BUFSZ - 1));
+       rcfg_size = BOARD_CONFIG_BUFSZ - ((0x100 + rcfg - bcfg) & (BOARD_CONFIG_BUFSZ - 1));
        memcpy(radio_config, rcfg, rcfg_size);
-       
+
        return 0;
 }
 
 void __init serial_setup(unsigned long mapbase, unsigned int uartclk)
 {
        struct uart_port s;
-       
+
        memset(&s, 0, sizeof(s));
 
        s.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
@@ -162,7 +162,7 @@ const char *get_system_type(void)
 
        case MACH_ATHEROS_AR2312:
                return "Atheros AR2312";
-               
+
        case MACH_ATHEROS_AR2313:
                return "Atheros AR2313";
 #endif
@@ -180,6 +180,7 @@ const char *get_system_type(void)
        return "Atheros (unknown)";
 }
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
 void __init plat_timer_setup(struct irqaction *irq)
 {
        unsigned int count;
@@ -191,6 +192,7 @@ void __init plat_timer_setup(struct irqaction *irq)
        count = read_c0_count();
        write_c0_compare(count + 1000);
 }
+#endif
 
 asmlinkage void plat_irq_dispatch(void)
 {
@@ -198,6 +200,13 @@ asmlinkage void plat_irq_dispatch(void)
        DO_AR5315(ar5315_irq_dispatch();)
 }
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
+void (*board_time_init)(void);
+void __init plat_time_init(void) {
+    board_time_init();
+}
+#endif
+
 void __init arch_init_irq(void)
 {
        clear_c0_status(ST0_IM);
@@ -207,3 +216,24 @@ void __init arch_init_irq(void)
        DO_AR5312(ar5312_misc_intr_init(AR531X_MISC_IRQ_BASE);)
        DO_AR5315(ar5315_misc_intr_init(AR531X_MISC_IRQ_BASE);)
 }
+
+static int __init ar531x_register_gpiodev(void)
+{
+       static struct resource res = {
+               .start = 0xFFFFFFFF,
+       };
+       struct platform_device *pdev;
+
+       printk(KERN_INFO "ar531x: Registering GPIODEV device\n");
+
+       pdev = platform_device_register_simple("GPIODEV", 0, &res, 1);
+
+       if (!pdev) {
+               printk(KERN_ERR "ar531x: GPIODEV init failed\n");
+               return -ENODEV;
+       }
+
+       return 0;
+}
+
+device_initcall(ar531x_register_gpiodev);