/*-----------------------------------------------------------------------------------------------*\
\*-----------------------------------------------------------------------------------------------*/
#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <asm/fcntl.h>
#include <asm/ioctl.h>
#include <asm/errno.h>
#include <asm/uaccess.h>
#include <linux/wait.h>
#include <linux/poll.h>
#include <linux/timer.h>
#include <linux/fs.h>
#include <asm/semaphore.h>

#define AVM_EVENT_INTERNAL
#include <linux/ar7wdt.h>
#include <linux/avm_event.h>

#include <asm/mach-ohio/led_config.h>
#include "led_drv.h"

#define MODULE_NAME     "avm"
MODULE_DESCRIPTION("AR7 Watchdog Timer + LED Driver + AVM Central Event distribution");
MODULE_LICENSE("Proprietary");
MODULE_AUTHOR("\n(C) Copyright 2003, Texas Instruments, Inc\n(C) Copyright 2004, 2005, AVM");
/*--- MODULE_LICENSE("\n(C) Copyright 2003, Texas Instruments, Inc\n(C) Copyright 2004, 2005, AVM"); ---*/



/*------------------------------------------------------------------------------------------*\
\*------------------------------------------------------------------------------------------*/
int ar7wdt_no_reboot = 0;
MODULE_PARM(ar7wdt_no_reboot, "i");
MODULE_PARM_DESC(ar7wdt_no_reboot, "Watchdog no reboot");

int avm_event_enable_push_button = 0;
MODULE_PARM(avm_event_enable_push_button, "i");
MODULE_PARM_DESC(avm_event_enable_push_button, "enable push putton funktionality");

#if !defined(CONFIG_AVM_LED) && !defined(CONFIG_AVM_LED_MODULE)
#if (CONFIG_MIPS_AVALANCHE_LED == 1) || (CONFIG_MIPS_AVALANCHE_LED_MODULE == 1)
#define ENABLE_LED 1
#endif /*--- #if (CONFIG_MIPS_AVALANCHE_LED == 1) || (CONFIG_MIPS_AVALANCHE_LED_MODULE == 1) ---*/
#endif /*--- #if !defined(CONFIG_AVM_LED) && !defined(CONFIG_AVM_LED_MODULE) ---*/

/*------------------------------------------------------------------------------------------*\
\*------------------------------------------------------------------------------------------*/
static int avm_sammel_init(void) {
    int ret;
#if (CONFIG_AVM_WATCHDOG == 1) || (CONFIG_AR7WDT_MODULE == 1)
    ret = ar7wdt_init();
    if(ret) {
        printk("[avm]: ar7wdt_init: failed\n");
        return ret;
    }
#endif /*--- #if (CONFIG_AVM_WATCHDOG == 1) || (CONFIG_AR7WDT_MODULE == 1) ---*/
#if defined(ENABLE_LED)
    ret = led_init();
    if(ret) {
        printk("[avm]: led_init: failed\n");
        return ret;
    }
#endif /*--- #if defined(ENABLE_LED) ---*/
#if (CONFIG_AVM_EVENT == 1) || (CONFIG_AVM_EVENT_MODULE == 1)
    ret = avm_event_init();
    if(ret) {
        printk("[avm]: avm_event_init: failed\n");
        return ret;
    }
#endif /*--- #if (CONFIG_AVM_EVENT == 1) || (CONFIG_AVM_EVENT_MODULE == 1) ---*/
    return 0;
}

/*------------------------------------------------------------------------------------------*\
\*------------------------------------------------------------------------------------------*/
static void avm_sammel_deinit(void) {
#if (CONFIG_AVM_WATCHDOG == 1) || (CONFIG_AR7WDT_MODULE == 1)
    ar7wdt_cleanup();
#endif /*--- #if (CONFIG_AVM_WATCHDOG == 1) || (CONFIG_AR7WDT_MODULE == 1) ---*/
#if defined(ENABLE_LED)
    led_exit();
#endif /*--- #if defined(ENABLE_LED) ---*/
#if (CONFIG_AVM_EVENT == 1) || (CONFIG_AVM_EVENT_MODULE == 1)
    avm_event_cleanup();
#endif /*--- #if (CONFIG_AVM_EVENT == 1) || (CONFIG_AVM_EVENT_MODULE == 1) ---*/
}

/*------------------------------------------------------------------------------------------*\
\*------------------------------------------------------------------------------------------*/
module_init(avm_sammel_init);
module_exit(avm_sammel_deinit);

