示例#1
0
void
ar7240wdt_init(void)
{
	int ret;
	extern void ar7240_gpio_config_input(int);

	printk("%s: Registering WDT ", __func__);
	if ((ret = misc_register(&ar7240wdt_miscdev))) {
		printk("failed %d\n", ret);
		return;
	} else {
		printk("success\n");
	}

#ifdef CONFIG_WASP_SUPPORT
	wdt->clk_freq = ath_ref_clk_freq;
#else
	wdt->clk_freq = ar7240_ahb_freq;
#endif

#ifdef CONFIG_MACH_HORNET
   	wdt->tmo = AR7240_DEFAULT_WD_TMO;
    ar7240_set_wd_timer(wdt->tmo * 6);
    ar7240_set_wd_timer_action(AR7240_WD_ACT_RESET);
    mod_timer(&wd_timer, AR7240_DEFAULT_MOD_TMO);

    if (request_irq(
        AR7240_GPIO_IRQn(AR7240_GPIO_RESET),
        ar7240_wdt_isr,
        0,
        "Watchdog Reset",
        wdt)) {
        wddbg("%s: request_irq %d\n", __func__, ret);
    }
#endif
	ar7240_gpio_config_input(AR7240_GPIO_RESET);
}
示例#2
0
文件: gpio.c 项目: celeduc/TL-WR703N
int __init ar7240_simple_config_init(void)
{
    int req;

	/* restore factory default and system led */
	dev_t dev;
    int rt;
    int ar7240_gpio_major = gpio_major;
    int ar7240_gpio_minor = gpio_minor;

	init_timer(&rst_timer);
	rst_timer.function = check_rst;
	
#ifdef CONFIG_PID_MR302001
	printk("\n\nWhoops! This kernel is for product mr3020 v1.0!\n\n");
#endif
#ifdef CONFIG_PID_WR74104
	printk("\n\nWhoops! This kernel is for product wr741 v4.0!\n\n");
#endif
#ifdef CONFIG_PID_MR322001
	printk("\n\nWhoops! This kernel is for product mr3220 v1.0!\n\n");
#endif
#ifdef CONFIG_PID_MR322002
	printk("\n\nWhoops! This kernel is for product mr3220 v2.0!\n\n");
#endif
#ifdef CONFIG_PID_WR70301
	printk("\n\nWhoops! This kernel is for product wr703 v1.0!\n\n");
#endif

#ifdef SUPPORT_HARDWARE_MULTI_MODE
	/* added by ZCF, 20110420 */
	init_sysMode();
	init_timer(&sysMode_timer);
	sysMode_timer.function = check_sysMode;
	mod_timer(&sysMode_timer, jiffies + 1 * HZ);
#endif

#ifndef JUMPSTART_RST_MULTIPLEXED
#ifdef JUMPSTART_GPIO
	init_timer(&wps_timer);
	wps_timer.function = check_wps;
	/* This is NECESSARY, lsz 090109 */
	ar7240_gpio_config_input(JUMPSTART_GPIO);
	 /* configure JUMPSTART_GPIO as level triggered interrupt */
    	ar7240_gpio_config_int (JUMPSTART_GPIO, INT_TYPE_LEVEL, INT_POL_ACTIVE_HIGH);

	 req = request_irq (AR7240_GPIO_IRQn(JUMPSTART_GPIO), jumpstart_irq, 0,
                       "SW_JUMPSTART", NULL);
    if (req != 0)
	{
        printk (KERN_ERR "unable to request IRQ for SWJUMPSTART GPIO (error %d)\n", req);
    }
#endif
#endif

#ifdef GPIO_INTERNET_LED_BIT
	g_internetLedPin = GPIO_INTERNET_LED_BIT;
#endif
#ifdef AP_USB_LED_GPIO
	ar7240_gpio_config_output(AP_USB_LED_GPIO);
	/* init Internet LED status (off) */
	ar7240_gpio_out_val(AP_USB_LED_GPIO, USB_LED_OFF);
#endif

#ifdef GPIO_WLAN_LED_BIT
	/* init WLAN LED status (off) */
	ar7240_gpio_out_val(WLAN_LED_GPIO, WLAN_LED_OFF);
#endif

#ifdef SYS_LED_GPIO
	/* configure SYS_LED_GPIO as output led */
	ar7240_gpio_config_output(SYS_LED_GPIO);
	//ar7240_gpio_out_val(SYS_LED_GPIO, SYS_LED_OFF);
#endif

#ifdef GPIO_SLOW_ETH_LED
	init_timer(&slow_led_timer);
	slow_led_timer.function = slow_led_expire;
	mod_timer(&slow_led_timer, jiffies + 1 * HZ);
#endif

#ifdef GPIO_JUMPSTART_LED_BIT
	/* configure gpio as outputs */
    ar7240_gpio_config_output (TRICOLOR_LED_GREEN_PIN); 
    /* switch off the led */
    ar7240_gpio_out_val(TRICOLOR_LED_GREEN_PIN, OFF);
#endif

#ifdef GPIO_USB_POWER_SUPPORT
	/* configure gpio as outputs */
    ar7240_gpio_config_output (SYS_USB_POWER_GPIO); 
    /* power on usb modem */
    ar7240_gpio_out_val(SYS_USB_POWER_GPIO, USB_POWER_ON);
#endif

    create_simple_config_led_proc_entry ();

	ar7240_gpio_config_input(RST_DFT_GPIO);

	/* configure GPIO RST_DFT_GPIO as level triggered interrupt */
	ar7240_gpio_config_int (RST_DFT_GPIO, INT_TYPE_LEVEL, INT_POL_ACTIVE_HIGH);

    rt = request_irq (AR7240_GPIO_IRQn(RST_DFT_GPIO), rst_irq, 0,
                       "RESTORE_FACTORY_DEFAULT", NULL);
    if (rt != 0)
	{
        printk (KERN_ERR "unable to request IRQ for RESTORE_FACTORY_DEFAULT GPIO (error %d)\n", rt);
    }

    if (ar7240_gpio_major)
	{
        dev = MKDEV(ar7240_gpio_major, ar7240_gpio_minor);
        rt = register_chrdev_region(dev, 1, "ar7240_gpio_chrdev");
    }
	else
	{
        rt = alloc_chrdev_region(&dev, ar7240_gpio_minor, 1, "ar7240_gpio_chrdev");
        ar7240_gpio_major = MAJOR(dev);
    }

    if (rt < 0)
	{
        printk(KERN_WARNING "ar7240_gpio_chrdev : can`t get major %d\n", ar7240_gpio_major);
        return rt;
    }

    cdev_init (&gpio_device_cdev, &gpio_device_op);
    rt = cdev_add(&gpio_device_cdev, dev, 1);
	
    if (rt < 0) 
		printk(KERN_NOTICE "Error %d adding ar7240_gpio_chrdev ", rt);

    return 0;
}
示例#3
0
文件: gpio.c 项目: celeduc/TL-WR703N
static int create_simple_config_led_proc_entry (void)
{
    if (simple_config_entry != NULL) {
        printk ("Already have a proc entry for /proc/simple_config!\n");
        return -ENOENT;
    }

    simple_config_entry = proc_mkdir("simple_config", NULL);
    if (!simple_config_entry)
        return -ENOENT;

    simulate_push_button_entry = create_proc_entry ("push_button", 0644,
                                                      simple_config_entry);
    if (!simulate_push_button_entry)
        return -ENOENT;

    simulate_push_button_entry->write_proc = push_button_write;
    simulate_push_button_entry->read_proc = push_button_read;
	
#ifdef GPIO_JUMPSTART_LED_BIT
    tricolor_led_entry = create_proc_entry ("tricolor_led", 0644,
                                            simple_config_entry);
    if (!tricolor_led_entry)
        return -ENOENT;

    tricolor_led_entry->write_proc = gpio_tricolor_led_write;
    tricolor_led_entry->read_proc = gpio_tricolor_led_read;
#endif

#ifdef GPIO_INTERNET_LED_BIT
	/* for internet led blink */
	internet_led_status_entry = create_proc_entry ("internet_blink", 0666,
                                                      simple_config_entry);
	if (!internet_led_status_entry)
		return -ENOENT;
	
    internet_led_status_entry->write_proc = internet_led_status_write;
    internet_led_status_entry->read_proc = internet_led_status_read;
#endif

#ifdef GPIO_USB_POWER_SUPPORT
	/*added by ZQQ, 10.06.02 for usb power*/
	usb_power_entry = create_proc_entry("usb_power", 0666, simple_config_entry);
	if(!usb_power_entry)
		return -ENOENT;

	usb_power_entry->write_proc = usb_power_write;
	usb_power_entry->read_proc = usb_power_read;	
	/*end added*/
#endif

#ifdef CONFIG_PID_MR302001
	wlan_led_entry = create_proc_entry("wlan_led", 0666, simple_config_entry);
	if (!wlan_led_entry)
		return -ENOENT;
	
	wlan_led_entry->read_proc = gpio_wlan_status_read;
	wlan_led_entry->write_proc = gpio_wlan_status_write;
#endif
    
	system_mode_entry = create_proc_entry("system_mode", 0666,
								simple_config_entry);
	if (!system_mode_entry)
		return -ENOENT;

	system_mode_entry->read_proc = gpio_system_mode_read;
	system_mode_entry->write_proc = gpio_system_mode_write;

#ifdef SUPPORT_HARDWARE_MULTI_MODE
	/* configure gpio as inputs */
	ar7240_gpio_config_input(SYS_MODE_GPIO_1);
	ar7240_gpio_config_input(SYS_MODE_GPIO_2);
#endif

    return 0;
}