static OS_TIMER_FUNC(wps_led_overlap)
{
	gpio_wps_other_led_off();

	if(time>0)
	{
		WPSled = !WPSled;
		ath_gpio_out_val(wps_led_gpio, WPSled);
		time--;
	}
	else if(off-->0)
	{
		if(off==4)
		{
			WPSled=WPS_LED_OFF;
			ath_gpio_out_val(wps_led_gpio, WPSled);
		}
		if(off==0)
		{
			time=9;
			off=5;
		}
	}

	OS_SET_TIMER(&os_timer_t, 100);

}
Beispiel #2
0
static int usb_power_write (struct file *file, const char *buf,
				unsigned long count, void *data)
{
    u_int32_t val = 0;

	if (sscanf(buf, "%d", &val) != 1)
        return -EINVAL;

	if ((val < 0) || (val > 1))
		return -EINVAL;

	printk("%s %d: write gpio:value = %d\r\n",__FUNCTION__,__LINE__,val);

	#ifdef USB_POWER_SW_GPIO
	if (USB_POWER_ON == val)
	{
		ath_gpio_out_val(USB_POWER_SW_GPIO, USB_POWER_ON);
	}
	else
	{
		ath_gpio_out_val(USB_POWER_SW_GPIO, USB_POWER_OFF);
	}
	#endif
	
	return count;
}
Beispiel #3
0
Datei: gpio.c Projekt: jhbsz/102
static OS_TIMER_FUNC(wps_led_blink)
{
	static int WPSled = WPS_LED_ON, sec = 0;
	ath_gpio_out_val(WPS_LED_GPIO, WPSled);
	WPSled = !WPSled;
	sec++;
	if (sec < WPS_TIME_OUT) {
		OS_SET_TIMER(&os_timer_t, 1000);
	} else {
		sec = 0;
		wps_led_blinking = 0;
		OS_CANCEL_TIMER(&os_timer_t);
		ath_gpio_out_val(WPS_LED_GPIO, initial_led_state);
	}
}
Beispiel #4
0
Datei: gpio.c Projekt: jhbsz/102
static OS_TIMER_FUNC(wps_led_fail)
{
	static int WPSled = WPS_LED_ON, sec = 0;
	ath_gpio_out_val(WPS_LED_GPIO, WPSled);
	WPSled = !WPSled;
	sec++;
	if (sec < 250 * 5) {//Keep blinking for 250 seconds & timer callback kicks in every 200 ms
		OS_SET_TIMER(&os_timer_t, 200);
	} else {
		sec = 0;
		wps_led_blinking = 0;
		OS_CANCEL_TIMER(&os_timer_t);
		ath_gpio_out_val(WPS_LED_GPIO, initial_led_state);
	}
}
static OS_TIMER_FUNC(wps_led_ingress)
{

	gpio_wps_other_led_off();

	if (WPS_LED_ON == WPSled)
	{
	    on--;
	    if(0==on){on=2;change=1;}
	    else change=0;
	}
	else if (WPS_LED_OFF == WPSled)
	{
	    change=1;  
	}
	if(1==change)
	{	
		WPSled = !WPSled;
		ath_gpio_out_val(wps_led_gpio, WPSled);
		
	}
    
    OS_SET_TIMER(&os_timer_t, 100);

}
void ap_usb_led_on(void)
{
#ifdef CONFIG_MACH_AR934x
#if !defined(CONFIG_I2S) && defined(AP_USB_LED_GPIO)
    unsigned int rddata;

    if(AP_USB_LED_GPIO == 4) { 
     	rddata = ath_reg_rd(ATH_GPIO_OUT_FUNCTION1); //87- for USB suspend
    	rddata = rddata & 0xffffff00;
    	rddata = rddata | ATH_GPIO_OUT_FUNCTION1_ENABLE_GPIO_4(0x0);
    	ath_reg_wr(ATH_GPIO_OUT_FUNCTION1, rddata);
    }else if(AP_USB_LED_GPIO == 11) {
        rddata = ath_reg_rd(ATH_GPIO_OUT_FUNCTION2); //87- for USB suspend
        rddata = rddata & 0x00ffffff;
        rddata = rddata | ATH_GPIO_OUT_FUNCTION2_ENABLE_GPIO_11(0x0);
        ath_reg_wr(ATH_GPIO_OUT_FUNCTION2, rddata);
    }
    
    ath_reg_rmw_clear(ATH_GPIO_OE, (1<<AP_USB_LED_GPIO));
    ath_reg_rmw_clear(ATH_GPIO_OUT, (1<<AP_USB_LED_GPIO));
#endif
#else
	ath_gpio_out_val(AP_USB_LED_GPIO, USB_LED_ON);
#endif
}
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;

	simple_config_led_entry = create_proc_entry("simple_config_led", 0644,
							simple_config_entry);
	if (!simple_config_led_entry)
		return -ENOENT;

	simple_config_led_entry->write_proc = gpio_simple_config_led_write;
	simple_config_led_entry->read_proc = gpio_simple_config_led_read;

	/* configure gpio as outputs */
	ath_gpio_config_output(wps_led_gpio);

	/* switch off the led */
	ath_gpio_out_val(wps_led_gpio, WPS_LED_OFF);
	return 0;
}
Beispiel #8
0
Datei: gpio.c Projekt: jhbsz/102
static int gpio_simple_config_led_write(struct file *file, const char *buf,
					unsigned long count, void *data)
{
	u_int32_t val;

	if (sscanf(buf, "%d", &val) != 1)
		return -EINVAL;
    
    if(val == SIMPLE_CONFIG_BLINK){
        if( ath_gpio_in_val(WPS_LED_GPIO) == 0 ){
            initial_led_state = WPS_LED_ON;
        }else{ 
            initial_led_state = WPS_LED_OFF;
        }
    }

	if ((val == SIMPLE_CONFIG_BLINK) && !wps_led_blinking) { /* wps LED blinking */
		wps_led_blinking = 1;
		simple_config_led_state = SIMPLE_CONFIG_BLINK;
		ath_gpio_out_val(WPS_LED_GPIO, WPS_LED_ON);
		OS_CANCEL_TIMER(&os_timer_t);
		OS_INIT_TIMER(NULL, &os_timer_t, wps_led_blink, &os_timer_t);
		OS_SET_TIMER(&os_timer_t, 1000);
	} else if (val == SIMPLE_CONFIG_FAIL) {	/* WPS failed */
		wps_led_blinking = 0;
		simple_config_led_state = SIMPLE_CONFIG_FAIL;
		ath_gpio_out_val(WPS_LED_GPIO, WPS_LED_ON);
		OS_CANCEL_TIMER(&os_timer_t);
		OS_INIT_TIMER(NULL, &os_timer_t, wps_led_fail, &os_timer_t);
		OS_SET_TIMER(&os_timer_t, 200);
	} else if (val == SIMPLE_CONFIG_ON) {	/* WPS Success */
		wps_led_blinking = 0;
		simple_config_led_state = SIMPLE_CONFIG_ON;
		OS_CANCEL_TIMER(&os_timer_t);
		ath_gpio_out_val(WPS_LED_GPIO, WPS_LED_ON);
		OS_INIT_TIMER(NULL, &os_timer_t, wps_led_success, &os_timer_t);
		OS_SET_TIMER(&os_timer_t, 120000);
	} else if (val == SIMPLE_CONFIG_OFF) {	/* wps LED off */
		wps_led_blinking = 0;
		simple_config_led_state = SIMPLE_CONFIG_OFF;
		OS_CANCEL_TIMER(&os_timer_t);
		ath_gpio_out_val(WPS_LED_GPIO, initial_led_state);
	}

	return count;
}
Beispiel #9
0
Datei: gpio.c Projekt: jhbsz/102
void ap_usb_host_led_on(int gpio)
{
#if defined(AP_USB1_LED_GPIO) || defined(AP_USB2_LED_GPIO)
    ath_gpio_config_output(gpio);
    ath_gpio_set_fn(gpio, 0);
    ath_gpio_out_val(gpio, USB_LED_ON);
#endif
}
/* END ADD: c00217102 2012-8-12 FOR WS323 */
static OS_TIMER_FUNC(wps_led_blink)
{
	gpio_wps_other_led_off();
	
	ath_gpio_out_val(wps_led_gpio, WPSled);
	WPSled = !WPSled;
	sec++;
	if (sec < 130) {        
		OS_SET_TIMER(&os_timer_t, 1000);
	} else {
		sec = 0;
		OS_CANCEL_TIMER(&os_timer_t);
		WPSled=WPS_LED_OFF;
		ath_gpio_out_val(wps_led_gpio, WPSled);
		simple_config_led_state = SIMPLE_CONFIG_OFF;
	}
}
Beispiel #11
0
void ap_usb_led_off(void)
{
#if 0
#ifdef AP_USB_LED_GPIO
	ath_gpio_out_val(AP_USB_LED_GPIO, USB_LED_OFF);
#endif
#endif
}
static OS_TIMER_FUNC(wps_led_error)
{
    WPSled = !WPSled;
	gpio_wps_other_led_off();	
	ath_gpio_out_val(wps_led_gpio, WPSled);

    OS_SET_TIMER(&os_timer_t, 100);
 
}
Beispiel #13
0
void ap_usb_led_on(void)
{
	/* we do not need this function, and usb hub drivers will call this function to let led on by lyj, 26Sep11 */
#if 0
#ifdef AP_USB_LED_GPIO  
	ath_gpio_out_val(AP_USB_LED_GPIO, USB_LED_ON);
#endif
#endif
}
Beispiel #14
0
Datei: gpio.c Projekt: jhbsz/102
static OS_TIMER_FUNC(power_led_blink)
{
	static int power_led_status = POWER_LED_OFF, power_on_timeout = 0;

    OS_CANCEL_TIMER(&power_on_timer);

    if (power_on_finish) {
		ath_gpio_out_val(POWER_ON_GLED_GPIO, POWER_LED_ON);
    } else if (++power_on_timeout >= POWER_ON_TIMEOUT) {
        ath_gpio_out_val(POWER_ON_GLED_GPIO, POWER_LED_OFF);  
        ath_gpio_config_input(POWER_ON_GLED_GPIO);
        ath_gpio_config_output(POWER_ON_RLED_GPIO);
        ath_gpio_out_val(POWER_ON_RLED_GPIO, POWER_LED_ON);  
    } else {
		ath_gpio_out_val(POWER_ON_GLED_GPIO, power_led_status);
	    power_led_status = !power_led_status;
		OS_SET_TIMER(&power_on_timer, POWER_LED_BLINK_INTERVAL);
    }
}
void ap_usb_led_off(void)
{
#ifdef CONFIG_MACH_AR934x
#if !defined(CONFIG_I2S) && defined(AP_USB_LED_GPIO)
	ath_reg_rmw_set(ATH_GPIO_OUT, (1<<AP_USB_LED_GPIO));
#endif
#else
	ath_gpio_out_val(AP_USB_LED_GPIO, USB_LED_OFF);
#endif
}
/* START ADD: c00217102 2012-8-12 FOR WS323 */
static OS_TIMER_FUNC(wps_led_on)
{
	static int WPSled = WPS_LED_ON, secd = 0;
	gpio_wps_other_led_off();
	ath_gpio_out_val(wps_led_gpio, WPSled);
	
	if (secd < 100) 
    {        
        secd++;
        OS_SET_TIMER(&os_timer_t, 100);
	} 
    else 
    {
		secd = 0;
		OS_CANCEL_TIMER(&os_timer_t);
		ath_gpio_out_val(wps_led_gpio, WPS_LED_OFF);        
		simple_config_led_state = SIMPLE_CONFIG_OFF;
        printk("OS_TIMER_FUNC(wps_led_on) over\n");
	}
}
static void gpio_wps_other_led_off()
{
	ath_gpio_out_val(RED_LED_GPIO, WPS_LED_OFF);
	ath_gpio_out_val(GREEN_LED_GPIO, WPS_LED_OFF);
	ath_gpio_out_val(BLUE_LED_GPIO, WPS_LED_OFF);	
	ath_gpio_out_val(WLAN_SIGNAL_HIGH_LED_GPIO, WPS_LED_OFF);
	ath_gpio_out_val(WLAN_SIGNAL_MID_LED_GPIO, WPS_LED_OFF);
	ath_gpio_out_val(WLAN_SIGNAL_LOW_LED_GPIO, WPS_LED_OFF);
}
Beispiel #18
0
Datei: gpio.c Projekt: jhbsz/102
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;

	simple_config_led_entry = create_proc_entry("simple_config_led", 0644,
							simple_config_entry);
	if (!simple_config_led_entry)
		return -ENOENT;

	simple_config_led_entry->write_proc = gpio_simple_config_led_write;
	simple_config_led_entry->read_proc = gpio_simple_config_led_read;

	/* configure gpio as outputs */
	ath_gpio_config_output(WPS_LED_GPIO);

	/* switch off the led */
	ath_gpio_out_val(WPS_LED_GPIO, WPS_LED_OFF);

