int __init ath_simple_config_init(void)
{
#if 0

#ifdef CONFIG_CUS100
	u32 mask = 0;
#endif
	int req, ret;

	ret = misc_register(&athfr_miscdev);

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

#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 JUMPSTART_GPIO: %d\n", __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,
			"SW JUMPSTART/FACTORY RESET", NULL);
	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;
	}
#if !defined(CONFIG_I2S) && defined(AP_USB_LED_GPIO)
	ath_gpio_config_output(AP_USB_LED_GPIO);
#endif
	init_waitqueue_head(&ath_fr_wq);


#endif
	create_simple_config_led_proc_entry();

	return 0;
}
Beispiel #2
0
Datei: wdt.c Projekt: jhbsz/102
int __init athwdt_init(void)
{
	int		ret;
	uint32_t	*sram = KSEG1ADDR(ATH_SRAM_BASE + 0x934);

	extern void ath_gpio_config_input(int);
#ifdef CONFIG_MACH_AR934x
	extern void athwdt_timer_init(void);
#endif

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

	if (ath_reg_rd(RST_WATCHDOG_TIMER_CONTROL_ADDRESS) &
		RST_WATCHDOG_TIMER_CONTROL_LAST_MASK) {
		*sram = (*sram + 1);
		printk("Watchdog Reset count: %u\n", *sram);
	} else {
		*sram = 0;
	}


#ifdef CONFIG_MACH_AR934x
	athwdt_timer_init();
#endif
	ath_gpio_config_input(ATH_GPIO_RESET);

	return 0;
}
Beispiel #3
0
Datei: gpio.c Projekt: jhbsz/102
void ath_config_slave_mdio_gpios(void)
{
	unsigned int mask;

	/* Slave MDIO phy address setting */
	ath_reg_wr(MDIO_PHY_ADDR_ADDRESS, ATH_MDIO_PHY_ADDR);

	/* Set the Clock Divisor */
	mask = ath_reg_rd(ATH_MDIO_MAC_MII_MGMT_CFG) & ~(0xf);
	mask |= ATH_MDIO_MGMT_CFG_CLK_DIV_28;
	ath_reg_wr(ATH_MDIO_MAC_MII_MGMT_CFG, mask);

#ifndef CONFIG_MACH_QCA956x
	/* Set External MDIO Multiplexing Register */
	mask = ath_reg_rd(ATH_GPIO_IN_ENABLE3) &
		~(GPIO_IN_ENABLE3_BOOT_EXT_MDC_MASK |
		GPIO_IN_ENABLE3_BOOT_EXT_MDO_MASK);
	mask |= GPIO_IN_ENABLE3_BOOT_EXT_MDC_SET(ATH_MDC_GPIO_PIN) |
		GPIO_IN_ENABLE3_BOOT_EXT_MDO_SET(ATH_MDIO_GPIO_PIN);
	ath_reg_wr(ATH_GPIO_IN_ENABLE3, mask);
#endif
	/* Configure the Direction of GPIO Pins */
	ath_gpio_config_input(ATH_MDC_GPIO_PIN);
	ath_gpio_config_output(ATH_MDIO_GPIO_PIN);
	/* Configure GPIO Output function as GPIOs */
	ath_gpio_set_fn(ATH_MDIO_GPIO_PIN, ATH_MDIO_OUPUT_FUNC);
}
Beispiel #4
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);
    }
}
Beispiel #5
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 #6
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;
}