#ifdef POWER_ON_RLED_GPIO
	power_on_proc_entry = create_proc_entry("power_on_finish", 0644,
							simple_config_entry);
	if (!power_on_proc_entry)
		return -ENOENT;

	power_on_proc_entry->write_proc = power_on_finish_write;
	power_on_proc_entry->read_proc = power_on_finish_read;
#endif
	return 0;
}
Beispiel #19
0
static int gpio_tricolor_led_write (struct file *file, const char *buf,
					unsigned long count, void *data)
{
    u_int32_t val, green_led_onoff = 0, yellow_led_onoff = 0;

	if (sscanf(buf, "%d", &val) != 1)
		return -EINVAL;

    if (val >= LED_STATE_MAX)
        return -EINVAL;

    if (val == gpio_tricolorled)
		return count;

    switch (val) {
        case LED_STATE_OFF :
                green_led_onoff = OFF;   /* both LEDs OFF */
                yellow_led_onoff = OFF;
                break;

        case LED_STATE_GREEN:
                green_led_onoff = ON;    /* green ON, Yellow OFF */
                yellow_led_onoff = OFF;
                break;

        case LED_STATE_YELLOW:
                green_led_onoff = OFF;   /* green OFF, Yellow ON */
                yellow_led_onoff = ON;
                break;
    
        case LED_STATE_ORANGE:
                green_led_onoff = ON;    /* both LEDs ON */
                yellow_led_onoff = ON;
                break;
	}

    ath_gpio_out_val (TRICOLOR_LED_GREEN_PIN, green_led_onoff);
    //ar7240_gpio_out_val (TRICOLOR_LED_YELLOW_PIN, yellow_led_onoff);
    gpio_tricolorled = val;

    return count;
}
Beispiel #20
0
Datei: gpio.c Projekt: jhbsz/102
static OS_TIMER_FUNC(wps_led_success)
{
    wps_led_blinking = 0;
    OS_CANCEL_TIMER(&os_timer_t);
    ath_gpio_out_val(WPS_LED_GPIO, initial_led_state);
}
Beispiel #21
0
int __init ar7240_simple_config_init(void)
{
    int req;

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

	init_timer(&rst_timer);
	rst_timer.function = check_rst;

	/* config gpio 11, 12, 14, 15, 16, 17 as normal gpio function */
	/* gpio11 */
	ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION2, 0xff<<24);
	/* gpio12 */
	ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION3, 0xff<<0);
	/* gpio14 */
	ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION3, 0xff<<16);
	/* gpio15 */
	ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION3, 0xff<<24);
	/* gpio16 */
	ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION4, 0xff<<0);
	/* gpio17 */
	ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION4, 0xff<<8);


#ifndef CONFIG_MUX_RESET_WPS_BUTTON
	/* This is NECESSARY, lsz 090109 */
	ath_gpio_config_input(WPS_BUTTON_GPIO);

    /* configure JUMPSTART_GPIO as level triggered interrupt */
    ath_gpio_config_int (WPS_BUTTON_GPIO, INT_TYPE_LEVEL, INT_POL_ACTIVE_LOW);

    req = request_irq (ATH_GPIO_IRQn(WPS_BUTTON_GPIO), wpsStart_irq, 0,
                       "SW_WPSSTART", NULL);
    if (req != 0)
	{
        printk (KERN_ERR "unable to request IRQ for SWWPSSTART GPIO (error %d)\n", req);
    }
#endif

    create_simple_config_led_proc_entry ();

	ath_gpio_config_input(RST_DFT_GPIO);

	/* configure GPIO RST_DFT_GPIO as level triggered interrupt */
    ath_gpio_config_int (RST_DFT_GPIO, INT_TYPE_LEVEL, INT_POL_ACTIVE_LOW);

    rt = request_irq (ATH_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);
    }

	/* wifi switch! */
	ath_gpio_config_input(WIFI_RADIO_SW_GPIO);
	current_wifi_value = ath_reg_rd(ATH_GPIO_IN) & (1 << WIFI_RADIO_SW_GPIO);
	
	/* configure GPIO RST_DFT_GPIO as level triggered interrupt */
	if(current_wifi_value == 0)
	{
		ignore_wifibutton = 1;
		ath_gpio_config_int (WIFI_RADIO_SW_GPIO, INT_TYPE_LEVEL, INT_POL_ACTIVE_LOW);
	}
	else
	{
		ignore_wifibutton =0;
		ath_gpio_config_int (WIFI_RADIO_SW_GPIO, INT_TYPE_LEVEL, INT_POL_ACTIVE_HIGH);
	}

    req = request_irq (ATH_GPIO_IRQn(WIFI_RADIO_SW_GPIO), wifi_sw_irq, 0,
                       "WIFI_RADIO_SWITCH", NULL);
    if (req != 0)
	{
        printk (KERN_ERR "unable to request IRQ for WIFI_RADIO_SWITCH GPIO (error %d)\n", req);
    }

    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);

	#ifdef AP_USB_LED_GPIO
	ath_gpio_config_output(AP_USB_LED_GPIO);
	#endif
	#ifdef AP_USB_1_LED_GPIO
	ath_gpio_config_output(AP_USB_1_LED_GPIO);
	#endif
	ath_gpio_config_output(SYS_LED_GPIO);
	
	/* for USB 3G by lyj, 31Aug11 */
	#ifdef USB_POWER_SW_GPIO
	ath_gpio_config_output(USB_POWER_SW_GPIO);
	#endif
	#ifdef USB_1_POWER_SW_GPIO
	ath_gpio_config_output(USB_1_POWER_SW_GPIO);
	#endif

	/* s27 will use the gpio 18 19 as ethernet led */
	#ifdef CONFIG_SUPPORT_S17
	/* GPIO18-19 by lyj, 27Sep11 */
	ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION4, 0xff<<16);
	ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION4, 0xff<<24);
	/* config GPIO18-19 as output by lyj, 27Sep11 */
	ath_gpio_config_output(18);
	ath_gpio_config_output(19);

	/* set GPIO18-19, for AR9344 art (LNA) by lyj, 27Sep11 */
	ath_reg_rmw_set(ATH_GPIO_OUT_FUNCTION4, 0x2f2e0000);
	#endif
	
	ath_gpio_out_val(SYS_LED_GPIO, SYS_LED_OFF);
	#ifdef AP_USB_LED_GPIO
	ath_gpio_out_val(AP_USB_LED_GPIO, USB_LED_OFF);
	#endif
	#ifdef AP_USB_1_LED_GPIO
	ath_gpio_out_val(AP_USB_1_LED_GPIO, USB_1_LED_OFF);
	#endif
	ath_gpio_out_val (TRICOLOR_LED_GREEN_PIN, OFF);
	
	/* for USB 3G by lyj, 31Aug11 */
	#ifdef USB_POWER_SW_GPIO
	ath_gpio_out_val(USB_POWER_SW_GPIO, USB_POWER_ON);
	#endif
	#ifdef USB_1_POWER_SW_GPIO
	ath_gpio_out_val(USB_1_POWER_SW_GPIO, USB_1_POWER_ON);
	#endif

	return 0;
}
Beispiel #22
0
void ap_usb_1_led_on(void)
{
#ifdef AP_USB_1_LED_GPIO  
	ath_gpio_out_val(AP_USB_1_LED_GPIO, USB_1_LED_ON);
#endif
}
static int gpio_simple_config_led_write(struct file *file, const char *buf,
					unsigned long count, void *data)
{
	u_int32_t val;

	if (sscanf(buf, "%d", &val) != 1)
	{
        printk("\n val wrong %d\n", val);
		return -EINVAL;
    }
    printk("\n config_led_write %d \n", val);

	if (val == SIMPLE_CONFIG_ON) {
		printk("\nWPS SIMPLE_CONFIG_ON\n");
	/* WPS Success */		
		simple_config_led_state = SIMPLE_CONFIG_ON;
		OS_CANCEL_TIMER(&os_timer_t);
		WPSled=WPS_LED_ON;
		gpio_wps_other_led_off();
		ath_gpio_out_val(wps_led_gpio, WPSled);
        wps_success_func();
		OS_INIT_TIMER(NULL, &os_timer_t, wps_led_on, &os_timer_t);
		OS_SET_TIMER(&os_timer_t, 100);        
	} else if (val == SIMPLE_CONFIG_OFF) {	/* WPS failed */
		simple_config_led_state = SIMPLE_CONFIG_OFF;
		OS_CANCEL_TIMER(&os_timer_t);
		WPSled=WPS_LED_OFF;
		gpio_wps_other_led_off();
		printk("\nWPS SIMPLE_CONFIG_OFF\n");
		ath_gpio_out_val(wps_led_gpio, WPSled);
	}
    /* START ADD: c00217102 2012-8-12 FOR WS323 */
    else if (val == SIMPLE_CONFIG_OVERLAP)
    {
        
		printk("\nWPS SIMPLE_CONFIG_OVERLAP\n");
		simple_config_led_state = SIMPLE_CONFIG_OVERLAP;
        OS_CANCEL_TIMER(&os_timer_t);
		WPSled=WPS_LED_ON;
		gpio_wps_other_led_off();
		ath_gpio_out_val(wps_led_gpio, WPSled);
		OS_INIT_TIMER(NULL, &os_timer_t, wps_led_overlap, &os_timer_t);
		OS_SET_TIMER(&os_timer_t, 100);
    }else if (val == SIMPLE_CONFIG_INGRESS_ERROR)
    {
		simple_config_led_state = SIMPLE_CONFIG_INGRESS_ERROR;
        OS_CANCEL_TIMER(&os_timer_t);
		WPSled=WPS_LED_ON;
		gpio_wps_other_led_off();
		ath_gpio_out_val(wps_led_gpio, WPSled);
		printk("\nWPS SIMPLE_CONFIG_INGRESS_ERROR\n");
		OS_INIT_TIMER(NULL, &os_timer_t, wps_led_error, &os_timer_t);
		OS_SET_TIMER(&os_timer_t, 100);
    }
	else if (val == SIMPLE_CONFIG_INGRESS)
    {		
		simple_config_led_state = SIMPLE_CONFIG_INGRESS;
        OS_CANCEL_TIMER(&os_timer_t);
		WPSled=WPS_LED_ON;
		gpio_wps_other_led_off();
		ath_gpio_out_val(wps_led_gpio, WPSled);
		printk("\nWPS SIMPLE_CONFIG_INGRESS\n");
		OS_INIT_TIMER(NULL, &os_timer_t, wps_led_ingress, &os_timer_t);
		OS_SET_TIMER(&os_timer_t, 100);
    }

    /* END ADD: c00217102 2012-8-12 FOR WS323 */
    
	return count;
}
Beispiel #24
0
Datei: gpio.c Projekt: jhbsz/102
void ap_usb_host_led_off(int gpio)
{
#if defined(AP_USB1_LED_GPIO) || defined(AP_USB2_LED_GPIO)
    ath_gpio_out_val(gpio, USB_LED_OFF);
#endif
}
Beispiel #25
0
/* ioctl for reset default detection and system led switch*/
int ar7240_gpio_ioctl(struct inode *inode, struct file *file,  unsigned int cmd, unsigned long arg)
{
	int i;
	int* argp = (int *)arg;

	if (_IOC_TYPE(cmd) != AR7240_GPIO_MAGIC ||
		_IOC_NR(cmd) < AR7240_GPIO_IOCTL_BASE ||
		_IOC_NR(cmd) > AR7240_GPIO_IOCTL_MAX)
	{
		printk("type:%d nr:%d\n", _IOC_TYPE(cmd), _IOC_NR(cmd));
		printk("ar7240_gpio_ioctl:unknown command\n");
		return -1;
	}

	switch (cmd)
	{
	case AR7240_GPIO_BTN_READ:
		*argp = counter;
		counter = 0;
		break;
			
	case AR7240_GPIO_LED_READ:
		printk("\n\n");
		for (i = 0; i < ATH_GPIO_COUNT; i ++)
		{
			printk("pin%d: %d\n", i, ath_gpio_in_val(i));
		}
		printk("\n");

	#ifdef CONFIG_GPIO_DEBUG
		print_gpio_regs("");
	#endif
			
		break;
			
	case AR7240_GPIO_LED_WRITE:
		if (unlikely(bBlockWps))
			bBlockWps = 0;
		ath_gpio_out_val(SYS_LED_GPIO, *argp);	/* PB92 use gpio 1 to config switch */
		break;

	case AR7240_GPIO_USB_LED1_WRITE:
			#ifdef AP_USB_LED_GPIO
			ath_gpio_out_val(AP_USB_LED_GPIO, *argp);
			#endif
			break;
			
	case AR7240_GPIO_USB_1_LED1_WRITE:
			#ifdef AP_USB_1_LED_GPIO
			ath_gpio_out_val(AP_USB_1_LED_GPIO, *argp);
			#endif
			break;
			
	case AR7240_GPIO_USB_POWER_WRITE:
			#ifdef USB_POWER_SW_GPIO
			ath_gpio_out_val(USB_POWER_SW_GPIO, *argp);
			#endif
			break;

	case AR7240_GPIO_USB_1_POWER_WRITE:
			#ifdef USB_1_POWER_SW_GPIO
			ath_gpio_out_val(USB_1_POWER_SW_GPIO, *argp);
			#endif
			break;
			
	default:
		printk("command not supported\n");
		return -1;
	}


	return 0;
}
Beispiel #26
0
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 CONFIG_MUX_RESET_WPS_BUTTON
	/* added by zjg, 12Apr10 */
	multi_use_reset_button_entry = create_proc_entry ("multi_use_reset_button", 0644,
                                                      simple_config_entry);
    if (!multi_use_reset_button_entry)
        return -ENOENT;

    multi_use_reset_button_entry->write_proc	= multi_use_reset_button_write;
    multi_use_reset_button_entry->read_proc 	= multi_use_reset_button_read;
	/* end added */
#endif

    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;

	/* for usb led blink */
	usb_led_blink_entry = create_proc_entry ("usb_blink", 0666,
                                                      simple_config_entry);
	if (!usb_led_blink_entry)
		return -ENOENT;
	
    usb_led_blink_entry->write_proc = usb_led_blink_write;
    usb_led_blink_entry->read_proc = usb_led_blink_read;


	wifi_button_entry = create_proc_entry ("wifi_button", 0644,
							simple_config_entry);
	if(!wifi_button_entry)
		return -ENOENT;

	wifi_button_entry->write_proc = wifi_button_wirte;
	wifi_button_entry->read_proc = wifi_button_read;

	/* if no usb, no need to init usb power proc entry */
#ifndef CONFIG_NO_USB	
	/*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

	/* configure gpio as outputs */
    ath_gpio_config_output (TRICOLOR_LED_GREEN_PIN); 
    //ar7240_gpio_config_output (TRICOLOR_LED_YELLOW_PIN); 

	/* switch off the led */
	/* TRICOLOR_LED_GREEN_PIN is poll up, so ON is OFF modified by tiger 09/07/15 */
    ath_gpio_out_val(TRICOLOR_LED_GREEN_PIN, ON);
    //ar7240_gpio_out_val(TRICOLOR_LED_YELLOW_PIN, OFF);

	return 0;
}
Beispiel #27
0
Datei: gpio.c Projekt: jhbsz/102
int __init ath_simple_config_init(void)
{
#ifdef CONFIG_CUS100
	u32 mask = 0;
#endif

#ifdef JUMPSTART_GPIO
	int req;
#endif
	int ret;
#ifdef AP_RESET_GPIO
    int req2;
#endif
	ret = misc_register(&athfr_miscdev);

	if (ret < 0) {
		printk("*** ath misc_register failed %d *** \n", ret);
		return -1;
	}

#ifdef AP_RESET_GPIO
    ath_gpio_config_input(AP_RESET_GPIO);
    ath_gpio_config_int(AP_RESET_GPIO, INT_TYPE_LEVEL, INT_POL_ACTIVE_LOW);
    printk("%s (%s) AP_RESET_GPIO: %d\n", __FILE__, __func__, AP_RESET_GPIO);
#endif

#ifdef JUMPSTART_GPIO
#ifdef CONFIG_CUS100
	mask = ath_reg_rd(ATH_MISC_INT_MASK);
	ath_reg_wr(ATH_MISC_INT_MASK, mask | (1 << 2));
	ath_gpio_config_int(JUMPSTART_GPIO, INT_TYPE_LEVEL,
				INT_POL_ACTIVE_HIGH);
	ath_gpio_intr_enable(JUMPSTART_GPIO);
	ath_gpio_config_input(JUMPSTART_GPIO);
#else
	ath_gpio_config_input(JUMPSTART_GPIO);
	/* configure Jumpstart GPIO as level triggered interrupt */
	ath_gpio_config_int(JUMPSTART_GPIO, INT_TYPE_LEVEL,
				INT_POL_ACTIVE_LOW);
	printk("%s (%s) JUMPSTART_GPIO: %d\n", __FILE__, __func__,
		JUMPSTART_GPIO);
#ifndef CONFIG_MACH_AR934x
	ath_reg_rmw_clear(ATH_GPIO_FUNCTIONS, (1 << 2));
	ath_reg_rmw_clear(ATH_GPIO_FUNCTIONS, (1 << 16));
	ath_reg_rmw_clear(ATH_GPIO_FUNCTIONS, (1 << 20));
#endif
#endif

	req = request_irq(ATH_GPIO_IRQn(JUMPSTART_GPIO), jumpstart_irq, 0,
#ifdef AP_RESET_GPIO
			"SW JUMPSTART", NULL);
#else
			"SW JUMPSTART/FACTORY RESET", NULL);
#endif
	if (req != 0) {
		printk("request_irq for jumpstart failed (error %d)\n", req);
		misc_deregister(&athfr_miscdev);
		ath_gpio_intr_shutdown(ATH_GPIO_IRQn(JUMPSTART_GPIO));
		return -1;
	}
#endif /* #ifdef JUMPSTART_GPIO */
#ifdef AP_RESET_GPIO
    req2 = request_irq(ATH_GPIO_IRQn(AP_RESET_GPIO), ath_reset_irq, 0,
            "FACTORY RESET", NULL);
    if (req2 != 0) {
        printk("request_irq for factory reset failed (error %d)\n", req);
        misc_deregister(&athfr_miscdev);
        free_irq(req, NULL);
        return -1;
    }
#endif

#ifdef ATH_S17INT_GPIO
    ath_gpio_config_input(ATH_S17INT_GPIO);
	/* configure S17 interrupt GPIO as level triggered interrupt */
	ath_gpio_config_int(ATH_S17INT_GPIO, INT_TYPE_LEVEL,
				INT_POL_ACTIVE_LOW);
	printk("%s (%s) ATH_S17INT_GPIO: %d\n", __FILE__, __func__,
		ATH_S17INT_GPIO);
#endif

#if !defined(CONFIG_I2S) && defined(AP_USB_LED_GPIO)
	ath_gpio_config_output(AP_USB_LED_GPIO);
#endif
	init_waitqueue_head(&ath_fr_wq);

#ifdef WPS_LED_GPIO
	create_simple_config_led_proc_entry();
#endif

#ifdef POWER_ON_GLED_GPIO
	printk("%s (%s) POWER_ON_GLED_GPIO: %d\n", __FILE__, __func__, POWER_ON_GLED_GPIO);
    ath_gpio_config_output(POWER_ON_GLED_GPIO);
    ath_gpio_out_val(POWER_ON_GLED_GPIO, POWER_LED_ON);
#endif

#ifdef POWER_ON_RLED_GPIO
	printk("%s (%s) POWER_ON_RLED_GPIO: %d\n", __FILE__, __func__, POWER_ON_RLED_GPIO);
    ath_gpio_config_output(POWER_ON_RLED_GPIO);
    ath_gpio_out_val(POWER_ON_RLED_GPIO, POWER_LED_OFF);
    OS_INIT_TIMER(NULL, &power_on_timer, power_led_blink, NULL);
    OS_SET_TIMER(&power_on_timer, POWER_LED_BLINK_INTERVAL);
#endif

	return 0;
}